From ccba98084344125e0f89331baced2ba6d1802b29 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 17 Dec 2009 00:42:25 +0000 Subject: A few fixes for bugs that caused coredumps on testing.bitlbee.org (or caught my attention in new compiler warnings). --- protocols/yahoo/libyahoo2.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index a1755cc9..836670f7 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -1529,12 +1529,19 @@ static void yahoo_process_buddy_list(struct yahoo_input_data *yid, struct yahoo_ case 7: newbud = y_new0(struct yahoo_buddy, 1); newbud->id = strdup(pair->value); - if(cur_group) + if (cur_group) { newbud->group = strdup(cur_group); - else { - struct yahoo_buddy *lastbud = (struct yahoo_buddy *)y_list_nth( - yd->buddies, y_list_length(yd->buddies)-1)->data; - newbud->group = strdup(lastbud->group); + } else { + YList *last; + struct yahoo_buddy *lastbud; + + for (last = yd->buddies; last && last->next; last = last->next); + if (last) { + lastbud = last->data; + newbud->group = strdup(lastbud->group); + } else { + newbud->group = strdup("Buddies"); + } } yd->buddies = y_list_append(yd->buddies, newbud); @@ -2392,10 +2399,16 @@ static void yahoo_https_auth_token_init(struct yahoo_https_auth_data *had) static void yahoo_https_auth_token_finish(struct http_request *req) { struct yahoo_https_auth_data *had = req->data; - struct yahoo_input_data *yid = had->yid; - struct yahoo_data *yd = yid->yd; + struct yahoo_input_data *yid; + struct yahoo_data *yd; int st; + if (y_list_find(inputs, had->yid) == NULL) + return; + + yid = had->yid; + yd = yid->yd; + if (req->status_code != 200) { YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 2000 + req->status_code, NULL); goto fail; @@ -2435,12 +2448,18 @@ static void yahoo_https_auth_init(struct yahoo_https_auth_data *had) static void yahoo_https_auth_finish(struct http_request *req) { struct yahoo_https_auth_data *had = req->data; - struct yahoo_input_data *yid = had->yid; - struct yahoo_data *yd = yid->yd; + struct yahoo_input_data *yid; + struct yahoo_data *yd; struct yahoo_packet *pack; - char *crumb; + char *crumb = NULL; int st; + if (y_list_find(inputs, had->yid) == NULL) + return; + + yid = had->yid; + yd = yid->yd; + md5_byte_t result[16]; md5_state_t ctx; -- cgit v1.2.3 From 4049061ea3b1fbe939c623a8501aea60906893ea Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 6 Mar 2010 17:10:32 +0000 Subject: Fixed up Yahoo! I'll have to do some more thorough testing of this code since I may have broken something. --- protocols/yahoo/libyahoo2.c | 20 +++++--------------- protocols/yahoo/yahoo.c | 37 +++++++------------------------------ 2 files changed, 12 insertions(+), 45 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 836670f7..20e284f7 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -4086,6 +4086,9 @@ void yahoo_send_typing(int id, const char *from, const char *who, int typ) yahoo_packet_free(pkt); } +/* TODO(wilmer): See if this this function still works since I got rid of a + lot of things that seemed illogical. Some things may have + been intentional. */ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away) { struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); @@ -4098,14 +4101,8 @@ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away) return; yd = yid->yd; - old_status = yd->current_status; - - if (msg && strncmp(msg,"Invisible",9)) { - yd->current_status = YAHOO_STATUS_CUSTOM; - } else { - yd->current_status = state; - } + yd->current_status = state; /* Thank you libpurple :) */ if (yd->current_status == YAHOO_STATUS_INVISIBLE) { @@ -4120,15 +4117,8 @@ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away) pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, 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); - } else { - yahoo_packet_hash(pkt, 19, ""); - } - + yahoo_packet_hash(pkt, 19, msg); yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); - yahoo_send_packet(yid, pkt, 0); yahoo_packet_free(pkt); diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index ac57d4b6..78a8eb8a 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -129,6 +129,8 @@ static char *byahoo_strip( const char *in ) static void byahoo_init( account_t *acc ) { set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); + + acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE; } static void byahoo_login( account_t *acc ) @@ -196,29 +198,10 @@ static int byahoo_send_typing( struct im_connection *ic, char *who, int typing ) static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) { struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; - char *away; - - away = NULL; - if( state && msg && g_strcasecmp( state, msg ) != 0 ) - { - yd->current_status = YAHOO_STATUS_CUSTOM; - away = ""; - } - else if( state ) + 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; - - away = ""; - if( g_strcasecmp( state, "Available" ) == 0 ) - { - yd->current_status = YAHOO_STATUS_AVAILABLE; - away = NULL; - } - else if( g_strcasecmp( state, "Be Right Back" ) == 0 ) + if( g_strcasecmp( state, "Be Right Back" ) == 0 ) yd->current_status = YAHOO_STATUS_BRB; else if( g_strcasecmp( state, "Busy" ) == 0 ) yd->current_status = YAHOO_STATUS_BUSY; @@ -238,17 +221,13 @@ static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) yd->current_status = YAHOO_STATUS_STEPPEDOUT; else if( g_strcasecmp( state, "Invisible" ) == 0 ) yd->current_status = YAHOO_STATUS_INVISIBLE; - else if( g_strcasecmp( state, GAIM_AWAY_CUSTOM ) == 0 ) - { - yd->current_status = YAHOO_STATUS_AVAILABLE; - - away = NULL; - } + else + yd->current_status = YAHOO_STATUS_CUSTOM; } else yd->current_status = YAHOO_STATUS_AVAILABLE; - yahoo_set_away( yd->y2_id, yd->current_status, msg, away != NULL ? 2 : 0 ); + yahoo_set_away( yd->y2_id, yd->current_status, msg, state ? 2 : 0 ); } static GList *byahoo_away_states( struct im_connection *ic ) @@ -257,7 +236,6 @@ static GList *byahoo_away_states( struct im_connection *ic ) if( m == NULL ) { - m = g_list_append( m, "Available" ); m = g_list_append( m, "Be Right Back" ); m = g_list_append( m, "Busy" ); m = g_list_append( m, "Not At Home" ); @@ -268,7 +246,6 @@ static GList *byahoo_away_states( struct im_connection *ic ) m = g_list_append( m, "Out To Lunch" ); m = g_list_append( m, "Stepped Out" ); m = g_list_append( m, "Invisible" ); - m = g_list_append( m, GAIM_AWAY_CUSTOM ); } return m; -- cgit v1.2.3 From be915f54a52dd0f88b2a64d5cef094b0e6c9334d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 6 Mar 2010 18:19:31 +0000 Subject: Yahoo! fixes. Turns out the protocol really is somewhat odd. --- protocols/yahoo/libyahoo2.c | 5 +---- protocols/yahoo/yahoo.c | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 20e284f7..721f4b7c 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -4086,9 +4086,6 @@ void yahoo_send_typing(int id, const char *from, const char *who, int typ) yahoo_packet_free(pkt); } -/* TODO(wilmer): See if this this function still works since I got rid of a - lot of things that seemed illogical. Some things may have - been intentional. */ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away) { struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); @@ -4117,7 +4114,7 @@ void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away) pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, yd->current_status, yd->session_id); snprintf(s, sizeof(s), "%d", yd->current_status); yahoo_packet_hash(pkt, 10, s); - yahoo_packet_hash(pkt, 19, msg); + yahoo_packet_hash(pkt, 19, msg && state == YAHOO_STATUS_CUSTOM ? msg : ""); yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); yahoo_send_packet(yid, pkt, 0); yahoo_packet_free(pkt); diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 78a8eb8a..a47de966 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -199,8 +199,10 @@ static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) { struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; - if( state ) + if( state && msg == NULL ) { + /* Use these states only if msg doesn't contain additional + info since away messages are only supported with CUSTOM. */ if( g_strcasecmp( state, "Be Right Back" ) == 0 ) yd->current_status = YAHOO_STATUS_BRB; else if( g_strcasecmp( state, "Busy" ) == 0 ) @@ -224,6 +226,8 @@ static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) else yd->current_status = YAHOO_STATUS_CUSTOM; } + else if( state ) + yd->current_status = YAHOO_STATUS_CUSTOM; else yd->current_status = YAHOO_STATUS_AVAILABLE; -- cgit v1.2.3