diff options
| -rw-r--r-- | protocols/nogaim.c | 25 | ||||
| -rw-r--r-- | protocols/nogaim.h | 1 | ||||
| -rw-r--r-- | root_commands.c | 6 | 
3 files changed, 20 insertions, 12 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() diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 668216b3..60f2898e 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -274,6 +274,7 @@ struct prpl {  void nogaim_init();  G_MODULE_EXPORT GSList *get_connections();  G_MODULE_EXPORT struct prpl *find_protocol(const char *name); +G_MODULE_EXPORT gboolean is_protocol_disabled(const char *name);  /* When registering a new protocol, you should allocate space for a new prpl   * struct, initialize it (set the function pointers to point to your   * functions), finally call this function. */ diff --git a/root_commands.c b/root_commands.c index b5d0aef1..e6ed1602 100644 --- a/root_commands.c +++ b/root_commands.c @@ -424,7 +424,11 @@ static void cmd_account(irc_t *irc, char **cmd)  		prpl = find_protocol(cmd[2]);  		if (prpl == NULL) { -			irc_rootmsg(irc, "Unknown protocol"); +			if (is_protocol_disabled(cmd[2])) { +				irc_rootmsg(irc, "Protocol disabled in global config"); +			} else { +				irc_rootmsg(irc, "Unknown protocol"); +			}  			return;  		} | 
