diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2008-12-14 10:31:49 +0000 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2008-12-14 10:31:49 +0000 | 
| commit | c0c43fba49da3d14097f2c7cf3569a829b84125a (patch) | |
| tree | 06414233d0b5fdd20482a77ca89952b846b37a32 /protocols | |
| parent | 939370c674071a198e3115f9fa511fa51e8bea9e (diff) | |
Fixed ic->away leaking memory. This var is only used by OSCAR and should
maybe be killed. Also fixed some completely broken indentation in those
functions.
Diffstat (limited to 'protocols')
| -rw-r--r-- | protocols/nogaim.c | 3 | ||||
| -rw-r--r-- | protocols/nogaim.h | 2 | ||||
| -rw-r--r-- | protocols/oscar/oscar.c | 37 | ||||
| -rw-r--r-- | protocols/yahoo/yahoo.c | 13 | 
4 files changed, 28 insertions, 27 deletions
| diff --git a/protocols/nogaim.c b/protocols/nogaim.c index bec80c25..fd445324 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -320,6 +320,9 @@ void imc_logout( struct im_connection *ic, int allow_reconnect )  	ic->acc->prpl->logout( ic );  	b_event_remove( ic->inpa ); +	g_free( ic->away ); +	ic->away = NULL; +	  	u = irc->users;  	while( u )  	{ diff --git a/protocols/nogaim.h b/protocols/nogaim.h index d828de4c..ddfff07e 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -238,7 +238,7 @@ G_MODULE_EXPORT void register_protocol( struct prpl * );  /* You will need this function in prpl->login() to get an im_connection from   * the account_t parameter. */  G_MODULE_EXPORT struct im_connection *imcb_new( account_t *acc ); -G_MODULE_EXPORT void imcb_free( struct im_connection *ic ); +G_MODULE_EXPORT void imc_free( struct im_connection *ic );  /* Once you're connected, you should call this function, so that the user will   * see the success. */  G_MODULE_EXPORT void imcb_connected( struct im_connection *ic ); diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 8be04259..4142c046 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -1938,8 +1938,7 @@ static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od,  	aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); -	if (ic->away) -		g_free(ic->away); +	g_free(ic->away);  	ic->away = NULL;  	if (!message) { @@ -1959,55 +1958,53 @@ static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od,  static void oscar_set_away_icq(struct im_connection *ic, struct oscar_data *od, const char *state, const char *message)  { -    const char *msg = NULL; +	const char *msg = NULL;  	gboolean no_message = FALSE;  	/* clean old states */ -    if (ic->away) { -		g_free(ic->away); -		ic->away = NULL; -    } +	g_free(ic->away); +	ic->away = NULL;  	od->sess->aim_icq_state = 0;  	/* if no message, then use an empty message */ -    if (message) { -        msg = message; -    } else { -        msg = ""; +	if (message) { +		msg = message; +	} else { +		msg = "";  		no_message = TRUE; -    } +	}  	if (!g_strcasecmp(state, "Online")) {  		aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL);  	} else if (!g_strcasecmp(state, "Away")) {  		aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY); -        ic->away = g_strdup(msg); +		ic->away = g_strdup(msg);  		od->sess->aim_icq_state = AIM_MTYPE_AUTOAWAY;  	} else if (!g_strcasecmp(state, "Do Not Disturb")) {  		aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); -        ic->away = g_strdup(msg); +		ic->away = g_strdup(msg);  		od->sess->aim_icq_state = AIM_MTYPE_AUTODND;  	} else if (!g_strcasecmp(state, "Not Available")) {  		aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); -        ic->away = g_strdup(msg); +		ic->away = g_strdup(msg);  		od->sess->aim_icq_state = AIM_MTYPE_AUTONA;  	} else if (!g_strcasecmp(state, "Occupied")) {  		aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); -        ic->away = g_strdup(msg); +		ic->away = g_strdup(msg);  		od->sess->aim_icq_state = AIM_MTYPE_AUTOBUSY;  	} else if (!g_strcasecmp(state, "Free For Chat")) {  		aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_CHAT); -        ic->away = g_strdup(msg); +		ic->away = g_strdup(msg);  		od->sess->aim_icq_state = AIM_MTYPE_AUTOFFC;  	} else if (!g_strcasecmp(state, "Invisible")) {  		aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE); -        ic->away = g_strdup(msg); +		ic->away = g_strdup(msg);  	} else if (!g_strcasecmp(state, GAIM_AWAY_CUSTOM)) {  	 	if (no_message) {  			aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL);  		} else {  			aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY); -            ic->away = g_strdup(msg); +			ic->away = g_strdup(msg);  			od->sess->aim_icq_state = AIM_MTYPE_AUTOAWAY;  		}  	} @@ -2019,7 +2016,7 @@ static void oscar_set_away(struct im_connection *ic, char *state, char *message)  {  	struct oscar_data *od = (struct oscar_data *)ic->proto_data; -    oscar_set_away_aim(ic, od, state, message); +	oscar_set_away_aim(ic, od, state, message);  	if (od->icq)  		oscar_set_away_icq(ic, od, state, message); diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index fa36de39..3e844c55 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -196,13 +196,14 @@ 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; -	ic->away = NULL; +	away = NULL;  	if( state && msg && g_strcasecmp( state, msg ) != 0 )  	{  		yd->current_status = YAHOO_STATUS_CUSTOM; -		ic->away = ""; +		away = "";  	}  	else if( state )  	{ @@ -211,11 +212,11 @@ static void byahoo_set_away( struct im_connection *ic, char *state, char *msg )  		   away state. */  		msg = NULL; -		ic->away = ""; +		away = "";  		if( g_strcasecmp( state, "Available" ) == 0 )  		{  			yd->current_status = YAHOO_STATUS_AVAILABLE; -			ic->away = NULL; +			away = NULL;  		}  		else if( g_strcasecmp( state, "Be Right Back" ) == 0 )  			yd->current_status = YAHOO_STATUS_BRB; @@ -241,13 +242,13 @@ static void byahoo_set_away( struct im_connection *ic, char *state, char *msg )  		{  			yd->current_status = YAHOO_STATUS_AVAILABLE; -			ic->away = NULL; +			away = NULL;  		}  	}  	else  		yd->current_status = YAHOO_STATUS_AVAILABLE; -	yahoo_set_away( yd->y2_id, yd->current_status, msg, ic->away != NULL ? 2 : 0 ); +	yahoo_set_away( yd->y2_id, yd->current_status, msg, away != NULL ? 2 : 0 );  }  static GList *byahoo_away_states( struct im_connection *ic ) | 
