diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-07-24 15:29:48 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-07-24 15:29:48 +0200 |
commit | c8791f25459aeb32f770c46bd3a3613c9fd2d0e2 (patch) | |
tree | 6fb660cf39c58f3d880d4db7466391fdff169811 /protocols/yahoo/yahoo.c | |
parent | 938c30512f4dac4f084fd6bb8b7f41655de9bce4 (diff) | |
parent | c495217e7c02c908d831645b033cf115ccdc3d6d (diff) |
Merging libyahoo2 fixes. Now completely up-to-date with libyahoo2 svn
again, should try to keep it up a little bit better and submit my fixes
upstream.
This also adds code for Yahoo! file transfers but BitlBee isn't using it
yet. (It doesn't seem to support flow control which makes this complicated.)
Diffstat (limited to 'protocols/yahoo/yahoo.c')
-rw-r--r-- | protocols/yahoo/yahoo.c | 157 |
1 files changed, 89 insertions, 68 deletions
diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index bf577496..dfd2e70f 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -1,7 +1,7 @@ /* * libyahoo2 wrapper to BitlBee * - * Mostly Copyright 2004 Wilmer van der Gaast <wilmer@gaast.net> + * Mostly Copyright 2004-2010 Wilmer van der Gaast <wilmer@gaast.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -270,8 +270,32 @@ static void byahoo_keepalive( struct im_connection *ic ) static void byahoo_add_buddy( struct im_connection *ic, char *who, char *group ) { struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; + bee_user_t *bu; - yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL ); + if( group && ( bu = bee_user_by_handle( ic->bee, ic, who ) ) && bu->group ) + { + GSList *bgl; + + /* If the person is in our list already, this is a group change. */ + yahoo_change_buddy_group( yd->y2_id, who, bu->group->name, group ); + + /* No idea how often people have people in multiple groups and + BitlBee doesn't currently support this anyway .. but keep + this struct up-to-date for now. */ + for( bgl = yd->buddygroups; bgl; bgl = bgl->next ) + { + struct byahoo_buddygroups *bg = bgl->data; + + if( g_strcasecmp( bg->buddy, who ) == 0 && + g_strcasecmp( bg->group, bu->group->name ) == 0 ) + { + g_free( bg->group ); + bg->group = g_strdup( group ); + } + } + } + else + yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL ); } static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *group ) @@ -340,14 +364,14 @@ static void byahoo_auth_allow( struct im_connection *ic, const char *who ) { struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; - yahoo_accept_buddy_ymsg13( yd->y2_id, NULL, who ); + yahoo_confirm_buddy( yd->y2_id, who, 0, "" ); } static void byahoo_auth_deny( struct im_connection *ic, const char *who ) { struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; - yahoo_reject_buddy_ymsg13( yd->y2_id, NULL, who, NULL ); + yahoo_confirm_buddy( yd->y2_id, who, 1, "" ); } void byahoo_initmodule( ) @@ -420,7 +444,7 @@ void byahoo_connect_callback( gpointer data, gint source, b_input_condition cond return; } - d->callback( d->fd, 0, d->data ); + d->callback( NULL + d->fd, 0, d->data ); g_free( d ); } @@ -440,7 +464,7 @@ gboolean byahoo_read_ready_callback( gpointer data, gint source, b_input_conditi /* WTF doesn't libyahoo clean this up? */ return FALSE; - yahoo_read_ready( d->id, d->fd, d->data ); + yahoo_read_ready( d->id, NULL + d->fd, d->data ); return TRUE; } @@ -457,7 +481,7 @@ gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condit { struct byahoo_write_ready_data *d = data; - return yahoo_write_ready( d->id, d->fd, d->data ); + return yahoo_write_ready( d->id, NULL + d->fd, d->data ); } void ext_yahoo_login_response( int id, int succ, const char *url ) @@ -486,7 +510,7 @@ void ext_yahoo_login_response( int id, int succ, const char *url ) else { char *errstr; - int allow_reconnect = TRUE; + int allow_reconnect = FALSE; yd->logged_in = FALSE; @@ -496,13 +520,15 @@ void ext_yahoo_login_response( int id, int succ, const char *url ) errstr = "Incorrect Yahoo! password"; else if( succ == YAHOO_LOGIN_LOCK ) errstr = "Yahoo! account locked"; + else if( succ == 1236 ) + errstr = "Yahoo! account locked or machine temporarily banned"; else if( succ == YAHOO_LOGIN_DUPL ) - { errstr = "Logged in on a different machine or device"; - allow_reconnect = FALSE; - } else if( succ == YAHOO_LOGIN_SOCK ) + { errstr = "Socket problem"; + allow_reconnect = TRUE; + } else errstr = "Unknown error"; @@ -605,9 +631,6 @@ void ext_yahoo_status_changed( int id, const char *who, int stat, const char *ms state_string = "Offline"; flags = 0; break; - case YAHOO_STATUS_NOTIFY: - state_string = "Notify"; - break; } imcb_buddy_status( ic, who, flags, state_string, msg ); @@ -616,6 +639,10 @@ void ext_yahoo_status_changed( int id, const char *who, int stat, const char *ms imcb_buddy_times( ic, who, 0, idle ); } +void ext_yahoo_got_buzz( int id, const char *me, const char *who, long tm ) +{ +} + void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8 ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); @@ -629,15 +656,22 @@ void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg, } } -void ext_yahoo_got_file( int id, - const char *ignored, - const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize ) +void ext_yahoo_got_file( int id, const char *ignored, const char *who, const char *msg, + const char *fname, unsigned long fesize, char *trid ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); imcb_log( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); } +void ext_yahoo_got_ft_data( int id, const unsigned char *in, int len, void *data ) +{ +} + +void ext_yahoo_file_transfer_done( int id, int result, void *data ) +{ +} + void ext_yahoo_typing_notify( int id, const char *ignored, const char *who, int stat ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); @@ -648,7 +682,7 @@ void ext_yahoo_typing_notify( int id, const char *ignored, const char *who, int imcb_buddy_typing( ic, (char*) who, 0 ); } -void ext_yahoo_system_message( int id, const char *msg ) +void ext_yahoo_system_message( int id, const char *me, const char *who, const char *msg ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); @@ -670,9 +704,10 @@ void ext_yahoo_error( int id, const char *err, int fatal, int num ) } /* TODO: Clear up the mess of inp and d structures */ -int ext_yahoo_add_handler( int id, int fd, yahoo_input_condition cond, void *data ) +int ext_yahoo_add_handler( int id, void *fd_, yahoo_input_condition cond, void *data ) { struct byahoo_input_data *inp = g_new0( struct byahoo_input_data, 1 ); + int fd = (int) fd_; if( cond == YAHOO_INPUT_READ ) { @@ -699,12 +734,12 @@ int ext_yahoo_add_handler( int id, int fd, yahoo_input_condition cond, void *dat else { g_free( inp ); - return( -1 ); + return -1; /* Panic... */ } byahoo_inputs = g_slist_append( byahoo_inputs, inp ); - return( inp->h ); + return inp->h; } void ext_yahoo_remove_handler( int id, int tag ) @@ -728,7 +763,7 @@ void ext_yahoo_remove_handler( int id, int tag ) b_event_remove( tag ); } -int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data ) +int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data, int use_ssl ) { struct byahoo_connect_callback_data *d; int fd; @@ -744,48 +779,41 @@ int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_c d->data = data; d->id = id; - return( fd ); + return fd; } -/* Because we don't want asynchronous connects in BitlBee, and because - libyahoo doesn't seem to use this one anyway, this one is now defunct. */ -int ext_yahoo_connect(const char *host, int port) +char *ext_yahoo_get_ip_addr( const char *domain ) +{ + return NULL; +} + +int ext_yahoo_write( void *fd, char *buf, int len ) { -#if 0 - struct sockaddr_in serv_addr; - static struct hostent *server; - static char last_host[256]; - int servfd; - char **p; + return write( (int) fd, buf, len ); +} - if(last_host[0] || g_strcasecmp(last_host, host)!=0) { - if(!(server = gethostbyname(host))) { - return -1; - } - strncpy(last_host, host, 255); - } +int ext_yahoo_read( void *fd, char *buf, int len ) +{ + return read( (int) fd, buf, len ); +} - if((servfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - return -1; - } +void ext_yahoo_close( void *fd ) +{ + close( (int) fd ); +} - for (p = server->h_addr_list; *p; p++) - { - memset(&serv_addr, 0, sizeof(serv_addr)); - serv_addr.sin_family = AF_INET; - memcpy(&serv_addr.sin_addr.s_addr, *p, server->h_length); - serv_addr.sin_port = htons(port); - - if(connect(servfd, (struct sockaddr *) &serv_addr, - sizeof(serv_addr)) == -1) { - return -1; - } else { - return servfd; - } - } +void ext_yahoo_got_buddy_change_group( int id, const char *me, const char *who, + const char *old_group, const char *new_group ) +{ + struct im_connection *ic = byahoo_get_ic_by_id( id ); + + imcb_add_buddy( ic, who, new_group ); +} - closesocket(servfd); -#endif +/* Because we don't want asynchronous connects in BitlBee, and because + libyahoo doesn't seem to use this one anyway, this one is now defunct. */ +int ext_yahoo_connect(const char *host, int port) +{ return -1; } @@ -897,7 +925,7 @@ void ext_yahoo_chat_cat_xml( int id, const char *xml ) { } -void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, int fd ) +void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, void *fd ) { } @@ -925,25 +953,18 @@ void ext_yahoo_chat_yahooerror( int id, const char *me ) { } -void ext_yahoo_contact_auth_request( int id, const char *myid, const char *who, const char *msg ) -{ - struct im_connection *ic = byahoo_get_ic_by_id( id ); - - imcb_ask_auth( ic, who, NULL ); -} - void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); - imcb_add_buddy( ic, (char*) who, NULL ); + imcb_ask_auth( ic, who, msg ); } void ext_yahoo_rejected( int id, const char *who, const char *msg ) { } -void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat ) +void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat, const char *msg ) { } @@ -988,7 +1009,7 @@ void ext_yahoo_got_webcam_image( int id, const char * who, const unsigned char * { } -void ext_yahoo_got_ping( int id, const char *msg) +void ext_yahoo_got_ping( int id, const char *msg ) { } |