# HG changeset patch # User Luke Schierer # Date 1038937843 0 # Node ID 89b56ab2b6927da769a0738adc3de82b8fa46e93 # Parent 630826d97d54abc852afd9e0b491a2f3a490834f [gaim-migrate @ 4248] faceprint got jabber registration working again :-) committer: Tailor Script diff -r 630826d97d54 -r 89b56ab2b692 src/multi.c --- a/src/multi.c Tue Dec 03 06:10:42 2002 +0000 +++ b/src/multi.c Tue Dec 03 17:50:43 2002 +0000 @@ -397,8 +397,11 @@ } else { if(p->register_user != NULL && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(u->register_user)) == TRUE) { - + ref_protocol(p); p->register_user(a); + /* we don't unref the protocol because register user has callbacks + * that need to get called first, then they will unref the protocol + * appropriately */ } } diff -r 630826d97d54 -r 89b56ab2b692 src/prpl.c --- a/src/prpl.c Tue Dec 03 06:10:42 2002 +0000 +++ b/src/prpl.c Tue Dec 03 17:50:43 2002 +0000 @@ -756,7 +756,7 @@ { struct _prpl_smiley *smiley; - smiley = (struct _prpl_smiley *)g_new0(struct _prpl_smiley, 1); + smiley = (struct _prpl_smiley *)g_new0(struct _prpl_smiley, 1); smiley->key = g_strdup(key); smiley->xpm = xpm; smiley->show = show; @@ -764,3 +764,38 @@ return list; } + +static gboolean delayed_unload(void *handle) { + g_module_close(handle); + return FALSE; +} + +gboolean ref_protocol(struct prpl *p) { +#ifdef GAIM_PLUGINS + if(p->plug) { /* This protocol is a plugin */ + prpl_accounts[p->protocol]++; + debug_printf("Protocol %s now in use by %d connections.\n", p->name, prpl_accounts[p->protocol]); + if(!p->plug->handle) { /*But the protocol isn't yet loaded */ + unload_protocol(p); + if (load_prpl(p)) + return FALSE; + } + } +#endif /* GAIM_PLUGINS */ + return TRUE; +} + +void unref_protocol(struct prpl *p) { +#ifdef GAIM_PLUGINS + if(p->plug) { /* This protocol is a plugin */ + prpl_accounts[p->protocol]--; + debug_printf("Protocol %s now in use by %d connections.\n", p->name, prpl_accounts[p->protocol]); + if(prpl_accounts[p->protocol] == 0) { /* No longer needed */ + debug_printf("Throwing out %s protocol plugin\n", p->name); + g_timeout_add(0, delayed_unload, p->plug->handle); + p->plug->handle = NULL; + } + } +#endif /* GAIM_PLUGINS */ +} + diff -r 630826d97d54 -r 89b56ab2b692 src/prpl.h --- a/src/prpl.h Tue Dec 03 06:10:42 2002 +0000 +++ b/src/prpl.h Tue Dec 03 17:50:43 2002 +0000 @@ -237,4 +237,8 @@ int transfer_get_file_info(struct file_transfer *xfer, int *size, char **name); +/* stuff to load/unload PRPLs as necessary */ +extern gboolean ref_protocol(struct prpl *p); +extern void unref_protocol(struct prpl *p); + #endif /* _PRPL_H_ */ diff -r 630826d97d54 -r 89b56ab2b692 src/server.c --- a/src/server.c Tue Dec 03 06:10:42 2002 +0000 +++ b/src/server.c Tue Dec 03 17:50:43 2002 +0000 @@ -43,21 +43,12 @@ void serv_login(struct aim_user *user) { struct prpl *p = find_prpl(user->protocol); - + if (user->gc != NULL || p == NULL) return; -#ifdef GAIM_PLUGINS - if (p->plug) { /* This protocol is a plugin */ - prpl_accounts[p->protocol]++; - debug_printf("Protocol %s is now being used by %d connections.\n", p->name, prpl_accounts[p->protocol]); - if (!p->plug->handle) { /* But the protocol isn't yet loaded. */ - unload_protocol(p); /* Unload it to free the old name and options */ - if (load_prpl(p)) /* And load the plugin */ - return; - } - } -#endif + if(!ref_protocol(p)) + return; if (p->login) { if (!strlen(user->password) && !(p->options & OPT_PROTO_NO_PASSWORD) && @@ -95,11 +86,6 @@ } } -static gboolean delayed_unload(void *handle) { - g_module_close(handle); - return FALSE; -} - void serv_close(struct gaim_connection *gc) { struct prpl *prpl; @@ -118,23 +104,12 @@ if (gc->prpl && gc->prpl->close) gc->prpl->close(gc); - + prpl = gc->prpl; account_offline(gc); destroy_gaim_conn(gc); -#ifdef GAIM_PLUGINS - if (prpl->plug) { /* This is a plugin */ - prpl_accounts[prpl->protocol]--; - debug_printf("Prpl %s is now being used by %d accounts\n", prpl->name, prpl_accounts[prpl->protocol]); - if (prpl_accounts[prpl->protocol] == 0) { /* We don't need this protocol anymore */ - debug_printf("Throwing out prpl %s\n", prpl->name); - g_timeout_add(0,delayed_unload, prpl->plug->handle); - prpl->plug->handle = NULL; - } - } -#endif - + unref_protocol(prpl); } void serv_touch_idle(struct gaim_connection *gc)