void gaym_privacy_change(GaimConnection * gc, const char *name) { /** * don't allow adding self to permit/deny lists */ if (name) { if (!gaim_utf8_strcasecmp(gc->account->username, name)) { gaim_privacy_deny_remove(gc->account, gc->account->username, TRUE); gaim_privacy_permit_remove(gc->account, gc->account->username, TRUE); gaim_debug_info("gaym", "declining to add self to permit/deny list\n"); return; } } GSList *rooms = NULL; for (rooms = gc->buddy_chats; rooms; rooms = rooms->next) { GaimConversation *convo = rooms->data; GaimConvChat *chat = gaim_conversation_get_chat_data(convo); GList *people = NULL; for (people = chat->in_room; people; people = people->next) { GaimConvChatBuddy *buddy = people->data; GaimConversationUiOps *ops = gaim_conversation_get_ui_ops(convo); if (name) { if (!gaim_utf8_strcasecmp(name, buddy->name)) { if (gaym_privacy_check(gc, buddy->name) && gaym_botfilter_check(gc, buddy->name, NULL, TRUE)) { gaim_conv_chat_unignore(GAIM_CONV_CHAT(convo), buddy->name); } else { gaim_conv_chat_ignore(GAIM_CONV_CHAT(convo), buddy->name); } ops->chat_update_user((convo), buddy->name); } } else { if (gaym_privacy_check(gc, buddy->name) && gaym_botfilter_check(gc, buddy->name, NULL, TRUE)) { gaim_conv_chat_unignore(GAIM_CONV_CHAT(convo), buddy->name); } else { gaim_conv_chat_ignore(GAIM_CONV_CHAT(convo), buddy->name); } ops->chat_update_user((convo), buddy->name); } } } }
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; char *room = NULL; char *topic = NULL; char *someid, *someotherid, *somebase64orhashosomething, *somenegativenumber; if (pkt->status == -1) { /* We can't join */ struct yahoo_pair *pair = pkt->hash->data; gchar const *failed_to_join = _("Failed to join chat"); switch (atoi(pair->value)) { case 0xFFFFFFFA: /* -6 */ gaim_notify_error(gc, NULL, failed_to_join, _("Unknown room")); break; case 0xFFFFFFF1: /* -15 */ gaim_notify_error(gc, NULL, failed_to_join, _("Maybe the room is full")); break; case 0xFFFFFFDD: /* -35 */ gaim_notify_error(gc, NULL, failed_to_join, _("Not available")); break; default: gaim_notify_error(gc, NULL, failed_to_join, _("Unknown error. You may need to logout and wait five minutes before being able to rejoin a chatroom")); } return; } for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; switch (pair->key) { case 104: room = yahoo_string_decode(gc, pair->value, TRUE); break; case 105: topic = yahoo_string_decode(gc, pair->value, TRUE); break; case 128: someid = pair->value; break; case 108: /* number of joiners */ break; case 129: someotherid = pair->value; break; case 130: somebase64orhashosomething = pair->value; break; case 126: somenegativenumber = pair->value; break; case 13: /* this is 1. maybe its the type of room? (normal, user created, private, etc?) */ break; case 61: /*this looks similar to 130 */ break; /* the previous section was just room info. this next section is info about individual room members, (including us) */ case 109: /* the yahoo id */ members = g_list_append(members, pair->value); break; case 110: /* age */ break; case 141: /* nickname */ break; case 142: /* location */ break; case 113: /* bitmask */ break; } } if (room && yd->chat_name && gaim_utf8_strcasecmp(room, yd->chat_name)) yahoo_chat_leave(gc, room, gaim_connection_get_display_name(gc), FALSE); c = gaim_find_chat(gc, YAHOO_CHAT_ID); if (room && (!c || gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) && members && ((g_list_length(members) > 1) || !g_ascii_strcasecmp(members->data, gaim_connection_get_display_name(gc)))) { int i; GList *flags = NULL; for (i = 0; i < g_list_length(members); i++) flags = g_list_append(flags, GINT_TO_POINTER(GAIM_CBFLAGS_NONE)); if (c && gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) { /* this might be a hack, but oh well, it should nicely */ char *tmpmsg; gaim_conversation_set_name(c, room); c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room); if (topic) gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic); yd->in_chat = 1; yd->chat_name = g_strdup(room); gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE); tmpmsg = g_strdup_printf(_("You are now chatting in %s."), room); gaim_conv_chat_write(GAIM_CONV_CHAT(c), "", tmpmsg, GAIM_MESSAGE_SYSTEM, time(NULL)); g_free(tmpmsg); } else { c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room); if (topic) gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic); yd->in_chat = 1; yd->chat_name = g_strdup(room); gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE); } g_list_free(flags); } else if (c) { yahoo_chat_add_users(GAIM_CONV_CHAT(c), members); } if (account->deny && c) { GaimConversationUiOps *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 ? 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); g_free(topic); }