From cf7a2f65cf2d84ecdc743c19f07af77dae5b922c Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Tue, 23 Mar 2010 12:25:30 +0200 Subject: [PATCH] core cleanup: introduce core init/destroy functions Moved non-libpurple code from purple plugin to new functions --- src/api/sipe-core-api.h | 6 +++--- src/core/sip-sec.c | 1 - src/core/sip-sec.h | 7 +++++++ src/core/sipe.c | 23 +++++++++++++++++++++++ src/purple/Makefile.am | 5 ++--- src/purple/purple-plugin.c | 29 ++++++----------------------- 6 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/api/sipe-core-api.h b/src/api/sipe-core-api.h index 3ae1dbe3..005d2959 100644 --- a/src/api/sipe-core-api.h +++ b/src/api/sipe-core-api.h @@ -21,8 +21,8 @@ */ /** - * Initialize & destroy functions for sip-sec. + * Initialize & destroy functions for the SIPE core * Should be called on loading and unloading of the plugin. */ -void sip_sec_init(void); -void sip_sec_destroy(void); +void sipe_core_init(void); +void sipe_core_destroy(void); diff --git a/src/core/sip-sec.c b/src/core/sip-sec.c index f97f6da3..9b146171 100644 --- a/src/core/sip-sec.c +++ b/src/core/sip-sec.c @@ -34,7 +34,6 @@ #include "sip-sec.h" #include "sipe-backend-debug.h" -#include "sipe-core-api.h" #include "sipe-utils.h" #include "sip-sec-mech.h" diff --git a/src/core/sip-sec.h b/src/core/sip-sec.h index 73a7ce9d..b148eef9 100644 --- a/src/core/sip-sec.h +++ b/src/core/sip-sec.h @@ -138,3 +138,10 @@ char *sip_sec_make_signature(SipSecContext context, int sip_sec_verify_signature(SipSecContext context, const char *message, const char *signature_hex); + +/** + * Initialize & destroy functions for sip-sec. + * Should be called on loading and unloading of the core. + */ +void sip_sec_init(void); +void sip_sec_destroy(void); diff --git a/src/core/sipe.c b/src/core/sipe.c index fb956578..fee7ead3 100644 --- a/src/core/sipe.c +++ b/src/core/sipe.c @@ -38,6 +38,7 @@ #endif #ifdef _WIN32 +#include "win32dep.h" /* for LOCALEDIR */ #ifdef _DLL #define _WS2TCPIP_H_ #define _WINSOCK2API_ @@ -52,6 +53,7 @@ #endif /* _WIN32 */ #include +#include #include #include #include @@ -89,9 +91,11 @@ #include "sipmsg.h" #include "sip-csta.h" #include "sip-sec.h" +#include "sipe-backend-debug.h" #include "sipe-cal.h" #include "sipe-chat.h" #include "sipe-conf.h" +#include "sipe-core-api.h" #include "sipe-dialog.h" #include "sipe-ews.h" #include "sipe-ft.h" @@ -10128,6 +10132,25 @@ PurplePluginInfo info = { NULL }; +void sipe_core_init(void) +{ + srand(time(NULL)); + sip_sec_init(); + +#ifdef ENABLE_NLS + SIPE_DEBUG_INFO("bindtextdomain = %s", + bindtextdomain(PACKAGE_NAME, LOCALEDIR)); + SIPE_DEBUG_INFO("bind_textdomain_codeset = %s", + bind_textdomain_codeset(PACKAGE_NAME, "UTF-8")); + textdomain(PACKAGE_NAME); +#endif +} + +void sipe_core_destroy(void) +{ + sip_sec_destroy(); +} + /* Local Variables: mode: c diff --git a/src/purple/Makefile.am b/src/purple/Makefile.am index 70aae374..2552b272 100644 --- a/src/purple/Makefile.am +++ b/src/purple/Makefile.am @@ -20,8 +20,7 @@ libsipe_la_CFLAGS = \ $(GLIB_CFLAGS) \ $(LOCALE_CPPFLAGS) \ $(PURPLE_CFLAGS) \ - -I$(srcdir)/../api \ - -I$(srcdir)/../core + -I$(srcdir)/../api libsipe_la_LDFLAGS = \ -module -avoid-version -no-undefined @@ -40,7 +39,7 @@ endif check_PROGRAMS = tests tests_SOURCES = tests.c purple-debug.c -tests_CFLAGS = $(libsipe_la_CFLAGS) +tests_CFLAGS = $(libsipe_la_CFLAGS) -I$(srcdir)/../core tests_LDADD = ../core/libsipe_core.la ../core/libsipe_core_purple.la tests_LDFLAGS = $(PURPLE_LIBS) diff --git a/src/purple/purple-plugin.c b/src/purple/purple-plugin.c index 226f263c..de27ca0d 100644 --- a/src/purple/purple-plugin.c +++ b/src/purple/purple-plugin.c @@ -24,28 +24,19 @@ #include "config.h" #endif -#include -#include +#include "sipe-common.h" +/* Flag needed for correct version of PURPLE_INIT_PLUGIN() */ #ifndef PURPLE_PLUGINS #define PURPLE_PLUGINS #endif -/* for LOCALEDIR */ -#ifdef _WIN32 -#include "win32dep.h" -#endif - -#include "sipe-common.h" - #include "accountopt.h" #include "prpl.h" #include "plugin.h" -#include "sipe-nls.h" - #include "sipe-core-api.h" -#include "sipe-backend-debug.h" +#include "sipe-nls.h" #include "core-depurple.h" @@ -53,7 +44,7 @@ void sipe_plugin_destroy(SIPE_UNUSED_PARAMETER PurplePlugin *plugin) { GList *entry; - sip_sec_destroy(); + sipe_core_destroy(); entry = prpl_info.protocol_options; while (entry) { @@ -75,16 +66,8 @@ static void init_plugin(PurplePlugin *plugin) PurpleAccountUserSplit *split; PurpleAccountOption *option; - srand(time(NULL)); - sip_sec_init(); - -#ifdef ENABLE_NLS - SIPE_DEBUG_INFO("bindtextdomain = %s", - bindtextdomain(PACKAGE_NAME, LOCALEDIR)); - SIPE_DEBUG_INFO("bind_textdomain_codeset = %s", - bind_textdomain_codeset(PACKAGE_NAME, "UTF-8")); - textdomain(PACKAGE_NAME); -#endif + /* This needs to be called first */ + sipe_core_init(); purple_plugin_register(plugin); -- 2.11.4.GIT