diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/jabber/jabber.c | 5 | ||||
-rw-r--r-- | protocols/msn/msn.h | 5 | ||||
-rw-r--r-- | protocols/msn/msn_util.c | 11 | ||||
-rw-r--r-- | protocols/msn/ns.c | 51 | ||||
-rw-r--r-- | protocols/msn/sb.c | 8 | ||||
-rw-r--r-- | protocols/nogaim.c | 42 | ||||
-rw-r--r-- | protocols/oscar/oscar.c | 13 | ||||
-rw-r--r-- | protocols/ssl_openssl.c | 86 |
8 files changed, 128 insertions, 93 deletions
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index ba652b8a..224762ce 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -1231,9 +1231,7 @@ static void jabber_handleroster(gjconn gjc, xmlnode querynode) x = xmlnode_get_nextsibling(x); } - x = jutil_presnew(0, NULL, "Online"); - gjab_send(gjc, x); - xmlnode_free(x); + account_online(GJ_GC(gjc)); } static void jabber_handleauthresp(gjconn gjc, jpacket p) @@ -1249,7 +1247,6 @@ static void jabber_handleauthresp(gjconn gjc, jpacket p) gjab_auth(gjc); } else { gjab_reqroster(gjc); - account_online(GJ_GC(gjc)); ((struct jabber_data *)GJ_GC(gjc)->proto_data)->did_import = TRUE; } diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index 9727c537..0cd174f2 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -65,8 +65,11 @@ struct msn_data GSList *msgq; GSList *switchboards; - int buddycount; const struct msn_away_state *away_state; + + int buddycount; + int groupcount; + char **grouplist; }; struct msn_switchboard diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index e5f0b2c9..5cda9f1c 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -45,19 +45,8 @@ int msn_write( struct gaim_connection *gc, char *s, int len ) int msn_logged_in( struct gaim_connection *gc ) { - struct msn_data *md = gc->proto_data; - char buf[1024]; - account_online( gc ); - /* account_online() sets an away state if there is any, so only - execute this code if we're not away. */ - if( md->away_state == msn_away_state_list ) - { - 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( 0 ); } diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 4ced58a0..90d525ef 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -256,6 +256,9 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( num_parts == 5 ) { md->buddycount = atoi( cmd[3] ); + md->groupcount = atoi( cmd[4] ); + if( md->groupcount > 0 ) + md->grouplist = g_new0( char *, md->groupcount ); if( !*cmd[3] || md->buddycount == 0 ) msn_logged_in( gc ); @@ -268,18 +271,6 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) msn_logged_in( gc ); } } - else if( strcmp( cmd[0], "GTC" ) == 0 ) - { - } - else if( strcmp( cmd[0], "BLP" ) == 0 ) - { - } - else if( strcmp( cmd[0], "PRP" ) == 0 ) - { - } - else if( strcmp( cmd[0], "LSG" ) == 0 ) - { - } else if( strcmp( cmd[0], "LST" ) == 0 ) { int list; @@ -296,7 +287,13 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( list & 1 ) /* FL */ { - add_buddy( gc, NULL, cmd[1], cmd[2] ); + char *group = NULL; + int num; + + if( cmd[4] != NULL && sscanf( cmd[4], "%d", &num ) == 1 ) + group = md->grouplist[num]; + + add_buddy( gc, group, cmd[1], cmd[2] ); } if( list & 2 ) /* AL */ { @@ -326,11 +323,22 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } } } - else if( strcmp( cmd[0], "BPR" ) == 0 ) - { - } - else if( strcmp( cmd[0], "CHG" ) == 0 ) + else if( strcmp( cmd[0], "LSG" ) == 0 ) { + int num; + + if( num_parts != 4 ) + { + hide_login_progress_error( gc, "Syntax error" ); + signoff( gc ); + return( 0 ); + } + + http_decode( cmd[2] ); + num = atoi( cmd[1] ); + + if( num < md->groupcount ) + md->grouplist[num] = g_strdup( cmd[2] ); } else if( strcmp( cmd[0], "CHL" ) == 0 ) { @@ -356,12 +364,6 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) return( msn_write( gc, buf, strlen( buf ) ) ); } - else if( strcmp( cmd[0], "QRY" ) == 0 ) - { - } - else if( strcmp( cmd[0], "QNG" ) == 0 ) - { - } else if( strcmp( cmd[0], "ILN" ) == 0 ) { const struct msn_away_state *st; @@ -478,9 +480,6 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) msn_buddy_ask( gc, cmd[4], cmd[5] ); } } - else if( strcmp( cmd[0], "REM" ) == 0 ) - { - } else if( strcmp( cmd[0], "OUT" ) == 0 ) { if( cmd[1] && strcmp( cmd[1], "OTH" ) == 0 ) diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index deaceba1..234be1d6 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -201,9 +201,6 @@ void msn_sb_destroy( struct msn_switchboard *sb ) debug( "Destroying switchboard: %s", sb->who ? sb->who : sb->key ? sb->key : "" ); - if( sb->key ) g_free( sb->key ); - if( sb->who ) g_free( sb->who ); - if( sb->msgq ) { struct msn_message *m; @@ -221,9 +218,12 @@ void msn_sb_destroy( struct msn_switchboard *sb ) serv_got_crap( gc, "Warning: Closing down MSN switchboard connection with " "unsent message to %s, you'll have to resend it.", - m->who ? m->who : "(unknown)" ); + sb->who ? sb->who : "(unknown)" ); } + if( sb->key ) g_free( sb->key ); + if( sb->who ) g_free( sb->who ); + if( sb->chat ) { serv_got_chat_left( gc, sb->chat->id ); diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 29ae860a..28f76fff 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -13,7 +13,7 @@ * from scratch for BitlBee and doesn't contain any code from Gaim anymore * (except for the function names). * - * Copyright 2002-2004 Wilmer van der Gaast <lintux@lintux.cx> + * Copyright 2002-2006 Wilmer van der Gaast <wilmer@gaast.net> and others */ /* @@ -38,7 +38,7 @@ #include <ctype.h> #include <iconv.h> -static char *proto_away_alias[7][5] = +static char *proto_away_alias[8][5] = { { "Away from computer", "Away", "Extended away", NULL }, { "NA", "N/A", "Not available", NULL }, @@ -46,6 +46,7 @@ static char *proto_away_alias[7][5] = { "Be right back", "BRB", NULL }, { "On the phone", "Phone", "On phone", NULL }, { "Out to lunch", "Lunch", "Food", NULL }, + { "Invisible", "Hidden" }, { NULL } }; static char *proto_away_alias_find( GList *gcm, char *away ); @@ -304,7 +305,7 @@ void hide_login_progress_error( struct gaim_connection *gc, char *msg ) void serv_got_crap( struct gaim_connection *gc, char *format, ... ) { va_list params; - char text[1024], buf[1024], acc_id[33]; + char text[1024], buf[1024], *acc_id; char *msg; account_t *a; @@ -329,11 +330,13 @@ void serv_got_crap( struct gaim_connection *gc, char *format, ... ) /* If we found one, add the screenname to the acc_id. */ if( a ) - g_snprintf( acc_id, 32, "%s(%s)", gc->prpl->name, gc->username ); + acc_id = g_strdup_printf( "%s(%s)", gc->prpl->name, gc->username ); else - g_snprintf( acc_id, 32, "%s", gc->prpl->name ); + acc_id = g_strdup( gc->prpl->name ); irc_usermsg( gc->irc, "%s - %s", acc_id, msg ); + + g_free( acc_id ); } static gboolean send_keepalive( gpointer d ) @@ -351,7 +354,7 @@ void account_online( struct gaim_connection *gc ) user_t *u; /* MSN servers sometimes redirect you to a different server and do - the whole login sequence again, so subsequent calls to this + the whole login sequence again, so these "late" calls to this function should be handled correctly. (IOW, ignored) */ if( gc->flags & OPT_LOGGED_IN ) return; @@ -363,9 +366,11 @@ void account_online( struct gaim_connection *gc ) gc->keepalive = g_timeout_add( 60000, send_keepalive, gc ); gc->flags |= OPT_LOGGED_IN; - if( u && u->away ) proto_away( gc, u->away ); + /* Also necessary when we're not away, at least for some of the + protocols. */ + proto_away( gc, u->away ); - if( !strcmp(gc->prpl->name, "icq") ) + if( strcmp( gc->prpl->name, "ICQ" ) == 0 ) { for( u = gc->irc->users; u; u = u->next ) if( u->gc == gc ) @@ -469,16 +474,6 @@ void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doi /* list.c */ -int bud_list_cache_exists( struct gaim_connection *gc ) -{ - return( 0 ); -} - -void do_import( struct gaim_connection *gc, void *null ) -{ - return; -} - void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname ) { user_t *u; @@ -530,6 +525,7 @@ void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *rea u->gc = gc; u->handle = g_strdup( handle ); + if( group ) u->group = g_strdup( group ); u->send_handler = buddy_send_handler; u->last_typing_notice = 0; } @@ -553,11 +549,6 @@ struct buddy *find_buddy( struct gaim_connection *gc, char *handle ) return( b ); } -void do_export( struct gaim_connection *gc ) -{ - return; -} - void signoff_blocked( struct gaim_connection *gc ) { return; /* Make all blocked users look invisible (TODO?) */ @@ -883,11 +874,6 @@ struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, c return( c ); } -void serv_finish_login( struct gaim_connection *gc ) -{ - return; -} - /* buddy_chat.c */ diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 4e552bce..97384afb 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -355,7 +355,9 @@ static void oscar_login(struct aim_user *user) { if (isdigit(*user->username)) { odata->icq = TRUE; - /* this is odd but it's necessary for a proper do_import and do_export */ + /* This is odd but it's necessary for a proper do_import and do_export. + We don't do those anymore, but let's stick with it, just in case + it accidentally fixes something else too... */ gc->password[8] = 0; } else { gc->flags |= OPT_CONN_HTML; @@ -1147,7 +1149,7 @@ static void gaim_icq_authask(struct gaim_connection *gc, guint32 uin, char *msg) if (strlen(msg) > 6) reason = msg + 6; - dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason:\n\n%s", uin, reason ? reason : "No reason given."); + dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason: %s", uin, reason ? reason : "No reason given."); data->gc = gc; data->uin = uin; do_ask_dialog(gc, dialog_msg, data, gaim_icq_authgrant, gaim_icq_authdeny); @@ -1736,11 +1738,6 @@ static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { odata->rights.maxpermits = (guint)maxpermits; odata->rights.maxdenies = (guint)maxdenies; -// serv_finish_login(gc); - - if (bud_list_cache_exists(gc)) - do_import(gc, NULL); - aim_clientready(sess, fr->conn); aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); @@ -2095,8 +2092,6 @@ static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { } /* End of switch on curitem->type */ } /* End of for loop */ - if (tmp) - do_export(gc); aim_ssi_enable(sess, fr->conn); /* Request offline messages, now that the buddy list is complete. */ diff --git a/protocols/ssl_openssl.c b/protocols/ssl_openssl.c index e62f95b9..b79088cc 100644 --- a/protocols/ssl_openssl.c +++ b/protocols/ssl_openssl.c @@ -4,7 +4,7 @@ * Copyright 2002-2004 Wilmer van der Gaast and others * \********************************************************************/ -/* SSL module - OpenTLS version */ +/* SSL module - OpenSSL version */ /* This program is free software; you can redistribute it and/or modify @@ -40,11 +40,13 @@ static gboolean initialized = FALSE; struct scd { - SslInputFunction func; + ssl_input_function func; gpointer data; int fd; gboolean established; + int inpa; + int lasterr; /* Necessary for SSL_get_error */ SSL *ssl; SSL_CTX *ssl_ctx; }; @@ -53,7 +55,7 @@ static void ssl_connected( gpointer data, gint source, GaimInputCondition cond ) -void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data ) +void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) { struct scd *conn = g_new0( struct scd, 1 ); SSL_METHOD *meth; @@ -92,19 +94,45 @@ void *ssl_connect( char *host, int port, SslInputFunction func, gpointer data ) return( conn ); } +static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond ); + static void ssl_connected( gpointer data, gint source, GaimInputCondition cond ) { struct scd *conn = data; if( source == -1 ) - goto ssl_connected_failure; + return ssl_handshake( data, -1, cond ); + /* Make it non-blocking at least during the handshake... */ + sock_make_nonblocking( conn->fd ); SSL_set_fd( conn->ssl, conn->fd ); - if( SSL_connect( conn->ssl ) < 0 ) - goto ssl_connected_failure; + return ssl_handshake( data, source, cond ); +} + +static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond ) +{ + struct scd *conn = data; + int st; + + if( conn->inpa != -1 ) + { + gaim_input_remove( conn->inpa ); + conn->inpa = -1; + } + + if( ( st = SSL_connect( conn->ssl ) ) < 0 ) + { + conn->lasterr = SSL_get_error( conn->ssl, st ); + if( conn->lasterr != SSL_ERROR_WANT_READ && conn->lasterr != SSL_ERROR_WANT_WRITE ) + goto ssl_connected_failure; + + conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ), ssl_handshake, data ); + return; + } conn->established = TRUE; + sock_make_blocking( conn->fd ); /* For now... */ conn->func( conn->data, conn, cond ); return; @@ -126,24 +154,57 @@ ssl_connected_failure: int ssl_read( void *conn, char *buf, int len ) { + int st; + if( !((struct scd*)conn)->established ) - return( 0 ); + { + ssl_errno = SSL_NOHANDSHAKE; + return -1; + } + + st = SSL_read( ((struct scd*)conn)->ssl, buf, len ); - return( SSL_read( ((struct scd*)conn)->ssl, buf, len ) ); + ssl_errno = SSL_OK; + if( st <= 0 ) + { + ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st ); + if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ) + ssl_errno = SSL_AGAIN; + } + + return st; } int ssl_write( void *conn, const char *buf, int len ) { + int st; + if( !((struct scd*)conn)->established ) - return( 0 ); + { + ssl_errno = SSL_NOHANDSHAKE; + return -1; + } + + st = SSL_write( ((struct scd*)conn)->ssl, buf, len ); - return( SSL_write( ((struct scd*)conn)->ssl, buf, len ) ); + ssl_errno = SSL_OK; + if( st <= 0 ) + { + ((struct scd*)conn)->lasterr = SSL_get_error( ((struct scd*)conn)->ssl, st ); + if( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_READ || ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ) + ssl_errno = SSL_AGAIN; + } + + return st; } void ssl_disconnect( void *conn_ ) { struct scd *conn = conn_; + if( conn->inpa != -1 ) + gaim_input_remove( conn->inpa ); + if( conn->established ) SSL_shutdown( conn->ssl ); @@ -158,3 +219,8 @@ int ssl_getfd( void *conn ) { return( ((struct scd*)conn)->fd ); } + +GaimInputCondition ssl_getdirection( void *conn ) +{ + return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? GAIM_INPUT_WRITE : GAIM_INPUT_READ ); +} |