Fix reconnect keys

This commit is contained in:
Berke Viktor 2013-05-15 18:26:54 +02:00
parent 6f09752db4
commit 0020f81e79
1 changed files with 26 additions and 14 deletions

View File

@ -1073,6 +1073,7 @@ check_autojoin_channels (server *serv)
session *sess;
GSList *list = sess_list;
GSList *sess_channels = NULL; /* joined channels that are not in the favorites list */
favchannel *fav;
/* shouldn't really happen, the io tag is destroyed in server.c */
if (!is_server (serv))
@ -1080,17 +1081,7 @@ check_autojoin_channels (server *serv)
return;
}
/* autojoin to favorite channels */
if (serv->favlist)
{
serv->p_join_list (serv, serv->favlist);
i++;
/* FIXME this is not going to work and is not needed either. server_free() does the job already. */
/* g_slist_free_full (serv->favlist, (GDestroyNotify) servlist_favchan_free); */
}
/* upon a reconnect, also autojoin to channels not in the favorites but joined during the session */
/* If there's a session (i.e. this is a reconnect), autojoin to everything that was open previously. */
while (list)
{
sess = list->data;
@ -1102,13 +1093,22 @@ check_autojoin_channels (server *serv)
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 */
fav = servlist_favchan_find (serv->network, sess->waitchannel, NULL); /* Is this channel in our favorites? */
/* session->channelkey is initially unset for channels joined from the favorites. You have to fill them up manually from favorites settings. */
if (fav)
{
/* session->channelkey is set if there was a key change during the session. In that case, use the session key, not the one from favorites. */
if (fav->key && !strlen (sess->channelkey))
{
safe_strcpy (sess->channelkey, fav->key, sizeof (sess->channelkey));
}
}
sess_channels = servlist_favchan_listadd (sess_channels, sess->waitchannel, sess->channelkey);
i++;
}
}
}
list = list->next;
}
@ -1118,6 +1118,18 @@ check_autojoin_channels (server *serv)
serv->p_join_list (serv, sess_channels);
g_slist_free_full (sess_channels, (GDestroyNotify) servlist_favchan_free);
}
else
{
/* If there's no session, just autojoin to favorites. */
if (serv->favlist)
{
serv->p_join_list (serv, serv->favlist);
i++;
/* FIXME this is not going to work and is not needed either. server_free() does the job already. */
/* g_slist_free_full (serv->favlist, (GDestroyNotify) servlist_favchan_free); */
}
}
serv->joindelay_tag = 0;
fe_server_event (serv, FE_SE_LOGGEDIN, i);