637 |
637 |
638 g_io_add_watch_full (channel, G_PRIORITY_HIGH_IDLE, G_IO_IN|G_IO_HUP|G_IO_ERR, (GIOFunc) lua_bgread_callback, cb, (GDestroyNotify) lua_bgread_callback_destroy); |
638 g_io_add_watch_full (channel, G_PRIORITY_HIGH_IDLE, G_IO_IN|G_IO_HUP|G_IO_ERR, (GIOFunc) lua_bgread_callback, cb, (GDestroyNotify) lua_bgread_callback_destroy); |
639 return 0; |
639 return 0; |
640 } |
640 } |
641 |
641 |
642 // BUDDY |
|
643 |
|
644 #if 0 |
|
645 static int lua_buddy_name (lua_State *L) |
|
646 { |
|
647 lua_buddy_t *buddy = luaL_checkbuddy (L, 1); |
|
648 if (lua_gettop (L) > 1) { // Set |
|
649 const char *name = luaL_checkstring (L, 2); |
|
650 buddy_setname (buddy->obj, name); |
|
651 return 0; |
|
652 } else { // Get |
|
653 const char *name = buddy_getname (buddy->obj); |
|
654 if (name) |
|
655 lua_pushstring (L, name); |
|
656 else |
|
657 lua_pushnil (L); |
|
658 return 1; |
|
659 } |
|
660 } |
|
661 #endif |
|
662 |
|
663 // MAIN INITIALIZATION CODE |
642 // MAIN INITIALIZATION CODE |
664 |
643 |
665 #ifdef LLM_LOG_HANDLER |
644 #ifdef LLM_LOG_HANDLER |
666 // FIXME: this should not be here |
645 // FIXME: this should not be here |
667 guint lua_lm_log_handler_id; |
646 guint lua_lm_log_handler_id; |
743 reg ( bgread ) |
722 reg ( bgread ) |
744 { NULL, NULL }, |
723 { NULL, NULL }, |
745 }; |
724 }; |
746 #undef reg |
725 #undef reg |
747 |
726 |
748 #if 0 |
|
749 #define reg(name) \ |
|
750 { #NAME, lua_buddy_##NAME }, |
|
751 static const luaL_Reg lua_reg_buddy[] = { |
|
752 reg ( jid ) |
|
753 reg ( group ) |
|
754 reg ( name ) |
|
755 reg ( nick ) |
|
756 reg ( in_room ) |
|
757 reg ( topic ) |
|
758 reg ( printstatus ) |
|
759 reg ( autowhois ) |
|
760 reg ( type ) |
|
761 reg ( subscription ) |
|
762 reg ( status ) |
|
763 reg ( message ) |
|
764 reg ( time ) |
|
765 reg ( priority ) |
|
766 reg ( events ) |
|
767 reg ( caps ) |
|
768 reg ( role ) |
|
769 reg ( realjid ) |
|
770 reg ( flags ) |
|
771 reg ( onserver ) |
|
772 reg ( resources ) |
|
773 { "__gc", lua_buddy_gc }, |
|
774 { NULL, NULL }, |
|
775 }; |
|
776 #undef reg |
|
777 #endif |
|
778 |
|
779 #if 0 |
|
780 static const luaL_Reg lua_reg_roster[] = { |
|
781 { "__index", lua_roster_index }, |
|
782 { "__newindex", lua_roster_newindex }, |
|
783 { "__len", lua_roster_len }, |
|
784 { NULL, NULL }, |
|
785 }; |
|
786 #endif |
|
787 |
|
788 const gchar *g_module_check_init (GModule *module) |
727 const gchar *g_module_check_init (GModule *module) |
789 { |
728 { |
790 lua = lua_newstate (lua_alloc, NULL); |
729 lua = lua_newstate (lua_alloc, NULL); |
791 if (!lua) { |
730 if (!lua) { |
792 scr_LogPrint (LPRINT_LOGNORM, "lua: Initialization error"); |
731 scr_LogPrint (LPRINT_LOGNORM, "lua: Initialization error"); |
798 luaL_register (lua, "main", lua_reg_main); |
737 luaL_register (lua, "main", lua_reg_main); |
799 lua_pop (lua, 1); // XXX |
738 lua_pop (lua, 1); // XXX |
800 lua_register (lua, "dopath", lua_global_dopath); |
739 lua_register (lua, "dopath", lua_global_dopath); |
801 lua_register (lua, "print", lua_global_print ); |
740 lua_register (lua, "print", lua_global_print ); |
802 |
741 |
803 #if 0 |
742 cmd_add ("lua", "Evaluate lua string", 0, 0, (void (*) (char *p)) do_lua, lua); |
804 lua_newtable (lua); |
|
805 luaL_newmetatable (lua, "mcabber.roster"); |
|
806 luaL_register (lua, NULL, lua_reg_roster); |
|
807 lua_setmetatable (lua, -2); |
|
808 lua_setglobal (lua, "roster"); |
|
809 |
|
810 lua_newuserdata (lua,1); |
|
811 luaL_newmetatable (lua, "mcabber.buddy"); |
|
812 luaL_register (lua, NULL, lua_reg_buddy); |
|
813 #endif |
|
814 |
|
815 cmd_add ("lua", "", 0, 0, (void (*) (char *p)) do_lua, lua); |
|
816 |
743 |
817 #ifdef LLM_LOG_HANDLER |
744 #ifdef LLM_LOG_HANDLER |
818 // FIXME: this should not be here. |
745 // FIXME: this should not be here. |
819 lua_lm_log_handler_id = g_log_set_handler ("lua-lm", G_LOG_LEVEL_MASK, (GLogFunc) lua_lm_log_handler, NULL); |
746 lua_lm_log_handler_id = g_log_set_handler ("lua-lm", G_LOG_LEVEL_MASK, (GLogFunc) lua_lm_log_handler, NULL); |
820 #endif |
747 #endif |