diff options
Diffstat (limited to 'protocols/msn')
-rw-r--r-- | protocols/msn/msn.c | 27 | ||||
-rw-r--r-- | protocols/msn/msn.h | 4 | ||||
-rw-r--r-- | protocols/msn/sb.c | 20 |
3 files changed, 25 insertions, 26 deletions
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index 663bff8c..a73d85d4 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -240,9 +240,9 @@ static void msn_remove_buddy( struct gaim_connection *gc, char *who, char *group msn_buddy_list_remove( gc, "FL", who ); } -static int msn_chat_send( struct gaim_connection *gc, int id, char *message ) +static int msn_chat_send( struct conversation *c, char *message ) { - 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 ) ); @@ -250,9 +250,9 @@ static int msn_chat_send( struct gaim_connection *gc, int id, char *message ) return( 0 ); } -static void msn_chat_invite( struct gaim_connection *gc, int id, char *msg, char *who ) +static void msn_chat_invite( struct conversation *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 ) @@ -262,15 +262,15 @@ 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 conversation *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 conversation *msn_chat_open( struct gaim_connection *gc, char *who ) { struct msn_switchboard *sb; struct msn_data *md = gc->proto_data; @@ -279,8 +279,7 @@ static int msn_chat_open( struct gaim_connection *gc, char *who ) if( ( sb = msn_sb_by_handle( gc, 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 { @@ -291,10 +290,7 @@ static int msn_chat_open( struct gaim_connection *gc, char *who ) 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: */ @@ -313,10 +309,11 @@ 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 ) diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index b4777d41..78cc3caf 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -168,9 +168,9 @@ const struct msn_status_code *msn_status_by_number( int number ); 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_by_chat( struct conversation *c ); struct msn_switchboard *msn_sb_spare( struct gaim_connection *gc ); int msn_sb_sendmessage( struct msn_switchboard *sb, char *text ); -void msn_sb_to_chat( struct msn_switchboard *sb ); +struct conversation *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/sb.c b/protocols/msn/sb.c index 7ec340bd..8e912273 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -85,16 +85,16 @@ 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 conversation *c ) { - struct msn_data *md = gc->proto_data; + struct msn_data *md = c->gc->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 ); } @@ -176,14 +176,14 @@ int msn_sb_sendmessage( struct msn_switchboard *sb, char *text ) } } -void msn_sb_to_chat( struct msn_switchboard *sb ) +struct conversation *msn_sb_to_chat( struct msn_switchboard *sb ) { struct gaim_connection *gc = sb->gc; 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 = serv_got_joined_chat( gc, buf ); /* Populate the channel. */ if( sb->who ) add_chat_buddy( sb->chat, sb->who ); @@ -195,6 +195,8 @@ 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 ) @@ -229,7 +231,7 @@ void msn_sb_destroy( struct msn_switchboard *sb ) if( sb->chat ) { - serv_got_chat_left( gc, sb->chat->id ); + serv_got_chat_left( sb->chat ); } if( sb->handler ) @@ -371,7 +373,7 @@ 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 = serv_got_joined_chat( gc, buf ); g_free( sb->who ); sb->who = NULL; @@ -609,7 +611,7 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int } else if( sb->chat ) { - serv_got_chat_in( gc, sb->chat->id, cmd[1], 0, body, 0 ); + serv_got_chat_in( sb->chat, cmd[1], 0, body, 0 ); } else { @@ -668,7 +670,7 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int } else if( sb->chat ) { - serv_got_chat_in( gc, sb->chat->id, cmd[1], 0, buf, 0 ); + serv_got_chat_in( sb->chat, cmd[1], 0, buf, 0 ); } else { |