comparison src/account.c @ 9460:eae7e049d639

[gaim-migrate @ 10285] " This patch completely eliminates the use of the old numeric prpl identifiers. I've noticed that some plugins (both in gaim's cvs and external) continue to use the constants even though they are essentially no longer valid - code that relies on them being unique will fail - the new built-in prpls (SILC and novell) ,and any recent external prpls don't have numeric values. The once side effect that the removal causes is that the code for importing of the old .gaimrc and *.blist files is a little more kludgy (using magic numbers instead of the old constants). IMHO this isn't a big deal as the code will go away eventually anyway. **This patch also fixes the raw plugin so that i compiles once again. **Someone should make sure that the gaim-remote and raw plugins still work. (If the raw doesn't work, it may be unrelated as it hasn't been updated since the latest significant MSN changes - i just made a minor change to make it compile)" --Daniel Atallah (13:44:44) Me: what think you of getting rid of prpl numbers? (13:45:05) Sean: what do you mean? (13:45:27) Me: right now they are listed as deprecated, but still used in a few of our own plugins as well as in some 3rd party stuff (13:45:32) Me: and the enum still exists in the core (13:45:44) Me: and the newwer prpls such as novell don't use them (13:45:59) Me: datallah has submitted a patch to get rid of them entirely (13:46:31) Me: the only thing it would break would be the old blist import, which he hacked into working with magic numbers, but which i tend to think we could remove entirely anyway (13:50:03) Sean: Let's get rid of them, then. (13:50:10) Sean: and take out old .blist code too (13:50:14) Me: cool (13:52:37) Sean: we should get rid of .gaimrc code too, sometime. (13:53:02) Sean: If anyone's seriously just now upgrading from 0.59.x, or whatever, they deserve to lose their preferences. (12:27:56) LSchiere: Paco-Paco: what do you think of getting rid of the deprecated prpl numbers? (12:28:14) Paco-Paco: LSchiere: I think it shouldh ave happened long ago committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 06 Jul 2004 18:06:43 +0000
parents 2c6af2767fcf
children da88e2cd5c53
comparison
equal deleted inserted replaced
9459:dbeca8eca296 9460:eae7e049d639
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 }