Mercurial > pidgin
comparison src/protocols/oscar/oscar.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 | 53c1e635f11d |
children | cde9fb3546ed |
comparison
equal
deleted
inserted
replaced
9029:697e169dac12 | 9030:7ab20f829190 |
---|---|
1342 g_free(data->who); | 1342 g_free(data->who); |
1343 g_free(data); | 1343 g_free(data); |
1344 } | 1344 } |
1345 | 1345 |
1346 /* this is the right click menu cb thingy */ | 1346 /* this is the right click menu cb thingy */ |
1347 static void oscar_ask_direct_im(GaimConnection *gc, const char *who) { | 1347 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1348 | |
1349 GaimBuddy *buddy; | |
1350 GaimConnection *gc; | |
1348 gchar *buf; | 1351 gchar *buf; |
1349 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); | 1352 struct ask_do_dir_im *data; |
1350 data->who = g_strdup(who); | 1353 |
1354 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1355 | |
1356 buddy = (GaimBuddy *) node; | |
1357 gc = gaim_account_get_connection(buddy->account); | |
1358 | |
1359 data = g_new0(struct ask_do_dir_im, 1); | |
1360 data->who = g_strdup(buddy->name); | |
1351 data->gc = gc; | 1361 data->gc = gc; |
1352 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), who); | 1362 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1363 buddy->name); | |
1353 | 1364 |
1354 gaim_request_action(gc, NULL, buf, | 1365 gaim_request_action(gc, NULL, buf, |
1355 _("Because this reveals your IP address, it " | 1366 _("Because this reveals your IP address, it " |
1356 "may be considered a privacy risk. Do you " | 1367 "may be considered a privacy risk. Do you " |
1357 "wish to continue?"), | 1368 "wish to continue?"), |
1358 0, data, 2, | 1369 0, data, 2, |
1359 _("Connect"), G_CALLBACK(oscar_direct_im), | 1370 _("Connect"), G_CALLBACK(oscar_direct_im), |
1360 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | 1371 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); |
1361 g_free(buf); | 1372 g_free(buf); |
1362 } | 1373 } |
1363 | 1374 |
1364 /***************************************************************************** | 1375 /***************************************************************************** |
1365 * End scary direct im stuff | 1376 * End scary direct im stuff |
1906 xfer->fd = 0; | 1917 xfer->fd = 0; |
1907 gaim_xfer_set_completed(xfer, TRUE); | 1918 gaim_xfer_set_completed(xfer, TRUE); |
1908 } | 1919 } |
1909 } | 1920 } |
1910 | 1921 |
1911 static void oscar_ask_sendfile(GaimConnection *gc, const char *destsn) { | 1922 static void oscar_ask_sendfile(GaimBlistNode *node, gpointer data) { |
1912 OscarData *od = (OscarData *)gc->proto_data; | 1923 |
1924 GaimBuddy *buddy; | |
1925 GaimConnection *gc; | |
1926 | |
1927 OscarData *od; | |
1913 GaimXfer *xfer; | 1928 GaimXfer *xfer; |
1914 struct aim_oft_info *oft_info; | 1929 struct aim_oft_info *oft_info; |
1915 const char *ip; | 1930 const char *ip; |
1916 | 1931 |
1932 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1933 | |
1934 buddy = (GaimBuddy *) node; | |
1935 gc = gaim_account_get_connection(buddy->account); | |
1936 od = (OscarData *)gc->proto_data; | |
1937 | |
1917 /* You want to send a file to someone else, you're so generous */ | 1938 /* You want to send a file to someone else, you're so generous */ |
1918 | 1939 |
1919 /* Build the file transfer handle */ | 1940 /* Build the file transfer handle */ |
1920 xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, destsn); | 1941 xfer = gaim_xfer_new(buddy->account, GAIM_XFER_SEND, buddy->name); |
1921 | 1942 |
1922 /* Create the oscar-specific data */ | 1943 /* Create the oscar-specific data */ |
1923 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); | 1944 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
1924 oft_info = aim_oft_createinfo(od->sess, NULL, destsn, ip, 0, 0, 0, NULL); | 1945 oft_info = aim_oft_createinfo(od->sess, NULL, buddy->name, ip, 0, 0, 0, NULL); |
1925 xfer->data = oft_info; | 1946 xfer->data = oft_info; |
1926 | 1947 |
1927 /* Setup our I/O op functions */ | 1948 /* Setup our I/O op functions */ |
1928 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); | 1949 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
1929 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); | 1950 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
3322 } | 3343 } |
3323 | 3344 |
3324 oscar_free_name_data(data); | 3345 oscar_free_name_data(data); |
3325 } | 3346 } |
3326 | 3347 |
3327 static void gaim_auth_sendrequest(GaimConnection *gc, const char *name) { | 3348 |
3349 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
3328 struct name_data *data = g_new(struct name_data, 1); | 3350 struct name_data *data = g_new(struct name_data, 1); |
3329 GaimBuddy *buddy; | 3351 GaimBuddy *buddy; |
3330 gchar *dialog_msg, *nombre; | 3352 gchar *dialog_msg, *nombre; |
3331 | 3353 |
3332 buddy = gaim_find_buddy(gc->account, name); | 3354 buddy = gaim_find_buddy(gc->account, name); |
3346 G_CALLBACK(gaim_auth_request_msgprompt), | 3368 G_CALLBACK(gaim_auth_request_msgprompt), |
3347 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); | 3369 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
3348 | 3370 |
3349 g_free(dialog_msg); | 3371 g_free(dialog_msg); |
3350 g_free(nombre); | 3372 g_free(nombre); |
3373 } | |
3374 | |
3375 | |
3376 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3377 GaimBuddy *buddy; | |
3378 GaimConnection *gc; | |
3379 | |
3380 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3381 | |
3382 buddy = (GaimBuddy *) node; | |
3383 gc = gaim_account_get_connection(buddy->account); | |
3384 gaim_auth_sendrequest(gc, buddy->name); | |
3351 } | 3385 } |
3352 | 3386 |
3353 /* When other people ask you for authorization */ | 3387 /* When other people ask you for authorization */ |
3354 static void gaim_auth_grant(struct name_data *data) { | 3388 static void gaim_auth_grant(struct name_data *data) { |
3355 GaimConnection *gc = data->gc; | 3389 GaimConnection *gc = data->gc; |
5066 } | 5100 } |
5067 } | 5101 } |
5068 } | 5102 } |
5069 return 0; | 5103 return 0; |
5070 } | 5104 } |
5071 static void oscar_ask_direct_im(GaimConnection *gc, const char *name); | 5105 |
5072 static int gaim_odc_send_im(aim_session_t *, aim_conn_t *, const char *, GaimConvImFlags); | 5106 static int gaim_odc_send_im(aim_session_t *, aim_conn_t *, const char *, GaimConvImFlags); |
5073 | 5107 |
5074 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { | 5108 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
5075 OscarData *od = (OscarData *)gc->proto_data; | 5109 OscarData *od = (OscarData *)gc->proto_data; |
5076 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); | 5110 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
6622 gaim_check_comment(od, text); | 6656 gaim_check_comment(od, text); |
6623 | 6657 |
6624 oscar_free_name_data(data); | 6658 oscar_free_name_data(data); |
6625 } | 6659 } |
6626 | 6660 |
6627 static void oscar_buddycb_edit_comment(GaimConnection *gc, const char *name) { | 6661 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6628 OscarData *od = gc->proto_data; | 6662 |
6629 struct name_data *data = g_new(struct name_data, 1); | 6663 GaimBuddy *buddy; |
6630 GaimBuddy *b; | 6664 GaimConnection *gc; |
6665 OscarData *od; | |
6666 struct name_data *data; | |
6631 GaimGroup *g; | 6667 GaimGroup *g; |
6632 char *comment; | 6668 char *comment; |
6633 gchar *comment_utf8; | 6669 gchar *comment_utf8; |
6634 | 6670 |
6635 if (!(b = gaim_find_buddy(gaim_connection_get_account(gc), name))) | 6671 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6672 | |
6673 buddy = (GaimBuddy *) node; | |
6674 gc = gaim_account_get_connection(buddy->account); | |
6675 od = gc->proto_data; | |
6676 | |
6677 data = g_new(struct name_data, 1); | |
6678 | |
6679 if (!(g = gaim_find_buddys_group(buddy))) | |
6636 return; | 6680 return; |
6637 if (!(g = gaim_find_buddys_group(b))) | 6681 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
6638 return; | |
6639 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, name); | |
6640 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; | 6682 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6641 | 6683 |
6642 data->gc = gc; | 6684 data->gc = gc; |
6643 data->name = g_strdup(name); | 6685 data->name = g_strdup(buddy->name); |
6644 data->nick = NULL; | 6686 data->nick = NULL; |
6645 | 6687 |
6646 gaim_request_input(gc, NULL, _("Buddy Comment:"), NULL, | 6688 gaim_request_input(gc, NULL, _("Buddy Comment:"), NULL, |
6647 comment_utf8, TRUE, FALSE, NULL, | 6689 comment_utf8, TRUE, FALSE, NULL, |
6648 _("OK"), G_CALLBACK(oscar_ssi_editcomment), | 6690 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
6651 | 6693 |
6652 free(comment); | 6694 free(comment); |
6653 g_free(comment_utf8); | 6695 g_free(comment_utf8); |
6654 } | 6696 } |
6655 | 6697 |
6656 static GList *oscar_buddy_menu(GaimConnection *gc, const char *who) { | 6698 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
6699 | |
6700 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
6657 OscarData *od = gc->proto_data; | 6701 OscarData *od = gc->proto_data; |
6702 | |
6658 GList *m = NULL; | 6703 GList *m = NULL; |
6659 struct proto_buddy_menu *pbm; | 6704 GaimBlistNodeAction *act; |
6660 | 6705 |
6661 pbm = g_new0(struct proto_buddy_menu, 1); | 6706 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), |
6662 pbm->label = _("Edit Buddy Comment"); | 6707 oscar_buddycb_edit_comment, NULL); |
6663 pbm->callback = oscar_buddycb_edit_comment; | 6708 m = g_list_append(m, act); |
6664 pbm->gc = gc; | |
6665 m = g_list_append(m, pbm); | |
6666 | 6709 |
6667 if (od->icq) { | 6710 if (od->icq) { |
6668 #if 0 | 6711 #if 0 |
6669 pbm = g_new0(struct proto_buddy_menu, 1); | 6712 act = gaim_blist_node_action_new(_("Get Status Msg"), |
6670 pbm->label = _("Get Status Msg"); | 6713 oscar_get_icqstatusmsg, NULL); |
6671 pbm->callback = oscar_get_icqstatusmsg; | 6714 m = g_list_append(m, act); |
6672 pbm->gc = gc; | |
6673 m = g_list_append(m, pbm); | |
6674 #endif | 6715 #endif |
6675 } else { | 6716 } else { |
6676 GaimBuddy *b = gaim_find_buddy(gc->account, who); | |
6677 aim_userinfo_t *userinfo; | 6717 aim_userinfo_t *userinfo; |
6678 | 6718 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
6679 if (b) | 6719 |
6680 userinfo = aim_locate_finduserinfo(od->sess, b->name); | 6720 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && |
6681 | 6721 GAIM_BUDDY_IS_ONLINE(buddy)) { |
6682 if (b && userinfo && aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), who) && GAIM_BUDDY_IS_ONLINE(b)) { | 6722 |
6683 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { | 6723 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
6684 pbm = g_new0(struct proto_buddy_menu, 1); | 6724 act = gaim_blist_node_action_new(_("Direct IM"), |
6685 pbm->label = _("Direct IM"); | 6725 oscar_ask_direct_im, NULL); |
6686 pbm->callback = oscar_ask_direct_im; | 6726 m = g_list_append(m, act); |
6687 pbm->gc = gc; | |
6688 m = g_list_append(m, pbm); | |
6689 } | 6727 } |
6690 | 6728 |
6691 if (userinfo->capabilities & AIM_CAPS_SENDFILE) { | 6729 if (userinfo->capabilities & AIM_CAPS_SENDFILE) { |
6692 pbm = g_new0(struct proto_buddy_menu, 1); | 6730 act = gaim_blist_node_action_new(_("Send File"), |
6693 pbm->label = _("Send File"); | 6731 oscar_ask_sendfile, NULL); |
6694 pbm->callback = oscar_ask_sendfile; | 6732 m = g_list_append(m, act); |
6695 pbm->gc = gc; | |
6696 m = g_list_append(m, pbm); | |
6697 } | 6733 } |
6698 #if 0 | 6734 #if 0 |
6699 if (userinfo->capabilities & AIM_CAPS_GETFILE) { | 6735 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
6700 pbm = g_new0(struct proto_buddy_menu, 1); | 6736 act = gaim_blist_node_action_new(_("Get File"), |
6701 pbm->label = _("Get File"); | 6737 oscar_ask_getfile, NULL); |
6702 pbm->callback = oscar_ask_getfile; | 6738 m = g_list_append(m, act); |
6703 pbm->gc = gc; | |
6704 m = g_list_append(m, pbm); | |
6705 } | 6739 } |
6706 #endif | 6740 #endif |
6707 } | 6741 } |
6708 } | 6742 } |
6709 | 6743 |
6710 if (od->sess->ssi.received_data) { | 6744 if (od->sess->ssi.received_data) { |
6711 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, who); | 6745 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
6712 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, who)) { | 6746 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { |
6713 pbm = g_new0(struct proto_buddy_menu, 1); | 6747 act = gaim_blist_node_action_new(_("Re-request Authorization"), |
6714 pbm->label = _("Re-request Authorization"); | 6748 gaim_auth_sendrequest_menu, NULL); |
6715 pbm->callback = gaim_auth_sendrequest; | 6749 m = g_list_append(m, act); |
6716 pbm->gc = gc; | |
6717 m = g_list_append(m, pbm); | |
6718 } | 6750 } |
6719 } | 6751 } |
6720 | 6752 |
6721 return m; | 6753 return m; |
6722 } | 6754 } |
6755 | |
6756 | |
6757 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
6758 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
6759 return oscar_buddy_menu((GaimBuddy *) node); | |
6760 } else { | |
6761 return NULL; | |
6762 } | |
6763 } | |
6764 | |
6723 | 6765 |
6724 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { | 6766 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
6725 OscarData *od = gc->proto_data; | 6767 OscarData *od = gc->proto_data; |
6726 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { | 6768 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
6727 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { | 6769 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7070 oscar_list_icon, | 7112 oscar_list_icon, |
7071 oscar_list_emblems, | 7113 oscar_list_emblems, |
7072 oscar_status_text, | 7114 oscar_status_text, |
7073 oscar_tooltip_text, | 7115 oscar_tooltip_text, |
7074 oscar_away_states, | 7116 oscar_away_states, |
7075 oscar_buddy_menu, | 7117 oscar_blist_node_menu, |
7076 oscar_chat_info, | 7118 oscar_chat_info, |
7077 oscar_login, | 7119 oscar_login, |
7078 oscar_close, | 7120 oscar_close, |
7079 oscar_send_im, | 7121 oscar_send_im, |
7080 oscar_set_info, | 7122 oscar_set_info, |
7120 NULL, | 7162 NULL, |
7121 NULL, | 7163 NULL, |
7122 NULL, | 7164 NULL, |
7123 NULL, | 7165 NULL, |
7124 NULL, | 7166 NULL, |
7125 NULL, | |
7126 NULL | 7167 NULL |
7127 }; | 7168 }; |
7128 | 7169 |
7129 static GaimPluginInfo info = | 7170 static GaimPluginInfo info = |
7130 { | 7171 { |