comparison libpurple/protocols/qq/qq.c @ 24117:d57928c9dd8f

2008.09.19 - ccpaging <ccpaging(at)gmail.com> * Rewrite buddy modify info, there is a ticket for this problem * Use ship32 to trans action code between request packet and reply packet process
author SHiNE CsyFeK <csyfek@gmail.com>
date Fri, 19 Sep 2008 14:46:41 +0000
parents bcfc98c7a55f
children bdfcfd71449c
comparison
equal deleted inserted replaced
24116:b72816d1a131 24117:d57928c9dd8f
454 454
455 return 1; 455 return 1;
456 } 456 }
457 457
458 /* send packet to get who's detailed information */ 458 /* send packet to get who's detailed information */
459 static void _qq_get_info(PurpleConnection *gc, const gchar *who) 459 static void qq_show_buddy_info(PurpleConnection *gc, const gchar *who)
460 { 460 {
461 guint32 uid; 461 guint32 uid;
462 qq_data *qd; 462 qq_data *qd;
463 463
464 qd = gc->proto_data; 464 qd = gc->proto_data;
469 purple_notify_error(gc, NULL, _("Invalid name"), NULL); 469 purple_notify_error(gc, NULL, _("Invalid name"), NULL);
470 return; 470 return;
471 } 471 }
472 472
473 qq_request_get_level(gc, uid); 473 qq_request_get_level(gc, uid);
474 qq_send_packet_get_info(gc, uid, TRUE); 474 qq_request_buddy_info(gc, uid, 0, QQ_BUDDY_INFO_DISPLAY);
475 } 475 }
476 476
477 /* get my own information */ 477 static void action_update_all_rooms(PurplePluginAction *action)
478 static void _qq_menu_modify_my_info(PurplePluginAction *action)
479 { 478 {
480 PurpleConnection *gc = (PurpleConnection *) action->context; 479 PurpleConnection *gc = (PurpleConnection *) action->context;
481 qq_data *qd; 480 qq_data *qd;
482
483 qd = (qq_data *) gc->proto_data; 481 qd = (qq_data *) gc->proto_data;
484 qq_prepare_modify_info(gc); 482
485 } 483 if ( !qd->is_login ) {
486 484 return;
487 static void _qq_menu_change_password(PurplePluginAction *action) 485 }
486
487 qq_update_all_rooms(gc, 0, 0);
488 }
489
490 static void action_modify_info_base(PurplePluginAction *action)
491 {
492 PurpleConnection *gc = (PurpleConnection *) action->context;
493 qq_data *qd;
494
495 qd = (qq_data *) gc->proto_data;
496 qq_request_buddy_info(gc, qd->uid, 0, QQ_BUDDY_INFO_MODIFY_BASE);
497 }
498
499 static void action_modify_info_ext(PurplePluginAction *action)
500 {
501 PurpleConnection *gc = (PurpleConnection *) action->context;
502 qq_data *qd;
503
504 qd = (qq_data *) gc->proto_data;
505 qq_request_buddy_info(gc, qd->uid, 0, QQ_BUDDY_INFO_MODIFY_EXT);
506 }
507
508 static void action_modify_info_addr(PurplePluginAction *action)
509 {
510 PurpleConnection *gc = (PurpleConnection *) action->context;
511 qq_data *qd;
512
513 qd = (qq_data *) gc->proto_data;
514 qq_request_buddy_info(gc, qd->uid, 0, QQ_BUDDY_INFO_MODIFY_ADDR);
515 }
516
517 static void action_modify_info_contact(PurplePluginAction *action)
518 {
519 PurpleConnection *gc = (PurpleConnection *) action->context;
520 qq_data *qd;
521
522 qd = (qq_data *) gc->proto_data;
523 qq_request_buddy_info(gc, qd->uid, 0, QQ_BUDDY_INFO_MODIFY_CONTACT);
524 }
525
526 static void action_change_password(PurplePluginAction *action)
488 { 527 {
489 purple_notify_uri(NULL, "https://password.qq.com"); 528 purple_notify_uri(NULL, "https://password.qq.com");
490 } 529 }
491 530
492 /* remove a buddy from my list and remove myself from his list */
493 /* TODO: re-enable this
494 static void _qq_menu_block_buddy(PurpleBlistNode * node)
495 {
496 guint32 uid;
497 gc_and_uid *g;
498 PurpleBuddy *buddy;
499 PurpleConnection *gc;
500 const gchar *who;
501
502 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
503
504 buddy = (PurpleBuddy *) node;
505 gc = purple_account_get_connection(buddy->account);
506 who = buddy->name;
507 g_return_if_fail(who != NULL);
508
509 uid = purple_name_to_uid(who);
510 g_return_if_fail(uid > 0);
511
512 g = g_new0(gc_and_uid, 1);
513 g->gc = gc;
514 g->uid = uid;
515
516 purple_request_action(gc, _("Block Buddy"),
517 _("Are you sure you want to block this buddy?"), NULL,
518 1, g, 2,
519 _("Cancel"),
520 G_CALLBACK(qq_do_nothing_with_gc_and_uid),
521 _("Block"), G_CALLBACK(qq_block_buddy_with_gc_and_uid));
522 }
523 */
524
525 /* show a brief summary of what we get from login packet */ 531 /* show a brief summary of what we get from login packet */
526 static void _qq_menu_account_info(PurplePluginAction *action) 532 static void action_show_account_info(PurplePluginAction *action)
527 { 533 {
528 PurpleConnection *gc = (PurpleConnection *) action->context; 534 PurpleConnection *gc = (PurpleConnection *) action->context;
529 qq_data *qd; 535 qq_data *qd;
530 GString *info; 536 GString *info;
531 537
626 /* } */ 632 /* } */
627 } 633 }
628 #endif 634 #endif
629 635
630 /* protocol related menus */ 636 /* protocol related menus */
631 static GList *_qq_actions(PurplePlugin *plugin, gpointer context) 637 static GList *qq_actions(PurplePlugin *plugin, gpointer context)
632 { 638 {
633 GList *m; 639 GList *m;
634 PurplePluginAction *act; 640 PurplePluginAction *act;
635 641
636 m = NULL; 642 m = NULL;
637 act = purple_plugin_action_new(_("Set My Information"), _qq_menu_modify_my_info); 643 act = purple_plugin_action_new(_("Modify Information"), action_modify_info_base);
638 m = g_list_append(m, act); 644 m = g_list_append(m, act);
639 645
640 act = purple_plugin_action_new(_("Change Password"), _qq_menu_change_password); 646 act = purple_plugin_action_new(_("Modify Extend Information"), action_modify_info_ext);
641 m = g_list_append(m, act); 647 m = g_list_append(m, act);
642 648
643 act = purple_plugin_action_new(_("Account Information"), _qq_menu_account_info); 649 act = purple_plugin_action_new(_("Modify Address"), action_modify_info_addr);
650 m = g_list_append(m, act);
651
652 act = purple_plugin_action_new(_("Modify Contact"), action_modify_info_contact);
653 m = g_list_append(m, act);
654
655 act = purple_plugin_action_new(_("Change Password"), action_change_password);
656 m = g_list_append(m, act);
657
658 act = purple_plugin_action_new(_("Account Information"), action_show_account_info);
659 m = g_list_append(m, act);
660
661 act = purple_plugin_action_new(_("Update all QQ Quns"), action_update_all_rooms);
644 m = g_list_append(m, act); 662 m = g_list_append(m, act);
645 663
646 /* 664 /*
647 act = purple_plugin_action_new(_("Qun: Search a permanent Qun"), _qq_menu_search_or_add_permanent_group); 665 act = purple_plugin_action_new(_("Qun: Search a permanent Qun"), _qq_menu_search_or_add_permanent_group);
648 m = g_list_append(m, act); 666 m = g_list_append(m, act);
674 692
675 /* buddy-related menu shown up with right-click */ 693 /* buddy-related menu shown up with right-click */
676 static GList *_qq_buddy_menu(PurpleBlistNode * node) 694 static GList *_qq_buddy_menu(PurpleBlistNode * node)
677 { 695 {
678 GList *m; 696 GList *m;
697 PurpleMenuAction *act;
679 698
680 if(PURPLE_BLIST_NODE_IS_CHAT(node)) 699 if(PURPLE_BLIST_NODE_IS_CHAT(node))
681 return _qq_chat_menu(node); 700 return _qq_chat_menu(node);
682 701
683 m = NULL; 702 m = NULL;
684 703
704 act = purple_menu_action_new(_("Remove both side"), PURPLE_CALLBACK(qq_remove_buddy_and_me), NULL, NULL); /* add NULL by gfhuang */
705 m = g_list_append(m, act);
706
685 /* TODO : not working, temp commented out by gfhuang */ 707 /* TODO : not working, temp commented out by gfhuang */
686 #if 0 708 #if 0
687
688 act = purple_menu_action_new(_("Block this buddy"), PURPLE_CALLBACK(_qq_menu_block_buddy), NULL, NULL); /* add NULL by gfhuang */
689 m = g_list_append(m, act);
690 /* if (q_bud && is_online(q_bud->status)) { */ 709 /* if (q_bud && is_online(q_bud->status)) { */
691 act = purple_menu_action_new(_("Send File"), PURPLE_CALLBACK(_qq_menu_send_file), NULL, NULL); /* add NULL by gfhuang */ 710 act = purple_menu_action_new(_("Send File"), PURPLE_CALLBACK(_qq_menu_send_file), NULL, NULL); /* add NULL by gfhuang */
692 m = g_list_append(m, act); 711 m = g_list_append(m, act);
693 /* } */ 712 /* } */
694 #endif 713 #endif
703 gchar *purple_name; 722 gchar *purple_name;
704 g_return_if_fail(who != NULL); 723 g_return_if_fail(who != NULL);
705 724
706 purple_name = chat_name_to_purple_name(who); 725 purple_name = chat_name_to_purple_name(who);
707 if (purple_name != NULL) 726 if (purple_name != NULL)
708 _qq_get_info(gc, purple_name); 727 qq_show_buddy_info(gc, purple_name);
709 } 728 }
710 729
711 /* convert chat nickname to qq-uid to invite individual IM to buddy */ 730 /* convert chat nickname to qq-uid to invite individual IM to buddy */
712 /* who is the nickname of buddy in QQ chat-room (Qun) */ 731 /* who is the nickname of buddy in QQ chat-room (Qun) */
713 static gchar *_qq_get_chat_buddy_real_name(PurpleConnection *gc, gint channel, const gchar *who) 732 static gchar *_qq_get_chat_buddy_real_name(PurpleConnection *gc, gint channel, const gchar *who)
733 qq_login, /* open */ 752 qq_login, /* open */
734 qq_close, /* close */ 753 qq_close, /* close */
735 _qq_send_im, /* send_im */ 754 _qq_send_im, /* send_im */
736 NULL, /* set_info */ 755 NULL, /* set_info */
737 NULL, /* send_typing */ 756 NULL, /* send_typing */
738 _qq_get_info, /* get_info */ 757 qq_show_buddy_info, /* get_info */
739 _qq_change_status, /* change status */ 758 _qq_change_status, /* change status */
740 NULL, /* set_idle */ 759 NULL, /* set_idle */
741 NULL, /* change_passwd */ 760 NULL, /* change_passwd */
742 qq_add_buddy, /* add_buddy */ 761 qq_add_buddy, /* add_buddy */
743 NULL, /* add_buddies */ 762 NULL, /* add_buddies */
758 NULL, /* keepalive */ 777 NULL, /* keepalive */
759 NULL, /* register_user */ 778 NULL, /* register_user */
760 _qq_get_chat_buddy_info, /* get_cb_info */ 779 _qq_get_chat_buddy_info, /* get_cb_info */
761 NULL, /* get_cb_away */ 780 NULL, /* get_cb_away */
762 NULL, /* alias_buddy */ 781 NULL, /* alias_buddy */
763 NULL, /* group_buddy */ 782 qq_change_buddys_group, /* group_buddy */
764 NULL, /* rename_group */ 783 NULL, /* rename_group */
765 NULL, /* buddy_free */ 784 NULL, /* buddy_free */
766 NULL, /* convo_closed */ 785 NULL, /* convo_closed */
767 NULL, /* normalize */ 786 NULL, /* normalize */
768 qq_set_my_buddy_icon, /* set_buddy_icon */ 787 qq_set_buddy_icon, /* set_buddy_icon */
769 NULL, /* remove_group */ 788 NULL, /* remove_group */
770 _qq_get_chat_buddy_real_name, /* get_cb_real_name */ 789 _qq_get_chat_buddy_real_name, /* get_cb_real_name */
771 NULL, /* set_chat_topic */ 790 NULL, /* set_chat_topic */
772 NULL, /* find_blist_chat */ 791 NULL, /* find_blist_chat */
773 qq_roomlist_get_list, /* roomlist_get_list */ 792 qq_roomlist_get_list, /* roomlist_get_list */
813 NULL, /**< destroy */ 832 NULL, /**< destroy */
814 833
815 NULL, /**< ui_info */ 834 NULL, /**< ui_info */
816 &prpl_info, /**< extra_info */ 835 &prpl_info, /**< extra_info */
817 NULL, /**< prefs_info */ 836 NULL, /**< prefs_info */
818 _qq_actions, 837 qq_actions,
819 838
820 /* padding */ 839 /* padding */
821 NULL, 840 NULL,
822 NULL, 841 NULL,
823 NULL, 842 NULL,
876 purple_prefs_add_none("/plugins/prpl/qq"); 895 purple_prefs_add_none("/plugins/prpl/qq");
877 purple_prefs_add_bool("/plugins/prpl/qq/show_status_by_icon", TRUE); 896 purple_prefs_add_bool("/plugins/prpl/qq/show_status_by_icon", TRUE);
878 purple_prefs_add_bool("/plugins/prpl/qq/show_fake_video", FALSE); 897 purple_prefs_add_bool("/plugins/prpl/qq/show_fake_video", FALSE);
879 purple_prefs_add_bool("/plugins/prpl/qq/show_room_when_newin", TRUE); 898 purple_prefs_add_bool("/plugins/prpl/qq/show_room_when_newin", TRUE);
880 purple_prefs_add_int("/plugins/prpl/qq/resend_interval", 3); 899 purple_prefs_add_int("/plugins/prpl/qq/resend_interval", 3);
881 purple_prefs_add_int("/plugins/prpl/qq/resend_times", 4); 900 purple_prefs_add_int("/plugins/prpl/qq/resend_times", 10);
882 } 901 }
883 902
884 PURPLE_INIT_PLUGIN(qq, init_plugin, info); 903 PURPLE_INIT_PLUGIN(qq, init_plugin, info);