Mercurial > pidgin
comparison src/protocols/gg/gg.c @ 9415:1c4092217e4a
[gaim-migrate @ 10230]
" Adds support for status messages to Gadu Gadu. Please test Gaim
support, as I have only been able to test it using a libgaim-style
setting.
May not apply cleanly to the plugin info section (callbacks) as I
couldn't sync the latest commit there, it's not in anon-CVS yet.
Should be easy to fix any conflict that occurs there." --Andrew Wellington
please test
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sun, 27 Jun 2004 18:19:09 +0000 |
parents | b3bda982996b |
children | da603f6c5482 |
comparison
equal
deleted
inserted
replaced
9414:f55fa0a2277e | 9415:1c4092217e4a |
---|---|
1 /* | 1 /* |
2 * gaim - Gadu-Gadu Protocol Plugin | 2 * gaim - Gadu-Gadu Protocol Plugin |
3 * $Id: gg.c 10116 2004-06-19 04:57:43Z seanegan $ | 3 * $Id: gg.c 10230 2004-06-27 18:19:09Z lschiere $ |
4 * | 4 * |
5 * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> | 5 * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> |
6 * | 6 * |
7 * This program is free software; you can redistribute it and/or modify | 7 * This program is free software; you can redistribute it and/or modify |
8 * it under the terms of the GNU General Public License as published by | 8 * it under the terms of the GNU General Public License as published by |
198 status = GG_STATUS_AVAIL; | 198 status = GG_STATUS_AVAIL; |
199 | 199 |
200 if (gd->own_status & GG_STATUS_FRIENDS_MASK) | 200 if (gd->own_status & GG_STATUS_FRIENDS_MASK) |
201 status |= GG_STATUS_FRIENDS_MASK; | 201 status |= GG_STATUS_FRIENDS_MASK; |
202 } | 202 } |
203 | |
204 if (msg) { | |
205 switch (status) { | |
206 case GG_STATUS_AVAIL: | |
207 status = GG_STATUS_AVAIL_DESCR; | |
208 break; | |
209 case GG_STATUS_BUSY: | |
210 status = GG_STATUS_BUSY_DESCR; | |
211 break; | |
212 case GG_STATUS_INVISIBLE: | |
213 status = GG_STATUS_INVISIBLE_DESCR; | |
214 break; | |
215 case GG_STATUS_NOT_AVAIL: | |
216 status = GG_STATUS_NOT_AVAIL_DESCR; | |
217 break; | |
218 } | |
219 } | |
203 | 220 |
204 gd->own_status = status; | 221 gd->own_status = status; |
205 gg_change_status(gd->sess, status); | 222 if (msg) |
223 gg_change_status_descr(gd->sess, status, msg); | |
224 else | |
225 gg_change_status(gd->sess, status); | |
226 } | |
227 | |
228 static void agg_get_away(GaimConnection *gc, const char *who) | |
229 { | |
230 GaimBuddy *buddy; | |
231 char *dialog_msg, **splitmsg; | |
232 | |
233 if (invalid_uin(who)) | |
234 return; | |
235 | |
236 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); | |
237 if (buddy->proto_data) { | |
238 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
239 splitmsg = g_strsplit(buddy->proto_data, "\r\n", 0); | |
240 | |
241 dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, (char *)buddy->proto_data, g_strjoinv("<BR>", splitmsg)); | |
242 gaim_notify_formatted(gc, NULL, _("Buddy Information"), buddy->proto_data, dialog_msg, NULL, (char *)who); | |
243 } | |
206 } | 244 } |
207 | 245 |
208 static gchar *get_away_text(int uc) | 246 static gchar *get_away_text(int uc) |
209 { | 247 { |
210 if (uc == UC_UNAVAILABLE) | 248 if (uc == UC_UNAVAILABLE) |
474 } | 512 } |
475 break; | 513 break; |
476 case GG_EVENT_NOTIFY60: | 514 case GG_EVENT_NOTIFY60: |
477 { | 515 { |
478 gchar user[20]; | 516 gchar user[20]; |
479 struct gg_notify_reply60 *n = (void *)e->event.notify60; | |
480 guint status; | 517 guint status; |
481 | 518 guint i = 0; |
482 while (n->uin) { | 519 |
483 switch (n->status) { | 520 for (i = 0; e->event.notify60[i].uin; i++) { |
521 GaimBuddy *buddy; | |
522 | |
523 g_snprintf(user, sizeof(user), "%lu", (long unsigned int)e->event.notify60[i].uin); | |
524 | |
525 buddy = gaim_find_buddy(gaim_connection_get_account(gc), user); | |
526 if (buddy && buddy->proto_data != NULL) { | |
527 g_free(buddy->proto_data); | |
528 buddy->proto_data = NULL; | |
529 } | |
530 | |
531 switch (e->event.notify60[i].status) { | |
484 case GG_STATUS_NOT_AVAIL: | 532 case GG_STATUS_NOT_AVAIL: |
533 case GG_STATUS_NOT_AVAIL_DESCR: | |
485 status = UC_UNAVAILABLE; | 534 status = UC_UNAVAILABLE; |
486 break; | 535 break; |
487 case GG_STATUS_AVAIL: | 536 case GG_STATUS_AVAIL: |
537 case GG_STATUS_AVAIL_DESCR: | |
488 case GG_STATUS_BUSY: | 538 case GG_STATUS_BUSY: |
539 case GG_STATUS_BUSY_DESCR: | |
489 case GG_STATUS_INVISIBLE: | 540 case GG_STATUS_INVISIBLE: |
490 status = UC_NORMAL | (n->status << 5); | 541 case GG_STATUS_INVISIBLE_DESCR: |
542 status = UC_NORMAL | (e->event.notify60[i].status << 5); | |
491 break; | 543 break; |
492 default: | 544 default: |
493 status = UC_NORMAL; | 545 status = UC_NORMAL; |
494 break; | 546 break; |
495 } | 547 } |
496 | 548 |
497 g_snprintf(user, sizeof(user), "%lu", (long unsigned int)n->uin); | 549 if (buddy && e->event.notify60[i].descr != NULL) { |
550 buddy->proto_data = g_strdup(e->event.notify60[i].descr); | |
551 } | |
552 | |
498 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0, | 553 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0, |
499 status); | 554 status); |
500 n++; | 555 i++; |
501 } | 556 } |
502 } | 557 } |
503 break; | 558 break; |
504 case GG_EVENT_STATUS: | 559 case GG_EVENT_STATUS: |
505 { | 560 { |
528 case GG_EVENT_STATUS60: | 583 case GG_EVENT_STATUS60: |
529 { | 584 { |
530 gchar user[20]; | 585 gchar user[20]; |
531 guint status; | 586 guint status; |
532 | 587 |
588 GaimBuddy *buddy; | |
589 | |
590 g_snprintf(user, sizeof(user), "%lu", e->event.status60.uin); | |
591 | |
592 buddy = gaim_find_buddy(gaim_connection_get_account(gc), user); | |
593 if (buddy && buddy->proto_data != NULL) { | |
594 g_free(buddy->proto_data); | |
595 buddy->proto_data = NULL; | |
596 } | |
597 | |
533 switch (e->event.status60.status) { | 598 switch (e->event.status60.status) { |
534 case GG_STATUS_NOT_AVAIL: | 599 case GG_STATUS_NOT_AVAIL: |
600 case GG_STATUS_NOT_AVAIL_DESCR: | |
535 status = UC_UNAVAILABLE; | 601 status = UC_UNAVAILABLE; |
536 break; | 602 break; |
537 case GG_STATUS_AVAIL: | 603 case GG_STATUS_AVAIL: |
604 case GG_STATUS_AVAIL_DESCR: | |
538 case GG_STATUS_BUSY: | 605 case GG_STATUS_BUSY: |
606 case GG_STATUS_BUSY_DESCR: | |
539 case GG_STATUS_INVISIBLE: | 607 case GG_STATUS_INVISIBLE: |
608 case GG_STATUS_INVISIBLE_DESCR: | |
540 status = UC_NORMAL | (e->event.status60.status << 5); | 609 status = UC_NORMAL | (e->event.status60.status << 5); |
541 break; | 610 break; |
542 default: | 611 default: |
543 status = UC_NORMAL; | 612 status = UC_NORMAL; |
544 break; | 613 break; |
545 } | 614 } |
546 | 615 |
547 g_snprintf(user, sizeof(user), "%lu", e->event.status60.uin); | 616 if (buddy && e->event.status60.descr != NULL) { |
617 buddy->proto_data = g_strdup(e->event.status60.descr); | |
618 } | |
619 | |
548 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0, | 620 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0, |
549 status); | 621 status); |
550 } | 622 } |
551 break; | 623 break; |
552 case GG_EVENT_ACK: | 624 case GG_EVENT_ACK: |
819 gg_notify(gd->sess, userlist, userlist_size); | 891 gg_notify(gd->sess, userlist, userlist_size); |
820 g_free(userlist); | 892 g_free(userlist); |
821 } | 893 } |
822 | 894 |
823 agg_save_buddy_list(gc, NULL); | 895 agg_save_buddy_list(gc, NULL); |
896 } | |
897 | |
898 static void agg_buddy_free (GaimBuddy *buddy) | |
899 { | |
900 if (buddy->proto_data) { | |
901 g_free(buddy->proto_data); | |
902 buddy->proto_data = NULL; | |
903 } | |
824 } | 904 } |
825 | 905 |
826 static void search_results(GaimConnection *gc, gchar *webdata) | 906 static void search_results(GaimConnection *gc, gchar *webdata) |
827 { | 907 { |
828 gchar **webdata_tbl; | 908 gchar **webdata_tbl; |
1571 NULL, | 1651 NULL, |
1572 NULL, | 1652 NULL, |
1573 NULL, | 1653 NULL, |
1574 agg_group_buddy, | 1654 agg_group_buddy, |
1575 agg_rename_group, | 1655 agg_rename_group, |
1576 NULL, | 1656 agg_buddy_free, |
1577 NULL, | 1657 NULL, |
1578 NULL, | 1658 NULL, |
1579 NULL, | 1659 NULL, |
1580 NULL, | 1660 NULL, |
1581 NULL, | 1661 NULL, |