New module loading scheme
authorMyhailo Danylenko <isbear@ukrpost.net>
Thu, 04 Mar 2010 19:53:29 +0200
changeset 18 fbe6977b37cc
parent 17 4a7cf0f5e85c
child 19 9ce7690c4dab
New module loading scheme
CMakeLists.txt
README
pep.c
pep.rc
--- a/CMakeLists.txt	Mon Feb 15 18:52:58 2010 +0200
+++ b/CMakeLists.txt	Thu Mar 04 19:53:29 2010 +0200
@@ -22,11 +22,9 @@
 ## Check for build dependencies
 find_package(PkgConfig REQUIRED) 
 pkg_check_modules(GLIB REQUIRED glib-2.0) 
-pkg_check_modules(GMODULE REQUIRED gmodule-2.0) 
 pkg_check_modules(LM REQUIRED loudmouth-1.0) 
 pkg_check_modules(MCABBER REQUIRED mcabber)
 link_directories(${GLIB_LIBRARY_DIRS}
-				 ${GMODULE_LIBRARY_DIRS}
 				 ${LM_LIBRARY_DIRS}
 				 ${MCABBER_LIBRARY_DIRS})
 
@@ -35,11 +33,9 @@
 
 ## Compiler setup
 include_directories(SYSTEM ${GLIB_INCLUDE_DIRS} 
-                    ${GMODULE_INCLUDE_DIRS} 
                     ${LM_INCLUDE_DIRS}
 					${MCABBER_INCLUDE_DIRS})
 target_link_libraries(pep ${GLIB_LIBRARIES} 
-                      ${GMODULE_LIBRARIES}
 					  ${LM_LIBRARIES}
 					  ${MCABBER_LIBRARIES})
 include_directories(${pep_SOURCE_DIR} 
--- a/README	Mon Feb 15 18:52:58 2010 +0200
+++ b/README	Thu Mar 04 19:53:29 2010 +0200
@@ -2,16 +2,8 @@
 This is a pep module for mcabber. It just provides common message
 listener for other modules like tune, avatar etc.
 
-This module have no options, just load it before loading modules,
-that depend on it.
-
-Note, that you must not unload this module, while other modules,
-that depend on it are loaded! This may cause segfault. In fact,
-if you by accident did that, you can load module back and avoid
-segfault, but you need to reload other modules to re-register
-their callbacks to this module. Segfault will happen, if you'll
-try to load/unload depending module while this is not loaded.
-I'll try to do something about that, but for now be careful.
+This module have no options, and generally should be loaded
+automatically by other modules.
 
 INSTALLATION
 
--- a/pep.c	Mon Feb 15 18:52:58 2010 +0200
+++ b/pep.c	Thu Mar 04 19:53:29 2010 +0200
@@ -20,15 +20,25 @@
  */
 
 #include <glib.h>
-#include <gmodule.h>
 #include <loudmouth/loudmouth.h>
 #include <string.h>
 
 #include <mcabber/xmpp.h>
 #include <mcabber/hooks.h>
+#include <mcabber/modules.h>
 
 #include "pep.h"
 
+static void pep_init   (void);
+static void pep_uninit (void);
+
+module_info_t info_pep = {
+	.mcabber_version = "0.10.0",
+	.requires        = NULL,
+	.init            = pep_init,
+	.uninit          = pep_uninit,
+};
+
 typedef struct pep_handler_struct pep_handler_t;
 
 struct pep_handler_struct {
@@ -167,7 +177,7 @@
 		pep_unregister_handlers ();
 }
 
-const gchar *g_module_check_init (GModule *module)
+static void pep_init (void)
 {
 	// create handlers
 	pep_message_handler = lm_message_handler_new (pep_message_event_handler, NULL, NULL);
@@ -178,11 +188,9 @@
 
 	// register handlers to connection
 	pep_register_handlers ();
-
-	return NULL;
 }
 
-void g_module_unload (GModule *module)
+static void pep_uninit (void)
 {
 	// release handlers
 	pep_unregister_handlers ();
--- a/pep.rc	Mon Feb 15 18:52:58 2010 +0200
+++ b/pep.rc	Thu Mar 04 19:53:29 2010 +0200
@@ -1,3 +1,3 @@
 
-load pep
+module load pep