summary refs log tree commit diff stats
path: root/src/common/inbound.c
diff options
context:
space:
mode:
authorBerke Viktor <bviktor@hexchat.org>2013-05-15 11:43:38 +0200
committerBerke Viktor <bviktor@hexchat.org>2013-05-15 11:43:38 +0200
commit8cf025f18d85c079a8e95140cdc5abc8b6fc9c04 (patch)
tree68cd74f675a885f4ec8448a7e0389b86a99dddee /src/common/inbound.c
parent81990ce53b90aa3351ef5981ce2a74c54a1f85f5 (diff)
Fix autojoins for sessions
Diffstat (limited to 'src/common/inbound.c')
-rw-r--r--src/common/inbound.c95
1 files changed, 24 insertions, 71 deletions
diff --git a/src/common/inbound.c b/src/common/inbound.c
index ec625c03..953a78ee 100644
--- a/src/common/inbound.c
+++ b/src/common/inbound.c
@@ -1066,39 +1066,38 @@ inbound_nameslist_end (server *serv, char *chan)
 	return FALSE;
 }
 
-#if 0//FIXME remove when finished porting
-static gboolean
+static void
 check_autojoin_channels (server *serv)
 {
-	char *po;
+	int i = 0;
 	session *sess;
 	GSList *list = sess_list;
-	int i = 0;
-	GSList *channels, *keys;
+	GSList *sess_channels = NULL;			/* joined channels that are not in the favorites list */
 
-	/* shouldnt really happen, the io tag is destroyed in server.c */
+	/* shouldn't really happen, the io tag is destroyed in server.c */
 	if (!is_server (serv))
-		return FALSE;
+	{
+		return;
+	}
 
 	/* send auto join list */
-	if (serv->autojoin)
+	if (serv->favlist)
 	{
-		joinlist_split (serv->autojoin, &channels, &keys);
-		serv->p_join_list (serv, channels, keys);
-		joinlist_free (channels, keys);
-
-		free (serv->autojoin);
-		serv->autojoin = NULL;
+		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); */
 	}
 
-	/* this is really only for re-connects when you
-    * join channels not in the auto-join list. */
-	channels = NULL;
-	keys = NULL;
+	/* This is really only for re-connects when you
+	 * join channels not in the auto-join list.
+	 */
+
 	while (list)
 	{
 		sess = list->data;
+
 		if (sess->server == serv)
 		{
 			if (sess->willjoinchannel[0] != 0)
@@ -1106,69 +1105,23 @@ check_autojoin_channels (server *serv)
 				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
+				if (!servlist_favchan_find (serv->network, sess->waitchannel, NULL))		/* don't reconnect if it's already in the favlist */
 				{
-					channels = g_slist_append (channels, g_strdup (sess->waitchannel));
-					keys = g_slist_append (keys, g_strdup (sess->channelkey));
+					sess_channels = servlist_favchan_listadd (sess_channels, sess->waitchannel, sess->channelkey);
+					i++;
 				}
-				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;
-
-	/* shouldn't really happen, the io tag is destroyed in server.c */
-	if (!is_server (serv))
-	{
-		return;
+		list = list->next;
 	}
 
-	/* send auto join list */
-	if (serv->favlist)
+	if (sess_channels)
 	{
-		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->p_join_list (serv, sess_channels);
+		g_slist_free_full (sess_channels, (GDestroyNotify) servlist_favchan_free);
 	}
 
-	/* This is really only for re-connects when you
-	 * join channels not in the auto-join list.
-	 */
-
-	/* FIXME handle reconnects */
-
 	serv->joindelay_tag = 0;
 	fe_server_event (serv, FE_SE_LOGGEDIN, i);
 }