Mercurial > pidgin.yaz
comparison libpurple/protocols/gg/gg.c @ 32441:aee8dcd35262
Convert gg prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
author | andrew.victor@mxit.com |
---|---|
date | Mon, 29 Aug 2011 21:52:24 +0000 |
parents | 99ca503ea087 |
children | cd1d9e04c587 |
comparison
equal
deleted
inserted
replaced
32440:e895aebcb504 | 32441:aee8dcd35262 |
---|---|
95 } | 95 } |
96 | 96 |
97 static void ggp_async_token_handler(gpointer _gc, gint fd, PurpleInputCondition cond) | 97 static void ggp_async_token_handler(gpointer _gc, gint fd, PurpleInputCondition cond) |
98 { | 98 { |
99 PurpleConnection *gc = _gc; | 99 PurpleConnection *gc = _gc; |
100 GGPInfo *info = gc->proto_data; | 100 GGPInfo *info = purple_connection_get_protocol_data(gc); |
101 GGPToken *token = info->token; | 101 GGPToken *token = info->token; |
102 GGPTokenCallback cb; | 102 GGPTokenCallback cb; |
103 | 103 |
104 struct gg_token *t = NULL; | 104 struct gg_token *t = NULL; |
105 | 105 |
168 account = purple_connection_get_account(gc); | 168 account = purple_connection_get_account(gc); |
169 | 169 |
170 if (ggp_setup_proxy(account) == -1) | 170 if (ggp_setup_proxy(account) == -1) |
171 return; | 171 return; |
172 | 172 |
173 info = gc->proto_data; | 173 info = purple_connection_get_protocol_data(gc); |
174 | 174 |
175 if ((req = gg_token(1)) == NULL) { | 175 if ((req = gg_token(1)) == NULL) { |
176 purple_notify_error(account, | 176 purple_notify_error(account, |
177 _("Token Error"), | 177 _("Token Error"), |
178 _("Unable to fetch the token.\n"), NULL); | 178 _("Unable to fetch the token.\n"), NULL); |
197 * @param Current action handler. | 197 * @param Current action handler. |
198 */ | 198 */ |
199 static void ggp_action_buddylist_get(PurplePluginAction *action) | 199 static void ggp_action_buddylist_get(PurplePluginAction *action) |
200 { | 200 { |
201 PurpleConnection *gc = (PurpleConnection *)action->context; | 201 PurpleConnection *gc = (PurpleConnection *)action->context; |
202 GGPInfo *info = gc->proto_data; | 202 GGPInfo *info = purple_connection_get_protocol_data(gc); |
203 | 203 |
204 purple_debug_info("gg", "Downloading...\n"); | 204 purple_debug_info("gg", "Downloading...\n"); |
205 | 205 |
206 gg_userlist_request(info->session, GG_USERLIST_GET, NULL); | 206 gg_userlist_request(info->session, GG_USERLIST_GET, NULL); |
207 } | 207 } |
212 * @param action Current action handler. | 212 * @param action Current action handler. |
213 */ | 213 */ |
214 static void ggp_action_buddylist_put(PurplePluginAction *action) | 214 static void ggp_action_buddylist_put(PurplePluginAction *action) |
215 { | 215 { |
216 PurpleConnection *gc = (PurpleConnection *)action->context; | 216 PurpleConnection *gc = (PurpleConnection *)action->context; |
217 GGPInfo *info = gc->proto_data; | 217 GGPInfo *info = purple_connection_get_protocol_data(gc); |
218 | 218 |
219 char *buddylist = ggp_buddylist_dump(purple_connection_get_account(gc)); | 219 char *buddylist = ggp_buddylist_dump(purple_connection_get_account(gc)); |
220 | 220 |
221 purple_debug_info("gg", "Uploading...\n"); | 221 purple_debug_info("gg", "Uploading...\n"); |
222 | 222 |
233 * @param action Current action handler. | 233 * @param action Current action handler. |
234 */ | 234 */ |
235 static void ggp_action_buddylist_delete(PurplePluginAction *action) | 235 static void ggp_action_buddylist_delete(PurplePluginAction *action) |
236 { | 236 { |
237 PurpleConnection *gc = (PurpleConnection *)action->context; | 237 PurpleConnection *gc = (PurpleConnection *)action->context; |
238 GGPInfo *info = gc->proto_data; | 238 GGPInfo *info = purple_connection_get_protocol_data(gc); |
239 | 239 |
240 purple_debug_info("gg", "Deleting...\n"); | 240 purple_debug_info("gg", "Deleting...\n"); |
241 | 241 |
242 gg_userlist_request(info->session, GG_USERLIST_PUT, NULL); | 242 gg_userlist_request(info->session, GG_USERLIST_PUT, NULL); |
243 } | 243 } |
332 | 332 |
333 static void ggp_callback_register_account_ok(PurpleConnection *gc, | 333 static void ggp_callback_register_account_ok(PurpleConnection *gc, |
334 PurpleRequestFields *fields) | 334 PurpleRequestFields *fields) |
335 { | 335 { |
336 PurpleAccount *account; | 336 PurpleAccount *account; |
337 GGPInfo *info = gc->proto_data; | 337 GGPInfo *info = purple_connection_get_protocol_data(gc); |
338 struct gg_http *h = NULL; | 338 struct gg_http *h = NULL; |
339 struct gg_pubdir *s; | 339 struct gg_pubdir *s; |
340 uin_t uin; | 340 uin_t uin; |
341 gchar *email, *p1, *p2, *t; | 341 gchar *email, *p1, *p2, *t; |
342 GGPToken *token = info->token; | 342 GGPToken *token = info->token; |
413 } | 413 } |
414 | 414 |
415 static void ggp_callback_register_account_cancel(PurpleConnection *gc, | 415 static void ggp_callback_register_account_cancel(PurpleConnection *gc, |
416 PurpleRequestFields *fields) | 416 PurpleRequestFields *fields) |
417 { | 417 { |
418 GGPInfo *info = gc->proto_data; | 418 GGPInfo *info = purple_connection_get_protocol_data(gc); |
419 GGPToken *token = info->token; | 419 GGPToken *token = info->token; |
420 | 420 |
421 purple_account_disconnect(gc->account); | 421 purple_account_disconnect(gc->account); |
422 | 422 |
423 g_free(token->id); | 423 g_free(token->id); |
431 PurpleAccount *account; | 431 PurpleAccount *account; |
432 PurpleRequestFields *fields; | 432 PurpleRequestFields *fields; |
433 PurpleRequestFieldGroup *group; | 433 PurpleRequestFieldGroup *group; |
434 PurpleRequestField *field; | 434 PurpleRequestField *field; |
435 | 435 |
436 GGPInfo *info = gc->proto_data; | 436 GGPInfo *info = purple_connection_get_protocol_data(gc); |
437 GGPToken *token = info->token; | 437 GGPToken *token = info->token; |
438 | 438 |
439 | 439 |
440 account = purple_connection_get_account(gc); | 440 account = purple_connection_get_account(gc); |
441 | 441 |
481 | 481 |
482 /* ----- PUBLIC DIRECTORY SEARCH ---------------------------------------- */ | 482 /* ----- PUBLIC DIRECTORY SEARCH ---------------------------------------- */ |
483 | 483 |
484 static void ggp_callback_show_next(PurpleConnection *gc, GList *row, gpointer user_data) | 484 static void ggp_callback_show_next(PurpleConnection *gc, GList *row, gpointer user_data) |
485 { | 485 { |
486 GGPInfo *info = gc->proto_data; | 486 GGPInfo *info = purple_connection_get_protocol_data(gc); |
487 GGPSearchForm *form = user_data; | 487 GGPSearchForm *form = user_data; |
488 guint32 seq; | 488 guint32 seq; |
489 | 489 |
490 form->page_number++; | 490 form->page_number++; |
491 | 491 |
518 purple_conversation_present(conv); | 518 purple_conversation_present(conv); |
519 } | 519 } |
520 | 520 |
521 static void ggp_callback_find_buddies(PurpleConnection *gc, PurpleRequestFields *fields) | 521 static void ggp_callback_find_buddies(PurpleConnection *gc, PurpleRequestFields *fields) |
522 { | 522 { |
523 GGPInfo *info = gc->proto_data; | 523 GGPInfo *info = purple_connection_get_protocol_data(gc); |
524 GGPSearchForm *form; | 524 GGPSearchForm *form; |
525 guint32 seq; | 525 guint32 seq; |
526 | 526 |
527 form = ggp_search_form_new(GGP_SEARCH_TYPE_FULL); | 527 form = ggp_search_form_new(GGP_SEARCH_TYPE_FULL); |
528 | 528 |
619 /* ----- CHANGE PASSWORD ------------------------------------------------ */ | 619 /* ----- CHANGE PASSWORD ------------------------------------------------ */ |
620 | 620 |
621 static void ggp_callback_change_passwd_ok(PurpleConnection *gc, PurpleRequestFields *fields) | 621 static void ggp_callback_change_passwd_ok(PurpleConnection *gc, PurpleRequestFields *fields) |
622 { | 622 { |
623 PurpleAccount *account; | 623 PurpleAccount *account; |
624 GGPInfo *info = gc->proto_data; | 624 GGPInfo *info = purple_connection_get_protocol_data(gc); |
625 struct gg_http *h; | 625 struct gg_http *h; |
626 gchar *cur, *p1, *p2, *t; | 626 gchar *cur, *p1, *p2, *t; |
627 | 627 |
628 cur = charset_convert( | 628 cur = charset_convert( |
629 purple_request_fields_get_string(fields, "password_cur"), | 629 purple_request_fields_get_string(fields, "password_cur"), |
694 { | 694 { |
695 PurpleRequestFields *fields; | 695 PurpleRequestFields *fields; |
696 PurpleRequestFieldGroup *group; | 696 PurpleRequestFieldGroup *group; |
697 PurpleRequestField *field; | 697 PurpleRequestField *field; |
698 | 698 |
699 GGPInfo *info = gc->proto_data; | 699 GGPInfo *info = purple_connection_get_protocol_data(gc); |
700 GGPToken *token = info->token; | 700 GGPToken *token = info->token; |
701 | 701 |
702 char *msg; | 702 char *msg; |
703 | 703 |
704 | 704 |
756 | 756 |
757 /* ----- CHANGE STATUS BROADCASTING ------------------------------------------------ */ | 757 /* ----- CHANGE STATUS BROADCASTING ------------------------------------------------ */ |
758 | 758 |
759 static void ggp_action_change_status_broadcasting_ok(PurpleConnection *gc, PurpleRequestFields *fields) | 759 static void ggp_action_change_status_broadcasting_ok(PurpleConnection *gc, PurpleRequestFields *fields) |
760 { | 760 { |
761 GGPInfo *info = gc->proto_data; | 761 GGPInfo *info = purple_connection_get_protocol_data(gc); |
762 int selected_field; | 762 int selected_field; |
763 PurpleAccount *account = purple_connection_get_account(gc); | 763 PurpleAccount *account = purple_connection_get_account(gc); |
764 PurpleStatus *status; | 764 PurpleStatus *status; |
765 | 765 |
766 selected_field = purple_request_fields_get_choice(fields, "status_broadcasting"); | 766 selected_field = purple_request_fields_get_choice(fields, "status_broadcasting"); |
776 } | 776 } |
777 | 777 |
778 static void ggp_action_change_status_broadcasting(PurplePluginAction *action) | 778 static void ggp_action_change_status_broadcasting(PurplePluginAction *action) |
779 { | 779 { |
780 PurpleConnection *gc = (PurpleConnection *)action->context; | 780 PurpleConnection *gc = (PurpleConnection *)action->context; |
781 GGPInfo *info = gc->proto_data; | 781 GGPInfo *info = purple_connection_get_protocol_data(gc); |
782 | 782 |
783 PurpleRequestFields *fields; | 783 PurpleRequestFields *fields; |
784 PurpleRequestFieldGroup *group; | 784 PurpleRequestFieldGroup *group; |
785 PurpleRequestField *field; | 785 PurpleRequestField *field; |
786 | 786 |
846 GList *l; | 846 GList *l; |
847 gchar *msg; | 847 gchar *msg; |
848 | 848 |
849 buddy = (PurpleBuddy *)node; | 849 buddy = (PurpleBuddy *)node; |
850 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | 850 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
851 info = gc->proto_data; | 851 info = purple_connection_get_protocol_data(gc); |
852 | 852 |
853 fields = purple_request_fields_new(); | 853 fields = purple_request_fields_new(); |
854 group = purple_request_field_group_new(NULL); | 854 group = purple_request_field_group_new(NULL); |
855 purple_request_fields_add_group(fields, group); | 855 purple_request_fields_add_group(fields, group); |
856 | 856 |
877 | 877 |
878 /* ----- BLOCK BUDDIES -------------------------------------------------- */ | 878 /* ----- BLOCK BUDDIES -------------------------------------------------- */ |
879 | 879 |
880 static void ggp_add_deny(PurpleConnection *gc, const char *who) | 880 static void ggp_add_deny(PurpleConnection *gc, const char *who) |
881 { | 881 { |
882 GGPInfo *info = gc->proto_data; | 882 GGPInfo *info = purple_connection_get_protocol_data(gc); |
883 uin_t uin = ggp_str_to_uin(who); | 883 uin_t uin = ggp_str_to_uin(who); |
884 | 884 |
885 purple_debug_info("gg", "ggp_add_deny: %u\n", uin); | 885 purple_debug_info("gg", "ggp_add_deny: %u\n", uin); |
886 | 886 |
887 gg_remove_notify_ex(info->session, uin, GG_USER_NORMAL); | 887 gg_remove_notify_ex(info->session, uin, GG_USER_NORMAL); |
888 gg_add_notify_ex(info->session, uin, GG_USER_BLOCKED); | 888 gg_add_notify_ex(info->session, uin, GG_USER_BLOCKED); |
889 } | 889 } |
890 | 890 |
891 static void ggp_rem_deny(PurpleConnection *gc, const char *who) | 891 static void ggp_rem_deny(PurpleConnection *gc, const char *who) |
892 { | 892 { |
893 GGPInfo *info = gc->proto_data; | 893 GGPInfo *info = purple_connection_get_protocol_data(gc); |
894 uin_t uin = ggp_str_to_uin(who); | 894 uin_t uin = ggp_str_to_uin(who); |
895 | 895 |
896 purple_debug_info("gg", "ggp_rem_deny: %u\n", uin); | 896 purple_debug_info("gg", "ggp_rem_deny: %u\n", uin); |
897 | 897 |
898 gg_remove_notify_ex(info->session, uin, GG_USER_BLOCKED); | 898 gg_remove_notify_ex(info->session, uin, GG_USER_BLOCKED); |
1347 } | 1347 } |
1348 } | 1348 } |
1349 | 1349 |
1350 static void ggp_pubdir_reply_handler(PurpleConnection *gc, gg_pubdir50_t req) | 1350 static void ggp_pubdir_reply_handler(PurpleConnection *gc, gg_pubdir50_t req) |
1351 { | 1351 { |
1352 GGPInfo *info = gc->proto_data; | 1352 GGPInfo *info = purple_connection_get_protocol_data(gc); |
1353 GGPSearchForm *form; | 1353 GGPSearchForm *form; |
1354 int res_count; | 1354 int res_count; |
1355 guint32 seq; | 1355 guint32 seq; |
1356 | 1356 |
1357 seq = gg_pubdir50_seq(req); | 1357 seq = gg_pubdir50_seq(req); |
1389 } | 1389 } |
1390 | 1390 |
1391 static void ggp_recv_image_handler(PurpleConnection *gc, const struct gg_event *ev) | 1391 static void ggp_recv_image_handler(PurpleConnection *gc, const struct gg_event *ev) |
1392 { | 1392 { |
1393 gint imgid = 0; | 1393 gint imgid = 0; |
1394 GGPInfo *info = gc->proto_data; | 1394 GGPInfo *info = purple_connection_get_protocol_data(gc); |
1395 GList *entry = g_list_first(info->pending_richtext_messages); | 1395 GList *entry = g_list_first(info->pending_richtext_messages); |
1396 gchar *handlerid = g_strdup_printf("IMGID_HANDLER-%i", ev->event.image_reply.crc32); | 1396 gchar *handlerid = g_strdup_printf("IMGID_HANDLER-%i", ev->event.image_reply.crc32); |
1397 | 1397 |
1398 imgid = purple_imgstore_add_with_id( | 1398 imgid = purple_imgstore_add_with_id( |
1399 g_memdup(ev->event.image_reply.image, ev->event.image_reply.size), | 1399 g_memdup(ev->event.image_reply.image, ev->event.image_reply.size), |
1437 * | 1437 * |
1438 * Image receiving, some code borrowed from Kadu http://www.kadu.net | 1438 * Image receiving, some code borrowed from Kadu http://www.kadu.net |
1439 */ | 1439 */ |
1440 static void ggp_recv_message_handler(PurpleConnection *gc, const struct gg_event *ev) | 1440 static void ggp_recv_message_handler(PurpleConnection *gc, const struct gg_event *ev) |
1441 { | 1441 { |
1442 GGPInfo *info = gc->proto_data; | 1442 GGPInfo *info = purple_connection_get_protocol_data(gc); |
1443 PurpleConversation *conv; | 1443 PurpleConversation *conv; |
1444 gchar *from; | 1444 gchar *from; |
1445 gchar *msg; | 1445 gchar *msg; |
1446 gchar *tmp; | 1446 gchar *tmp; |
1447 | 1447 |
1606 g_free(from); | 1606 g_free(from); |
1607 } | 1607 } |
1608 | 1608 |
1609 static void ggp_send_image_handler(PurpleConnection *gc, const struct gg_event *ev) | 1609 static void ggp_send_image_handler(PurpleConnection *gc, const struct gg_event *ev) |
1610 { | 1610 { |
1611 GGPInfo *info = gc->proto_data; | 1611 GGPInfo *info = purple_connection_get_protocol_data(gc); |
1612 PurpleStoredImage *image; | 1612 PurpleStoredImage *image; |
1613 gint imgid = GPOINTER_TO_INT(g_hash_table_lookup(info->pending_images, GINT_TO_POINTER(ev->event.image_request.crc32))); | 1613 gint imgid = GPOINTER_TO_INT(g_hash_table_lookup(info->pending_images, GINT_TO_POINTER(ev->event.image_request.crc32))); |
1614 | 1614 |
1615 purple_debug_info("gg", "ggp_send_image_handler: image request received, crc32: %u, imgid: %d\n", ev->event.image_request.crc32, imgid); | 1615 purple_debug_info("gg", "ggp_send_image_handler: image request received, crc32: %u, imgid: %d\n", ev->event.image_request.crc32, imgid); |
1616 | 1616 |
1712 } | 1712 } |
1713 | 1713 |
1714 static void ggp_callback_recv(gpointer _gc, gint fd, PurpleInputCondition cond) | 1714 static void ggp_callback_recv(gpointer _gc, gint fd, PurpleInputCondition cond) |
1715 { | 1715 { |
1716 PurpleConnection *gc = _gc; | 1716 PurpleConnection *gc = _gc; |
1717 GGPInfo *info = gc->proto_data; | 1717 GGPInfo *info = purple_connection_get_protocol_data(gc); |
1718 struct gg_event *ev; | 1718 struct gg_event *ev; |
1719 int i; | 1719 int i; |
1720 | 1720 |
1721 if (!(ev = gg_watch_fd(info->session))) { | 1721 if (!(ev = gg_watch_fd(info->session))) { |
1722 purple_debug_error("gg", | 1722 purple_debug_error("gg", |
1847 GGPInfo *info; | 1847 GGPInfo *info; |
1848 struct gg_event *ev; | 1848 struct gg_event *ev; |
1849 | 1849 |
1850 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); | 1850 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); |
1851 | 1851 |
1852 info = gc->proto_data; | 1852 info = purple_connection_get_protocol_data(gc); |
1853 | 1853 |
1854 purple_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", | 1854 purple_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", |
1855 info->session->check, info->session->state); | 1855 info->session->check, info->session->state); |
1856 | 1856 |
1857 switch (info->session->state) { | 1857 switch (info->session->state) { |
2065 static GList *ggp_blist_node_menu(PurpleBlistNode *node) | 2065 static GList *ggp_blist_node_menu(PurpleBlistNode *node) |
2066 { | 2066 { |
2067 PurpleMenuAction *act; | 2067 PurpleMenuAction *act; |
2068 GList *m = NULL; | 2068 GList *m = NULL; |
2069 PurpleAccount *account; | 2069 PurpleAccount *account; |
2070 PurpleConnection *gc; | |
2070 GGPInfo *info; | 2071 GGPInfo *info; |
2071 | 2072 |
2072 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) | 2073 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) |
2073 return NULL; | 2074 return NULL; |
2074 | 2075 |
2075 account = purple_buddy_get_account((PurpleBuddy *) node); | 2076 account = purple_buddy_get_account((PurpleBuddy *) node); |
2076 info = purple_account_get_connection(account)->proto_data; | 2077 gc = purple_account_get_connection(account); |
2078 info = purple_connection_get_protocol_data(gc); | |
2077 if (info->chats) { | 2079 if (info->chats) { |
2078 act = purple_menu_action_new(_("Add to chat"), | 2080 act = purple_menu_action_new(_("Add to chat"), |
2079 PURPLE_CALLBACK(ggp_bmenu_add_to_chat), | 2081 PURPLE_CALLBACK(ggp_bmenu_add_to_chat), |
2080 NULL, NULL); | 2082 NULL, NULL); |
2081 m = g_list_append(m, act); | 2083 m = g_list_append(m, act); |
2123 info->searches = ggp_search_new(); | 2125 info->searches = ggp_search_new(); |
2124 info->pending_richtext_messages = NULL; | 2126 info->pending_richtext_messages = NULL; |
2125 info->pending_images = g_hash_table_new(g_direct_hash, g_direct_equal); | 2127 info->pending_images = g_hash_table_new(g_direct_hash, g_direct_equal); |
2126 info->status_broadcasting = purple_account_get_bool(account, "status_broadcasting", TRUE); | 2128 info->status_broadcasting = purple_account_get_bool(account, "status_broadcasting", TRUE); |
2127 | 2129 |
2128 gc->proto_data = info; | 2130 purple_connection_set_protocol_data(gc, info); |
2129 | 2131 |
2130 glp->uin = ggp_get_uin(account); | 2132 glp->uin = ggp_get_uin(account); |
2131 glp->password = (char *)purple_account_get_password(account); | 2133 glp->password = (char *)purple_account_get_password(account); |
2132 glp->image_size = 255; | 2134 glp->image_size = 255; |
2133 | 2135 |
2187 ggp_async_login_handler, gc); | 2189 ggp_async_login_handler, gc); |
2188 } | 2190 } |
2189 | 2191 |
2190 static void ggp_close(PurpleConnection *gc) | 2192 static void ggp_close(PurpleConnection *gc) |
2191 { | 2193 { |
2194 PurpleAccount *account; | |
2195 GGPInfo *info;; | |
2192 | 2196 |
2193 if (gc == NULL) { | 2197 if (gc == NULL) { |
2194 purple_debug_info("gg", "gc == NULL\n"); | 2198 purple_debug_info("gg", "gc == NULL\n"); |
2195 return; | 2199 return; |
2196 } | 2200 } |
2197 | 2201 |
2198 if (gc->proto_data) { | 2202 account = purple_connection_get_account(gc); |
2199 PurpleAccount *account = purple_connection_get_account(gc); | 2203 info = purple_connection_get_protocol_data(gc); |
2200 PurpleStatus *status; | 2204 |
2201 GGPInfo *info = gc->proto_data; | 2205 if (info) { |
2202 | 2206 PurpleStatus *status = purple_account_get_active_status(account); |
2203 status = purple_account_get_active_status(account); | |
2204 | 2207 |
2205 if (info->session != NULL) { | 2208 if (info->session != NULL) { |
2206 ggp_set_status(account, status); | 2209 ggp_set_status(account, status); |
2207 gg_logoff(info->session); | 2210 gg_logoff(info->session); |
2208 gg_free_session(info->session); | 2211 gg_free_session(info->session); |
2217 | 2220 |
2218 ggp_search_destroy(info->searches); | 2221 ggp_search_destroy(info->searches); |
2219 g_list_free(info->pending_richtext_messages); | 2222 g_list_free(info->pending_richtext_messages); |
2220 g_hash_table_destroy(info->pending_images); | 2223 g_hash_table_destroy(info->pending_images); |
2221 g_free(info); | 2224 g_free(info); |
2222 gc->proto_data = NULL; | 2225 purple_connection_set_protocol_data(gc, NULL); |
2223 } | 2226 } |
2224 | 2227 |
2225 if (gc->inpa > 0) | 2228 if (gc->inpa > 0) |
2226 purple_input_remove(gc->inpa); | 2229 purple_input_remove(gc->inpa); |
2227 | 2230 |
2229 } | 2232 } |
2230 | 2233 |
2231 static int ggp_send_im(PurpleConnection *gc, const char *who, const char *msg, | 2234 static int ggp_send_im(PurpleConnection *gc, const char *who, const char *msg, |
2232 PurpleMessageFlags flags) | 2235 PurpleMessageFlags flags) |
2233 { | 2236 { |
2234 GGPInfo *info = gc->proto_data; | 2237 GGPInfo *info = purple_connection_get_protocol_data(gc); |
2235 char *tmp, *plain; | 2238 char *tmp, *plain; |
2236 int ret = 1; | 2239 int ret = 1; |
2237 unsigned char format[1024]; | 2240 unsigned char format[1024]; |
2238 unsigned int format_length = sizeof(struct gg_msg_richtext); | 2241 unsigned int format_length = sizeof(struct gg_msg_richtext); |
2239 gint pos = 0; | 2242 gint pos = 0; |
2347 return ret; | 2350 return ret; |
2348 } | 2351 } |
2349 | 2352 |
2350 static unsigned int ggp_send_typing(PurpleConnection *gc, const char *name, PurpleTypingState state) | 2353 static unsigned int ggp_send_typing(PurpleConnection *gc, const char *name, PurpleTypingState state) |
2351 { | 2354 { |
2355 GGPInfo *info = purple_connection_get_protocol_data(gc); | |
2352 int dummy_length; // we don't send real length of typed message | 2356 int dummy_length; // we don't send real length of typed message |
2353 | 2357 |
2354 if (state == PURPLE_TYPED) // not supported | 2358 if (state == PURPLE_TYPED) // not supported |
2355 return 1; | 2359 return 1; |
2356 | 2360 |
2358 dummy_length = (int)g_random_int(); | 2362 dummy_length = (int)g_random_int(); |
2359 else // PURPLE_NOT_TYPING | 2363 else // PURPLE_NOT_TYPING |
2360 dummy_length = 0; | 2364 dummy_length = 0; |
2361 | 2365 |
2362 gg_typing_notification( | 2366 gg_typing_notification( |
2363 ((GGPInfo*)gc->proto_data)->session, | 2367 info->session, |
2364 ggp_str_to_uin(name), | 2368 ggp_str_to_uin(name), |
2365 dummy_length); | 2369 dummy_length); |
2366 | 2370 |
2367 return 1; // wait 1 second before another notification | 2371 return 1; // wait 1 second before another notification |
2368 } | 2372 } |
2369 | 2373 |
2370 static void ggp_get_info(PurpleConnection *gc, const char *name) | 2374 static void ggp_get_info(PurpleConnection *gc, const char *name) |
2371 { | 2375 { |
2372 GGPInfo *info = gc->proto_data; | 2376 GGPInfo *info = purple_connection_get_protocol_data(gc); |
2373 GGPSearchForm *form; | 2377 GGPSearchForm *form; |
2374 guint32 seq; | 2378 guint32 seq; |
2375 | 2379 |
2376 form = ggp_search_form_new(GGP_SEARCH_TYPE_INFO); | 2380 form = ggp_search_form_new(GGP_SEARCH_TYPE_INFO); |
2377 | 2381 |
2443 | 2447 |
2444 if (!purple_status_is_active(status)) | 2448 if (!purple_status_is_active(status)) |
2445 return; | 2449 return; |
2446 | 2450 |
2447 gc = purple_account_get_connection(account); | 2451 gc = purple_account_get_connection(account); |
2448 info = gc->proto_data; | 2452 info = purple_connection_get_protocol_data(gc); |
2449 | 2453 |
2450 new_status = ggp_to_gg_status(status, &new_msg); | 2454 new_status = ggp_to_gg_status(status, &new_msg); |
2451 | 2455 |
2452 if (!info->status_broadcasting) | 2456 if (!info->status_broadcasting) |
2453 new_status = new_status|GG_STATUS_FRIENDS_MASK; | 2457 new_status = new_status|GG_STATUS_FRIENDS_MASK; |
2464 } | 2468 } |
2465 | 2469 |
2466 static void ggp_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) | 2470 static void ggp_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
2467 { | 2471 { |
2468 PurpleAccount *account; | 2472 PurpleAccount *account; |
2469 GGPInfo *info = gc->proto_data; | 2473 GGPInfo *info = purple_connection_get_protocol_data(gc); |
2470 const gchar *name = purple_buddy_get_name(buddy); | 2474 const gchar *name = purple_buddy_get_name(buddy); |
2471 | 2475 |
2472 gg_add_notify(info->session, ggp_str_to_uin(name)); | 2476 gg_add_notify(info->session, ggp_str_to_uin(name)); |
2473 | 2477 |
2474 account = purple_connection_get_account(gc); | 2478 account = purple_connection_get_account(gc); |
2478 } | 2482 } |
2479 | 2483 |
2480 static void ggp_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, | 2484 static void ggp_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, |
2481 PurpleGroup *group) | 2485 PurpleGroup *group) |
2482 { | 2486 { |
2483 GGPInfo *info = gc->proto_data; | 2487 GGPInfo *info = purple_connection_get_protocol_data(gc); |
2484 | 2488 |
2485 gg_remove_notify(info->session, ggp_str_to_uin(purple_buddy_get_name(buddy))); | 2489 gg_remove_notify(info->session, ggp_str_to_uin(purple_buddy_get_name(buddy))); |
2486 } | 2490 } |
2487 | 2491 |
2488 static void ggp_join_chat(PurpleConnection *gc, GHashTable *data) | 2492 static void ggp_join_chat(PurpleConnection *gc, GHashTable *data) |
2489 { | 2493 { |
2490 GGPInfo *info = gc->proto_data; | 2494 GGPInfo *info = purple_connection_get_protocol_data(gc); |
2491 GGPChat *chat; | 2495 GGPChat *chat; |
2492 char *chat_name; | 2496 char *chat_name; |
2493 GList *l; | 2497 GList *l; |
2494 PurpleConversation *conv; | 2498 PurpleConversation *conv; |
2495 PurpleAccount *account = purple_connection_get_account(gc); | 2499 PurpleAccount *account = purple_connection_get_account(gc); |
2523 } | 2527 } |
2524 | 2528 |
2525 static int ggp_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags) | 2529 static int ggp_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags) |
2526 { | 2530 { |
2527 PurpleConversation *conv; | 2531 PurpleConversation *conv; |
2528 GGPInfo *info = gc->proto_data; | 2532 GGPInfo *info = purple_connection_get_protocol_data(gc); |
2529 GGPChat *chat = NULL; | 2533 GGPChat *chat = NULL; |
2530 GList *l; | 2534 GList *l; |
2531 /* char *msg, *plain; */ | 2535 /* char *msg, *plain; */ |
2532 gchar *msg; | 2536 gchar *msg; |
2533 uin_t *uins; | 2537 uin_t *uins; |
2578 return 0; | 2582 return 0; |
2579 } | 2583 } |
2580 | 2584 |
2581 static void ggp_keepalive(PurpleConnection *gc) | 2585 static void ggp_keepalive(PurpleConnection *gc) |
2582 { | 2586 { |
2583 GGPInfo *info = gc->proto_data; | 2587 GGPInfo *info = purple_connection_get_protocol_data(gc); |
2584 | 2588 |
2585 /* purple_debug_info("gg", "Keeping connection alive....\n"); */ | 2589 /* purple_debug_info("gg", "Keeping connection alive....\n"); */ |
2586 | 2590 |
2587 if (gg_ping(info->session) < 0) { | 2591 if (gg_ping(info->session) < 0) { |
2588 purple_debug_info("gg", "Not connected to the server " | 2592 purple_debug_info("gg", "Not connected to the server " |