From a312b6bcbc6aa836850d94fc2abc70ceffe275cd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 7 Jun 2006 13:25:46 +0200 Subject: Added storage_xml.c --- account.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'account.c') diff --git a/account.c b/account.c index 168d18c0..810f3a6f 100644 --- a/account.c +++ b/account.c @@ -34,7 +34,7 @@ account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) if( irc->accounts ) { for( a = irc->accounts; a->next; a = a->next ); - a = a->next = g_new0 ( account_t, 1 ); + a = a->next = g_new0( account_t, 1 ); } else { -- cgit v1.2.3 From 2b14eef99faf7e113cc6c17d68bf6402f87ddd66 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 21 Jun 2006 00:14:46 +0200 Subject: Implemented handling of autoconnect attribute. --- account.c | 1 + 1 file changed, 1 insertion(+) (limited to 'account.c') diff --git a/account.c b/account.c index 810f3a6f..b75afa51 100644 --- a/account.c +++ b/account.c @@ -44,6 +44,7 @@ account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) a->prpl = prpl; a->user = g_strdup( user ); a->pass = g_strdup( pass ); + a->auto_connect = 1; a->irc = irc; return( a ); -- cgit v1.2.3 From 0a3c243b6659dc10efb227e507f324c2711d6dcd Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 1 Jul 2006 01:18:56 +0200 Subject: Got rid of struct aim_user (now using account_t everywhere). Needs some more testing though. --- account.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'account.c') diff --git a/account.c b/account.c index b75afa51..ced62e25 100644 --- a/account.c +++ b/account.c @@ -142,8 +142,6 @@ void account_del( irc_t *irc, account_t *acc ) void account_on( irc_t *irc, account_t *a ) { - struct aim_user *u; - if( a->gc ) { /* Trying to enable an already-enabled account */ @@ -152,17 +150,8 @@ void account_on( irc_t *irc, account_t *a ) cancel_auto_reconnect( a ); - u = g_new0 ( struct aim_user, 1 ); - u->irc = irc; - u->prpl = a->prpl; - strncpy( u->username, a->user, sizeof( u->username ) - 1 ); - strncpy( u->password, a->pass, sizeof( u->password ) - 1 ); - if( a->server) strncpy( u->proto_opt[0], a->server, sizeof( u->proto_opt[0] ) - 1 ); - - a->gc = (struct gaim_connection *) u; /* Bit hackish :-/ */ a->reconnect = 0; - - a->prpl->login( u ); + a->prpl->login( a ); } void account_off( irc_t *irc, account_t *a ) -- cgit v1.2.3 From 5100caa16bb707d89f1873aca99b5f87abc1dd56 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 1 Jul 2006 17:52:05 +0200 Subject: Added "account set" command. --- account.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'account.c') diff --git a/account.c b/account.c index ced62e25..4e399e8a 100644 --- a/account.c +++ b/account.c @@ -27,9 +27,12 @@ #include "bitlbee.h" #include "account.h" +char *set_eval_account( set_t *set, char *value ); + account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) { account_t *a; + set_t *s; if( irc->accounts ) { @@ -47,9 +50,63 @@ account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) a->auto_connect = 1; a->irc = irc; + s = set_add( &a->set, "auto_connect", NULL, set_eval_account, a ); + s->flags |= ACC_SET_NOSAVE; + + s = set_add( &a->set, "password", NULL, set_eval_account, a ); + s->flags |= ACC_SET_NOSAVE; + + s = set_add( &a->set, "server", NULL, set_eval_account, a ); + s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; + + s = set_add( &a->set, "username", NULL, set_eval_account, a ); + s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; + set_setstr( &a->set, "username", user ); + return( a ); } +char *set_eval_account( set_t *set, char *value ) +{ + account_t *acc = set->data; + + /* Double-check: We refuse to edit on-line accounts. */ + if( acc->gc ) + return NULL; + + if( strcmp( set->key, "username" ) == 0 ) + { + g_free( acc->user ); + acc->user = g_strdup( value ); + return value; + } + else if( strcmp( set->key, "password" ) == 0 ) + { + g_free( acc->pass ); + acc->pass = g_strdup( value ); + return NULL; /* password shouldn't be visible in plaintext! */ + } + else if( strcmp( set->key, "server" ) == 0 ) + { + g_free( acc->server ); + if( *value ) + acc->server = g_strdup( value ); + else + acc->server = NULL; + return value; + } + else if( strcmp( set->key, "auto_connect" ) == 0 ) + { + if( !is_bool( value ) ) + return NULL; + + acc->auto_connect = bool2int( value ); + return value; + } + + return NULL; +} + account_t *account_get( irc_t *irc, char *id ) { account_t *a, *ret = NULL; @@ -129,6 +186,9 @@ void account_del( irc_t *irc, account_t *acc ) irc->accounts = a->next; } + while( a->set ) + set_del( &a->set, a->set->key ); + g_free( a->user ); g_free( a->pass ); if( a->server ) g_free( a->server ); -- cgit v1.2.3 From 96863f65118767e968469e82ba6b02006e36b81c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 2 Jul 2006 11:49:31 +0200 Subject: Added protocol-specific settings, made the server setting specific to only OSCAR and Jabber. --- account.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'account.c') diff --git a/account.c b/account.c index 186565dd..1f2ec165 100644 --- a/account.c +++ b/account.c @@ -27,8 +27,6 @@ #include "bitlbee.h" #include "account.h" -char *set_eval_account( set_t *set, char *value ); - account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) { account_t *a; @@ -50,19 +48,21 @@ account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) a->auto_connect = 1; a->irc = irc; - s = set_add( &a->set, "auto_connect", NULL, set_eval_account, a ); + s = set_add( &a->set, "auto_connect", "true", set_eval_account, a ); s->flags |= ACC_SET_NOSAVE; s = set_add( &a->set, "password", NULL, set_eval_account, a ); s->flags |= ACC_SET_NOSAVE; - s = set_add( &a->set, "server", NULL, set_eval_account, a ); - s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; - s = set_add( &a->set, "username", NULL, set_eval_account, a ); s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; set_setstr( &a->set, "username", user ); + /* This function adds some more settings (and might want to do more + things that have to be done now, although I can't think of anything. */ + if( prpl->acc_init ) + prpl->acc_init( a ); + return( a ); } -- cgit v1.2.3 From 5b52a4895e5a59ff6509f7771f4d8665737688c3 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 3 Jul 2006 23:22:45 +0200 Subject: Implemented per-account nick lists instead of per-protocol nick lists. nick_t is dead, instead nicks are just saves in a per-account_t GLib hash table. While doing this, the import_buddies command finally died and text_save() disappeared, because the old file format can't handle most of the new features in this branch anyway. Still have to implement support for the new nick lists in text_load()! --- account.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'account.c') diff --git a/account.c b/account.c index 1f2ec165..28c33d3b 100644 --- a/account.c +++ b/account.c @@ -58,6 +58,8 @@ account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; set_setstr( &a->set, "username", user ); + a->nicks = g_hash_table_new_full( g_str_hash, g_str_equal, g_free, g_free ); + /* This function adds some more settings (and might want to do more things that have to be done now, although I can't think of anything. */ if( prpl->acc_init ) @@ -125,7 +127,7 @@ account_t *account_get( irc_t *irc, char *id ) { for( a = irc->accounts; a; a = a->next ) if( a->prpl == proto && - a->prpl->cmp_buddynames( handle, a->user ) == 0 ) + a->prpl->handle_cmp( handle, a->user ) == 0 ) ret = a; } @@ -189,6 +191,8 @@ void account_del( irc_t *irc, account_t *acc ) while( a->set ) set_del( &a->set, a->set->key ); + g_hash_table_destroy( a->nicks ); + g_free( a->user ); g_free( a->pass ); if( a->server ) g_free( a->server ); -- cgit v1.2.3 From 00a52700d1dbab0736c7ace63c8be2f17b08b8f6 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 14 Jul 2006 20:24:59 +0200 Subject: Added a per-connection auto_reconnect setting. --- account.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'account.c') diff --git a/account.c b/account.c index 28c33d3b..86e35f76 100644 --- a/account.c +++ b/account.c @@ -51,6 +51,8 @@ account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) s = set_add( &a->set, "auto_connect", "true", set_eval_account, a ); s->flags |= ACC_SET_NOSAVE; + s = set_add( &a->set, "auto_reconnect", "true", set_eval_account, a ); + s = set_add( &a->set, "password", NULL, set_eval_account, a ); s->flags |= ACC_SET_NOSAVE; -- cgit v1.2.3 From 04026d44c29f2b7d64f81bb2d2d061a7d111662f Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 15 Jul 2006 19:26:13 +0200 Subject: Fixed a broken call to set_get() (CRASH), shut up a compiler warning in events_glib and now using the right evaluator for acc->"auto_reconnect". --- account.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'account.c') diff --git a/account.c b/account.c index 86e35f76..95aa9b7c 100644 --- a/account.c +++ b/account.c @@ -51,7 +51,7 @@ account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) s = set_add( &a->set, "auto_connect", "true", set_eval_account, a ); s->flags |= ACC_SET_NOSAVE; - s = set_add( &a->set, "auto_reconnect", "true", set_eval_account, a ); + s = set_add( &a->set, "auto_reconnect", "true", set_eval_bool, a ); s = set_add( &a->set, "password", NULL, set_eval_account, a ); s->flags |= ACC_SET_NOSAVE; -- cgit v1.2.3 From 0da65d5fb37691ed4d31f7ab4058732f1440db6b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 30 Mar 2007 22:40:45 -0700 Subject: s/gaim_connection/im_connection/ and some other minor API changes. The rest will come tomorrow. It compiles, I'll leave the real testing up to someone else. ;-) --- account.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'account.c') diff --git a/account.c b/account.c index 95aa9b7c..03d05586 100644 --- a/account.c +++ b/account.c @@ -64,8 +64,8 @@ account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass ) /* This function adds some more settings (and might want to do more things that have to be done now, although I can't think of anything. */ - if( prpl->acc_init ) - prpl->acc_init( a ); + if( prpl->init ) + prpl->init( a ); return( a ); } @@ -75,7 +75,7 @@ char *set_eval_account( set_t *set, char *value ) account_t *acc = set->data; /* Double-check: We refuse to edit on-line accounts. */ - if( set->flags & ACC_SET_OFFLINE_ONLY && acc->gc ) + if( set->flags & ACC_SET_OFFLINE_ONLY && acc->ic ) return NULL; if( strcmp( set->key, "username" ) == 0 ) @@ -179,7 +179,7 @@ void account_del( irc_t *irc, account_t *acc ) for( a = irc->accounts; a; a = (l=a)->next ) if( a == acc ) { - if( a->gc ) return; /* Caller should have checked, accounts still in use can't be deleted. */ + if( a->ic ) return; /* Caller should have checked, accounts still in use can't be deleted. */ if( l ) { @@ -208,7 +208,7 @@ void account_del( irc_t *irc, account_t *acc ) void account_on( irc_t *irc, account_t *a ) { - if( a->gc ) + if( a->ic ) { /* Trying to enable an already-enabled account */ return; @@ -222,9 +222,9 @@ void account_on( irc_t *irc, account_t *a ) void account_off( irc_t *irc, account_t *a ) { - a->gc->wants_to_die = TRUE; - signoff( a->gc ); - a->gc = NULL; + a->ic->wants_to_die = TRUE; + signoff( a->ic ); + a->ic = NULL; if( a->reconnect ) { /* Shouldn't happen */ -- cgit v1.2.3 From aef4828a1dc51de10a43bb7dd5d023de9971295b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 5 Apr 2007 22:20:31 -0700 Subject: More cleanups, mainly in the callbacks. Replaced things like do_error_dialog() and (set|hide)_login_progress(_error)?() with things that hopefully make more sense. Although it's still not really great... --- account.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'account.c') diff --git a/account.c b/account.c index 03d05586..9245a6e9 100644 --- a/account.c +++ b/account.c @@ -223,7 +223,7 @@ void account_on( irc_t *irc, account_t *a ) void account_off( irc_t *irc, account_t *a ) { a->ic->wants_to_die = TRUE; - signoff( a->ic ); + imc_logout( a->ic ); a->ic = NULL; if( a->reconnect ) { -- cgit v1.2.3 From c2fb38096ea4e75a680e57e103d4a4986aa84c75 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 15 Apr 2007 15:39:35 -0700 Subject: Cleaned up struct im_connection. No more username/password stuff since it's in acc too. wants_to_die is now an argument to imc_logout(). --- account.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'account.c') diff --git a/account.c b/account.c index 9245a6e9..1b0d7f26 100644 --- a/account.c +++ b/account.c @@ -222,8 +222,7 @@ void account_on( irc_t *irc, account_t *a ) void account_off( irc_t *irc, account_t *a ) { - a->ic->wants_to_die = TRUE; - imc_logout( a->ic ); + imc_logout( a->ic, TRUE ); a->ic = NULL; if( a->reconnect ) { -- cgit v1.2.3 From b0eaa5b5a0ab866791992f6f1d7f011d012d103d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 20 Apr 2007 20:23:39 -0700 Subject: No auto reconnect when the user does "account off" (in fact this auto reconnect gets cancelled immediately, but the message is confusing). --- account.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'account.c') diff --git a/account.c b/account.c index 1b0d7f26..388d04d0 100644 --- a/account.c +++ b/account.c @@ -222,7 +222,7 @@ void account_on( irc_t *irc, account_t *a ) void account_off( irc_t *irc, account_t *a ) { - imc_logout( a->ic, TRUE ); + imc_logout( a->ic, FALSE ); a->ic = NULL; if( a->reconnect ) { -- cgit v1.2.3 From 30ce1ced040c44c528d0a6e6e9c6b10a1caf1052 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 12 Dec 2007 23:30:51 +0000 Subject: Killed the parameter to "account add" and changed the default server for OSCAR to what both login.icq.com and login.oscar.aol.com resolve to these days. There's no need to specify a server anymore so why bother. And cleaned up the docs (removed all references to those OSCAR servers). --- account.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'account.c') diff --git a/account.c b/account.c index 388d04d0..4eb78faa 100644 --- a/account.c +++ b/account.c @@ -94,10 +94,15 @@ char *set_eval_account( set_t *set, char *value ) { g_free( acc->server ); if( *value ) + { acc->server = g_strdup( value ); + return value; + } else + { acc->server = NULL; - return value; + return g_strdup( set->def ); + } } else if( strcmp( set->key, "auto_connect" ) == 0 ) { -- cgit v1.2.3 From fa75134008bd9206ca02380927c27581feb65c3e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 2 Apr 2008 00:07:21 +0100 Subject: Reordered irc_free() a little bit, hoping that this will fix a crash-on-quit bug I can't figure out. The previous order wasn't optimal. --- account.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'account.c') diff --git a/account.c b/account.c index 4eb78faa..2c6e1069 100644 --- a/account.c +++ b/account.c @@ -181,19 +181,17 @@ void account_del( irc_t *irc, account_t *acc ) { account_t *a, *l = NULL; + if( acc->ic ) + /* Caller should have checked, accounts still in use can't be deleted. */ + return; + for( a = irc->accounts; a; a = (l=a)->next ) if( a == acc ) { - if( a->ic ) return; /* Caller should have checked, accounts still in use can't be deleted. */ - if( l ) - { l->next = a->next; - } else - { irc->accounts = a->next; - } while( a->set ) set_del( &a->set, a->set->key ); @@ -202,7 +200,7 @@ void account_del( irc_t *irc, account_t *acc ) g_free( a->user ); g_free( a->pass ); - if( a->server ) g_free( a->server ); + g_free( a->server ); if( a->reconnect ) /* This prevents any reconnect still queued to happen */ cancel_auto_reconnect( a ); g_free( a ); -- cgit v1.2.3