comparison src/account.c @ 11982:54a3eae03182

[gaim-migrate @ 14275] This is a much better way to deal with people upgrading from oldstatus committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 05 Nov 2005 13:34:37 +0000
parents 717cbb3115bc
children 41d84ac57cb6
comparison
equal deleted inserted replaced
11981:053bb5ad040b 11982:54a3eae03182
676 GaimAccount *ret; 676 GaimAccount *ret;
677 xmlnode *child; 677 xmlnode *child;
678 char *protocol_id = NULL; 678 char *protocol_id = NULL;
679 char *name = NULL; 679 char *name = NULL;
680 char *data; 680 char *data;
681 gboolean upgrade = FALSE;
682 681
683 child = xmlnode_get_child(node, "protocol"); 682 child = xmlnode_get_child(node, "protocol");
684 if (child != NULL) 683 if (child != NULL)
685 protocol_id = xmlnode_get_data(child); 684 protocol_id = xmlnode_get_data(child);
686 685
727 /* Read the statuses */ 726 /* Read the statuses */
728 child = xmlnode_get_child(node, "statuses"); 727 child = xmlnode_get_child(node, "statuses");
729 if (child != NULL) 728 if (child != NULL)
730 { 729 {
731 parse_statuses(child, ret); 730 parse_statuses(child, ret);
732 } else {
733 upgrade = TRUE;
734 } 731 }
735 732
736 /* Read the userinfo */ 733 /* Read the userinfo */
737 child = xmlnode_get_child(node, "userinfo"); 734 child = xmlnode_get_child(node, "userinfo");
738 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) 735 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
761 if (child != NULL) 758 if (child != NULL)
762 { 759 {
763 parse_proxy_info(child, ret); 760 parse_proxy_info(child, ret);
764 } 761 }
765 762
766 if (upgrade && gaim_account_get_enabled(ret, gaim_core_get_ui())) {
767 gaim_presence_set_status_active(ret->presence, "available", TRUE);
768 }
769
770 return ret; 763 return ret;
771 } 764 }
772 765
773 static void 766 static void
774 load_accounts(void) 767 load_accounts(void)
812 gaim_account_new(const char *username, const char *protocol_id) 805 gaim_account_new(const char *username, const char *protocol_id)
813 { 806 {
814 GaimAccount *account = NULL; 807 GaimAccount *account = NULL;
815 GaimPlugin *prpl = NULL; 808 GaimPlugin *prpl = NULL;
816 GaimPluginProtocolInfo *prpl_info = NULL; 809 GaimPluginProtocolInfo *prpl_info = NULL;
810 GaimStatusType *status_type;
817 811
818 g_return_val_if_fail(username != NULL, NULL); 812 g_return_val_if_fail(username != NULL, NULL);
819 g_return_val_if_fail(protocol_id != NULL, NULL); 813 g_return_val_if_fail(protocol_id != NULL, NULL);
820 814
821 account = gaim_accounts_find(username, protocol_id); 815 account = gaim_accounts_find(username, protocol_id);
843 prpl = gaim_find_prpl(protocol_id); 837 prpl = gaim_find_prpl(protocol_id);
844 838
845 if (prpl == NULL) 839 if (prpl == NULL)
846 return account; 840 return account;
847 841
848 /* TODO: Should maybe use gaim_prpl_get_statuses()? */
849 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); 842 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
850 if (prpl_info != NULL && prpl_info->status_types != NULL) 843 if (prpl_info != NULL && prpl_info->status_types != NULL)
851 gaim_account_set_status_types(account, prpl_info->status_types(account)); 844 gaim_account_set_status_types(account, prpl_info->status_types(account));
852 845
853 gaim_presence_set_status_active(account->presence, "offline", TRUE); 846 status_type = gaim_account_get_status_type_with_primitive(account, GAIM_STATUS_AVAILABLE);
847 if (status_type != NULL)
848 gaim_presence_set_status_active(account->presence,
849 gaim_status_type_get_id(status_type),
850 TRUE);
851 else
852 gaim_presence_set_status_active(account->presence,
853 "offline",
854 TRUE);
854 855
855 return account; 856 return account;
856 } 857 }
857 858
858 void 859 void