1
0
mirror of https://github.com/irssi/irssi.git synced 2024-10-27 05:20:20 -04:00

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
This commit is contained in:
Emanuele Giaquinta 2008-11-12 20:31:41 +00:00 committed by exg
parent ee6133f324
commit cf41f6d45d
4 changed files with 19 additions and 22 deletions

View File

@ -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);
}

View File

@ -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)

View File

@ -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) {

View File

@ -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);