# HG changeset patch # User Paul Aurich # Date 1268167991 0 # Node ID 93d32ecf3186bbba8cd32ecc6a2d4069a441dc4f # Parent d93676b59db13b185d52006b49f776d3eca036eb jabber: Only initialize SASL once, too. A lot of these have moved from plugin init to plugin load time. There's not much that happens between then, but this could in theory cause issues. diff -r d93676b59db1 -r 93d32ecf3186 libpurple/protocols/jabber/jabber.c --- a/libpurple/protocols/jabber/jabber.c Tue Mar 09 19:09:37 2010 +0000 +++ b/libpurple/protocols/jabber/jabber.c Tue Mar 09 20:53:11 2010 +0000 @@ -3539,6 +3539,36 @@ const gchar *type = "pc"; /* default client type, if unknown or unspecified */ const gchar *ui_name = NULL; +#ifdef HAVE_CYRUS_SASL + /* We really really only want to do this once per process */ + static gboolean sasl_initialized = FALSE; +#ifdef _WIN32 + UINT old_error_mode; + gchar *sasldir; +#endif + int ret; +#endif + + /* XXX - If any other plugin wants SASL this won't be good ... */ +#ifdef HAVE_CYRUS_SASL + if (!sasl_initialized) { + sasl_initialized = TRUE; +#ifdef _WIN32 + sasldir = g_build_filename(wpurple_install_dir(), "sasl2", NULL); + sasl_set_path(SASL_PATH_TYPE_PLUGIN, sasldir); + g_free(sasldir); + /* Suppress error popups for failing to load sasl plugins */ + old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS); +#endif + if ((ret = sasl_client_init(NULL)) != SASL_OK) { + purple_debug_error("xmpp", "Error (%d) initializing SASL.\n", ret); + } +#ifdef _WIN32 + /* Restore the original error mode */ + SetErrorMode(old_error_mode); +#endif + } +#endif jabber_cmds = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, cmds_free_func); diff -r d93676b59db1 -r 93d32ecf3186 libpurple/protocols/jabber/libxmpp.c --- a/libpurple/protocols/jabber/libxmpp.c Tue Mar 09 19:09:37 2010 +0000 +++ b/libpurple/protocols/jabber/libxmpp.c Tue Mar 09 20:53:11 2010 +0000 @@ -249,13 +249,6 @@ static void init_plugin(PurplePlugin *plugin) { -#ifdef HAVE_CYRUS_SASL -#ifdef _WIN32 - UINT old_error_mode; - gchar *sasldir; -#endif - int ret; -#endif PurpleAccountUserSplit *split; PurpleAccountOption *option; @@ -315,24 +308,6 @@ purple_prefs_remove("/plugins/prpl/jabber"); - /* XXX - If any other plugin wants SASL this won't be good ... */ -#ifdef HAVE_CYRUS_SASL -#ifdef _WIN32 - sasldir = g_build_filename(wpurple_install_dir(), "sasl2", NULL); - sasl_set_path(SASL_PATH_TYPE_PLUGIN, sasldir); - g_free(sasldir); - /* Suppress error popups for failing to load sasl plugins */ - old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS); -#endif - if ((ret = sasl_client_init(NULL)) != SASL_OK) { - purple_debug_error("xmpp", "Error (%d) initializing SASL.\n", ret); - } -#ifdef _WIN32 - /* Restore the original error mode */ - SetErrorMode(old_error_mode); -#endif -#endif - purple_signal_connect(purple_get_core(), "uri-handler", plugin, PURPLE_CALLBACK(xmpp_uri_handler), NULL); }