Created
October 24, 2011 15:02
-
-
Save Nadrin/1309253 to your computer and use it in GitHub Desktop.
BitlBee libpurple local contact list patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== modified file 'protocols/account.c' | |
--- protocols/account.c 2010-11-21 19:34:59 +0000 | |
+++ protocols/account.c 2011-10-24 11:28:52 +0000 | |
@@ -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 ) | |
@@ -342,6 +346,9 @@ | |
void account_on( bee_t *bee, account_t *a ) | |
{ | |
+ GHashTableIter nicks; | |
+ gpointer k, v; | |
+ | |
if( a->ic ) | |
{ | |
/* Trying to enable an already-enabled account */ | |
@@ -355,6 +362,15 @@ | |
if( a->ic && !( a->ic->flags & OPT_SLOW_LOGIN ) ) | |
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 ) | |
@@ -457,3 +473,13 @@ | |
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; | |
+} | |
=== modified file 'protocols/account.h' | |
--- protocols/account.h 2010-08-23 23:12:24 +0000 | |
+++ protocols/account.h 2011-10-24 11:26:20 +0000 | |
@@ -58,6 +58,8 @@ | |
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_NOSAVE = 0x01, /* Don't save this setting (i.e. stored elsewhere). */ | |
@@ -69,6 +71,7 @@ | |
{ | |
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_LOCAL = 0x04, /* Contact list is local. */ | |
} account_flag_t; | |
#endif | |
=== modified file 'storage_xml.c' | |
--- storage_xml.c 2011-10-03 14:56:58 +0000 | |
+++ storage_xml.c 2011-10-24 11:31:59 +0000 | |
@@ -129,7 +129,7 @@ | |
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; | |
handle = xml_attr( attr_names, attr_values, "handle" ); | |
@@ -139,8 +139,11 @@ | |
tag = xml_attr( attr_names, attr_values, "tag" ); | |
protocol = xml_attr( attr_names, attr_values, "protocol" ); | |
- if( protocol ) | |
- prpl = find_protocol( protocol ); | |
+ if( protocol ) | |
+ { | |
+ prpl = find_protocol( protocol ); | |
+ local = protocol_account_islocal( protocol ); | |
+ } | |
if( !handle || !pass_b64 || !protocol ) | |
g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, | |
@@ -158,6 +161,8 @@ | |
set_setstr( &xd->current_account->set, "auto_connect", autoconnect ); | |
if( tag ) | |
set_setstr( &xd->current_account->set, "tag", tag ); | |
+ if( local ) | |
+ xd->current_account->flags |= ACC_FLAG_LOCAL; | |
} | |
else | |
{ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment