comparison src/protocols/qq/qq.c @ 14051:f78289db8977

[gaim-migrate @ 16664] Removed code for looking up specific Chinese geolocation info from a user's IP address. The code was defunct for two reasons: First, the file holding the geolocation data (QQWry.dat) was simply too large to package with Gaim. Second, the current version of QQ seems to have stopped broadcasting the user's IP address with his/her status. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Mon, 07 Aug 2006 08:30:36 +0000
parents 8294485b79db
children d178bff33359
comparison
equal deleted inserted replaced
14050:6342ffdeb3ac 14051:f78289db8977
46 #include "group_info.h" 46 #include "group_info.h"
47 #include "group_join.h" 47 #include "group_join.h"
48 #include "group_opt.h" 48 #include "group_opt.h"
49 #include "header_info.h" 49 #include "header_info.h"
50 #include "im.h" 50 #include "im.h"
51 #include "ip_location.h"
52 #include "keep_alive.h" 51 #include "keep_alive.h"
53 #include "login_logout.h" 52 #include "login_logout.h"
54 #include "packet_parse.h" 53 #include "packet_parse.h"
55 #include "qq.h" 54 #include "qq.h"
56 #include "qq_proxy.h" 55 #include "qq_proxy.h"
243 q_bud = (qq_buddy *) b->proto_data; 242 q_bud = (qq_buddy *) b->proto_data;
244 /* g_return_if_fail(q_bud != NULL); */ 243 /* g_return_if_fail(q_bud != NULL); */
245 244
246 if (GAIM_BUDDY_IS_ONLINE(b) && q_bud != NULL) 245 if (GAIM_BUDDY_IS_ONLINE(b) && q_bud != NULL)
247 { 246 {
248 /*
249 ip_value = ntohl(*(guint32 *) (q_bud->ip));
250 if (qq_ip_get_location(ip_value, &country, &city)) {
251 country_utf8 = qq_to_utf8(country, QQ_CHARSET_DEFAULT);
252 city_utf8 = qq_to_utf8(city, QQ_CHARSET_DEFAULT);
253 g_string_append_printf(tooltip, "\n%s, %s", country_utf8, city_utf8);
254 g_free(country);
255 g_free(city);
256 g_free(country_utf8);
257 g_free(city_utf8);
258 }
259 */
260 ip_str = gen_ip_str(q_bud->ip); 247 ip_str = gen_ip_str(q_bud->ip);
261 if (strlen(ip_str) != 0) { 248 if (strlen(ip_str) != 0) {
262 g_string_append_printf(tooltip, "\n<b>%s Address:</b> %s:%d", (q_bud->comm_flag & QQ_COMM_FLAG_TCP_MODE) 249 g_string_append_printf(tooltip, "\n<b>%s Address:</b> %s:%d",
250 (q_bud->comm_flag & QQ_COMM_FLAG_TCP_MODE)
263 ? "TCP" : "UDP", ip_str, q_bud->port); 251 ? "TCP" : "UDP", ip_str, q_bud->port);
264 } 252 }
265 g_free(ip_str); 253 g_free(ip_str);
266 g_string_append_printf(tooltip, "\n<b>Age:</b> %d", q_bud->age); 254 g_string_append_printf(tooltip, "\n<b>Age:</b> %d", q_bud->age);
267 switch (q_bud->gender) { 255 switch (q_bud->gender) {
516 504
517 gaim_notify_formatted(gc, NULL, _("Login Information"), NULL, info->str, NULL, NULL); 505 gaim_notify_formatted(gc, NULL, _("Login Information"), NULL, info->str, NULL, NULL);
518 506
519 g_string_free(info, TRUE); 507 g_string_free(info, TRUE);
520 } 508 }
521
522 /*
523 static void _qq_menu_locate_ip_cb(GaimConnection * gc, GaimRequestFields * fields)
524 {
525 GList *groups, *flds;
526 GaimRequestField *field;
527 const gchar *id, *value;
528 gchar *ip_str = NULL, *ip_dupstr = NULL;
529 guint8 *ip;
530 gchar *country, *country_utf8, *city, *city_utf8;
531 guint32 ip_value;
532
533 for (groups = gaim_request_fields_get_groups(fields); groups && !ip_str; groups = groups->next) {
534 for (flds = gaim_request_field_group_get_fields(groups->data); flds && !ip_str; flds = flds->next) {
535 field = flds->data;
536 id = gaim_request_field_get_id(field);
537 value = gaim_request_field_string_get_value(field);
538
539 if (!g_ascii_strcasecmp(id, "ip")) {
540 ip_str = g_strdup(value);
541 break;
542 }
543 }
544 }
545
546 if(ip_str) {
547 ip = str_ip_gen(ip_str);
548 ip_dupstr = gen_ip_str(ip);
549
550 ip_value = ntohl(*(guint32 *)ip);
551 if (qq_ip_get_location(ip_value, &country, &city)) {
552 country_utf8 = qq_to_utf8(country, QQ_CHARSET_DEFAULT);
553 city_utf8 = qq_to_utf8(city, QQ_CHARSET_DEFAULT);
554 gaim_notify_info(gc, ip_dupstr, country_utf8, city_utf8);
555 g_free(country);
556 g_free(city);
557 g_free(country_utf8);
558 g_free(city_utf8);
559 }
560 else
561 gaim_notify_info(gc, ip_dupstr, "IP not found", NULL);
562 g_free(ip);
563 g_free(ip_dupstr);
564 g_free(ip_str);
565 }
566 }
567
568 static void _qq_menu_locate_ip(GaimPluginAction *action)
569 {
570 GaimConnection *gc = (GaimConnection *) action->context;
571 GaimRequestField *field;
572 GaimRequestFields *fields;
573 GaimRequestFieldGroup *group;
574
575 g_return_if_fail(gc != NULL);
576
577 fields = gaim_request_fields_new();
578 group = gaim_request_field_group_new(NULL);
579 gaim_request_fields_add_group(fields, group);
580
581 field = gaim_request_field_string_new("ip", _("IP Address"), NULL, FALSE);
582 gaim_request_field_group_add_field(group, field);
583
584 gaim_request_fields(gc, _("Locate an IP"),
585 _("Locate an IP address"), NULL, fields,
586 _("Check"), G_CALLBACK(_qq_menu_locate_ip_cb), _("Cancel"), NULL, gc);
587 }
588 */
589 509
590 static void _qq_menu_search_or_add_permanent_group(GaimPluginAction * action) 510 static void _qq_menu_search_or_add_permanent_group(GaimPluginAction * action)
591 { 511 {
592 gaim_gtk_roomlist_dialog_show(); 512 gaim_gtk_roomlist_dialog_show();
593 } 513 }
845 765
846 act = gaim_plugin_action_new(_("Qun: Create a permanent Qun"), _qq_menu_create_permanent_group); 766 act = gaim_plugin_action_new(_("Qun: Create a permanent Qun"), _qq_menu_create_permanent_group);
847 m = g_list_append(m, act); 767 m = g_list_append(m, act);
848 */ 768 */
849 769
850 /* XXX consider re-enabling this
851 act = gaim_plugin_action_new(_("Locate an IP"), _qq_menu_locate_ip);
852 m = g_list_append(m, act);
853 */
854
855 return m; 770 return m;
856 } 771 }
857 772
858 /* chat-related (QQ Qun) menu shown up with right-click */ 773 /* chat-related (QQ Qun) menu shown up with right-click */
859 /* XXX re-enable this 774 /* XXX re-enable this
1064 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); 979 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
1065 980
1066 my_protocol = plugin; 981 my_protocol = plugin;
1067 982
1068 gaim_prefs_add_none("/plugins/prpl/qq"); 983 gaim_prefs_add_none("/plugins/prpl/qq");
1069 gaim_prefs_add_string("/plugins/prpl/qq/ipfile", "");
1070 gaim_prefs_add_bool("/plugins/prpl/qq/show_status_by_icon", TRUE); 984 gaim_prefs_add_bool("/plugins/prpl/qq/show_status_by_icon", TRUE);
1071 gaim_prefs_add_bool("/plugins/prpl/qq/show_fake_video", FALSE); 985 gaim_prefs_add_bool("/plugins/prpl/qq/show_fake_video", FALSE);
1072 gaim_prefs_add_string("/plugins/prpl/qq/datadir", DATADIR); 986 gaim_prefs_add_string("/plugins/prpl/qq/datadir", DATADIR);
1073 gaim_prefs_add_bool("/plugins/prpl/qq/prompt_for_missing_packet", TRUE); 987 gaim_prefs_add_bool("/plugins/prpl/qq/prompt_for_missing_packet", TRUE);
1074 gaim_prefs_add_bool("/plugins/prpl/qq/prompt_group_msg_on_recv", TRUE); 988 gaim_prefs_add_bool("/plugins/prpl/qq/prompt_group_msg_on_recv", TRUE);