diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2007-04-05 22:20:31 -0700 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2007-04-05 22:20:31 -0700 |
commit | aef4828a1dc51de10a43bb7dd5d023de9971295b (patch) | |
tree | cbb675b41369f1ada1579fba4060726573cf9cb5 /protocols/msn | |
parent | 0da65d5fb37691ed4d31f7ab4058732f1440db6b (diff) |
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...
Diffstat (limited to 'protocols/msn')
-rw-r--r-- | protocols/msn/msn.c | 18 | ||||
-rw-r--r-- | protocols/msn/msn_util.c | 6 | ||||
-rw-r--r-- | protocols/msn/ns.c | 121 | ||||
-rw-r--r-- | protocols/msn/sb.c | 11 |
4 files changed, 77 insertions, 79 deletions
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index afc90627..860be01b 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -38,7 +38,7 @@ static void msn_init( account_t *acc ) static void msn_login( account_t *acc ) { - struct im_connection *ic = new_gaim_conn( acc ); + struct im_connection *ic = imc_new( acc ); struct msn_data *md = g_new0( struct msn_data, 1 ); ic->proto_data = md; @@ -46,18 +46,18 @@ static void msn_login( account_t *acc ) if( strchr( acc->user, '@' ) == NULL ) { - hide_login_progress( ic, "Invalid account name" ); - signoff( ic ); + imc_error( ic, "Invalid account name" ); + imc_logout( ic ); return; } - set_login_progress( ic, 1, "Connecting" ); + imc_log( ic, "Connecting" ); md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, ic ); if( md->fd < 0 ) { - hide_login_progress( ic, "Could not connect to server" ); - signoff( ic ); + imc_error( ic, "Could not connect to server" ); + imc_logout( ic ); return; } @@ -95,7 +95,7 @@ static void msn_logout( struct im_connection *ic ) { m = l->data; - serv_got_crap( ic, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who ); + imc_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 ); @@ -227,7 +227,7 @@ static void msn_set_my_name( struct im_connection *ic, char *info ) 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( ic, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who ); + imc_log( ic, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who ); } static void msn_add_buddy( struct im_connection *ic, char *who, char *group ) @@ -372,7 +372,7 @@ static char *msn_set_display_name( set_t *set, char *value ) if( strlen( value ) > 129 ) { - serv_got_crap( ic, "Maximum name length exceeded" ); + imc_log( ic, "Maximum name length exceeded" ); return NULL; } diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index 1be1586c..72411095 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -35,8 +35,8 @@ int msn_write( struct im_connection *ic, char *s, int len ) st = write( md->fd, s, len ); if( st != len ) { - hide_login_progress_error( ic, "Short write() to main server" ); - signoff( ic ); + imc_error( ic, "Short write() to main server" ); + imc_logout( ic ); return( 0 ); } @@ -45,7 +45,7 @@ int msn_write( struct im_connection *ic, char *s, int len ) int msn_logged_in( struct im_connection *ic ) { - account_online( ic ); + imc_connected( ic ); return( 0 ); } diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 9d86a68e..e4530b8f 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -46,8 +46,8 @@ gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) if( source == -1 ) { - hide_login_progress( ic, "Could not connect to server" ); - signoff( ic ); + imc_error( ic, "Could not connect to server" ); + imc_logout( ic ); return FALSE; } @@ -75,7 +75,7 @@ gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) if( msn_write( ic, s, strlen( s ) ) ) { ic->inpa = b_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, ic ); - set_login_progress( ic, 1, "Connected to server, waiting for reply" ); + imc_log( ic, "Connected to server, waiting for reply" ); } return FALSE; @@ -88,8 +88,8 @@ static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition c if( msn_handler( md->handler ) == -1 ) /* Don't do this on ret == 0, it's already done then. */ { - hide_login_progress( ic, "Error while reading from server" ); - signoff( ic ); + imc_error( ic, "Error while reading from server" ); + imc_logout( ic ); return FALSE; } @@ -113,8 +113,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { if( cmd[2] && strncmp( cmd[2], "MSNP8", 5 ) != 0 ) { - hide_login_progress( ic, "Unsupported protocol" ); - signoff( ic ); + imc_error( ic, "Unsupported protocol" ); + imc_logout( ic ); return( 0 ); } @@ -142,15 +142,15 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) server = strchr( cmd[3], ':' ); if( !server ) { - hide_login_progress_error( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 0 ); } *server = 0; port = atoi( server + 1 ); server = cmd[3]; - set_login_progress( ic, 1, "Transferring to other server" ); + imc_log( ic, "Transferring to other server" ); md->fd = proxy_connect( server, port, msn_ns_connected, ic ); } @@ -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( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 0 ); } *server = 0; @@ -171,8 +171,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( strcmp( cmd[4], "CKI" ) != 0 ) { - hide_login_progress_error( ic, "Unknown authentication method for switchboard" ); - signoff( ic ); + imc_error( ic, "Unknown authentication method for switchboard" ); + imc_logout( ic ); return( 0 ); } @@ -203,8 +203,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else { - hide_login_progress_error( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 0 ); } } @@ -215,8 +215,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) /* Time for some Passport black magic... */ if( !passport_get_id( msn_auth_got_passport_id, ic, ic->username, ic->password, cmd[4] ) ) { - hide_login_progress_error( ic, "Error while contacting Passport server" ); - signoff( ic ); + imc_error( ic, "Error while contacting Passport server" ); + imc_logout( ic ); return( 0 ); } } @@ -235,15 +235,15 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) s->value = g_strdup( cmd[4] ); } - set_login_progress( ic, 1, "Authenticated, getting buddy list" ); + imc_log( ic, "Authenticated, getting buddy list" ); g_snprintf( buf, sizeof( buf ), "SYN %d 0\r\n", ++md->trId ); return( msn_write( ic, buf, strlen( buf ) ) ); } else { - hide_login_progress( ic, "Unknown authentication type" ); - signoff( ic ); + imc_error( ic, "Unknown authentication type" ); + imc_logout( ic ); 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( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); 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( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 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( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 0 ); } @@ -327,7 +327,7 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { if( ic->flags & OPT_LOGGED_IN ) { - serv_got_crap( ic, "Successfully transferred to different server" ); + imc_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( ic, buf, strlen( buf ) ) ); } @@ -343,8 +343,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts != 4 ) { - hide_login_progress_error( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 0 ); } @@ -362,8 +362,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts != 3 ) { - hide_login_progress_error( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 0 ); } @@ -384,8 +384,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts != 6 ) { - hide_login_progress_error( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 0 ); } @@ -412,8 +412,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts != 5 ) { - hide_login_progress_error( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 0 ); } @@ -437,8 +437,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts != 7 ) { - hide_login_progress_error( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 0 ); } @@ -447,8 +447,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) server = strchr( cmd[2], ':' ); if( !server ) { - hide_login_progress_error( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 0 ); } *server = 0; @@ -457,8 +457,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( strcmp( cmd[3], "CKI" ) != 0 ) { - hide_login_progress_error( ic, "Unknown authentication method for switchboard" ); - signoff( ic ); + imc_error( ic, "Unknown authentication method for switchboard" ); + imc_logout( ic ); return( 0 ); } @@ -477,8 +477,8 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( strchr( cmd[4], '@' ) == NULL ) { - hide_login_progress_error( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 0 ); } @@ -498,27 +498,27 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { if( cmd[1] && strcmp( cmd[1], "OTH" ) == 0 ) { - hide_login_progress_error( ic, "Someone else logged in with your account" ); + imc_error( ic, "Someone else logged in with your account" ); ic->wants_to_die = 1; } else if( cmd[1] && strcmp( cmd[1], "SSD" ) == 0 ) { - hide_login_progress_error( ic, "Terminating session because of server shutdown" ); + imc_error( ic, "Terminating session because of server shutdown" ); } else { - hide_login_progress_error( ic, "Session terminated by remote server (reason unknown)" ); + imc_error( ic, "Session terminated by remote server (reason unknown)" ); } - signoff( ic ); + imc_logout( ic ); return( 0 ); } else if( strcmp( cmd[0], "REA" ) == 0 ) { if( num_parts != 5 ) { - hide_login_progress_error( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 0 ); } @@ -545,14 +545,14 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } else if( strcmp( cmd[0], "IPG" ) == 0 ) { - do_error_dialog( ic, "Received IPG command, we don't handle them yet.", "MSN" ); + imc_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( ic, "Syntax error" ); - signoff( ic ); + imc_error( ic, "Syntax error" ); + imc_logout( ic ); return( 0 ); } } @@ -561,12 +561,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( ic, buf, "MSN" ); + imc_error( ic, "Error reported by MSN server: %s", err->text ); if( err->flags & STATUS_FATAL ) { - signoff( ic ); + imc_logout( ic ); return( 0 ); } } @@ -616,7 +615,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( ic, "The server is going down for maintenance in %s minutes.", arg1 ); + imc_log( ic, "The server is going down for maintenance in %s minutes.", arg1 ); } if( arg1 ) g_free( arg1 ); @@ -633,7 +632,7 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int if( inbox && folders ) { - serv_got_crap( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); + imc_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 +642,7 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int if( from && fromname ) { - serv_got_crap( ic, "Received an e-mail message from %s <%s>.", fromname, from ); + imc_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); } } else if( g_strncasecmp( ct, "text/x-msmsgsactivemailnotification", 35 ) == 0 ) @@ -676,8 +675,8 @@ static void msn_auth_got_passport_id( struct passport_reply *rep ) err = g_strdup_printf( "Error during Passport authentication (%s)", rep->error_string ? rep->error_string : "Unknown error" ); - hide_login_progress( ic, err ); - signoff( ic ); + imc_error( ic, err ); + imc_logout( ic ); g_free( err ); } diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index f9c755a5..f7007d32 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -221,7 +221,7 @@ void msn_sb_destroy( struct msn_switchboard *sb ) } g_slist_free( sb->msgq ); - serv_got_crap( ic, "Warning: Closing down MSN switchboard connection with " + imc_log( ic, "Warning: Closing down MSN switchboard connection with " "unsent message to %s, you'll have to resend it.", sb->who ? sb->who : "(unknown)" ); } @@ -320,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( ic, "Received an XFR from a switchboard server, unable to comply! This is likely to be a bug, please report it!" ); - signoff( ic ); + imc_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 ); return( 0 ); } else if( strcmp( cmd[0], "USR" ) == 0 ) @@ -527,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( ic, buf, "MSN" ); + imc_error( ic, "Error reported by switchboard server: %s", err->text ); if( err->flags & STATUS_SB_FATAL ) { @@ -537,7 +536,7 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts ) } else if( err->flags & STATUS_FATAL ) { - signoff( ic ); + imc_logout( ic ); return 0; } else if( err->flags & STATUS_SB_IM_SPARE ) |