diff options
author | dequis <dx@dxzone.com.ar> | 2015-11-23 18:20:34 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2015-11-23 18:20:34 -0300 |
commit | ad9ac5dccf8d27700850c02946ad3242a45d6fa9 (patch) | |
tree | b3596ac049c06c614644f9e4e592df94bbc6aae0 /protocols/nogaim.c | |
parent | 9c8dbc75d416c8867be20ccf3732303163e620ce (diff) |
Show a nicer message when a protocol is disabled in account add
This adds the disabled protocols' prpl structs to a different linked
list, only used for this lookup. They were previously marked as leaking
by valgrind, so, whatever. I can't free them, since some protocols
memdup() it after attempting to register.
I think disabling the protocols from bitlbee.conf is just stupid and
provides no real benefits, but someone will complain if i get rid of it.
So this just improves the error message to make it less confusing when
someone accidentally uncomments that crap.
Diffstat (limited to 'protocols/nogaim.c')
-rw-r--r-- | protocols/nogaim.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 9462a5d9..459a3913 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -89,6 +89,7 @@ void load_plugins(void) #endif GList *protocols = NULL; +GList *disabled_protocols = NULL; void register_protocol(struct prpl *p) { @@ -102,25 +103,27 @@ void register_protocol(struct prpl *p) } if (refused) { - log_message(LOGLVL_WARNING, "Protocol %s disabled\n", p->name); + disabled_protocols = g_list_append(disabled_protocols, p); } else { protocols = g_list_append(protocols, p); } } -struct prpl *find_protocol(const char *name) +static int proto_name_cmp(const void *proto_, const void *name) { - GList *gl; - - for (gl = protocols; gl; gl = gl->next) { - struct prpl *proto = gl->data; + const struct prpl *proto = proto_; + return g_strcasecmp(proto->name, name); +} - if (g_strcasecmp(proto->name, name) == 0) { - return proto; - } - } +struct prpl *find_protocol(const char *name) +{ + GList *gl = g_list_find_custom(protocols, name, proto_name_cmp); + return gl ? gl->data: NULL; +} - return NULL; +gboolean is_protocol_disabled(const char *name) +{ + return g_list_find_custom(disabled_protocols, name, proto_name_cmp) != NULL; } void nogaim_init() |