# HG changeset patch # User Luke Schierer # Date 1088541330 0 # Node ID 66b3f54527e6199c0ebf74ad53dd90356282a00e # Parent dfee44a581a4631cf07d1b598788ba2a3bc6e3a7 [gaim-migrate @ 10245] " As discussed on #gaim (15:02:02) Paco-Paco: the ugliness of this feature trumps compatability, unless there is some pretty important functionality to be lost (15:04:02) aatharuv: Paco-Paco: Because zephyr is a silly UDP based protocol, and sometimes subscriptions (chats you've registered for) get lost, and you can tell a user to a cli tool 'zctl' which will restore the subs. (15:04:32) aatharuv: Paco-Paco: Of course, I should just add this as a protocol option, so users don't have to do that. (15:04:39) Paco-Paco: yes (15:04:50) Paco-Paco: that would be the appropriate answer (15:06:05) LSchiere: okay, so rather then messing with anoncvs delays, i'm going to leave this in for now, and aatharuv can just change to to a account option in place Okay, here's a patch to reload subscriptions incase the server loses track of them, as a protocol action. Since my anoncvs hasn't even gotten the original zephyr patch yet, you might as well reverse the original patch, and apply this new one." --Arun A Tharuvai committer: Tailor Script diff -r dfee44a581a4 -r 66b3f54527e6 src/protocols/zephyr/zephyr.c --- a/src/protocols/zephyr/zephyr.c Tue Jun 29 17:23:08 2004 +0000 +++ b/src/protocols/zephyr/zephyr.c Tue Jun 29 20:35:30 2004 +0000 @@ -894,9 +894,7 @@ static void zephyr_login(GaimAccount * account) { ZSubscription_t sub; - unsigned short port = 0; - FILE* wgfile; - char* wgfilename; + if (zgc) { gaim_notify_error(account->gc, NULL, _("Already logged in with Zephyr"), _("Because Zephyr uses your system username, you " "are unable to have multiple accounts on it " "when logged in as the same user.")); @@ -908,24 +906,19 @@ gaim_connection_update_progress(zgc, _("Connecting"), 0, 2); z_call_s(ZInitialize(), "Couldn't initialize zephyr"); - z_call_s(ZOpenPort(&port), "Couldn't open port"); + z_call_s(ZOpenPort(NULL), "Couldn't open port"); z_call_s(ZSetLocation((char *) gaim_account_get_string(zgc->account, "exposure_level", EXPOSE_REALMVIS)), "Couldn't set location"); sub.zsub_class = "MESSAGE"; sub.zsub_classinst = "PERSONAL"; sub.zsub_recipient = (char *)gaim_zephyr_get_sender(); - + /* we don't care if this fails. i'm lying right now. */ if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Couldn't subscribe to messages!\n"); } - wgfile = gaim_mkstemp_template(&wgfilename,"gaimwgXXXXXX"); - if (wgfile) { - fprintf(wgfile,"%d\n",port); - fclose(wgfile); - } gaim_connection_set_state(zgc, GAIM_CONNECTED); serv_finish_login(zgc); @@ -1344,6 +1337,46 @@ } +static int zephyr_resubscribe(GaimConnection *gc) +{ + /* Resubscribe to the in-memory list of subscriptions and also + unsubscriptions*/ + + GSList *s = subscrips; + zephyr_triple *zt; + ZSubscription_t zst; + while (s) { + zt = s->data; + zst.zsub_class = zt->class; + zst.zsub_classinst = zt->instance; + zst.zsub_recipient = zt->recipient; + ZSubscribeTo(&zst, 1, 0); + /* XXX We really should care if this fails */ + s = s->next; + } + /* XXX handle unsubscriptions */ + return 1; +} + +static void zephyr_action_resubscribe(GaimPluginAction *action) +{ + + GaimConnection *gc = (GaimConnection *) action->context; + zephyr_resubscribe(gc); +} + + +static GList *zephyr_actions(GaimPlugin *plugin, gpointer context) +{ + GList *list = NULL; + GaimPluginAction *act = NULL; + + act = gaim_plugin_action_new(_("Resubscribe"), zephyr_action_resubscribe); + list = g_list_append(list, act); + + return list; +} + static GaimPlugin *my_protocol = NULL; static GaimPluginProtocolInfo prpl_info = { @@ -1429,7 +1462,7 @@ NULL, /**< ui_info */ &prpl_info, /**< extra_info */ NULL, - NULL + zephyr_actions }; static void init_plugin(GaimPlugin * plugin) diff -r dfee44a581a4 -r 66b3f54527e6 src/util.c --- a/src/util.c Tue Jun 29 17:23:08 2004 +0000 +++ b/src/util.c Tue Jun 29 20:35:30 2004 +0000 @@ -1951,13 +1951,7 @@ static const char *gaim_mkstemp_templ = {"gaimXXXXXX"}; FILE * -gaim_mkstemp(char **fpath) { - return gaim_mkstemp_template(fpath, gaim_mkstemp_templ); -} - - -FILE * -gaim_mkstemp_template(char **fpath, const char *template) +gaim_mkstemp(char **fpath) { const gchar *tmpdir; #ifndef _WIN32 @@ -1968,7 +1962,7 @@ g_return_val_if_fail(fpath != NULL, NULL); if((tmpdir = (gchar*)g_get_tmp_dir()) != NULL) { - if((*fpath = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", tmpdir, template)) != NULL) { + if((*fpath = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", tmpdir, gaim_mkstemp_templ)) != NULL) { #ifdef _WIN32 char* result = _mktemp( *fpath ); if( result == NULL ) diff -r dfee44a581a4 -r 66b3f54527e6 src/util.h --- a/src/util.h Tue Jun 29 17:23:08 2004 +0000 +++ b/src/util.h Tue Jun 29 20:35:30 2004 +0000 @@ -394,26 +394,6 @@ FILE *gaim_mkstemp(char **path); /** - * Creates a temporary file and returns a file pointer to it. - * - * This is like mkstemp(), but returns a file pointer. It uses the - * semantics of tempnam() for the directory to use and allocates the - * space for the file path. - * - * The caller is responsible for closing the file and removing it when - * done, as well as freeing the space pointed to by @a path with - * g_free(). - * - * @param path The returned path to the temp file. - * - * @param pattern Pattern for use with the returned filename. - * - * @return A file pointer to the temporary file, or @c NULL on failure. - */ - -FILE *gaim_mkstemp_template(char **path,const char *template); - -/** * Checks if the given program name is valid and executable. * * @param program The file name of the application.