New module loading scheme
authorMyhailo Danylenko <isbear@ukrpost.net>
Thu, 04 Mar 2010 19:50:02 +0200
changeset 23 2b7060ce1152
parent 22 4f45c246856c
child 24 7aa499342e2b
New module loading scheme
CMakeLists.txt
README
avatar.c
avatar.rc
--- a/CMakeLists.txt	Mon Feb 22 23:25:24 2010 +0200
+++ b/CMakeLists.txt	Thu Mar 04 19:50:02 2010 +0200
@@ -22,7 +22,6 @@
 ## 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(PNG REQUIRED libpng)
 pkg_check_modules(MCABBER REQUIRED mcabber)
@@ -41,7 +40,6 @@
 set(CMAKE_REQUIRED_FLAGS ${LM_LDFLAGS} ${LM_CFLAGS})
 check_symbol_exists(lm_connection_unregister_reply_handler loudmouth/loudmouth.h HAVE_LM_CONNECTION_UNREGISTER_REPLY_HANDLER)
 link_directories(${GLIB_LIBRARY_DIRS}
-				 ${GMODULE_LIBRARY_DIRS}
 				 ${LM_LIBRARY_DIRS}
 				 ${PNG_LIBRARY_DIRS}
 				 ${AALIB_LIBRARY_DIRS}
@@ -53,13 +51,11 @@
 ## Compiler setup
 configure_file(config.h.in config.h)
 include_directories(SYSTEM ${GLIB_INCLUDE_DIRS} 
-                    ${GMODULE_INCLUDE_DIRS} 
                     ${LM_INCLUDE_DIRS}
 					${PNG_INCLUDE_DIRS}
 					${AALIB_INCLUDE_DIRS}
                     ${MCABBER_INCLUDE_DIRS})
 target_link_libraries(avatar ${GLIB_LIBRARIES}
-                      ${GMODULE_LIBRARIES}
 					  ${LM_LIBRARIES}
 					  ${PNG_LIBRARIES}
 					  ${AALIB_LIBRARIES}
--- a/README	Mon Feb 22 23:25:24 2010 +0200
+++ b/README	Thu Mar 04 19:50:02 2010 +0200
@@ -4,8 +4,7 @@
 and provides command '/avatar' to publish your own. But this is not all.
 It also will show you buddy's avatar! Yes, it is aalib :)
 
-This module depends on module 'pep'. You must load it prior to this module
-and not unload until you unload this module.
+This module depends on module 'pep'.
 
 For this module to actually do something you should set option
 avatars_directory - a place, where your buddy's avatars will be saved.
--- a/avatar.c	Mon Feb 22 23:25:24 2010 +0200
+++ b/avatar.c	Thu Mar 04 19:50:02 2010 +0200
@@ -22,7 +22,6 @@
 #define PNG_USER_MEM_SUPPORTED
 
 #include <glib.h>
-#include <gmodule.h>
 #include <loudmouth/loudmouth.h>
 #include <aalib.h>
 #include <png.h>
@@ -42,11 +41,27 @@
 #include <mcabber/hbuf.h>
 #include <mcabber/hooks.h>
 #include <mcabber/settings.h>
+#include <mcabber/modules.h>
 
 #include <mcabber/pep.h>
 
 #include "config.h"
 
+// module description
+
+static void avatar_init   (void);
+static void avatar_uninit (void);
+
+static const gchar *deps[] = { "pep", NULL };
+module_info_t info_avatar = {
+	.mcabber_version = "0.10.0",
+	.requires        = deps,
+	.init            = avatar_init,
+	.uninit          = avatar_uninit,
+};
+
+// globals
+
 #define NS_AVATAR_DATA            ( "urn:xmpp:avatar:data"            )
 #define NS_AVATAR_METADATA        ( "urn:xmpp:avatar:metadata"        )
 #define NS_AVATAR_METADATA_NOTIFY ( "urn:xmpp:avatar:metadata+notify" )
@@ -1126,7 +1141,7 @@
 	}
 }
 
-const gchar *g_module_check_init (GModule *module)
+static void avatar_init (void)
 {
 	pep_register_xmlns_handler (NS_AVATAR_METADATA, avatar_handler, NULL, NULL);
 	avatar_metadata_reply_handler = lm_message_handler_new (avatar_publish_metadata_reply_handler, NULL, NULL);
@@ -1137,11 +1152,9 @@
 
 	xmpp_add_feature (NS_AVATAR_METADATA);
 	xmpp_add_feature (NS_AVATAR_METADATA_NOTIFY);
-
-	return NULL;
 }
 
-void g_module_unload (GModule *module)
+static void avatar_uninit (void)
 {
 	xmpp_del_feature (NS_AVATAR_METADATA);
 	xmpp_del_feature (NS_AVATAR_METADATA_NOTIFY);
--- a/avatar.rc	Mon Feb 22 23:25:24 2010 +0200
+++ b/avatar.rc	Thu Mar 04 19:50:02 2010 +0200
@@ -26,6 +26,5 @@
 # changes resulting image a bit)
 set avatar_background = 255
 
-load pep
-load avatar
+module load avatar