static void sig_nicklist_remove(MUC_REC *channel, XMPP_NICK_REC *nick) { if (!IS_MUC(channel) || !IS_XMPP_NICK(nick)) return; g_free(nick->status); }
void send_join(MUC_REC *channel) { g_return_if_fail(IS_MUC(channel)); if (!channel->server->connected) return; muc_nick(channel, channel->nick); }
static void sig_nick_changed(MUC_REC *channel) { if (!IS_MUC(channel)) return; if (MUC(active_win->active) == channel) update_nick_statusbar(channel->server, channel, TRUE); }
static void sig_channel_destroyed(MUC_REC *channel) { if (!IS_MUC(channel)) return; if (!channel->server->disconnected && !channel->left) muc_part(channel, settings_get_str("part_message")); g_free(channel->nick); }
static void sig_channel_created(MUC_REC *channel) { if (!IS_MUC(channel)) return; if (channel->nicks != NULL) g_hash_table_destroy(channel->nicks); channel->nicks = g_hash_table_new((GHashFunc)g_str_hash, (GCompareFunc)g_str_equal); }
static void sig_channel_destroyed(MUC_REC *channel) { g_return_if_fail(channel != NULL); if (!IS_MUC(channel)) return; if (MUC(active_win->active) == channel) update_nick_statusbar(channel->server, NULL, TRUE); }
void muc_part(MUC_REC *channel, const char *reason) { g_return_if_fail(IS_MUC(channel)); send_part(channel, reason); channel->left = TRUE; if (channel->ownnick != NULL) signal_emit("message part", 5, channel->server, channel->name, channel->ownnick->nick, channel->ownnick->host, reason); channel_destroy(CHANNEL(channel)); }
static void sig_window_destroyed(WINDOW_REC *window) { XMPP_SERVER_REC *server; MUC_REC *channel; g_return_if_fail(window != NULL); if ((server = XMPP_SERVER(window->active_server)) == NULL) return; channel = MUC(window->active); if (channel != NULL || !IS_MUC(active_win->active)) update_nick_statusbar(server, NULL, TRUE); }
static void update_nick_statusbar(XMPP_SERVER_REC *server, MUC_REC *channel, gboolean redraw) { char *newnick; newnick = IS_MUC(channel) ? channel->nick : settings_get_bool("xmpp_set_nick_as_username") ? server->user : server->jid; if (strcmp(server->nick, newnick) == 0) return; g_free(server->nick); server->nick = g_strdup(newnick); if (redraw) statusbar_items_redraw("user"); }
void muc_nick(MUC_REC *channel, const char *nick) { LmMessage *lmsg; LmMessageNode *node; char *recoded, *str; g_return_if_fail(IS_MUC(channel)); if (!channel->server->connected) return; str = g_strconcat(channel->name, "/", nick, NULL); recoded = xmpp_recode_out(str); g_free(str); lmsg = lm_message_new(recoded, LM_MESSAGE_TYPE_PRESENCE); g_free(recoded); node = lm_message_node_add_child(lmsg->node, "x", NULL); lm_message_node_set_attribute(node, XMLNS, XMLNS_MUC); if (!channel->joined) { if (channel->key != NULL) { recoded = xmpp_recode_out(channel->key); lm_message_node_add_child(node, "password", recoded); g_free(recoded); } node = lm_message_node_add_child(node, "history", NULL); str = g_strdup_printf("%d", settings_get_int("xmpp_history_maxstanzas")); lm_message_node_set_attribute(node, "maxstanzas", str); g_free(str); if (channel->server->show != XMPP_PRESENCE_AVAILABLE) { recoded = xmpp_recode_out( xmpp_presence_show[channel->server->show]); lm_message_node_add_child(lmsg->node, "show", recoded); g_free(recoded); } if (channel->server->away_reason != NULL) { recoded = xmpp_recode_out( channel->server->away_reason); lm_message_node_add_child(lmsg->node, "status", recoded); g_free(recoded); } } signal_emit("xmpp send presence", 2, channel->server, lmsg); lm_message_unref(lmsg); }
XMPP_NICK_REC * xmpp_nicklist_insert(MUC_REC *channel, const char *nickname, const char *full_jid) { XMPP_NICK_REC *rec; g_return_val_if_fail(IS_MUC(channel), NULL); g_return_val_if_fail(nickname != NULL, NULL); rec = g_new0(XMPP_NICK_REC, 1); rec->nick = g_strdup(nickname); rec->host = (full_jid != NULL) ? g_strdup(full_jid) : g_strconcat(channel->name, "/", rec->nick, (void *)NULL); rec->show = XMPP_PRESENCE_AVAILABLE; rec->status = NULL; rec->affiliation = XMPP_NICKLIST_AFFILIATION_NONE; rec->role = XMPP_NICKLIST_ROLE_NONE; nicklist_insert(CHANNEL(channel), (NICK_REC *)rec); return rec; }
void xmpp_nicklist_rename(MUC_REC *channel, XMPP_NICK_REC *nick, const char *oldnick, const char *newnick) { g_return_if_fail(IS_MUC(channel)); g_return_if_fail(IS_XMPP_NICK(nick)); g_return_if_fail(oldnick != NULL); g_return_if_fail(newnick != NULL); /* remove old nick from hash table */ nick_hash_remove(CHANNEL(channel), NICK(nick)); g_free(nick->nick); nick->nick = g_strdup(newnick); /* add new nick to hash table */ nick_hash_add(CHANNEL(channel), NICK(nick)); signal_emit("nicklist changed", 3, channel, nick, oldnick); if (strcmp(oldnick, channel->nick) == 0) { nicklist_set_own(CHANNEL(channel), NICK(nick)); g_free(channel->nick); channel->nick = g_strdup(newnick); } }