summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmanuele Giaquinta <exg@irssi.org>2008-11-12 20:31:41 +0000
committerexg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564>2008-11-12 20:31:41 +0000
commitcf41f6d45d401494edc009027ab76a433b5d8db8 (patch)
treee3e27a078accb38fd553c7ed71923cc48ea85269 /src
parentee6133f3240285bad34f54e834c8467ced91a513 (diff)
downloadirssi-cf41f6d45d401494edc009027ab76a433b5d8db8.zip
Export server_send_away and use it in irc-servers-reconnect.c:sig_connected
instead of duplicating the code. git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4900 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/irc/core/irc-commands.c18
-rw-r--r--src/irc/core/irc-servers-reconnect.c8
-rw-r--r--src/irc/core/irc-servers.c14
-rw-r--r--src/irc/core/irc-servers.h1
4 files changed, 19 insertions, 22 deletions
diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c
index bac66f08..fb94f1f3 100644
--- a/src/irc/core/irc-commands.c
+++ b/src/irc/core/irc-commands.c
@@ -529,20 +529,6 @@ static void cmd_ping(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
g_free(str);
}
-static void server_send_away(IRC_SERVER_REC *server, const char *reason)
-{
- if (!IS_IRC_SERVER(server))
- return;
-
- if (*reason != '\0' || server->usermode_away) {
- g_free_and_null(server->away_reason);
- if (*reason != '\0')
- server->away_reason = g_strdup(reason);
-
- irc_send_cmdv(server, "AWAY :%s", reason);
- }
-}
-
/* SYNTAX: AWAY [-one | -all] [<reason>] */
static void cmd_away(const char *data, IRC_SERVER_REC *server)
{
@@ -556,9 +542,9 @@ static void cmd_away(const char *data, IRC_SERVER_REC *server)
PARAM_FLAG_GETREST, "away", &optlist, &reason)) return;
if (g_hash_table_lookup(optlist, "one") != NULL)
- server_send_away(server, reason);
+ irc_server_send_away(server, reason);
else
- g_slist_foreach(servers, (GFunc) server_send_away, reason);
+ g_slist_foreach(servers, (GFunc) irc_server_send_away, reason);
cmd_params_free(free_arg);
}
diff --git a/src/irc/core/irc-servers-reconnect.c b/src/irc/core/irc-servers-reconnect.c
index 573bf9b1..1587d4e6 100644
--- a/src/irc/core/irc-servers-reconnect.c
+++ b/src/irc/core/irc-servers-reconnect.c
@@ -70,12 +70,8 @@ static void sig_connected(IRC_SERVER_REC *server)
if (!IS_IRC_SERVER(server) || !server->connrec->reconnection)
return;
- if (server->connrec->away_reason != NULL) {
- irc_send_cmdv(server, "AWAY :%s", server->connrec->away_reason);
-
- g_free(server->away_reason);
- server->away_reason = g_strdup(server->connrec->away_reason);
- }
+ if (server->connrec->away_reason != NULL)
+ irc_server_send_away(server, server->connrec->away_reason);
}
static void event_nick_collision(IRC_SERVER_REC *server, const char *data)
diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c
index d1292a08..d769fa5f 100644
--- a/src/irc/core/irc-servers.c
+++ b/src/irc/core/irc-servers.c
@@ -346,6 +346,20 @@ static void sig_server_quit(IRC_SERVER_REC *server, const char *msg)
g_free(str);
}
+void irc_server_send_away(IRC_SERVER_REC *server, const char *reason)
+{
+ if (!IS_IRC_SERVER(server))
+ return;
+
+ if (*reason != '\0' || server->usermode_away) {
+ g_free_and_null(server->away_reason);
+ if (*reason != '\0')
+ server->away_reason = g_strdup(reason);
+
+ irc_send_cmdv(server, "AWAY :%s", reason);
+ }
+}
+
void irc_server_send_data(IRC_SERVER_REC *server, const char *data, int len)
{
if (net_sendbuffer_send(server->handle, data, len) == -1) {
diff --git a/src/irc/core/irc-servers.h b/src/irc/core/irc-servers.h
index cdf5721e..fc3480a7 100644
--- a/src/irc/core/irc-servers.h
+++ b/src/irc/core/irc-servers.h
@@ -117,6 +117,7 @@ void irc_server_purge_output(IRC_SERVER_REC *server, const char *target);
char *irc_server_get_channels(IRC_SERVER_REC *server);
/* INTERNAL: */
+void irc_server_send_away(IRC_SERVER_REC *server, const char *reason);
void irc_server_send_data(IRC_SERVER_REC *server, const char *data, int len);
void irc_server_init_isupport(IRC_SERVER_REC *server);