diff options
| -rw-r--r-- | protocols/purple/bpurple.h | 12 | ||||
| -rw-r--r-- | protocols/purple/ft-direct.c | 6 | ||||
| -rw-r--r-- | protocols/purple/ft.c | 6 | ||||
| -rw-r--r-- | protocols/purple/purple.c | 101 | 
4 files changed, 78 insertions, 47 deletions
| diff --git a/protocols/purple/bpurple.h b/protocols/purple/bpurple.h new file mode 100644 index 00000000..364aef49 --- /dev/null +++ b/protocols/purple/bpurple.h @@ -0,0 +1,12 @@ +#ifndef BPURPLE_H +# define BPURPLE_H + +#include <purple.h> +#include <glib.h> + +struct purple_data +{ +    PurpleAccount *account; +}; + +#endif /* !BPURPLE_H */ diff --git a/protocols/purple/ft-direct.c b/protocols/purple/ft-direct.c index 05201ac3..4bb10662 100644 --- a/protocols/purple/ft-direct.c +++ b/protocols/purple/ft-direct.c @@ -27,6 +27,7 @@     this code for now. */  #include "bitlbee.h" +#include "bpurple.h"  #include <stdarg.h> @@ -206,13 +207,14 @@ static gboolean prplcb_xfer_send_cb(gpointer data, gint fd, b_input_condition co  void purple_transfer_request(struct im_connection *ic, file_transfer_t *ft, char *handle)  { -	PurpleAccount *pa = ic->proto_data; +	struct purple_data *pd = ic->proto_data;  	struct prpl_xfer_data *px;  	/* xfer_new() will pick up this variable. It's a hack but we're not  	   multi-threaded anyway. */  	next_ft = ft; -	serv_send_file(purple_account_get_connection(pa), handle, ft->file_name); +	serv_send_file(purple_account_get_connection(pd->account), handle, +	               ft->file_name);  	ft->write = prpl_xfer_write; diff --git a/protocols/purple/ft.c b/protocols/purple/ft.c index 28f5d228..d1484054 100644 --- a/protocols/purple/ft.c +++ b/protocols/purple/ft.c @@ -27,6 +27,7 @@     varying levels of success). */  #include "bitlbee.h" +#include "bpurple.h"  #include <stdarg.h> @@ -284,12 +285,13 @@ void purple_transfer_request(struct im_connection *ic, file_transfer_t *ft, char  static void purple_transfer_forward(struct file_transfer *ft)  {  	struct prpl_xfer_data *px = ft->data; -	PurpleAccount *pa = px->ic->proto_data; +	struct purple_data *pd = px->ic->proto_data;  	/* xfer_new() will pick up this variable. It's a hack but we're not  	   multi-threaded anyway. */  	next_ft = ft; -	serv_send_file(purple_account_get_connection(pa), px->handle, px->fn); +	serv_send_file(purple_account_get_connection(pd->account), +                   px->handle, px->fn);  }  static gboolean purple_transfer_request_cb(gpointer data, gint fd, b_input_condition cond) diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c index d2b2bc67..0d830770 100644 --- a/protocols/purple/purple.c +++ b/protocols/purple/purple.c @@ -22,6 +22,7 @@  \***************************************************************************/  #include "bitlbee.h" +#include "bpurple.h"  #include "help.h"  #include <stdarg.h> @@ -41,9 +42,11 @@ static char *set_eval_display_name(set_t *set, char *value);  struct im_connection *purple_ic_by_pa(PurpleAccount *pa)  {  	GSList *i; +	struct purple_data *pd;  	for (i = purple_connections; i; i = i->next) { -		if (((struct im_connection *) i->data)->proto_data == pa) { +		pd = ((struct im_connection *) i->data)->proto_data; +		if (pd->account == pa) {  			return i->data;  		}  	} @@ -289,7 +292,7 @@ static void purple_sync_settings(account_t *acc, PurpleAccount *pa)  static void purple_login(account_t *acc)  {  	struct im_connection *ic = imcb_new(acc); -	PurpleAccount *pa; +	struct purple_data *pd;  	if ((local_bee != NULL && local_bee != acc->bee) ||  	    (global.conf->runmode == RUNMODE_DAEMON && !getenv("BITLBEE_DEBUG"))) { @@ -305,30 +308,33 @@ static void purple_login(account_t *acc)  	   on dead connections. */  	purple_connections = g_slist_prepend(purple_connections, ic); -	ic->proto_data = pa = purple_account_new(acc->user, (char *) acc->prpl->data); -	purple_account_set_password(pa, acc->pass); -	purple_sync_settings(acc, pa); +	ic->proto_data = pd = g_new0(struct purple_data, 1); +	pd->account = purple_account_new(acc->user, (char *) acc->prpl->data); +	purple_account_set_password(pd->account, acc->pass); +	purple_sync_settings(acc, pd->account); -	purple_account_set_enabled(pa, "BitlBee", TRUE); +	purple_account_set_enabled(pd->account, "BitlBee", TRUE);  }  static void purple_logout(struct im_connection *ic)  { -	PurpleAccount *pa = ic->proto_data; +	struct purple_data *pd = ic->proto_data; -	purple_account_set_enabled(pa, "BitlBee", FALSE); +	purple_account_set_enabled(pd->account, "BitlBee", FALSE);  	purple_connections = g_slist_remove(purple_connections, ic); -	purple_accounts_remove(pa); +	purple_accounts_remove(pd->account); +	g_free(pd);  }  static int purple_buddy_msg(struct im_connection *ic, char *who, char *message, int flags)  {  	PurpleConversation *conv; +	struct purple_data *pd = ic->proto_data;  	if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, -	                                                  who, ic->proto_data)) == NULL) { +	                                                  who, pd->account)) == NULL) {  		conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, -		                               ic->proto_data, who); +		                               pd->account, who);  	}  	purple_conv_im_send(purple_conversation_get_im_data(conv), message); @@ -338,10 +344,10 @@ static int purple_buddy_msg(struct im_connection *ic, char *who, char *message,  static GList *purple_away_states(struct im_connection *ic)  { -	PurpleAccount *pa = ic->proto_data; +	struct purple_data *pd = ic->proto_data;  	GList *st, *ret = NULL; -	for (st = purple_account_get_status_types(pa); st; st = st->next) { +	for (st = purple_account_get_status_types(pd->account); st; st = st->next) {  		PurpleStatusPrimitive prim = purple_status_type_get_primitive(st->data);  		if (prim != PURPLE_STATUS_AVAILABLE && prim != PURPLE_STATUS_OFFLINE) {  			ret = g_list_append(ret, (void *) purple_status_type_get_name(st->data)); @@ -353,8 +359,8 @@ static GList *purple_away_states(struct im_connection *ic)  static void purple_set_away(struct im_connection *ic, char *state_txt, char *message)  { -	PurpleAccount *pa = ic->proto_data; -	GList *status_types = purple_account_get_status_types(pa), *st; +	struct purple_data *pd = ic->proto_data; +	GList *status_types = purple_account_get_status_types(pd->account), *st;  	PurpleStatusType *pst = NULL;  	GList *args = NULL; @@ -377,7 +383,8 @@ static void purple_set_away(struct im_connection *ic, char *state_txt, char *mes  		args = g_list_append(args, message);  	} -	purple_account_set_status_list(pa, st ? purple_status_type_get_id(pst) : "away", +	purple_account_set_status_list(pd->account, +	                               st ? purple_status_type_get_id(pst) : "away",  	                               TRUE, args);  	g_list_free(args); @@ -446,67 +453,71 @@ static void purple_add_buddy(struct im_connection *ic, char *who, char *group)  {  	PurpleBuddy *pb;  	PurpleGroup *pg = NULL; +	struct purple_data *pd = ic->proto_data;  	if (group && !(pg = purple_find_group(group))) {  		pg = purple_group_new(group);  		purple_blist_add_group(pg, NULL);  	} -	pb = purple_buddy_new((PurpleAccount *) ic->proto_data, who, NULL); +	pb = purple_buddy_new(pd->account, who, NULL);  	purple_blist_add_buddy(pb, NULL, pg, NULL); -	purple_account_add_buddy((PurpleAccount *) ic->proto_data, pb); +	purple_account_add_buddy(pd->account, pb); -	purple_gg_buddylist_export(((PurpleAccount *) ic->proto_data)->gc); +	purple_gg_buddylist_export(pd->account->gc);  }  static void purple_remove_buddy(struct im_connection *ic, char *who, char *group)  {  	PurpleBuddy *pb; +	struct purple_data *pd = ic->proto_data; -	pb = purple_find_buddy((PurpleAccount *) ic->proto_data, who); +	pb = purple_find_buddy(pd->account, who);  	if (pb != NULL) {  		PurpleGroup *group;  		group = purple_buddy_get_group(pb); -		purple_account_remove_buddy((PurpleAccount *) ic->proto_data, pb, group); +		purple_account_remove_buddy(pd->account, pb, group);  		purple_blist_remove_buddy(pb);  	} -	purple_gg_buddylist_export(((PurpleAccount *) ic->proto_data)->gc); +	purple_gg_buddylist_export(pd->account->gc);  }  static void purple_add_permit(struct im_connection *ic, char *who)  { -	PurpleAccount *pa = ic->proto_data; +	struct purple_data *pd = ic->proto_data; -	purple_privacy_permit_add(pa, who, FALSE); +	purple_privacy_permit_add(pd->account, who, FALSE);  }  static void purple_add_deny(struct im_connection *ic, char *who)  { -	PurpleAccount *pa = ic->proto_data; +	struct purple_data *pd = ic->proto_data; -	purple_privacy_deny_add(pa, who, FALSE); +	purple_privacy_deny_add(pd->account, who, FALSE);  }  static void purple_rem_permit(struct im_connection *ic, char *who)  { -	PurpleAccount *pa = ic->proto_data; +	struct purple_data *pd = ic->proto_data; -	purple_privacy_permit_remove(pa, who, FALSE); +	purple_privacy_permit_remove(pd->account, who, FALSE);  }  static void purple_rem_deny(struct im_connection *ic, char *who)  { -	PurpleAccount *pa = ic->proto_data; +	struct purple_data *pd = ic->proto_data; -	purple_privacy_deny_remove(pa, who, FALSE); +	purple_privacy_deny_remove(pd->account, who, FALSE);  }  static void purple_get_info(struct im_connection *ic, char *who)  { -	serv_get_info(purple_account_get_connection(ic->proto_data), who); +	struct purple_data *pd = ic->proto_data; + +	serv_get_info(purple_account_get_connection(pd->account), who);  }  static void purple_keepalive(struct im_connection *ic) @@ -516,7 +527,7 @@ static void purple_keepalive(struct im_connection *ic)  static int purple_send_typing(struct im_connection *ic, char *who, int flags)  {  	PurpleTypingState state = PURPLE_NOT_TYPING; -	PurpleAccount *pa = ic->proto_data; +	struct purple_data *pd = ic->proto_data;  	if (flags & OPT_TYPING) {  		state = PURPLE_TYPING; @@ -524,7 +535,7 @@ static int purple_send_typing(struct im_connection *ic, char *who, int flags)  		state = PURPLE_TYPED;  	} -	serv_send_typing(purple_account_get_connection(pa), who, state); +	serv_send_typing(purple_account_get_connection(pd->account), who, state);  	return 1;  } @@ -558,10 +569,10 @@ struct groupchat *purple_chat_with(struct im_connection *ic, char *who)  	/* There went my nice afternoon. :-( */ -	PurpleAccount *pa = ic->proto_data; -	PurplePlugin *prpl = purple_plugins_find_with_id(pa->protocol_id); +	struct purple_data *pd = ic->proto_data; +	PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id);  	PurplePluginProtocolInfo *pi = prpl->info->extra_info; -	PurpleBuddy *pb = purple_find_buddy((PurpleAccount *) ic->proto_data, who); +	PurpleBuddy *pb = purple_find_buddy(pd->account, who);  	PurpleMenuAction *mi;  	GList *menu; @@ -596,8 +607,9 @@ void purple_chat_invite(struct groupchat *gc, char *who, char *message)  {  	PurpleConversation *pc = gc->data;  	PurpleConvChat *pcc = PURPLE_CONV_CHAT(pc); +	struct purple_data *pd = gc->ic->proto_data; -	serv_chat_invite(purple_account_get_connection(gc->ic->proto_data), +	serv_chat_invite(purple_account_get_connection(pd->account),  	                 purple_conv_chat_get_id(pcc),  	                 message && *message ? message : "Please join my chat",  	                 who); @@ -622,24 +634,27 @@ void purple_chat_leave(struct groupchat *gc)  struct groupchat *purple_chat_join(struct im_connection *ic, const char *room, const char *nick, const char *password,                                     set_t **sets)  { -	PurpleAccount *pa = ic->proto_data; -	PurplePlugin *prpl = purple_plugins_find_with_id(pa->protocol_id); +	struct purple_data *pd = ic->proto_data; +	PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id);  	PurplePluginProtocolInfo *pi = prpl->info->extra_info;  	GHashTable *chat_hash;  	PurpleConversation *conv;  	GList *info, *l;  	if (!pi->chat_info || !pi->chat_info_defaults || -	    !(info = pi->chat_info(purple_account_get_connection(pa)))) { +	    !(info = pi->chat_info(purple_account_get_connection(pd->account)))) {  		imcb_error(ic, "Joining chatrooms not supported by this protocol");  		return NULL;  	} -	if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, room, pa))) { +	if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, +	                                                  room, pd->account))) {  		purple_conversation_destroy(conv);  	} -	chat_hash = pi->chat_info_defaults(purple_account_get_connection(pa), room); +	chat_hash = pi->chat_info_defaults( +	        purple_account_get_connection(pd->account), room +	);  	for (l = info; l; l = l->next) {  		struct proto_chat_entry *pce = l->data; @@ -653,7 +668,7 @@ struct groupchat *purple_chat_join(struct im_connection *ic, const char *room, c  		}  	} -	serv_join_chat(purple_account_get_connection(pa), chat_hash); +	serv_join_chat(purple_account_get_connection(pd->account), chat_hash);  	return NULL;  } | 
