aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-03-14 18:22:43 +0000
committerWilmer van der Gaast <wilmer@gaast.net>2010-03-14 18:22:43 +0000
commit90cd6c4780c7e42a0b7caff5d3a2ba1e0bd3f308 (patch)
tree9df51cf89400399a68895badf429df1d127aa840
parentceebeb12e935e7a6fa72e1375e99d53cc91fcf45 (diff)
Allow disabling certain IM protocols at runtime, patch from
misc@mandriva.org, bug #381.
-rw-r--r--bitlbee.conf8
-rw-r--r--conf.c6
-rw-r--r--conf.h1
-rw-r--r--protocols/nogaim.c14
4 files changed, 28 insertions, 1 deletions
diff --git a/bitlbee.conf b/bitlbee.conf
index 4a3bbddf..c5dafd9f 100644
--- a/bitlbee.conf
+++ b/bitlbee.conf
@@ -119,6 +119,14 @@
## Proxy = socks4://socksproxy.localnet.com
## Proxy = socks5://socksproxy.localnet.com
+## Protocols offered by bitlbee
+##
+## As recompiling may be quite unpractical for some people, this option
+## allows to remove the support of protocol, even if compiled in. If
+## nothing is given, there are no restrictions.
+##
+## Protocols = jabber yahoo
+
[defaults]
diff --git a/conf.c b/conf.c
index c8cfaad8..b997fb0a 100644
--- a/conf.c
+++ b/conf.c
@@ -62,6 +62,7 @@ conf_t *conf_load( int argc, char *argv[] )
conf->ping_interval = 180;
conf->ping_timeout = 300;
conf->user = NULL;
+ conf->protocols = NULL;
proxytype = 0;
i = conf_loadini( conf, global.conf_file );
@@ -306,6 +307,11 @@ static int conf_loadini( conf_t *conf, char *file )
g_free( conf->user );
conf->user = g_strdup( ini->value );
}
+ else if( g_strcasecmp( ini->key, "protocols" ) == 0 )
+ {
+ g_strfreev( conf->protocols );
+ conf->protocols = g_strsplit_set( ini->value, " \t,;", -1 );
+ }
else
{
fprintf( stderr, "Error: Unknown setting `%s` in configuration file (line %d).\n", ini->key, ini->line );
diff --git a/conf.h b/conf.h
index c41fd096..b112681d 100644
--- a/conf.h
+++ b/conf.h
@@ -49,6 +49,7 @@ typedef struct conf
int ping_interval;
int ping_timeout;
char *user;
+ char **protocols;
} conf_t;
G_GNUC_MALLOC conf_t *conf_load( int argc, char *argv[] );
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index 75c2139b..9c6daeaf 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -97,7 +97,19 @@ GList *protocols = NULL;
void register_protocol (struct prpl *p)
{
- protocols = g_list_append(protocols, p);
+ int i;
+ gboolean refused = global.conf->protocols != NULL;
+
+ for (i = 0; global.conf->protocols && global.conf->protocols[i]; i++)
+ {
+ if (g_strcasecmp(p->name, global.conf->protocols[i]) == 0)
+ refused = FALSE;
+ }
+
+ if (refused)
+ log_message(LOGLVL_WARNING, "Protocol %s disabled\n", p->name);
+ else
+ protocols = g_list_append(protocols, p);
}
struct prpl *find_protocol(const char *name)