void yahoo_chat_add_user(PurpleChatConversation *chat, const char *user, const char *reason) { if (purple_chat_conversation_has_user(chat, user)) return; purple_chat_conversation_add_user(chat, user, reason, PURPLE_CHAT_USER_NONE, TRUE); }
static void yahoo_conf_join(YahooData *yd, PurpleChatConversation *c, const char *dn, const char *room, const char *topic, const char *members) { struct yahoo_packet *pkt; char **memarr = NULL; int i; if (members) memarr = g_strsplit(members, "\n", 0); pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGON, YAHOO_STATUS_AVAILABLE, yd->session_id); yahoo_packet_hash(pkt, "sss", 1, dn, 3, dn, 57, room); if (memarr) { for(i = 0 ; memarr[i]; i++) { if (!strcmp(memarr[i], "") || !strcmp(memarr[i], dn)) continue; yahoo_packet_hash_str(pkt, 3, memarr[i]); purple_chat_conversation_add_user(c, memarr[i], NULL, PURPLE_CHAT_USER_NONE, TRUE); } } yahoo_packet_send_and_free(pkt, yd); if (memarr) g_strfreev(memarr); }
/* this is slow, and different from the purple_* version in that it (hopefully) won't add a user twice */ void yahoo_chat_add_users(PurpleChatConversation *chat, GList *newusers) { GList *i; for (i = newusers; i; i = i->next) { if (purple_chat_conversation_has_user(chat, i->data)) continue; purple_chat_conversation_add_user(chat, i->data, NULL, PURPLE_CHAT_USER_NONE, TRUE); } }
static void joined_chat(PurpleChatConversation *from, PurpleChatConversation *to, int id, const char *room, gpointer userdata) { /* tell their chat window that we joined */ purple_debug_info("nullprpl", "%s sees that %s joined chat room %s\n", purple_chat_conversation_get_nick(to), purple_chat_conversation_get_nick(from), room); purple_chat_conversation_add_user(to, purple_chat_conversation_get_nick(from), NULL, /* user-provided join message, IRC style */ PURPLE_CHAT_USER_NONE, TRUE); /* show a join message */ if (from != to) { /* add them to our chat window */ purple_debug_info("nullprpl", "%s sees that %s is in chat room %s\n", purple_chat_conversation_get_nick(from), purple_chat_conversation_get_nick(to), room); purple_chat_conversation_add_user(from, purple_chat_conversation_get_nick(to), NULL, /* user-provided join message, IRC style */ PURPLE_CHAT_USER_NONE, FALSE); /* show a join message */ } }
static void ycht_process_chatjoin(YchtConn *ycht, YchtPkt *pkt) { char *room, *topic; PurpleConnection *gc = ycht->gc; PurpleChatConversation *c = NULL; gboolean new_room = FALSE; char **members; int i; room = g_list_nth_data(pkt->data, 0); topic = g_list_nth_data(pkt->data, 1); if (!g_list_nth_data(pkt->data, 4)) return; if (!room) return; members = g_strsplit(g_list_nth_data(pkt->data, 4), "\001", 0); for (i = 0; members[i]; i++) { char *tmp = strchr(members[i], '\002'); if (tmp) *tmp = '\0'; } if (g_list_length(pkt->data) > 5) new_room = TRUE; if (new_room && ycht->changing_rooms) { purple_serv_got_chat_left(gc, YAHOO_CHAT_ID); ycht->changing_rooms = FALSE; c = purple_serv_got_joined_chat(gc, YAHOO_CHAT_ID, room); } else { c = purple_conversations_find_chat(gc, YAHOO_CHAT_ID); } if (topic) purple_chat_conversation_set_topic(c, NULL, topic); for (i = 0; members[i]; i++) { if (new_room) { /*if (!strcmp(members[i], purple_connection_get_display_name(ycht->gc))) continue;*/ purple_chat_conversation_add_user(c, members[i], NULL, PURPLE_CHAT_USER_NONE, TRUE); } else { yahoo_chat_add_user(c, members[i], NULL); } } g_strfreev(members); }
static void ggp_chat_joined(ggp_chat_local_info *chat, uin_t uin) { int idx = ggp_chat_participant_find(chat, uin); if (idx >= 0) { purple_debug_warning("gg", "ggp_chat_joined: " "user %u is already present in chat %" G_GUINT64_FORMAT "\n", uin, chat->id); return; } chat->participants_count++; chat->participants = g_realloc(chat->participants, sizeof(uin) * chat->participants_count); chat->participants[chat->participants_count - 1] = uin; if (!chat->conv) return; purple_chat_conversation_add_user(chat->conv, ggp_uin_to_str(uin), NULL, PURPLE_CHAT_USER_NONE, TRUE); }
static void ggp_chat_open_conv(ggp_chat_local_info *chat) { int i; if (chat->conv != NULL) return; chat->conv = purple_serv_got_joined_chat(chat->gc, chat->local_id, ggp_chat_get_name_from_id(chat->id)); if (chat->previously_joined) { purple_conversation_write_system_message( PURPLE_CONVERSATION(chat->conv), _("You have re-joined the chat"), 0); } chat->previously_joined = TRUE; purple_chat_conversation_clear_users(chat->conv); for (i = 0; i < chat->participants_count; i++) { purple_chat_conversation_add_user(chat->conv, ggp_uin_to_str(chat->participants[i]), NULL, PURPLE_CHAT_USER_NONE, FALSE); } }