diff options
Diffstat (limited to 'protocols/msn')
-rw-r--r-- | protocols/msn/msn.c | 187 | ||||
-rw-r--r-- | protocols/msn/msn.h | 26 | ||||
-rw-r--r-- | protocols/msn/msn_util.c | 40 | ||||
-rw-r--r-- | protocols/msn/ns.c | 255 | ||||
-rw-r--r-- | protocols/msn/sb.c | 89 |
5 files changed, 295 insertions, 302 deletions
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index f8686835..df04e30d 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -28,7 +28,7 @@ static char *msn_set_display_name( set_t *set, char *value ); -static void msn_acc_init( account_t *acc ) +static void msn_init( account_t *acc ) { set_t *s; @@ -38,38 +38,38 @@ static void msn_acc_init( account_t *acc ) static void msn_login( account_t *acc ) { - struct gaim_connection *gc = new_gaim_conn( acc ); + struct im_connection *ic = imcb_new( acc ); struct msn_data *md = g_new0( struct msn_data, 1 ); - gc->proto_data = md; + ic->proto_data = md; md->fd = -1; if( strchr( acc->user, '@' ) == NULL ) { - hide_login_progress( gc, "Invalid account name" ); - signoff( gc ); + imcb_error( ic, "Invalid account name" ); + imc_logout( ic, FALSE ); return; } - set_login_progress( gc, 1, "Connecting" ); + imcb_log( ic, "Connecting" ); - md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, gc ); + md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, ic ); if( md->fd < 0 ) { - hide_login_progress( gc, "Could not connect to server" ); - signoff( gc ); + imcb_error( ic, "Could not connect to server" ); + imc_logout( ic, TRUE ); return; } - md->gc = gc; + md->ic = ic; md->away_state = msn_away_state_list; - msn_connections = g_slist_append( msn_connections, gc ); + msn_connections = g_slist_append( msn_connections, ic ); } -static void msn_close( struct gaim_connection *gc ) +static void msn_logout( struct im_connection *ic ) { - struct msn_data *md = gc->proto_data; + struct msn_data *md = ic->proto_data; GSList *l; if( md ) @@ -95,7 +95,7 @@ static void msn_close( struct gaim_connection *gc ) { m = l->data; - serv_got_crap( gc, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who ); + imcb_log( ic, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who ); g_free( m->who ); g_free( m->text ); g_free( m ); @@ -110,23 +110,23 @@ static void msn_close( struct gaim_connection *gc ) g_free( md ); } - for( l = gc->permit; l; l = l->next ) + for( l = ic->permit; l; l = l->next ) g_free( l->data ); - g_slist_free( gc->permit ); + g_slist_free( ic->permit ); - for( l = gc->deny; l; l = l->next ) + for( l = ic->deny; l; l = l->next ) g_free( l->data ); - g_slist_free( gc->deny ); + g_slist_free( ic->deny ); - msn_connections = g_slist_remove( msn_connections, gc ); + msn_connections = g_slist_remove( msn_connections, ic ); } -static int msn_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away ) +static int msn_buddy_msg( struct im_connection *ic, char *who, char *message, int away ) { struct msn_switchboard *sb; - struct msn_data *md = gc->proto_data; + struct msn_data *md = ic->proto_data; - if( ( sb = msn_sb_by_handle( gc, who ) ) ) + if( ( sb = msn_sb_by_handle( ic, who ) ) ) { return( msn_sb_sendmessage( sb, message ) ); } @@ -141,7 +141,7 @@ static int msn_send_im( struct gaim_connection *gc, char *who, char *message, in m->text = g_strdup( message ); /* FIXME: *CHECK* the reliability of using spare sb's! */ - if( ( sb = msn_sb_spare( gc ) ) ) + if( ( sb = msn_sb_spare( ic ) ) ) { debug( "Trying to use a spare switchboard to message %s", who ); @@ -159,7 +159,7 @@ static int msn_send_im( struct gaim_connection *gc, char *who, char *message, in /* If we reach this line, there was no spare switchboard, so let's make one. */ g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); - if( !msn_write( gc, buf, strlen( buf ) ) ) + if( !msn_write( ic, buf, strlen( buf ) ) ) { g_free( m->who ); g_free( m->text ); @@ -179,31 +179,22 @@ static int msn_send_im( struct gaim_connection *gc, char *who, char *message, in return( 0 ); } -static GList *msn_away_states( struct gaim_connection *gc ) +static GList *msn_away_states( struct im_connection *ic ) { - GList *l = NULL; + static GList *l = NULL; int i; - for( i = 0; msn_away_state_list[i].number > -1; i ++ ) - l = g_list_append( l, (void*) msn_away_state_list[i].name ); + if( l == NULL ) + for( i = 0; msn_away_state_list[i].number > -1; i ++ ) + l = g_list_append( l, (void*) msn_away_state_list[i].name ); - return( l ); + return l; } -static char *msn_get_status_string( struct gaim_connection *gc, int number ) -{ - const struct msn_away_state *st = msn_away_state_by_number( number ); - - if( st ) - return( (char*) st->name ); - else - return( "" ); -} - -static void msn_set_away( struct gaim_connection *gc, char *state, char *message ) +static void msn_set_away( struct im_connection *ic, char *state, char *message ) { char buf[1024]; - struct msn_data *md = gc->proto_data; + struct msn_data *md = ic->proto_data; const struct msn_away_state *st; if( strcmp( state, GAIM_AWAY_CUSTOM ) == 0 ) @@ -215,43 +206,43 @@ static void msn_set_away( struct gaim_connection *gc, char *state, char *message md->away_state = st; g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, st->code ); - msn_write( gc, buf, strlen( buf ) ); + msn_write( ic, buf, strlen( buf ) ); } -static void msn_set_info( struct gaim_connection *gc, char *info ) +static void msn_set_my_name( struct im_connection *ic, char *info ) { - msn_set_display_name( set_find( &gc->acc->set, "display_name" ), info ); + msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info ); } -static void msn_get_info(struct gaim_connection *gc, char *who) +static void msn_get_info(struct im_connection *ic, char *who) { /* Just make an URL and let the user fetch the info */ - serv_got_crap( gc, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who ); + imcb_log( ic, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who ); } -static void msn_add_buddy( struct gaim_connection *gc, char *who ) +static void msn_add_buddy( struct im_connection *ic, char *who, char *group ) { - msn_buddy_list_add( gc, "FL", who, who ); + msn_buddy_list_add( ic, "FL", who, who ); } -static void msn_remove_buddy( struct gaim_connection *gc, char *who, char *group ) +static void msn_remove_buddy( struct im_connection *ic, char *who, char *group ) { - msn_buddy_list_remove( gc, "FL", who ); + msn_buddy_list_remove( ic, "FL", who ); } -static int msn_chat_send( struct gaim_connection *gc, int id, char *message ) +static void msn_chat_msg( struct groupchat *c, char *message, int flags ) { - struct msn_switchboard *sb = msn_sb_by_id( gc, id ); + struct msn_switchboard *sb = msn_sb_by_chat( c ); if( sb ) - return( msn_sb_sendmessage( sb, message ) ); - else - return( 0 ); + msn_sb_sendmessage( sb, message ); + /* FIXME: Error handling (although this can't happen unless something's + already severely broken) disappeared here! */ } -static void msn_chat_invite( struct gaim_connection *gc, int id, char *msg, char *who ) +static void msn_chat_invite( struct groupchat *c, char *msg, char *who ) { - struct msn_switchboard *sb = msn_sb_by_id( gc, id ); + struct msn_switchboard *sb = msn_sb_by_chat( c ); char buf[1024]; if( sb ) @@ -261,39 +252,35 @@ static void msn_chat_invite( struct gaim_connection *gc, int id, char *msg, char } } -static void msn_chat_leave( struct gaim_connection *gc, int id ) +static void msn_chat_leave( struct groupchat *c ) { - struct msn_switchboard *sb = msn_sb_by_id( gc, id ); + struct msn_switchboard *sb = msn_sb_by_chat( c ); if( sb ) msn_sb_write( sb, "OUT\r\n", 5 ); } -static int msn_chat_open( struct gaim_connection *gc, char *who ) +static struct groupchat *msn_chat_with( struct im_connection *ic, char *who ) { struct msn_switchboard *sb; - struct msn_data *md = gc->proto_data; + struct msn_data *md = ic->proto_data; char buf[1024]; - if( ( sb = msn_sb_by_handle( gc, who ) ) ) + if( ( sb = msn_sb_by_handle( ic, who ) ) ) { debug( "Converting existing switchboard to %s to a groupchat", who ); - msn_sb_to_chat( sb ); - return( 1 ); + return msn_sb_to_chat( sb ); } else { struct msn_message *m; - if( ( sb = msn_sb_spare( gc ) ) ) + if( ( sb = msn_sb_spare( ic ) ) ) { debug( "Trying to reuse an existing switchboard as a groupchat with %s", who ); g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, who ); if( msn_sb_write( sb, buf, strlen( buf ) ) ) - { - msn_sb_to_chat( sb ); - return( 1 ); - } + return msn_sb_to_chat( sb ); } /* If the stuff above failed for some reason: */ @@ -301,7 +288,7 @@ static int msn_chat_open( struct gaim_connection *gc, char *who ) /* Request a new switchboard. */ g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); - if( !msn_write( gc, buf, strlen( buf ) ) ) + if( !msn_write( ic, buf, strlen( buf ) ) ) return( 0 ); /* Create a magic message. This is quite hackish, but who cares? :-P */ @@ -312,49 +299,50 @@ static int msn_chat_open( struct gaim_connection *gc, char *who ) /* Queue the magic message and cross your fingers. */ md->msgq = g_slist_append( md->msgq, m ); - return( 1 ); + /* FIXME: Can I try to return something here already? */ + return NULL; } - return( 0 ); + return NULL; } -static void msn_keepalive( struct gaim_connection *gc ) +static void msn_keepalive( struct im_connection *ic ) { - msn_write( gc, "PNG\r\n", strlen( "PNG\r\n" ) ); + msn_write( ic, "PNG\r\n", strlen( "PNG\r\n" ) ); } -static void msn_add_permit( struct gaim_connection *gc, char *who ) +static void msn_add_permit( struct im_connection *ic, char *who ) { - msn_buddy_list_add( gc, "AL", who, who ); + msn_buddy_list_add( ic, "AL", who, who ); } -static void msn_rem_permit( struct gaim_connection *gc, char *who ) +static void msn_rem_permit( struct im_connection *ic, char *who ) { - msn_buddy_list_remove( gc, "AL", who ); + msn_buddy_list_remove( ic, "AL", who ); } -static void msn_add_deny( struct gaim_connection *gc, char *who ) +static void msn_add_deny( struct im_connection *ic, char *who ) { struct msn_switchboard *sb; - msn_buddy_list_add( gc, "BL", who, who ); + msn_buddy_list_add( ic, "BL", who, who ); /* If there's still a conversation with this person, close it. */ - if( ( sb = msn_sb_by_handle( gc, who ) ) ) + if( ( sb = msn_sb_by_handle( ic, who ) ) ) { msn_sb_destroy( sb ); } } -static void msn_rem_deny( struct gaim_connection *gc, char *who ) +static void msn_rem_deny( struct im_connection *ic, char *who ) { - msn_buddy_list_remove( gc, "BL", who ); + msn_buddy_list_remove( ic, "BL", who ); } -static int msn_send_typing( struct gaim_connection *gc, char *who, int typing ) +static int msn_send_typing( struct im_connection *ic, char *who, int typing ) { - if( typing ) - return( msn_send_im( gc, who, TYPING_NOTIFICATION_MESSAGE, strlen( TYPING_NOTIFICATION_MESSAGE ), 0 ) ); + if( typing & OPT_TYPING ) + return( msn_buddy_msg( ic, who, TYPING_NOTIFICATION_MESSAGE, 0 ) ); else return( 1 ); } @@ -362,26 +350,26 @@ static int msn_send_typing( struct gaim_connection *gc, char *who, int typing ) static char *msn_set_display_name( set_t *set, char *value ) { account_t *acc = set->data; - struct gaim_connection *gc = acc->gc; + struct im_connection *ic = acc->ic; struct msn_data *md; char buf[1024], *fn; /* Double-check. */ - if( gc == NULL ) + if( ic == NULL ) return NULL; - md = gc->proto_data; + md = ic->proto_data; if( strlen( value ) > 129 ) { - serv_got_crap( gc, "Maximum name length exceeded" ); + imcb_log( ic, "Maximum name length exceeded" ); return NULL; } fn = msn_http_encode( value ); - g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn ); - msn_write( gc, buf, strlen( buf ) ); + g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn ); + msn_write( ic, buf, strlen( buf ) ); g_free( fn ); /* Returning NULL would be better, because the server still has to @@ -390,26 +378,25 @@ static char *msn_set_display_name( set_t *set, char *value ) return value; } -void msn_init() +void msn_initmodule() { struct prpl *ret = g_new0(struct prpl, 1); ret->name = "msn"; ret->login = msn_login; - ret->acc_init = msn_acc_init; - ret->close = msn_close; - ret->send_im = msn_send_im; + ret->init = msn_init; + ret->logout = msn_logout; + ret->buddy_msg = msn_buddy_msg; ret->away_states = msn_away_states; - ret->get_status_string = msn_get_status_string; ret->set_away = msn_set_away; - ret->set_info = msn_set_info; ret->get_info = msn_get_info; + ret->set_my_name = msn_set_my_name; ret->add_buddy = msn_add_buddy; ret->remove_buddy = msn_remove_buddy; - ret->chat_send = msn_chat_send; + ret->chat_msg = msn_chat_msg; ret->chat_invite = msn_chat_invite; ret->chat_leave = msn_chat_leave; - ret->chat_open = msn_chat_open; + ret->chat_with = msn_chat_with; ret->keepalive = msn_keepalive; ret->add_permit = msn_add_permit; ret->rem_permit = msn_rem_permit; diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index b4777d41..721466d6 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -56,7 +56,7 @@ struct msn_data { - struct gaim_connection *gc; + struct im_connection *ic; int fd; struct msn_handler_data *handler; @@ -74,7 +74,7 @@ struct msn_data struct msn_switchboard { - struct gaim_connection *gc; + struct im_connection *ic; int fd; gint inp; @@ -88,7 +88,7 @@ struct msn_switchboard GSList *msgq; char *who; - struct conversation *chat; + struct groupchat *chat; }; struct msn_away_state @@ -148,11 +148,11 @@ GSList *msn_switchboards; gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ); /* msn_util.c */ -int msn_write( struct gaim_connection *gc, char *s, int len ); -int msn_logged_in( struct gaim_connection *gc ); -int msn_buddy_list_add( struct gaim_connection *gc, char *list, char *who, char *realname ); -int msn_buddy_list_remove( struct gaim_connection *gc, char *list, char *who ); -void msn_buddy_ask( struct gaim_connection *gc, char *handle, char *realname ); +int msn_write( struct im_connection *ic, char *s, int len ); +int msn_logged_in( struct im_connection *ic ); +int msn_buddy_list_add( struct im_connection *ic, char *list, char *who, char *realname ); +int msn_buddy_list_remove( struct im_connection *ic, char *list, char *who ); +void msn_buddy_ask( struct im_connection *ic, char *handle, char *realname ); char *msn_findheader( char *text, char *header, int len ); char **msn_linesplit( char *line ); int msn_handler( struct msn_handler_data *h ); @@ -166,11 +166,11 @@ const struct msn_status_code *msn_status_by_number( int number ); /* sb.c */ int msn_sb_write( struct msn_switchboard *sb, char *s, int len ); -struct msn_switchboard *msn_sb_create( struct gaim_connection *gc, char *host, int port, char *key, int session ); -struct msn_switchboard *msn_sb_by_handle( struct gaim_connection *gc, char *handle ); -struct msn_switchboard *msn_sb_by_id( struct gaim_connection *gc, int id ); -struct msn_switchboard *msn_sb_spare( struct gaim_connection *gc ); +struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session ); +struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle ); +struct msn_switchboard *msn_sb_by_chat( struct groupchat *c ); +struct msn_switchboard *msn_sb_spare( struct im_connection *ic ); int msn_sb_sendmessage( struct msn_switchboard *sb, char *text ); -void msn_sb_to_chat( struct msn_switchboard *sb ); +struct groupchat *msn_sb_to_chat( struct msn_switchboard *sb ); void msn_sb_destroy( struct msn_switchboard *sb ); gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ); diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index ff4c148c..c9eb5ee2 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -27,38 +27,38 @@ #include "msn.h" #include <ctype.h> -int msn_write( struct gaim_connection *gc, char *s, int len ) +int msn_write( struct im_connection *ic, char *s, int len ) { - struct msn_data *md = gc->proto_data; + struct msn_data *md = ic->proto_data; int st; st = write( md->fd, s, len ); if( st != len ) { - hide_login_progress_error( gc, "Short write() to main server" ); - signoff( gc ); + imcb_error( ic, "Short write() to main server" ); + imc_logout( ic, TRUE ); return( 0 ); } return( 1 ); } -int msn_logged_in( struct gaim_connection *gc ) +int msn_logged_in( struct im_connection *ic ) { - account_online( gc ); + imcb_connected( ic ); return( 0 ); } -int msn_buddy_list_add( struct gaim_connection *gc, char *list, char *who, char *realname_ ) +int msn_buddy_list_add( struct im_connection *ic, char *list, char *who, char *realname_ ) { - struct msn_data *md = gc->proto_data; + struct msn_data *md = ic->proto_data; char buf[1024], *realname; realname = msn_http_encode( realname_ ); g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s\r\n", ++md->trId, list, who, realname ); - if( msn_write( gc, buf, strlen( buf ) ) ) + if( msn_write( ic, buf, strlen( buf ) ) ) { g_free( realname ); @@ -70,13 +70,13 @@ int msn_buddy_list_add( struct gaim_connection *gc, char *list, char *who, char return( 0 ); } -int msn_buddy_list_remove( struct gaim_connection *gc, char *list, char *who ) +int msn_buddy_list_remove( struct im_connection *ic, char *list, char *who ) { - struct msn_data *md = gc->proto_data; + struct msn_data *md = ic->proto_data; char buf[1024]; g_snprintf( buf, sizeof( buf ), "REM %d %s %s\r\n", ++md->trId, list, who ); - if( msn_write( gc, buf, strlen( buf ) ) ) + if( msn_write( ic, buf, strlen( buf ) ) ) return( 1 ); return( 0 ); @@ -84,17 +84,17 @@ int msn_buddy_list_remove( struct gaim_connection *gc, char *list, char *who ) struct msn_buddy_ask_data { - struct gaim_connection *gc; + struct im_connection *ic; char *handle; char *realname; }; static void msn_buddy_ask_yes( gpointer w, struct msn_buddy_ask_data *bla ) { - msn_buddy_list_add( bla->gc, "AL", bla->handle, bla->realname ); + msn_buddy_list_add( bla->ic, "AL", bla->handle, bla->realname ); - if( find_buddy( bla->gc, bla->handle ) == NULL ) - show_got_added( bla->gc, bla->handle, NULL ); + if( imcb_find_buddy( bla->ic, bla->handle ) == NULL ) + imcb_ask_add( bla->ic, bla->handle, NULL ); g_free( bla->handle ); g_free( bla->realname ); @@ -103,26 +103,26 @@ static void msn_buddy_ask_yes( gpointer w, struct msn_buddy_ask_data *bla ) static void msn_buddy_ask_no( gpointer w, struct msn_buddy_ask_data *bla ) { - msn_buddy_list_add( bla->gc, "BL", bla->handle, bla->realname ); + msn_buddy_list_add( bla->ic, "BL", bla->handle, bla->realname ); g_free( bla->handle ); g_free( bla->realname ); g_free( bla ); } -void msn_buddy_ask( struct gaim_connection *gc, char *handle, char *realname ) +void msn_buddy_ask( struct im_connection *ic, char *handle, char *realname ) { struct msn_buddy_ask_data *bla = g_new0( struct msn_buddy_ask_data, 1 ); char buf[1024]; - bla->gc = gc; + bla->ic = ic; bla->handle = g_strdup( handle ); bla->realname = g_strdup( realname ); g_snprintf( buf, sizeof( buf ), "The user %s (%s) wants to add you to his/her buddy list.", handle, realname ); - do_ask_dialog( gc, buf, bla, msn_buddy_ask_yes, msn_buddy_ask_no ); + imcb_ask( ic, buf, bla, msn_buddy_ask_yes, msn_buddy_ask_no ); } char *msn_findheader( char *text, char *header, int len ) diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 9774f3e2..9bd7f152 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -37,26 +37,26 @@ static void msn_auth_got_passport_id( struct passport_reply *rep ); gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) { - struct gaim_connection *gc = data; + struct im_connection *ic = data; struct msn_data *md; char s[1024]; - if( !g_slist_find( msn_connections, gc ) ) + if( !g_slist_find( msn_connections, ic ) ) return FALSE; if( source == -1 ) { - hide_login_progress( gc, "Could not connect to server" ); - signoff( gc ); + imcb_error( ic, "Could not connect to server" ); + imc_logout( ic, TRUE ); return FALSE; } - md = gc->proto_data; + md = ic->proto_data; if( !md->handler ) { md->handler = g_new0( struct msn_handler_data, 1 ); - md->handler->data = gc; + md->handler->data = ic; md->handler->exec_command = msn_ns_command; md->handler->exec_message = msn_ns_message; } @@ -72,10 +72,10 @@ gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) md->handler->rxq = g_new0( char, 1 ); g_snprintf( s, sizeof( s ), "VER %d MSNP8 CVR0\r\n", ++md->trId ); - if( msn_write( gc, s, strlen( s ) ) ) + if( msn_write( ic, s, strlen( s ) ) ) { - gc->inpa = b_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, gc ); - set_login_progress( gc, 1, "Connected to server, waiting for reply" ); + ic->inpa = b_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, ic ); + imcb_log( ic, "Connected to server, waiting for reply" ); } return FALSE; @@ -83,13 +83,13 @@ gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond ) { - struct gaim_connection *gc = data; - struct msn_data *md = gc->proto_data; + struct im_connection *ic = data; + struct msn_data *md = ic->proto_data; if( msn_handler( md->handler ) == -1 ) /* Don't do this on ret == 0, it's already done then. */ { - hide_login_progress( gc, "Error while reading from server" ); - signoff( gc ); + imcb_error( ic, "Error while reading from server" ); + imc_logout( ic, TRUE ); return FALSE; } @@ -99,8 +99,8 @@ static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition c static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { - struct gaim_connection *gc = data; - struct msn_data *md = gc->proto_data; + struct im_connection *ic = data; + struct msn_data *md = ic->proto_data; char buf[1024]; if( num_parts == 0 ) @@ -113,20 +113,20 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { if( cmd[2] && strncmp( cmd[2], "MSNP8", 5 ) != 0 ) { - hide_login_progress( gc, "Unsupported protocol" ); - signoff( gc ); + imcb_error( ic, "Unsupported protocol" ); + imc_logout( ic, FALSE ); return( 0 ); } g_snprintf( buf, sizeof( buf ), "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s\r\n", - ++md->trId, gc->username ); - return( msn_write( gc, buf, strlen( buf ) ) ); + ++md->trId, ic->acc->user ); + return( msn_write( ic, buf, strlen( buf ) ) ); } else if( strcmp( cmd[0], "CVR" ) == 0 ) { /* We don't give a damn about the information we just received */ - g_snprintf( buf, sizeof( buf ), "USR %d TWN I %s\r\n", ++md->trId, gc->username ); - return( msn_write( gc, buf, strlen( buf ) ) ); + g_snprintf( buf, sizeof( buf ), "USR %d TWN I %s\r\n", ++md->trId, ic->acc->user ); + return( msn_write( ic, buf, strlen( buf ) ) ); } else if( strcmp( cmd[0], "XFR" ) == 0 ) { @@ -135,24 +135,24 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts == 6 && strcmp( cmd[2], "NS" ) == 0 ) { - b_event_remove( gc->inpa ); - gc->inpa = 0; + b_event_remove( ic->inpa ); + ic->inpa = 0; closesocket( md->fd ); server = strchr( cmd[3], ':' ); if( !server ) { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } *server = 0; port = atoi( server + 1 ); server = cmd[3]; - set_login_progress( gc, 1, "Transferring to other server" ); + imcb_log( ic, "Transferring to other server" ); - md->fd = proxy_connect( server, port, msn_ns_connected, gc ); + md->fd = proxy_connect( server, port, msn_ns_connected, ic ); } else if( num_parts == 6 && strcmp( cmd[2], "SB" ) == 0 ) { @@ -161,8 +161,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) server = strchr( cmd[3], ':' ); if( !server ) { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } *server = 0; @@ -171,13 +171,13 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( strcmp( cmd[4], "CKI" ) != 0 ) { - hide_login_progress_error( gc, "Unknown authentication method for switchboard" ); - signoff( gc ); + imcb_error( ic, "Unknown authentication method for switchboard" ); + imc_logout( ic, TRUE ); return( 0 ); } debug( "Connecting to a new switchboard with key %s", cmd[5] ); - sb = msn_sb_create( gc, server, port, cmd[5], MSN_SB_NEW ); + sb = msn_sb_create( ic, server, port, cmd[5], MSN_SB_NEW ); if( md->msgq ) { @@ -203,8 +203,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } } @@ -213,10 +213,10 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts == 5 && strcmp( cmd[2], "TWN" ) == 0 && strcmp( cmd[3], "S" ) == 0 ) { /* Time for some Passport black magic... */ - if( !passport_get_id( msn_auth_got_passport_id, gc, gc->username, gc->password, cmd[4] ) ) + if( !passport_get_id( msn_auth_got_passport_id, ic, ic->acc->user, ic->acc->pass, cmd[4] ) ) { - hide_login_progress_error( gc, "Error while contacting Passport server" ); - signoff( gc ); + imcb_error( ic, "Error while contacting Passport server" ); + imc_logout( ic, TRUE ); return( 0 ); } } @@ -226,24 +226,24 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) http_decode( cmd[4] ); - strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) ); - gc->displayname[sizeof(gc->displayname)-1] = 0; + strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); + ic->displayname[sizeof(ic->displayname)-1] = 0; - if( ( s = set_find( &gc->acc->set, "display_name" ) ) ) + if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) { g_free( s->value ); s->value = g_strdup( cmd[4] ); } - set_login_progress( gc, 1, "Authenticated, getting buddy list" ); + imcb_log( ic, "Authenticated, getting buddy list" ); g_snprintf( buf, sizeof( buf ), "SYN %d 0\r\n", ++md->trId ); - return( msn_write( gc, buf, strlen( buf ) ) ); + return( msn_write( ic, buf, strlen( buf ) ) ); } else { - hide_login_progress( gc, "Unknown authentication type" ); - signoff( gc ); + imcb_error( ic, "Unknown authentication type" ); + imc_logout( ic, FALSE ); return( 0 ); } } @@ -251,8 +251,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { if( num_parts != 4 ) { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } @@ -260,8 +260,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( md->handler->msglen <= 0 ) { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } } @@ -275,14 +275,14 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) md->grouplist = g_new0( char *, md->groupcount ); if( !*cmd[3] || md->buddycount == 0 ) - msn_logged_in( gc ); + msn_logged_in( ic ); } else { /* Hrrm... This SYN reply doesn't really look like something we expected. Let's assume everything is okay. */ - msn_logged_in( gc ); + msn_logged_in( ic ); } } else if( strcmp( cmd[0], "LST" ) == 0 ) @@ -291,8 +291,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts != 4 && num_parts != 5 ) { - hide_login_progress( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } @@ -304,36 +304,37 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) char *group = NULL; int num; - if( cmd[4] != NULL && sscanf( cmd[4], "%d", &num ) == 1 ) + if( cmd[4] != NULL && sscanf( cmd[4], "%d", &num ) == 1 && num < md->groupcount ) group = md->grouplist[num]; - add_buddy( gc, group, cmd[1], cmd[2] ); + imcb_add_buddy( ic, cmd[1], group ); + imcb_rename_buddy( ic, cmd[1], cmd[2] ); } if( list & 2 ) /* AL */ { - gc->permit = g_slist_append( gc->permit, g_strdup( cmd[1] ) ); + ic->permit = g_slist_append( ic->permit, g_strdup( cmd[1] ) ); } if( list & 4 ) /* BL */ { - gc->deny = g_slist_append( gc->deny, g_strdup( cmd[1] ) ); + ic->deny = g_slist_append( ic->deny, g_strdup( cmd[1] ) ); } if( list & 8 ) /* RL */ { if( ( list & 6 ) == 0 ) - msn_buddy_ask( gc, cmd[1], cmd[2] ); + msn_buddy_ask( ic, cmd[1], cmd[2] ); } if( --md->buddycount == 0 ) { - if( gc->flags & OPT_LOGGED_IN ) + if( ic->flags & OPT_LOGGED_IN ) { - serv_got_crap( gc, "Successfully transferred to different server" ); + imcb_log( ic, "Successfully transferred to different server" ); g_snprintf( buf, sizeof( buf ), "CHG %d %s %d\r\n", ++md->trId, md->away_state->code, 0 ); - return( msn_write( gc, buf, strlen( buf ) ) ); + return( msn_write( ic, buf, strlen( buf ) ) ); } else { - msn_logged_in( gc ); + msn_logged_in( ic ); } } } @@ -343,8 +344,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts != 4 ) { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } @@ -362,8 +363,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts != 3 ) { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } @@ -376,7 +377,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) for( i = 0; i < 16; i ++ ) g_snprintf( buf + strlen( buf ), 3, "%02x", digest[i] ); - return( msn_write( gc, buf, strlen( buf ) ) ); + return( msn_write( ic, buf, strlen( buf ) ) ); } else if( strcmp( cmd[0], "ILN" ) == 0 ) { @@ -384,13 +385,13 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts != 6 ) { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } http_decode( cmd[4] ); - serv_buddy_rename( gc, cmd[3], cmd[4] ); + imcb_rename_buddy( ic, cmd[3], cmd[4] ); st = msn_away_state_by_code( cmd[2] ); if( !st ) @@ -399,12 +400,13 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) st = msn_away_state_list; } - serv_got_update( gc, cmd[3], 1, 0, 0, 0, st->number, 0 ); + imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN | + ( st->number ? OPT_AWAY : 0 ), st->name, NULL ); } else if( strcmp( cmd[0], "FLN" ) == 0 ) { if( cmd[1] ) - serv_got_update( gc, cmd[1], 0, 0, 0, 0, 0, 0 ); + imcb_buddy_status( ic, cmd[1], 0, NULL, NULL ); } else if( strcmp( cmd[0], "NLN" ) == 0 ) { @@ -412,13 +414,13 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts != 5 ) { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } http_decode( cmd[3] ); - serv_buddy_rename( gc, cmd[2], cmd[3] ); + imcb_rename_buddy( ic, cmd[2], cmd[3] ); st = msn_away_state_by_code( cmd[1] ); if( !st ) @@ -427,7 +429,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) st = msn_away_state_list; } - serv_got_update( gc, cmd[2], 1, 0, 0, 0, st->number, 0 ); + imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN | + ( st->number ? OPT_AWAY : 0 ), st->name, NULL ); } else if( strcmp( cmd[0], "RNG" ) == 0 ) { @@ -437,8 +440,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts != 7 ) { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } @@ -447,8 +450,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) server = strchr( cmd[2], ':' ); if( !server ) { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } *server = 0; @@ -457,14 +460,14 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( strcmp( cmd[3], "CKI" ) != 0 ) { - hide_login_progress_error( gc, "Unknown authentication method for switchboard" ); - signoff( gc ); + imcb_error( ic, "Unknown authentication method for switchboard" ); + imc_logout( ic, TRUE ); return( 0 ); } debug( "Got a call from %s (session %d). Key = %s", cmd[5], session, cmd[4] ); - sb = msn_sb_create( gc, server, port, cmd[4], session ); + sb = msn_sb_create( ic, server, port, cmd[4], session ); sb->who = g_strdup( cmd[5] ); } else if( strcmp( cmd[0], "ADD" ) == 0 ) @@ -477,60 +480,69 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( strchr( cmd[4], '@' ) == NULL ) { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); - return( 0 ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); + return 0; } - /* We got added by someone. If we don't have this person in permit/deny yet, inform the user. */ - for( l = gc->permit; l; l = l->next ) + /* We got added by someone. If we don't have this + person in permit/deny yet, inform the user. */ + for( l = ic->permit; l; l = l->next ) if( g_strcasecmp( l->data, cmd[4] ) == 0 ) - return( 1 ); + return 1; - for( l = gc->deny; l; l = l->next ) + for( l = ic->deny; l; l = l->next ) if( g_strcasecmp( l->data, cmd[4] ) == 0 ) - return( 1 ); + return 1; - msn_buddy_ask( gc, cmd[4], cmd[5] ); + msn_buddy_ask( ic, cmd[4], cmd[5] ); + } + else if( num_parts >= 6 && strcmp( cmd[2], "FL" ) == 0 ) + { + http_decode( cmd[5] ); + imcb_add_buddy( ic, cmd[4], NULL ); + imcb_rename_buddy( ic, cmd[4], cmd[5] ); } } else if( strcmp( cmd[0], "OUT" ) == 0 ) { + int allow_reconnect = TRUE; + if( cmd[1] && strcmp( cmd[1], "OTH" ) == 0 ) { - hide_login_progress_error( gc, "Someone else logged in with your account" ); - gc->wants_to_die = 1; + imcb_error( ic, "Someone else logged in with your account" ); + allow_reconnect = FALSE; } else if( cmd[1] && strcmp( cmd[1], "SSD" ) == 0 ) { - hide_login_progress_error( gc, "Terminating session because of server shutdown" ); + imcb_error( ic, "Terminating session because of server shutdown" ); } else { - hide_login_progress_error( gc, "Session terminated by remote server (reason unknown)" ); + imcb_error( ic, "Session terminated by remote server (reason unknown)" ); } - signoff( gc ); + imc_logout( ic, allow_reconnect ); return( 0 ); } else if( strcmp( cmd[0], "REA" ) == 0 ) { if( num_parts != 5 ) { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } - if( g_strcasecmp( cmd[3], gc->username ) == 0 ) + if( g_strcasecmp( cmd[3], ic->acc->user ) == 0 ) { set_t *s; http_decode( cmd[4] ); - strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) ); - gc->displayname[sizeof(gc->displayname)-1] = 0; + strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); + ic->displayname[sizeof(ic->displayname)-1] = 0; - if( ( s = set_find( &gc->acc->set, "display_name" ) ) ) + if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) { g_free( s->value ); s->value = g_strdup( cmd[4] ); @@ -540,19 +552,19 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { /* This is not supposed to happen, but let's handle it anyway... */ http_decode( cmd[4] ); - serv_buddy_rename( gc, cmd[3], cmd[4] ); + imcb_rename_buddy( ic, cmd[3], cmd[4] ); } } else if( strcmp( cmd[0], "IPG" ) == 0 ) { - do_error_dialog( gc, "Received IPG command, we don't handle them yet.", "MSN" ); + imcb_error( ic, "Received IPG command, we don't handle them yet." ); md->handler->msglen = atoi( cmd[1] ); if( md->handler->msglen <= 0 ) { - hide_login_progress_error( gc, "Syntax error" ); - signoff( gc ); + imcb_error( ic, "Syntax error" ); + imc_logout( ic, TRUE ); return( 0 ); } } @@ -561,12 +573,11 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) int num = atoi( cmd[0] ); const struct msn_status_code *err = msn_status_by_number( num ); - g_snprintf( buf, sizeof( buf ), "Error reported by MSN server: %s", err->text ); - do_error_dialog( gc, buf, "MSN" ); + imcb_error( ic, "Error reported by MSN server: %s", err->text ); if( err->flags & STATUS_FATAL ) { - signoff( gc ); + imc_logout( ic, TRUE ); return( 0 ); } } @@ -580,7 +591,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts ) { - struct gaim_connection *gc = data; + struct im_connection *ic = data; char *body; int blen = 0; @@ -616,7 +627,7 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int if( mtype && strcmp( mtype, "1" ) == 0 ) { if( arg1 ) - serv_got_crap( gc, "The server is going down for maintenance in %s minutes.", arg1 ); + imcb_log( ic, "The server is going down for maintenance in %s minutes.", arg1 ); } if( arg1 ) g_free( arg1 ); @@ -633,7 +644,7 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int if( inbox && folders ) { - serv_got_crap( gc, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); + imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); } } else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 ) @@ -643,7 +654,7 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int if( from && fromname ) { - serv_got_crap( gc, "Received an e-mail message from %s <%s>.", fromname, from ); + imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); } } else if( g_strncasecmp( ct, "text/x-msmsgsactivemailnotification", 35 ) == 0 ) @@ -664,26 +675,20 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int static void msn_auth_got_passport_id( struct passport_reply *rep ) { - struct gaim_connection *gc = rep->data; - struct msn_data *md = gc->proto_data; + struct im_connection *ic = rep->data; + struct msn_data *md = ic->proto_data; char *key = rep->result; char buf[1024]; if( key == NULL ) { - char *err; - - err = g_strdup_printf( "Error during Passport authentication (%s)", - rep->error_string ? rep->error_string : "Unknown error" ); - - hide_login_progress( gc, err ); - signoff( gc ); - - g_free( err ); + imcb_error( ic, "Error during Passport authentication (%s)", + rep->error_string ? rep->error_string : "Unknown error" ); + imc_logout( ic, TRUE ); } else { g_snprintf( buf, sizeof( buf ), "USR %d TWN S %s\r\n", ++md->trId, key ); - msn_write( gc, buf, strlen( buf ) ); + msn_write( ic, buf, strlen( buf ) ); } } diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index 7ec340bd..1693cb95 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -47,9 +47,9 @@ int msn_sb_write( struct msn_switchboard *sb, char *s, int len ) return( 1 ); } -struct msn_switchboard *msn_sb_create( struct gaim_connection *gc, char *host, int port, char *key, int session ) +struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session ) { - struct msn_data *md = gc->proto_data; + struct msn_data *md = ic->proto_data; struct msn_switchboard *sb = g_new0( struct msn_switchboard, 1 ); sb->fd = proxy_connect( host, port, msn_sb_connected, sb ); @@ -59,7 +59,7 @@ struct msn_switchboard *msn_sb_create( struct gaim_connection *gc, char *host, i return( NULL ); } - sb->gc = gc; + sb->ic = ic; sb->key = g_strdup( key ); sb->session = session; @@ -69,9 +69,9 @@ struct msn_switchboard *msn_sb_create( struct gaim_connection *gc, char *host, i return( sb ); } -struct msn_switchboard *msn_sb_by_handle( struct gaim_connection *gc, char *handle ) +struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle ) { - struct msn_data *md = gc->proto_data; + struct msn_data *md = ic->proto_data; struct msn_switchboard *sb; GSList *l; @@ -85,25 +85,25 @@ struct msn_switchboard *msn_sb_by_handle( struct gaim_connection *gc, char *hand return( NULL ); } -struct msn_switchboard *msn_sb_by_id( struct gaim_connection *gc, int id ) +struct msn_switchboard *msn_sb_by_chat( struct groupchat *c ) { - struct msn_data *md = gc->proto_data; + struct msn_data *md = c->ic->proto_data; struct msn_switchboard *sb; GSList *l; for( l = md->switchboards; l; l = l->next ) { sb = l->data; - if( sb->chat && sb->chat->id == id ) + if( sb->chat == c ) return( sb ); } return( NULL ); } -struct msn_switchboard *msn_sb_spare( struct gaim_connection *gc ) +struct msn_switchboard *msn_sb_spare( struct im_connection *ic ) { - struct msn_data *md = gc->proto_data; + struct msn_data *md = ic->proto_data; struct msn_switchboard *sb; GSList *l; @@ -141,9 +141,9 @@ int msn_sb_sendmessage( struct msn_switchboard *sb, char *text ) } else { - i = strlen( MSN_TYPING_HEADERS ) + strlen( sb->gc->username ); + i = strlen( MSN_TYPING_HEADERS ) + strlen( sb->ic->acc->user ); buf = g_new0( char, i ); - i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->gc->username ); + i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->ic->acc->user ); } /* Build the final packet (MSG command + the message). */ @@ -176,18 +176,18 @@ int msn_sb_sendmessage( struct msn_switchboard *sb, char *text ) } } -void msn_sb_to_chat( struct msn_switchboard *sb ) +struct groupchat *msn_sb_to_chat( struct msn_switchboard *sb ) { - struct gaim_connection *gc = sb->gc; + struct im_connection *ic = sb->ic; char buf[1024]; /* Create the groupchat structure. */ g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session ); - sb->chat = serv_got_joined_chat( gc, ++msn_chat_id, buf ); + sb->chat = imcb_chat_new( ic, buf ); /* Populate the channel. */ - if( sb->who ) add_chat_buddy( sb->chat, sb->who ); - add_chat_buddy( sb->chat, gc->username ); + if( sb->who ) imcb_chat_add_buddy( sb->chat, sb->who ); + imcb_chat_add_buddy( sb->chat, ic->acc->user ); /* And make sure the switchboard doesn't look like a regular chat anymore. */ if( sb->who ) @@ -195,12 +195,14 @@ void msn_sb_to_chat( struct msn_switchboard *sb ) g_free( sb->who ); sb->who = NULL; } + + return sb->chat; } void msn_sb_destroy( struct msn_switchboard *sb ) { - struct gaim_connection *gc = sb->gc; - struct msn_data *md = gc->proto_data; + struct im_connection *ic = sb->ic; + struct msn_data *md = ic->proto_data; debug( "Destroying switchboard: %s", sb->who ? sb->who : sb->key ? sb->key : "" ); @@ -219,7 +221,7 @@ void msn_sb_destroy( struct msn_switchboard *sb ) } g_slist_free( sb->msgq ); - serv_got_crap( gc, "Warning: Closing down MSN switchboard connection with " + imcb_log( ic, "Warning: Closing down MSN switchboard connection with " "unsent message to %s, you'll have to resend it.", sb->who ? sb->who : "(unknown)" ); } @@ -229,7 +231,7 @@ void msn_sb_destroy( struct msn_switchboard *sb ) if( sb->chat ) { - serv_got_chat_left( gc, sb->chat->id ); + imcb_chat_removed( sb->chat ); } if( sb->handler ) @@ -250,7 +252,7 @@ void msn_sb_destroy( struct msn_switchboard *sb ) gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ) { struct msn_switchboard *sb = data; - struct gaim_connection *gc; + struct im_connection *ic; struct msn_data *md; char buf[1024]; @@ -258,8 +260,8 @@ gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ) if( !g_slist_find( msn_switchboards, sb ) ) return FALSE; - gc = sb->gc; - md = gc->proto_data; + ic = sb->ic; + md = ic->proto_data; if( source != sb->fd ) { @@ -277,9 +279,9 @@ gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ) sb->handler->exec_message = msn_sb_message; if( sb->session == MSN_SB_NEW ) - g_snprintf( buf, sizeof( buf ), "USR %d %s %s\r\n", ++sb->trId, gc->username, sb->key ); + g_snprintf( buf, sizeof( buf ), "USR %d %s %s\r\n", ++sb->trId, ic->acc->user, sb->key ); else - g_snprintf( buf, sizeof( buf ), "ANS %d %s %s %d\r\n", ++sb->trId, gc->username, sb->key, sb->session ); + g_snprintf( buf, sizeof( buf ), "ANS %d %s %s %d\r\n", ++sb->trId, ic->acc->user, sb->key, sb->session ); if( msn_sb_write( sb, buf, strlen( buf ) ) ) sb->inp = b_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb ); @@ -307,7 +309,7 @@ static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition c static int msn_sb_command( gpointer data, char **cmd, int num_parts ) { struct msn_switchboard *sb = data; - struct gaim_connection *gc = sb->gc; + struct im_connection *ic = sb->ic; char buf[1024]; if( !num_parts ) @@ -318,8 +320,8 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts ) if( strcmp( cmd[0], "XFR" ) == 0 ) { - hide_login_progress_error( gc, "Received an XFR from a switchboard server, unable to comply! This is likely to be a bug, please report it!" ); - signoff( gc ); + imcb_error( ic, "Received an XFR from a switchboard server, unable to comply! This is likely to be a bug, please report it!" ); + imc_logout( ic, TRUE ); return( 0 ); } else if( strcmp( cmd[0], "USR" ) == 0 ) @@ -371,17 +373,17 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts ) if( num == 1 ) { g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session ); - sb->chat = serv_got_joined_chat( gc, ++msn_chat_id, buf ); + sb->chat = imcb_chat_new( ic, buf ); g_free( sb->who ); sb->who = NULL; } - add_chat_buddy( sb->chat, cmd[4] ); + imcb_chat_add_buddy( sb->chat, cmd[4] ); if( num == tot ) { - add_chat_buddy( sb->chat, gc->username ); + imcb_chat_add_buddy( sb->chat, ic->acc->user ); } } } @@ -459,11 +461,11 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts ) /* This SB is a one-to-one chat right now, but someone else is joining. */ msn_sb_to_chat( sb ); - add_chat_buddy( sb->chat, cmd[1] ); + imcb_chat_add_buddy( sb->chat, cmd[1] ); } else if( sb->chat ) { - add_chat_buddy( sb->chat, cmd[1] ); + imcb_chat_add_buddy( sb->chat, cmd[1] ); sb->ready = 1; } else @@ -513,7 +515,7 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts ) } else if( sb->chat ) { - remove_chat_buddy( sb->chat, cmd[1], "" ); + imcb_chat_remove_buddy( sb->chat, cmd[1], "" ); } else { @@ -525,8 +527,7 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts ) int num = atoi( cmd[0] ); const struct msn_status_code *err = msn_status_by_number( num ); - g_snprintf( buf, sizeof( buf ), "Error reported by switchboard server: %s", err->text ); - do_error_dialog( gc, buf, "MSN" ); + imcb_error( ic, "Error reported by switchboard server: %s", err->text ); if( err->flags & STATUS_SB_FATAL ) { @@ -535,7 +536,7 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts ) } else if( err->flags & STATUS_FATAL ) { - signoff( gc ); + imc_logout( ic, TRUE ); return 0; } else if( err->flags & STATUS_SB_IM_SPARE ) @@ -576,7 +577,7 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts ) static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts ) { struct msn_switchboard *sb = data; - struct gaim_connection *gc = sb->gc; + struct im_connection *ic = sb->ic; char *body; int blen = 0; @@ -605,11 +606,11 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int if( sb->who ) { - serv_got_im( gc, cmd[1], body, 0, 0, blen ); + imcb_buddy_msg( ic, cmd[1], body, 0, 0 ); } else if( sb->chat ) { - serv_got_chat_in( gc, sb->chat->id, cmd[1], 0, body, 0 ); + imcb_chat_msg( sb->chat, cmd[1], body, 0, 0 ); } else { @@ -664,11 +665,11 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int if( sb->who ) { - serv_got_im( gc, cmd[1], buf, 0, 0, strlen( buf ) ); + imcb_buddy_msg( ic, cmd[1], buf, 0, 0 ); } else if( sb->chat ) { - serv_got_chat_in( gc, sb->chat->id, cmd[1], 0, buf, 0 ); + imcb_chat_msg( sb->chat, cmd[1], buf, 0, 0 ); } else { @@ -681,7 +682,7 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int if( who ) { - serv_got_typing( gc, who, 5, 1 ); + imcb_buddy_typing( ic, who, OPT_TYPING ); g_free( who ); } |