- Timestamp:
- 2010-07-24T15:46:59Z (14 years ago)
- Branches:
- master
- Children:
- e135cd09
- Parents:
- 7989d40d
- Location:
- protocols
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/account.c
r7989d40d r40e6dac 34 34 account_t *a; 35 35 set_t *s; 36 char tag[strlen(prpl->name)+10]; 36 37 37 38 if( bee->accounts ) … … 65 66 s->flags |= ACC_SET_NOSAVE | SET_NULL_OK; 66 67 68 s = set_add( &a->set, "tag", NULL, set_eval_account, a ); 69 67 70 s = set_add( &a->set, "username", NULL, set_eval_account, a ); 68 71 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 69 72 set_setstr( &a->set, "username", user ); 73 74 if( account_by_tag( bee, prpl->name ) ) 75 { 76 int i; 77 78 for( i = 2; i < 10000; i ++ ) 79 { 80 sprintf( tag, "%s%d", prpl->name, i ); 81 if( !account_by_tag( bee, tag ) ) 82 break; 83 } 84 } 85 else 86 { 87 strcpy( tag, prpl->name ); 88 } 89 set_setstr( &a->set, "tag", tag ); 70 90 71 91 a->nicks = g_hash_table_new_full( g_str_hash, g_str_equal, g_free, g_free ); … … 130 150 return SET_INVALID; 131 151 } 152 } 153 else if( strcmp( set->key, "tag" ) == 0 ) 154 { 155 account_t *oa; 156 157 /* Enforce uniqueness. */ 158 if( ( oa = account_by_tag( acc->bee, value ) ) && oa != acc ) 159 return SET_INVALID; 160 161 g_free( acc->tag ); 162 acc->tag = g_strdup( value ); 163 return value; 132 164 } 133 165 else if( strcmp( set->key, "auto_connect" ) == 0 ) … … 173 205 } 174 206 175 account_t *account_get( bee_t *bee, c har *id )207 account_t *account_get( bee_t *bee, const char *id ) 176 208 { 177 209 account_t *a, *ret = NULL; 178 210 char *handle, *s; 179 211 int nr; 212 213 /* Tags get priority above anything else. */ 214 if( ( a = account_by_tag( bee, id ) ) ) 215 return a; 180 216 181 217 /* This checks if the id string ends with (...) */ … … 232 268 233 269 return( ret ); 270 } 271 272 account_t *account_by_tag( bee_t *bee, const char *tag ) 273 { 274 account_t *a; 275 276 for( a = bee->accounts; a; a = a->next ) 277 if( a->tag && g_strcasecmp( tag, a->tag ) == 0 ) 278 return a; 279 280 return NULL; 234 281 } 235 282 … … 264 311 g_hash_table_destroy( a->nicks ); 265 312 313 g_free( a->tag ); 266 314 g_free( a->user ); 267 315 g_free( a->pass ); -
protocols/account.h
r7989d40d r40e6dac 33 33 char *pass; 34 34 char *server; 35 char *tag; 35 36 36 37 int auto_connect; … … 48 49 49 50 account_t *account_add( bee_t *bee, struct prpl *prpl, char *user, char *pass ); 50 account_t *account_get( bee_t *bee, char *id ); 51 account_t *account_get( bee_t *bee, const char *id ); 52 account_t *account_by_tag( bee_t *bee, const char *tag ); 51 53 void account_del( bee_t *bee, account_t *acc ); 52 54 void account_on( bee_t *bee, account_t *a );
Note: See TracChangeset
for help on using the changeset viewer.