diff options
Diffstat (limited to 'protocols')
| -rw-r--r-- | protocols/jabber/conference.c | 4 | ||||
| -rw-r--r-- | protocols/jabber/jabber.c | 2 | ||||
| -rw-r--r-- | protocols/jabber/jabber.h | 2 | ||||
| -rw-r--r-- | protocols/jabber/presence.c | 10 | ||||
| -rw-r--r-- | protocols/nogaim.c | 16 | ||||
| -rw-r--r-- | protocols/nogaim.h | 6 | ||||
| -rw-r--r-- | protocols/oscar/oscar.c | 70 | ||||
| -rw-r--r-- | protocols/yahoo/yahoo.c | 30 | 
8 files changed, 97 insertions, 43 deletions
| diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c index 79fdd053..480006bd 100644 --- a/protocols/jabber/conference.c +++ b/protocols/jabber/conference.c @@ -25,7 +25,7 @@  static xt_status jabber_chat_join_failed( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); -struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password ) +struct groupchat *jabber_chat_join( struct im_connection *ic, const char *room, const char *nick, const char *password )  {  	struct jabber_chat *jc;  	struct xt_node *node; @@ -35,9 +35,9 @@ struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *  	roomjid = g_strdup_printf( "%s/%s", room, nick );  	node = xt_new_node( "x", NULL, NULL );  	xt_add_attr( node, "xmlns", XMLNS_MUC ); -	node = jabber_make_packet( "presence", NULL, roomjid, node );  	if( password )  		xt_add_child( node, xt_new_node( "password", password, NULL ) ); +	node = jabber_make_packet( "presence", NULL, roomjid, node );  	jabber_cache_add( ic, node, jabber_chat_join_failed );  	if( !jabber_write_packet( ic, node ) ) diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 518c9506..6f7e1c05 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -424,7 +424,7 @@ static void jabber_remove_buddy( struct im_connection *ic, char *who, char *grou  		presence_send_request( ic, who, "unsubscribe" );  } -static struct groupchat *jabber_chat_join_( struct im_connection *ic, char *room, char *nick, char *password ) +static struct groupchat *jabber_chat_join_( struct im_connection *ic, const char *room, const char *nick, const char *password )  {  	if( strchr( room, '@' ) == NULL )  		imcb_error( ic, "Invalid room name: %s", room ); diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 904bf0c4..ee453144 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -239,7 +239,7 @@ xt_status sasl_pkt_result( struct xt_node *node, gpointer data );  gboolean sasl_supported( struct im_connection *ic );  /* conference.c */ -struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password ); +struct groupchat *jabber_chat_join( struct im_connection *ic, const char *room, const char *nick, const char *password );  struct groupchat *jabber_chat_by_jid( struct im_connection *ic, const char *name );  void jabber_chat_free( struct groupchat *c );  int jabber_chat_msg( struct groupchat *ic, char *message, int flags ); diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c index 6fc360b7..939bc888 100644 --- a/protocols/jabber/presence.c +++ b/protocols/jabber/presence.c @@ -48,8 +48,9 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )  	{  		if( !( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) )  		{ -			if( set_getbool( &ic->irc->set, "debug" ) ) -				imcb_log( ic, "Warning: Could not handle presence information from JID: %s", from ); +			/* +			imcb_log( ic, "Warning: Could not handle presence information from JID: %s", from ); +			*/  			return XT_HANDLED;  		} @@ -105,8 +106,9 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )  	{  		if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) == NULL )  		{ -			if( set_getbool( &ic->irc->set, "debug" ) ) -				imcb_log( ic, "Warning: Received presence information from unknown JID: %s", from ); +			/* +			imcb_log( ic, "Warning: Received presence information from unknown JID: %s", from ); +			*/  			return XT_HANDLED;  		} diff --git a/protocols/nogaim.c b/protocols/nogaim.c index e6a89dfd..9dbf71ab 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -248,6 +248,8 @@ static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond )  void imcb_connected( struct im_connection *ic )  { +	irc_t *irc = ic->irc; +	struct chat *c;  	user_t *u;  	/* MSN servers sometimes redirect you to a different server and do @@ -270,6 +272,15 @@ void imcb_connected( struct im_connection *ic )  	/* Apparently we're connected successfully, so reset the  	   exponential backoff timer. */  	ic->acc->auto_reconnect_delay = 0; +	 +	for( c = irc->chatrooms; c; c = c->next ) +	{ +		if( c->acc != ic->acc ) +			continue; +		 +		if( set_getbool( &c->set, "auto_join" ) ) +			chat_join( irc, c, NULL ); +	}  }  gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ) @@ -309,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 )  	{ @@ -715,7 +729,7 @@ void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags )  	}  } -struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ) +struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle )  {  	struct groupchat *c; diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 7e14c560..83091c02 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -212,7 +212,7 @@ struct prpl {  	 * your protocol does not support publicly named group chats, then do  	 * not implement this. */  	struct groupchat * -	     (* chat_join)	(struct im_connection *, char *room, char *nick, char *password); +	     (* chat_join)	(struct im_connection *, const char *room, const char *nick, const char *password);  	/* Change the topic, if supported. Note that BitlBee expects the IM  	   server to confirm the topic change with a regular topic change  	   event. If it doesn't do that, you have to fake it to make it @@ -242,7 +242,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 ); @@ -293,7 +293,7 @@ G_MODULE_EXPORT void imcb_chat_invited( struct im_connection *ic, char *handle,   * - After you have a groupchat pointer, you should add the handles, finally   *   the user her/himself. At that point the group chat will be visible to the   *   user, too. */ -G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ); +G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle );  G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, char *handle );  /* To remove a handle from a group chat. Reason can be NULL. */  G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ); diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 28207103..bb9734c8 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -90,7 +90,7 @@ struct oscar_data {  	GSList *oscar_chats; -	gboolean killme; +	gboolean killme, no_reconnect;  	gboolean icq;  	GSList *evilhack; @@ -180,6 +180,7 @@ static struct chat_connection *find_oscar_chat_by_conn(struct im_connection *ic,  static int gaim_parse_auth_resp  (aim_session_t *, aim_frame_t *, ...);  static int gaim_parse_login      (aim_session_t *, aim_frame_t *, ...); +static int gaim_parse_logout     (aim_session_t *, aim_frame_t *, ...);  static int gaim_handle_redirect  (aim_session_t *, aim_frame_t *, ...);  static int gaim_parse_oncoming   (aim_session_t *, aim_frame_t *, ...);  static int gaim_parse_offgoing   (aim_session_t *, aim_frame_t *, ...); @@ -293,7 +294,7 @@ static gboolean oscar_callback(gpointer data, gint source,  		if (aim_get_command(odata->sess, conn) >= 0) {  			aim_rxdispatch(odata->sess);                                 if (odata->killme) -                                       imc_logout(ic, TRUE); +                                       imc_logout(ic, !odata->no_reconnect);  		} else {  			if ((conn->type == AIM_CONN_TYPE_BOS) ||  				   !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { @@ -519,6 +520,7 @@ static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) {  			break;  		case 0x18:  			/* connecting too frequently */ +			od->no_reconnect = TRUE;  			imcb_error(ic, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."));  			break;  		case 0x1c: @@ -571,6 +573,7 @@ static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) {  	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0);  	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parseaiminfo, 0);  	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parsemtn, 0); +	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_parse_logout, 0);  	((struct oscar_data *)ic->proto_data)->conn = bosconn;  	for (i = 0; i < (int)strlen(info->bosip); i++) { @@ -750,6 +753,30 @@ static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) {  	return 1;  } +static int gaim_parse_logout(aim_session_t *sess, aim_frame_t *fr, ...) { +	struct im_connection *ic = sess->aux_data; +	struct oscar_data *odata = ic->proto_data; +	int code; +	va_list ap; + +	va_start(ap, fr); +	code = va_arg(ap, int); +	va_end(ap); +	 +	imcb_error( ic, "Connection aborted by server: %s", code == 1 ? +	                "someone else logged in with your account" : +	                "unknown reason" ); +	 +	/* Tell BitlBee to disable auto_reconnect if code == 1, since that +	   means a concurrent login somewhere else. */ +	odata->no_reconnect = code == 1; +	 +	/* DO NOT log out here! Just tell the callback to do it. */ +	odata->killme = TRUE; + +	return 1; +} +  static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) {  	struct im_connection *ic = sess->aux_data;  	struct chat_connection *chatcon; @@ -1938,8 +1965,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 +1985,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 +2043,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); @@ -2580,7 +2604,7 @@ void oscar_chat_leave(struct groupchat *c)  	oscar_chat_kill(c->ic, c->data);  } -struct groupchat *oscar_chat_join(struct im_connection * ic, char * room, char * nick, char * password ) +struct groupchat *oscar_chat_join(struct im_connection * ic, const char * room, const char * nick, const char * password )  {  	struct oscar_data * od = (struct oscar_data *)ic->proto_data;  	aim_conn_t * cur; diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 8feb6639..5aa5033c 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 ) @@ -790,9 +791,22 @@ int ext_yahoo_connect(const char *host, int port)  static void byahoo_accept_conf( void *data )  {  	struct byahoo_conf_invitation *inv = data; +	struct groupchat *b; +	 +	for( b = inv->ic->groupchats; b; b = b->next ) +		if( b == inv->c ) +			break; +	 +	if( b != NULL ) +	{ +		yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name ); +		imcb_chat_add_buddy( inv->c, inv->ic->acc->user ); +	} +	else +	{ +		imcb_log( inv->ic, "Duplicate/corrupted invitation to `%s'.", inv->name ); +	} -	yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name ); -	imcb_chat_add_buddy( inv->c, inv->ic->acc->user );  	g_free( inv->name );  	g_free( inv );  } | 
