Mercurial > pidgin
comparison 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 |
comparison
equal
deleted
inserted
replaced
9426:dfee44a581a4 | 9427:66b3f54527e6 |
---|---|
892 } | 892 } |
893 | 893 |
894 static void zephyr_login(GaimAccount * account) | 894 static void zephyr_login(GaimAccount * account) |
895 { | 895 { |
896 ZSubscription_t sub; | 896 ZSubscription_t sub; |
897 unsigned short port = 0; | 897 |
898 FILE* wgfile; | |
899 char* wgfilename; | |
900 if (zgc) { | 898 if (zgc) { |
901 gaim_notify_error(account->gc, NULL, | 899 gaim_notify_error(account->gc, NULL, |
902 _("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.")); | 900 _("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.")); |
903 return; | 901 return; |
904 } | 902 } |
906 zgc = gaim_account_get_connection(account); | 904 zgc = gaim_account_get_connection(account); |
907 zgc->flags |= GAIM_CONNECTION_HTML; | 905 zgc->flags |= GAIM_CONNECTION_HTML; |
908 gaim_connection_update_progress(zgc, _("Connecting"), 0, 2); | 906 gaim_connection_update_progress(zgc, _("Connecting"), 0, 2); |
909 | 907 |
910 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); | 908 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); |
911 z_call_s(ZOpenPort(&port), "Couldn't open port"); | 909 z_call_s(ZOpenPort(NULL), "Couldn't open port"); |
912 z_call_s(ZSetLocation((char *) | 910 z_call_s(ZSetLocation((char *) |
913 gaim_account_get_string(zgc->account, "exposure_level", EXPOSE_REALMVIS)), "Couldn't set location"); | 911 gaim_account_get_string(zgc->account, "exposure_level", EXPOSE_REALMVIS)), "Couldn't set location"); |
914 | 912 |
915 sub.zsub_class = "MESSAGE"; | 913 sub.zsub_class = "MESSAGE"; |
916 sub.zsub_classinst = "PERSONAL"; | 914 sub.zsub_classinst = "PERSONAL"; |
917 sub.zsub_recipient = (char *)gaim_zephyr_get_sender(); | 915 sub.zsub_recipient = (char *)gaim_zephyr_get_sender(); |
918 | 916 |
919 /* we don't care if this fails. i'm lying right now. */ | 917 /* we don't care if this fails. i'm lying right now. */ |
920 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { | 918 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { |
921 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Couldn't subscribe to messages!\n"); | 919 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Couldn't subscribe to messages!\n"); |
922 } | 920 } |
923 | 921 |
924 wgfile = gaim_mkstemp_template(&wgfilename,"gaimwgXXXXXX"); | |
925 if (wgfile) { | |
926 fprintf(wgfile,"%d\n",port); | |
927 fclose(wgfile); | |
928 } | |
929 gaim_connection_set_state(zgc, GAIM_CONNECTED); | 922 gaim_connection_set_state(zgc, GAIM_CONNECTED); |
930 serv_finish_login(zgc); | 923 serv_finish_login(zgc); |
931 | 924 |
932 process_anyone(); | 925 process_anyone(); |
933 process_zsubs(); | 926 process_zsubs(); |
1342 gcc = gaim_conversation_get_chat_data(gconv); | 1335 gcc = gaim_conversation_get_chat_data(gconv); |
1343 gaim_conv_chat_set_topic(gcc, sender, topic); | 1336 gaim_conv_chat_set_topic(gcc, sender, topic); |
1344 | 1337 |
1345 } | 1338 } |
1346 | 1339 |
1340 static int zephyr_resubscribe(GaimConnection *gc) | |
1341 { | |
1342 /* Resubscribe to the in-memory list of subscriptions and also | |
1343 unsubscriptions*/ | |
1344 | |
1345 GSList *s = subscrips; | |
1346 zephyr_triple *zt; | |
1347 ZSubscription_t zst; | |
1348 while (s) { | |
1349 zt = s->data; | |
1350 zst.zsub_class = zt->class; | |
1351 zst.zsub_classinst = zt->instance; | |
1352 zst.zsub_recipient = zt->recipient; | |
1353 ZSubscribeTo(&zst, 1, 0); | |
1354 /* XXX We really should care if this fails */ | |
1355 s = s->next; | |
1356 } | |
1357 /* XXX handle unsubscriptions */ | |
1358 return 1; | |
1359 } | |
1360 | |
1361 static void zephyr_action_resubscribe(GaimPluginAction *action) | |
1362 { | |
1363 | |
1364 GaimConnection *gc = (GaimConnection *) action->context; | |
1365 zephyr_resubscribe(gc); | |
1366 } | |
1367 | |
1368 | |
1369 static GList *zephyr_actions(GaimPlugin *plugin, gpointer context) | |
1370 { | |
1371 GList *list = NULL; | |
1372 GaimPluginAction *act = NULL; | |
1373 | |
1374 act = gaim_plugin_action_new(_("Resubscribe"), zephyr_action_resubscribe); | |
1375 list = g_list_append(list, act); | |
1376 | |
1377 return list; | |
1378 } | |
1379 | |
1347 static GaimPlugin *my_protocol = NULL; | 1380 static GaimPlugin *my_protocol = NULL; |
1348 | 1381 |
1349 static GaimPluginProtocolInfo prpl_info = { | 1382 static GaimPluginProtocolInfo prpl_info = { |
1350 GAIM_PRPL_API_VERSION, | 1383 GAIM_PRPL_API_VERSION, |
1351 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD, | 1384 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD, |
1427 NULL, /**< destroy */ | 1460 NULL, /**< destroy */ |
1428 | 1461 |
1429 NULL, /**< ui_info */ | 1462 NULL, /**< ui_info */ |
1430 &prpl_info, /**< extra_info */ | 1463 &prpl_info, /**< extra_info */ |
1431 NULL, | 1464 NULL, |
1432 NULL | 1465 zephyr_actions |
1433 }; | 1466 }; |
1434 | 1467 |
1435 static void init_plugin(GaimPlugin * plugin) | 1468 static void init_plugin(GaimPlugin * plugin) |
1436 { | 1469 { |
1437 GaimAccountOption *option; | 1470 GaimAccountOption *option; |