From ba9edaa568088900145bbd1004c864b7d408c38d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 10 May 2006 19:34:46 +0200 Subject: Moved everything to the BitlBee event handling API. --- protocols/yahoo/yahoo.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index bf1dd1a0..1ce860eb 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -442,7 +442,7 @@ struct byahoo_connect_callback_data int id; }; -void byahoo_connect_callback( gpointer data, gint source, GaimInputCondition cond ) +void byahoo_connect_callback( gpointer data, gint source, b_input_condition cond ) { struct byahoo_connect_callback_data *d = data; @@ -464,7 +464,7 @@ struct byahoo_read_ready_data gpointer data; }; -void byahoo_read_ready_callback( gpointer data, gint source, GaimInputCondition cond ) +gboolean byahoo_read_ready_callback( gpointer data, gint source, b_input_condition cond ) { struct byahoo_read_ready_data *d = data; @@ -472,7 +472,7 @@ void byahoo_read_ready_callback( gpointer data, gint source, GaimInputCondition { /* WTF doesn't libyahoo clean this up? */ ext_yahoo_remove_handler( d->id, d->tag ); - return; + return FALSE; } yahoo_read_ready( d->id, d->fd, d->data ); @@ -486,7 +486,7 @@ struct byahoo_write_ready_data gpointer data; }; -void byahoo_write_ready_callback( gpointer data, gint source, GaimInputCondition cond ) +gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condition cond ) { struct byahoo_write_ready_data *d = data; @@ -494,7 +494,7 @@ void byahoo_write_ready_callback( gpointer data, gint source, GaimInputCondition { /* WTF doesn't libyahoo clean this up? */ ext_yahoo_remove_handler( d->id, d->tag ); - return; + return FALSE; } yahoo_write_ready( d->id, d->fd, d->data ); @@ -685,7 +685,7 @@ int ext_yahoo_add_handler( int id, int fd, yahoo_input_condition cond, void *dat d->data = data; inp->d = d; - d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_READ, (GaimInputFunction) byahoo_read_ready_callback, (gpointer) d ); + d->tag = inp->h = b_input_add( fd, GAIM_INPUT_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d ); } else if( cond == YAHOO_INPUT_WRITE ) { @@ -696,7 +696,7 @@ int ext_yahoo_add_handler( int id, int fd, yahoo_input_condition cond, void *dat d->data = data; inp->d = d; - d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_WRITE, (GaimInputFunction) byahoo_write_ready_callback, (gpointer) d ); + d->tag = inp->h = b_input_add( fd, GAIM_INPUT_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d ); } else { @@ -727,7 +727,7 @@ void ext_yahoo_remove_handler( int id, int tag ) l = l->next; } - gaim_input_remove( tag ); + b_event_remove( tag ); } int ext_yahoo_connect_async( int id, char *host, int port, yahoo_connect_callback callback, void *data ) @@ -736,7 +736,7 @@ int ext_yahoo_connect_async( int id, char *host, int port, yahoo_connect_callbac int fd; d = g_new0( struct byahoo_connect_callback_data, 1 ); - if( ( fd = proxy_connect( host, port, (GaimInputFunction) byahoo_connect_callback, (gpointer) d ) ) < 0 ) + if( ( fd = proxy_connect( host, port, (b_event_handler) byahoo_connect_callback, (gpointer) d ) ) < 0 ) { g_free( d ); return( fd ); -- cgit v1.2.3 From 7a685f15d0e5774467a8721eb97d059726ce792b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 15 May 2006 11:26:54 +0200 Subject: Added correct return values for callbacks in yahoo.c. --- protocols/yahoo/yahoo.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 1ce860eb..fba5dfb8 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -469,13 +469,12 @@ gboolean byahoo_read_ready_callback( gpointer data, gint source, b_input_conditi struct byahoo_read_ready_data *d = data; if( !byahoo_get_gc_by_id( d->id ) ) - { /* WTF doesn't libyahoo clean this up? */ - ext_yahoo_remove_handler( d->id, d->tag ); return FALSE; - } yahoo_read_ready( d->id, d->fd, d->data ); + + return TRUE; } struct byahoo_write_ready_data @@ -491,13 +490,12 @@ gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condit struct byahoo_write_ready_data *d = data; if( !byahoo_get_gc_by_id( d->id ) ) - { /* WTF doesn't libyahoo clean this up? */ - ext_yahoo_remove_handler( d->id, d->tag ); return FALSE; - } yahoo_write_ready( d->id, d->fd, d->data ); + + return FALSE; } void ext_yahoo_login_response( int id, int succ, char *url ) -- cgit v1.2.3 From 812a41362a9316da1734fdaa8b1aad36bde9cb5c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 23 Jun 2006 20:15:28 +0200 Subject: Added saner base64 encoding function (actually, moved the one from libyahoo2.c to core, with some changes), which I need for the XML format password garbling. --- protocols/yahoo/libyahoo2.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index c691f18b..ee0f2f0e 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -694,34 +694,10 @@ static void yahoo_packet_dump(unsigned char *data, int len) } } -static char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789._"; -static void to_y64(unsigned char *out, const unsigned char *in, int inlen) /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ +static void to_y64(unsigned char *out, const unsigned char *in, int inlen) { - for (; inlen >= 3; inlen -= 3) - { - *out++ = base64digits[in[0] >> 2]; - *out++ = base64digits[((in[0]<<4) & 0x30) | (in[1]>>4)]; - *out++ = base64digits[((in[1]<<2) & 0x3c) | (in[2]>>6)]; - *out++ = base64digits[in[2] & 0x3f]; - in += 3; - } - if (inlen > 0) - { - unsigned char fragment; - - *out++ = base64digits[in[0] >> 2]; - fragment = (in[0] << 4) & 0x30; - if (inlen > 1) - fragment |= in[1] >> 4; - *out++ = base64digits[fragment]; - *out++ = (inlen < 2) ? '-' - : base64digits[(in[1] << 2) & 0x3c]; - *out++ = '-'; - } - *out = '\0'; + return base64_encode_real(in, inlen, out, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"); } static void yahoo_add_to_send_queue(struct yahoo_input_data *yid, void *data, int length) -- cgit v1.2.3 From 7ed3199067034b4fda4055778e02274f83bcfcb8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 25 Jun 2006 16:07:01 +0200 Subject: Moved Base64-related functions to a separate file and added decode funtions. --- protocols/yahoo/libyahoo2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index ee0f2f0e..69b63baa 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -89,6 +89,8 @@ char *strchr (), *strrchr (); #define vsnprintf _vsnprintf #endif +#include "base64.h" + #ifdef USE_STRUCT_CALLBACKS struct yahoo_callbacks *yc=NULL; @@ -697,7 +699,7 @@ static void yahoo_packet_dump(unsigned char *data, int len) /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ static void to_y64(unsigned char *out, const unsigned char *in, int inlen) { - return base64_encode_real(in, inlen, out, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"); + base64_encode_real(in, inlen, out, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"); } static void yahoo_add_to_send_queue(struct yahoo_input_data *yid, void *data, int length) -- cgit v1.2.3 From 0a3c243b6659dc10efb227e507f324c2711d6dcd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 1 Jul 2006 01:18:56 +0200 Subject: Got rid of struct aim_user (now using account_t everywhere). Needs some more testing though. --- protocols/yahoo/yahoo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 79c0febb..c21779ba 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -120,16 +120,16 @@ static char *byahoo_strip( char *in ) return( g_strndup( in, len ) ); } -static void byahoo_login( struct aim_user *user ) +static void byahoo_login( account_t *acc ) { - struct gaim_connection *gc = new_gaim_conn( user ); + struct gaim_connection *gc = new_gaim_conn( acc ); struct byahoo_data *yd = gc->proto_data = g_new0( struct byahoo_data, 1 ); yd->logged_in = FALSE; yd->current_status = YAHOO_STATUS_AVAILABLE; set_login_progress( gc, 1, "Connecting" ); - yd->y2_id = yahoo_init( user->username, user->password ); + yd->y2_id = yahoo_init( acc->user, acc->pass ); yahoo_login( yd->y2_id, yd->current_status ); } @@ -424,7 +424,7 @@ static struct gaim_connection *byahoo_get_gc_by_id( int id ) gc = l->data; yd = gc->proto_data; - if( !strcmp(gc->prpl->name, "yahoo") && yd->y2_id == id ) + if( strcmp( gc->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id ) return( gc ); } -- cgit v1.2.3 From 5b52a4895e5a59ff6509f7771f4d8665737688c3 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 3 Jul 2006 23:22:45 +0200 Subject: Implemented per-account nick lists instead of per-protocol nick lists. nick_t is dead, instead nicks are just saves in a per-account_t GLib hash table. While doing this, the import_buddies command finally died and text_save() disappeared, because the old file format can't handle most of the new features in this branch anyway. Still have to implement support for the new nick lists in text_load()! --- protocols/yahoo/yahoo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index c21779ba..23c6f813 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -408,7 +408,8 @@ void byahoo_init( ) ret->chat_invite = byahoo_chat_invite; ret->chat_leave = byahoo_chat_leave; ret->chat_open = byahoo_chat_open; - ret->cmp_buddynames = g_strcasecmp; + + ret->handle_cmp = g_strcasecmp; register_protocol(ret); } -- cgit v1.2.3 From 66b9e86eafc3709c491f96c917069db8b6a0c895 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Jul 2006 15:33:31 +0200 Subject: Add support for checking test suite coverage using gcov. --- protocols/yahoo/Makefile | 3 +++ 1 file changed, 3 insertions(+) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/Makefile b/protocols/yahoo/Makefile index b4014f8a..34c3551a 100644 --- a/protocols/yahoo/Makefile +++ b/protocols/yahoo/Makefile @@ -16,6 +16,9 @@ LFLAGS += -r # [SH] Phony targets all: yahoo_mod.o +check: all +gcov: + gcov *.c .PHONY: all clean distclean -- cgit v1.2.3 From a36b030d747a39fed8224e6350d56d55b2aec4e2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 27 Jul 2006 21:18:33 +0200 Subject: The Yahoo! module now properly sets away states instead of away messages. (So other BitlBees can read your Yahoo! away states better and others can see the proper icons again.) --- protocols/yahoo/yahoo.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 79c0febb..28735432 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -191,13 +191,18 @@ static void byahoo_set_away( struct gaim_connection *gc, char *state, char *msg gc->away = NULL; - if( msg ) + if( state && msg && g_strcasecmp( state, msg ) != 0 ) { yd->current_status = YAHOO_STATUS_CUSTOM; gc->away = ""; } - if( state ) + else if( state ) { + /* Set msg to NULL since (if it isn't NULL already) it's equal + to state. msg must be empty if we want to use an existing + away state. */ + msg = NULL; + gc->away = ""; if( g_strcasecmp( state, "Available" ) == 0 ) { @@ -234,10 +239,7 @@ static void byahoo_set_away( struct gaim_connection *gc, char *state, char *msg else yd->current_status = YAHOO_STATUS_AVAILABLE; - if( yd->current_status == YAHOO_STATUS_INVISIBLE ) - yahoo_set_away( yd->y2_id, yd->current_status, NULL, gc->away != NULL ); - else - yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL ); + yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL ); } static GList *byahoo_away_states( struct gaim_connection *gc ) -- cgit v1.2.3 From 348c11b16c156979ef2c7141ca7450af693b3713 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 22 Jan 2007 10:42:55 +0100 Subject: Add lcov target --- protocols/yahoo/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/Makefile b/protocols/yahoo/Makefile index 34c3551a..2cfd147b 100644 --- a/protocols/yahoo/Makefile +++ b/protocols/yahoo/Makefile @@ -17,6 +17,7 @@ LFLAGS += -r # [SH] Phony targets all: yahoo_mod.o check: all +lcov: gcov: gcov *.c -- cgit v1.2.3 From fa29d09342c79b886efacee4cfc3078be5f5a722 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 27 Mar 2007 22:53:11 -0700 Subject: Preparing for Jabber conference room support. --- protocols/yahoo/yahoo.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 6f286196..e0dcabff 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -139,7 +139,7 @@ static void byahoo_close( struct gaim_connection *gc ) GSList *l; while( gc->conversations ) - serv_got_chat_left( gc, gc->conversations->id ); + serv_got_chat_left( gc->conversations ); for( l = yd->buddygroups; l; l = l->next ) { @@ -331,40 +331,31 @@ static char *byahoo_get_status_string( struct gaim_connection *gc, int stat ) } } -static int byahoo_chat_send( struct gaim_connection *gc, int id, char *message ) +static int byahoo_chat_send( struct conversation *c, char *message ) { - struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; - struct conversation *c; + struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data; - for( c = gc->conversations; c && c->id != id; c = c->next ); - yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 ); return( 0 ); } -static void byahoo_chat_invite( struct gaim_connection *gc, int id, char *msg, char *who ) +static void byahoo_chat_invite( struct conversation *c, char *msg, char *who ) { - struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; - struct conversation *c; - - for( c = gc->conversations; c && c->id != id; c = c->next ); + struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data; yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ); } -static void byahoo_chat_leave( struct gaim_connection *gc, int id ) +static void byahoo_chat_leave( struct conversation *c ) { - struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; - struct conversation *c; - - for( c = gc->conversations; c && c->id != id; c = c->next ); + struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data; yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title ); - serv_got_chat_left( gc, c->id ); + serv_got_chat_left( c ); } -static int byahoo_chat_open( struct gaim_connection *gc, char *who ) +static struct conversation *byahoo_chat_open( struct gaim_connection *gc, char *who ) { struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; struct conversation *c; @@ -374,7 +365,7 @@ static int byahoo_chat_open( struct gaim_connection *gc, char *who ) roomname = g_new0( char, strlen( gc->username ) + 16 ); g_snprintf( roomname, strlen( gc->username ) + 16, "%s-Bee-%d", gc->username, byahoo_chat_id ); - c = serv_got_joined_chat( gc, ++byahoo_chat_id, roomname ); + c = serv_got_joined_chat( gc, roomname ); add_chat_buddy( c, gc->username ); /* FIXME: Free this thing when the chat's destroyed. We can't *always* @@ -386,7 +377,7 @@ static int byahoo_chat_open( struct gaim_connection *gc, char *who ) g_free( roomname ); - return( 1 ); + return c; } void byahoo_init( ) @@ -804,7 +795,7 @@ static void byahoo_accept_conf( gpointer w, struct byahoo_conf_invitation *inv ) static void byahoo_reject_conf( gpointer w, struct byahoo_conf_invitation *inv ) { yahoo_conference_decline( inv->yid, NULL, inv->members, inv->name, "User rejected groupchat" ); - serv_got_chat_left( inv->gc, inv->c->id ); + serv_got_chat_left( inv->c ); g_free( inv->name ); g_free( inv ); } @@ -819,7 +810,7 @@ void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList inv = g_malloc( sizeof( struct byahoo_conf_invitation ) ); memset( inv, 0, sizeof( struct byahoo_conf_invitation ) ); inv->name = g_strdup( room ); - inv->c = serv_got_joined_chat( gc, ++byahoo_chat_id, room ); + inv->c = serv_got_joined_chat( gc, room ); inv->c->data = members; inv->yid = id; inv->members = members; @@ -871,7 +862,8 @@ void ext_yahoo_conf_message( int id, char *who, char *room, char *msg, int utf8 for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); - serv_got_chat_in( gc, c ? c->id : 0, who, 0, m, 0 ); + if( c ) + serv_got_chat_in( c, who, 0, m, 0 ); g_free( m ); } -- cgit v1.2.3 From 0da65d5fb37691ed4d31f7ab4058732f1440db6b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 30 Mar 2007 22:40:45 -0700 Subject: s/gaim_connection/im_connection/ and some other minor API changes. The rest will come tomorrow. It compiles, I'll leave the real testing up to someone else. ;-) --- protocols/yahoo/yahoo.c | 215 ++++++++++++++++++++++++------------------------ 1 file changed, 107 insertions(+), 108 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index e0dcabff..52db9007 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -57,10 +57,10 @@ struct byahoo_input_data struct byahoo_conf_invitation { char *name; - struct conversation *c; + struct groupchat *c; int yid; YList *members; - struct gaim_connection *gc; + struct im_connection *ic; }; static GSList *byahoo_inputs = NULL; @@ -122,24 +122,24 @@ static char *byahoo_strip( char *in ) static void byahoo_login( account_t *acc ) { - struct gaim_connection *gc = new_gaim_conn( acc ); - struct byahoo_data *yd = gc->proto_data = g_new0( struct byahoo_data, 1 ); + struct im_connection *ic = new_gaim_conn( acc ); + struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 ); yd->logged_in = FALSE; yd->current_status = YAHOO_STATUS_AVAILABLE; - set_login_progress( gc, 1, "Connecting" ); + set_login_progress( ic, 1, "Connecting" ); yd->y2_id = yahoo_init( acc->user, acc->pass ); yahoo_login( yd->y2_id, yd->current_status ); } -static void byahoo_close( struct gaim_connection *gc ) +static void byahoo_logout( struct im_connection *ic ) { - struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; + struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; GSList *l; - while( gc->conversations ) - serv_got_chat_left( gc->conversations ); + while( ic->conversations ) + serv_got_chat_left( ic->conversations ); for( l = yd->buddygroups; l; l = l->next ) { @@ -159,42 +159,42 @@ static void byahoo_close( struct gaim_connection *gc ) g_free( yd ); } -static void byahoo_get_info(struct gaim_connection *gc, char *who) +static void byahoo_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"), + serv_got_crap(ic, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), yahoo_get_profile_url(), who); } -static int byahoo_send_im( struct gaim_connection *gc, char *who, char *what, int len, int flags ) +static int byahoo_send_im( struct im_connection *ic, char *who, char *what, int flags ) { - struct byahoo_data *yd = gc->proto_data; + struct byahoo_data *yd = ic->proto_data; yahoo_send_im( yd->y2_id, NULL, who, what, 1 ); return 1; } -static int byahoo_send_typing( struct gaim_connection *gc, char *who, int typing ) +static int byahoo_send_typing( struct im_connection *ic, char *who, int typing ) { - struct byahoo_data *yd = gc->proto_data; + struct byahoo_data *yd = ic->proto_data; yahoo_send_typing( yd->y2_id, NULL, who, typing ); return 1; } -static void byahoo_set_away( struct gaim_connection *gc, char *state, char *msg ) +static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) { - struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; + struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; - gc->away = NULL; + ic->away = NULL; if( state && msg && g_strcasecmp( state, msg ) != 0 ) { yd->current_status = YAHOO_STATUS_CUSTOM; - gc->away = ""; + ic->away = ""; } else if( state ) { @@ -203,11 +203,11 @@ static void byahoo_set_away( struct gaim_connection *gc, char *state, char *msg away state. */ msg = NULL; - gc->away = ""; + ic->away = ""; if( g_strcasecmp( state, "Available" ) == 0 ) { yd->current_status = YAHOO_STATUS_AVAILABLE; - gc->away = NULL; + ic->away = NULL; } else if( g_strcasecmp( state, "Be Right Back" ) == 0 ) yd->current_status = YAHOO_STATUS_BRB; @@ -233,16 +233,16 @@ static void byahoo_set_away( struct gaim_connection *gc, char *state, char *msg { yd->current_status = YAHOO_STATUS_AVAILABLE; - gc->away = NULL; + ic->away = NULL; } } else yd->current_status = YAHOO_STATUS_AVAILABLE; - yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL ); + yahoo_set_away( yd->y2_id, yd->current_status, msg, ic->away != NULL ); } -static GList *byahoo_away_states( struct gaim_connection *gc ) +static GList *byahoo_away_states( struct im_connection *ic ) { GList *m = NULL; @@ -262,23 +262,23 @@ static GList *byahoo_away_states( struct gaim_connection *gc ) return m; } -static void byahoo_keepalive( struct gaim_connection *gc ) +static void byahoo_keepalive( struct im_connection *ic ) { - struct byahoo_data *yd = gc->proto_data; + struct byahoo_data *yd = ic->proto_data; yahoo_keepalive( yd->y2_id ); } -static void byahoo_add_buddy( struct gaim_connection *gc, char *who ) +static void byahoo_add_buddy( struct im_connection *ic, char *who, char *group ) { - struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; + struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; - yahoo_add_buddy( yd->y2_id, who, BYAHOO_DEFAULT_GROUP ); + yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP ); } -static void byahoo_remove_buddy( struct gaim_connection *gc, char *who, char *group ) +static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *group ) { - struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; + struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; GSList *bgl; yahoo_remove_buddy( yd->y2_id, who, BYAHOO_DEFAULT_GROUP ); @@ -292,7 +292,7 @@ static void byahoo_remove_buddy( struct gaim_connection *gc, char *who, char *gr } } -static char *byahoo_get_status_string( struct gaim_connection *gc, int stat ) +static char *byahoo_get_status_string( struct im_connection *ic, int stat ) { enum yahoo_status a = stat >> 1; @@ -331,42 +331,40 @@ static char *byahoo_get_status_string( struct gaim_connection *gc, int stat ) } } -static int byahoo_chat_send( struct conversation *c, char *message ) +static void byahoo_chat_send( struct groupchat *c, char *message, int flags ) { - struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data; + struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 ); - - return( 0 ); } -static void byahoo_chat_invite( struct conversation *c, char *msg, char *who ) +static void byahoo_chat_invite( struct groupchat *c, char *msg, char *who ) { - struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data; + struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ); } -static void byahoo_chat_leave( struct conversation *c ) +static void byahoo_chat_leave( struct groupchat *c ) { - struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data; + struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title ); serv_got_chat_left( c ); } -static struct conversation *byahoo_chat_open( struct gaim_connection *gc, char *who ) +static struct groupchat *byahoo_chat_with( struct im_connection *ic, char *who ) { - struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; - struct conversation *c; + struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; + struct groupchat *c; char *roomname; YList *members; - roomname = g_new0( char, strlen( gc->username ) + 16 ); - g_snprintf( roomname, strlen( gc->username ) + 16, "%s-Bee-%d", gc->username, byahoo_chat_id ); + roomname = g_new0( char, strlen( ic->username ) + 16 ); + g_snprintf( roomname, strlen( ic->username ) + 16, "%s-Bee-%d", ic->username, byahoo_chat_id ); - c = serv_got_joined_chat( gc, roomname ); - add_chat_buddy( c, gc->username ); + c = serv_got_joined_chat( ic, roomname ); + add_chat_buddy( c, ic->username ); /* FIXME: Free this thing when the chat's destroyed. We can't *always* do this because it's not always created here. */ @@ -380,18 +378,19 @@ static struct conversation *byahoo_chat_open( struct gaim_connection *gc, char * return c; } -void byahoo_init( ) +void byahoo_initmodule( ) { struct prpl *ret = g_new0(struct prpl, 1); ret->name = "yahoo"; ret->login = byahoo_login; - ret->close = byahoo_close; + ret->keepalive = byahoo_keepalive; + ret->logout = byahoo_logout; + ret->send_im = byahoo_send_im; ret->get_info = byahoo_get_info; ret->away_states = byahoo_away_states; ret->set_away = byahoo_set_away; - ret->keepalive = byahoo_keepalive; ret->add_buddy = byahoo_add_buddy; ret->remove_buddy = byahoo_remove_buddy; ret->get_status_string = byahoo_get_status_string; @@ -400,26 +399,26 @@ void byahoo_init( ) ret->chat_send = byahoo_chat_send; ret->chat_invite = byahoo_chat_invite; ret->chat_leave = byahoo_chat_leave; - ret->chat_open = byahoo_chat_open; + ret->chat_with = byahoo_chat_with; ret->handle_cmp = g_strcasecmp; register_protocol(ret); } -static struct gaim_connection *byahoo_get_gc_by_id( int id ) +static struct im_connection *byahoo_get_ic_by_id( int id ) { GSList *l; - struct gaim_connection *gc; + struct im_connection *ic; struct byahoo_data *yd; for( l = get_connections(); l; l = l->next ) { - gc = l->data; - yd = gc->proto_data; + ic = l->data; + yd = ic->proto_data; - if( strcmp( gc->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id ) - return( gc ); + if( strcmp( ic->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id ) + return( ic ); } return( NULL ); @@ -440,7 +439,7 @@ void byahoo_connect_callback( gpointer data, gint source, b_input_condition cond { struct byahoo_connect_callback_data *d = data; - if( !byahoo_get_gc_by_id( d->id ) ) + if( !byahoo_get_ic_by_id( d->id ) ) { g_free( d ); return; @@ -462,7 +461,7 @@ gboolean byahoo_read_ready_callback( gpointer data, gint source, b_input_conditi { struct byahoo_read_ready_data *d = data; - if( !byahoo_get_gc_by_id( d->id ) ) + if( !byahoo_get_ic_by_id( d->id ) ) /* WTF doesn't libyahoo clean this up? */ return FALSE; @@ -483,7 +482,7 @@ gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condit { struct byahoo_write_ready_data *d = data; - if( !byahoo_get_gc_by_id( d->id ) ) + if( !byahoo_get_ic_by_id( d->id ) ) /* WTF doesn't libyahoo clean this up? */ return FALSE; @@ -494,10 +493,10 @@ gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condit void ext_yahoo_login_response( int id, int succ, char *url ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); + struct im_connection *ic = byahoo_get_ic_by_id( id ); struct byahoo_data *yd = NULL; - if( gc == NULL ) + if( ic == NULL ) { /* libyahoo2 seems to call this one twice when something went wrong sometimes. Don't know why. Because we clean @@ -507,11 +506,11 @@ void ext_yahoo_login_response( int id, int succ, char *url ) return; } - yd = (struct byahoo_data *) gc->proto_data; + yd = (struct byahoo_data *) ic->proto_data; if( succ == YAHOO_LOGIN_OK ) { - account_online( gc ); + account_online( ic ); yd->logged_in = TRUE; } @@ -531,7 +530,7 @@ void ext_yahoo_login_response( int id, int succ, char *url ) else if( succ == YAHOO_LOGIN_DUPL ) { errstr = "Logged in on a different machine or device"; - gc->wants_to_die = TRUE; + ic->wants_to_die = TRUE; } else if( succ == YAHOO_LOGIN_SOCK ) errstr = "Socket problem"; @@ -550,20 +549,20 @@ void ext_yahoo_login_response( int id, int succ, char *url ) } if( yd->logged_in ) - hide_login_progress_error( gc, s ); + hide_login_progress_error( ic, s ); else - hide_login_progress( gc, s ); + hide_login_progress( ic, s ); g_free( s ); - signoff( gc ); + signoff( ic ); } } void ext_yahoo_got_buddies( int id, YList *buds ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); - struct byahoo_data *yd = gc->proto_data; + struct im_connection *ic = byahoo_get_ic_by_id( id ); + struct byahoo_data *yd = ic->proto_data; YList *bl = buds; while( bl ) @@ -580,7 +579,7 @@ void ext_yahoo_got_buddies( int id, YList *buds ) yd->buddygroups = g_slist_append( yd->buddygroups, bg ); } - add_buddy( gc, b->group, b->id, b->real_name ); + add_buddy( ic, b->group, b->id, b->real_name ); bl = bl->next; } } @@ -599,68 +598,68 @@ void ext_yahoo_got_cookies( int id ) void ext_yahoo_status_changed( int id, char *who, int stat, char *msg, int away ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); + struct im_connection *ic = byahoo_get_ic_by_id( id ); - serv_got_update( gc, who, stat != YAHOO_STATUS_OFFLINE, 0, 0, + serv_got_update( ic, who, stat != YAHOO_STATUS_OFFLINE, 0, 0, ( stat == YAHOO_STATUS_IDLE ) ? away : 0, ( stat != YAHOO_STATUS_AVAILABLE ) | ( stat << 1 ), 0 ); } void ext_yahoo_got_im( int id, char *who, char *msg, long tm, int stat, int utf8 ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); + struct im_connection *ic = byahoo_get_ic_by_id( id ); char *m = byahoo_strip( msg ); - serv_got_im( gc, who, m, 0, 0, strlen( m ) ); + serv_got_im( ic, who, m, 0, 0, strlen( m ) ); g_free( m ); } void ext_yahoo_got_file( int id, char *who, char *url, long expires, char *msg, char *fname, unsigned long fesize ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); + struct im_connection *ic = byahoo_get_ic_by_id( id ); - serv_got_crap( gc, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); + serv_got_crap( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); } void ext_yahoo_typing_notify( int id, char *who, int stat ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); + struct im_connection *ic = byahoo_get_ic_by_id( id ); if (stat == 1) { /* User is typing */ - serv_got_typing( gc, who, 1, 1 ); + serv_got_typing( ic, who, 1, 1 ); } else { /* User stopped typing */ - serv_got_typing( gc, who, 1, 0 ); + serv_got_typing( ic, who, 1, 0 ); } } void ext_yahoo_system_message( int id, char *msg ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); + struct im_connection *ic = byahoo_get_ic_by_id( id ); - serv_got_crap( gc, "Yahoo! system message: %s", msg ); + serv_got_crap( ic, "Yahoo! system message: %s", msg ); } void ext_yahoo_webcam_invite( int id, char *from ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); + struct im_connection *ic = byahoo_get_ic_by_id( id ); - serv_got_crap( gc, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from ); + serv_got_crap( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from ); } void ext_yahoo_error( int id, char *err, int fatal ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); + struct im_connection *ic = byahoo_get_ic_by_id( id ); if( fatal ) { - hide_login_progress_error( gc, err ); - signoff( gc ); + hide_login_progress_error( ic, err ); + signoff( ic ); } else { - do_error_dialog( gc, err, "Yahoo! error" ); + do_error_dialog( ic, err, "Yahoo! error" ); } } @@ -787,7 +786,7 @@ int ext_yahoo_connect(char *host, int port) static void byahoo_accept_conf( gpointer w, struct byahoo_conf_invitation *inv ) { yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name ); - add_chat_buddy( inv->c, inv->gc->username ); + add_chat_buddy( inv->c, inv->ic->username ); g_free( inv->name ); g_free( inv ); } @@ -802,7 +801,7 @@ static void byahoo_reject_conf( gpointer w, struct byahoo_conf_invitation *inv ) void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList *members ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); + struct im_connection *ic = byahoo_get_ic_by_id( id ); struct byahoo_conf_invitation *inv; char txt[1024]; YList *m; @@ -810,34 +809,34 @@ void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList inv = g_malloc( sizeof( struct byahoo_conf_invitation ) ); memset( inv, 0, sizeof( struct byahoo_conf_invitation ) ); inv->name = g_strdup( room ); - inv->c = serv_got_joined_chat( gc, room ); + inv->c = serv_got_joined_chat( ic, room ); inv->c->data = members; inv->yid = id; inv->members = members; - inv->gc = gc; + inv->ic = ic; for( m = members; m; m = m->next ) - if( g_strcasecmp( m->data, gc->username ) != 0 ) + if( g_strcasecmp( m->data, ic->username ) != 0 ) add_chat_buddy( inv->c, m->data ); g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg ); - do_ask_dialog( gc, txt, inv, byahoo_accept_conf, byahoo_reject_conf ); + do_ask_dialog( ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf ); } void ext_yahoo_conf_userdecline( int id, char *who, char *room, char *msg ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); + struct im_connection *ic = byahoo_get_ic_by_id( id ); - serv_got_crap( gc, "Invite to chatroom %s rejected by %s: %s", room, who, msg ); + serv_got_crap( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg ); } void ext_yahoo_conf_userjoin( int id, char *who, char *room ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); - struct conversation *c; + struct im_connection *ic = byahoo_get_ic_by_id( id ); + struct groupchat *c; - for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); + for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); if( c ) add_chat_buddy( c, who ); @@ -845,10 +844,10 @@ void ext_yahoo_conf_userjoin( int id, char *who, char *room ) void ext_yahoo_conf_userleave( int id, char *who, char *room ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); - struct conversation *c; + struct im_connection *ic = byahoo_get_ic_by_id( id ); + struct groupchat *c; - for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); + for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); if( c ) remove_chat_buddy( c, who, "" ); @@ -856,11 +855,11 @@ void ext_yahoo_conf_userleave( int id, char *who, char *room ) void ext_yahoo_conf_message( int id, char *who, char *room, char *msg, int utf8 ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); + struct im_connection *ic = byahoo_get_ic_by_id( id ); char *m = byahoo_strip( msg ); - struct conversation *c; + struct groupchat *c; - for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); + for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); if( c ) serv_got_chat_in( c, who, 0, m, 0 ); @@ -909,12 +908,12 @@ void ext_yahoo_game_notify( int id, char *who, int stat ) void ext_yahoo_mail_notify( int id, char *from, char *subj, int cnt ) { - struct gaim_connection *gc = byahoo_get_gc_by_id( id ); + struct im_connection *ic = byahoo_get_ic_by_id( id ); if( from && subj ) - serv_got_crap( gc, "Received e-mail message from %s with subject `%s'", from, subj ); + serv_got_crap( ic, "Received e-mail message from %s with subject `%s'", from, subj ); else if( cnt > 0 ) - serv_got_crap( gc, "Received %d new e-mails", cnt ); + serv_got_crap( ic, "Received %d new e-mails", cnt ); } void ext_yahoo_webcam_invite_reply( int id, char *from, int accept ) -- cgit v1.2.3 From aef4828a1dc51de10a43bb7dd5d023de9971295b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 5 Apr 2007 22:20:31 -0700 Subject: 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... --- protocols/yahoo/yahoo.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 52db9007..424a0ad1 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -122,13 +122,13 @@ static char *byahoo_strip( char *in ) static void byahoo_login( account_t *acc ) { - struct im_connection *ic = new_gaim_conn( acc ); + struct im_connection *ic = imc_new( acc ); struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 ); yd->logged_in = FALSE; yd->current_status = YAHOO_STATUS_AVAILABLE; - set_login_progress( ic, 1, "Connecting" ); + imc_log( ic, "Connecting" ); yd->y2_id = yahoo_init( acc->user, acc->pass ); yahoo_login( yd->y2_id, yd->current_status ); } @@ -162,7 +162,7 @@ static void byahoo_logout( struct im_connection *ic ) static void byahoo_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"), + imc_log(ic, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), yahoo_get_profile_url(), who); } @@ -510,7 +510,7 @@ void ext_yahoo_login_response( int id, int succ, char *url ) if( succ == YAHOO_LOGIN_OK ) { - account_online( ic ); + imc_connected( ic ); yd->logged_in = TRUE; } @@ -549,13 +549,13 @@ void ext_yahoo_login_response( int id, int succ, char *url ) } if( yd->logged_in ) - hide_login_progress_error( ic, s ); + imc_error( ic, s ); else - hide_login_progress( ic, s ); + imc_error( ic, s ); g_free( s ); - signoff( ic ); + imc_logout( ic ); } } @@ -618,7 +618,7 @@ void ext_yahoo_got_file( int id, char *who, char *url, long expires, char *msg, { struct im_connection *ic = byahoo_get_ic_by_id( id ); - serv_got_crap( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); + imc_log( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); } void ext_yahoo_typing_notify( int id, char *who, int stat ) @@ -638,29 +638,24 @@ void ext_yahoo_system_message( int id, char *msg ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); - serv_got_crap( ic, "Yahoo! system message: %s", msg ); + imc_log( ic, "Yahoo! system message: %s", msg ); } void ext_yahoo_webcam_invite( int id, char *from ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); - serv_got_crap( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from ); + imc_log( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from ); } void ext_yahoo_error( int id, char *err, int fatal ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); + imc_error( ic, "%s", err ); + if( fatal ) - { - hide_login_progress_error( ic, err ); - signoff( ic ); - } - else - { - do_error_dialog( ic, err, "Yahoo! error" ); - } + imc_logout( ic ); } /* TODO: Clear up the mess of inp and d structures */ @@ -828,7 +823,7 @@ void ext_yahoo_conf_userdecline( int id, char *who, char *room, char *msg ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); - serv_got_crap( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg ); + imc_log( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg ); } void ext_yahoo_conf_userjoin( int id, char *who, char *room ) @@ -911,9 +906,9 @@ void ext_yahoo_mail_notify( int id, char *from, char *subj, int cnt ) struct im_connection *ic = byahoo_get_ic_by_id( id ); if( from && subj ) - serv_got_crap( ic, "Received e-mail message from %s with subject `%s'", from, subj ); + imc_log( ic, "Received e-mail message from %s with subject `%s'", from, subj ); else if( cnt > 0 ) - serv_got_crap( ic, "Received %d new e-mails", cnt ); + imc_log( ic, "Received %d new e-mails", cnt ); } void ext_yahoo_webcam_invite_reply( int id, char *from, int accept ) -- cgit v1.2.3 From cd4723c257f9f7bd8d4a46c6562f93c2aefc3dbb Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Apr 2007 14:59:52 -0700 Subject: More format string problems. --- protocols/yahoo/yahoo.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 424a0ad1..c10c3103 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -517,7 +517,6 @@ void ext_yahoo_login_response( int id, int succ, char *url ) else { char *errstr; - char *s; yd->logged_in = FALSE; @@ -538,22 +537,9 @@ void ext_yahoo_login_response( int id, int succ, char *url ) errstr = "Unknown error"; if( url && *url ) - { - s = g_malloc( strlen( "Error %d (%s). See %s for more information." ) + strlen( url ) + strlen( errstr ) + 16 ); - sprintf( s, "Error %d (%s). See %s for more information.", succ, errstr, url ); - } + imc_error( ic, "Error %d (%s). See %s for more information.", succ, errstr, url ); else - { - s = g_malloc( strlen( "Error %d (%s)" ) + strlen( errstr ) + 16 ); - sprintf( s, "Error %d (%s)", succ, errstr ); - } - - if( yd->logged_in ) - imc_error( ic, s ); - else - imc_error( ic, s ); - - g_free( s ); + imc_error( ic, "Error %d (%s)", succ, errstr ); imc_logout( ic ); } -- cgit v1.2.3 From c2fb38096ea4e75a680e57e103d4a4986aa84c75 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Apr 2007 15:39:35 -0700 Subject: Cleaned up struct im_connection. No more username/password stuff since it's in acc too. wants_to_die is now an argument to imc_logout(). --- protocols/yahoo/yahoo.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index c10c3103..ae66b209 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -360,11 +360,10 @@ static struct groupchat *byahoo_chat_with( struct im_connection *ic, char *who ) char *roomname; YList *members; - roomname = g_new0( char, strlen( ic->username ) + 16 ); - g_snprintf( roomname, strlen( ic->username ) + 16, "%s-Bee-%d", ic->username, byahoo_chat_id ); + roomname = g_strdup_printf( "%s-Bee-%d", ic->acc->user, byahoo_chat_id ); c = serv_got_joined_chat( ic, roomname ); - add_chat_buddy( c, ic->username ); + add_chat_buddy( c, ic->acc->user ); /* FIXME: Free this thing when the chat's destroyed. We can't *always* do this because it's not always created here. */ @@ -517,6 +516,7 @@ void ext_yahoo_login_response( int id, int succ, char *url ) else { char *errstr; + int allow_reconnect = TRUE; yd->logged_in = FALSE; @@ -529,7 +529,7 @@ void ext_yahoo_login_response( int id, int succ, char *url ) else if( succ == YAHOO_LOGIN_DUPL ) { errstr = "Logged in on a different machine or device"; - ic->wants_to_die = TRUE; + allow_reconnect = FALSE; } else if( succ == YAHOO_LOGIN_SOCK ) errstr = "Socket problem"; @@ -541,7 +541,7 @@ void ext_yahoo_login_response( int id, int succ, char *url ) else imc_error( ic, "Error %d (%s)", succ, errstr ); - imc_logout( ic ); + imc_logout( ic, allow_reconnect ); } } @@ -641,7 +641,7 @@ void ext_yahoo_error( int id, char *err, int fatal ) imc_error( ic, "%s", err ); if( fatal ) - imc_logout( ic ); + imc_logout( ic, TRUE ); } /* TODO: Clear up the mess of inp and d structures */ @@ -767,7 +767,7 @@ int ext_yahoo_connect(char *host, int port) static void byahoo_accept_conf( gpointer w, struct byahoo_conf_invitation *inv ) { yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name ); - add_chat_buddy( inv->c, inv->ic->username ); + add_chat_buddy( inv->c, inv->ic->acc->user ); g_free( inv->name ); g_free( inv ); } @@ -797,7 +797,7 @@ void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList inv->ic = ic; for( m = members; m; m = m->next ) - if( g_strcasecmp( m->data, ic->username ) != 0 ) + if( g_strcasecmp( m->data, ic->acc->user ) != 0 ) add_chat_buddy( inv->c, m->data ); g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg ); -- cgit v1.2.3 From 84b045d409f1e8da6d8bf379c6fef7236dcd9bcd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Apr 2007 18:03:08 -0700 Subject: s/imc/imcb/ for callback functions. Moved things aroundin nogaim.h a little bit, grouping things by category instead of original Gaim 0.58 filename. --- protocols/yahoo/yahoo.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index ae66b209..e380d0ae 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -122,13 +122,13 @@ static char *byahoo_strip( char *in ) static void byahoo_login( account_t *acc ) { - struct im_connection *ic = imc_new( acc ); + struct im_connection *ic = imcb_new( acc ); struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 ); yd->logged_in = FALSE; yd->current_status = YAHOO_STATUS_AVAILABLE; - imc_log( ic, "Connecting" ); + imcb_log( ic, "Connecting" ); yd->y2_id = yahoo_init( acc->user, acc->pass ); yahoo_login( yd->y2_id, yd->current_status ); } @@ -162,7 +162,7 @@ static void byahoo_logout( struct im_connection *ic ) static void byahoo_get_info(struct im_connection *ic, char *who) { /* Just make an URL and let the user fetch the info */ - imc_log(ic, "%s\n%s: %s%s", _("User Info"), + imcb_log(ic, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), yahoo_get_profile_url(), who); } @@ -509,7 +509,7 @@ void ext_yahoo_login_response( int id, int succ, char *url ) if( succ == YAHOO_LOGIN_OK ) { - imc_connected( ic ); + imcb_connected( ic ); yd->logged_in = TRUE; } @@ -537,9 +537,9 @@ void ext_yahoo_login_response( int id, int succ, char *url ) errstr = "Unknown error"; if( url && *url ) - imc_error( ic, "Error %d (%s). See %s for more information.", succ, errstr, url ); + imcb_error( ic, "Error %d (%s). See %s for more information.", succ, errstr, url ); else - imc_error( ic, "Error %d (%s)", succ, errstr ); + imcb_error( ic, "Error %d (%s)", succ, errstr ); imc_logout( ic, allow_reconnect ); } @@ -604,7 +604,7 @@ void ext_yahoo_got_file( int id, char *who, char *url, long expires, char *msg, { struct im_connection *ic = byahoo_get_ic_by_id( id ); - imc_log( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); + imcb_log( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); } void ext_yahoo_typing_notify( int id, char *who, int stat ) @@ -624,21 +624,21 @@ void ext_yahoo_system_message( int id, char *msg ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); - imc_log( ic, "Yahoo! system message: %s", msg ); + imcb_log( ic, "Yahoo! system message: %s", msg ); } void ext_yahoo_webcam_invite( int id, char *from ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); - imc_log( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from ); + imcb_log( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from ); } void ext_yahoo_error( int id, char *err, int fatal ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); - imc_error( ic, "%s", err ); + imcb_error( ic, "%s", err ); if( fatal ) imc_logout( ic, TRUE ); @@ -802,14 +802,14 @@ void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg ); - do_ask_dialog( ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf ); + imcb_ask( ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf ); } void ext_yahoo_conf_userdecline( int id, char *who, char *room, char *msg ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); - imc_log( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg ); + imcb_log( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg ); } void ext_yahoo_conf_userjoin( int id, char *who, char *room ) @@ -892,9 +892,9 @@ void ext_yahoo_mail_notify( int id, char *from, char *subj, int cnt ) struct im_connection *ic = byahoo_get_ic_by_id( id ); if( from && subj ) - imc_log( ic, "Received e-mail message from %s with subject `%s'", from, subj ); + imcb_log( ic, "Received e-mail message from %s with subject `%s'", from, subj ); else if( cnt > 0 ) - imc_log( ic, "Received %d new e-mails", cnt ); + imcb_log( ic, "Received %d new e-mails", cnt ); } void ext_yahoo_webcam_invite_reply( int id, char *from, int accept ) -- cgit v1.2.3 From 6bbb939e953bbe1ca9ed3101a1569abe4521f543 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Apr 2007 21:01:13 -0700 Subject: Split serv_got_update() into imcb_buddy_(status|times). (Well, the second one isn't implemented yet, but I'll do that later.) At last I got rid of the hack called get_status_string(). And now Yahoo seems to mess up away messages... --- protocols/yahoo/yahoo.c | 101 +++++++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 43 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index e380d0ae..dec42bdc 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -292,45 +292,6 @@ static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *grou } } -static char *byahoo_get_status_string( struct im_connection *ic, int stat ) -{ - enum yahoo_status a = stat >> 1; - - switch (a) - { - case YAHOO_STATUS_BRB: - return "Be Right Back"; - case YAHOO_STATUS_BUSY: - return "Busy"; - case YAHOO_STATUS_NOTATHOME: - return "Not At Home"; - case YAHOO_STATUS_NOTATDESK: - return "Not At Desk"; - case YAHOO_STATUS_NOTINOFFICE: - return "Not In Office"; - case YAHOO_STATUS_ONPHONE: - return "On Phone"; - case YAHOO_STATUS_ONVACATION: - return "On Vacation"; - case YAHOO_STATUS_OUTTOLUNCH: - return "Out To Lunch"; - case YAHOO_STATUS_STEPPEDOUT: - return "Stepped Out"; - case YAHOO_STATUS_INVISIBLE: - return "Invisible"; - case YAHOO_STATUS_CUSTOM: - return "Away"; - case YAHOO_STATUS_IDLE: - return "Idle"; - case YAHOO_STATUS_OFFLINE: - return "Offline"; - case YAHOO_STATUS_NOTIFY: - return "Notify"; - default: - return "Away"; - } -} - static void byahoo_chat_send( struct groupchat *c, char *message, int flags ) { struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; @@ -392,7 +353,6 @@ void byahoo_initmodule( ) ret->set_away = byahoo_set_away; ret->add_buddy = byahoo_add_buddy; ret->remove_buddy = byahoo_remove_buddy; - ret->get_status_string = byahoo_get_status_string; ret->send_typing = byahoo_send_typing; ret->chat_send = byahoo_chat_send; @@ -585,10 +545,65 @@ void ext_yahoo_got_cookies( int id ) void ext_yahoo_status_changed( int id, char *who, int stat, char *msg, int away ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); + char *state_string = NULL; + int flags = OPT_LOGGED_IN; + + if( away ) + flags |= OPT_AWAY; + + switch (stat) + { + case YAHOO_STATUS_BRB: + state_string = "Be Right Back"; + break; + case YAHOO_STATUS_BUSY: + state_string = "Busy"; + break; + case YAHOO_STATUS_NOTATHOME: + state_string = "Not At Home"; + break; + case YAHOO_STATUS_NOTATDESK: + state_string = "Not At Desk"; + break; + case YAHOO_STATUS_NOTINOFFICE: + state_string = "Not In Office"; + break; + case YAHOO_STATUS_ONPHONE: + state_string = "On Phone"; + break; + case YAHOO_STATUS_ONVACATION: + state_string = "On Vacation"; + break; + case YAHOO_STATUS_OUTTOLUNCH: + state_string = "Out To Lunch"; + break; + case YAHOO_STATUS_STEPPEDOUT: + state_string = "Stepped Out"; + break; + case YAHOO_STATUS_INVISIBLE: + state_string = "Invisible"; + break; + case YAHOO_STATUS_CUSTOM: + state_string = "Away"; + break; + case YAHOO_STATUS_IDLE: + state_string = "Idle"; + break; + case YAHOO_STATUS_OFFLINE: + state_string = "Offline"; + flags = 0; + break; + case YAHOO_STATUS_NOTIFY: + state_string = "Notify"; + break; + } + + imcb_buddy_status( ic, who, flags, state_string, msg ); - serv_got_update( ic, who, stat != YAHOO_STATUS_OFFLINE, 0, 0, - ( stat == YAHOO_STATUS_IDLE ) ? away : 0, - ( stat != YAHOO_STATUS_AVAILABLE ) | ( stat << 1 ), 0 ); + /* Not implemented yet... + if( stat == YAHOO_STATUS_IDLE ) + imcb_buddy_times( ic, who, 0, away ); + */ } void ext_yahoo_got_im( int id, char *who, char *msg, long tm, int stat, int utf8 ) -- cgit v1.2.3 From cfc8d58f4c15048e943800272017f69804bb61b7 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Apr 2007 21:31:52 -0700 Subject: Updating the Yahoo! module. This seems to fix handling of incoming away states/messages, should fix some issues with group chats, and unfortunately also adds some crap which I don't want to clean up for now. --- protocols/yahoo/libyahoo2.c | 571 ++++++++++++++++++++++++++++++++----- protocols/yahoo/yahoo.c | 102 ++++--- protocols/yahoo/yahoo2.h | 7 +- protocols/yahoo/yahoo2_callbacks.h | 229 +++++++-------- protocols/yahoo/yahoo2_types.h | 15 +- protocols/yahoo/yahoo_util.c | 14 +- 6 files changed, 696 insertions(+), 242 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 69b63baa..38041ad4 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -104,6 +104,8 @@ void yahoo_register_callbacks(struct yahoo_callbacks * tyc) #define YAHOO_CALLBACK(x) x #endif +static int yahoo_send_data(int fd, void *data, int len); + int yahoo_log_message(char * fmt, ...) { char out[1024]; @@ -203,7 +205,12 @@ enum yahoo_service { /* these are easier to see in hex */ YAHOO_SERVICE_CHATEXIT = 0x9b, YAHOO_SERVICE_CHATLOGOUT = 0xa0, YAHOO_SERVICE_CHATPING, - YAHOO_SERVICE_COMMENT = 0xa8 + YAHOO_SERVICE_COMMENT = 0xa8, + YAHOO_SERVICE_STEALTH = 0xb9, + YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd, + YAHOO_SERVICE_PICTURE = 0xbe, + YAHOO_SERVICE_PICTURE_UPDATE = 0xc1, + YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2 }; struct yahoo_pair { @@ -740,6 +747,9 @@ static void yahoo_send_packet(struct yahoo_input_data *yid, struct yahoo_packet yahoo_packet_dump(data, len); + if( yid->type == YAHOO_CONNECTION_FT ) + yahoo_send_data(yid->fd, data, len); + else yahoo_add_to_send_queue(yid, data, len); FREE(data); } @@ -925,6 +935,7 @@ static void yahoo_process_notify(struct yahoo_input_data *yid, struct yahoo_pack struct yahoo_data *yd = yid->yd; char *msg = NULL; char *from = NULL; + char *to = NULL; int stat = 0; int accept = 0; char *ind = NULL; @@ -933,6 +944,8 @@ static void yahoo_process_notify(struct yahoo_input_data *yid, struct yahoo_pack struct yahoo_pair *pair = l->data; if (pair->key == 4) from = pair->value; + if (pair->key == 5) + to = pair->value; if (pair->key == 49) msg = pair->value; if (pair->key == 13) @@ -950,19 +963,19 @@ static void yahoo_process_notify(struct yahoo_input_data *yid, struct yahoo_pack return; if (!strncasecmp(msg, "TYPING", strlen("TYPING"))) - YAHOO_CALLBACK(ext_yahoo_typing_notify)(yd->client_id, from, stat); + YAHOO_CALLBACK(ext_yahoo_typing_notify)(yd->client_id, to, from, stat); else if (!strncasecmp(msg, "GAME", strlen("GAME"))) - YAHOO_CALLBACK(ext_yahoo_game_notify)(yd->client_id, from, stat); + YAHOO_CALLBACK(ext_yahoo_game_notify)(yd->client_id, to, from, stat); else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE"))) { if (!strcmp(ind, " ")) { - YAHOO_CALLBACK(ext_yahoo_webcam_invite)(yd->client_id, from); + YAHOO_CALLBACK(ext_yahoo_webcam_invite)(yd->client_id, to, from); } else { accept = atoi(ind); /* accept the invitation (-1 = deny 1 = accept) */ if (accept < 0) accept = 0; - YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply)(yd->client_id, from, accept); + YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply)(yd->client_id, to, from, accept); } } else @@ -1021,7 +1034,7 @@ static void yahoo_process_filetransfer(struct yahoo_input_data *yid, struct yaho *tmp = '\0'; } if(url && from) - YAHOO_CALLBACK(ext_yahoo_got_file)(yd->client_id, from, url, expires, msg, filename, filesize); + YAHOO_CALLBACK(ext_yahoo_got_file)(yd->client_id, to, from, url, expires, msg, filename, filesize); } @@ -1095,31 +1108,31 @@ static void yahoo_process_conference(struct yahoo_input_data *yid, struct yahoo_ if(pkt->status == 2) ; else if(members) - YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, host, room, msg, members); + YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, id, host, room, msg, members); else if(msg) - YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, msg, 0); + YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, msg, 0, E_CONFNOTAVAIL); break; case YAHOO_SERVICE_CONFADDINVITE: if(pkt->status == 2) ; else - YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, host, room, msg, members); + YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, id, host, room, msg, members); break; case YAHOO_SERVICE_CONFDECLINE: if(who) - YAHOO_CALLBACK(ext_yahoo_conf_userdecline)(yd->client_id, who, room, msg); + YAHOO_CALLBACK(ext_yahoo_conf_userdecline)(yd->client_id, id, who, room, msg); break; case YAHOO_SERVICE_CONFLOGON: if(who) - YAHOO_CALLBACK(ext_yahoo_conf_userjoin)(yd->client_id, who, room); + YAHOO_CALLBACK(ext_yahoo_conf_userjoin)(yd->client_id, id, who, room); break; case YAHOO_SERVICE_CONFLOGOFF: if(who) - YAHOO_CALLBACK(ext_yahoo_conf_userleave)(yd->client_id, who, room); + YAHOO_CALLBACK(ext_yahoo_conf_userleave)(yd->client_id, id, who, room); break; case YAHOO_SERVICE_CONFMSG: if(who) - YAHOO_CALLBACK(ext_yahoo_conf_message)(yd->client_id, who, room, msg, utf8); + YAHOO_CALLBACK(ext_yahoo_conf_message)(yd->client_id, id, who, room, msg, utf8); break; } } @@ -1127,6 +1140,7 @@ static void yahoo_process_conference(struct yahoo_input_data *yid, struct yahoo_ static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet *pkt) { char *msg = NULL; + char *id = NULL; char *who = NULL; char *room = NULL; char *topic = NULL; @@ -1143,6 +1157,11 @@ static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; + if (pair->key == 1) { + /* My identity */ + id = pair->value; + } + if (pair->key == 104) { /* Room name */ room = pair->value; @@ -1217,12 +1236,12 @@ static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet if(!room) { if (pkt->service == YAHOO_SERVICE_CHATLOGOUT) { /* yahoo originated chat logout */ - YAHOO_CALLBACK(ext_yahoo_chat_yahoologout)(yid->yd->client_id); + YAHOO_CALLBACK(ext_yahoo_chat_yahoologout)(yid->yd->client_id, id); return ; } if (pkt->service == YAHOO_SERVICE_COMMENT && chaterr) { - YAHOO_CALLBACK(ext_yahoo_chat_yahooerror)(yid->yd->client_id); - return ; + YAHOO_CALLBACK(ext_yahoo_chat_yahooerror)(yid->yd->client_id, id); + return; } WARNING(("We didn't get a room name, ignoring packet")); @@ -1235,7 +1254,7 @@ static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet WARNING(("Count of members doesn't match No. of members we got")); } if(firstjoin && members) { - YAHOO_CALLBACK(ext_yahoo_chat_join)(yid->yd->client_id, room, topic, members, yid->fd); + YAHOO_CALLBACK(ext_yahoo_chat_join)(yid->yd->client_id, id, room, topic, members, yid->fd); } else if(who) { if(y_list_length(members) != 1) { WARNING(("Got more than 1 member on a normal join")); @@ -1244,7 +1263,7 @@ static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet while(members) { YList *n = members->next; currentmember = members->data; - YAHOO_CALLBACK(ext_yahoo_chat_userjoin)(yid->yd->client_id, room, currentmember); + YAHOO_CALLBACK(ext_yahoo_chat_userjoin)(yid->yd->client_id, id, room, currentmember); y_list_free_1(members); members=n; } @@ -1252,12 +1271,12 @@ static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet break; case YAHOO_SERVICE_CHATEXIT: if(who) { - YAHOO_CALLBACK(ext_yahoo_chat_userleave)(yid->yd->client_id, room, who); + YAHOO_CALLBACK(ext_yahoo_chat_userleave)(yid->yd->client_id, id, room, who); } break; case YAHOO_SERVICE_COMMENT: if(who) { - YAHOO_CALLBACK(ext_yahoo_chat_message)(yid->yd->client_id, who, room, msg, msgtype, utf8); + YAHOO_CALLBACK(ext_yahoo_chat_message)(yid->yd->client_id, id, who, room, msg, msgtype, utf8); } break; } @@ -1316,9 +1335,9 @@ static void yahoo_process_message(struct yahoo_input_data *yid, struct yahoo_pac if (pkt->service == YAHOO_SERVICE_SYSMESSAGE) { YAHOO_CALLBACK(ext_yahoo_system_message)(yd->client_id, message->msg); } else if (pkt->status <= 2 || pkt->status == 5) { - YAHOO_CALLBACK(ext_yahoo_got_im)(yd->client_id, message->from, message->msg, message->tm, pkt->status, message->utf8); + YAHOO_CALLBACK(ext_yahoo_got_im)(yd->client_id, message->to, message->from, message->msg, message->tm, pkt->status, message->utf8); } else if (pkt->status == 0xffffffff) { - YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, message->msg, 0); + YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, message->msg, 0, E_SYSTEM); } free(message); } @@ -1331,13 +1350,32 @@ static void yahoo_process_status(struct yahoo_input_data *yid, struct yahoo_pack { YList *l; struct yahoo_data *yd = yid->yd; - char *name = NULL; - int state = 0; - int away = 0; - int idle = 0; - char *msg = NULL; + + struct user + { + char *name; /* 7 name */ + int state; /* 10 state */ + int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */ + int mobile; /* 60 mobile */ + char *msg; /* 19 custom status message */ + int away; /* 47 away (or invisible)*/ + int buddy_session; /* 11 state */ + int f17; /* 17 in chat? then what about flags? */ + int idle; /* 137 seconds idle */ + int f138; /* 138 state */ + char *f184; /* 184 state */ + int f192; /* 192 state */ + int f10001; /* 10001 state */ + int f10002; /* 10002 state */ + int f198; /* 198 state */ + char *f197; /* 197 state */ + char *f205; /* 205 state */ + int f213; /* 213 state */ + } *u; + + YList *users = 0; - if(pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { + if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_DUPL, NULL); return; } @@ -1361,51 +1399,87 @@ static void yahoo_process_status(struct yahoo_input_data *yid, struct yahoo_pack NOTICE(("key %d:%s", pair->key, pair->value)); break; case 7: /* the current buddy */ - name = pair->value; + u = y_new0(struct user, 1); + u->name = pair->value; + users = y_list_prepend(users, u); break; case 10: /* state */ - state = strtol(pair->value, NULL, 10); + ((struct user*)users->data)->state = strtol(pair->value, NULL, 10); break; case 19: /* custom status message */ - msg = pair->value; + ((struct user*)users->data)->msg = pair->value; break; case 47: /* is it an away message or not */ - away = atoi(pair->value); + ((struct user*)users->data)->away = atoi(pair->value); break; case 137: /* seconds idle */ - idle = atoi(pair->value); + ((struct user*)users->data)->idle = atoi(pair->value); break; - case 11: /* what is this? */ - NOTICE(("key %d:%s", pair->key, pair->value)); + case 11: /* this is the buddy's session id */ + ((struct user*)users->data)->buddy_session = atoi(pair->value); break; case 17: /* in chat? */ + ((struct user*)users->data)->f17 = atoi(pair->value); break; - case 13: /* in pager? */ - if (pkt->service == YAHOO_SERVICE_LOGOFF || strtol(pair->value, NULL, 10) == 0) { - YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, YAHOO_STATUS_OFFLINE, NULL, 1); - break; - } - if (state == YAHOO_STATUS_AVAILABLE) { - YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, NULL, 0); - } else if (state == YAHOO_STATUS_CUSTOM) { - YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away); - } else { - YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, NULL, idle); - } - + case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ + ((struct user*)users->data)->flags = atoi(pair->value); break; - case 60: + case 60: /* SMS -> 1 MOBILE USER */ /* sometimes going offline makes this 2, but invisible never sends it */ - NOTICE(("key %d:%s", pair->key, pair->value)); - break; + ((struct user*)users->data)->mobile = atoi(pair->value); + break; + case 138: + ((struct user*)users->data)->f138 = atoi(pair->value); + break; + case 184: + ((struct user*)users->data)->f184 = pair->value; + break; + case 192: + ((struct user*)users->data)->f192 = atoi(pair->value); + break; + case 10001: + ((struct user*)users->data)->f10001 = atoi(pair->value); + break; + case 10002: + ((struct user*)users->data)->f10002 = atoi(pair->value); + break; + case 198: + ((struct user*)users->data)->f198 = atoi(pair->value); + break; + case 197: + ((struct user*)users->data)->f197 = pair->value; + break; + case 205: + ((struct user*)users->data)->f205 = pair->value; + break; + case 213: + ((struct user*)users->data)->f213 = atoi(pair->value); + break; case 16: /* Custom error message */ - YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, pair->value, 0); + YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, pair->value, 0, E_CUSTOM); break; default: WARNING(("unknown status key %d:%s", pair->key, pair->value)); break; } } + + while (users) { + YList *t = users; + struct user *u = users->data; + + if (u->name != NULL) { + if (pkt->service == YAHOO_SERVICE_LOGOFF || u->flags == 0) { + YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0); + } else { + YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, u->state, u->msg, u->away, u->idle, u->mobile); + } + } + + users = y_list_remove_link(users, users); + y_list_free_1(t); + FREE(u); + } } static void yahoo_process_list(struct yahoo_input_data *yid, struct yahoo_packet *pkt) @@ -1511,6 +1585,113 @@ static void yahoo_process_verify(struct yahoo_input_data *yid, struct yahoo_pack } +static void yahoo_process_picture_checksum( struct yahoo_input_data *yid, struct yahoo_packet *pkt) +{ + struct yahoo_data *yd = yid->yd; + char *from = NULL; + char *to = NULL; + int checksum = 0; + YList *l; + + for(l = pkt->hash; l; l = l->next) + { + struct yahoo_pair *pair = l->data; + + switch(pair->key) + { + case 1: + case 4: + from = pair->value; + case 5: + to = pair->value; + break; + case 212: + break; + case 192: + checksum = atoi( pair->value ); + break; + } + } + + YAHOO_CALLBACK(ext_yahoo_got_buddyicon_checksum)(yd->client_id,to,from,checksum); +} + +static void yahoo_process_picture(struct yahoo_input_data *yid, struct yahoo_packet *pkt) +{ + struct yahoo_data *yd = yid->yd; + char *url = NULL; + char *from = NULL; + char *to = NULL; + int status = 0; + int checksum = 0; + YList *l; + + for(l = pkt->hash; l; l = l->next) + { + struct yahoo_pair *pair = l->data; + + switch(pair->key) + { + case 1: + case 4: /* sender */ + from = pair->value; + break; + case 5: /* we */ + to = pair->value; + break; + case 13: /* request / sending */ + status = atoi( pair->value ); + break; + case 20: /* url */ + url = pair->value; + break; + case 192: /*checksum */ + checksum = atoi( pair->value ); + break; + } + } + + switch( status ) + { + case 1: /* this is a request, ignore for now */ + YAHOO_CALLBACK(ext_yahoo_got_buddyicon_request)(yd->client_id, to, from); + break; + case 2: /* this is cool - we get a picture :) */ + YAHOO_CALLBACK(ext_yahoo_got_buddyicon)(yd->client_id,to, from, url, checksum); + break; + } +} + +static void yahoo_process_picture_upload(struct yahoo_input_data *yid, struct yahoo_packet *pkt) +{ + struct yahoo_data *yd = yid->yd; + YList *l; + char *url = NULL; + + if ( pkt->status != 1 ) + return; /* something went wrong */ + + for(l = pkt->hash; l; l = l->next) + { + struct yahoo_pair *pair = l->data; + + switch(pair->key) + { + case 5: /* we */ + break; + case 20: /* url */ + url = pair->value; + break; + case 27: /* local filename */ + break; + case 38: /* time */ + break; + } + } + + YAHOO_CALLBACK(ext_yahoo_buddyicon_uploaded)(yd->client_id, url); +} + static void yahoo_process_auth_pre_0x0b(struct yahoo_input_data *yid, const char *seed, const char *sn) { @@ -2153,6 +2334,8 @@ static void yahoo_process_contact(struct yahoo_input_data *yid, struct yahoo_pac int state = YAHOO_STATUS_AVAILABLE; int online = FALSE; int away = 0; + int idle = 0; + int mobile = 0; YList *l; @@ -2174,12 +2357,17 @@ static void yahoo_process_contact(struct yahoo_input_data *yid, struct yahoo_pac online = strtol(pair->value, NULL, 10); else if (pair->key == 47) away = strtol(pair->value, NULL, 10); + else if (pair->key == 137) + idle = strtol(pair->value, NULL, 10); + else if (pair->key == 60) + mobile = strtol(pair->value, NULL, 10); + } if (id) YAHOO_CALLBACK(ext_yahoo_contact_added)(yd->client_id, id, who, msg); else if (name) - YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away); + YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away, idle, mobile); else if(pkt->status == 0x07) YAHOO_CALLBACK(ext_yahoo_rejected)(yd->client_id, who, msg); } @@ -2307,7 +2495,7 @@ static void yahoo_process_ignore(struct yahoo_input_data *yid, struct yahoo_pack */ /* if(status) - YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, status, who, 0); + YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, who, 0, status); */ } @@ -2331,7 +2519,7 @@ static void yahoo_process_voicechat(struct yahoo_input_data *yid, struct yahoo_p room=pair->value; } - NOTICE(("got voice chat invite from %s in %s", who, room)); + NOTICE(("got voice chat invite from %s in %s to identity %s", who, room, me)); /* * send: s:0 1:me 5:who 57:room 13:1 * ???? s:4 5:who 10:99 19:-1615114531 @@ -2343,6 +2531,21 @@ static void yahoo_process_voicechat(struct yahoo_input_data *yid, struct yahoo_p */ } +static void yahoo_process_ping(struct yahoo_input_data *yid, struct yahoo_packet *pkt) +{ + char *errormsg = NULL; + + YList *l; + for (l = pkt->hash; l; l = l->next) { + struct yahoo_pair *pair = l->data; + if (pair->key == 16) + errormsg = pair->value; + } + + NOTICE(("got ping packet")); + YAHOO_CALLBACK(ext_yahoo_got_ping)(yid->yd->client_id, errormsg); +} + static void _yahoo_webcam_get_server_connected(int fd, int error, void *d) { struct yahoo_input_data *yid = d; @@ -2518,6 +2721,9 @@ static void yahoo_packet_process(struct yahoo_input_data *yid, struct yahoo_pack case YAHOO_SERVICE_WEBCAM: yahoo_process_webcam_key(yid, pkt); break; + case YAHOO_SERVICE_PING: + yahoo_process_ping(yid, pkt); + break; case YAHOO_SERVICE_IDLE: case YAHOO_SERVICE_MAILSTAT: case YAHOO_SERVICE_CHATINVITE: @@ -2525,7 +2731,6 @@ static void yahoo_packet_process(struct yahoo_input_data *yid, struct yahoo_pack case YAHOO_SERVICE_NEWPERSONALMAIL: case YAHOO_SERVICE_ADDIDENT: case YAHOO_SERVICE_ADDIGNORE: - case YAHOO_SERVICE_PING: case YAHOO_SERVICE_GOTGROUPRENAME: case YAHOO_SERVICE_GROUPRENAME: case YAHOO_SERVICE_PASSTHROUGH2: @@ -2537,6 +2742,15 @@ static void yahoo_packet_process(struct yahoo_input_data *yid, struct yahoo_pack WARNING(("unhandled service 0x%02x", pkt->service)); yahoo_dump_unhandled(pkt); break; + case YAHOO_SERVICE_PICTURE: + yahoo_process_picture(yid, pkt); + break; + case YAHOO_SERVICE_PICTURE_CHECKSUM: + yahoo_process_picture_checksum(yid, pkt); + break; + case YAHOO_SERVICE_PICTURE_UPLOAD: + yahoo_process_picture_upload(yid, pkt); + break; default: WARNING(("unknown service 0x%02x", pkt->service)); yahoo_dump_unhandled(pkt); @@ -3346,7 +3560,7 @@ int yahoo_read_ready(int id, int fd, void *data) DEBUG_MSG(("len == %d (<= 0)", len)); if(yid->type == YAHOO_CONNECTION_PAGER) { - YAHOO_CALLBACK(ext_yahoo_login_response)(yid->yd->client_id, YAHOO_LOGIN_SOCK, NULL); + YAHOO_CALLBACK(ext_yahoo_error)(yid->yd->client_id, "Connection closed by server", 1, E_CONNECTION); } yahoo_process_connection[yid->type](yid, 1); @@ -3494,11 +3708,12 @@ int yahoo_get_fd(int id) return yid->fd; } -void yahoo_send_im(int id, const char *from, const char *who, const char *what, int utf8) +void yahoo_send_im(int id, const char *from, const char *who, const char *what, int utf8, int picture) { struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); struct yahoo_packet *pkt = NULL; struct yahoo_data *yd; + char pic_str[10]; if(!yid) return; @@ -3507,6 +3722,8 @@ void yahoo_send_im(int id, const char *from, const char *who, const char *what, pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, yd->session_id); + snprintf(pic_str, sizeof(pic_str), "%d", picture); + if(from && strcmp(from, yd->user)) yahoo_packet_hash(pkt, 0, yd->user); yahoo_packet_hash(pkt, 1, from?from:yd->user); @@ -3518,6 +3735,7 @@ void yahoo_send_im(int id, const char *from, const char *who, const char *what, yahoo_packet_hash(pkt, 63, ";0"); /* imvironment name; or ;0 */ yahoo_packet_hash(pkt, 64, "0"); + yahoo_packet_hash(pkt, 206, pic_str); yahoo_send_packet(yid, pkt, 0); @@ -3570,12 +3788,24 @@ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away) service = YAHOO_SERVICE_ISBACK; else service = YAHOO_SERVICE_ISAWAY; - pkt = yahoo_packet_new(service, yd->current_status, yd->session_id); - snprintf(s, sizeof(s), "%d", yd->current_status); - yahoo_packet_hash(pkt, 10, s); - if (yd->current_status == YAHOO_STATUS_CUSTOM) { - yahoo_packet_hash(pkt, 19, msg); - yahoo_packet_hash(pkt, 47, away?"1":"0"); + + if ((away == 2) && (yd->current_status == YAHOO_STATUS_AVAILABLE)) { + pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_BRB, yd->session_id); + yahoo_packet_hash(pkt, 10, "999"); + yahoo_packet_hash(pkt, 47, "2"); + }else { + pkt = yahoo_packet_new(service, YAHOO_STATUS_AVAILABLE, yd->session_id); + snprintf(s, sizeof(s), "%d", yd->current_status); + yahoo_packet_hash(pkt, 10, s); + if (yd->current_status == YAHOO_STATUS_CUSTOM) { + yahoo_packet_hash(pkt, 19, msg); + yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); + } else { + yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); + } + + + } yahoo_send_packet(yid, pkt, 0); @@ -3816,7 +4046,7 @@ void yahoo_chat_keepalive (int id) yahoo_packet_free (pkt); } -void yahoo_add_buddy(int id, const char *who, const char *group) +void yahoo_add_buddy(int id, const char *who, const char *group, const char *msg) { struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); struct yahoo_data *yd; @@ -3833,6 +4063,8 @@ void yahoo_add_buddy(int id, const char *who, const char *group) yahoo_packet_hash(pkt, 1, yd->user); yahoo_packet_hash(pkt, 7, who); yahoo_packet_hash(pkt, 65, group); + if (msg != NULL) /* add message/request "it's me add me" */ + yahoo_packet_hash(pkt, 14, msg); yahoo_send_packet(yid, pkt, 0); yahoo_packet_free(pkt); } @@ -3898,6 +4130,28 @@ void yahoo_ignore_buddy(int id, const char *who, int unignore) yahoo_packet_free(pkt); } +void yahoo_stealth_buddy(int id, const char *who, int unstealth) +{ + struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); + struct yahoo_data *yd; + struct yahoo_packet *pkt; + + if(!yid) + return; + yd = yid->yd; + + if (!yd->logged_in) + return; + + pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH, YAHOO_STATUS_AVAILABLE, yd->session_id); + yahoo_packet_hash(pkt, 1, yd->user); + yahoo_packet_hash(pkt, 7, who); + yahoo_packet_hash(pkt, 31, unstealth?"2":"1"); + yahoo_packet_hash(pkt, 13, "2"); + yahoo_send_packet(yid, pkt, 0); + yahoo_packet_free(pkt); +} + void yahoo_change_buddy_group(int id, const char *who, const char *old_group, const char *new_group) { struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); @@ -4206,6 +4460,100 @@ void yahoo_chat_logoff(int id, const char *from) yahoo_packet_free(pkt); } +void yahoo_buddyicon_request(int id, const char *who) +{ + struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); + struct yahoo_data *yd; + struct yahoo_packet *pkt; + + if( !yid ) + return; + + yd = yid->yd; + + pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); + yahoo_packet_hash(pkt, 4, yd->user); + yahoo_packet_hash(pkt, 5, who); + yahoo_packet_hash(pkt, 13, "1"); + yahoo_send_packet(yid, pkt, 0); + + yahoo_packet_free(pkt); +} + +void yahoo_send_picture_info(int id, const char *who, const char *url, int checksum) +{ + struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); + struct yahoo_data *yd; + struct yahoo_packet *pkt; + char checksum_str[10]; + + if( !yid ) + return; + + yd = yid->yd; + + snprintf(checksum_str, sizeof(checksum_str), "%d", checksum); + + pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); + yahoo_packet_hash(pkt, 1, yd->user); + yahoo_packet_hash(pkt, 4, yd->user); + yahoo_packet_hash(pkt, 5, who); + yahoo_packet_hash(pkt, 13, "2"); + yahoo_packet_hash(pkt, 20, url); + yahoo_packet_hash(pkt, 192, checksum_str); + yahoo_send_packet(yid, pkt, 0); + + yahoo_packet_free(pkt); +} + +void yahoo_send_picture_update(int id, const char *who, int type) +{ + struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); + struct yahoo_data *yd; + struct yahoo_packet *pkt; + char type_str[10]; + + if( !yid ) + return; + + yd = yid->yd; + + snprintf(type_str, sizeof(type_str), "%d", type); + + pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, YAHOO_STATUS_AVAILABLE, 0); + yahoo_packet_hash(pkt, 1, yd->user); + yahoo_packet_hash(pkt, 5, who); + yahoo_packet_hash(pkt, 206, type_str); + yahoo_send_packet(yid, pkt, 0); + + yahoo_packet_free(pkt); +} + +void yahoo_send_picture_checksum(int id, const char *who, int checksum) +{ + struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); + struct yahoo_data *yd; + struct yahoo_packet *pkt; + char checksum_str[10]; + + if( !yid ) + return; + + yd = yid->yd; + + snprintf(checksum_str, sizeof(checksum_str), "%d", checksum); + + pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, 0); + yahoo_packet_hash(pkt, 1, yd->user); + if( who != 0 ) + yahoo_packet_hash(pkt, 5, who); + yahoo_packet_hash(pkt, 192, checksum_str); + yahoo_packet_hash(pkt, 212, "1"); + yahoo_send_packet(yid, pkt, 0); + + yahoo_packet_free(pkt); +} + void yahoo_webcam_close_feed(int id, const char *who) { struct yahoo_input_data *yid = find_input_by_id_and_webcam_user(id, who); @@ -4409,6 +4757,99 @@ struct send_file_data { void *user_data; }; +static void _yahoo_send_picture_connected(int id, int fd, int error, void *data) +{ + struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_FT); + struct send_file_data *sfd = data; + struct yahoo_packet *pkt = sfd->pkt; + unsigned char buff[1024]; + + if(fd <= 0) { + sfd->callback(id, fd, error, sfd->user_data); + FREE(sfd); + yahoo_packet_free(pkt); + inputs = y_list_remove(inputs, yid); + FREE(yid); + return; + } + + yid->fd = fd; + yahoo_send_packet(yid, pkt, 8); + yahoo_packet_free(pkt); + + snprintf((char *)buff, sizeof(buff), "29"); + buff[2] = 0xc0; + buff[3] = 0x80; + + write(yid->fd, buff, 4); + + /* YAHOO_CALLBACK(ext_yahoo_add_handler)(nyd->fd, YAHOO_INPUT_READ); */ + + sfd->callback(id, fd, error, sfd->user_data); + FREE(sfd); + inputs = y_list_remove(inputs, yid); + /* + while(yahoo_tcp_readline(buff, sizeof(buff), nyd->fd) > 0) { + if(!strcmp(buff, "")) + break; +} + + */ + yahoo_input_close(yid); +} + +void yahoo_send_picture(int id, const char *name, unsigned long size, + yahoo_get_fd_callback callback, void *data) +{ + struct yahoo_data *yd = find_conn_by_id(id); + struct yahoo_input_data *yid; + struct yahoo_server_settings *yss; + struct yahoo_packet *pkt = NULL; + char size_str[10]; + char expire_str[10]; + long content_length=0; + unsigned char buff[1024]; + char url[255]; + struct send_file_data *sfd; + + if(!yd) + return; + + yss = yd->server_settings; + + yid = y_new0(struct yahoo_input_data, 1); + yid->yd = yd; + yid->type = YAHOO_CONNECTION_FT; + + pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPLOAD, YAHOO_STATUS_AVAILABLE, yd->session_id); + + snprintf(size_str, sizeof(size_str), "%ld", size); + snprintf(expire_str, sizeof(expire_str), "%ld", (long)604800); + + yahoo_packet_hash(pkt, 0, yd->user); + yahoo_packet_hash(pkt, 1, yd->user); + yahoo_packet_hash(pkt, 14, ""); + yahoo_packet_hash(pkt, 27, name); + yahoo_packet_hash(pkt, 28, size_str); + yahoo_packet_hash(pkt, 38, expire_str); + + + content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt); + + snprintf(url, sizeof(url), "http://%s:%d/notifyft", + yss->filetransfer_host, yss->filetransfer_port); + snprintf((char *)buff, sizeof(buff), "Y=%s; T=%s", + yd->cookie_y, yd->cookie_t); + inputs = y_list_prepend(inputs, yid); + + sfd = y_new0(struct send_file_data, 1); + sfd->pkt = pkt; + sfd->callback = callback; + sfd->user_data = data; + yahoo_http_post(yid->yd->client_id, url, (char *)buff, content_length+4+size, + _yahoo_send_picture_connected, sfd); +} + static void _yahoo_send_file_connected(int id, int fd, int error, void *data) { struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_FT); diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index dec42bdc..6f6590df 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -66,7 +66,7 @@ struct byahoo_conf_invitation static GSList *byahoo_inputs = NULL; static int byahoo_chat_id = 0; -static char *byahoo_strip( char *in ) +static char *byahoo_strip( const char *in ) { int len; @@ -85,7 +85,7 @@ static char *byahoo_strip( char *in ) } else if( strncmp( in, "\e[", 2 ) == 0 ) { - char *s; + const char *s; for( s = in + 2; *s && *s != 'm'; s ++ ); @@ -171,7 +171,7 @@ static int byahoo_send_im( struct im_connection *ic, char *who, char *what, int { struct byahoo_data *yd = ic->proto_data; - yahoo_send_im( yd->y2_id, NULL, who, what, 1 ); + yahoo_send_im( yd->y2_id, NULL, who, what, 1, 0 ); return 1; } @@ -239,7 +239,7 @@ static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) else yd->current_status = YAHOO_STATUS_AVAILABLE; - yahoo_set_away( yd->y2_id, yd->current_status, msg, ic->away != NULL ); + yahoo_set_away( yd->y2_id, yd->current_status, msg, ic->away != NULL ? 2 : 0 ); } static GList *byahoo_away_states( struct im_connection *ic ) @@ -273,7 +273,7 @@ static void byahoo_add_buddy( struct im_connection *ic, char *who, char *group ) { struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; - yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP ); + 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 ) @@ -450,7 +450,7 @@ gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condit return FALSE; } -void ext_yahoo_login_response( int id, int succ, char *url ) +void ext_yahoo_login_response( int id, int succ, const char *url ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); struct byahoo_data *yd = NULL; @@ -542,7 +542,7 @@ void ext_yahoo_got_cookies( int id ) { } -void ext_yahoo_status_changed( int id, char *who, int stat, char *msg, int away ) +void ext_yahoo_status_changed( int id, const char *who, int stat, const char *msg, int away, int idle, int mobile ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); char *state_string = NULL; @@ -606,50 +606,52 @@ void ext_yahoo_status_changed( int id, char *who, int stat, char *msg, int away */ } -void ext_yahoo_got_im( int id, char *who, char *msg, long tm, int stat, int utf8 ) +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 ); char *m = byahoo_strip( msg ); - serv_got_im( ic, who, m, 0, 0, strlen( m ) ); + serv_got_im( ic, (char*) who, (char*) m, 0, 0, strlen( m ) ); g_free( m ); } -void ext_yahoo_got_file( int id, char *who, char *url, long expires, char *msg, char *fname, unsigned long fesize ) +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 ) { 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_typing_notify( int id, char *who, int stat ) +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 ); if (stat == 1) { /* User is typing */ - serv_got_typing( ic, who, 1, 1 ); + serv_got_typing( ic, (char*) who, 1, 1 ); } else { /* User stopped typing */ - serv_got_typing( ic, who, 1, 0 ); + serv_got_typing( ic, (char*) who, 1, 0 ); } } -void ext_yahoo_system_message( int id, char *msg ) +void ext_yahoo_system_message( int id, const char *msg ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); imcb_log( ic, "Yahoo! system message: %s", msg ); } -void ext_yahoo_webcam_invite( int id, char *from ) +void ext_yahoo_webcam_invite( int id, const char *ignored, const char *from ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); imcb_log( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from ); } -void ext_yahoo_error( int id, char *err, int fatal ) +void ext_yahoo_error( int id, const char *err, int fatal, int num ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); @@ -718,7 +720,7 @@ void ext_yahoo_remove_handler( int id, int tag ) b_event_remove( tag ); } -int ext_yahoo_connect_async( int id, 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 ) { struct byahoo_connect_callback_data *d; int fd; @@ -739,7 +741,7 @@ int ext_yahoo_connect_async( int id, char *host, int port, yahoo_connect_callbac /* 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(char *host, int port) +int ext_yahoo_connect(const char *host, int port) { #if 0 struct sockaddr_in serv_addr; @@ -795,7 +797,8 @@ static void byahoo_reject_conf( gpointer w, struct byahoo_conf_invitation *inv ) g_free( inv ); } -void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList *members ) +void ext_yahoo_got_conf_invite( int id, const char *ignored, + const char *who, const char *room, const char *msg, YList *members ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); struct byahoo_conf_invitation *inv; @@ -805,7 +808,7 @@ void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList inv = g_malloc( sizeof( struct byahoo_conf_invitation ) ); memset( inv, 0, sizeof( struct byahoo_conf_invitation ) ); inv->name = g_strdup( room ); - inv->c = serv_got_joined_chat( ic, room ); + inv->c = serv_got_joined_chat( ic, (char*) room ); inv->c->data = members; inv->yid = id; inv->members = members; @@ -820,14 +823,14 @@ void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList imcb_ask( ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf ); } -void ext_yahoo_conf_userdecline( int id, char *who, char *room, char *msg ) +void ext_yahoo_conf_userdecline( int id, const char *ignored, const char *who, const char *room, const char *msg ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); imcb_log( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg ); } -void ext_yahoo_conf_userjoin( int id, char *who, char *room ) +void ext_yahoo_conf_userjoin( int id, const char *ignored, const char *who, const char *room ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); struct groupchat *c; @@ -835,10 +838,11 @@ void ext_yahoo_conf_userjoin( int id, char *who, char *room ) for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); if( c ) - add_chat_buddy( c, who ); + add_chat_buddy( c, (char*) who ); } -void ext_yahoo_conf_userleave( int id, char *who, char *room ) +void ext_yahoo_conf_userleave( int id, const char *ignored, const char *who, const char *room ) + { struct im_connection *ic = byahoo_get_ic_by_id( id ); struct groupchat *c; @@ -846,10 +850,10 @@ void ext_yahoo_conf_userleave( int id, char *who, char *room ) for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); if( c ) - remove_chat_buddy( c, who, "" ); + remove_chat_buddy( c, (char*) who, "" ); } -void ext_yahoo_conf_message( int id, char *who, char *room, char *msg, int utf8 ) +void ext_yahoo_conf_message( int id, const char *ignored, const char *who, const char *room, const char *msg, int utf8 ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); char *m = byahoo_strip( msg ); @@ -858,51 +862,55 @@ void ext_yahoo_conf_message( int id, char *who, char *room, char *msg, int utf8 for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); if( c ) - serv_got_chat_in( c, who, 0, m, 0 ); + serv_got_chat_in( c, (char*) who, 0, (char*) m, 0 ); g_free( m ); } -void ext_yahoo_chat_cat_xml( int id, char *xml ) +void ext_yahoo_chat_cat_xml( int id, const char *xml ) { } -void ext_yahoo_chat_join( int id, char *room, char *topic, YList *members, int fd ) +void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, int fd ) { } -void ext_yahoo_chat_userjoin( int id, char *room, struct yahoo_chat_member *who ) +void ext_yahoo_chat_userjoin( int id, const char *me, const char *room, struct yahoo_chat_member *who ) { + free(who->id); + free(who->alias); + free(who->location); + free(who); } -void ext_yahoo_chat_userleave( int id, char *room, char *who ) +void ext_yahoo_chat_userleave( int id, const char *me, const char *room, const char *who ) { } -void ext_yahoo_chat_message( int id, char *who, char *room, char *msg, int msgtype, int utf8 ) +void ext_yahoo_chat_message( int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, int utf8 ) { } -void ext_yahoo_chat_yahoologout( int id ) +void ext_yahoo_chat_yahoologout( int id, const char *me ) { } -void ext_yahoo_chat_yahooerror( int id ) +void ext_yahoo_chat_yahooerror( int id, const char *me ) { } -void ext_yahoo_contact_added( int id, char *myid, char *who, char *msg ) +void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg ) { } -void ext_yahoo_rejected( int id, char *who, char *msg ) +void ext_yahoo_rejected( int id, const char *who, const char *msg ) { } -void ext_yahoo_game_notify( int id, char *who, int stat ) +void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat ) { } -void ext_yahoo_mail_notify( int id, char *from, char *subj, int cnt ) +void ext_yahoo_mail_notify( int id, const char *from, const char *subj, int cnt ) { struct im_connection *ic = byahoo_get_ic_by_id( id ); @@ -912,11 +920,11 @@ void ext_yahoo_mail_notify( int id, char *from, char *subj, int cnt ) imcb_log( ic, "Received %d new e-mails", cnt ); } -void ext_yahoo_webcam_invite_reply( int id, char *from, int accept ) +void ext_yahoo_webcam_invite_reply( int id, const char *me, const char *from, int accept ) { } -void ext_yahoo_webcam_closed( int id, char *who, int reason ) +void ext_yahoo_webcam_closed( int id, const char *who, int reason ) { } @@ -924,7 +932,7 @@ void ext_yahoo_got_search_result( int id, int found, int start, int total, YList { } -void ext_yahoo_webcam_viewer( int id, char *who, int connect ) +void ext_yahoo_webcam_viewer( int id, const char *who, int connect ) { } @@ -932,7 +940,7 @@ void ext_yahoo_webcam_data_request( int id, int send ) { } -int ext_yahoo_log( char *fmt, ... ) +int ext_yahoo_log( const char *fmt, ... ) { return( 0 ); } @@ -940,3 +948,13 @@ int ext_yahoo_log( char *fmt, ... ) void ext_yahoo_got_webcam_image( int id, const char * who, const unsigned char *image, unsigned int image_size, unsigned int real_size, unsigned int timestamp ) { } + +void ext_yahoo_got_ping( int id, const char *msg) +{ +} + +void ext_yahoo_got_buddyicon (int id, const char *me, const char *who, const char *url, int checksum) {} +void ext_yahoo_got_buddyicon_checksum (int id, const char *me,const char *who, int checksum) {} + +void ext_yahoo_got_buddyicon_request(int id, const char *me, const char *who){} +void ext_yahoo_buddyicon_uploaded(int id, const char *url){} diff --git a/protocols/yahoo/yahoo2.h b/protocols/yahoo/yahoo2.h index 5ac5e4f9..e54e09fb 100644 --- a/protocols/yahoo/yahoo2.h +++ b/protocols/yahoo/yahoo2.h @@ -119,7 +119,7 @@ void yahoo_chat_keepalive(int id); /* from is the identity you're sending from. if NULL, the default is used */ /* utf8 is whether msg is a utf8 string or not. */ -void yahoo_send_im(int id, const char *from, const char *who, const char *msg, int utf8); +void yahoo_send_im(int id, const char *from, const char *who, const char *msg, int utf8, int picture); /* if type is true, send typing notice, else send stopped typing notice */ void yahoo_send_typing(int id, const char *from, const char *who, int typ); @@ -127,9 +127,10 @@ void yahoo_send_typing(int id, const char *from, const char *who, int typ); /* away says whether the custom message is an away message or a sig */ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away); -void yahoo_add_buddy(int id, const char *who, const char *group); +void yahoo_add_buddy(int id, const char *who, const char *group, const char *msg); void yahoo_remove_buddy(int id, const char *who, const char *group); void yahoo_reject_buddy(int id, const char *who, const char *msg); +void yahoo_stealth_buddy(int id, const char *who, int unstealth); /* if unignore is true, unignore, else ignore */ void yahoo_ignore_buddy(int id, const char *who, int unignore); void yahoo_change_buddy_group(int id, const char *who, const char *old_group, const char *new_group); @@ -213,6 +214,8 @@ const char * yahoo_get_cookie(int id, const char *which); /* You'll have to do urlencoding yourself, but see yahoo_httplib.h first */ const char * yahoo_get_profile_url( void ); +void yahoo_buddyicon_request(int id, const char *who); + #include "yahoo_httplib.h" #ifdef __cplusplus diff --git a/protocols/yahoo/yahoo2_callbacks.h b/protocols/yahoo/yahoo2_callbacks.h index 1ab8a9d7..b7f4e99b 100644 --- a/protocols/yahoo/yahoo2_callbacks.h +++ b/protocols/yahoo/yahoo2_callbacks.h @@ -30,7 +30,6 @@ */ - #ifndef YAHOO2_CALLBACKS_H #define YAHOO2_CALLBACKS_H @@ -66,7 +65,6 @@ typedef enum { typedef void (*yahoo_connect_callback)(int fd, int error, void *callback_data); - /* * The following functions need to be implemented in the client * interface. They will be called by the library when each @@ -95,9 +93,7 @@ struct yahoo_callbacks { * succ - enum yahoo_login_status * url - url to reactivate account if locked */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response)(int id, int succ, char *url); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response)(int id, int succ, const char *url); /* @@ -110,8 +106,6 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response)(int id, int succ, char *url); void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddies)(int id, YList * buds); - - /* * Name: ext_yahoo_got_ignore * Called when the ignore list is got from the server @@ -122,9 +116,6 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddies)(int id, YList * buds); void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ignore)(int id, YList * igns); - - - /* * Name: ext_yahoo_got_identities * Called when the contact list is got from the server @@ -135,9 +126,6 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ignore)(int id, YList * igns); void YAHOO_CALLBACK_TYPE(ext_yahoo_got_identities)(int id, YList * ids); - - - /* * Name: ext_yahoo_got_cookies * Called when the cookie list is got from the server @@ -147,6 +135,14 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_identities)(int id, YList * ids); void YAHOO_CALLBACK_TYPE(ext_yahoo_got_cookies)(int id); +/* + * Name: ext_yahoo_got_ping + * Called when the ping packet is received from the server + * Params: + * id - the id that identifies the server connection + * errormsg - optional error message + */ +void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ping)(int id, const char *errormsg); /* @@ -158,11 +154,11 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_cookies)(int id); * stat - status code (enum yahoo_status) * msg - the message if stat == YAHOO_STATUS_CUSTOM * away - whether the contact is away or not (YAHOO_STATUS_CUSTOM) - * for YAHOO_STATUS_IDLE, this is the number of seconds he is idle + * idle - this is the number of seconds he is idle [if he is idle] + * mobile - this is set for mobile users/buddies + * TODO: add support for pager, chat, and game states */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed)(int id, char *who, int stat, char *msg, int away); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed)(int id, const char *who, int stat, const char *msg, int away, int idle, int mobile); /* @@ -170,6 +166,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed)(int id, char *who, int stat, * Called when remote user sends you a message. * Params: * id - the id that identifies the server connection + * me - the identity the message was sent to * who - the handle of the remote user * msg - the message - NULL if stat == 2 * tm - timestamp of message if offline @@ -179,9 +176,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed)(int id, char *who, int stat, * 5 * utf8 - whether the message is encoded as utf8 or not */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im)(int id, char *who, char *msg, long tm, int stat, int utf8); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im)(int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8); /* @@ -189,14 +184,13 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im)(int id, char *who, char *msg, long tm * Called when remote user sends you a conference invitation. * Params: * id - the id that identifies the server connection + * me - the identity the invitation was sent to * who - the user inviting you * room - the room to join * msg - the message * members - the initial members of the conference (null terminated list) */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite)(int id, char *who, char *room, char *msg, YList *members); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite)(int id, const char *me, const char *who, const char *room, const char *msg, YList *members); /* @@ -204,13 +198,12 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite)(int id, char *who, char *roo * Called when someone declines to join the conference. * Params: * id - the id that identifies the server connection + * me - the identity in the conference * who - the user who has declined * room - the room * msg - the declining message */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline)(int id, char *who, char *room, char *msg); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline)(int id, const char *me, const char *who, const char *room, const char *msg); /* @@ -218,12 +211,11 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline)(int id, char *who, char *ro * Called when someone joins the conference. * Params: * id - the id that identifies the server connection + * me - the identity in the conference * who - the user who has joined * room - the room joined */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin)(int id, char *who, char *room); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin)(int id, const char *me, const char *who, const char *room); /* @@ -231,33 +223,21 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin)(int id, char *who, char *room) * Called when someone leaves the conference. * Params: * id - the id that identifies the server connection + * me - the identity in the conference * who - the user who has left * room - the room left */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave)(int id, char *who, char *room); - - - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave)(int id, const char *me, const char *who, const char *room); /* * Name: ext_yahoo_chat_cat_xml - * Called when joining the chatroom. + * Called when ? * Params: * id - the id that identifies the server connection - * room - the room joined, used in all other chat calls, freed by - * library after call - * topic - the topic of the room, freed by library after call - * members - the initial members of the chatroom (null terminated YList of - * yahoo_chat_member's) Must be freed by the client + * xml - ? */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml)(int id, char *xml); - - - - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml)(int id, const char *xml); /* @@ -265,6 +245,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml)(int id, char *xml); * Called when joining the chatroom. * Params: * id - the id that identifies the server connection + * me - the identity in the chatroom * room - the room joined, used in all other chat calls, freed by * library after call * topic - the topic of the room, freed by library after call @@ -272,11 +253,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml)(int id, char *xml); * of yahoo_chat_member's) Must be freed by the client * fd - the socket where the connection is coming from (for tracking) */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join)(int id, char *room, char *topic, YList *members, int fd); - - - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join)(int id, const char *me, const char *room, const char *topic, YList *members, int fd); /* @@ -284,12 +261,11 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join)(int id, char *room, char *topic, Y * Called when someone joins the chatroom. * Params: * id - the id that identifies the server connection + * me - the identity in the chatroom * room - the room joined * who - the user who has joined, Must be freed by the client */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin)(int id, char *room, struct yahoo_chat_member *who); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin)(int id, const char *me, const char *room, struct yahoo_chat_member *who); /* @@ -297,12 +273,11 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin)(int id, char *room, struct yah * Called when someone leaves the chatroom. * Params: * id - the id that identifies the server connection + * me - the identity in the chatroom * room - the room left * who - the user who has left (Just the User ID) */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave)(int id, char *room, char *who); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave)(int id, const char *me, const char *room, const char *who); /* @@ -310,6 +285,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave)(int id, char *room, char *who * Called when someone messages in the chatroom. * Params: * id - the id that identifies the server connection + * me - the identity in the chatroom * room - the room * who - the user who messaged (Just the user id) * msg - the message @@ -317,7 +293,8 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave)(int id, char *room, char *who * 2 = /me type message * utf8 - whether the message is utf8 encoded or not */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message)(int id, char *who, char *room, char *msg, int msgtype, int utf8); +void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message)(int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, int utf8); + /* * @@ -328,10 +305,12 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message)(int id, char *who, char *room, * of the disconnect request before doing anything here (auto-join's etc) * Params: * id - the id that identifies this connection + * me - the identity in the chatroom * Returns: * nothing. */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout)(int id); +void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout)(int id, const char *me); + /* * @@ -343,25 +322,25 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout)(int id); * of the error before doing anything about it. * Params: * id - the id that identifies this connection + * me - the identity in the chatroom * Returns: * nothing. */ +void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror)(int id, const char *me); -void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror)(int id); /* * Name: ext_yahoo_conf_message * Called when someone messages in the conference. * Params: * id - the id that identifies the server connection + * me - the identity the conf message was sent to * who - the user who messaged * room - the room * msg - the message * utf8 - whether the message is utf8 encoded or not */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message)(int id, char *who, char *room, char *msg, int utf8); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message)(int id, const char *me, const char *who, const char *room, const char *msg, int utf8); /* @@ -369,6 +348,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message)(int id, char *who, char *room, * Called when someone sends you a file * Params: * id - the id that identifies the server connection + * me - the identity the file was sent to * who - the user who sent the file * url - the file url * expires - the expiry date of the file on the server (timestamp) @@ -376,9 +356,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message)(int id, char *who, char *room, * fname- the file name if direct transfer * fsize- the file size if direct transfer */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_got_file)(int id, char *who, char *url, long expires, char *msg, char *fname, unsigned long fesize); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_got_file)(int id, const char *me, const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize); /* @@ -390,9 +368,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_file)(int id, char *who, char *url, long * who - who was added * msg - any message sent */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added)(int id, char *myid, char *who, char *msg); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added)(int id, const char *myid, const char *who, const char *msg); /* @@ -403,9 +379,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added)(int id, char *myid, char *who, * who - who rejected you * msg - any message sent */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected)(int id, char *who, char *msg); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected)(int id, const char *who, const char *msg); /* @@ -413,12 +387,11 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected)(int id, char *who, char *msg); * Called when remote user starts or stops typing. * Params: * id - the id that identifies the server connection + * me - the handle of the identity the notification is sent to * who - the handle of the remote user * stat - 1 if typing, 0 if stopped typing */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify)(int id, char *who, int stat); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify)(int id, const char *me, const char *who, int stat); /* @@ -426,12 +399,11 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify)(int id, char *who, int stat); * Called when remote user starts or stops a game. * Params: * id - the id that identifies the server connection + * me - the handle of the identity the notification is sent to * who - the handle of the remote user * stat - 1 if game, 0 if stopped gaming */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify)(int id, char *who, int stat); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify)(int id, const char *me, const char *who, int stat); /* @@ -443,9 +415,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify)(int id, char *who, int stat); * subj - the subject of the mail - NULL if only mail count * cnt - mail count - 0 if new mail notification */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify)(int id, char *from, char *subj, int cnt); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify)(int id, const char *from, const char *subj, int cnt); /* @@ -455,17 +425,49 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify)(int id, char *from, char *subj, * id - the id that identifies the server connection * msg - the message */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_system_message)(int id, char *msg); - - - - - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_system_message)(int id, const char *msg); +/* + * Name: ext_yahoo_got_buddyicon + * Buddy icon received + * Params: + * id - the id that identifies the server connection + * me - the handle of the identity the notification is sent to + * who - the person the buddy icon is for + * url - the url to use to load the icon + * checksum - the checksum of the icon content + */ +void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon)(int id, const char *me, const char *who, const char *url, int checksum); +/* + * Name: ext_yahoo_got_buddyicon_checksum + * Buddy icon checksum received + * Params: + * id - the id that identifies the server connection + * me - the handle of the identity the notification is sent to + * who - the yahoo id of the buddy icon checksum is for + * checksum - the checksum of the icon content + */ +void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_checksum)(int id, const char *me,const char *who, int checksum); +/* + * Name: ext_yahoo_got_buddyicon_request + * Buddy icon request received + * Params: + * id - the id that identifies the server connection + * me - the handle of the identity the notification is sent to + * who - the yahoo id of the buddy that requested the buddy icon + */ +void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_request)(int id, const char *me, const char *who); +/* + * Name: ext_yahoo_got_buddyicon_request + * Buddy icon request received + * Params: + * id - the id that identifies the server connection + * url - remote url, the uploaded buddy icon can be fetched from + */ +void YAHOO_CALLBACK_TYPE(ext_yahoo_buddyicon_uploaded)(int id, const char *url); /* * Name: ext_yahoo_got_webcam_image @@ -495,18 +497,15 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_webcam_image)(int id, const char * who, unsigned int timestamp); - - /* * Name: ext_yahoo_webcam_invite * Called when you get a webcam invitation * Params: * id - the id that identifies the server connection + * me - identity the invitation is to * from - who the invitation is from */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite)(int id, char *from); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite)(int id, const char *me, const char *from); /* @@ -514,11 +513,11 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite)(int id, char *from); * Called when you get a response to a webcam invitation * Params: * id - the id that identifies the server connection + * me - identity the invitation response is to * from - who the invitation response is from * accept - 0 (decline), 1 (accept) */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply)(int id, char *from, int accept); - +void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply)(int id, const char *me, const char *from, int accept); /* @@ -533,7 +532,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply)(int id, char *from, int * 3 = user declines permission * 4 = user does not have webcam online */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed)(int id, char *who, int reason); +void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed)(int id, const char *who, int reason); /* @@ -551,7 +550,6 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed)(int id, char *who, int reason) void YAHOO_CALLBACK_TYPE(ext_yahoo_got_search_result)(int id, int found, int start, int total, YList *contacts); - /* * Name: ext_yahoo_error * Called on error. @@ -559,10 +557,9 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_got_search_result)(int id, int found, int sta * id - the id that identifies the server connection * err - the error message * fatal- whether this error is fatal to the connection or not + * num - Which error is this */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_error)(int id, char *err, int fatal); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_error)(int id, const char *err, int fatal, int num); /* @@ -573,9 +570,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_error)(int id, char *err, int fatal); * who - the viewer * connect - 0=disconnect 1=connect 2=request */ -void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer)(int id, char *who, int connect); - - +void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer)(int id, const char *who, int connect); /* @@ -588,8 +583,6 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer)(int id, char *who, int connect void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request)(int id, int send); - - /* * Name: ext_yahoo_log * Called to log a message. @@ -598,13 +591,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request)(int id, int send); * Returns: * 0 */ -int YAHOO_CALLBACK_TYPE(ext_yahoo_log)(char *fmt, ...); - - - - - - +int YAHOO_CALLBACK_TYPE(ext_yahoo_log)(const char *fmt, ...); /* @@ -623,8 +610,6 @@ int YAHOO_CALLBACK_TYPE(ext_yahoo_log)(char *fmt, ...); int YAHOO_CALLBACK_TYPE(ext_yahoo_add_handler)(int id, int fd, yahoo_input_condition cond, void *data); - - /* * Name: ext_yahoo_remove_handler * Remove the listener for the fd. @@ -635,9 +620,6 @@ int YAHOO_CALLBACK_TYPE(ext_yahoo_add_handler)(int id, int fd, yahoo_input_condi void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler)(int id, int tag); - - - /* * Name: ext_yahoo_connect * Connect to a host:port @@ -647,13 +629,7 @@ void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler)(int id, int tag); * Returns: * a unix file descriptor to the socket */ -int YAHOO_CALLBACK_TYPE(ext_yahoo_connect)(char *host, int port); - - - - - - +int YAHOO_CALLBACK_TYPE(ext_yahoo_connect)(const char *host, int port); /* @@ -674,7 +650,7 @@ int YAHOO_CALLBACK_TYPE(ext_yahoo_connect)(char *host, int port); * Returns: * a unix file descriptor to the socket */ -int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async)(int id, char *host, int port, +int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async)(int id, const char *host, int port, yahoo_connect_callback callback, void *callback_data); #ifdef USE_STRUCT_CALLBACKS @@ -685,7 +661,7 @@ int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async)(int id, char *host, int port, * before doing anything else */ void yahoo_register_callbacks(struct yahoo_callbacks * tyc); - + #undef YAHOO_CALLBACK_TYPE #endif @@ -695,3 +671,4 @@ void yahoo_register_callbacks(struct yahoo_callbacks * tyc); #endif #endif + diff --git a/protocols/yahoo/yahoo2_types.h b/protocols/yahoo/yahoo2_types.h index 1a92b267..df1756eb 100644 --- a/protocols/yahoo/yahoo2_types.h +++ b/protocols/yahoo/yahoo2_types.h @@ -29,6 +29,7 @@ extern "C" { #endif enum yahoo_status { + YAHOO_STATUS_DISCONNECTED = -1, YAHOO_STATUS_AVAILABLE = 0, YAHOO_STATUS_BRB, YAHOO_STATUS_BUSY, @@ -42,13 +43,15 @@ enum yahoo_status { YAHOO_STATUS_INVISIBLE = 12, YAHOO_STATUS_CUSTOM = 99, YAHOO_STATUS_IDLE = 999, + YAHOO_STATUS_WEBLOGIN = 0x5a55aa55, YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */ - YAHOO_STATUS_NOTIFY = 0x16 + YAHOO_STATUS_NOTIFY = 0x16 /* TYPING */ }; #define YAHOO_STATUS_GAME 0x2 /* Games don't fit into the regular status model */ enum yahoo_login_status { YAHOO_LOGIN_OK = 0, + YAHOO_LOGIN_LOGOFF = 2, YAHOO_LOGIN_UNAME = 3, YAHOO_LOGIN_PASSWD = 13, YAHOO_LOGIN_LOCK = 14, @@ -57,6 +60,9 @@ enum yahoo_login_status { }; enum yahoo_error { + E_UNKNOWN = -1, + E_CONNECTION = -2, + E_SYSTEM = -3, E_CUSTOM = 0, /* responses from ignore buddy */ @@ -78,6 +84,7 @@ enum yahoo_log_level { YAHOO_LOG_DEBUG }; +#define YAHOO_PROTO_VER 0x000b /* Yahoo style/color directives */ #define YAHOO_COLOR_BLACK "\033[30m" @@ -115,6 +122,12 @@ enum yahoo_webcam_direction_type { YAHOO_WEBCAM_UPLOAD }; +enum yahoo_stealth_visibility_type { + YAHOO_STEALTH_DEFAULT = 0, + YAHOO_STEALTH_ONLINE, + YAHOO_STEALTH_PERM_OFFLINE +}; + /* chat member attribs */ #define YAHOO_CHAT_MALE 0x8000 #define YAHOO_CHAT_FEMALE 0x10000 diff --git a/protocols/yahoo/yahoo_util.c b/protocols/yahoo/yahoo_util.c index 7babfa49..5375205f 100644 --- a/protocols/yahoo/yahoo_util.c +++ b/protocols/yahoo/yahoo_util.c @@ -68,13 +68,15 @@ char ** y_strsplit(char * str, char * sep, int nelem) char *s, *p; int i=0; int l = strlen(sep); - if(nelem < 0) { + if(nelem <= 0) { char * s; nelem=0; - for(s=strstr(str, sep); s; s=strstr(s+l, sep),nelem++) - ; - if(strcmp(str+strlen(str)-l, sep)) - nelem++; + if (*str) { + for(s=strstr(str, sep); s; s=strstr(s+l, sep),nelem++) + ; + if(strcmp(str+strlen(str)-l, sep)) + nelem++; + } } vector = y_new(char *, nelem + 1); @@ -86,7 +88,7 @@ char ** y_strsplit(char * str, char * sep, int nelem) vector[i][len] = '\0'; } - if(i Date: Mon, 16 Apr 2007 20:57:30 -0700 Subject: Hopefully improved Yahoo! "markup" stripping. --- protocols/yahoo/yahoo.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 6f6590df..aad9d2df 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -70,7 +70,7 @@ static char *byahoo_strip( const char *in ) { int len; - /* This should get rid of HTML tags at the beginning of the string. */ + /* This should get rid of the markup noise at the beginning of the string. */ while( *in ) { if( g_strncasecmp( in, " 0 && in[len-1] == '>' ) + while( len > 0 && ( in[len-1] == '>' || in[len-1] == 'm' ) ) { int blen = len; + const char *search; - len --; - while( len > 0 && ( in[len] != '<' || in[len+1] != '/' ) ) + if( in[len-1] == '>' ) + search = " 0 && strncmp( in + len, search, 2 ) != 0 ) len --; - if( len == 0 && ( in[len] != '<' || in[len+1] != '/' ) ) + if( len <= 0 && strncmp( in, search, 2 ) != 0 ) { len = blen; break; -- cgit v1.2.3 From 9624fdf0d6f170d8caa7948fb1b3a138b05e1d8c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 16 Apr 2007 21:49:17 -0700 Subject: API cleanup pretty much complete. Fixed pretty much everything except the buddy/groupchat related functions. --- protocols/yahoo/yahoo.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index aad9d2df..191a197c 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -617,7 +617,7 @@ void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg, struct im_connection *ic = byahoo_get_ic_by_id( id ); char *m = byahoo_strip( msg ); - serv_got_im( ic, (char*) who, (char*) m, 0, 0, strlen( m ) ); + imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 ); g_free( m ); } @@ -633,14 +633,11 @@ void ext_yahoo_got_file( int id, 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 ); - if (stat == 1) { - /* User is typing */ - serv_got_typing( ic, (char*) who, 1, 1 ); - } - else { - /* User stopped typing */ - serv_got_typing( ic, (char*) who, 1, 0 ); - } + + if( stat == 1 ) + imcb_buddy_typing( ic, (char*) who, OPT_TYPING ); + else + imcb_buddy_typing( ic, (char*) who, 0 ); } void ext_yahoo_system_message( int id, const char *msg ) -- cgit v1.2.3 From f0cb961652cbd639e89dcd88a86f20a2414146c4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 18 Apr 2007 23:03:43 -0700 Subject: More API changes: buddy list management. imcb_add_buddy() is now a *real* callback, it's only called from inside IM-modules. This makes sure a buddy only gets added to the BitlBee structures if the add was successful. This gets rid of the weirdness described in #55. Unfortunately for now this change breaks A) automatic renaming of ICQ contacts (if there are names stored in the contact list) B) add -tmp. --- protocols/yahoo/libyahoo2.c | 19 +++++++++++++------ protocols/yahoo/yahoo.c | 7 ++++++- 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 38041ad4..5beae687 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -2402,12 +2402,19 @@ static void yahoo_process_buddyadd(struct yahoo_input_data *yid, struct yahoo_pa if(!where) where = "Unknown"; - bud = y_new0(struct yahoo_buddy, 1); - bud->id = strdup(who); - bud->group = strdup(where); - bud->real_name = NULL; - - yd->buddies = y_list_append(yd->buddies, bud); + /* status: 0 == Successful, 1 == Error (does not exist), 2 == Already in list */ + if( status == 0 ) { + bud = y_new0(struct yahoo_buddy, 1); + bud->id = strdup(who); + bud->group = strdup(where); + bud->real_name = NULL; + + yd->buddies = y_list_append(yd->buddies, bud); + + /* Possibly called already, but at least the call above doesn't + seem to happen every time (not anytime I tried). */ + YAHOO_CALLBACK(ext_yahoo_contact_added)(yd->client_id, me, who, NULL); + } /* YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, who, status, NULL, (status==YAHOO_STATUS_AVAILABLE?0:1)); */ } diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 191a197c..c3d57a94 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -531,7 +531,9 @@ void ext_yahoo_got_buddies( int id, YList *buds ) yd->buddygroups = g_slist_append( yd->buddygroups, bg ); } - add_buddy( ic, b->group, b->id, b->real_name ); + imcb_add_buddy( ic, b->id, b->group ); + imcb_rename_buddy( ic, b->id, b->real_name ); + bl = bl->next; } } @@ -903,6 +905,9 @@ void ext_yahoo_chat_yahooerror( int id, const char *me ) void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg ) { + /* Groups schmoups. If I want to handle groups properly I can get the + buddy data from some internal libyahoo2 structure. */ + imcb_add_buddy( byahoo_get_ic_by_id( id ), (char*) who, NULL ); } void ext_yahoo_rejected( int id, const char *who, const char *msg ) -- cgit v1.2.3 From 61ae52c5fbe8fbaf75adb148cd05c357590e8807 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 19 Apr 2007 22:19:06 -0700 Subject: Renamed/slightly changed syntax of groupchat callback functions. --- protocols/yahoo/yahoo.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index c3d57a94..7bf3f333 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -145,7 +145,7 @@ static void byahoo_logout( struct im_connection *ic ) GSList *l; while( ic->conversations ) - serv_got_chat_left( ic->conversations ); + imcb_chat_removed( ic->conversations ); for( l = yd->buddygroups; l; l = l->next ) { @@ -317,7 +317,7 @@ static void byahoo_chat_leave( struct groupchat *c ) struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title ); - serv_got_chat_left( c ); + imcb_chat_removed( c ); } static struct groupchat *byahoo_chat_with( struct im_connection *ic, char *who ) @@ -329,8 +329,8 @@ static struct groupchat *byahoo_chat_with( struct im_connection *ic, char *who ) roomname = g_strdup_printf( "%s-Bee-%d", ic->acc->user, byahoo_chat_id ); - c = serv_got_joined_chat( ic, roomname ); - add_chat_buddy( c, ic->acc->user ); + c = imcb_chat_new( ic, roomname ); + imcb_chat_add_buddy( c, ic->acc->user ); /* FIXME: Free this thing when the chat's destroyed. We can't *always* do this because it's not always created here. */ @@ -789,7 +789,7 @@ int ext_yahoo_connect(const char *host, int port) static void byahoo_accept_conf( gpointer w, struct byahoo_conf_invitation *inv ) { yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name ); - add_chat_buddy( inv->c, inv->ic->acc->user ); + imcb_chat_add_buddy( inv->c, inv->ic->acc->user ); g_free( inv->name ); g_free( inv ); } @@ -797,7 +797,7 @@ static void byahoo_accept_conf( gpointer w, struct byahoo_conf_invitation *inv ) static void byahoo_reject_conf( gpointer w, struct byahoo_conf_invitation *inv ) { yahoo_conference_decline( inv->yid, NULL, inv->members, inv->name, "User rejected groupchat" ); - serv_got_chat_left( inv->c ); + imcb_chat_removed( inv->c ); g_free( inv->name ); g_free( inv ); } @@ -813,7 +813,7 @@ void ext_yahoo_got_conf_invite( int id, const char *ignored, inv = g_malloc( sizeof( struct byahoo_conf_invitation ) ); memset( inv, 0, sizeof( struct byahoo_conf_invitation ) ); inv->name = g_strdup( room ); - inv->c = serv_got_joined_chat( ic, (char*) room ); + inv->c = imcb_chat_new( ic, (char*) room ); inv->c->data = members; inv->yid = id; inv->members = members; @@ -821,7 +821,7 @@ void ext_yahoo_got_conf_invite( int id, const char *ignored, for( m = members; m; m = m->next ) if( g_strcasecmp( m->data, ic->acc->user ) != 0 ) - add_chat_buddy( inv->c, m->data ); + imcb_chat_add_buddy( inv->c, m->data ); g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg ); @@ -843,7 +843,7 @@ void ext_yahoo_conf_userjoin( int id, const char *ignored, const char *who, cons for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); if( c ) - add_chat_buddy( c, (char*) who ); + imcb_chat_add_buddy( c, (char*) who ); } void ext_yahoo_conf_userleave( int id, const char *ignored, const char *who, const char *room ) @@ -855,7 +855,7 @@ void ext_yahoo_conf_userleave( int id, const char *ignored, const char *who, con for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); if( c ) - remove_chat_buddy( c, (char*) who, "" ); + imcb_chat_remove_buddy( c, (char*) who, "" ); } void ext_yahoo_conf_message( int id, const char *ignored, const char *who, const char *room, const char *msg, int utf8 ) @@ -867,7 +867,7 @@ void ext_yahoo_conf_message( int id, const char *ignored, const char *who, const for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); if( c ) - serv_got_chat_in( c, (char*) who, 0, (char*) m, 0 ); + imcb_chat_msg( c, (char*) who, (char*) m, 0, 0 ); g_free( m ); } -- cgit v1.2.3 From f6c963b97d3f686ca5410f1896cf8e266b455c22 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 20 Apr 2007 21:13:21 -0700 Subject: Renamed some more prpl functions. --- protocols/yahoo/yahoo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 7bf3f333..0a49baac 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -173,7 +173,7 @@ static void byahoo_get_info(struct im_connection *ic, char *who) who); } -static int byahoo_send_im( struct im_connection *ic, char *who, char *what, int flags ) +static int byahoo_buddy_msg( struct im_connection *ic, char *who, char *what, int flags ) { struct byahoo_data *yd = ic->proto_data; @@ -298,7 +298,7 @@ static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *grou } } -static void byahoo_chat_send( struct groupchat *c, char *message, int flags ) +static void byahoo_chat_msg( struct groupchat *c, char *message, int flags ) { struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; @@ -353,7 +353,7 @@ void byahoo_initmodule( ) ret->keepalive = byahoo_keepalive; ret->logout = byahoo_logout; - ret->send_im = byahoo_send_im; + ret->buddy_msg = byahoo_buddy_msg; ret->get_info = byahoo_get_info; ret->away_states = byahoo_away_states; ret->set_away = byahoo_set_away; @@ -361,7 +361,7 @@ void byahoo_initmodule( ) ret->remove_buddy = byahoo_remove_buddy; ret->send_typing = byahoo_send_typing; - ret->chat_send = byahoo_chat_send; + ret->chat_msg = byahoo_chat_msg; ret->chat_invite = byahoo_chat_invite; ret->chat_leave = byahoo_chat_leave; ret->chat_with = byahoo_chat_with; -- cgit v1.2.3 From df1fb67d1dbf52d138f63e0d917dda2412d4fc0b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 20 Apr 2007 22:18:40 -0700 Subject: Consistency; Using OPT_T(YP|HINK)ING for outgoing typing notfication crap too. --- protocols/yahoo/yahoo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 0a49baac..69fc29bb 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -186,7 +186,7 @@ static int byahoo_send_typing( struct im_connection *ic, char *who, int typing ) { struct byahoo_data *yd = ic->proto_data; - yahoo_send_typing( yd->y2_id, NULL, who, typing ); + yahoo_send_typing( yd->y2_id, NULL, who, ( typing & OPT_TYPING ) != 0 ); return 1; } -- cgit v1.2.3 From e35d1a121d5fb2da3698fbe4a365fe38d0097665 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 22 Apr 2007 13:44:27 -0700 Subject: Read-only support for Jabber conferences (non-anonymous rooms only). Just don't use this, you're really not going to like it. :-) --- protocols/yahoo/yahoo.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 69fc29bb..28a72877 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -144,8 +144,8 @@ static void byahoo_logout( struct im_connection *ic ) struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; GSList *l; - while( ic->conversations ) - imcb_chat_removed( ic->conversations ); + while( ic->groupchats ) + imcb_chat_free( ic->groupchats ); for( l = yd->buddygroups; l; l = l->next ) { @@ -317,7 +317,7 @@ static void byahoo_chat_leave( struct groupchat *c ) struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title ); - imcb_chat_removed( c ); + imcb_chat_free( c ); } static struct groupchat *byahoo_chat_with( struct im_connection *ic, char *who ) @@ -797,7 +797,7 @@ static void byahoo_accept_conf( gpointer w, struct byahoo_conf_invitation *inv ) static void byahoo_reject_conf( gpointer w, struct byahoo_conf_invitation *inv ) { yahoo_conference_decline( inv->yid, NULL, inv->members, inv->name, "User rejected groupchat" ); - imcb_chat_removed( inv->c ); + imcb_chat_free( inv->c ); g_free( inv->name ); g_free( inv ); } @@ -840,7 +840,7 @@ void ext_yahoo_conf_userjoin( int id, const char *ignored, const char *who, cons struct im_connection *ic = byahoo_get_ic_by_id( id ); struct groupchat *c; - for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); + for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next ); if( c ) imcb_chat_add_buddy( c, (char*) who ); @@ -852,7 +852,7 @@ void ext_yahoo_conf_userleave( int id, const char *ignored, const char *who, con struct im_connection *ic = byahoo_get_ic_by_id( id ); struct groupchat *c; - for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); + for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next ); if( c ) imcb_chat_remove_buddy( c, (char*) who, "" ); @@ -864,7 +864,7 @@ void ext_yahoo_conf_message( int id, const char *ignored, const char *who, const char *m = byahoo_strip( msg ); struct groupchat *c; - for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); + for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next ); if( c ) imcb_chat_msg( c, (char*) who, (char*) m, 0, 0 ); -- cgit v1.2.3 From 77bfd077778c30c70f791752ce3a13d537aedd3b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 23 Nov 2007 23:07:44 +0000 Subject: Replaced GPL-incompatible SHA1 hashing code (and renamed the files in case I ever need SHA256 ;-)). --- protocols/yahoo/libyahoo2.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 5beae687..ce38bc73 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -75,7 +75,7 @@ char *strchr (), *strrchr (); #include #include -#include "sha.h" +#include "sha1.h" #include "md5.h" #include "yahoo2.h" #include "yahoo_httplib.h" @@ -1819,8 +1819,8 @@ static void yahoo_process_auth_0x0b(struct yahoo_input_data *yid, const char *se md5_byte_t result[16]; md5_state_t ctx; - SHA_CTX ctx1; - SHA_CTX ctx2; + sha1_state_t ctx1; + sha1_state_t ctx2; char *alphabet1 = "FBZDWAGHrJTLMNOPpRSKUVEXYChImkwQ"; char *alphabet2 = "F0E1D2C3B4A59687abcdefghijklmnop"; @@ -1876,7 +1876,7 @@ static void yahoo_process_auth_0x0b(struct yahoo_input_data *yid, const char *se magic_ptr = (unsigned char *)seed; - while (*magic_ptr != (int)NULL) { + while (*magic_ptr != 0) { char *loc; /* Ignore parentheses. */ @@ -2055,27 +2055,27 @@ static void yahoo_process_auth_0x0b(struct yahoo_input_data *yid, const char *se if (cnt < 64) memset(&(pass_hash_xor2[cnt]), 0x5c, 64-cnt); - shaInit(&ctx1); - shaInit(&ctx2); + sha1_init(&ctx1); + sha1_init(&ctx2); /* The first context gets the password hash XORed * with 0x36 plus a magic value * which we previously extrapolated from our * challenge. */ - shaUpdate(&ctx1, pass_hash_xor1, 64); + sha1_append(&ctx1, pass_hash_xor1, 64); if (j >= 3 ) - ctx1.sizeLo = 0x1ff; - shaUpdate(&ctx1, magic_key_char, 4); - shaFinal(&ctx1, digest1); + ctx1.Length_Low = 0x1ff; + sha1_append(&ctx1, magic_key_char, 4); + sha1_finish(&ctx1, digest1); /* The second context gets the password hash XORed * with 0x5c plus the SHA-1 digest * of the first context. */ - shaUpdate(&ctx2, pass_hash_xor2, 64); - shaUpdate(&ctx2, digest1, 20); - shaFinal(&ctx2, digest2); + sha1_append(&ctx2, pass_hash_xor2, 64); + sha1_append(&ctx2, digest1, 20); + sha1_finish(&ctx2, digest2); /* Now that we have digest2, use it to fetch * characters from an alphabet to construct @@ -2146,27 +2146,27 @@ static void yahoo_process_auth_0x0b(struct yahoo_input_data *yid, const char *se if (cnt < 64) memset(&(crypt_hash_xor2[cnt]), 0x5c, 64-cnt); - shaInit(&ctx1); - shaInit(&ctx2); + sha1_init(&ctx1); + sha1_init(&ctx2); /* The first context gets the password hash XORed * with 0x36 plus a magic value * which we previously extrapolated from our * challenge. */ - shaUpdate(&ctx1, crypt_hash_xor1, 64); + sha1_append(&ctx1, crypt_hash_xor1, 64); if (j >= 3 ) - ctx1.sizeLo = 0x1ff; - shaUpdate(&ctx1, magic_key_char, 4); - shaFinal(&ctx1, digest1); + ctx1.Length_Low = 0x1ff; + sha1_append(&ctx1, magic_key_char, 4); + sha1_finish(&ctx1, digest1); /* The second context gets the password hash XORed * with 0x5c plus the SHA-1 digest * of the first context. */ - shaUpdate(&ctx2, crypt_hash_xor2, 64); - shaUpdate(&ctx2, digest1, 20); - shaFinal(&ctx2, digest2); + sha1_append(&ctx2, crypt_hash_xor2, 64); + sha1_append(&ctx2, digest1, 20); + sha1_finish(&ctx2, digest2); /* Now that we have digest2, use it to fetch * characters from an alphabet to construct -- cgit v1.2.3 From c058ff976bbbbf43ef11c262f21440e61244f73e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 9 Dec 2007 23:19:35 +0000 Subject: Added /invite support for Jabber chatrooms (and fixed the argument order to chat_invite). --- protocols/yahoo/yahoo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 28a72877..625f3d1c 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -305,7 +305,7 @@ static void byahoo_chat_msg( struct groupchat *c, char *message, int flags ) yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 ); } -static void byahoo_chat_invite( struct groupchat *c, char *msg, char *who ) +static void byahoo_chat_invite( struct groupchat *c, char *who, char *msg ) { struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; -- cgit v1.2.3 From 1febf5c93b231942cd9cac8ac6a5a0d830c581cc Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Jan 2008 21:15:32 +0000 Subject: Added "mail_notifications" setting. Who needs those notifications anyway? Closes: #338. --- protocols/yahoo/yahoo.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 625f3d1c..d413597a 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -126,6 +126,11 @@ static char *byahoo_strip( const char *in ) return( g_strndup( in, len ) ); } +static void byahoo_init( account_t *acc ) +{ + set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); +} + static void byahoo_login( account_t *acc ) { struct im_connection *ic = imcb_new( acc ); @@ -348,6 +353,7 @@ void byahoo_initmodule( ) { struct prpl *ret = g_new0(struct prpl, 1); ret->name = "yahoo"; + ret->init = byahoo_init; ret->login = byahoo_login; ret->keepalive = byahoo_keepalive; @@ -922,7 +928,9 @@ void ext_yahoo_mail_notify( int id, const char *from, const char *subj, int cnt { struct im_connection *ic = byahoo_get_ic_by_id( id ); - if( from && subj ) + if( !set_getbool( &ic->acc->set, "mail_notifications" ) ) + ; /* The user doesn't care. */ + else if( from && subj ) imcb_log( ic, "Received e-mail message from %s with subject `%s'", from, subj ); else if( cnt > 0 ) imcb_log( ic, "Received %d new e-mails", cnt ); -- cgit v1.2.3 From ac4adf9a546c2e9b247b9de4b753177e6bd479e4 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 17 Jan 2008 22:48:32 +0000 Subject: Apparently ext_yahoo_got_im can be called with msg=NULL, so it should be handled. Let's just ignore those packets. --- protocols/yahoo/yahoo.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index d413597a..9f9ffcf7 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -623,10 +623,14 @@ void ext_yahoo_status_changed( int id, const char *who, int stat, const char *ms 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 ); - char *m = byahoo_strip( msg ); + char *m; - imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 ); - g_free( m ); + if( msg ) + { + m = byahoo_strip( msg ); + imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 ); + g_free( m ); + } } void ext_yahoo_got_file( int id, -- cgit v1.2.3 From fc5cf88448d4337d1a5fde418df1c6206a9b0ea2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 16 Feb 2008 16:45:12 +0100 Subject: Fix lcov dependencies. --- protocols/yahoo/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/Makefile b/protocols/yahoo/Makefile index 2cfd147b..b4fe56e2 100644 --- a/protocols/yahoo/Makefile +++ b/protocols/yahoo/Makefile @@ -17,7 +17,7 @@ LFLAGS += -r # [SH] Phony targets all: yahoo_mod.o check: all -lcov: +lcov: check gcov: gcov *.c -- cgit v1.2.3 From a869d9147584de96a0ac341416e551953167800f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 15 Mar 2008 17:44:21 +0000 Subject: Indicate that we support YMSG protocol version 12, this should hopefully keep BitlBee working after 2008-04-02 . --- protocols/yahoo/libyahoo2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index ce38bc73..4e93449e 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -736,7 +736,7 @@ static void yahoo_send_packet(struct yahoo_input_data *yid, struct yahoo_packet data = y_new0(unsigned char, len + 1); memcpy(data + pos, "YMSG", 4); pos += 4; - pos += yahoo_put16(data + pos, 0x0a00); + pos += yahoo_put16(data + pos, 0x000c); pos += yahoo_put16(data + pos, 0x0000); pos += yahoo_put16(data + pos, pktlen + extra_pad); pos += yahoo_put16(data + pos, pkt->service); -- cgit v1.2.3 From 79eae4a9edb343eaad30425289f7737467a535bb Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 15 Mar 2008 21:05:39 +0000 Subject: Inviting someone to a Yahoo! chatroom with msg=NULL is bad. I wonder if /invite ever worked in the Yahoo! module... --- protocols/yahoo/yahoo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 9f9ffcf7..36579d66 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -314,7 +314,7 @@ static void byahoo_chat_invite( struct groupchat *c, char *who, char *msg ) { struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; - yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ); + yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ? msg : "" ); } static void byahoo_chat_leave( struct groupchat *c ) -- cgit v1.2.3 From 4bb50efd1015a04d44c301961710fa08e0eda162 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 15 Mar 2008 23:53:54 +0000 Subject: Although I have no idea what the author meant with code like `if(cp != "\005")', I'm sure he feels homesick to QuickBasic. Since BitlBee doesn't use this function anyway, it doesn't really matter if my fix works. As long as it keeps the compiler quiet. --- protocols/yahoo/libyahoo2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 4e93449e..80d88a85 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -3350,7 +3350,7 @@ static void yahoo_process_search_connection(struct yahoo_input_data *yid, int ov yct->age = atoi(cp); break; case 5: - if(cp != "\005") + if(strcmp(cp, "5") != 0) yct->location = cp; k = 0; break; -- cgit v1.2.3