aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/msn/tables.c
blob: 42b12aa9d8200f01ae2bb4e60a0d66d9fb842746 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
  /********************************************************************\
  * BitlBee -- An IRC to other IM-networks gateway                     *
  *                                                                    *
  * Copyright 2002-2004 Wilmer van der Gaast and others                *
  \********************************************************************/

/* MSN module - Some tables with useful data                            */

/*
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License with
  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  Suite 330, Boston, MA  02111-1307  USA
*/

#include "nogaim.h"
#include "msn.h"

const struct msn_away_state msn_away_state_list[] =
{
	{ "NLN", "" },
	{ "AWY", "Away" },
	{ "BSY", "Busy" },
	{ "IDL", "Idle" },
	{ "BRB", "Be Right Back" },
	{ "PHN", "On the Phone" },
	{ "LUN", "Out to Lunch" },
	{ "HDN", "Hidden" },
	{ "",    "" }
};

const struct msn_away_state *msn_away_state_by_code( char *code )
{
	int i;
	
	for( i = 0; *msn_away_state_list[i].code; i ++ )
		if( g_strcasecmp( msn_away_state_list[i].code, code ) == 0 )
			return( msn_away_state_list + i );
	
	return NULL;
}

const struct msn_away_state *msn_away_state_by_name( char *name )
{
	int i;
	
	for( i = 0; *msn_away_state_list[i].code; i ++ )
		if( g_strcasecmp( msn_away_state_list[i].name, name ) == 0 )
			return( msn_away_state_list + i );
	
	return NULL;
}

const struct msn_status_code msn_status_code_list[] =
{
	{ 200, "Invalid syntax",                                        0 },
	{ 201, "Invalid parameter",                                     0 },
	{ 205, "Invalid (non-existent) handle",                         0 },
	{ 206, "Domain name missing",                                   0 },
	{ 207, "Already logged in",                                     0 },
	{ 208, "Invalid handle",                                        STATUS_SB_IM_SPARE },
	{ 209, "Forbidden nickname",                                    0 },
	{ 210, "Buddy list too long",                                   0 },
	{ 215, "Handle is already in list",                             0 },
	{ 216, "Handle is not in list",                                 STATUS_SB_IM_SPARE },
	{ 217, "Person is off-line or non-existent",                    STATUS_SB_IM_SPARE },
	{ 218, "Already in that mode",                                  0 },
	{ 219, "Handle is already in opposite list",                    0 },
	{ 223, "Too many groups",                                       0 },
	{ 224, "Invalid group or already in list",                      0 },
	{ 225, "Handle is not in that group",                           0 },
	{ 229, "Group name too long",                                   0 },
	{ 230, "Cannot remove that group",                              0 },
	{ 231, "Invalid group",                                         0 },
	{ 280, "Switchboard failed",                                    STATUS_SB_FATAL },
	{ 281, "Transfer to switchboard failed",                        0 },
	
	{ 300, "Required field missing",                                0 },
	{ 302, "Not logged in",                                         0 },
	
	{ 500, "Internal server error/Account banned",                  STATUS_FATAL },
	{ 501, "Database server error",                                 STATUS_FATAL },
	{ 502, "Command disabled",                                      0 },
	{ 510, "File operation failed",                                 STATUS_FATAL },
	{ 520, "Memory allocation failed",                              STATUS_FATAL },
	{ 540, "Challenge response invalid",                            STATUS_FATAL },
	
	{ 600, "Server is busy",                                        STATUS_FATAL },
	{ 601, "Server is unavailable",                                 STATUS_FATAL },
	{ 602, "Peer nameserver is down",                               STATUS_FATAL },
	{ 603, "Database connection failed",                            STATUS_FATAL },
	{ 604, "Server is going down",                                  STATUS_FATAL },
	{ 605, "Server is unavailable",                                 STATUS_FATAL },
	
	{ 700, "Could not create connection",                           STATUS_FATAL },
	{ 710, "Invalid CVR parameters",                                STATUS_FATAL },
	{ 711, "Write is blocking",                                     STATUS_FATAL },
	{ 712, "Session is overloaded",                                 STATUS_FATAL },
	{ 713, "Calling too rapidly",                                   STATUS_SB_IM_SPARE },
	{ 714, "Too many sessions",                                     STATUS_FATAL },
	{ 715, "Not expected/Invalid argument/action",                  0 },
	{ 717, "Bad friend file",                                       STATUS_FATAL },
	{ 731, "Not expected/Invalid argument",                         0 },
	
	{ 800, "Changing too rapidly",                                  0 },
	
	{ 910, "Server is busy",                                        STATUS_FATAL },
	{ 911, "Authentication failed",                                 STATUS_SB_FATAL | STATUS_FATAL },
	{ 912, "Server is busy",                                        STATUS_FATAL },
	{ 913, "Not allowed when hiding",                               0 },
	{ 914, "Server is unavailable",                                 STATUS_FATAL },
	{ 915, "Server is unavailable",                                 STATUS_FATAL },
	{ 916, "Server is unavailable",                                 STATUS_FATAL },
	{ 917, "Authentication failed",                                 STATUS_FATAL },
	{ 918, "Server is busy",                                        STATUS_FATAL },
	{ 919, "Server is busy",                                        STATUS_FATAL },
	{ 920, "Not accepting new principals",                          0 }, /* When a sb is full? */
	{ 922, "Server is busy",                                        STATUS_FATAL },
	{ 923, "Kids Passport without parental consent",                STATUS_FATAL },
	{ 924, "Passport account not yet verified",                     STATUS_FATAL },
	{ 928, "Bad ticket",                                            STATUS_FATAL },
	{  -1, NULL,                                                    0 }
};

const struct msn_status_code *msn_status_by_number( int number )
{
	static struct msn_status_code *unknown = NULL;
	int i;
	
	for( i = 0; msn_status_code_list[i].number >= 0; i ++ )
		if( msn_status_code_list[i].number == number )
			return( msn_status_code_list + i );
	
	if( unknown == NULL )
	{
		unknown = g_new0( struct msn_status_code, 1 );
		unknown->text = g_new0( char, 128 );
	}
	
	unknown->number = number;
	unknown->flags = 0;
	g_snprintf( unknown->text, 128, "Unknown error (%d)", number );
	
	return( unknown );
}
if( global.conf->ping_interval > 0 && global.conf->ping_timeout > 0 ) irc->ping_source_id = b_timeout_add( global.conf->ping_interval * 1000, irc_userping, irc ); irc_connection_list = g_slist_append( irc_connection_list, irc ); b = irc->b = bee_new(); b->ui_data = irc; b->ui = &irc_ui_funcs; s = set_add( &b->set, "away_devoice", "true", NULL/*set_eval_away_devoice*/, irc ); s = set_add( &b->set, "buddy_sendbuffer", "false", set_eval_bool, irc ); s = set_add( &b->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc ); s = set_add( &b->set, "charset", "utf-8", set_eval_charset, irc ); //s = set_add( &b->set, "control_channel", irc->channel, NULL/*set_eval_control_channel*/, irc ); s = set_add( &b->set, "default_target", "root", NULL, irc ); s = set_add( &b->set, "display_namechanges", "false", set_eval_bool, irc ); s = set_add( &b->set, "handle_unknown", "root", NULL, irc ); s = set_add( &b->set, "lcnicks", "true", set_eval_bool, irc ); s = set_add( &b->set, "ops", "both", NULL/*set_eval_ops*/, irc ); s = set_add( &b->set, "private", "true", set_eval_bool, irc ); s = set_add( &b->set, "query_order", "lifo", NULL, irc ); s = set_add( &b->set, "root_nick", ROOT_NICK, NULL/*set_eval_root_nick*/, irc ); s = set_add( &b->set, "simulate_netsplit", "true", set_eval_bool, irc ); s = set_add( &b->set, "to_char", ": ", set_eval_to_char, irc ); s = set_add( &b->set, "typing_notice", "false", set_eval_bool, irc ); irc->root = iu = irc_user_new( irc, ROOT_NICK ); iu->host = g_strdup( myhost ); iu->fullname = g_strdup( ROOT_FN ); iu->f = &irc_user_root_funcs; iu = irc_user_new( irc, NS_NICK ); iu->host = g_strdup( myhost ); iu->fullname = g_strdup( ROOT_FN ); iu->f = &irc_user_root_funcs; irc->user = g_new0( irc_user_t, 1 ); irc->user->host = g_strdup( host ); conf_loaddefaults( irc ); /* Evaluator sets the iconv/oconv structures. */ set_eval_charset( set_find( &b->set, "charset" ), set_getstr( &b->set, "charset" ) ); irc_write( irc, ":%s NOTICE AUTH :%s", irc->root->host, "BitlBee-IRCd initialized, please go on" ); g_free( myhost ); g_free( host ); return irc; } /* immed=1 makes this function pretty much equal to irc_free(), except that this one will "log". In case the connection is already broken and we shouldn't try to write to it. */ void irc_abort( irc_t *irc, int immed, char *format, ... ) { if( format != NULL ) { va_list params; char *reason; va_start( params, format ); reason = g_strdup_vprintf( format, params ); va_end( params ); if( !immed ) irc_write( irc, "ERROR :Closing link: %s", reason ); ipc_to_master_str( "OPERMSG :Client exiting: %s@%s [%s]\r\n", irc->user->nick ? irc->user->nick : "(NONE)", irc->root->host, reason ); g_free( reason ); } else { if( !immed ) irc_write( irc, "ERROR :Closing link" ); ipc_to_master_str( "OPERMSG :Client exiting: %s@%s [%s]\r\n", irc->user->nick ? irc->user->nick : "(NONE)", irc->root->host, "No reason given" ); } irc->status |= USTATUS_SHUTDOWN; if( irc->sendbuffer && !immed ) { /* Set up a timeout event that should shut down the connection in a second, just in case ..._write doesn't do it first. */ b_event_remove( irc->r_watch_source_id ); irc->r_watch_source_id = 0; b_event_remove( irc->ping_source_id ); irc->ping_source_id = b_timeout_add( 1000, (b_event_handler) irc_free, irc ); } else { irc_free( irc ); } } static gboolean irc_free_hashkey( gpointer key, gpointer value, gpointer data ); void irc_free( irc_t * irc ) { log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd ); /* if( irc->status & USTATUS_IDENTIFIED && set_getbool( &irc->b->set, "save_on_quit" ) ) if( storage_save( irc, NULL, TRUE ) != STORAGE_OK ) irc_usermsg( irc, "Error while saving settings!" ); */ irc_connection_list = g_slist_remove( irc_connection_list, irc ); /* while( irc->queries != NULL ) query_del( irc, irc->queries ); */ while( irc->users ) irc_user_free( irc, (irc_user_t *) irc->users->data ); while( irc->channels ) irc_channel_free( irc->channels->data ); if( irc->ping_source_id > 0 ) b_event_remove( irc->ping_source_id ); if( irc->r_watch_source_id > 0 ) b_event_remove( irc->r_watch_source_id ); if( irc->w_watch_source_id > 0 ) b_event_remove( irc->w_watch_source_id ); closesocket( irc->fd ); irc->fd = -1; g_hash_table_foreach_remove( irc->nick_user_hash, irc_free_hashkey, NULL ); g_hash_table_destroy( irc->nick_user_hash ); g_hash_table_foreach_remove( irc->watches, irc_free_hashkey, NULL ); g_hash_table_destroy( irc->watches ); if( irc->iconv != (GIConv) -1 ) g_iconv_close( irc->iconv ); if( irc->oconv != (GIConv) -1 ) g_iconv_close( irc->oconv ); g_free( irc->sendbuffer ); g_free( irc->readbuffer ); g_free( irc->password ); g_free( irc ); if( global.conf->runmode == RUNMODE_INETD || global.conf->runmode == RUNMODE_FORKDAEMON || ( global.conf->runmode == RUNMODE_DAEMON && global.listen_socket == -1 && irc_connection_list == NULL ) ) b_main_quit(); } static gboolean irc_free_hashkey( gpointer key, gpointer value, gpointer data ) { g_free( key ); return( TRUE ); } /* USE WITH CAUTION! Sets pass without checking */ void irc_setpass (irc_t *irc, const char *pass) { g_free (irc->password); if (pass) { irc->password = g_strdup (pass); } else { irc->password = NULL; } } static char **irc_splitlines( char *buffer ); void irc_process( irc_t *irc ) { char **lines, *temp, **cmd; int i; if( irc->readbuffer != NULL ) { lines = irc_splitlines( irc->readbuffer ); for( i = 0; *lines[i] != '\0'; i ++ ) { char *conv = NULL; /* [WvG] If the last line isn't empty, it's an incomplete line and we should wait for the rest to come in before processing it. */ if( lines[i+1] == NULL ) { temp = g_strdup( lines[i] ); g_free( irc->readbuffer ); irc->readbuffer = temp; i ++; break; } if( irc->iconv != (GIConv) -1 ) { gsize bytes_read, bytes_written; conv = g_convert_with_iconv( lines[i], -1, irc->iconv, &bytes_read, &bytes_written, NULL ); if( conv == NULL || bytes_read != strlen( lines[i] ) ) { /* GLib can do strange things if things are not in the expected charset, so let's be a little bit paranoid here: */ if( irc->status & USTATUS_LOGGED_IN ) { irc_usermsg( irc, "Error: Charset mismatch detected. The charset " "setting is currently set to %s, so please make " "sure your IRC client will send and accept text in " "that charset, or tell BitlBee which charset to " "expect by changing the charset setting. See " "`help set charset' for more information. Your " "message was ignored.", set_getstr( &irc->b->set, "charset" ) ); g_free( conv ); conv = NULL; } else { irc_write( irc, ":%s NOTICE AUTH :%s", irc->root->host, "Warning: invalid characters received at login time." ); conv = g_strdup( lines[i] ); for( temp = conv; *temp; temp ++ ) if( *temp & 0x80 ) *temp = '?'; } } lines[i] = conv; } if( lines[i] && ( cmd = irc_parse_line( lines[i] ) ) ) { irc_exec( irc, cmd ); g_free( cmd ); } g_free( conv ); /* Shouldn't really happen, but just in case... */ if( !g_slist_find( irc_connection_list, irc ) ) { g_free( lines ); return; } } if( lines[i] != NULL ) { g_free( irc->readbuffer ); irc->readbuffer = NULL; } g_free( lines ); } } /* Splits a long string into separate lines. The array is NULL-terminated and, unless the string contains an incomplete line at the end, ends with an empty string. Could use g_strsplit() but this one does it in-place. (So yes, it's destructive.) */ static char **irc_splitlines( char *buffer ) { int i, j, n = 3; char **lines; /* Allocate n+1 elements. */ lines = g_new( char *, n + 1 ); lines[0] = buffer; /* Split the buffer in several strings, and accept any kind of line endings, * knowing that ERC on Windows may send something interesting like \r\r\n, * and surely there must be clients that think just \n is enough... */ for( i = 0, j = 0; buffer[i] != '\0'; i ++ ) { if( buffer[i] == '\r' || buffer[i] == '\n' ) { while( buffer[i] == '\r' || buffer[i] == '\n' ) buffer[i++] = '\0'; lines[++j] = buffer + i; if( j >= n ) { n *= 2; lines = g_renew( char *, lines, n + 1 ); } if( buffer[i] == '\0' ) break; } } /* NULL terminate our list. */ lines[++j] = NULL; return lines; } /* Split an IRC-style line into little parts/arguments. */ char **irc_parse_line( char *line ) { int i, j; char **cmd; /* Move the line pointer to the start of the command, skipping spaces and the optional prefix. */ if( line[0] == ':' ) { for( i = 0; line[i] && line[i] != ' '; i ++ ); line = line + i; } for( i = 0; line[i] == ' '; i ++ ); line = line + i; /* If we're already at the end of the line, return. If not, we're going to need at least one element. */ if( line[0] == '\0') return NULL; /* Count the number of char **cmd elements we're going to need. */ j = 1; for( i = 0; line[i] != '\0'; i ++ ) { if( line[i] == ' ' ) { j ++; if( line[i+1] == ':' ) break; } } /* Allocate the space we need. */ cmd = g_new( char *, j + 1 ); cmd[j] = NULL; /* Do the actual line splitting, format is: * Input: "PRIVMSG #bitlbee :foo bar" * Output: cmd[0]=="PRIVMSG", cmd[1]=="#bitlbee", cmd[2]=="foo bar", cmd[3]==NULL */ cmd[0] = line; for( i = 0, j = 0; line[i] != '\0'; i ++ ) { if( line[i] == ' ' ) { line[i] = '\0'; cmd[++j] = line + i + 1; if( line[i+1] == ':' ) { cmd[j] ++; break; } } } return cmd; } /* Converts such an array back into a command string. Mainly used for the IPC code right now. */ char *irc_build_line( char **cmd ) { int i, len; char *s; if( cmd[0] == NULL ) return NULL; len = 1; for( i = 0; cmd[i]; i ++ ) len += strlen( cmd[i] ) + 1; if( strchr( cmd[i-1], ' ' ) != NULL ) len ++; s = g_new0( char, len + 1 ); for( i = 0; cmd[i]; i ++ ) { if( cmd[i+1] == NULL && strchr( cmd[i], ' ' ) != NULL ) strcat( s, ":" ); strcat( s, cmd[i] ); if( cmd[i+1] ) strcat( s, " " ); } strcat( s, "\r\n" ); return s; } void irc_write( irc_t *irc, char *format, ... ) { va_list params; va_start( params, format ); irc_vawrite( irc, format, params ); va_end( params ); return; } void irc_write_all( int now, char *format, ... ) { va_list params; GSList *temp; va_start( params, format ); temp = irc_connection_list; while( temp != NULL ) { irc_t *irc = temp->data; if( now ) { g_free( irc->sendbuffer ); irc->sendbuffer = g_strdup( "\r\n" ); } irc_vawrite( temp->data, format, params ); if( now ) { bitlbee_io_current_client_write( irc, irc->fd, GAIM_INPUT_WRITE ); } temp = temp->next; } va_end( params ); return; } void irc_vawrite( irc_t *irc, char *format, va_list params ) { int size; char line[IRC_MAX_LINE+1]; /* Don't try to write anything new anymore when shutting down. */ if( irc->status & USTATUS_SHUTDOWN ) return; memset( line, 0, sizeof( line ) ); g_vsnprintf( line, IRC_MAX_LINE - 2, format, params ); strip_newlines( line ); if( irc->oconv != (GIConv) -1 ) { gsize bytes_read, bytes_written; char *conv; conv = g_convert_with_iconv( line, -1, irc->oconv, &bytes_read, &bytes_written, NULL ); if( bytes_read == strlen( line ) ) strncpy( line, conv, IRC_MAX_LINE - 2 ); g_free( conv ); } g_strlcat( line, "\r\n", IRC_MAX_LINE + 1 ); if( irc->sendbuffer != NULL ) { size = strlen( irc->sendbuffer ) + strlen( line ); irc->sendbuffer = g_renew ( char, irc->sendbuffer, size + 1 ); strcpy( ( irc->sendbuffer + strlen( irc->sendbuffer ) ), line ); } else { irc->sendbuffer = g_strdup(line); } if( irc->w_watch_source_id == 0 ) { /* If the buffer is empty we can probably write, so call the write event handler immediately. If it returns TRUE, it should be called again, so add the event to the queue. If it's FALSE, we emptied the buffer and saved ourselves some work in the event queue. */ /* Really can't be done as long as the code doesn't do error checking very well: if( bitlbee_io_current_client_write( irc, irc->fd, GAIM_INPUT_WRITE ) ) */ /* So just always do it via the event handler. */ irc->w_watch_source_id = b_input_add( irc->fd, GAIM_INPUT_WRITE, bitlbee_io_current_client_write, irc ); } return; } int irc_check_login( irc_t *irc ) { if( irc->user->user && irc->user->nick ) { if( global.conf->authmode == AUTHMODE_CLOSED && !( irc->status & USTATUS_AUTHORIZED ) ) { irc_send_num( irc, 464, ":This server is password-protected." ); return 0; } else { irc_channel_t *ic; irc_user_t *iu = irc->user; irc->user = irc_user_new( irc, iu->nick ); irc->user->user = iu->user; irc->user->host = iu->host; irc->user->fullname = iu->fullname; irc->user->f = &irc_user_self_funcs; g_free( iu->nick ); g_free( iu ); if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON ) ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->user->host, irc->user->nick, irc->user->fullname ); irc->status |= USTATUS_LOGGED_IN; /* This is for bug #209 (use PASS to identify to NickServ). */ if( irc->password != NULL ) { char *send_cmd[] = { "identify", g_strdup( irc->password ), NULL }; /*irc_setpass( irc, NULL );*/ /*root_command( irc, send_cmd );*/ g_free( send_cmd[1] ); } irc_send_login( irc ); irc->umode[0] = '\0'; irc_umode_set( irc, "+" UMODE, TRUE ); ic = irc_channel_new( irc, ROOT_CHAN ); irc_channel_set_topic( ic, CONTROL_TOPIC, irc->root ); irc_channel_add_user( ic, irc->user ); irc->last_root_cmd = g_strdup( ROOT_CHAN ); irc_send_msg( irc->root, "PRIVMSG", ROOT_CHAN, "Welcome to the BitlBee gateway!\n\n" "If you've never used BitlBee before, please do read the help " "information using the \x02help\x02 command. Lots of FAQs are " "answered there.\n" "If you already have an account on this server, just use the " "\x02identify\x02 command to identify yourself.", NULL ); return 1; } } else { /* More information needed. */ return 0; } } void irc_umode_set( irc_t *irc, const char *s, gboolean allow_priv ) { /* allow_priv: Set to 0 if s contains user input, 1 if you want to set a "privileged" mode (+o, +R, etc). */ char m[128], st = 1; const char *t; int i; char changes[512], *p, st2 = 2; char badflag = 0; memset( m, 0, sizeof( m ) ); for( t = irc->umode; *t; t ++ ) if( *t < sizeof( m ) ) m[(int)*t] = 1; p = changes; for( t = s; *t; t ++ ) { if( *t == '+' || *t == '-' ) st = *t == '+'; else if( ( st == 0 && ( !strchr( UMODES_KEEP, *t ) || allow_priv ) ) || ( st == 1 && strchr( UMODES, *t ) ) || ( st == 1 && allow_priv && strchr( UMODES_PRIV, *t ) ) ) { if( m[(int)*t] != st) { if( st != st2 ) st2 = st, *p++ = st ? '+' : '-'; *p++ = *t; } m[(int)*t] = st; } else badflag = 1; } *p = '\0'; memset( irc->umode, 0, sizeof( irc->umode ) ); for( i = 'A'; i <= 'z' && strlen( irc->umode ) < ( sizeof( irc->umode ) - 1 ); i ++ ) if( m[i] ) irc->umode[strlen(irc->umode)] = i; if( badflag ) irc_send_num( irc, 501, ":Unknown MODE flag" ); if( *changes ) irc_write( irc, ":%s!%s@%s MODE %s :%s", irc->user->nick, irc->user->user, irc->user->host, irc->user->nick, changes ); } /* Returns 0 if everything seems to be okay, a number >0 when there was a timeout. The number returned is the number of seconds we received no pongs from the user. When not connected yet, we don't ping but drop the connection when the user fails to connect in IRC_LOGIN_TIMEOUT secs. */ static gboolean irc_userping( gpointer _irc, gint fd, b_input_condition cond ) { irc_t *irc = _irc; int rv = 0; if( !( irc->status & USTATUS_LOGGED_IN ) ) { if( gettime() > ( irc->last_pong + IRC_LOGIN_TIMEOUT ) ) rv = gettime() - irc->last_pong; } else { if( ( gettime() > ( irc->last_pong + global.conf->ping_interval ) ) && !irc->pinging ) { irc_write( irc, "PING :%s", IRC_PING_STRING ); irc->pinging = 1; } else if( gettime() > ( irc->last_pong + global.conf->ping_timeout ) ) { rv = gettime() - irc->last_pong; } } if( rv > 0 ) { irc_abort( irc, 0, "Ping Timeout: %d seconds", rv ); return FALSE; } return TRUE; } static char *set_eval_charset( set_t *set, char *value ) { irc_t *irc = set->data; GIConv ic, oc; if( g_strcasecmp( value, "none" ) == 0 ) value = g_strdup( "utf-8" ); if( ( ic = g_iconv_open( "utf-8", value ) ) == (GIConv) -1 ) { return NULL; } if( ( oc = g_iconv_open( value, "utf-8" ) ) == (GIConv) -1 ) { g_iconv_close( ic ); return NULL; } if( irc->iconv != (GIConv) -1 ) g_iconv_close( irc->iconv ); if( irc->oconv != (GIConv) -1 ) g_iconv_close( irc->oconv ); irc->iconv = ic; irc->oconv = oc; return value; }