comparison src/protocols/jabber/buddy.c @ 9030:7ab20f829190

[gaim-migrate @ 9806] Siege updated the code for creating right-click menu's for buddies, chats, groups, etc. It uses more stuff from the blist API and less stuff from multi.h. It also combines the code for right-click menus for chats, buddies, etc. (all types of blist nodes). So PRPLs and plugins can easily add right-click menu options to anything in the buddy list in a clean way. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 23 May 2004 17:27:45 +0000
parents 67421e0dc497
children 7a8aa87164ae
comparison
equal deleted inserted replaced
9029:697e169dac12 9030:7ab20f829190
833 833
834 jabber_send(js, presence); 834 jabber_send(js, presence);
835 xmlnode_free(presence); 835 xmlnode_free(presence);
836 } 836 }
837 837
838 static void jabber_buddy_make_invisible(GaimConnection *gc, const char *name) 838 static void jabber_buddy_make_invisible(GaimBlistNode *node, gpointer data)
839 { 839 {
840 GaimBuddy *buddy;
841 GaimConnection *gc;
842 JabberStream *js;
843
844 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
845
846 buddy = (GaimBuddy *) node;
847 gc = gaim_account_get_connection(buddy->account);
848 js = gc->proto_data;
849
850 jabber_buddy_set_invisibility(js, buddy->name, TRUE);
851 }
852
853 static void jabber_buddy_make_visible(GaimBlistNode *node, gpointer data)
854 {
855 GaimBuddy *buddy;
856 GaimConnection *gc;
857 JabberStream *js;
858
859 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
860
861 buddy = (GaimBuddy *) node;
862 gc = gaim_account_get_connection(buddy->account);
863 js = gc->proto_data;
864
865 jabber_buddy_set_invisibility(js, buddy->name, FALSE);
866 }
867
868 static void jabber_buddy_cancel_presence_notification(GaimBlistNode *node,
869 gpointer data)
870 {
871 GaimBuddy *buddy;
872 GaimConnection *gc;
873 JabberStream *js;
874
875 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
876
877 buddy = (GaimBuddy *) node;
878 gc = gaim_account_get_connection(buddy->account);
879 js = gc->proto_data;
880
881 /* I wonder if we should prompt the user before doing this */
882 jabber_presence_subscription_set(js, buddy->name, "unsubscribed");
883 }
884
885 static void jabber_buddy_rerequest_auth(GaimBlistNode *node, gpointer data)
886 {
887 GaimBuddy *buddy;
888 GaimConnection *gc;
889 JabberStream *js;
890
891 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
892
893 buddy = (GaimBuddy *) node;
894 gc = gaim_account_get_connection(buddy->account);
895 js = gc->proto_data;
896
897 jabber_presence_subscription_set(js, buddy->name, "subscribe");
898 }
899
900
901 static void jabber_buddy_unsubscribe(GaimBlistNode *node, gpointer data)
902 {
903 GaimBuddy *buddy;
904 GaimConnection *gc;
905 JabberStream *js;
906
907 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
908
909 buddy = (GaimBuddy *) node;
910 gc = gaim_account_get_connection(buddy->account);
911 js = gc->proto_data;
912
913 jabber_presence_subscription_set(js, buddy->name, "unsubscribe");
914 }
915
916
917 GList *jabber_buddy_menu(GaimBuddy *buddy)
918 {
919 GaimConnection *gc = gaim_account_get_connection(buddy->account);
840 JabberStream *js = gc->proto_data; 920 JabberStream *js = gc->proto_data;
841 jabber_buddy_set_invisibility(js, name, TRUE); 921 JabberBuddy *jb = jabber_buddy_find(js, buddy->name, TRUE);
842 } 922
843
844 static void jabber_buddy_make_visible(GaimConnection *gc, const char *name)
845 {
846 JabberStream *js = gc->proto_data;
847 jabber_buddy_set_invisibility(js, name, FALSE);
848 }
849
850 static void jabber_buddy_cancel_presence_notification(GaimConnection *gc,
851 const char *name)
852 {
853 JabberStream *js = gc->proto_data;
854
855 /* I wonder if we should prompt the user before doing this */
856 jabber_presence_subscription_set(js, name, "unsubscribed");
857 }
858
859 static void jabber_buddy_rerequest_auth(GaimConnection *gc, const char *name)
860 {
861 JabberStream *js = gc->proto_data;
862
863 jabber_presence_subscription_set(js, name, "subscribe");
864 }
865
866 static void jabber_buddy_unsubscribe(GaimConnection *gc, const char *name)
867 {
868 JabberStream *js = gc->proto_data;
869
870 jabber_presence_subscription_set(js, name, "unsubscribe");
871 }
872
873 GList *jabber_buddy_menu(GaimConnection *gc, const char *name)
874 {
875 GList *m = NULL; 923 GList *m = NULL;
876 struct proto_buddy_menu *pbm; 924 GaimBlistNodeAction *act;
877 JabberStream *js = gc->proto_data;
878 JabberBuddy *jb = jabber_buddy_find(js, name, TRUE);
879 925
880 if(!jb) 926 if(!jb)
881 return m; 927 return m;
882 928
883 pbm = g_new0(struct proto_buddy_menu, 1); 929 act = gaim_blist_node_action_new(_("Send File"),
884 pbm->label = _("Send File"); 930 jabber_si_xfer_ask_send, NULL);
885 pbm->callback = jabber_si_xfer_ask_send; 931 m = g_list_append(m, act);
886 pbm->gc = gc;
887 m = g_list_append(m, pbm);
888 932
889 /* XXX: fix the NOT ME below */ 933 /* XXX: fix the NOT ME below */
890 934
891 if(js->protocol_version == JABBER_PROTO_0_9 /* && NOT ME */) { 935 if(js->protocol_version == JABBER_PROTO_0_9 /* && NOT ME */) {
892 pbm = g_new0(struct proto_buddy_menu, 1);
893 if(jb->invisible & JABBER_INVIS_BUDDY) { 936 if(jb->invisible & JABBER_INVIS_BUDDY) {
894 pbm->label = _("Un-hide From"); 937 act = gaim_blist_node_action_new(_("Un-hide From"),
895 pbm->callback = jabber_buddy_make_visible; 938 jabber_buddy_make_visible, NULL);
896 } else { 939 } else {
897 pbm->label = _("Temporarily Hide From"); 940 act = gaim_blist_node_action_new(_("Temporarily Hide From"),
898 pbm->callback = jabber_buddy_make_invisible; 941 jabber_buddy_make_invisible, NULL);
899 } 942 }
900 pbm->gc = gc; 943 m = g_list_append(m, act);
901 m = g_list_append(m, pbm);
902 } 944 }
903 945
904 if(jb->subscription & JABBER_SUB_FROM /* && NOT ME */) { 946 if(jb->subscription & JABBER_SUB_FROM /* && NOT ME */) {
905 pbm = g_new0(struct proto_buddy_menu, 1); 947 act = gaim_blist_node_action_new(_("Cancel Presence Notification"),
906 pbm->label = _("Cancel Presence Notification"); 948 jabber_buddy_cancel_presence_notification, NULL);
907 pbm->callback = jabber_buddy_cancel_presence_notification; 949 m = g_list_append(m, act);
908 pbm->gc = gc;
909 m = g_list_append(m, pbm);
910 } 950 }
911 951
912 if(!(jb->subscription & JABBER_SUB_TO)) { 952 if(!(jb->subscription & JABBER_SUB_TO)) {
913 pbm = g_new0(struct proto_buddy_menu, 1); 953 act = gaim_blist_node_action_new(_("(Re-)Request authorization"),
914 pbm->label = _("(Re-)Request authorization"); 954 jabber_buddy_rerequest_auth, NULL);
915 pbm->callback = jabber_buddy_rerequest_auth; 955 m = g_list_append(m, act);
916 pbm->gc = gc; 956
917 m = g_list_append(m, pbm);
918 } else /* if(NOT ME) */{ 957 } else /* if(NOT ME) */{
919 pbm = g_new0(struct proto_buddy_menu, 1); 958
920 pbm->label = _("Unsubscribe"); 959 /* shouldn't this just happen automatically when the buddy is
921 pbm->callback = jabber_buddy_unsubscribe; 960 removed? */
922 pbm->gc = gc; 961 act = gaim_blist_node_action_new(_("Unsubscribe"),
923 m = g_list_append(m, pbm); 962 jabber_buddy_unsubscribe, NULL);
963 m = g_list_append(m, act);
924 } 964 }
925 965
926 return m; 966 return m;
927 } 967 }
968
969 GList *
970 jabber_blist_node_menu(GaimBlistNode *node)
971 {
972 if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
973 return jabber_buddy_menu((GaimBuddy *) node);
974 } else {
975 return NULL;
976 }
977 }
978
979