diff options
author | Berke Viktor <bviktor@hexchat.org> | 2013-05-14 16:40:32 +0200 |
---|---|---|
committer | Berke Viktor <bviktor@hexchat.org> | 2013-05-14 16:40:32 +0200 |
commit | a435e8648fa16c8f661626b055e0e6626bf26460 (patch) | |
tree | 5fce9360f1232168ec4f063076e98a5241717a07 /src/common/proto-irc.c | |
parent | 7cdfeff20490971c40deed9f59697f0e524348c8 (diff) |
Fix initial autojoins and some erroneous copies/frees
Diffstat (limited to 'src/common/proto-irc.c')
-rw-r--r-- | src/common/proto-irc.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index c763fb71..f6d8af5e 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -118,6 +118,7 @@ irc_join (server *serv, char *channel, char *key) tcp_sendf (serv, "JOIN %s\r\n", channel); } +#if 0//FIXME remove when finished porting static void irc_join_list_flush (server *serv, GString *c, GString *k) { @@ -231,6 +232,60 @@ irc_join_list (server *serv, GSList *channels, GSList *keys) } irc_join_list_flush (serv, c, k); +#endif + +static void +irc_join_list_flush (server *serv) +{ + /* FIXME implement flushing for too long favorites lists */ +} + +static void +irc_join_list (server *serv, GSList *favorites) +{ + int first_item = 1; + favchannel *fav; + char *chanstr; + char *keystr; + GString *chanlist = g_string_new (NULL); + GString *keylist = g_string_new (NULL); + GSList *favlist; + + favlist = favorites; + + while (favlist) + { + fav = favlist->data; + + if (!first_item) + { + g_string_append_c (chanlist, ','); /* add separators but only if it's not the 1st element */ + g_string_append_c (keylist, ','); + } + + g_string_append (chanlist, fav->name); + + if (fav->key) + { + g_string_append (keylist, fav->key); + } + else + { + g_string_append_c (keylist, 'x'); /* 'x' filler for keyless channels */ + } + + first_item = 0; + favlist = favlist->next; + } + + chanstr = g_string_free (chanlist, FALSE); /* convert our strings to char arrays */ + keystr = g_string_free (keylist, FALSE); + + tcp_sendf (serv, "JOIN %s %s\r\n", chanstr, keystr); /* send the actual command */ + + g_free (chanstr); /* cleanup */ + g_free (keystr); + g_slist_free (favlist); } static void |