src/account.c

changeset 9460
7c1ab9155fe2
parent 9423
dcee2ab7399b
child 9619
2d8adb92f665
equal deleted inserted replaced
9459:72399a7d7e29 9460:7c1ab9155fe2
69 typedef struct 69 typedef struct
70 { 70 {
71 AccountParserTag tag; 71 AccountParserTag tag;
72 72
73 GaimAccount *account; 73 GaimAccount *account;
74 GaimProtocol protocol;
75 GaimProxyInfo *proxy_info; 74 GaimProxyInfo *proxy_info;
76 char *protocol_id; 75 char *protocol_id;
77 76
78 GString *buffer; 77 GString *buffer;
79 78
448 447
449 schedule_accounts_save(); 448 schedule_accounts_save();
450 } 449 }
451 450
452 void 451 void
453 gaim_account_set_protocol(GaimAccount *account, GaimProtocol protocol)
454 {
455 g_return_if_fail(account != NULL);
456
457 gaim_account_set_protocol_id(account, gaim_prpl_num_to_id(protocol));
458 }
459
460 void
461 gaim_account_set_protocol_id(GaimAccount *account, const char *protocol_id) 452 gaim_account_set_protocol_id(GaimAccount *account, const char *protocol_id)
462 { 453 {
463 g_return_if_fail(account != NULL); 454 g_return_if_fail(account != NULL);
464 g_return_if_fail(protocol_id != NULL); 455 g_return_if_fail(protocol_id != NULL);
465 456
724 gaim_account_get_buddy_icon(const GaimAccount *account) 715 gaim_account_get_buddy_icon(const GaimAccount *account)
725 { 716 {
726 g_return_val_if_fail(account != NULL, NULL); 717 g_return_val_if_fail(account != NULL, NULL);
727 718
728 return account->buddy_icon; 719 return account->buddy_icon;
729 }
730
731 GaimProtocol
732 gaim_account_get_protocol(const GaimAccount *account)
733 {
734 g_return_val_if_fail(account != NULL, -1);
735
736 return gaim_prpl_id_to_num(gaim_account_get_protocol_id(account));
737 } 720 }
738 721
739 const char * 722 const char *
740 gaim_account_get_protocol_id(const GaimAccount *account) 723 gaim_account_get_protocol_id(const GaimAccount *account)
741 { 724 {
1541 gaim_accounts_get_all(void) 1524 gaim_accounts_get_all(void)
1542 { 1525 {
1543 return accounts; 1526 return accounts;
1544 } 1527 }
1545 1528
1546 static GaimAccount * 1529 GaimAccount *
1547 gaim_accounts_find_with_prpl_num(const char *name, GaimProtocol protocol) 1530 gaim_accounts_find(const char *name, const char *protocol_id)
1548 { 1531 {
1549 GaimAccount *account = NULL; 1532 GaimAccount *account = NULL;
1550 GList *l; 1533 GList *l;
1551 char *who; 1534 char *who;
1552 1535
1555 who = g_strdup(gaim_normalize(NULL, name)); 1538 who = g_strdup(gaim_normalize(NULL, name));
1556 1539
1557 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { 1540 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
1558 account = (GaimAccount *)l->data; 1541 account = (GaimAccount *)l->data;
1559 1542
1560 if (!strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who)) {
1561 if (protocol != -1) {
1562 if (gaim_account_get_protocol(account) == protocol)
1563 break;
1564 }
1565 else
1566 break;
1567 }
1568
1569 account = NULL;
1570 }
1571
1572 g_free(who);
1573
1574 return account;
1575 }
1576
1577 GaimAccount *
1578 gaim_accounts_find(const char *name, const char *protocol_id)
1579 {
1580 GaimAccount *account = NULL;
1581 GList *l;
1582 char *who;
1583
1584 g_return_val_if_fail(name != NULL, NULL);
1585
1586 who = g_strdup(gaim_normalize(NULL, name));
1587
1588 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
1589 account = (GaimAccount *)l->data;
1590
1591 if (!strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who) && 1543 if (!strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who) &&
1592 (!protocol_id || !strcmp(account->protocol_id, protocol_id))) { 1544 (!protocol_id || !strcmp(account->protocol_id, protocol_id))) {
1593 1545
1594 break; 1546 break;
1595 } 1547 }
1596 1548
1597 account = NULL; 1549 account = NULL;
1598 } 1550 }
1599
1600 if(!account && protocol_id)
1601 account = gaim_accounts_find_with_prpl_num(name, atoi(protocol_id));
1602 1551
1603 g_free(who); 1552 g_free(who);
1604 1553
1605 return account; 1554 return account;
1606 } 1555 }

mercurial