Mercurial > pidgin
comparison libpurple/protocols/qq/qq.c @ 24154:237e5a94e11c
2008.10.08 - ccpaging <ccpaging(at)gmail.com>
* Update group part
* Delete some meaningless functions and data
* Added 'change my icon'
2008.10.08 - lonicerae <lonicerae(at)gmail.com>
* Merge 20081008 patch into trunk
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 15:08:30 +0000 |
parents | d3811bdb6b07 |
children | 3c52353b83ae |
comparison
equal
deleted
inserted
replaced
24153:340fc40fe4ef | 24154:237e5a94e11c |
---|---|
472 | 472 |
473 return 1; | 473 return 1; |
474 } | 474 } |
475 | 475 |
476 /* send a chat msg to a QQ Qun */ | 476 /* send a chat msg to a QQ Qun */ |
477 static int qq_chat_send(PurpleConnection *gc, int channel, const char *message, PurpleMessageFlags flags) | 477 static int qq_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags) |
478 { | 478 { |
479 gchar *msg, *msg_with_qq_smiley; | 479 gchar *msg, *msg_with_qq_smiley; |
480 qq_group *group; | 480 guint32 room_id = id; |
481 | 481 |
482 g_return_val_if_fail(message != NULL, -1); | 482 g_return_val_if_fail(message != NULL, -1); |
483 g_return_val_if_fail(strlen(message) <= QQ_MSG_IM_MAX, -E2BIG); | 483 g_return_val_if_fail(strlen(message) <= QQ_MSG_IM_MAX, -E2BIG); |
484 | |
485 group = qq_group_find_by_channel(gc, channel); | |
486 g_return_val_if_fail(group != NULL, -1); | |
487 | 484 |
488 purple_debug_info("QQ_MESG", "Send qun mesg in utf8: %s\n", message); | 485 purple_debug_info("QQ_MESG", "Send qun mesg in utf8: %s\n", message); |
489 msg = utf8_to_qq(message, QQ_CHARSET_DEFAULT); | 486 msg = utf8_to_qq(message, QQ_CHARSET_DEFAULT); |
490 msg_with_qq_smiley = purple_smiley_to_qq(msg); | 487 msg_with_qq_smiley = purple_smiley_to_qq(msg); |
491 qq_send_packet_group_im(gc, group, msg_with_qq_smiley); | 488 qq_send_packet_group_im(gc, room_id, msg_with_qq_smiley); |
492 g_free(msg); | 489 g_free(msg); |
493 g_free(msg_with_qq_smiley); | 490 g_free(msg_with_qq_smiley); |
494 | 491 |
495 return 1; | 492 return 1; |
496 } | 493 } |
534 } | 531 } |
535 | 532 |
536 static void action_change_icon(PurplePluginAction *action) | 533 static void action_change_icon(PurplePluginAction *action) |
537 { | 534 { |
538 PurpleConnection *gc = (PurpleConnection *) action->context; | 535 PurpleConnection *gc = (PurpleConnection *) action->context; |
536 qq_data *qd; | |
537 gchar *icon_name; | |
538 gchar *icon_path; | |
539 | 539 |
540 g_return_if_fail(NULL != gc && NULL != gc->proto_data); | 540 g_return_if_fail(NULL != gc && NULL != gc->proto_data); |
541 | 541 qd = (qq_data *) gc->proto_data; |
542 purple_request_file(action, _("Select icon..."), NULL, | 542 |
543 if ( !qd->is_login ) { | |
544 return; | |
545 } | |
546 | |
547 icon_name = qq_get_icon_name(qd->my_icon); | |
548 icon_path = qq_get_icon_path(icon_name); | |
549 g_free(icon_name); | |
550 | |
551 purple_debug_info("QQ", "Change prev icon %s to ...\n", icon_path); | |
552 purple_request_file(action, _("Select icon..."), icon_path, | |
543 FALSE, | 553 FALSE, |
544 NULL, NULL, | 554 G_CALLBACK(qq_change_icon_cb), NULL, |
545 purple_connection_get_account(gc), NULL, NULL, | 555 purple_connection_get_account(gc), NULL, NULL, |
546 gc); | 556 gc); |
557 g_free(icon_path); | |
547 } | 558 } |
548 | 559 |
549 static void action_modify_info_base(PurplePluginAction *action) | 560 static void action_modify_info_base(PurplePluginAction *action) |
550 { | 561 { |
551 PurpleConnection *gc = (PurpleConnection *) action->context; | 562 PurpleConnection *gc = (PurpleConnection *) action->context; |
792 { | 803 { |
793 GList *m; | 804 GList *m; |
794 PurplePluginAction *act; | 805 PurplePluginAction *act; |
795 | 806 |
796 m = NULL; | 807 m = NULL; |
797 act = purple_plugin_action_new(_("Change icon"), action_change_icon); | 808 act = purple_plugin_action_new(_("Change Icon"), action_change_icon); |
798 m = g_list_append(m, act); | 809 m = g_list_append(m, act); |
799 | 810 |
800 act = purple_plugin_action_new(_("Modify Information"), action_modify_info_base); | 811 act = purple_plugin_action_new(_("Modify Information"), action_modify_info_base); |
801 m = g_list_append(m, act); | 812 m = g_list_append(m, act); |
802 | 813 |
869 #endif | 880 #endif |
870 | 881 |
871 return m; | 882 return m; |
872 } | 883 } |
873 | 884 |
885 /* convert name displayed in a chat channel to original QQ UID */ | |
886 static gchar *chat_name_to_purple_name(const gchar *const name) | |
887 { | |
888 const char *start; | |
889 const char *end; | |
890 gchar *ret; | |
891 | |
892 g_return_val_if_fail(name != NULL, NULL); | |
893 | |
894 /* Sample: (1234567)*/ | |
895 start = strchr(name, '('); | |
896 g_return_val_if_fail(start != NULL, NULL); | |
897 end = strchr(start, ')'); | |
898 g_return_val_if_fail(end != NULL && (end - start) > 1, NULL); | |
899 | |
900 ret = g_strndup(start + 1, end - start - 1); | |
901 | |
902 return ret; | |
903 } | |
904 | |
874 /* convert chat nickname to uid to get this buddy info */ | 905 /* convert chat nickname to uid to get this buddy info */ |
875 /* who is the nickname of buddy in QQ chat-room (Qun) */ | 906 /* who is the nickname of buddy in QQ chat-room (Qun) */ |
876 static void qq_get_chat_buddy_info(PurpleConnection *gc, gint channel, const gchar *who) | 907 static void qq_get_chat_buddy_info(PurpleConnection *gc, gint channel, const gchar *who) |
877 { | 908 { |
878 qq_data *qd; | 909 qq_data *qd; |
879 gchar *uid_str; | 910 gchar *uid_str; |
880 guint32 uid; | 911 guint32 uid; |
881 | 912 |
913 purple_debug_info("QQ", "Get chat buddy info of %s\n", who); | |
882 g_return_if_fail(who != NULL); | 914 g_return_if_fail(who != NULL); |
883 | 915 |
884 uid_str = chat_name_to_purple_name(who); | 916 uid_str = chat_name_to_purple_name(who); |
885 if (uid_str == NULL) { | 917 if (uid_str == NULL) { |
886 return; | 918 return; |
1091 | 1123 |
1092 option = purple_account_option_int_new(_("Update interval(s)"), "update_interval", 300); | 1124 option = purple_account_option_int_new(_("Update interval(s)"), "update_interval", 300); |
1093 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 1125 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
1094 | 1126 |
1095 purple_prefs_add_none("/plugins/prpl/qq"); | 1127 purple_prefs_add_none("/plugins/prpl/qq"); |
1096 purple_prefs_add_string("/plugins/prpl/qq/icon_dir", QQ_BUDDY_ICON_DIR); | |
1097 purple_prefs_add_bool("/plugins/prpl/qq/show_status_by_icon", TRUE); | 1128 purple_prefs_add_bool("/plugins/prpl/qq/show_status_by_icon", TRUE); |
1098 purple_prefs_add_bool("/plugins/prpl/qq/show_fake_video", FALSE); | 1129 purple_prefs_add_bool("/plugins/prpl/qq/show_fake_video", FALSE); |
1099 purple_prefs_add_bool("/plugins/prpl/qq/show_room_when_newin", TRUE); | 1130 purple_prefs_add_bool("/plugins/prpl/qq/show_room_when_newin", TRUE); |
1100 purple_prefs_add_int("/plugins/prpl/qq/resend_interval", 3); | 1131 purple_prefs_add_int("/plugins/prpl/qq/resend_interval", 3); |
1101 purple_prefs_add_int("/plugins/prpl/qq/resend_times", 10); | 1132 purple_prefs_add_int("/plugins/prpl/qq/resend_times", 10); |