aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitlbee.c2
-rw-r--r--ipc.c10
-rw-r--r--irc.c36
-rw-r--r--irc.h8
-rw-r--r--irc_commands.c6
-rw-r--r--protocols/msn/msn.c51
-rw-r--r--protocols/nogaim.c3
-rw-r--r--protocols/nogaim.h6
-rw-r--r--root_commands.c6
-rw-r--r--storage_text.c4
10 files changed, 80 insertions, 52 deletions
diff --git a/bitlbee.c b/bitlbee.c
index 748b7bba..1d4e2b34 100644
--- a/bitlbee.c
+++ b/bitlbee.c
@@ -227,7 +227,7 @@ gboolean bitlbee_io_current_client_write( gpointer data, gint fd, b_input_condit
irc->sendbuffer = NULL;
irc->w_watch_source_id = 0;
- if( irc->status == USTATUS_SHUTDOWN )
+ if( irc->status & USTATUS_SHUTDOWN )
irc_free( irc );
return FALSE;
diff --git a/ipc.c b/ipc.c
index be9bda0b..28aa07cb 100644
--- a/ipc.c
+++ b/ipc.c
@@ -114,7 +114,7 @@ static void ipc_child_cmd_die( irc_t *irc, char **cmd )
static void ipc_child_cmd_wallops( irc_t *irc, char **cmd )
{
- if( irc->status < USTATUS_LOGGED_IN )
+ if( !( irc->status & USTATUS_LOGGED_IN ) )
return;
if( strchr( irc->umode, 'w' ) )
@@ -123,7 +123,7 @@ static void ipc_child_cmd_wallops( irc_t *irc, char **cmd )
static void ipc_child_cmd_lilo( irc_t *irc, char **cmd )
{
- if( irc->status < USTATUS_LOGGED_IN )
+ if( !( irc->status & USTATUS_LOGGED_IN ) )
return;
if( strchr( irc->umode, 's' ) )
@@ -132,7 +132,7 @@ static void ipc_child_cmd_lilo( irc_t *irc, char **cmd )
static void ipc_child_cmd_opermsg( irc_t *irc, char **cmd )
{
- if( irc->status < USTATUS_LOGGED_IN )
+ if( !( irc->status & USTATUS_LOGGED_IN ) )
return;
if( strchr( irc->umode, 'o' ) )
@@ -153,7 +153,7 @@ static void ipc_child_cmd_rehash( irc_t *irc, char **cmd )
static void ipc_child_cmd_kill( irc_t *irc, char **cmd )
{
- if( irc->status < USTATUS_LOGGED_IN )
+ if( !( irc->status & USTATUS_LOGGED_IN ) )
return;
if( nick_cmp( cmd[1], irc->nick ) != 0 )
@@ -165,7 +165,7 @@ static void ipc_child_cmd_kill( irc_t *irc, char **cmd )
static void ipc_child_cmd_hello( irc_t *irc, char **cmd )
{
- if( irc->status < USTATUS_LOGGED_IN )
+ if( !( irc->status & USTATUS_LOGGED_IN ) )
ipc_to_master_str( "HELLO\r\n" );
else
ipc_to_master_str( "HELLO %s %s :%s\r\n", irc->host, irc->nick, irc->realname );
diff --git a/irc.c b/irc.c
index 97365f4d..52b80d41 100644
--- a/irc.c
+++ b/irc.c
@@ -176,7 +176,7 @@ void irc_abort( irc_t *irc, int immed, char *format, ... )
irc->nick ? irc->nick : "(NONE)", irc->host, "No reason given" );
}
- irc->status = USTATUS_SHUTDOWN;
+ irc->status |= USTATUS_SHUTDOWN;
if( irc->sendbuffer && !immed )
{
/* We won't read from this socket anymore. Instead, we'll connect a timer
@@ -210,7 +210,7 @@ void irc_free(irc_t * irc)
log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd );
- if( irc->status >= USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) )
+ if( irc->status & USTATUS_IDENTIFIED && set_getint( irc, "save_on_quit" ) )
if( storage_save( irc, TRUE ) != STORAGE_OK )
irc_usermsg( irc, "Error while saving settings!" );
@@ -706,7 +706,7 @@ int irc_check_login( irc_t *irc )
{
if( irc->user && irc->nick )
{
- if( global.conf->authmode == AUTHMODE_CLOSED && irc->status < USTATUS_AUTHORIZED )
+ if( global.conf->authmode == AUTHMODE_CLOSED && !( irc->status & USTATUS_AUTHORIZED ) )
{
irc_reply( irc, 464, ":This server is password-protected." );
return 0;
@@ -763,7 +763,7 @@ void irc_login( irc_t *irc )
if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON )
ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->host, irc->nick, irc->realname );
- irc->status = USTATUS_LOGGED_IN;
+ irc->status |= USTATUS_LOGGED_IN;
}
void irc_motd( irc_t *irc )
@@ -904,9 +904,31 @@ void irc_kick( irc_t *irc, user_t *u, char *channel, user_t *kicker )
void irc_kill( irc_t *irc, user_t *u )
{
- char *nick;
+ char *nick, *s;
+ char reason[64];
+
+ if( u->gc && u->gc->flags & OPT_LOGGING_OUT )
+ {
+ if( u->gc->user->proto_opt[0][0] )
+ g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost,
+ u->gc->user->proto_opt[0] );
+ else if( ( s = strchr( u->gc->username, '@' ) ) )
+ g_snprintf( reason, sizeof( reason ), "%s %s", irc->myhost,
+ s + 1 );
+ else
+ g_snprintf( reason, sizeof( reason ), "%s %s.%s", irc->myhost,
+ u->gc->prpl->name, irc->myhost );
+
+ /* proto_opt might contain garbage after the : */
+ if( ( s = strchr( reason, ':' ) ) )
+ *s = 0;
+ }
+ else
+ {
+ strcpy( reason, "Leaving..." );
+ }
- irc_write( irc, ":%s!%s@%s QUIT :%s", u->nick, u->user, u->host, "Leaving..." );
+ irc_write( irc, ":%s!%s@%s QUIT :%s", u->nick, u->user, u->host, reason );
nick = g_strdup( u->nick );
nick_lc( nick );
@@ -1164,7 +1186,7 @@ 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( !( irc->status & USTATUS_LOGGED_IN ) )
{
if( gettime() > ( irc->last_pong + IRC_LOGIN_TIMEOUT ) )
rv = gettime() - irc->last_pong;
diff --git a/irc.h b/irc.h
index e702a864..ad52f42f 100644
--- a/irc.h
+++ b/irc.h
@@ -41,10 +41,10 @@
typedef enum
{
USTATUS_OFFLINE = 0,
- USTATUS_AUTHORIZED,
- USTATUS_LOGGED_IN,
- USTATUS_IDENTIFIED,
- USTATUS_SHUTDOWN = -1
+ USTATUS_AUTHORIZED = 1,
+ USTATUS_LOGGED_IN = 2,
+ USTATUS_IDENTIFIED = 4,
+ USTATUS_SHUTDOWN = 8
} irc_status_t;
typedef struct channel
diff --git a/irc_commands.c b/irc_commands.c
index dc59f7ee..f410bb52 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -31,7 +31,7 @@ static void irc_cmd_pass( irc_t *irc, char **cmd )
{
if( global.conf->auth_pass && strcmp( cmd[1], global.conf->auth_pass ) == 0 )
{
- irc->status = USTATUS_AUTHORIZED;
+ irc->status |= USTATUS_AUTHORIZED;
irc_check_login( irc );
}
else
@@ -609,11 +609,11 @@ void irc_exec( irc_t *irc, char *cmd[] )
/* There should be no typo in the next line: */
for( n_arg = 0; cmd[n_arg]; n_arg ++ ); n_arg --;
- if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status >= USTATUS_LOGGED_IN )
+ if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status & USTATUS_LOGGED_IN )
{
irc_reply( irc, 462, ":Only allowed before logging in" );
}
- else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && irc->status < USTATUS_LOGGED_IN )
+ else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && !( irc->status & USTATUS_LOGGED_IN ) )
{
irc_reply( irc, 451, ":Register first" );
}
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c
index 3c7064f8..bac9c427 100644
--- a/protocols/msn/msn.c
+++ b/protocols/msn/msn.c
@@ -63,33 +63,38 @@ static void msn_close( struct gaim_connection *gc )
struct msn_data *md = gc->proto_data;
GSList *l;
- if( md->fd >= 0 )
- closesocket( md->fd );
-
- if( md->handler )
- {
- if( md->handler->rxq ) g_free( md->handler->rxq );
- if( md->handler->cmd_text ) g_free( md->handler->cmd_text );
- g_free( md->handler );
- }
-
- while( md->switchboards )
- msn_sb_destroy( md->switchboards->data );
-
- if( md->msgq )
+ if( md )
{
- struct msn_message *m;
+ if( md->fd >= 0 )
+ closesocket( md->fd );
- for( l = md->msgq; l; l = l->next )
+ if( md->handler )
{
- m = l->data;
+ if( md->handler->rxq ) g_free( md->handler->rxq );
+ if( md->handler->cmd_text ) g_free( md->handler->cmd_text );
+ g_free( md->handler );
+ }
- serv_got_crap( gc, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who );
- g_free( m->who );
- g_free( m->text );
- g_free( m );
+ while( md->switchboards )
+ msn_sb_destroy( md->switchboards->data );
+
+ if( md->msgq )
+ {
+ struct msn_message *m;
+
+ for( l = md->msgq; l; l = l->next )
+ {
+ m = l->data;
+
+ serv_got_crap( gc, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who );
+ g_free( m->who );
+ g_free( m->text );
+ g_free( m );
+ }
+ g_slist_free( md->msgq );
}
- g_slist_free( md->msgq );
+
+ g_free( md );
}
for( l = gc->permit; l; l = l->next )
@@ -100,8 +105,6 @@ static void msn_close( struct gaim_connection *gc )
g_free( l->data );
g_slist_free( gc->deny );
- g_free( md );
-
msn_connections = g_slist_remove( msn_connections, gc );
}
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index b1975f19..78b51b53 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -293,8 +293,9 @@ void signoff( struct gaim_connection *gc )
account_t *a;
serv_got_crap( gc, "Signing off.." );
-
+
b_event_remove( gc->keepalive );
+ gc->flags |= OPT_LOGGING_OUT;
gc->keepalive = 0;
gc->prpl->close( gc );
b_event_remove( gc->inpa );
diff --git a/protocols/nogaim.h b/protocols/nogaim.h
index b0319d27..2080465c 100644
--- a/protocols/nogaim.h
+++ b/protocols/nogaim.h
@@ -53,10 +53,12 @@
#define WEBSITE "http://www.bitlbee.org/"
#define IM_FLAG_AWAY 0x0020
-#define OPT_CONN_HTML 0x00000001
-#define OPT_LOGGED_IN 0x00010000
#define GAIM_AWAY_CUSTOM "Custom"
+#define OPT_CONN_HTML 0x00000001
+#define OPT_LOGGED_IN 0x00010000
+#define OPT_LOGGING_OUT 0x00020000
+
/* ok. now the fun begins. first we create a connection structure */
struct gaim_connection
{
diff --git a/root_commands.c b/root_commands.c
index 0e12e9ab..3d3584b3 100644
--- a/root_commands.c
+++ b/root_commands.c
@@ -162,7 +162,7 @@ static void cmd_register( irc_t *irc, char **cmd )
break;
case STORAGE_OK:
- irc->status = USTATUS_IDENTIFIED;
+ irc->status |= USTATUS_IDENTIFIED;
irc_umode_set( irc, "+R", 1 );
break;
@@ -186,7 +186,7 @@ static void cmd_drop( irc_t *irc, char **cmd )
break;
case STORAGE_OK:
irc_setpass( irc, NULL );
- irc->status = USTATUS_LOGGED_IN;
+ irc->status &= ~USTATUS_IDENTIFIED;
irc_umode_set( irc, "-R", 1 );
irc_usermsg( irc, "Account `%s' removed", irc->nick );
break;
@@ -200,7 +200,7 @@ static void cmd_account( irc_t *irc, char **cmd )
{
account_t *a;
- if( global.conf->authmode == AUTHMODE_REGISTERED && irc->status < USTATUS_IDENTIFIED )
+ if( global.conf->authmode == AUTHMODE_REGISTERED && !( irc->status & USTATUS_IDENTIFIED ) )
{
irc_usermsg( irc, "This server only accepts registered users" );
return;
diff --git a/storage_text.c b/storage_text.c
index f807cb3e..506c9f03 100644
--- a/storage_text.c
+++ b/storage_text.c
@@ -70,7 +70,7 @@ static storage_status_t text_load ( const char *my_nick, const char* password, i
FILE *fp;
user_t *ru = user_find( irc, ROOT_NICK );
- if( irc->status >= USTATUS_IDENTIFIED )
+ if( irc->status & USTATUS_IDENTIFIED )
return( 1 );
g_snprintf( s, 511, "%s%s%s", global.conf->configdir, my_nick, ".accounts" );
@@ -87,7 +87,7 @@ static storage_status_t text_load ( const char *my_nick, const char* password, i
/* Do this now. If the user runs with AuthMode = Registered, the
account command will not work otherwise. */
- irc->status = USTATUS_IDENTIFIED;
+ irc->status |= USTATUS_IDENTIFIED;
while( fscanf( fp, "%511[^\n]s", s ) > 0 )
{