From ecf8fa820aa8fa3592bdf96ed3bdeec4ec94f036 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 9 May 2006 09:20:05 +0200 Subject: Split off event handling related functions (depending on GLib) to events_glib.c. --- protocols/nogaim.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 51d08e5a..4c2a3bb4 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -1,7 +1,7 @@ /********************************************************************\ * BitlBee -- An IRC to other IM-networks gateway * * * - * Copyright 2002-2004 Wilmer van der Gaast and others * + * Copyright 2002-2006 Wilmer van der Gaast and others * \********************************************************************/ /* @@ -12,8 +12,6 @@ * This file contains functions called by the Gaim IM-modules. It's written * from scratch for BitlBee and doesn't contain any code from Gaim anymore * (except for the function names). - * - * Copyright 2002-2006 Wilmer van der Gaast and others */ /* -- cgit v1.2.3 From ba9edaa568088900145bbd1004c864b7d408c38d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 10 May 2006 19:34:46 +0200 Subject: Moved everything to the BitlBee event handling API. --- protocols/nogaim.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 4c2a3bb4..c3d810a3 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -327,7 +327,7 @@ void serv_got_crap( struct gaim_connection *gc, char *format, ... ) g_free( text ); } -static gboolean send_keepalive( gpointer d ) +static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond ) { struct gaim_connection *gc = d; @@ -351,7 +351,7 @@ void account_online( struct gaim_connection *gc ) serv_got_crap( gc, "Logged in" ); - gc->keepalive = g_timeout_add( 60000, send_keepalive, gc ); + gc->keepalive = b_timeout_add( 60000, send_keepalive, gc ); gc->flags |= OPT_LOGGED_IN; /* Also necessary when we're not away, at least for some of the @@ -359,7 +359,7 @@ void account_online( struct gaim_connection *gc ) proto_away( gc, u->away ); } -gboolean auto_reconnect( gpointer data ) +gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ) { account_t *a = data; @@ -371,7 +371,7 @@ gboolean auto_reconnect( gpointer data ) void cancel_auto_reconnect( account_t *a ) { - while( g_source_remove_by_user_data( (gpointer) a ) ); + while( b_event_remove_by_data( (gpointer) a ) ); a->reconnect = 0; } @@ -383,10 +383,10 @@ void signoff( struct gaim_connection *gc ) serv_got_crap( gc, "Signing off.." ); - gaim_input_remove( gc->keepalive ); + b_event_remove( gc->keepalive ); gc->keepalive = 0; gc->prpl->close( gc ); - gaim_input_remove( gc->inpa ); + b_event_remove( gc->inpa ); while( u ) { @@ -416,7 +416,7 @@ void signoff( struct gaim_connection *gc ) serv_got_crap( gc, "Reconnecting in %d seconds..", delay ); a->reconnect = 1; - g_timeout_add( delay * 1000, auto_reconnect, a ); + b_timeout_add( delay * 1000, auto_reconnect, a ); } destroy_gaim_conn( gc ); -- cgit v1.2.3 From c98be000bb619dd597194b3a50a06f9717649f80 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 15 May 2006 11:52:01 +0200 Subject: No more need for remove_by_user_data, hope the auto-reconnect code isn't too unreliable anymore. --- protocols/nogaim.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index c3d810a3..06b629a5 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -247,7 +247,7 @@ struct gaim_connection *new_gaim_conn( struct aim_user *user ) /* [MD] BUGFIX: don't set gc->irc to the global IRC, but use the one from the struct aim_user. * This fixes daemon mode breakage where IRC doesn't point to the currently active connection. */ - gc->irc=user->irc; + gc->irc = user->irc; connections = g_slist_append( connections, gc ); @@ -371,7 +371,8 @@ gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ) void cancel_auto_reconnect( account_t *a ) { - while( b_event_remove_by_data( (gpointer) a ) ); + /* while( b_event_remove_by_data( (gpointer) a ) ); */ + b_event_remove( a->reconnect ); a->reconnect = 0; } @@ -413,10 +414,9 @@ void signoff( struct gaim_connection *gc ) else if( !gc->wants_to_die && set_getint( irc, "auto_reconnect" ) ) { int delay = set_getint( irc, "auto_reconnect_delay" ); - serv_got_crap( gc, "Reconnecting in %d seconds..", delay ); - a->reconnect = 1; - b_timeout_add( delay * 1000, auto_reconnect, a ); + serv_got_crap( gc, "Reconnecting in %d seconds..", delay ); + a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a ); } destroy_gaim_conn( gc ); -- cgit v1.2.3 From fb62f81f947c74e274b05e32d2e88e3a4d7e2613 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 3 Jun 2006 21:51:16 +0200 Subject: Implemented netsplits for "account off". --- protocols/nogaim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 04d48236..f95ddd8a 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -294,7 +294,8 @@ void signoff( struct gaim_connection *gc ) account_t *a; serv_got_crap( gc, "Signing off.." ); - + gc->flags |= OPT_LOGGING_OUT; + gaim_input_remove( gc->keepalive ); gc->keepalive = 0; gc->prpl->close( gc ); -- cgit v1.2.3 From 5c9512ffa716f2bc8bbf9e2c31ee40624a0ff842 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 30 Jun 2006 11:17:18 +0200 Subject: Made set.c API more generic so it's not specific to irc_t structures anymore, but can be used for account_t structures too, for example. --- protocols/nogaim.c | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 04d1ee3e..f94d936d 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -219,8 +219,8 @@ void serv_got_crap( struct gaim_connection *gc, char *format, ... ) text = g_strdup_vprintf( format, params ); va_end( params ); - if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) || - ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) + if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) || + ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) ) strip_html( text ); /* Try to find a different connection on the same protocol. */ @@ -323,9 +323,9 @@ void signoff( struct gaim_connection *gc ) { /* Uhm... This is very sick. */ } - else if( !gc->wants_to_die && set_getint( irc, "auto_reconnect" ) ) + else if( !gc->wants_to_die && set_getint( &irc->set, "auto_reconnect" ) ) { - int delay = set_getint( irc, "auto_reconnect_delay" ); + int delay = set_getint( &irc->set, "auto_reconnect_delay" ); serv_got_crap( gc, "Reconnecting in %d seconds..", delay ); a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a ); @@ -364,12 +364,12 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea char *s; irc_t *irc = gc->irc; - if( set_getint( irc, "debug" ) && 0 ) /* This message is too useless */ + if( set_getint( &irc->set, "debug" ) && 0 ) /* This message is too useless */ serv_got_crap( gc, "Receiving user add from handle: %s", handle ); if( user_findhandle( gc, handle ) ) { - if( set_getint( irc, "debug" ) ) + if( set_getint( &irc->set, "debug" ) ) serv_got_crap( gc, "User already exists, ignoring add request: %s", handle ); return; @@ -457,7 +457,7 @@ void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname u->realname = g_strdup( realname ); - if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( gc->irc, "display_namechanges" ) ) + if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( &gc->irc->set, "display_namechanges" ) ) serv_got_crap( gc, "User `%s' changed name to `%s'", u->nick, u->realname ); } } @@ -513,14 +513,14 @@ void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, in if( !u ) { - if( g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "add" ) == 0 ) + if( g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "add" ) == 0 ) { add_buddy( gc, NULL, handle, NULL ); u = user_findhandle( gc, handle ); } else { - if( set_getint( gc->irc, "debug" ) || g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "ignore" ) != 0 ) + if( set_getint( &gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 ) { serv_got_crap( gc, "serv_got_update() for handle %s:", handle ); serv_got_crap( gc, "loggedin = %d, type = %d", loggedin, type ); @@ -579,7 +579,7 @@ void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, in u->away = NULL; /* LISPy... */ - if( ( set_getint( gc->irc, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ + if( ( set_getint( &gc->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ ( u->online ) && /* Don't touch offline people */ ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ @@ -598,18 +598,18 @@ void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 f if( !u ) { - char *h = set_getstr( irc, "handle_unknown" ); + char *h = set_getstr( &irc->set, "handle_unknown" ); if( g_strcasecmp( h, "ignore" ) == 0 ) { - if( set_getint( irc, "debug" ) ) + if( set_getint( &irc->set, "debug" ) ) serv_got_crap( gc, "Ignoring message from unknown handle %s", handle ); return; } else if( g_strncasecmp( h, "add", 3 ) == 0 ) { - int private = set_getint( irc, "private" ); + int private = set_getint( &irc->set, "private" ); if( h[3] ) { @@ -630,8 +630,8 @@ void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 f } } - if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) || - ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) + if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) || + ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) ) strip_html( msg ); while( strlen( msg ) > 425 ) @@ -671,7 +671,7 @@ void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int { user_t *u; - if( !set_getint( gc->irc, "typing_notice" ) ) + if( !set_getint( &gc->irc->set, "typing_notice" ) ) return; if( ( u = user_findhandle( gc, handle ) ) ) { @@ -693,7 +693,7 @@ void serv_got_chat_left( struct gaim_connection *gc, int id ) struct conversation *c, *l = NULL; GList *ir; - if( set_getint( gc->irc, "debug" ) ) + if( set_getint( &gc->irc->set, "debug" ) ) serv_got_crap( gc, "You were removed from conversation %d", (int) id ); for( c = gc->conversations; c && c->id != id; c = (l=c)->next ); @@ -738,8 +738,8 @@ void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whispe u = user_findhandle( gc, who ); for( c = gc->conversations; c && c->id != id; c = c->next ); - if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) || - ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) ) + if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) || + ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) ) strip_html( msg ); if( c && u ) @@ -772,7 +772,7 @@ struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, c c->channel = g_strdup( s ); g_free( s ); - if( set_getint( gc->irc, "debug" ) ) + if( set_getint( &gc->irc->set, "debug" ) ) serv_got_crap( gc, "Creating new conversation: (id=%d,handle=%s)", id, handle ); return( c ); @@ -786,7 +786,7 @@ void add_chat_buddy( struct conversation *b, char *handle ) user_t *u = user_findhandle( b->gc, handle ); int me = 0; - if( set_getint( b->gc->irc, "debug" ) ) + if( set_getint( &b->gc->irc->set, "debug" ) ) serv_got_crap( b->gc, "User %s added to conversation %d", handle, b->id ); /* It might be yourself! */ @@ -820,7 +820,7 @@ void remove_chat_buddy( struct conversation *b, char *handle, char *reason ) user_t *u; int me = 0; - if( set_getint( b->gc->irc, "debug" ) ) + if( set_getint( &b->gc->irc->set, "debug" ) ) serv_got_crap( b->gc, "User %s removed from conversation %d (%s)", handle, b->id, reason ? reason : "" ); /* It might be yourself! */ @@ -882,8 +882,9 @@ struct conversation *conv_findchannel( char *channel ) return( NULL ); } -char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ) +char *set_eval_away_devoice( set_t *set, char *value ) { + irc_t *irc = set->data; int st; if( ( g_strcasecmp( value, "true" ) == 0 ) || ( g_strcasecmp( value, "yes" ) == 0 ) || ( g_strcasecmp( value, "on" ) == 0 ) ) @@ -897,7 +898,7 @@ char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ) /* Horror.... */ - if( st != set_getint( irc, "away_devoice" ) ) + if( st != set_getint( &irc->set, "away_devoice" ) ) { char list[80] = ""; user_t *u = irc->users; @@ -937,7 +938,7 @@ char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ) irc->channel, pm, v, list ); } - return( set_eval_bool( irc, set, value ) ); + return( set_eval_bool( set, value ) ); } @@ -1017,7 +1018,7 @@ int bim_set_away( struct gaim_connection *gc, char *away ) if( s ) { gc->prpl->set_away( gc, s, away ); - if( set_getint( gc->irc, "debug" ) ) + if( set_getint( &gc->irc->set, "debug" ) ) serv_got_crap( gc, "Setting away state to %s", s ); } else -- cgit v1.2.3 From 0a3c243b6659dc10efb227e507f324c2711d6dcd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 1 Jul 2006 01:18:56 +0200 Subject: Got rid of struct aim_user (now using account_t everywhere). Needs some more testing though. --- protocols/nogaim.c | 99 ++++++++++++++++++++++++------------------------------ 1 file changed, 43 insertions(+), 56 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index f94d936d..8346f5fa 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -144,33 +144,21 @@ GSList *get_connections() { return connections; } /* multi.c */ -struct gaim_connection *new_gaim_conn( struct aim_user *user ) +struct gaim_connection *new_gaim_conn( account_t *acc ) { struct gaim_connection *gc; - account_t *a; gc = g_new0( struct gaim_connection, 1 ); - gc->prpl = user->prpl; - g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username ); - g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password ); - /* [MD] BUGFIX: don't set gc->irc to the global IRC, but use the one from the struct aim_user. - * This fixes daemon mode breakage where IRC doesn't point to the currently active connection. - */ - gc->irc = user->irc; - - connections = g_slist_append( connections, gc ); + /* Maybe we should get rid of this memory waste later. ;-) */ + g_snprintf( gc->username, sizeof( gc->username ), "%s", acc->user ); + g_snprintf( gc->password, sizeof( gc->password ), "%s", acc->pass ); - user->gc = gc; - gc->user = user; + gc->irc = acc->irc; + gc->acc = acc; + acc->gc = gc; - // Find the account_t so we can set its gc pointer - for( a = gc->irc->accounts; a; a = a->next ) - if( ( struct aim_user * ) a->gc == user ) - { - a->gc = gc; - break; - } + connections = g_slist_append( connections, gc ); return( gc ); } @@ -188,7 +176,6 @@ void destroy_gaim_conn( struct gaim_connection *gc ) } connections = g_slist_remove( connections, gc ); - g_free( gc->user ); g_free( gc ); } @@ -225,14 +212,14 @@ void serv_got_crap( struct gaim_connection *gc, char *format, ... ) /* Try to find a different connection on the same protocol. */ for( a = gc->irc->accounts; a; a = a->next ) - if( a->prpl == gc->prpl && a->gc != gc ) + if( a->prpl == gc->acc->prpl && a->gc != gc ) break; /* If we found one, include the screenname in the message. */ if( a ) - irc_usermsg( gc->irc, "%s(%s) - %s", gc->prpl->name, gc->username, text ); + irc_usermsg( gc->irc, "%s(%s) - %s", gc->acc->prpl->name, gc->username, text ); else - irc_usermsg( gc->irc, "%s - %s", gc->prpl->name, text ); + irc_usermsg( gc->irc, "%s - %s", gc->acc->prpl->name, text ); g_free( text ); } @@ -241,8 +228,8 @@ static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond ) { struct gaim_connection *gc = d; - if( gc->prpl && gc->prpl->keepalive ) - gc->prpl->keepalive( gc ); + if( gc->acc->prpl->keepalive ) + gc->acc->prpl->keepalive( gc ); return TRUE; } @@ -298,7 +285,7 @@ void signoff( struct gaim_connection *gc ) gc->flags |= OPT_LOGGING_OUT; gc->keepalive = 0; - gc->prpl->close( gc ); + gc->acc->prpl->close( gc ); b_event_remove( gc->inpa ); while( u ) @@ -378,7 +365,7 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea } memset( nick, 0, MAX_NICK_LENGTH + 1 ); - strcpy( nick, nick_get( gc->irc, handle, gc->prpl, realname ) ); + strcpy( nick, nick_get( gc->irc, handle, gc->acc->prpl, realname ) ); u = user_add( gc->irc, nick ); @@ -390,15 +377,15 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea u->host = g_strdup( s + 1 ); u->user = g_strndup( handle, s - handle ); } - else if( gc->user->proto_opt[0] && *gc->user->proto_opt[0] ) + else if( *gc->acc->server ) { char *colon; - if( ( colon = strchr( gc->user->proto_opt[0], ':' ) ) ) - u->host = g_strndup( gc->user->proto_opt[0], - colon - gc->user->proto_opt[0] ); + if( ( colon = strchr( gc->acc->server, ':' ) ) ) + u->host = g_strndup( gc->acc->server, + colon - gc->acc->server ); else - u->host = g_strdup( gc->user->proto_opt[0] ); + u->host = g_strdup( gc->acc->server ); u->user = g_strdup( handle ); @@ -409,7 +396,7 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea } else { - u->host = g_strdup( gc->user->prpl->name ); + u->host = g_strdup( gc->acc->prpl->name ); u->user = g_strdup( handle ); } @@ -479,7 +466,7 @@ void show_got_added_no( gpointer w, struct show_got_added_data *data ) void show_got_added_yes( gpointer w, struct show_got_added_data *data ) { - data->gc->prpl->add_buddy( data->gc, data->handle ); + data->gc->acc->prpl->add_buddy( data->gc, data->handle ); add_buddy( data->gc, NULL, data->handle, data->handle ); return show_got_added_no( w, data ); @@ -558,11 +545,11 @@ void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, in remove_chat_buddy_silent( c, handle ); } - if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) ) + if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "oscar" ) == 0 || strcmp( gc->acc->prpl->name, "icq" ) == 0 ) ) { u->away = g_strdup( "Away" ); } - else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber") ) ) + else if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "jabber" ) == 0 ) ) { if( type & UC_DND ) u->away = g_strdup( "Do Not Disturb" ); @@ -571,9 +558,9 @@ void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, in else // if( type & UC_AWAY ) u->away = g_strdup( "Away" ); } - else if( ( type & UC_UNAVAILABLE ) && gc->prpl->get_status_string ) + else if( ( type & UC_UNAVAILABLE ) && gc->acc->prpl->get_status_string ) { - u->away = g_strdup( gc->prpl->get_status_string( gc, type ) ); + u->away = g_strdup( gc->acc->prpl->get_status_string( gc, type ) ); } else u->away = NULL; @@ -732,7 +719,7 @@ void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whispe user_t *u; /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ - if( g_strcasecmp( who, gc->user->username ) == 0 ) + if( g_strcasecmp( who, gc->username ) == 0 ) return; u = user_findhandle( gc, who ); @@ -790,7 +777,7 @@ void add_chat_buddy( struct conversation *b, char *handle ) serv_got_crap( b->gc, "User %s added to conversation %d", handle, b->id ); /* It might be yourself! */ - if( b->gc->prpl->cmp_buddynames( handle, b->gc->user->username ) == 0 ) + if( b->gc->acc->prpl->cmp_buddynames( handle, b->gc->username ) == 0 ) { u = user_find( b->gc->irc, b->gc->irc->nick ); if( !b->joined ) @@ -824,7 +811,7 @@ void remove_chat_buddy( struct conversation *b, char *handle, char *reason ) serv_got_crap( b->gc, "User %s removed from conversation %d (%s)", handle, b->id, reason ? reason : "" ); /* It might be yourself! */ - if( g_strcasecmp( handle, b->gc->user->username ) == 0 ) + if( g_strcasecmp( handle, b->gc->username ) == 0 ) { u = user_find( b->gc->irc, b->gc->irc->nick ); b->joined = 0; @@ -958,7 +945,7 @@ int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flag msg = buf; } - st = gc->prpl->send_im( gc, handle, msg, strlen( msg ), flags ); + st = gc->acc->prpl->send_im( gc, handle, msg, strlen( msg ), flags ); g_free( buf ); return st; @@ -975,7 +962,7 @@ int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ) msg = buf; } - st = gc->prpl->chat_send( gc, id, msg ); + st = gc->acc->prpl->chat_send( gc, id, msg ); g_free( buf ); return st; @@ -989,7 +976,7 @@ int bim_set_away( struct gaim_connection *gc, char *away ) char *s; if( !away ) away = ""; - ms = m = gc->prpl->away_states( gc ); + ms = m = gc->acc->prpl->away_states( gc ); while( m ) { @@ -1010,19 +997,19 @@ int bim_set_away( struct gaim_connection *gc, char *away ) if( m ) { - gc->prpl->set_away( gc, m->data, *away ? away : NULL ); + gc->acc->prpl->set_away( gc, m->data, *away ? away : NULL ); } else { s = bim_away_alias_find( ms, away ); if( s ) { - gc->prpl->set_away( gc, s, away ); + gc->acc->prpl->set_away( gc, s, away ); if( set_getint( &gc->irc->set, "debug" ) ) serv_got_crap( gc, "Setting away state to %s", s ); } else - gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); + gc->acc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); } g_list_free( ms ); @@ -1074,46 +1061,46 @@ static char *bim_away_alias_find( GList *gcm, char *away ) void bim_add_allow( struct gaim_connection *gc, char *handle ) { - if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) + if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) == NULL ) { gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) ); } - gc->prpl->add_permit( gc, handle ); + gc->acc->prpl->add_permit( gc, handle ); } void bim_rem_allow( struct gaim_connection *gc, char *handle ) { GSList *l; - if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) + if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) ) ) { g_free( l->data ); gc->permit = g_slist_delete_link( gc->permit, l ); } - gc->prpl->rem_permit( gc, handle ); + gc->acc->prpl->rem_permit( gc, handle ); } void bim_add_block( struct gaim_connection *gc, char *handle ) { - if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) + if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) == NULL ) { gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) ); } - gc->prpl->add_deny( gc, handle ); + gc->acc->prpl->add_deny( gc, handle ); } void bim_rem_block( struct gaim_connection *gc, char *handle ) { GSList *l; - if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) + if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) ) ) { g_free( l->data ); gc->deny = g_slist_delete_link( gc->deny, l ); } - gc->prpl->rem_deny( gc, handle ); + gc->acc->prpl->rem_deny( gc, handle ); } -- cgit v1.2.3 From 5b52a4895e5a59ff6509f7771f4d8665737688c3 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 3 Jul 2006 23:22:45 +0200 Subject: Implemented per-account nick lists instead of per-protocol nick lists. nick_t is dead, instead nicks are just saves in a per-account_t GLib hash table. While doing this, the import_buddies command finally died and text_save() disappeared, because the old file format can't handle most of the new features in this branch anyway. Still have to implement support for the new nick lists in text_load()! --- protocols/nogaim.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 8346f5fa..54965b84 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -365,7 +365,7 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea } memset( nick, 0, MAX_NICK_LENGTH + 1 ); - strcpy( nick, nick_get( gc->irc, handle, gc->acc->prpl, realname ) ); + strcpy( nick, nick_get( gc->acc, handle, realname ) ); u = user_add( gc->irc, nick ); @@ -377,7 +377,7 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea u->host = g_strdup( s + 1 ); u->user = g_strndup( handle, s - handle ); } - else if( *gc->acc->server ) + else if( gc->acc->server ) { char *colon; @@ -777,7 +777,7 @@ void add_chat_buddy( struct conversation *b, char *handle ) serv_got_crap( b->gc, "User %s added to conversation %d", handle, b->id ); /* It might be yourself! */ - if( b->gc->acc->prpl->cmp_buddynames( handle, b->gc->username ) == 0 ) + if( b->gc->acc->prpl->handle_cmp( handle, b->gc->username ) == 0 ) { u = user_find( b->gc->irc, b->gc->irc->nick ); if( !b->joined ) @@ -1061,7 +1061,7 @@ static char *bim_away_alias_find( GList *gcm, char *away ) void bim_add_allow( struct gaim_connection *gc, char *handle ) { - if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) == NULL ) + if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) == NULL ) { gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) ); } @@ -1073,7 +1073,7 @@ void bim_rem_allow( struct gaim_connection *gc, char *handle ) { GSList *l; - if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) ) ) + if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) ) { g_free( l->data ); gc->permit = g_slist_delete_link( gc->permit, l ); @@ -1084,7 +1084,7 @@ void bim_rem_allow( struct gaim_connection *gc, char *handle ) void bim_add_block( struct gaim_connection *gc, char *handle ) { - if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) == NULL ) + if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) == NULL ) { gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) ); } @@ -1096,7 +1096,7 @@ void bim_rem_block( struct gaim_connection *gc, char *handle ) { GSList *l; - if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) ) ) + if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) ) { g_free( l->data ); gc->deny = g_slist_delete_link( gc->deny, l ); -- cgit v1.2.3 From 00a52700d1dbab0736c7ace63c8be2f17b08b8f6 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 14 Jul 2006 20:24:59 +0200 Subject: Added a per-connection auto_reconnect setting. --- protocols/nogaim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 54965b84..f0008385 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -310,7 +310,8 @@ void signoff( struct gaim_connection *gc ) { /* Uhm... This is very sick. */ } - else if( !gc->wants_to_die && set_getint( &irc->set, "auto_reconnect" ) ) + else if( !gc->wants_to_die && set_getbool( &irc->set, "auto_reconnect" ) && + set_getbool( &a->set, "auto_reconnect" ) ) { int delay = set_getint( &irc->set, "auto_reconnect_delay" ); -- cgit v1.2.3 From d5ccd83c5235528df2481003502647b86b41fdc4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 13 Aug 2006 21:15:23 +0200 Subject: Extra comments in set.h and now properly using set_getbool() instead of set_getint(). --- protocols/nogaim.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index f0008385..47e2bda6 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -207,7 +207,7 @@ void serv_got_crap( struct gaim_connection *gc, char *format, ... ) va_end( params ); if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) || - ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) ) + ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) ) strip_html( text ); /* Try to find a different connection on the same protocol. */ @@ -352,12 +352,12 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea char *s; irc_t *irc = gc->irc; - if( set_getint( &irc->set, "debug" ) && 0 ) /* This message is too useless */ + if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */ serv_got_crap( gc, "Receiving user add from handle: %s", handle ); if( user_findhandle( gc, handle ) ) { - if( set_getint( &irc->set, "debug" ) ) + if( set_getbool( &irc->set, "debug" ) ) serv_got_crap( gc, "User already exists, ignoring add request: %s", handle ); return; @@ -445,7 +445,7 @@ void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname u->realname = g_strdup( realname ); - if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( &gc->irc->set, "display_namechanges" ) ) + if( ( gc->flags & OPT_LOGGED_IN ) && set_getbool( &gc->irc->set, "display_namechanges" ) ) serv_got_crap( gc, "User `%s' changed name to `%s'", u->nick, u->realname ); } } @@ -508,7 +508,7 @@ void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, in } else { - if( set_getint( &gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 ) + if( set_getbool( &gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 ) { serv_got_crap( gc, "serv_got_update() for handle %s:", handle ); serv_got_crap( gc, "loggedin = %d, type = %d", loggedin, type ); @@ -567,7 +567,7 @@ void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, in u->away = NULL; /* LISPy... */ - if( ( set_getint( &gc->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ + if( ( set_getbool( &gc->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ ( u->online ) && /* Don't touch offline people */ ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ @@ -590,14 +590,14 @@ void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 f if( g_strcasecmp( h, "ignore" ) == 0 ) { - if( set_getint( &irc->set, "debug" ) ) + if( set_getbool( &irc->set, "debug" ) ) serv_got_crap( gc, "Ignoring message from unknown handle %s", handle ); return; } else if( g_strncasecmp( h, "add", 3 ) == 0 ) { - int private = set_getint( &irc->set, "private" ); + int private = set_getbool( &irc->set, "private" ); if( h[3] ) { @@ -619,7 +619,7 @@ void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 f } if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) || - ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) ) + ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) ) strip_html( msg ); while( strlen( msg ) > 425 ) @@ -659,7 +659,7 @@ void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int { user_t *u; - if( !set_getint( &gc->irc->set, "typing_notice" ) ) + if( !set_getbool( &gc->irc->set, "typing_notice" ) ) return; if( ( u = user_findhandle( gc, handle ) ) ) { @@ -681,7 +681,7 @@ void serv_got_chat_left( struct gaim_connection *gc, int id ) struct conversation *c, *l = NULL; GList *ir; - if( set_getint( &gc->irc->set, "debug" ) ) + if( set_getbool( &gc->irc->set, "debug" ) ) serv_got_crap( gc, "You were removed from conversation %d", (int) id ); for( c = gc->conversations; c && c->id != id; c = (l=c)->next ); @@ -727,7 +727,7 @@ void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whispe for( c = gc->conversations; c && c->id != id; c = c->next ); if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) || - ( ( gc->flags & OPT_CONN_HTML ) && set_getint( &gc->irc->set, "strip_html" ) ) ) + ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) ) strip_html( msg ); if( c && u ) @@ -760,7 +760,7 @@ struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, c c->channel = g_strdup( s ); g_free( s ); - if( set_getint( &gc->irc->set, "debug" ) ) + if( set_getbool( &gc->irc->set, "debug" ) ) serv_got_crap( gc, "Creating new conversation: (id=%d,handle=%s)", id, handle ); return( c ); @@ -774,7 +774,7 @@ void add_chat_buddy( struct conversation *b, char *handle ) user_t *u = user_findhandle( b->gc, handle ); int me = 0; - if( set_getint( &b->gc->irc->set, "debug" ) ) + if( set_getbool( &b->gc->irc->set, "debug" ) ) serv_got_crap( b->gc, "User %s added to conversation %d", handle, b->id ); /* It might be yourself! */ @@ -808,7 +808,7 @@ void remove_chat_buddy( struct conversation *b, char *handle, char *reason ) user_t *u; int me = 0; - if( set_getint( &b->gc->irc->set, "debug" ) ) + if( set_getbool( &b->gc->irc->set, "debug" ) ) serv_got_crap( b->gc, "User %s removed from conversation %d (%s)", handle, b->id, reason ? reason : "" ); /* It might be yourself! */ @@ -886,7 +886,7 @@ char *set_eval_away_devoice( set_t *set, char *value ) /* Horror.... */ - if( st != set_getint( &irc->set, "away_devoice" ) ) + if( st != set_getbool( &irc->set, "away_devoice" ) ) { char list[80] = ""; user_t *u = irc->users; @@ -1006,7 +1006,7 @@ int bim_set_away( struct gaim_connection *gc, char *away ) if( s ) { gc->acc->prpl->set_away( gc, s, away ); - if( set_getint( &gc->irc->set, "debug" ) ) + if( set_getbool( &gc->irc->set, "debug" ) ) serv_got_crap( gc, "Setting away state to %s", s ); } else -- cgit v1.2.3 From 8d7429102adf8dce6844f2f3da2723d1f87c6442 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 22 Sep 2006 18:56:58 +0200 Subject: Fixed return value on incomplete write()s in write handler, protection against write()ing to sockets that are closed already, hopefully sane detection for SASL support, and only sending type=unavailable presence tag to logged in sessions. --- protocols/nogaim.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 47e2bda6..ec87ccd5 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -279,6 +279,11 @@ void signoff( struct gaim_connection *gc ) user_t *t, *u = irc->users; account_t *a; + /* Nested calls might happen sometimes, this is probably the best + place to catch them. */ + if( gc->flags & OPT_LOGGING_OUT ) + return; + serv_got_crap( gc, "Signing off.." ); b_event_remove( gc->keepalive ); -- cgit v1.2.3 From 5e202b09f2cd9faff5f316ae6804facb5342eace Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 23 Sep 2006 18:18:24 +0200 Subject: Implemented a list of away states, using this for a better set_away(), and got rid of the double tag sent because of presence_announce(). --- protocols/nogaim.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index ec87ccd5..36461b32 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -1018,8 +1018,6 @@ int bim_set_away( struct gaim_connection *gc, char *away ) gc->acc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); } - g_list_free( ms ); - return( 1 ); } -- cgit v1.2.3 From 66f783fa6365fefe7ba449e6409b4dc1359b155b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 21 Oct 2006 23:40:06 +0200 Subject: Complete fix (or mostly a work-around) for nested calls to signoff(). (Can happen when the IRC connection to the user is broken, a write() to it eventually fails, which triggers an irc_kill() which, in turn, will call signoff() for all accounts.) --- protocols/nogaim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 36461b32..3e9d7c07 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -283,12 +283,12 @@ void signoff( struct gaim_connection *gc ) place to catch them. */ if( gc->flags & OPT_LOGGING_OUT ) return; + else + gc->flags |= OPT_LOGGING_OUT; serv_got_crap( gc, "Signing off.." ); b_event_remove( gc->keepalive ); - gc->flags |= OPT_LOGGING_OUT; - gc->keepalive = 0; gc->acc->prpl->close( gc ); b_event_remove( gc->inpa ); -- cgit v1.2.3 From 208715962fcd1b806d42ef7edb47503eb296895b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 22 Oct 2006 11:24:55 +0200 Subject: Away devoices are done by the server instead of by root now. This makes more sense with the "netsplit feature". (Because of less noisy joins.) --- protocols/nogaim.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 47e2bda6..0270d5a0 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -572,7 +572,7 @@ void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, in ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ { - irc_write( gc->irc, ":%s!%s@%s MODE %s %cv %s", gc->irc->mynick, gc->irc->mynick, gc->irc->myhost, + irc_write( gc->irc, ":%s MODE %s %cv %s", gc->irc->myhost, gc->irc->channel, u->away?'-':'+', u->nick ); } } @@ -906,8 +906,8 @@ char *set_eval_away_devoice( set_t *set, char *value ) if( ( strlen( list ) + strlen( u->nick ) ) >= 79 ) { for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0; - irc_write( irc, ":%s!%s@%s MODE %s %c%s%s", - irc->mynick, irc->mynick, irc->myhost, + irc_write( irc, ":%s MODE %s %c%s%s", + irc->myhost, irc->channel, pm, v, list ); *list = 0; @@ -922,7 +922,7 @@ char *set_eval_away_devoice( set_t *set, char *value ) /* $v = 'v' x $i */ for( i = 0; i < count; v[i++] = 'v' ); v[i] = 0; - irc_write( irc, ":%s!%s@%s MODE %s %c%s%s", irc->mynick, irc->mynick, irc->myhost, + irc_write( irc, ":%s MODE %s %c%s%s", irc->myhost, irc->channel, pm, v, list ); } -- cgit v1.2.3 From fa29d09342c79b886efacee4cfc3078be5f5a722 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 27 Mar 2007 22:53:11 -0700 Subject: Preparing for Jabber conference room support. --- protocols/nogaim.c | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index b627a23a..e983352f 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -681,15 +681,14 @@ void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int } } -void serv_got_chat_left( struct gaim_connection *gc, int id ) +void serv_got_chat_left( struct conversation *c ) { - struct conversation *c, *l = NULL; + struct gaim_connection *gc = c->gc; + struct conversation *l = NULL; GList *ir; if( set_getbool( &gc->irc->set, "debug" ) ) - serv_got_crap( gc, "You were removed from conversation %d", (int) id ); - - for( c = gc->conversations; c && c->id != id; c = (l=c)->next ); + serv_got_crap( gc, "You were removed from conversation 0x%x", (int) c ); if( c ) { @@ -719,9 +718,9 @@ void serv_got_chat_left( struct gaim_connection *gc, int id ) } } -void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t mtime ) +void serv_got_chat_in( struct conversation *c, char *who, int whisper, char *msg, time_t mtime ) { - struct conversation *c; + struct gaim_connection *gc = c->gc; user_t *u; /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ @@ -729,7 +728,6 @@ void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whispe return; u = user_findhandle( gc, who ); - for( c = gc->conversations; c && c->id != id; c = c->next ); if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) || ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) ) @@ -738,13 +736,12 @@ void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whispe if( c && u ) irc_privmsg( gc->irc, u, "PRIVMSG", c->channel, "", msg ); else - serv_got_crap( gc, "Message from/to conversation %s@%d (unknown conv/user): %s", who, id, msg ); + serv_got_crap( gc, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg ); } -struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, char *handle ) +struct conversation *serv_got_joined_chat( struct gaim_connection *gc, char *handle ) { struct conversation *c; - char *s; /* This one just creates the conversation structure, user won't see anything yet */ @@ -754,21 +751,16 @@ struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, c c = c->next = g_new0( struct conversation, 1 ); } else - gc->conversations = c = g_new0( struct conversation, 1); + gc->conversations = c = g_new0( struct conversation, 1 ); - c->id = id; c->gc = gc; c->title = g_strdup( handle ); - - s = g_new( char, 16 ); - sprintf( s, "&chat_%03d", gc->irc->c_id++ ); - c->channel = g_strdup( s ); - g_free( s ); + c->channel = g_strdup_printf( "&chat_%03d", gc->irc->c_id++ ); if( set_getbool( &gc->irc->set, "debug" ) ) - serv_got_crap( gc, "Creating new conversation: (id=%d,handle=%s)", id, handle ); + serv_got_crap( gc, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle ); - return( c ); + return c; } @@ -780,7 +772,7 @@ void add_chat_buddy( struct conversation *b, char *handle ) int me = 0; if( set_getbool( &b->gc->irc->set, "debug" ) ) - serv_got_crap( b->gc, "User %s added to conversation %d", handle, b->id ); + serv_got_crap( b->gc, "User %s added to conversation 0x%x", handle, (int) b ); /* It might be yourself! */ if( b->gc->acc->prpl->handle_cmp( handle, b->gc->username ) == 0 ) @@ -814,7 +806,7 @@ void remove_chat_buddy( struct conversation *b, char *handle, char *reason ) int me = 0; if( set_getbool( &b->gc->irc->set, "debug" ) ) - serv_got_crap( b->gc, "User %s removed from conversation %d (%s)", handle, b->id, reason ? reason : "" ); + serv_got_crap( b->gc, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" ); /* It might be yourself! */ if( g_strcasecmp( handle, b->gc->username ) == 0 ) @@ -857,7 +849,7 @@ static int remove_chat_buddy_silent( struct conversation *b, char *handle ) /* Misc. BitlBee stuff which shouldn't really be here */ -struct conversation *conv_findchannel( char *channel ) +struct conversation *chat_by_channel( char *channel ) { struct gaim_connection *gc; struct conversation *c; @@ -869,10 +861,10 @@ struct conversation *conv_findchannel( char *channel ) gc = l->data; for( c = gc->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next ); if( c ) - return( c ); + return c; } - return( NULL ); + return NULL; } char *set_eval_away_devoice( set_t *set, char *value ) @@ -957,18 +949,18 @@ int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flag return st; } -int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ) +int bim_chat_msg( struct conversation *c, char *msg ) { char *buf = NULL; int st; - if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "", 6 ) != 0 ) ) + if( ( c->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "", 6 ) != 0 ) ) { buf = escape_html( msg ); msg = buf; } - st = gc->acc->prpl->chat_send( gc, id, msg ); + st = c->gc->acc->prpl->chat_send( c, msg ); g_free( buf ); return st; -- cgit v1.2.3 From 0da65d5fb37691ed4d31f7ab4058732f1440db6b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 30 Mar 2007 22:40:45 -0700 Subject: s/gaim_connection/im_connection/ and some other minor API changes. The rest will come tomorrow. It compiles, I'll leave the real testing up to someone else. ;-) --- protocols/nogaim.c | 428 ++++++++++++++++++++++++++--------------------------- 1 file changed, 214 insertions(+), 214 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index e983352f..987c08f2 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -35,7 +35,7 @@ #include "nogaim.h" #include -static int remove_chat_buddy_silent( struct conversation *b, char *handle ); +static int remove_chat_buddy_silent( struct groupchat *b, char *handle ); GSList *connections; @@ -114,25 +114,25 @@ struct prpl *find_protocol(const char *name) /* nogaim.c */ void nogaim_init() { - extern void msn_init(); - extern void oscar_init(); - extern void byahoo_init(); - extern void jabber_init(); + extern void msn_initmodule(); + extern void oscar_initmodule(); + extern void byahoo_initmodule(); + extern void jabber_initmodule(); #ifdef WITH_MSN - msn_init(); + msn_initmodule(); #endif #ifdef WITH_OSCAR - oscar_init(); + oscar_initmodule(); #endif #ifdef WITH_YAHOO - byahoo_init(); + byahoo_initmodule(); #endif #ifdef WITH_JABBER - jabber_init(); + jabber_initmodule(); #endif #ifdef WITH_PLUGINS @@ -144,59 +144,59 @@ GSList *get_connections() { return connections; } /* multi.c */ -struct gaim_connection *new_gaim_conn( account_t *acc ) +struct im_connection *new_gaim_conn( account_t *acc ) { - struct gaim_connection *gc; + struct im_connection *ic; - gc = g_new0( struct gaim_connection, 1 ); + ic = g_new0( struct im_connection, 1 ); /* Maybe we should get rid of this memory waste later. ;-) */ - g_snprintf( gc->username, sizeof( gc->username ), "%s", acc->user ); - g_snprintf( gc->password, sizeof( gc->password ), "%s", acc->pass ); + g_snprintf( ic->username, sizeof( ic->username ), "%s", acc->user ); + g_snprintf( ic->password, sizeof( ic->password ), "%s", acc->pass ); - gc->irc = acc->irc; - gc->acc = acc; - acc->gc = gc; + ic->irc = acc->irc; + ic->acc = acc; + acc->ic = ic; - connections = g_slist_append( connections, gc ); + connections = g_slist_append( connections, ic ); - return( gc ); + return( ic ); } -void destroy_gaim_conn( struct gaim_connection *gc ) +void destroy_gaim_conn( struct im_connection *ic ) { account_t *a; /* Destroy the pointer to this connection from the account list */ - for( a = gc->irc->accounts; a; a = a->next ) - if( a->gc == gc ) + for( a = ic->irc->accounts; a; a = a->next ) + if( a->ic == ic ) { - a->gc = NULL; + a->ic = NULL; break; } - connections = g_slist_remove( connections, gc ); - g_free( gc ); + connections = g_slist_remove( connections, ic ); + g_free( ic ); } -void set_login_progress( struct gaim_connection *gc, int step, char *msg ) +void set_login_progress( struct im_connection *ic, int step, char *msg ) { - serv_got_crap( gc, "Logging in: %s", msg ); + serv_got_crap( ic, "Logging in: %s", msg ); } /* Errors *while* logging in */ -void hide_login_progress( struct gaim_connection *gc, char *msg ) +void hide_login_progress( struct im_connection *ic, char *msg ) { - serv_got_crap( gc, "Login error: %s", msg ); + serv_got_crap( ic, "Login error: %s", msg ); } /* Errors *after* logging in */ -void hide_login_progress_error( struct gaim_connection *gc, char *msg ) +void hide_login_progress_error( struct im_connection *ic, char *msg ) { - serv_got_crap( gc, "Logged out: %s", msg ); + serv_got_crap( ic, "Logged out: %s", msg ); } -void serv_got_crap( struct gaim_connection *gc, char *format, ... ) +void serv_got_crap( struct im_connection *ic, char *format, ... ) { va_list params; char *text; @@ -206,54 +206,54 @@ void serv_got_crap( struct gaim_connection *gc, char *format, ... ) text = g_strdup_vprintf( format, params ); va_end( params ); - if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) || - ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) ) + if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || + ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) strip_html( text ); /* Try to find a different connection on the same protocol. */ - for( a = gc->irc->accounts; a; a = a->next ) - if( a->prpl == gc->acc->prpl && a->gc != gc ) + for( a = ic->irc->accounts; a; a = a->next ) + if( a->prpl == ic->acc->prpl && a->ic != ic ) break; /* If we found one, include the screenname in the message. */ if( a ) - irc_usermsg( gc->irc, "%s(%s) - %s", gc->acc->prpl->name, gc->username, text ); + irc_usermsg( ic->irc, "%s(%s) - %s", ic->acc->prpl->name, ic->username, text ); else - irc_usermsg( gc->irc, "%s - %s", gc->acc->prpl->name, text ); + irc_usermsg( ic->irc, "%s - %s", ic->acc->prpl->name, text ); g_free( text ); } static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond ) { - struct gaim_connection *gc = d; + struct im_connection *ic = d; - if( gc->acc->prpl->keepalive ) - gc->acc->prpl->keepalive( gc ); + if( ic->acc->prpl->keepalive ) + ic->acc->prpl->keepalive( ic ); return TRUE; } -void account_online( struct gaim_connection *gc ) +void account_online( struct im_connection *ic ) { user_t *u; /* MSN servers sometimes redirect you to a different server and do the whole login sequence again, so these "late" calls to this function should be handled correctly. (IOW, ignored) */ - if( gc->flags & OPT_LOGGED_IN ) + if( ic->flags & OPT_LOGGED_IN ) return; - u = user_find( gc->irc, gc->irc->nick ); + u = user_find( ic->irc, ic->irc->nick ); - serv_got_crap( gc, "Logged in" ); + serv_got_crap( ic, "Logged in" ); - gc->keepalive = b_timeout_add( 60000, send_keepalive, gc ); - gc->flags |= OPT_LOGGED_IN; + ic->keepalive = b_timeout_add( 60000, send_keepalive, ic ); + ic->flags |= OPT_LOGGED_IN; /* Also necessary when we're not away, at least for some of the protocols. */ - bim_set_away( gc, u->away ); + bim_set_away( ic, u->away ); } gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ) @@ -273,29 +273,29 @@ void cancel_auto_reconnect( account_t *a ) a->reconnect = 0; } -void signoff( struct gaim_connection *gc ) +void signoff( struct im_connection *ic ) { - irc_t *irc = gc->irc; + irc_t *irc = ic->irc; user_t *t, *u = irc->users; account_t *a; /* Nested calls might happen sometimes, this is probably the best place to catch them. */ - if( gc->flags & OPT_LOGGING_OUT ) + if( ic->flags & OPT_LOGGING_OUT ) return; else - gc->flags |= OPT_LOGGING_OUT; + ic->flags |= OPT_LOGGING_OUT; - serv_got_crap( gc, "Signing off.." ); + serv_got_crap( ic, "Signing off.." ); - b_event_remove( gc->keepalive ); - gc->keepalive = 0; - gc->acc->prpl->close( gc ); - b_event_remove( gc->inpa ); + b_event_remove( ic->keepalive ); + ic->keepalive = 0; + ic->acc->prpl->logout( ic ); + b_event_remove( ic->inpa ); while( u ) { - if( u->gc == gc ) + if( u->ic == ic ) { t = u->next; user_del( irc, u->nick ); @@ -305,65 +305,65 @@ void signoff( struct gaim_connection *gc ) u = u->next; } - query_del_by_gc( gc->irc, gc ); + query_del_by_conn( ic->irc, ic ); for( a = irc->accounts; a; a = a->next ) - if( a->gc == gc ) + if( a->ic == ic ) break; if( !a ) { /* Uhm... This is very sick. */ } - else if( !gc->wants_to_die && set_getbool( &irc->set, "auto_reconnect" ) && + else if( !ic->wants_to_die && set_getbool( &irc->set, "auto_reconnect" ) && set_getbool( &a->set, "auto_reconnect" ) ) { int delay = set_getint( &irc->set, "auto_reconnect_delay" ); - serv_got_crap( gc, "Reconnecting in %d seconds..", delay ); + serv_got_crap( ic, "Reconnecting in %d seconds..", delay ); a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a ); } - destroy_gaim_conn( gc ); + destroy_gaim_conn( ic ); } /* dialogs.c */ -void do_error_dialog( struct gaim_connection *gc, char *msg, char *title ) +void do_error_dialog( struct im_connection *ic, char *msg, char *title ) { if( msg && title ) - serv_got_crap( gc, "Error: %s: %s", title, msg ); + serv_got_crap( ic, "Error: %s: %s", title, msg ); else if( msg ) - serv_got_crap( gc, "Error: %s", msg ); + serv_got_crap( ic, "Error: %s", msg ); else if( title ) - serv_got_crap( gc, "Error: %s", title ); + serv_got_crap( ic, "Error: %s", title ); else - serv_got_crap( gc, "Error" ); + serv_got_crap( ic, "Error" ); } -void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doit, void *dont ) +void do_ask_dialog( struct im_connection *ic, char *msg, void *data, void *doit, void *dont ) { - query_add( gc->irc, gc, msg, doit, dont, data ); + query_add( ic->irc, ic, msg, doit, dont, data ); } /* list.c */ -void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname ) +void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname ) { user_t *u; char nick[MAX_NICK_LENGTH+1]; char *s; - irc_t *irc = gc->irc; + irc_t *irc = ic->irc; if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */ - serv_got_crap( gc, "Receiving user add from handle: %s", handle ); + serv_got_crap( ic, "Receiving user add from handle: %s", handle ); - if( user_findhandle( gc, handle ) ) + if( user_findhandle( ic, handle ) ) { if( set_getbool( &irc->set, "debug" ) ) - serv_got_crap( gc, "User already exists, ignoring add request: %s", handle ); + serv_got_crap( ic, "User already exists, ignoring add request: %s", handle ); return; @@ -371,9 +371,9 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea } memset( nick, 0, MAX_NICK_LENGTH + 1 ); - strcpy( nick, nick_get( gc->acc, handle, realname ) ); + strcpy( nick, nick_get( ic->acc, handle, realname ) ); - u = user_add( gc->irc, nick ); + u = user_add( ic->irc, nick ); if( !realname || !*realname ) realname = nick; u->realname = g_strdup( realname ); @@ -383,15 +383,15 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea u->host = g_strdup( s + 1 ); u->user = g_strndup( handle, s - handle ); } - else if( gc->acc->server ) + else if( ic->acc->server ) { char *colon; - if( ( colon = strchr( gc->acc->server, ':' ) ) ) - u->host = g_strndup( gc->acc->server, - colon - gc->acc->server ); + if( ( colon = strchr( ic->acc->server, ':' ) ) ) + u->host = g_strndup( ic->acc->server, + colon - ic->acc->server ); else - u->host = g_strdup( gc->acc->server ); + u->host = g_strdup( ic->acc->server ); u->user = g_strdup( handle ); @@ -402,23 +402,23 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea } else { - u->host = g_strdup( gc->acc->prpl->name ); + u->host = g_strdup( ic->acc->prpl->name ); u->user = g_strdup( handle ); } - u->gc = gc; + u->ic = ic; u->handle = g_strdup( handle ); if( group ) u->group = g_strdup( group ); u->send_handler = buddy_send_handler; u->last_typing_notice = 0; } -struct buddy *find_buddy( struct gaim_connection *gc, char *handle ) +struct buddy *find_buddy( struct im_connection *ic, char *handle ) { static struct buddy b[1]; user_t *u; - u = user_findhandle( gc, handle ); + u = user_findhandle( ic, handle ); if( !u ) return( NULL ); @@ -427,20 +427,20 @@ struct buddy *find_buddy( struct gaim_connection *gc, char *handle ) strncpy( b->name, handle, 80 ); strncpy( b->show, u->realname, BUDDY_ALIAS_MAXLEN ); b->present = u->online; - b->gc = u->gc; + b->ic = u->ic; return( b ); } -void signoff_blocked( struct gaim_connection *gc ) +void signoff_blocked( struct im_connection *ic ) { return; /* Make all blocked users look invisible (TODO?) */ } -void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname ) +void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname ) { - user_t *u = user_findhandle( gc, handle ); + user_t *u = user_findhandle( ic, handle ); if( !u ) return; @@ -450,8 +450,8 @@ void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname u->realname = g_strdup( realname ); - if( ( gc->flags & OPT_LOGGED_IN ) && set_getbool( &gc->irc->set, "display_namechanges" ) ) - serv_got_crap( gc, "User `%s' changed name to `%s'", u->nick, u->realname ); + if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) ) + serv_got_crap( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); } } @@ -460,7 +460,7 @@ void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname struct show_got_added_data { - struct gaim_connection *gc; + struct im_connection *ic; char *handle; }; @@ -472,51 +472,51 @@ void show_got_added_no( gpointer w, struct show_got_added_data *data ) void show_got_added_yes( gpointer w, struct show_got_added_data *data ) { - data->gc->acc->prpl->add_buddy( data->gc, data->handle ); - add_buddy( data->gc, NULL, data->handle, data->handle ); + data->ic->acc->prpl->add_buddy( data->ic, data->handle, NULL ); + add_buddy( data->ic, NULL, data->handle, data->handle ); return show_got_added_no( w, data ); } -void show_got_added( struct gaim_connection *gc, char *handle, const char *realname ) +void show_got_added( struct im_connection *ic, char *handle, const char *realname ) { struct show_got_added_data *data = g_new0( struct show_got_added_data, 1 ); char *s; /* TODO: Make a setting for this! */ - if( user_findhandle( gc, handle ) != NULL ) + if( user_findhandle( ic, handle ) != NULL ) return; s = g_strdup_printf( "The user %s is not in your buddy list yet. Do you want to add him/her now?", handle ); - data->gc = gc; + data->ic = ic; data->handle = g_strdup( handle ); - query_add( gc->irc, gc, s, show_got_added_yes, show_got_added_no, data ); + query_add( ic->irc, ic, s, show_got_added_yes, show_got_added_no, data ); } /* server.c */ -void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps ) +void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps ) { user_t *u; int oa, oo; - u = user_findhandle( gc, handle ); + u = user_findhandle( ic, handle ); if( !u ) { - if( g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "add" ) == 0 ) + if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 ) { - add_buddy( gc, NULL, handle, NULL ); - u = user_findhandle( gc, handle ); + add_buddy( ic, NULL, handle, NULL ); + u = user_findhandle( ic, handle ); } else { - if( set_getbool( &gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 ) + if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 ) { - serv_got_crap( gc, "serv_got_update() for handle %s:", handle ); - serv_got_crap( gc, "loggedin = %d, type = %d", loggedin, type ); + serv_got_crap( ic, "serv_got_update() for handle %s:", handle ); + serv_got_crap( ic, "loggedin = %d, type = %d", loggedin, type ); } return; @@ -536,26 +536,26 @@ void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, in if( loggedin && !u->online ) { - irc_spawn( gc->irc, u ); + irc_spawn( ic->irc, u ); u->online = 1; } else if( !loggedin && u->online ) { - struct conversation *c; + struct groupchat *c; - irc_kill( gc->irc, u ); + irc_kill( ic->irc, u ); u->online = 0; /* Remove him/her from the conversations to prevent PART messages after he/she QUIT already */ - for( c = gc->conversations; c; c = c->next ) + for( c = ic->conversations; c; c = c->next ) remove_chat_buddy_silent( c, handle ); } - if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "oscar" ) == 0 || strcmp( gc->acc->prpl->name, "icq" ) == 0 ) ) + if( ( type & UC_UNAVAILABLE ) && ( strcmp( ic->acc->prpl->name, "oscar" ) == 0 || strcmp( ic->acc->prpl->name, "icq" ) == 0 ) ) { u->away = g_strdup( "Away" ); } - else if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "jabber" ) == 0 ) ) + else if( ( type & UC_UNAVAILABLE ) && ( strcmp( ic->acc->prpl->name, "jabber" ) == 0 ) ) { if( type & UC_DND ) u->away = g_strdup( "Do Not Disturb" ); @@ -564,30 +564,30 @@ void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, in else // if( type & UC_AWAY ) u->away = g_strdup( "Away" ); } - else if( ( type & UC_UNAVAILABLE ) && gc->acc->prpl->get_status_string ) + else if( ( type & UC_UNAVAILABLE ) && ic->acc->prpl->get_status_string ) { - u->away = g_strdup( gc->acc->prpl->get_status_string( gc, type ) ); + u->away = g_strdup( ic->acc->prpl->get_status_string( ic, type ) ); } else u->away = NULL; /* LISPy... */ - if( ( set_getbool( &gc->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ + if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ ( u->online ) && /* Don't touch offline people */ ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ { - irc_write( gc->irc, ":%s MODE %s %cv %s", gc->irc->myhost, - gc->irc->channel, u->away?'-':'+', u->nick ); + irc_write( ic->irc, ":%s MODE %s %cv %s", ic->irc->myhost, + ic->irc->channel, u->away?'-':'+', u->nick ); } } -void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len ) +void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len ) { - irc_t *irc = gc->irc; + irc_t *irc = ic->irc; user_t *u; - u = user_findhandle( gc, handle ); + u = user_findhandle( ic, handle ); if( !u ) { @@ -596,7 +596,7 @@ void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 f if( g_strcasecmp( h, "ignore" ) == 0 ) { if( set_getbool( &irc->set, "debug" ) ) - serv_got_crap( gc, "Ignoring message from unknown handle %s", handle ); + serv_got_crap( ic, "Ignoring message from unknown handle %s", handle ); return; } @@ -612,19 +612,19 @@ void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 f private = 0; } - add_buddy( gc, NULL, handle, NULL ); - u = user_findhandle( gc, handle ); + add_buddy( ic, NULL, handle, NULL ); + u = user_findhandle( ic, handle ); u->is_private = private; } else { - serv_got_crap( gc, "Message from unknown handle %s:", handle ); + serv_got_crap( ic, "Message from unknown handle %s:", handle ); u = user_find( irc, irc->mynick ); } } - if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) || - ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) ) + if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || + ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) strip_html( msg ); while( strlen( msg ) > 425 ) @@ -660,14 +660,14 @@ void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 f irc_msgfrom( irc, u->nick, msg ); } -void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type ) +void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type ) { user_t *u; - if( !set_getbool( &gc->irc->set, "typing_notice" ) ) + if( !set_getbool( &ic->irc->set, "typing_notice" ) ) return; - if( ( u = user_findhandle( gc, handle ) ) ) { + if( ( u = user_findhandle( ic, handle ) ) ) { /* If type is: * 0: user has stopped typing * 1: user is actively typing @@ -676,19 +676,19 @@ void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int if (type == 0 || type == 1 || type == 2) { char buf[256]; g_snprintf(buf, 256, "\1TYPING %d\1", type); - irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, buf ); + irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf ); } } } -void serv_got_chat_left( struct conversation *c ) +void serv_got_chat_left( struct groupchat *c ) { - struct gaim_connection *gc = c->gc; - struct conversation *l = NULL; + struct im_connection *ic = c->ic; + struct groupchat *l = NULL; GList *ir; - if( set_getbool( &gc->irc->set, "debug" ) ) - serv_got_crap( gc, "You were removed from conversation 0x%x", (int) c ); + if( set_getbool( &ic->irc->set, "debug" ) ) + serv_got_crap( ic, "You were removed from conversation 0x%x", (int) c ); if( c ) { @@ -696,18 +696,18 @@ void serv_got_chat_left( struct conversation *c ) { user_t *u, *r; - r = user_find( gc->irc, gc->irc->mynick ); - irc_privmsg( gc->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" ); + r = user_find( ic->irc, ic->irc->mynick ); + irc_privmsg( ic->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" ); - u = user_find( gc->irc, gc->irc->nick ); - irc_kick( gc->irc, u, c->channel, r ); - /* irc_part( gc->irc, u, c->channel ); */ + u = user_find( ic->irc, ic->irc->nick ); + irc_kick( ic->irc, u, c->channel, r ); + /* irc_part( ic->irc, u, c->channel ); */ } if( l ) l->next = c->next; else - gc->conversations = c->next; + ic->conversations = c->next; for( ir = c->in_room; ir; ir = ir->next ) g_free( ir->data ); @@ -718,47 +718,47 @@ void serv_got_chat_left( struct conversation *c ) } } -void serv_got_chat_in( struct conversation *c, char *who, int whisper, char *msg, time_t mtime ) +void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, time_t mtime ) { - struct gaim_connection *gc = c->gc; + struct im_connection *ic = c->ic; user_t *u; /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ - if( g_strcasecmp( who, gc->username ) == 0 ) + if( g_strcasecmp( who, ic->username ) == 0 ) return; - u = user_findhandle( gc, who ); + u = user_findhandle( ic, who ); - if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) || - ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) ) + if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || + ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) strip_html( msg ); if( c && u ) - irc_privmsg( gc->irc, u, "PRIVMSG", c->channel, "", msg ); + irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", msg ); else - serv_got_crap( gc, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg ); + serv_got_crap( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg ); } -struct conversation *serv_got_joined_chat( struct gaim_connection *gc, char *handle ) +struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle ) { - struct conversation *c; + struct groupchat *c; /* This one just creates the conversation structure, user won't see anything yet */ - if( gc->conversations ) + if( ic->conversations ) { - for( c = gc->conversations; c->next; c = c->next ); - c = c->next = g_new0( struct conversation, 1 ); + for( c = ic->conversations; c->next; c = c->next ); + c = c->next = g_new0( struct groupchat, 1 ); } else - gc->conversations = c = g_new0( struct conversation, 1 ); + ic->conversations = c = g_new0( struct groupchat, 1 ); - c->gc = gc; + c->ic = ic; c->title = g_strdup( handle ); - c->channel = g_strdup_printf( "&chat_%03d", gc->irc->c_id++ ); + c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ ); - if( set_getbool( &gc->irc->set, "debug" ) ) - serv_got_crap( gc, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle ); + if( set_getbool( &ic->irc->set, "debug" ) ) + serv_got_crap( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle ); return c; } @@ -766,20 +766,20 @@ struct conversation *serv_got_joined_chat( struct gaim_connection *gc, char *han /* buddy_chat.c */ -void add_chat_buddy( struct conversation *b, char *handle ) +void add_chat_buddy( struct groupchat *b, char *handle ) { - user_t *u = user_findhandle( b->gc, handle ); + user_t *u = user_findhandle( b->ic, handle ); int me = 0; - if( set_getbool( &b->gc->irc->set, "debug" ) ) - serv_got_crap( b->gc, "User %s added to conversation 0x%x", handle, (int) b ); + if( set_getbool( &b->ic->irc->set, "debug" ) ) + serv_got_crap( b->ic, "User %s added to conversation 0x%x", handle, (int) b ); /* It might be yourself! */ - if( b->gc->acc->prpl->handle_cmp( handle, b->gc->username ) == 0 ) + if( b->ic->acc->prpl->handle_cmp( handle, b->ic->username ) == 0 ) { - u = user_find( b->gc->irc, b->gc->irc->nick ); + u = user_find( b->ic->irc, b->ic->irc->nick ); if( !b->joined ) - irc_join( b->gc->irc, u, b->channel ); + irc_join( b->ic->irc, u, b->channel ); b->joined = me = 1; } @@ -787,45 +787,45 @@ void add_chat_buddy( struct conversation *b, char *handle ) your contact list. Try to handle that here */ if( !u ) { - add_buddy( b->gc, NULL, handle, NULL ); - u = user_findhandle( b->gc, handle ); + add_buddy( b->ic, NULL, handle, NULL ); + u = user_findhandle( b->ic, handle ); } /* Add the handle to the room userlist, if it's not 'me' */ if( !me ) { if( b->joined ) - irc_join( b->gc->irc, u, b->channel ); + irc_join( b->ic->irc, u, b->channel ); b->in_room = g_list_append( b->in_room, g_strdup( handle ) ); } } -void remove_chat_buddy( struct conversation *b, char *handle, char *reason ) +void remove_chat_buddy( struct groupchat *b, char *handle, char *reason ) { user_t *u; int me = 0; - if( set_getbool( &b->gc->irc->set, "debug" ) ) - serv_got_crap( b->gc, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" ); + if( set_getbool( &b->ic->irc->set, "debug" ) ) + serv_got_crap( b->ic, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" ); /* It might be yourself! */ - if( g_strcasecmp( handle, b->gc->username ) == 0 ) + if( g_strcasecmp( handle, b->ic->username ) == 0 ) { - u = user_find( b->gc->irc, b->gc->irc->nick ); + u = user_find( b->ic->irc, b->ic->irc->nick ); b->joined = 0; me = 1; } else { - u = user_findhandle( b->gc, handle ); + u = user_findhandle( b->ic, handle ); } if( remove_chat_buddy_silent( b, handle ) ) if( ( b->joined || me ) && u ) - irc_part( b->gc->irc, u, b->channel ); + irc_part( b->ic->irc, u, b->channel ); } -static int remove_chat_buddy_silent( struct conversation *b, char *handle ) +static int remove_chat_buddy_silent( struct groupchat *b, char *handle ) { GList *i; @@ -849,17 +849,17 @@ static int remove_chat_buddy_silent( struct conversation *b, char *handle ) /* Misc. BitlBee stuff which shouldn't really be here */ -struct conversation *chat_by_channel( char *channel ) +struct groupchat *chat_by_channel( char *channel ) { - struct gaim_connection *gc; - struct conversation *c; + struct im_connection *ic; + struct groupchat *c; GSList *l; /* This finds the connection which has a conversation which belongs to this channel */ for( l = connections; l; l = l->next ) { - gc = l->data; - for( c = gc->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next ); + ic = l->data; + for( c = ic->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next ); if( c ) return c; } @@ -898,7 +898,7 @@ char *set_eval_away_devoice( set_t *set, char *value ) while( u ) { - if( u->gc && u->online && !u->away ) + if( u->ic && u->online && !u->away ) { if( ( strlen( list ) + strlen( u->nick ) ) >= 79 ) { @@ -932,49 +932,49 @@ char *set_eval_away_devoice( set_t *set, char *value ) /* The plan is to not allow straight calls to prpl functions anymore, but do them all from some wrappers. We'll start to define some down here: */ -int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags ) +int bim_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags ) { char *buf = NULL; int st; - if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "", 6 ) != 0 ) ) + if( ( ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "", 6 ) != 0 ) ) { buf = escape_html( msg ); msg = buf; } - st = gc->acc->prpl->send_im( gc, handle, msg, strlen( msg ), flags ); + st = ic->acc->prpl->send_im( ic, handle, msg, flags ); g_free( buf ); return st; } -int bim_chat_msg( struct conversation *c, char *msg ) +int bim_chat_msg( struct groupchat *c, char *msg, int flags ) { char *buf = NULL; int st; - if( ( c->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "", 6 ) != 0 ) ) + if( ( c->ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "", 6 ) != 0 ) ) { buf = escape_html( msg ); msg = buf; } - st = c->gc->acc->prpl->chat_send( c, msg ); + c->ic->acc->prpl->chat_send( c, msg, flags ); g_free( buf ); - return st; + return 1; } static char *bim_away_alias_find( GList *gcm, char *away ); -int bim_set_away( struct gaim_connection *gc, char *away ) +int bim_set_away( struct im_connection *ic, char *away ) { GList *m, *ms; char *s; if( !away ) away = ""; - ms = m = gc->acc->prpl->away_states( gc ); + ms = m = ic->acc->prpl->away_states( ic ); while( m ) { @@ -995,19 +995,19 @@ int bim_set_away( struct gaim_connection *gc, char *away ) if( m ) { - gc->acc->prpl->set_away( gc, m->data, *away ? away : NULL ); + ic->acc->prpl->set_away( ic, m->data, *away ? away : NULL ); } else { s = bim_away_alias_find( ms, away ); if( s ) { - gc->acc->prpl->set_away( gc, s, away ); - if( set_getbool( &gc->irc->set, "debug" ) ) - serv_got_crap( gc, "Setting away state to %s", s ); + ic->acc->prpl->set_away( ic, s, away ); + if( set_getbool( &ic->irc->set, "debug" ) ) + serv_got_crap( ic, "Setting away state to %s", s ); } else - gc->acc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); + ic->acc->prpl->set_away( ic, GAIM_AWAY_CUSTOM, away ); } return( 1 ); @@ -1055,48 +1055,48 @@ static char *bim_away_alias_find( GList *gcm, char *away ) return( NULL ); } -void bim_add_allow( struct gaim_connection *gc, char *handle ) +void bim_add_allow( struct im_connection *ic, char *handle ) { - if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) == NULL ) + if( g_slist_find_custom( ic->permit, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) == NULL ) { - gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) ); + ic->permit = g_slist_prepend( ic->permit, g_strdup( handle ) ); } - gc->acc->prpl->add_permit( gc, handle ); + ic->acc->prpl->add_permit( ic, handle ); } -void bim_rem_allow( struct gaim_connection *gc, char *handle ) +void bim_rem_allow( struct im_connection *ic, char *handle ) { GSList *l; - if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) ) + if( ( l = g_slist_find_custom( ic->permit, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) ) ) { g_free( l->data ); - gc->permit = g_slist_delete_link( gc->permit, l ); + ic->permit = g_slist_delete_link( ic->permit, l ); } - gc->acc->prpl->rem_permit( gc, handle ); + ic->acc->prpl->rem_permit( ic, handle ); } -void bim_add_block( struct gaim_connection *gc, char *handle ) +void bim_add_block( struct im_connection *ic, char *handle ) { - if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) == NULL ) + if( g_slist_find_custom( ic->deny, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) == NULL ) { - gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) ); + ic->deny = g_slist_prepend( ic->deny, g_strdup( handle ) ); } - gc->acc->prpl->add_deny( gc, handle ); + ic->acc->prpl->add_deny( ic, handle ); } -void bim_rem_block( struct gaim_connection *gc, char *handle ) +void bim_rem_block( struct im_connection *ic, char *handle ) { GSList *l; - if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) ) + if( ( l = g_slist_find_custom( ic->deny, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) ) ) { g_free( l->data ); - gc->deny = g_slist_delete_link( gc->deny, l ); + ic->deny = g_slist_delete_link( ic->deny, l ); } - gc->acc->prpl->rem_deny( gc, handle ); + ic->acc->prpl->rem_deny( ic, handle ); } -- cgit v1.2.3 From aef4828a1dc51de10a43bb7dd5d023de9971295b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 5 Apr 2007 22:20:31 -0700 Subject: More cleanups, mainly in the callbacks. Replaced things like do_error_dialog() and (set|hide)_login_progress(_error)?() with things that hopefully make more sense. Although it's still not really great... --- protocols/nogaim.c | 107 ++++++++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 51 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 987c08f2..0c042bac 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -144,7 +144,7 @@ GSList *get_connections() { return connections; } /* multi.c */ -struct im_connection *new_gaim_conn( account_t *acc ) +struct im_connection *imc_new( account_t *acc ) { struct im_connection *ic; @@ -163,7 +163,7 @@ struct im_connection *new_gaim_conn( account_t *acc ) return( ic ); } -void destroy_gaim_conn( struct im_connection *ic ) +void imc_free( struct im_connection *ic ) { account_t *a; @@ -179,24 +179,7 @@ void destroy_gaim_conn( struct im_connection *ic ) g_free( ic ); } -void set_login_progress( struct im_connection *ic, int step, char *msg ) -{ - serv_got_crap( ic, "Logging in: %s", msg ); -} - -/* Errors *while* logging in */ -void hide_login_progress( struct im_connection *ic, char *msg ) -{ - serv_got_crap( ic, "Login error: %s", msg ); -} - -/* Errors *after* logging in */ -void hide_login_progress_error( struct im_connection *ic, char *msg ) -{ - serv_got_crap( ic, "Logged out: %s", msg ); -} - -void serv_got_crap( struct im_connection *ic, char *format, ... ) +static void serv_got_crap( struct im_connection *ic, char *format, ... ) { va_list params; char *text; @@ -224,6 +207,40 @@ void serv_got_crap( struct im_connection *ic, char *format, ... ) g_free( text ); } +void imc_log( struct im_connection *ic, char *format, ... ) +{ + va_list params; + char *text; + + va_start( params, format ); + text = g_strdup_vprintf( format, params ); + va_end( params ); + + if( ic->flags & OPT_LOGGED_IN ) + serv_got_crap( ic, "%s", text ); + else + serv_got_crap( ic, "Logging in: %s", text ); + + g_free( text ); +} + +void imc_error( struct im_connection *ic, char *format, ... ) +{ + va_list params; + char *text; + + va_start( params, format ); + text = g_strdup_vprintf( format, params ); + va_end( params ); + + if( ic->flags & OPT_LOGGED_IN ) + serv_got_crap( ic, "Error: %s", text ); + else + serv_got_crap( ic, "Couldn't log in: %s", text ); + + g_free( text ); +} + static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond ) { struct im_connection *ic = d; @@ -234,7 +251,7 @@ static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond ) return TRUE; } -void account_online( struct im_connection *ic ) +void imc_connected( struct im_connection *ic ) { user_t *u; @@ -246,7 +263,7 @@ void account_online( struct im_connection *ic ) u = user_find( ic->irc, ic->irc->nick ); - serv_got_crap( ic, "Logged in" ); + imc_log( ic, "Logged in" ); ic->keepalive = b_timeout_add( 60000, send_keepalive, ic ); ic->flags |= OPT_LOGGED_IN; @@ -273,7 +290,7 @@ void cancel_auto_reconnect( account_t *a ) a->reconnect = 0; } -void signoff( struct im_connection *ic ) +void imc_logout( struct im_connection *ic ) { irc_t *irc = ic->irc; user_t *t, *u = irc->users; @@ -286,7 +303,7 @@ void signoff( struct im_connection *ic ) else ic->flags |= OPT_LOGGING_OUT; - serv_got_crap( ic, "Signing off.." ); + imc_log( ic, "Signing off.." ); b_event_remove( ic->keepalive ); ic->keepalive = 0; @@ -320,28 +337,16 @@ void signoff( struct im_connection *ic ) { int delay = set_getint( &irc->set, "auto_reconnect_delay" ); - serv_got_crap( ic, "Reconnecting in %d seconds..", delay ); + imc_log( ic, "Reconnecting in %d seconds..", delay ); a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a ); } - destroy_gaim_conn( ic ); + imc_free( ic ); } /* dialogs.c */ -void do_error_dialog( struct im_connection *ic, char *msg, char *title ) -{ - if( msg && title ) - serv_got_crap( ic, "Error: %s: %s", title, msg ); - else if( msg ) - serv_got_crap( ic, "Error: %s", msg ); - else if( title ) - serv_got_crap( ic, "Error: %s", title ); - else - serv_got_crap( ic, "Error" ); -} - void do_ask_dialog( struct im_connection *ic, char *msg, void *data, void *doit, void *dont ) { query_add( ic->irc, ic, msg, doit, dont, data ); @@ -358,12 +363,12 @@ void add_buddy( struct im_connection *ic, char *group, char *handle, char *realn irc_t *irc = ic->irc; if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */ - serv_got_crap( ic, "Receiving user add from handle: %s", handle ); + imc_log( ic, "Receiving user add from handle: %s", handle ); if( user_findhandle( ic, handle ) ) { if( set_getbool( &irc->set, "debug" ) ) - serv_got_crap( ic, "User already exists, ignoring add request: %s", handle ); + imc_log( ic, "User already exists, ignoring add request: %s", handle ); return; @@ -451,7 +456,7 @@ void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname ) u->realname = g_strdup( realname ); if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) ) - serv_got_crap( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); + imc_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); } } @@ -515,8 +520,8 @@ void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int { if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 ) { - serv_got_crap( ic, "serv_got_update() for handle %s:", handle ); - serv_got_crap( ic, "loggedin = %d, type = %d", loggedin, type ); + imc_log( ic, "serv_got_update() for handle %s:", handle ); + imc_log( ic, "loggedin = %d, type = %d", loggedin, type ); } return; @@ -596,7 +601,7 @@ void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 fla if( g_strcasecmp( h, "ignore" ) == 0 ) { if( set_getbool( &irc->set, "debug" ) ) - serv_got_crap( ic, "Ignoring message from unknown handle %s", handle ); + imc_log( ic, "Ignoring message from unknown handle %s", handle ); return; } @@ -618,7 +623,7 @@ void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 fla } else { - serv_got_crap( ic, "Message from unknown handle %s:", handle ); + imc_log( ic, "Message from unknown handle %s:", handle ); u = user_find( irc, irc->mynick ); } } @@ -688,7 +693,7 @@ void serv_got_chat_left( struct groupchat *c ) GList *ir; if( set_getbool( &ic->irc->set, "debug" ) ) - serv_got_crap( ic, "You were removed from conversation 0x%x", (int) c ); + imc_log( ic, "You were removed from conversation 0x%x", (int) c ); if( c ) { @@ -736,7 +741,7 @@ void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, t if( c && u ) irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", msg ); else - serv_got_crap( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg ); + imc_log( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg ); } struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle ) @@ -758,7 +763,7 @@ struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle ) c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ ); if( set_getbool( &ic->irc->set, "debug" ) ) - serv_got_crap( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle ); + imc_log( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle ); return c; } @@ -772,7 +777,7 @@ void add_chat_buddy( struct groupchat *b, char *handle ) int me = 0; if( set_getbool( &b->ic->irc->set, "debug" ) ) - serv_got_crap( b->ic, "User %s added to conversation 0x%x", handle, (int) b ); + imc_log( b->ic, "User %s added to conversation 0x%x", handle, (int) b ); /* It might be yourself! */ if( b->ic->acc->prpl->handle_cmp( handle, b->ic->username ) == 0 ) @@ -806,7 +811,7 @@ void remove_chat_buddy( struct groupchat *b, char *handle, char *reason ) int me = 0; if( set_getbool( &b->ic->irc->set, "debug" ) ) - serv_got_crap( b->ic, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" ); + imc_log( b->ic, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" ); /* It might be yourself! */ if( g_strcasecmp( handle, b->ic->username ) == 0 ) @@ -1004,7 +1009,7 @@ int bim_set_away( struct im_connection *ic, char *away ) { ic->acc->prpl->set_away( ic, s, away ); if( set_getbool( &ic->irc->set, "debug" ) ) - serv_got_crap( ic, "Setting away state to %s", s ); + imc_log( ic, "Setting away state to %s", s ); } else ic->acc->prpl->set_away( ic, GAIM_AWAY_CUSTOM, away ); -- cgit v1.2.3 From c2fb38096ea4e75a680e57e103d4a4986aa84c75 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Apr 2007 15:39:35 -0700 Subject: Cleaned up struct im_connection. No more username/password stuff since it's in acc too. wants_to_die is now an argument to imc_logout(). --- protocols/nogaim.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 0c042bac..273cc6c8 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -150,10 +150,6 @@ struct im_connection *imc_new( account_t *acc ) ic = g_new0( struct im_connection, 1 ); - /* Maybe we should get rid of this memory waste later. ;-) */ - g_snprintf( ic->username, sizeof( ic->username ), "%s", acc->user ); - g_snprintf( ic->password, sizeof( ic->password ), "%s", acc->pass ); - ic->irc = acc->irc; ic->acc = acc; acc->ic = ic; @@ -200,7 +196,7 @@ static void serv_got_crap( struct im_connection *ic, char *format, ... ) /* If we found one, include the screenname in the message. */ if( a ) - irc_usermsg( ic->irc, "%s(%s) - %s", ic->acc->prpl->name, ic->username, text ); + irc_usermsg( ic->irc, "%s(%s) - %s", ic->acc->prpl->name, ic->acc->user, text ); else irc_usermsg( ic->irc, "%s - %s", ic->acc->prpl->name, text ); @@ -290,7 +286,7 @@ void cancel_auto_reconnect( account_t *a ) a->reconnect = 0; } -void imc_logout( struct im_connection *ic ) +void imc_logout( struct im_connection *ic, int allow_reconnect ) { irc_t *irc = ic->irc; user_t *t, *u = irc->users; @@ -332,7 +328,7 @@ void imc_logout( struct im_connection *ic ) { /* Uhm... This is very sick. */ } - else if( !ic->wants_to_die && set_getbool( &irc->set, "auto_reconnect" ) && + else if( allow_reconnect && set_getbool( &irc->set, "auto_reconnect" ) && set_getbool( &a->set, "auto_reconnect" ) ) { int delay = set_getint( &irc->set, "auto_reconnect_delay" ); @@ -437,11 +433,6 @@ struct buddy *find_buddy( struct im_connection *ic, char *handle ) return( b ); } -void signoff_blocked( struct im_connection *ic ) -{ - return; /* Make all blocked users look invisible (TODO?) */ -} - void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname ) { @@ -729,7 +720,7 @@ void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, t user_t *u; /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ - if( g_strcasecmp( who, ic->username ) == 0 ) + if( g_strcasecmp( who, ic->acc->user ) == 0 ) return; u = user_findhandle( ic, who ); @@ -780,7 +771,7 @@ void add_chat_buddy( struct groupchat *b, char *handle ) imc_log( b->ic, "User %s added to conversation 0x%x", handle, (int) b ); /* It might be yourself! */ - if( b->ic->acc->prpl->handle_cmp( handle, b->ic->username ) == 0 ) + if( b->ic->acc->prpl->handle_cmp( handle, b->ic->acc->user ) == 0 ) { u = user_find( b->ic->irc, b->ic->irc->nick ); if( !b->joined ) @@ -814,7 +805,7 @@ void remove_chat_buddy( struct groupchat *b, char *handle, char *reason ) imc_log( b->ic, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" ); /* It might be yourself! */ - if( g_strcasecmp( handle, b->ic->username ) == 0 ) + if( g_strcasecmp( handle, b->ic->acc->user ) == 0 ) { u = user_find( b->ic->irc, b->ic->irc->nick ); b->joined = 0; @@ -957,7 +948,6 @@ int bim_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags int bim_chat_msg( struct groupchat *c, char *msg, int flags ) { char *buf = NULL; - int st; if( ( c->ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "", 6 ) != 0 ) ) { -- cgit v1.2.3 From 84b045d409f1e8da6d8bf379c6fef7236dcd9bcd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Apr 2007 18:03:08 -0700 Subject: s/imc/imcb/ for callback functions. Moved things aroundin nogaim.h a little bit, grouping things by category instead of original Gaim 0.58 filename. --- protocols/nogaim.c | 91 ++++++++++++++++++++++++------------------------------ 1 file changed, 41 insertions(+), 50 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 273cc6c8..6121d398 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -144,7 +144,7 @@ GSList *get_connections() { return connections; } /* multi.c */ -struct im_connection *imc_new( account_t *acc ) +struct im_connection *imcb_new( account_t *acc ) { struct im_connection *ic; @@ -203,7 +203,7 @@ static void serv_got_crap( struct im_connection *ic, char *format, ... ) g_free( text ); } -void imc_log( struct im_connection *ic, char *format, ... ) +void imcb_log( struct im_connection *ic, char *format, ... ) { va_list params; char *text; @@ -220,7 +220,7 @@ void imc_log( struct im_connection *ic, char *format, ... ) g_free( text ); } -void imc_error( struct im_connection *ic, char *format, ... ) +void imcb_error( struct im_connection *ic, char *format, ... ) { va_list params; char *text; @@ -247,7 +247,7 @@ static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond ) return TRUE; } -void imc_connected( struct im_connection *ic ) +void imcb_connected( struct im_connection *ic ) { user_t *u; @@ -259,14 +259,14 @@ void imc_connected( struct im_connection *ic ) u = user_find( ic->irc, ic->irc->nick ); - imc_log( ic, "Logged in" ); + imcb_log( ic, "Logged in" ); ic->keepalive = b_timeout_add( 60000, send_keepalive, ic ); ic->flags |= OPT_LOGGED_IN; /* Also necessary when we're not away, at least for some of the protocols. */ - bim_set_away( ic, u->away ); + imc_set_away( ic, u->away ); } gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ) @@ -299,7 +299,7 @@ void imc_logout( struct im_connection *ic, int allow_reconnect ) else ic->flags |= OPT_LOGGING_OUT; - imc_log( ic, "Signing off.." ); + imcb_log( ic, "Signing off.." ); b_event_remove( ic->keepalive ); ic->keepalive = 0; @@ -333,7 +333,7 @@ void imc_logout( struct im_connection *ic, int allow_reconnect ) { int delay = set_getint( &irc->set, "auto_reconnect_delay" ); - imc_log( ic, "Reconnecting in %d seconds..", delay ); + imcb_log( ic, "Reconnecting in %d seconds..", delay ); a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a ); } @@ -343,7 +343,7 @@ void imc_logout( struct im_connection *ic, int allow_reconnect ) /* dialogs.c */ -void do_ask_dialog( struct im_connection *ic, char *msg, void *data, void *doit, void *dont ) +void imcb_ask( struct im_connection *ic, char *msg, void *data, void *doit, void *dont ) { query_add( ic->irc, ic, msg, doit, dont, data ); } @@ -359,12 +359,12 @@ void add_buddy( struct im_connection *ic, char *group, char *handle, char *realn irc_t *irc = ic->irc; if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */ - imc_log( ic, "Receiving user add from handle: %s", handle ); + imcb_log( ic, "Receiving user add from handle: %s", handle ); if( user_findhandle( ic, handle ) ) { if( set_getbool( &irc->set, "debug" ) ) - imc_log( ic, "User already exists, ignoring add request: %s", handle ); + imcb_log( ic, "User already exists, ignoring add request: %s", handle ); return; @@ -447,7 +447,7 @@ void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname ) u->realname = g_strdup( realname ); if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) ) - imc_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); + imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); } } @@ -474,7 +474,7 @@ void show_got_added_yes( gpointer w, struct show_got_added_data *data ) return show_got_added_no( w, data ); } -void show_got_added( struct im_connection *ic, char *handle, const char *realname ) +void imcb_ask_add( struct im_connection *ic, char *handle, const char *realname ) { struct show_got_added_data *data = g_new0( struct show_got_added_data, 1 ); char *s; @@ -511,8 +511,8 @@ void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int { if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 ) { - imc_log( ic, "serv_got_update() for handle %s:", handle ); - imc_log( ic, "loggedin = %d, type = %d", loggedin, type ); + imcb_log( ic, "serv_got_update() for handle %s:", handle ); + imcb_log( ic, "loggedin = %d, type = %d", loggedin, type ); } return; @@ -551,15 +551,6 @@ void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int { u->away = g_strdup( "Away" ); } - else if( ( type & UC_UNAVAILABLE ) && ( strcmp( ic->acc->prpl->name, "jabber" ) == 0 ) ) - { - if( type & UC_DND ) - u->away = g_strdup( "Do Not Disturb" ); - else if( type & UC_XA ) - u->away = g_strdup( "Extended Away" ); - else // if( type & UC_AWAY ) - u->away = g_strdup( "Away" ); - } else if( ( type & UC_UNAVAILABLE ) && ic->acc->prpl->get_status_string ) { u->away = g_strdup( ic->acc->prpl->get_status_string( ic, type ) ); @@ -592,7 +583,7 @@ void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 fla if( g_strcasecmp( h, "ignore" ) == 0 ) { if( set_getbool( &irc->set, "debug" ) ) - imc_log( ic, "Ignoring message from unknown handle %s", handle ); + imcb_log( ic, "Ignoring message from unknown handle %s", handle ); return; } @@ -614,7 +605,7 @@ void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 fla } else { - imc_log( ic, "Message from unknown handle %s:", handle ); + imcb_log( ic, "Message from unknown handle %s:", handle ); u = user_find( irc, irc->mynick ); } } @@ -684,7 +675,7 @@ void serv_got_chat_left( struct groupchat *c ) GList *ir; if( set_getbool( &ic->irc->set, "debug" ) ) - imc_log( ic, "You were removed from conversation 0x%x", (int) c ); + imcb_log( ic, "You were removed from conversation 0x%x", (int) c ); if( c ) { @@ -732,7 +723,7 @@ void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, t if( c && u ) irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", msg ); else - imc_log( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg ); + imcb_log( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg ); } struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle ) @@ -754,7 +745,7 @@ struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle ) c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ ); if( set_getbool( &ic->irc->set, "debug" ) ) - imc_log( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle ); + imcb_log( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle ); return c; } @@ -768,7 +759,7 @@ void add_chat_buddy( struct groupchat *b, char *handle ) int me = 0; if( set_getbool( &b->ic->irc->set, "debug" ) ) - imc_log( b->ic, "User %s added to conversation 0x%x", handle, (int) b ); + imcb_log( b->ic, "User %s added to conversation 0x%x", handle, (int) b ); /* It might be yourself! */ if( b->ic->acc->prpl->handle_cmp( handle, b->ic->acc->user ) == 0 ) @@ -802,7 +793,7 @@ void remove_chat_buddy( struct groupchat *b, char *handle, char *reason ) int me = 0; if( set_getbool( &b->ic->irc->set, "debug" ) ) - imc_log( b->ic, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" ); + imcb_log( b->ic, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" ); /* It might be yourself! */ if( g_strcasecmp( handle, b->ic->acc->user ) == 0 ) @@ -928,7 +919,7 @@ char *set_eval_away_devoice( set_t *set, char *value ) /* The plan is to not allow straight calls to prpl functions anymore, but do them all from some wrappers. We'll start to define some down here: */ -int bim_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags ) +int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags ) { char *buf = NULL; int st; @@ -945,7 +936,7 @@ int bim_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags return st; } -int bim_chat_msg( struct groupchat *c, char *msg, int flags ) +int imc_chat_msg( struct groupchat *c, char *msg, int flags ) { char *buf = NULL; @@ -961,9 +952,9 @@ int bim_chat_msg( struct groupchat *c, char *msg, int flags ) return 1; } -static char *bim_away_alias_find( GList *gcm, char *away ); +static char *imc_away_alias_find( GList *gcm, char *away ); -int bim_set_away( struct im_connection *ic, char *away ) +int imc_set_away( struct im_connection *ic, char *away ) { GList *m, *ms; char *s; @@ -994,12 +985,12 @@ int bim_set_away( struct im_connection *ic, char *away ) } else { - s = bim_away_alias_find( ms, away ); + s = imc_away_alias_find( ms, away ); if( s ) { ic->acc->prpl->set_away( ic, s, away ); if( set_getbool( &ic->irc->set, "debug" ) ) - imc_log( ic, "Setting away state to %s", s ); + imcb_log( ic, "Setting away state to %s", s ); } else ic->acc->prpl->set_away( ic, GAIM_AWAY_CUSTOM, away ); @@ -1008,7 +999,7 @@ int bim_set_away( struct im_connection *ic, char *away ) return( 1 ); } -static char *bim_away_alias_list[8][5] = +static char *imc_away_alias_list[8][5] = { { "Away from computer", "Away", "Extended away", NULL }, { "NA", "N/A", "Not available", NULL }, @@ -1020,28 +1011,28 @@ static char *bim_away_alias_list[8][5] = { NULL } }; -static char *bim_away_alias_find( GList *gcm, char *away ) +static char *imc_away_alias_find( GList *gcm, char *away ) { GList *m; int i, j; - for( i = 0; *bim_away_alias_list[i]; i ++ ) + for( i = 0; *imc_away_alias_list[i]; i ++ ) { - for( j = 0; bim_away_alias_list[i][j]; j ++ ) - if( g_strncasecmp( away, bim_away_alias_list[i][j], strlen( bim_away_alias_list[i][j] ) ) == 0 ) + for( j = 0; imc_away_alias_list[i][j]; j ++ ) + if( g_strncasecmp( away, imc_away_alias_list[i][j], strlen( imc_away_alias_list[i][j] ) ) == 0 ) break; - if( !bim_away_alias_list[i][j] ) /* If we reach the end, this row */ + if( !imc_away_alias_list[i][j] ) /* If we reach the end, this row */ continue; /* is not what we want. Next! */ /* Now find an entry in this row which exists in gcm */ - for( j = 0; bim_away_alias_list[i][j]; j ++ ) + for( j = 0; imc_away_alias_list[i][j]; j ++ ) { m = gcm; while( m ) { - if( g_strcasecmp( bim_away_alias_list[i][j], m->data ) == 0 ) - return( bim_away_alias_list[i][j] ); + if( g_strcasecmp( imc_away_alias_list[i][j], m->data ) == 0 ) + return( imc_away_alias_list[i][j] ); m = m->next; } } @@ -1050,7 +1041,7 @@ static char *bim_away_alias_find( GList *gcm, char *away ) return( NULL ); } -void bim_add_allow( struct im_connection *ic, char *handle ) +void imc_add_allow( struct im_connection *ic, char *handle ) { if( g_slist_find_custom( ic->permit, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) == NULL ) { @@ -1060,7 +1051,7 @@ void bim_add_allow( struct im_connection *ic, char *handle ) ic->acc->prpl->add_permit( ic, handle ); } -void bim_rem_allow( struct im_connection *ic, char *handle ) +void imc_rem_allow( struct im_connection *ic, char *handle ) { GSList *l; @@ -1073,7 +1064,7 @@ void bim_rem_allow( struct im_connection *ic, char *handle ) ic->acc->prpl->rem_permit( ic, handle ); } -void bim_add_block( struct im_connection *ic, char *handle ) +void imc_add_block( struct im_connection *ic, char *handle ) { if( g_slist_find_custom( ic->deny, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) == NULL ) { @@ -1083,7 +1074,7 @@ void bim_add_block( struct im_connection *ic, char *handle ) ic->acc->prpl->add_deny( ic, handle ); } -void bim_rem_block( struct im_connection *ic, char *handle ) +void imc_rem_block( struct im_connection *ic, char *handle ) { GSList *l; -- cgit v1.2.3 From 6bbb939e953bbe1ca9ed3101a1569abe4521f543 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Apr 2007 21:01:13 -0700 Subject: Split serv_got_update() into imcb_buddy_(status|times). (Well, the second one isn't implemented yet, but I'll do that later.) At last I got rid of the hack called get_status_string(). And now Yahoo seems to mess up away messages... --- protocols/nogaim.c | 57 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 24 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 6121d398..ef30f749 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -186,7 +186,7 @@ static void serv_got_crap( struct im_connection *ic, char *format, ... ) va_end( params ); if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || - ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) + ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) strip_html( text ); /* Try to find a different connection on the same protocol. */ @@ -493,32 +493,31 @@ void imcb_ask_add( struct im_connection *ic, char *handle, const char *realname /* server.c */ -void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps ) +void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message ) { user_t *u; int oa, oo; - u = user_findhandle( ic, handle ); + u = user_findhandle( ic, (char*) handle ); if( !u ) { if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 ) { - add_buddy( ic, NULL, handle, NULL ); - u = user_findhandle( ic, handle ); + add_buddy( ic, NULL, (char*) handle, NULL ); + u = user_findhandle( ic, (char*) handle ); } else { if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 ) { - imcb_log( ic, "serv_got_update() for handle %s:", handle ); - imcb_log( ic, "loggedin = %d, type = %d", loggedin, type ); + imcb_log( ic, "imcb_buddy_status() for unknown handle %s:", handle ); + imcb_log( ic, "flags = %d, state = %s, message = %s", flags, + state ? state : "NULL", message ? message : "NULL" ); } return; } - /* Why did we have this here.... - return; */ } oa = u->away != NULL; @@ -530,12 +529,12 @@ void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int u->away = NULL; } - if( loggedin && !u->online ) + if( ( flags & OPT_LOGGED_IN ) && !u->online ) { irc_spawn( ic->irc, u ); u->online = 1; } - else if( !loggedin && u->online ) + else if( !( flags & OPT_LOGGED_IN ) && u->online ) { struct groupchat *c; @@ -544,19 +543,29 @@ void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int /* Remove him/her from the conversations to prevent PART messages after he/she QUIT already */ for( c = ic->conversations; c; c = c->next ) - remove_chat_buddy_silent( c, handle ); + remove_chat_buddy_silent( c, (char*) handle ); } - if( ( type & UC_UNAVAILABLE ) && ( strcmp( ic->acc->prpl->name, "oscar" ) == 0 || strcmp( ic->acc->prpl->name, "icq" ) == 0 ) ) - { - u->away = g_strdup( "Away" ); - } - else if( ( type & UC_UNAVAILABLE ) && ic->acc->prpl->get_status_string ) + if( flags & OPT_AWAY ) { - u->away = g_strdup( ic->acc->prpl->get_status_string( ic, type ) ); + if( state && message ) + { + u->away = g_strdup_printf( "%s (%s)", state, message ); + } + else if( state ) + { + u->away = g_strdup( state ); + } + else if( message ) + { + u->away = g_strdup( message ); + } + else + { + u->away = g_strdup( "Away" ); + } } - else - u->away = NULL; + /* else waste_any_state_information_for_now(); */ /* LISPy... */ if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ @@ -611,7 +620,7 @@ void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 fla } if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || - ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) + ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) strip_html( msg ); while( strlen( msg ) > 425 ) @@ -717,7 +726,7 @@ void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, t u = user_findhandle( ic, who ); if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || - ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) + ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) strip_html( msg ); if( c && u ) @@ -924,7 +933,7 @@ int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags char *buf = NULL; int st; - if( ( ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "", 6 ) != 0 ) ) + if( ( ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "", 6 ) != 0 ) ) { buf = escape_html( msg ); msg = buf; @@ -940,7 +949,7 @@ int imc_chat_msg( struct groupchat *c, char *msg, int flags ) { char *buf = NULL; - if( ( c->ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "", 6 ) != 0 ) ) + if( ( c->ic->flags & OPT_DOES_HTML ) && ( g_strncasecmp( msg, "", 6 ) != 0 ) ) { buf = escape_html( msg ); msg = buf; -- cgit v1.2.3 From 9624fdf0d6f170d8caa7948fb1b3a138b05e1d8c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 16 Apr 2007 21:49:17 -0700 Subject: API cleanup pretty much complete. Fixed pretty much everything except the buddy/groupchat related functions. --- protocols/nogaim.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index ef30f749..2a452e57 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -423,7 +423,7 @@ struct buddy *find_buddy( struct im_connection *ic, char *handle ) if( !u ) return( NULL ); - + memset( b, 0, sizeof( b ) ); strncpy( b->name, handle, 80 ); strncpy( b->show, u->realname, BUDDY_ALIAS_MAXLEN ); @@ -574,11 +574,11 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ { irc_write( ic->irc, ":%s MODE %s %cv %s", ic->irc->myhost, - ic->irc->channel, u->away?'-':'+', u->nick ); + ic->irc->channel, u->away?'-':'+', u->nick ); } } -void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len ) +void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at ) { irc_t *irc = ic->irc; user_t *u; @@ -656,24 +656,19 @@ void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 fla irc_msgfrom( irc, u->nick, msg ); } -void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type ) +void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags ) { user_t *u; if( !set_getbool( &ic->irc->set, "typing_notice" ) ) return; - if( ( u = user_findhandle( ic, handle ) ) ) { - /* If type is: - * 0: user has stopped typing - * 1: user is actively typing - * 2: user has entered text, but is not actively typing - */ - if (type == 0 || type == 1 || type == 2) { - char buf[256]; - g_snprintf(buf, 256, "\1TYPING %d\1", type); - irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf ); - } + if( ( u = user_findhandle( ic, handle ) ) ) + { + char buf[256]; + + g_snprintf( buf, 256, "\1TYPING %d\1", ( flags >> 8 ) & 3 ); + irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf ); } } -- cgit v1.2.3 From f0cb961652cbd639e89dcd88a86f20a2414146c4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 18 Apr 2007 23:03:43 -0700 Subject: More API changes: buddy list management. imcb_add_buddy() is now a *real* callback, it's only called from inside IM-modules. This makes sure a buddy only gets added to the BitlBee structures if the add was successful. This gets rid of the weirdness described in #55. Unfortunately for now this change breaks A) automatic renaming of ICQ contacts (if there are names stored in the contact list) B) add -tmp. --- protocols/nogaim.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 2a452e57..02a1bf71 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -351,16 +351,12 @@ void imcb_ask( struct im_connection *ic, char *msg, void *data, void *doit, void /* list.c */ -void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname ) +void imcb_add_buddy( struct im_connection *ic, char *handle, char *group ) { user_t *u; - char nick[MAX_NICK_LENGTH+1]; - char *s; + char nick[MAX_NICK_LENGTH+1], *s; irc_t *irc = ic->irc; - if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */ - imcb_log( ic, "Receiving user add from handle: %s", handle ); - if( user_findhandle( ic, handle ) ) { if( set_getbool( &irc->set, "debug" ) ) @@ -368,16 +364,19 @@ void add_buddy( struct im_connection *ic, char *group, char *handle, char *realn return; - /* Buddy seems to exist already. Let's ignore this request then... */ + /* Buddy seems to exist already. Let's ignore this request then... + Eventually subsequent calls to this function *should* be possible + when a buddy is in multiple groups. But for now BitlBee doesn't + even support groups so let's silently ignore this for now. */ } memset( nick, 0, MAX_NICK_LENGTH + 1 ); - strcpy( nick, nick_get( ic->acc, handle, realname ) ); + strcpy( nick, nick_get( ic->acc, handle, NULL ) ); u = user_add( ic->irc, nick ); - if( !realname || !*realname ) realname = nick; - u->realname = g_strdup( realname ); +// if( !realname || !*realname ) realname = nick; +// u->realname = g_strdup( realname ); if( ( s = strchr( handle, '@' ) ) ) { @@ -386,14 +385,7 @@ void add_buddy( struct im_connection *ic, char *group, char *handle, char *realn } else if( ic->acc->server ) { - char *colon; - - if( ( colon = strchr( ic->acc->server, ':' ) ) ) - u->host = g_strndup( ic->acc->server, - colon - ic->acc->server ); - else - u->host = g_strdup( ic->acc->server ); - + u->host = g_strdup( ic->acc->server ); u->user = g_strdup( handle ); /* s/ /_/ ... important for AOL screennames */ @@ -414,7 +406,7 @@ void add_buddy( struct im_connection *ic, char *group, char *handle, char *realn u->last_typing_notice = 0; } -struct buddy *find_buddy( struct im_connection *ic, char *handle ) +struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle ) { static struct buddy b[1]; user_t *u; @@ -434,11 +426,11 @@ struct buddy *find_buddy( struct im_connection *ic, char *handle ) } -void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname ) +void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) { user_t *u = user_findhandle( ic, handle ); - if( !u ) return; + if( !u || !realname ) return; if( g_strcasecmp( u->realname, realname ) != 0 ) { @@ -469,7 +461,7 @@ void show_got_added_no( gpointer w, struct show_got_added_data *data ) void show_got_added_yes( gpointer w, struct show_got_added_data *data ) { data->ic->acc->prpl->add_buddy( data->ic, data->handle, NULL ); - add_buddy( data->ic, NULL, data->handle, data->handle ); + /* imcb_add_buddy( data->ic, NULL, data->handle, data->handle ); */ return show_got_added_no( w, data ); } @@ -504,7 +496,7 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, { if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 ) { - add_buddy( ic, NULL, (char*) handle, NULL ); + imcb_add_buddy( ic, (char*) handle, NULL ); u = user_findhandle( ic, (char*) handle ); } else @@ -608,7 +600,7 @@ void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_ private = 0; } - add_buddy( ic, NULL, handle, NULL ); + imcb_add_buddy( ic, handle, NULL ); u = user_findhandle( ic, handle ); u->is_private = private; } @@ -778,7 +770,7 @@ void add_chat_buddy( struct groupchat *b, char *handle ) your contact list. Try to handle that here */ if( !u ) { - add_buddy( b->ic, NULL, handle, NULL ); + imcb_add_buddy( b->ic, handle, NULL ); u = user_findhandle( b->ic, handle ); } -- cgit v1.2.3 From d323394cf97afa79bc2a75f5f2dd0f88bf1b8fa4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 19 Apr 2007 21:49:30 -0700 Subject: New code to use nicknames stored in ICQ contact lists. --- protocols/nogaim.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 02a1bf71..2fa6277e 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -371,7 +371,7 @@ void imcb_add_buddy( struct im_connection *ic, char *handle, char *group ) } memset( nick, 0, MAX_NICK_LENGTH + 1 ); - strcpy( nick, nick_get( ic->acc, handle, NULL ) ); + strcpy( nick, nick_get( ic->acc, handle ) ); u = user_add( ic->irc, nick ); @@ -425,10 +425,10 @@ struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle ) return( b ); } - void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) { user_t *u = user_findhandle( ic, handle ); + char *s, newnick[MAX_NICK_LENGTH+1]; if( !u || !realname ) return; @@ -440,6 +440,27 @@ void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) ) imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); + + if( !u->online && !nick_saved( ic->acc, handle ) ) + { + /* Detect numeric handles: */ + for( s = u->user; isdigit( *s ); s++ ); + + if( *s == 0 ) + { + /* If we reached the end of the string, it only contained numbers. + Seems to be an ICQ# then, so hopefully realname contains + something more useful. */ + strcpy( newnick, realname ); + + /* Some processing to make sure this string is a valid IRC nickname. */ + nick_strip( newnick ); + if( set_getbool( &ic->irc->set, "lcnicks" ) ) + nick_lc( newnick ); + + u->nick = g_strdup( newnick ); + } + } } } -- cgit v1.2.3 From 61ae52c5fbe8fbaf75adb148cd05c357590e8807 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 19 Apr 2007 22:19:06 -0700 Subject: Renamed/slightly changed syntax of groupchat callback functions. --- protocols/nogaim.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 2fa6277e..c27a684d 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -685,7 +685,7 @@ void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags } } -void serv_got_chat_left( struct groupchat *c ) +void imcb_chat_removed( struct groupchat *c ) { struct im_connection *ic = c->ic; struct groupchat *l = NULL; @@ -722,7 +722,7 @@ void serv_got_chat_left( struct groupchat *c ) } } -void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, time_t mtime ) +void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at ) { struct im_connection *ic = c->ic; user_t *u; @@ -743,7 +743,7 @@ void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, t imcb_log( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg ); } -struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle ) +struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ) { struct groupchat *c; @@ -770,7 +770,7 @@ struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle ) /* buddy_chat.c */ -void add_chat_buddy( struct groupchat *b, char *handle ) +void imcb_chat_add_buddy( struct groupchat *b, char *handle ) { user_t *u = user_findhandle( b->ic, handle ); int me = 0; @@ -804,7 +804,7 @@ void add_chat_buddy( struct groupchat *b, char *handle ) } } -void remove_chat_buddy( struct groupchat *b, char *handle, char *reason ) +void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ) { user_t *u; int me = 0; -- cgit v1.2.3 From f6c963b97d3f686ca5410f1896cf8e266b455c22 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 20 Apr 2007 21:13:21 -0700 Subject: Renamed some more prpl functions. --- protocols/nogaim.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index c27a684d..a70d6eca 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -281,7 +281,6 @@ gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ) void cancel_auto_reconnect( account_t *a ) { - /* while( b_event_remove_by_data( (gpointer) a ) ); */ b_event_remove( a->reconnect ); a->reconnect = 0; } @@ -947,7 +946,7 @@ int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags msg = buf; } - st = ic->acc->prpl->send_im( ic, handle, msg, flags ); + st = ic->acc->prpl->buddy_msg( ic, handle, msg, flags ); g_free( buf ); return st; @@ -963,7 +962,7 @@ int imc_chat_msg( struct groupchat *c, char *msg, int flags ) msg = buf; } - c->ic->acc->prpl->chat_send( c, msg, flags ); + c->ic->acc->prpl->chat_msg( c, msg, flags ); g_free( buf ); return 1; -- cgit v1.2.3 From e35d1a121d5fb2da3698fbe4a365fe38d0097665 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 22 Apr 2007 13:44:27 -0700 Subject: Read-only support for Jabber conferences (non-anonymous rooms only). Just don't use this, you're really not going to like it. :-) --- protocols/nogaim.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index a70d6eca..f3dbb0b8 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -553,8 +553,8 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, irc_kill( ic->irc, u ); u->online = 0; - /* Remove him/her from the conversations to prevent PART messages after he/she QUIT already */ - for( c = ic->conversations; c; c = c->next ) + /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */ + for( c = ic->groupchats; c; c = c->next ) remove_chat_buddy_silent( c, (char*) handle ); } @@ -684,10 +684,10 @@ void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags } } -void imcb_chat_removed( struct groupchat *c ) +void imcb_chat_free( struct groupchat *c ) { struct im_connection *ic = c->ic; - struct groupchat *l = NULL; + struct groupchat *l; GList *ir; if( set_getbool( &ic->irc->set, "debug" ) ) @@ -707,10 +707,13 @@ void imcb_chat_removed( struct groupchat *c ) /* irc_part( ic->irc, u, c->channel ); */ } + /* Find the previous chat in the linked list. */ + for( l = ic->groupchats; l && l->next != c; l = l->next ); + if( l ) l->next = c->next; else - ic->conversations = c->next; + ic->groupchats = c->next; for( ir = c->in_room; ir; ir = ir->next ) g_free( ir->data ); @@ -748,13 +751,13 @@ struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ) /* This one just creates the conversation structure, user won't see anything yet */ - if( ic->conversations ) + if( ic->groupchats ) { - for( c = ic->conversations; c->next; c = c->next ); + for( c = ic->groupchats; c->next; c = c->next ); c = c->next = g_new0( struct groupchat, 1 ); } else - ic->conversations = c = g_new0( struct groupchat, 1 ); + ic->groupchats = c = g_new0( struct groupchat, 1 ); c->ic = ic; c->title = g_strdup( handle ); @@ -862,7 +865,7 @@ struct groupchat *chat_by_channel( char *channel ) for( l = connections; l; l = l->next ) { ic = l->data; - for( c = ic->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next ); + for( c = ic->groupchats; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next ); if( c ) return c; } -- cgit v1.2.3 From 0e7ab64dfb66192a875c37322ca6f8a364ec5bc8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 22 Apr 2007 19:58:44 -0700 Subject: Got rid of one HORRIBLE stupidity called chat_by_channel(), which still used the GLOBAL IM connections list, allowing user A to interfere with user B's groupchats if running in daemon mode. I can't believe this was still there... --- protocols/nogaim.c | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index f3dbb0b8..5b1c4346 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -855,24 +855,6 @@ static int remove_chat_buddy_silent( struct groupchat *b, char *handle ) /* Misc. BitlBee stuff which shouldn't really be here */ -struct groupchat *chat_by_channel( char *channel ) -{ - struct im_connection *ic; - struct groupchat *c; - GSList *l; - - /* This finds the connection which has a conversation which belongs to this channel */ - for( l = connections; l; l = l->next ) - { - ic = l->data; - for( c = ic->groupchats; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next ); - if( c ) - return c; - } - - return NULL; -} - char *set_eval_away_devoice( set_t *set, char *value ) { irc_t *irc = set->data; -- cgit v1.2.3 From 2d317bbe8def887fb796b2daaa958c59d8f4c070 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 22 Apr 2007 22:18:47 -0700 Subject: Fixes: handling of being kicked, now sending tags to all conferences the user's in. --- protocols/nogaim.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 5b1c4346..5a9f5b3e 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -806,6 +806,7 @@ void imcb_chat_add_buddy( struct groupchat *b, char *handle ) } } +/* This function is one BIG hack... :-( EREWRITE */ void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ) { user_t *u; @@ -817,6 +818,9 @@ void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ) /* It might be yourself! */ if( g_strcasecmp( handle, b->ic->acc->user ) == 0 ) { + if( b->joined == 0 ) + return; + u = user_find( b->ic->irc, b->ic->irc->nick ); b->joined = 0; me = 1; @@ -826,9 +830,8 @@ void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ) u = user_findhandle( b->ic, handle ); } - if( remove_chat_buddy_silent( b, handle ) ) - if( ( b->joined || me ) && u ) - irc_part( b->ic->irc, u, b->channel ); + if( me || ( remove_chat_buddy_silent( b, handle ) && b->joined && u ) ) + irc_part( b->ic->irc, u, b->channel ); } static int remove_chat_buddy_silent( struct groupchat *b, char *handle ) -- cgit v1.2.3 From d06eabf19ec3f849d8bab22c13d43e4eba9a48ee Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 4 Jun 2007 14:22:05 +0100 Subject: Added imcb_buddy_nick_hint so the Jabber conference module can suggest sane nicknames for chatroom participants. There'll probably be a lot of underscores now, but this is by far the cleanest way to implement this, I think. At least now whispers will work properly. Also using this function call to set names for ICQ contacts in a slightly saner way. --- protocols/nogaim.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 5a9f5b3e..71cebacd 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -427,7 +427,6 @@ struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle ) void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) { user_t *u = user_findhandle( ic, handle ); - char *s, newnick[MAX_NICK_LENGTH+1]; if( !u || !realname ) return; @@ -439,30 +438,34 @@ void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) ) imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); - - if( !u->online && !nick_saved( ic->acc, handle ) ) - { - /* Detect numeric handles: */ - for( s = u->user; isdigit( *s ); s++ ); - - if( *s == 0 ) - { - /* If we reached the end of the string, it only contained numbers. - Seems to be an ICQ# then, so hopefully realname contains - something more useful. */ - strcpy( newnick, realname ); - - /* Some processing to make sure this string is a valid IRC nickname. */ - nick_strip( newnick ); - if( set_getbool( &ic->irc->set, "lcnicks" ) ) - nick_lc( newnick ); - - u->nick = g_strdup( newnick ); - } - } } } +/* Mainly meant for ICQ (and now also for Jabber conferences) to allow IM + modules to suggest a nickname for a handle. */ +void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick ) +{ + user_t *u = user_findhandle( ic, handle ); + char newnick[MAX_NICK_LENGTH+1]; + + if( !u->online && !nick_saved( ic->acc, handle ) ) + { + /* Only do this if the person isn't online yet (which should + be the case if we just added it) and if the user hasn't + assigned a nickname to this buddy already. */ + + strcpy( newnick, nick ); + + /* Some processing to make sure this string is a valid IRC nickname. */ + nick_strip( newnick ); + if( set_getbool( &ic->irc->set, "lcnicks" ) ) + nick_lc( newnick ); + + nick_dedupe( ic->acc, handle, newnick ); + + u->nick = g_strdup( newnick ); + } +} /* prpl.c */ -- cgit v1.2.3 From e0e2a71ed3e7937ed5da85af95be016a8441547b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 4 Jun 2007 14:36:51 +0100 Subject: Fixed retarded use of strcpy() and no longer using Jabber fullnames for nickname generation. IM fullnames and IRC nicknames are just *different*. --- protocols/nogaim.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 71cebacd..06bd8e4b 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -448,13 +448,14 @@ void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick ) user_t *u = user_findhandle( ic, handle ); char newnick[MAX_NICK_LENGTH+1]; - if( !u->online && !nick_saved( ic->acc, handle ) ) + if( u && !u->online && !nick_saved( ic->acc, handle ) ) { /* Only do this if the person isn't online yet (which should be the case if we just added it) and if the user hasn't assigned a nickname to this buddy already. */ - strcpy( newnick, nick ); + strncpy( newnick, nick, MAX_NICK_LENGTH ); + newnick[MAX_NICK_LENGTH] = 0; /* Some processing to make sure this string is a valid IRC nickname. */ nick_strip( newnick ); -- cgit v1.2.3 From 7e9dc74b15901b182be2a1d20bafdba696e4f5f2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 14 Jun 2007 00:30:59 +0100 Subject: Fixed the duplicate-nick problem. Very very very stupid bug... :-( --- protocols/nogaim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 06bd8e4b..6c564c8c 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -464,7 +464,7 @@ void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick ) nick_dedupe( ic->acc, handle, newnick ); - u->nick = g_strdup( newnick ); + user_rename( ic->irc, u->nick, newnick ); } } -- cgit v1.2.3 From 43d8cc5909aa45aee0b3368e70275469b0f8de22 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 14 Jun 2007 00:31:18 +0100 Subject: Fixed a memory management problem that caused some strange nickname issues. --- protocols/nogaim.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 6c564c8c..a1a97dc3 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -446,7 +446,7 @@ void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick ) { user_t *u = user_findhandle( ic, handle ); - char newnick[MAX_NICK_LENGTH+1]; + char newnick[MAX_NICK_LENGTH+1], *orig_nick; if( u && !u->online && !nick_saved( ic->acc, handle ) ) { @@ -464,7 +464,11 @@ void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick ) nick_dedupe( ic->acc, handle, newnick ); - user_rename( ic->irc, u->nick, newnick ); + /* u->nick will be freed halfway the process, so it can't be + passed as an argument. */ + orig_nick = g_strdup( u->nick ); + user_rename( ic->irc, orig_nick, newnick ); + g_free( orig_nick ); } } -- cgit v1.2.3 From 998b1035a6c8349b3661861eeb5d9d1f4082ba0a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 14 Jun 2007 00:31:39 +0100 Subject: Added imcb_remove_buddy() so deletions in Jabber roster pushes actually work. This also solves the issue of underscores appearing and disappearing in their nicknames when people leave/join a chat. --- protocols/nogaim.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index a1a97dc3..4f04993c 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -441,6 +441,14 @@ void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) } } +void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group ) +{ + user_t *u; + + if( ( u = user_findhandle( ic, handle ) ) ) + user_del( ic->irc, u->nick ); +} + /* Mainly meant for ICQ (and now also for Jabber conferences) to allow IM modules to suggest a nickname for a handle. */ void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick ) -- cgit v1.2.3 From 1962ac169c14c7b24e276caac0976b8983496fd5 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 2 Jul 2007 22:07:43 +0100 Subject: Fixed nick hint function to only set the nick if it's different from the current one (otherwise the dedupe function will dedupe the nick against itself). --- protocols/nogaim.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 4f04993c..22d82ecb 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -470,13 +470,19 @@ void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick ) if( set_getbool( &ic->irc->set, "lcnicks" ) ) nick_lc( newnick ); - nick_dedupe( ic->acc, handle, newnick ); - - /* u->nick will be freed halfway the process, so it can't be - passed as an argument. */ - orig_nick = g_strdup( u->nick ); - user_rename( ic->irc, orig_nick, newnick ); - g_free( orig_nick ); + if( strcmp( u->nick, newnick ) != 0 ) + { + /* Only do this if newnick is different from the current one. + If rejoining a channel, maybe we got this nick already + (and dedupe would only add an underscore. */ + nick_dedupe( ic->acc, handle, newnick ); + + /* u->nick will be freed halfway the process, so it can't be + passed as an argument. */ + orig_nick = g_strdup( u->nick ); + user_rename( ic->irc, orig_nick, newnick ); + g_free( orig_nick ); + } } } -- cgit v1.2.3 From c9c7ca771d3b06ab448a72bdcddfdacd5be815c0 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 11 Jul 2007 15:22:00 +0100 Subject: Fixed imc_logout() (assigning u too early). Stupid me. --- protocols/nogaim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 22d82ecb..7dc777ef 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -288,7 +288,7 @@ void cancel_auto_reconnect( account_t *a ) void imc_logout( struct im_connection *ic, int allow_reconnect ) { irc_t *irc = ic->irc; - user_t *t, *u = irc->users; + user_t *t, *u; account_t *a; /* Nested calls might happen sometimes, this is probably the best @@ -305,6 +305,7 @@ void imc_logout( struct im_connection *ic, int allow_reconnect ) ic->acc->prpl->logout( ic ); b_event_remove( ic->inpa ); + u = irc->users; while( u ) { if( u->ic == ic ) -- cgit v1.2.3 From 85023c65b697d2dab932acbda31258ae5270dbe6 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Jul 2007 16:47:34 +0100 Subject: Added imcb_clean_handle() to sanitize handles properly (without putting IRC-specific stuff into the Jabber module). Only using this in the MUC code for now because this only works if the IM module can somehow convert the cleaned up handle back to the original one. --- protocols/nogaim.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 7dc777ef..4b0b738b 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -98,7 +98,6 @@ void register_protocol (struct prpl *p) protocols = g_list_append(protocols, p); } - struct prpl *find_protocol(const char *name) { GList *gl; @@ -1113,3 +1112,35 @@ void imc_rem_block( struct im_connection *ic, char *handle ) ic->acc->prpl->rem_deny( ic, handle ); } + +void imcb_clean_handle( struct im_connection *ic, char *handle ) +{ + /* Accepts a handle and does whatever is necessary to make it + BitlBee-friendly. Currently this means removing everything + outside 33-127 (ASCII printable excl spaces), @ (only one + is allowed) and ! and : */ + char out[strlen(handle)+1]; + int s, d; + + s = d = 0; + while( handle[s] ) + { + if( handle[s] > ' ' && handle[s] != '!' && handle[s] != ':' && + ( handle[s] & 0x80 ) == 0 ) + { + if( handle[s] == '@' ) + { + /* See if we got an @ already? */ + out[d] = 0; + if( strchr( out, '@' ) ) + continue; + } + + out[d++] = handle[s]; + } + s ++; + } + out[d] = handle[s]; + + strcpy( handle, out ); +} -- cgit v1.2.3 From 8ad90fbd65d544ac207d52780499df76db9adc6f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 30 Aug 2007 23:23:07 +0100 Subject: From vmiklos: More verbose error message on plugin load failures. --- protocols/nogaim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index a70d6eca..9ebd048e 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -47,7 +47,7 @@ gboolean load_plugin(char *path) GModule *mod = g_module_open(path, G_MODULE_BIND_LAZY); if(!mod) { - log_message(LOGLVL_ERROR, "Can't find `%s', not loading", path); + log_message(LOGLVL_ERROR, "Can't find `%s', not loading (%s)\n", path, g_module_error()); return FALSE; } -- cgit v1.2.3 From 118638279f7a39422d9e07365b380fa773c5243e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 10 Oct 2007 23:15:59 +0100 Subject: Made the netsplit-like quit messages optional. --- protocols/nogaim.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 9ebd048e..d7b26b74 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -585,8 +585,20 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ { - irc_write( ic->irc, ":%s MODE %s %cv %s", ic->irc->myhost, - ic->irc->channel, u->away?'-':'+', u->nick ); + char *from; + + if( set_getbool( &ic->irc->set, "simulate_netsplit" ) ) + { + from = g_strdup( ic->irc->myhost ); + } + else + { + from = g_strdup_printf( "%s!%s@%s", ic->irc->mynick, ic->irc->mynick, + ic->irc->myhost ); + } + irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel, + u->away?'-':'+', u->nick ); + g_free( from ); } } -- cgit v1.2.3 From d444c09e6c7ac6fc3c1686af0e63c09805d8cd00 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 12 Oct 2007 01:06:50 +0100 Subject: Added word_wrap() function to misc.c and using it at the right places so that long messages in groupchats also get wrapped properly (instead of truncated). --- protocols/nogaim.c | 46 +++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index d7b26b74..d90870ad 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -605,6 +605,7 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at ) { irc_t *irc = ic->irc; + char *wrapped; user_t *u; u = user_findhandle( ic, handle ); @@ -647,37 +648,9 @@ void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_ ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) strip_html( msg ); - while( strlen( msg ) > 425 ) - { - char tmp, *nl; - - tmp = msg[425]; - msg[425] = 0; - - /* If there's a newline/space in this string, split up there, - looks a bit prettier. */ - if( ( nl = strrchr( msg, '\n' ) ) || ( nl = strrchr( msg, ' ' ) ) ) - { - msg[425] = tmp; - tmp = *nl; - *nl = 0; - } - - irc_msgfrom( irc, u->nick, msg ); - - /* Move on. */ - if( nl ) - { - *nl = tmp; - msg = nl + 1; - } - else - { - msg[425] = tmp; - msg += 425; - } - } - irc_msgfrom( irc, u->nick, msg ); + wrapped = word_wrap( msg, 425 ); + irc_msgfrom( irc, u->nick, wrapped ); + g_free( wrapped ); } void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags ) @@ -736,6 +709,7 @@ void imcb_chat_removed( struct groupchat *c ) void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at ) { struct im_connection *ic = c->ic; + char *wrapped; user_t *u; /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ @@ -748,10 +722,16 @@ void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) strip_html( msg ); + wrapped = word_wrap( msg, 425 ); if( c && u ) - irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", msg ); + { + irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped ); + } else - imcb_log( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg ); + { + imcb_log( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, wrapped ); + } + g_free( wrapped ); } struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ) -- cgit v1.2.3 From 764b163d6bc0587498c14de8023d70aea076e646 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 12 Oct 2007 14:18:16 +0200 Subject: Fix another warning. --- protocols/nogaim.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index d90870ad..d0395fa9 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -35,7 +35,7 @@ #include "nogaim.h" #include -static int remove_chat_buddy_silent( struct groupchat *b, char *handle ); +static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ); GSList *connections; @@ -555,7 +555,7 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, /* Remove him/her from the conversations to prevent PART messages after he/she QUIT already */ for( c = ic->conversations; c; c = c->next ) - remove_chat_buddy_silent( c, (char*) handle ); + remove_chat_buddy_silent( c, handle ); } if( flags & OPT_AWAY ) @@ -820,7 +820,7 @@ void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ) irc_part( b->ic->irc, u, b->channel ); } -static int remove_chat_buddy_silent( struct groupchat *b, char *handle ) +static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ) { GList *i; -- cgit v1.2.3 From 50e1776cb0c76b3328d458dd8a1bfb379b6b0e43 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 19 Nov 2007 22:23:58 +0000 Subject: Merging /TOPIC code from Miklos Vajna. Untested, because I still have to implement the Jabber hooks. --- protocols/nogaim.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index d1aceb1a..2ad8a049 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -759,6 +759,29 @@ void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, g_free( wrapped ); } +void imcb_chat_topic( struct groupchat *c, char *who, char *topic ) +{ + struct im_connection *ic = c->ic; + user_t *u = NULL; + + if( who == NULL) + u = user_find( ic, ic->irc->mynick ); + else if( g_strcasecmp( who, ic->acc->user ) == 0 ) + u = user_find( ic, ic->irc->nick ); + else + u = user_findhandle( ic, who ); + + if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || + ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) + strip_html( topic ); + + g_free( c->topic ); + c->topic = g_strdup( topic ); + + if( c->joined && u ) + irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic ); +} + struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ) { struct groupchat *c; @@ -776,6 +799,7 @@ struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ) c->ic = ic; c->title = g_strdup( handle ); c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ ); + c->topic = g_strdup_printf( "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->channel, c->title ); if( set_getbool( &ic->irc->set, "debug" ) ) imcb_log( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle ); -- cgit v1.2.3 From ef5c1855b406e462fb8b90b517f1672a47bcc4b5 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 19 Nov 2007 23:14:39 +0000 Subject: Added Jabber groupchat topic support. --- protocols/nogaim.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 2ad8a049..e0f04c0b 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -759,15 +759,15 @@ void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, g_free( wrapped ); } -void imcb_chat_topic( struct groupchat *c, char *who, char *topic ) +void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at ) { struct im_connection *ic = c->ic; user_t *u = NULL; if( who == NULL) - u = user_find( ic, ic->irc->mynick ); + u = user_find( ic->irc, ic->irc->mynick ); else if( g_strcasecmp( who, ic->acc->user ) == 0 ) - u = user_find( ic, ic->irc->nick ); + u = user_find( ic->irc, ic->irc->nick ); else u = user_findhandle( ic, who ); -- cgit v1.2.3 From 56f260affd91651cb0c44ee14713f7dfa0717ad4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 22 Nov 2007 22:56:52 +0000 Subject: Some changes to get rid of compiler warnings. (And disabling strict aliasing because there are too many warnings about it. :-P) --- protocols/nogaim.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index e0f04c0b..5e698902 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -698,7 +698,7 @@ void imcb_chat_free( struct groupchat *c ) GList *ir; if( set_getbool( &ic->irc->set, "debug" ) ) - imcb_log( ic, "You were removed from conversation 0x%x", (int) c ); + imcb_log( ic, "You were removed from conversation %p", c ); if( c ) { @@ -754,7 +754,7 @@ void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, } else { - imcb_log( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, wrapped ); + imcb_log( ic, "Message from/to conversation %s@%p (unknown conv/user): %s", who, c, wrapped ); } g_free( wrapped ); } @@ -802,7 +802,7 @@ struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ) c->topic = g_strdup_printf( "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->channel, c->title ); if( set_getbool( &ic->irc->set, "debug" ) ) - imcb_log( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle ); + imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle ); return c; } @@ -816,7 +816,7 @@ void imcb_chat_add_buddy( struct groupchat *b, char *handle ) int me = 0; if( set_getbool( &b->ic->irc->set, "debug" ) ) - imcb_log( b->ic, "User %s added to conversation 0x%x", handle, (int) b ); + imcb_log( b->ic, "User %s added to conversation %p", handle, b ); /* It might be yourself! */ if( b->ic->acc->prpl->handle_cmp( handle, b->ic->acc->user ) == 0 ) @@ -851,7 +851,7 @@ void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ) int me = 0; if( set_getbool( &b->ic->irc->set, "debug" ) ) - imcb_log( b->ic, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" ); + imcb_log( b->ic, "User %s removed from conversation %p (%s)", handle, b, reason ? reason : "" ); /* It might be yourself! */ if( g_strcasecmp( handle, b->ic->acc->user ) == 0 ) -- cgit v1.2.3 From 52744f8f65a278a59a8903d5c594e057d63c7006 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 17 Jan 2008 22:06:55 +0000 Subject: Fixing some Solaris compiler warnings (u_int->uint, adding some typecasts for pid_t variables). --- protocols/nogaim.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 5e698902..b9008af1 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -624,7 +624,7 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, } } -void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at ) +void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, uint32_t flags, time_t sent_at ) { irc_t *irc = ic->irc; char *wrapped; @@ -675,7 +675,7 @@ void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_ g_free( wrapped ); } -void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags ) +void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags ) { user_t *u; @@ -731,7 +731,7 @@ void imcb_chat_free( struct groupchat *c ) } } -void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at ) +void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at ) { struct im_connection *ic = c->ic; char *wrapped; -- cgit v1.2.3 From 83ba3e541acc3c29616fbf982b57633d303d941a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 18 Jan 2008 13:20:37 +0000 Subject: Moving imcb_chat_new() to a saner location (no code changes) and fixing default channel topic. --- protocols/nogaim.c | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index b9008af1..cfdaa454 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -691,6 +691,31 @@ void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags ) } } +struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ) +{ + struct groupchat *c; + + /* This one just creates the conversation structure, user won't see anything yet */ + + if( ic->groupchats ) + { + for( c = ic->groupchats; c->next; c = c->next ); + c = c->next = g_new0( struct groupchat, 1 ); + } + else + ic->groupchats = c = g_new0( struct groupchat, 1 ); + + c->ic = ic; + c->title = g_strdup( handle ); + c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ ); + c->topic = g_strdup_printf( "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->title ); + + if( set_getbool( &ic->irc->set, "debug" ) ) + imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle ); + + return c; +} + void imcb_chat_free( struct groupchat *c ) { struct im_connection *ic = c->ic; @@ -727,6 +752,7 @@ void imcb_chat_free( struct groupchat *c ) g_list_free( c->in_room ); g_free( c->channel ); g_free( c->title ); + g_free( c->topic ); g_free( c ); } } @@ -782,31 +808,6 @@ void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic ); } -struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ) -{ - struct groupchat *c; - - /* This one just creates the conversation structure, user won't see anything yet */ - - if( ic->groupchats ) - { - for( c = ic->groupchats; c->next; c = c->next ); - c = c->next = g_new0( struct groupchat, 1 ); - } - else - ic->groupchats = c = g_new0( struct groupchat, 1 ); - - c->ic = ic; - c->title = g_strdup( handle ); - c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ ); - c->topic = g_strdup_printf( "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->channel, c->title ); - - if( set_getbool( &ic->irc->set, "debug" ) ) - imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle ); - - return c; -} - /* buddy_chat.c */ -- cgit v1.2.3 From 31e584652a5543b87e0953525a742fb067c28e6f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 20 Jan 2008 00:17:57 +0000 Subject: Added imcb_chat_log() for chatroom system messages, so they can be displayed inside the right channel. --- protocols/nogaim.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'protocols/nogaim.c') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index cfdaa454..3ce15166 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -785,6 +785,24 @@ void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, t g_free( wrapped ); } +void imcb_chat_log( struct groupchat *c, char *format, ... ) +{ + irc_t *irc = c->ic->irc; + va_list params; + char *text; + user_t *u; + + va_start( params, format ); + text = g_strdup_vprintf( format, params ); + va_end( params ); + + u = user_find( irc, irc->mynick ); + + irc_privmsg( irc, u, "PRIVMSG", c->channel, "System message: ", text ); + + g_free( text ); +} + void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at ) { struct im_connection *ic = c->ic; -- cgit v1.2.3