aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2014-07-24 00:51:07 -0300
committerdequis <dx@dxzone.com.ar>2014-07-24 00:51:07 -0300
commit1783ab6964c9a8ffc3488bb5243f0b15858f4e74 (patch)
tree9f87690db5ada596a220b6abdf09bc87e3c05dc2
parent757515a793748591e8689167e153ea9ff26ff9e5 (diff)
Gadugadu local contact storage (ticket #917)
Patch originally by MichaƂ Siejak, adapted for 3.2.1
-rw-r--r--protocols/account.c26
-rw-r--r--protocols/account.h3
-rw-r--r--storage_xml.c7
3 files changed, 35 insertions, 1 deletions
diff --git a/protocols/account.c b/protocols/account.c
index b90a60ee..83c214b1 100644
--- a/protocols/account.c
+++ b/protocols/account.c
@@ -27,6 +27,10 @@
#include "bitlbee.h"
#include "account.h"
+static const char* account_protocols_local[] = {
+ "gg", NULL
+};
+
static char *set_eval_nick_source( set_t *set, char *value );
account_t *account_add( bee_t *bee, struct prpl *prpl, char *user, char *pass )
@@ -346,6 +350,9 @@ static gboolean account_on_timeout( gpointer d, gint fd, b_input_condition cond
void account_on( bee_t *bee, account_t *a )
{
+ GHashTableIter nicks;
+ gpointer k, v;
+
if( a->ic )
{
/* Trying to enable an already-enabled account */
@@ -359,6 +366,15 @@ void account_on( bee_t *bee, account_t *a )
if( a->ic && !( a->ic->flags & ( OPT_SLOW_LOGIN | OPT_LOGGED_IN ) ) )
a->ic->keepalive = b_timeout_add( 120000, account_on_timeout, a->ic );
+
+ if( a->flags & ACC_FLAG_LOCAL )
+ {
+ g_hash_table_iter_init(&nicks, a->nicks);
+ while( g_hash_table_iter_next( &nicks, &k, &v ) )
+ {
+ a->prpl->add_buddy( a->ic, (char*) k, NULL );
+ }
+ }
}
void account_off( bee_t *bee, account_t *a )
@@ -464,3 +480,13 @@ int account_reconnect_delay( account_t *a )
return a->auto_reconnect_delay;
}
+
+int protocol_account_islocal( const char* protocol )
+{
+ const char** p = account_protocols_local;
+ do {
+ if( strcmp( *p, protocol ) == 0 )
+ return 1;
+ } while( *( ++p ) );
+ return 0;
+}
diff --git a/protocols/account.h b/protocols/account.h
index ed3ca531..14633fad 100644
--- a/protocols/account.h
+++ b/protocols/account.h
@@ -58,6 +58,8 @@ char *set_eval_account( set_t *set, char *value );
char *set_eval_account_reconnect_delay( set_t *set, char *value );
int account_reconnect_delay( account_t *a );
+int protocol_account_islocal( const char* protocol );
+
typedef enum
{
ACC_SET_OFFLINE_ONLY = 0x02, /* Allow changes only if the acct is offline. */
@@ -69,6 +71,7 @@ typedef enum
ACC_FLAG_AWAY_MESSAGE = 0x01, /* Supports away messages instead of just states. */
ACC_FLAG_STATUS_MESSAGE = 0x02, /* Supports status messages (without being away). */
ACC_FLAG_HANDLE_DOMAINS = 0x04, /* Contact handles need a domain portion. */
+ ACC_FLAG_LOCAL = 0x08, /* Contact list is local. */
} account_flag_t;
#endif
diff --git a/storage_xml.c b/storage_xml.c
index d32ed25f..ddd09938 100644
--- a/storage_xml.c
+++ b/storage_xml.c
@@ -86,7 +86,7 @@ static xt_status handle_account( struct xt_node *node, gpointer data )
char *protocol, *handle, *server, *password = NULL, *autoconnect, *tag;
char *pass_b64 = NULL;
unsigned char *pass_cr = NULL;
- int pass_len;
+ int pass_len, local = 0;
struct prpl *prpl = NULL;
account_t *acc;
struct xt_node *c;
@@ -99,7 +99,10 @@ static xt_status handle_account( struct xt_node *node, gpointer data )
protocol = xt_find_attr( node, "protocol" );
if( protocol )
+ {
prpl = find_protocol( protocol );
+ local = protocol_account_islocal( protocol );
+ }
if( !handle || !pass_b64 || !protocol || !prpl )
return XT_ABORT;
@@ -113,6 +116,8 @@ static xt_status handle_account( struct xt_node *node, gpointer data )
set_setstr( &acc->set, "auto_connect", autoconnect );
if( tag )
set_setstr( &acc->set, "tag", tag );
+ if( local )
+ acc->flags |= ACC_FLAG_LOCAL;
}
else
return XT_ABORT;