diff options
author | Timo Sirainen <cras@irssi.org> | 2001-01-14 18:30:02 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-01-14 18:30:02 +0000 |
commit | c49b5adc1bdb1e4a12aa59bd487c526d587b78a6 (patch) | |
tree | c5f7f11bf2551a29773153d9205bd6c97055110f /src | |
parent | 93ba91b8ed23284cfe14f5d77d5910e112039424 (diff) | |
download | irssi-c49b5adc1bdb1e4a12aa59bd487c526d587b78a6.zip |
Added nicklist_rename()
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1115 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/core/nicklist.c | 29 | ||||
-rw-r--r-- | src/core/nicklist.h | 6 |
2 files changed, 33 insertions, 2 deletions
diff --git a/src/core/nicklist.c b/src/core/nicklist.c index 1fc15139..d5841b45 100644 --- a/src/core/nicklist.c +++ b/src/core/nicklist.c @@ -67,7 +67,7 @@ static void nicklist_destroy(CHANNEL_REC *channel, NICK_REC *nick) g_free(nick); } -/* remove nick from list */ +/* Remove nick from list */ void nicklist_remove(CHANNEL_REC *channel, NICK_REC *nick) { g_return_if_fail(IS_CHANNEL(channel)); @@ -77,6 +77,33 @@ void nicklist_remove(CHANNEL_REC *channel, NICK_REC *nick) nicklist_destroy(channel, nick); } +/* Change nick */ +void nicklist_rename(SERVER_REC *server, const char *old_nick, + const char *new_nick) +{ + CHANNEL_REC *channel; + NICK_REC *nickrec; + GSList *nicks, *tmp; + + nicks = nicklist_get_same(server, old_nick); + for (tmp = nicks; tmp != NULL; tmp = tmp->next->next) { + channel = tmp->data; + nickrec = tmp->next->data; + + /* remove old nick from hash table */ + g_hash_table_remove(channel->nicks, nickrec->nick); + + g_free(nickrec->nick); + nickrec->nick = g_strdup(new_nick); + + /* add new nick to hash table */ + g_hash_table_insert(channel->nicks, nickrec->nick, nickrec); + + signal_emit("nicklist changed", 3, channel, nickrec, old_nick); + } + g_slist_free(nicks); +} + static NICK_REC *nicklist_find_wildcards(CHANNEL_REC *channel, const char *mask) { diff --git a/src/core/nicklist.h b/src/core/nicklist.h index 6d278a2e..e1deb154 100644 --- a/src/core/nicklist.h +++ b/src/core/nicklist.h @@ -15,8 +15,12 @@ struct _NICK_REC { /* Add new nick to list */ NICK_REC *nicklist_insert(CHANNEL_REC *channel, const char *nick, int op, int voice, int send_massjoin); -/* remove nick from list */ +/* Remove nick from list */ void nicklist_remove(CHANNEL_REC *channel, NICK_REC *nick); +/* Change nick */ +void nicklist_rename(SERVER_REC *server, const char *old_nick, + const char *new_nick); + /* Find nick record from list */ NICK_REC *nicklist_find(CHANNEL_REC *channel, const char *mask); /* Get list of nicks that match the mask */ |