diff src/protocols/zephyr/zephyr.c @ 9427:66b3f54527e6

[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 <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 29 Jun 2004 20:35:30 +0000
parents dfee44a581a4
children c5cf752acc4a
line wrap: on
line diff
--- 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)