Changes in account.c [5b52a48:c99af3a]
Legend:
- Unmodified
- Added
- Removed
-
account.c
r5b52a48 rc99af3a 31 31 { 32 32 account_t *a; 33 set_t *s;34 33 35 34 if( irc->accounts ) 36 35 { 37 36 for( a = irc->accounts; a->next; a = a->next ); 38 a = a->next = g_new0 ( account_t, 1 );37 a = a->next = g_new0 ( account_t, 1 ); 39 38 } 40 39 else … … 46 45 a->user = g_strdup( user ); 47 46 a->pass = g_strdup( pass ); 48 a->auto_connect = 1;49 47 a->irc = irc; 50 48 51 s = set_add( &a->set, "auto_connect", "true", set_eval_account, a );52 s->flags |= ACC_SET_NOSAVE;53 54 s = set_add( &a->set, "password", NULL, set_eval_account, a );55 s->flags |= ACC_SET_NOSAVE;56 57 s = set_add( &a->set, "username", NULL, set_eval_account, a );58 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY;59 set_setstr( &a->set, "username", user );60 61 a->nicks = g_hash_table_new_full( g_str_hash, g_str_equal, g_free, g_free );62 63 /* This function adds some more settings (and might want to do more64 things that have to be done now, although I can't think of anything. */65 if( prpl->acc_init )66 prpl->acc_init( a );67 68 49 return( a ); 69 }70 71 char *set_eval_account( set_t *set, char *value )72 {73 account_t *acc = set->data;74 75 /* Double-check: We refuse to edit on-line accounts. */76 if( set->flags & ACC_SET_OFFLINE_ONLY && acc->gc )77 return NULL;78 79 if( strcmp( set->key, "username" ) == 0 )80 {81 g_free( acc->user );82 acc->user = g_strdup( value );83 return value;84 }85 else if( strcmp( set->key, "password" ) == 0 )86 {87 g_free( acc->pass );88 acc->pass = g_strdup( value );89 return NULL; /* password shouldn't be visible in plaintext! */90 }91 else if( strcmp( set->key, "server" ) == 0 )92 {93 g_free( acc->server );94 if( *value )95 acc->server = g_strdup( value );96 else97 acc->server = NULL;98 return value;99 }100 else if( strcmp( set->key, "auto_connect" ) == 0 )101 {102 if( !is_bool( value ) )103 return NULL;104 105 acc->auto_connect = bool2int( value );106 return value;107 }108 109 return NULL;110 50 } 111 51 … … 113 53 { 114 54 account_t *a, *ret = NULL; 115 char *handle, *s;116 55 int nr; 117 118 /* This checks if the id string ends with (...) */119 if( ( handle = strchr( id, '(' ) ) && ( s = strchr( handle, ')' ) ) && s[1] == 0 )120 {121 struct prpl *proto;122 123 *s = *handle = 0;124 handle ++;125 126 if( ( proto = find_protocol( id ) ) )127 {128 for( a = irc->accounts; a; a = a->next )129 if( a->prpl == proto &&130 a->prpl->handle_cmp( handle, a->user ) == 0 )131 ret = a;132 }133 134 /* Restore the string. */135 handle --;136 *handle = '(';137 *s = ')';138 139 if( ret )140 return ret;141 }142 56 143 57 if( sscanf( id, "%d", &nr ) == 1 && nr < 1000 ) … … 189 103 } 190 104 191 while( a->set )192 set_del( &a->set, a->set->key );193 194 g_hash_table_destroy( a->nicks );195 196 105 g_free( a->user ); 197 106 g_free( a->pass ); … … 207 116 void account_on( irc_t *irc, account_t *a ) 208 117 { 118 struct aim_user *u; 119 209 120 if( a->gc ) 210 121 { … … 215 126 cancel_auto_reconnect( a ); 216 127 128 u = g_new0 ( struct aim_user, 1 ); 129 u->irc = irc; 130 u->prpl = a->prpl; 131 strncpy( u->username, a->user, sizeof( u->username ) - 1 ); 132 strncpy( u->password, a->pass, sizeof( u->password ) - 1 ); 133 if( a->server) strncpy( u->proto_opt[0], a->server, sizeof( u->proto_opt[0] ) - 1 ); 134 135 a->gc = (struct gaim_connection *) u; /* Bit hackish :-/ */ 217 136 a->reconnect = 0; 218 a->prpl->login( a ); 137 138 a->prpl->login( u ); 219 139 } 220 140
Note: See TracChangeset
for help on using the changeset viewer.