# HG changeset patch # User Mark Doliner # Date 1116910467 0 # Node ID ca3e0882d377a8ad64a5e721eb6e041a9ab0592b # Parent ea9e65f52b4b8d669ad2fa13417af6db8ff313ee [gaim-migrate @ 12721] sf patch #1202156, from Bleeter Yaluser . Forward port privacy . Tidy up whitespace . Remove file TX send limit committer: Tailor Script diff -r ea9e65f52b4b -r ca3e0882d377 ChangeLog --- a/ChangeLog Tue May 24 04:46:51 2005 +0000 +++ b/ChangeLog Tue May 24 04:54:27 2005 +0000 @@ -11,7 +11,6 @@ * Screenname colors in chats now chosen intelligently from GNOME color palette * New "find buddy" results dialog (Alex Converse) - * Yahoo! has the following new "/" commands: /join, /buzz * Smiley selection dialog rewritten to look nicer (Nathan Fredrickson) * If Gaim is exited with the buddy list hidden in the docklet, it will remain hidden when Gaim is started again (Scott Shedden) diff -r ea9e65f52b4b -r ca3e0882d377 src/protocols/yahoo/yahoo.c --- a/src/protocols/yahoo/yahoo.c Tue May 24 04:46:51 2005 +0000 +++ b/src/protocols/yahoo/yahoo.c Tue May 24 04:54:27 2005 +0000 @@ -54,6 +54,92 @@ static void yahoo_add_buddy(GaimConnection *gc, GaimBuddy *, GaimGroup *); static void yahoo_login_page_cb(void *user_data, const char *buf, size_t len); +static void +yahoo_add_permit(GaimConnection *gc, const char *who) +{ + gaim_debug_info("yahoo", + "Permitting ID %s local contact rights for account %s\n", who, gc->account); + gaim_privacy_permit_add(gc->account,who,TRUE); +} + +static void +yahoo_rem_permit(GaimConnection *gc, const char *who) +{ + gaim_debug_info("yahoo", + "Denying ID %s local contact rights for account %s\n", who, gc->account); + gaim_privacy_permit_remove(gc->account,who,TRUE); +} + +gboolean yahoo_privacy_check(GaimConnection *gc, const char *who) +{ + /* returns TRUE if allowed through, FALSE otherwise */ + GSList *list; + gboolean permitted=FALSE; + + switch (gc->account->perm_deny) { + case 0: + gaim_debug_warning("yahoo", "Privacy setting was 0. If you can " + "reproduce this, please file a bug report.\n"); + permitted = TRUE; + break; + + case GAIM_PRIVACY_ALLOW_ALL: + permitted = TRUE; + break; + + case GAIM_PRIVACY_DENY_ALL: + gaim_debug_info("yahoo", + "%s blocked data received from %s (GAIM_PRIVACY_DENY_ALL)\n", + gc->account->username,who); + break; + + case GAIM_PRIVACY_ALLOW_USERS: + for( list=gc->account->permit; list!=NULL; list=list->next ) { + if ( !gaim_utf8_strcasecmp(who, gaim_normalize(gc->account, + (char *)list->data)) ) { + permitted=TRUE; + gaim_debug_info("yahoo", + "%s allowed data received from %s (GAIM_PRIVACY_ALLOW_USERS)\n", + gc->account->username,who); + break; + } + } + break; + + case GAIM_PRIVACY_DENY_USERS: + /* seeing we're letting everyone through, except the deny list*/ + permitted=TRUE; + for( list=gc->account->deny; list!=NULL; list=list->next ) { + if ( !gaim_utf8_strcasecmp(who, gaim_normalize( gc->account, + (char *)list->data )) ) { + permitted=FALSE; + gaim_debug_info("yahoo", + "%s blocked data received from %s (GAIM_PRIVACY_DENY_USERS)\n", + gc->account->username,who); + } + break; + } + break; + + case GAIM_PRIVACY_ALLOW_BUDDYLIST: + if ( gaim_find_buddy(gc->account,who) != NULL ) { + permitted = TRUE; + } else { + gaim_debug_info("yahoo", + "%s blocked data received from %s (GAIM_PRIVACY_ALLOW_BUDDYLIST)\n", + gc->account->username,who); + } + break; + + default: + gaim_debug_warning("yahoo", "Privacy setting was unknown. If you can " + "reproduce this, please file a bug report.\n"); + permitted = FALSE; + break; + } + + return permitted; +} static void yahoo_update_status(GaimConnection *gc, const char *name, YahooFriend *f) { @@ -521,10 +607,16 @@ yd->tmp_serv_ilist = NULL; } - if (got_serv_list) { - gc->account->perm_deny = 4; - serv_set_permit_deny(gc); + if (got_serv_list && + ((gc->account->perm_deny != GAIM_PRIVACY_ALLOW_BUDDYLIST) && + (gc->account->perm_deny != GAIM_PRIVACY_DENY_ALL) && + (gc->account->perm_deny != GAIM_PRIVACY_ALLOW_USERS))) + { + gc->account->perm_deny = GAIM_PRIVACY_DENY_USERS; + gaim_debug_info("yahoo", "Privacy defaulting to GAIM_PRIVACY_DENY_USERS.\n", + gc->account->username); } + } static void yahoo_process_notify(GaimConnection *gc, struct yahoo_packet *pkt) @@ -552,7 +644,8 @@ if (!from || !msg) return; - if (!g_ascii_strncasecmp(msg, "TYPING", strlen("TYPING"))) { + if (!g_ascii_strncasecmp(msg, "TYPING", strlen("TYPING")) + && (yahoo_privacy_check(gc, from))) { if (*stat == '1') serv_got_typing(gc, from, 0, GAIM_TYPING); else @@ -634,6 +727,11 @@ continue; } + if (!yahoo_privacy_check(gc, im->from)) { + gaim_debug_info("yahoo", "Message from %s dropped.\n", im->from); + return; + } + m = yahoo_string_decode(gc, im->msg, im->utf8); gaim_str_strip_cr(m); @@ -1813,7 +1911,11 @@ gaim_debug_misc("yahoo", "Warning, nonutf8 audible, ignoring!\n"); return; } - + if (!yahoo_privacy_check(gc, who)) { + gaim_debug_misc("yahoo", "Audible message from %s for %s dropped!\n", + gc->account->username, who); + return; + } serv_got_im(gc, who, msg, 0, time(NULL)); } @@ -3189,6 +3291,8 @@ g_free(gpo); } +/********************************* Commands **********************************/ + static GaimCmdRet yahoogaim_cmd_buzz(GaimConversation *c, const gchar *cmd, gchar **args, gchar **error, void *data) { @@ -3207,7 +3311,6 @@ static GaimPlugin *my_protocol = NULL; -/********************************* Commands **********************************/ static GaimCmdRet yahoogaim_cmd_chat_join(GaimConversation *conv, const char *cmd, @@ -3279,9 +3382,9 @@ NULL, /* add_buddies */ yahoo_remove_buddy, NULL, /*remove_buddies */ - NULL, /* add_permit */ + yahoo_add_permit, yahoo_add_deny, - NULL, /* rem_permit */ + yahoo_rem_permit, yahoo_rem_deny, yahoo_set_permit_deny, NULL, /* warn */ diff -r ea9e65f52b4b -r ca3e0882d377 src/protocols/yahoo/yahoo.h --- a/src/protocols/yahoo/yahoo.h Tue May 24 04:46:51 2005 +0000 +++ b/src/protocols/yahoo/yahoo.h Tue May 24 04:54:27 2005 +0000 @@ -188,4 +188,13 @@ /* yahoo_profile.c */ void yahoo_get_info(GaimConnection *gc, const char *name); +/** + * Check to see whether the sender is permitted to send + * + * @param gc The gc handle. + * @param who The sender of the packet to check +*/ +gboolean yahoo_privacy_check + (GaimConnection *gc, const char *who); + #endif /* _YAHOO_H_ */ diff -r ea9e65f52b4b -r ca3e0882d377 src/protocols/yahoo/yahoo_filexfer.c --- a/src/protocols/yahoo/yahoo_filexfer.c Tue May 24 04:46:51 2005 +0000 +++ b/src/protocols/yahoo/yahoo_filexfer.c Tue May 24 04:54:27 2005 +0000 @@ -166,30 +166,23 @@ account = gaim_connection_get_account(gc); if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { - if (0 && gaim_xfer_get_size(xfer) >= 1048577) { - gaim_notify_error(gc, NULL, _("File Transfer Failed"), - _("Gaim cannot send files over Yahoo! that are bigger than " - "One Megabyte (1,048,576 bytes).")); - gaim_xfer_cancel_local(xfer); + if (yd->jp) { + if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), + gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), + yahoo_sendfile_connected, xfer) == -1) + { + gaim_notify_error(gc, NULL, _("File Transfer Failed"), + _("Unable to establish file descriptor.")); + gaim_xfer_cancel_remote(xfer); + } } else { - if (yd->jp) { - if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), - gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_sendfile_connected, xfer) == -1) - { - gaim_notify_error(gc, NULL, _("File Transfer Failed"), - _("Unable to establish file descriptor.")); - gaim_xfer_cancel_remote(xfer); - } - } else { - if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), - gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_sendfile_connected, xfer) == -1) - { - gaim_notify_error(gc, NULL, _("File Transfer Failed"), - _("Unable to establish file descriptor.")); - gaim_xfer_cancel_remote(xfer); - } + if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), + gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), + yahoo_sendfile_connected, xfer) == -1) + { + gaim_notify_error(gc, NULL, _("File Transfer Failed"), + _("Unable to establish file descriptor.")); + gaim_xfer_cancel_remote(xfer); } } } else { diff -r ea9e65f52b4b -r ca3e0882d377 src/protocols/yahoo/yahoochat.c --- a/src/protocols/yahoo/yahoochat.c Tue May 24 04:46:51 2005 +0000 +++ b/src/protocols/yahoo/yahoochat.c Tue May 24 04:54:27 2005 +0000 @@ -31,6 +31,7 @@ #endif #include "debug.h" +#include "privacy.h" #include "prpl.h" #include "conversation.h" @@ -154,6 +155,11 @@ if (members) { g_hash_table_replace(components, g_strdup("members"), g_strdup(members->str)); } + if (!yahoo_privacy_check(gc, who)) { + gaim_debug_info("yahoo", + "Invite to conference %s from %s has been dropped.\n", room, who); + return; + } serv_got_chat_invite(gc, room, who, msg, components); g_string_free(members, TRUE); @@ -332,10 +338,13 @@ void yahoo_process_chat_join(GaimConnection *gc, struct yahoo_packet *pkt) { + GaimAccount *account = gaim_connection_get_account(gc); struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; GaimConversation *c = NULL; GSList *l; GList *members = NULL; + GList *roomies = NULL; + GaimConversationUiOps *ops; char *room = NULL; char *topic = NULL; char *someid, *someotherid, *somebase64orhashosomething, *somenegativenumber; @@ -434,6 +443,18 @@ yahoo_chat_add_users(GAIM_CONV_CHAT(c), members); } + ops = gaim_conversation_get_ui_ops(c); + + for (l = account->deny; l != NULL; l = l->next) { + for (roomies = members; roomies; roomies = roomies->next) { + if (!gaim_utf8_strcasecmp((char *)l->data, roomies->data)) { + gaim_debug_info("yahoo", "Ignoring room member %s in room %s\n" ,roomies->data, room); + gaim_conv_chat_ignore(GAIM_CONV_CHAT(c),roomies->data); + ops->chat_update_user((c), roomies->data); + } + } + } + g_list_free(roomies); g_list_free(members); g_free(room); if (topic) @@ -562,6 +583,11 @@ components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); g_hash_table_replace(components, g_strdup("room"), g_strdup(room)); + if (!yahoo_privacy_check(gc, who)) { + gaim_debug_info("yahoo", + "Invite to room %s from %s has been dropped.\n", room, who); + return; + } serv_got_chat_invite(gc, room, who, msg, components); } if (room)