From ea902752503fc5b356d6513911081ec932d804f2 Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 13 Nov 2016 17:00:04 -0300 Subject: purple: fix file transfer memory management This means cancelling transfers on logout to avoid crashes, keeping track of timeouts, reffing and unreffing the xfers, listening to the callbacks from UI and purple more carefully and using the correct functions to free the correct things at the correct moments. Originally intended to fix a crash triggered when the dcc stall timeout kicks in after the account is offline, which is apparently very frequent with telegram (it sends file transfers while fetching history, and randomly disconnects a while later). Trying to fix that meant opening a can of worms, but after three days of work on this bug I'm pretty sure I've finished dealing with the resulting mess and tested all the typical edge cases. --- protocols/purple/purple.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'protocols/purple/purple.c') diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c index d476afba..4ee41d62 100644 --- a/protocols/purple/purple.c +++ b/protocols/purple/purple.c @@ -42,6 +42,8 @@ static char *set_eval_display_name(set_t *set, char *value); void purple_request_input_callback(guint id, struct im_connection *ic, const char *message, const char *who); +void purple_transfer_cancel_all(struct im_connection *ic); + /* purple_request_input specific stuff */ typedef void (*ri_callback_t)(gpointer, const gchar *); @@ -384,6 +386,10 @@ static void purple_logout(struct im_connection *ic) imcb_chat_free(ic->groupchats->data); } + if (pd->filetransfers) { + purple_transfer_cancel_all(ic); + } + purple_account_set_enabled(pd->account, "BitlBee", FALSE); purple_connections = g_slist_remove(purple_connections, ic); purple_accounts_remove(pd->account); -- cgit v1.2.3 From 9f03c472fef309878ff2f3bc720d51e6d03077f1 Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 13 Nov 2016 21:37:14 -0300 Subject: Improve support for protocols which don't require a password This adds a prpl_options_t enum with flags, which mostly just brings OPT_PROTO_{NO_PASSWORD,PASSWORD_OPTIONAL} from libpurple as PRPL_OPT_{NO_PASSWORD,PASSWORD_OPTIONAL} --- protocols/purple/purple.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'protocols/purple/purple.c') diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c index 4ee41d62..c7123798 100644 --- a/protocols/purple/purple.c +++ b/protocols/purple/purple.c @@ -1724,6 +1724,7 @@ void purple_initmodule() supported by this libpurple instance. */ for (prots = purple_plugins_get_protocols(); prots; prots = prots->next) { PurplePlugin *prot = prots->data; + PurplePluginProtocolInfo *pi = prot->info->extra_info; struct prpl *ret; /* If we already have this one (as a native module), don't @@ -1737,6 +1738,15 @@ void purple_initmodule() if (strncmp(ret->name, "prpl-", 5) == 0) { ret->name += 5; } + + if (pi->options & OPT_PROTO_NO_PASSWORD) { + ret->options |= PRPL_OPT_NO_PASSWORD; + } + + if (pi->options & OPT_PROTO_PASSWORD_OPTIONAL) { + ret->options |= PRPL_OPT_PASSWORD_OPTIONAL; + } + register_protocol(ret); g_string_append_printf(help, "\n* %s (%s)", ret->name, prot->info->name); -- cgit v1.2.3