Fix autojoins for sessions
This commit is contained in:
parent
81990ce53b
commit
8cf025f18d
@ -1066,86 +1066,13 @@ inbound_nameslist_end (server *serv, char *chan)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if 0//FIXME remove when finished porting
|
||||
static gboolean
|
||||
check_autojoin_channels (server *serv)
|
||||
{
|
||||
char *po;
|
||||
session *sess;
|
||||
GSList *list = sess_list;
|
||||
int i = 0;
|
||||
GSList *channels, *keys;
|
||||
|
||||
/* shouldnt really happen, the io tag is destroyed in server.c */
|
||||
if (!is_server (serv))
|
||||
return FALSE;
|
||||
|
||||
/* send auto join list */
|
||||
if (serv->autojoin)
|
||||
{
|
||||
joinlist_split (serv->autojoin, &channels, &keys);
|
||||
serv->p_join_list (serv, channels, keys);
|
||||
joinlist_free (channels, keys);
|
||||
|
||||
free (serv->autojoin);
|
||||
serv->autojoin = NULL;
|
||||
i++;
|
||||
}
|
||||
|
||||
/* this is really only for re-connects when you
|
||||
* join channels not in the auto-join list. */
|
||||
channels = NULL;
|
||||
keys = NULL;
|
||||
while (list)
|
||||
{
|
||||
sess = list->data;
|
||||
if (sess->server == serv)
|
||||
{
|
||||
if (sess->willjoinchannel[0] != 0)
|
||||
{
|
||||
strcpy (sess->waitchannel, sess->willjoinchannel);
|
||||
sess->willjoinchannel[0] = 0;
|
||||
|
||||
po = strchr (sess->waitchannel, ',');
|
||||
if (po)
|
||||
*po = 0;
|
||||
po = strchr (sess->waitchannel, ' ');
|
||||
if (po)
|
||||
*po = 0;
|
||||
|
||||
/* There can be no gap between keys, list keyed chans first. */
|
||||
if (sess->channelkey[0] != 0)
|
||||
{
|
||||
channels = g_slist_prepend (channels, g_strdup (sess->waitchannel));
|
||||
keys = g_slist_prepend (keys, g_strdup (sess->channelkey));
|
||||
}
|
||||
else
|
||||
{
|
||||
channels = g_slist_append (channels, g_strdup (sess->waitchannel));
|
||||
keys = g_slist_append (keys, g_strdup (sess->channelkey));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
if (channels)
|
||||
{
|
||||
serv->p_join_list (serv, channels, keys);
|
||||
joinlist_free (channels, keys);
|
||||
}
|
||||
|
||||
serv->joindelay_tag = 0;
|
||||
fe_server_event (serv, FE_SE_LOGGEDIN, i);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
check_autojoin_channels (server *serv)
|
||||
{
|
||||
int i = 0;
|
||||
session *sess;
|
||||
GSList *list = sess_list;
|
||||
GSList *sess_channels = NULL; /* joined channels that are not in the favorites list */
|
||||
|
||||
/* shouldn't really happen, the io tag is destroyed in server.c */
|
||||
if (!is_server (serv))
|
||||
@ -1167,7 +1094,33 @@ check_autojoin_channels (server *serv)
|
||||
* join channels not in the auto-join list.
|
||||
*/
|
||||
|
||||
/* FIXME handle reconnects */
|
||||
while (list)
|
||||
{
|
||||
sess = list->data;
|
||||
|
||||
if (sess->server == serv)
|
||||
{
|
||||
if (sess->willjoinchannel[0] != 0)
|
||||
{
|
||||
strcpy (sess->waitchannel, sess->willjoinchannel);
|
||||
sess->willjoinchannel[0] = 0;
|
||||
|
||||
if (!servlist_favchan_find (serv->network, sess->waitchannel, NULL)) /* don't reconnect if it's already in the favlist */
|
||||
{
|
||||
sess_channels = servlist_favchan_listadd (sess_channels, sess->waitchannel, sess->channelkey);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
if (sess_channels)
|
||||
{
|
||||
serv->p_join_list (serv, sess_channels);
|
||||
g_slist_free_full (sess_channels, (GDestroyNotify) servlist_favchan_free);
|
||||
}
|
||||
|
||||
serv->joindelay_tag = 0;
|
||||
fe_server_event (serv, FE_SE_LOGGEDIN, i);
|
||||
|
@ -185,13 +185,13 @@ irc_join_list (server *serv, GSList *favorites)
|
||||
|
||||
g_string_append (chanlist, fav->name);
|
||||
|
||||
if (fav->key)
|
||||
if (fav->key && strlen (fav->key)) /* strlen() is required since key can be '' for session->channelkey */
|
||||
{
|
||||
g_string_append (keylist, fav->key);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_string_append_c (keylist, 'x'); /* 'x' filler for keyless channels */
|
||||
g_string_append_c (keylist, 'x'); /* 'x' filler for keyless channels so that our JOIN command is always well-formatted */
|
||||
}
|
||||
|
||||
first_item = 0;
|
||||
|
@ -998,30 +998,44 @@ servlist_command_add (ircnet *net, char *cmd)
|
||||
return entry;
|
||||
}
|
||||
|
||||
favchannel *
|
||||
servlist_favchan_add (ircnet *net, char *channel)
|
||||
GSList *
|
||||
servlist_favchan_listadd (GSList *chanlist, char *channel, char *key)
|
||||
{
|
||||
int pos;
|
||||
favchannel *chan;
|
||||
|
||||
chan = malloc (sizeof (favchannel));
|
||||
memset (chan, 0, sizeof (favchannel));
|
||||
|
||||
chan->name = g_strdup (channel);
|
||||
chan->key = g_strdup (key);
|
||||
chanlist = g_slist_append (chanlist, chan);
|
||||
|
||||
return chanlist;
|
||||
}
|
||||
|
||||
void
|
||||
servlist_favchan_add (ircnet *net, char *channel)
|
||||
{
|
||||
int pos;
|
||||
char *name;
|
||||
char *key;
|
||||
|
||||
if (strchr (channel, ',') != NULL)
|
||||
{
|
||||
pos = (int) (strchr (channel, ',') - channel);
|
||||
chan->name = g_strndup (channel, pos);
|
||||
chan->key = g_strdup (channel + pos + 1);
|
||||
name = g_strndup (channel, pos);
|
||||
key = g_strdup (channel + pos + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
chan->name = g_strdup (channel);
|
||||
chan->key = NULL;
|
||||
name = g_strdup (channel);
|
||||
key = NULL;
|
||||
}
|
||||
|
||||
net->favchanlist = g_slist_append (net->favchanlist, chan);
|
||||
net->favchanlist = servlist_favchan_listadd (net->favchanlist, name, key);
|
||||
|
||||
return chan;
|
||||
g_free (name);
|
||||
g_free (key);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -100,7 +100,7 @@ favchannel *servlist_favchan_find (ircnet *net, char *channel, int *pos);
|
||||
|
||||
ircserver *servlist_server_add (ircnet *net, char *name);
|
||||
commandentry *servlist_command_add (ircnet *net, char *command);
|
||||
favchannel *servlist_favchan_add (ircnet *net, char *channel);
|
||||
void servlist_favchan_add (ircnet *net, char *channel);
|
||||
|
||||
void servlist_command_free (commandentry *entry);
|
||||
void servlist_favchan_free (favchannel *channel);
|
||||
@ -110,6 +110,7 @@ void servlist_command_remove (ircnet *net, commandentry *entry);
|
||||
void servlist_favchan_remove (ircnet *net, favchannel *channel);
|
||||
|
||||
favchannel *servlist_favchan_copy (favchannel *fav);
|
||||
GSList *servlist_favchan_listadd (GSList *chanlist, char *channel, char *key);
|
||||
|
||||
gboolean joinlist_is_in_list (server *serv, char *channel);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user