summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fe-common/irc/fe-netjoin.c43
-rw-r--r--src/fe-common/irc/fe-netsplit.c31
-rw-r--r--src/irc/core/irc-servers.h2
3 files changed, 48 insertions, 28 deletions
diff --git a/src/fe-common/irc/fe-netjoin.c b/src/fe-common/irc/fe-netjoin.c
index f5cb081e..22ca642c 100644
--- a/src/fe-common/irc/fe-netjoin.c
+++ b/src/fe-common/irc/fe-netjoin.c
@@ -164,11 +164,11 @@ static void print_channel_netjoins(char *channel, TEMP_PRINT_REC *rec,
g_free(channel);
}
-static void print_netjoins(NETJOIN_SERVER_REC *server)
+static void print_netjoins(NETJOIN_SERVER_REC *server, const char *channel)
{
TEMP_PRINT_REC *temp;
GHashTable *channels;
- GSList *tmp, *next, *old;
+ GSList *tmp, *tmp2, *next, *next2, *old;
g_return_if_fail(server != NULL);
@@ -181,11 +181,17 @@ static void print_netjoins(NETJOIN_SERVER_REC *server)
for (tmp = server->netjoins; tmp != NULL; tmp = next) {
NETJOIN_REC *rec = tmp->data;
- next = tmp->next;
- while (rec->now_channels != NULL) {
- char *channel = rec->now_channels->data;
+ next = g_slist_next(tmp);
+
+ for (tmp2 = rec->now_channels; tmp2 != NULL; tmp2 = next2) {
+ char *channel = tmp2->data;
char *realchannel = channel + 1;
+ next2 = g_slist_next(tmp2);
+
+ if (channel != NULL && strcasecmp(realchannel, channel) != 0)
+ continue;
+
temp = g_hash_table_lookup(channels, realchannel);
if (temp == NULL) {
temp = g_new0(TEMP_PRINT_REC, 1);
@@ -214,8 +220,8 @@ static void print_netjoins(NETJOIN_SERVER_REC *server)
g_free(data);
}
- rec->now_channels =
- g_slist_remove(rec->now_channels, channel);
+ /* drop tmp2 from the list */
+ rec->now_channels = g_slist_delete_link(rec->now_channels, tmp2);
g_free(channel);
}
@@ -235,20 +241,25 @@ static void print_netjoins(NETJOIN_SERVER_REC *server)
/* something is going to be printed to screen, print our current netsplit
message before it. */
-static void sig_print_starting(void)
+static void sig_print_starting(TEXT_DEST_REC *dest)
{
- GSList *tmp, *next;
+ NETJOIN_SERVER_REC *rec;
if (printing_joins)
return;
- for (tmp = joinservers; tmp != NULL; tmp = next) {
- NETJOIN_SERVER_REC *server = tmp->data;
+ if (!IS_IRC_SERVER(dest->server))
+ return;
- next = tmp->next;
- if (server->netjoins != NULL)
- print_netjoins(server);
- }
+ if (dest->level != MSGLEVEL_PUBLIC)
+ return;
+
+ if (!server_ischannel(dest->server, dest->target))
+ return;
+
+ rec = netjoin_find_server(IRC_SERVER(dest->server));
+ if (rec != NULL && rec->netjoins != NULL)
+ print_netjoins(rec, dest->target);
}
static int sig_check_netjoins(void)
@@ -272,7 +283,7 @@ static int sig_check_netjoins(void)
}
if (server->netjoins != NULL)
- print_netjoins(server);
+ print_netjoins(server, NULL);
}
/* now remove all netjoins which haven't had any new joins
diff --git a/src/fe-common/irc/fe-netsplit.c b/src/fe-common/irc/fe-netsplit.c
index 3eb30796..aa05639b 100644
--- a/src/fe-common/irc/fe-netsplit.c
+++ b/src/fe-common/irc/fe-netsplit.c
@@ -142,7 +142,7 @@ static void get_server_splits(void *key, NETSPLIT_REC *split,
}
}
-static void print_server_splits(IRC_SERVER_REC *server, TEMP_SPLIT_REC *rec)
+static void print_server_splits(IRC_SERVER_REC *server, TEMP_SPLIT_REC *rec, const char *channel)
{
GString *destservers;
char *sourceserver;
@@ -168,6 +168,9 @@ static void print_server_splits(IRC_SERVER_REC *server, TEMP_SPLIT_REC *rec)
for (tmp = rec->channels; tmp != NULL; tmp = tmp->next) {
TEMP_SPLIT_CHAN_REC *chan = tmp->data;
+ if (channel != NULL && strcasecmp(channel, chan->name) != 0)
+ continue;
+
g_string_truncate(chan->nicks, chan->nicks->len-2);
if (netsplit_max_nicks > 0 &&
@@ -193,7 +196,7 @@ static void temp_split_chan_free(TEMP_SPLIT_CHAN_REC *rec)
g_free(rec);
}
-static void print_splits(IRC_SERVER_REC *server)
+static void print_splits(IRC_SERVER_REC *server, const char *channel)
{
TEMP_SPLIT_REC temp;
GSList *servers;
@@ -212,7 +215,7 @@ static void print_splits(IRC_SERVER_REC *server)
g_hash_table_foreach(server->splits,
(GHFunc) get_server_splits, &temp);
- print_server_splits(server, &temp);
+ print_server_splits(server, &temp, channel);
g_slist_foreach(temp.channels,
(GFunc) temp_split_chan_free, NULL);
@@ -233,25 +236,31 @@ static int check_server_splits(IRC_SERVER_REC *server)
if (time(NULL)-last < SPLIT_WAIT_TIME)
return FALSE;
- print_splits(server);
+ print_splits(server, NULL);
return TRUE;
}
/* something is going to be printed to screen, print our current netsplit
message before it. */
-static void sig_print_starting(void)
+static void sig_print_starting(TEXT_DEST_REC *dest)
{
- GSList *tmp;
+ IRC_SERVER_REC *rec;
if (printing_splits)
return;
- for (tmp = servers; tmp != NULL; tmp = tmp->next) {
- IRC_SERVER_REC *rec = tmp->data;
+ if (IS_IRC_SERVER(dest->server) == FALSE)
+ return;
- if (IS_IRC_SERVER(rec) && rec->split_servers != NULL)
- print_splits(rec);
- }
+ if (dest->level != MSGLEVEL_PUBLIC)
+ return;
+
+ if (server_ischannel(dest->server, dest->target) == FALSE)
+ return;
+
+ rec = IRC_SERVER(dest->server);
+ if (rec->split_servers != NULL)
+ print_splits(rec, dest->target);
}
static int sig_check_splits(void)
diff --git a/src/irc/core/irc-servers.h b/src/irc/core/irc-servers.h
index ecf65ac2..bb100f86 100644
--- a/src/irc/core/irc-servers.h
+++ b/src/irc/core/irc-servers.h
@@ -67,6 +67,7 @@ struct _IRC_SERVER_REC {
unsigned int nick_collision:1; /* We're just now being killed because of nick collision */
unsigned int motd_got:1; /* We've received MOTD */
unsigned int isupport_sent:1; /* Server has sent us an isupport reply */
+ unsigned int cap_complete:1; /* We've done the initial CAP negotiation */
int max_kicks_in_cmd; /* max. number of people to kick with one /KICK command */
int max_modes_in_cmd; /* max. number of mode changes in one /MODE command */
@@ -76,7 +77,6 @@ struct _IRC_SERVER_REC {
GSList *cap_supported; /* A list of caps supported by the server */
GSList *cap_active; /* A list of caps active for this session */
GSList *cap_queue; /* A list of caps to request on connection */
- int cap_complete:1; /* We've done the initial CAP negotiation */
GString *sasl_buffer; /* Buffer used to reassemble a fragmented SASL payload */
guint sasl_timeout; /* Holds the source id of the running timeout */