comparison src/account.c @ 5643:eb685809108b

[gaim-migrate @ 6057] When a prpl couldn't load, the account's prpl ID got set to -1 and the account config file had to be manually editted. Now that's fixed, and it stores the ID on load and writes it on save. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 01 Jun 2003 21:36:40 +0000
parents c9724982ce45
children 6b3214ab8632
comparison
equal deleted inserted replaced
5642:1693a3027dc8 5643:eb685809108b
65 { 65 {
66 AccountParserTag tag; 66 AccountParserTag tag;
67 67
68 GaimAccount *account; 68 GaimAccount *account;
69 GaimProtocol protocol; 69 GaimProtocol protocol;
70 char *protocol_id;
70 71
71 GString *buffer; 72 GString *buffer;
72 73
73 GaimPrefType setting_type; 74 GaimPrefType setting_type;
74 char *setting_name; 75 char *setting_name;
132 g_return_if_fail(account != NULL); 133 g_return_if_fail(account != NULL);
133 134
134 if (account->gc != NULL) 135 if (account->gc != NULL)
135 gaim_connection_destroy(account->gc); 136 gaim_connection_destroy(account->gc);
136 137
137 if (account->username != NULL) g_free(account->username); 138 if (account->username != NULL) g_free(account->username);
138 if (account->alias != NULL) g_free(account->alias); 139 if (account->alias != NULL) g_free(account->alias);
139 if (account->password != NULL) g_free(account->password); 140 if (account->password != NULL) g_free(account->password);
140 if (account->user_info != NULL) g_free(account->user_info); 141 if (account->user_info != NULL) g_free(account->user_info);
142 if (account->protocol_id != NULL) g_free(account->protocol_id);
141 143
142 g_hash_table_destroy(account->settings); 144 g_hash_table_destroy(account->settings);
143 145
144 accounts = g_list_remove(accounts, account); 146 accounts = g_list_remove(accounts, account);
145 147
544 546
545 if (data->tag == TAG_PROTOCOL) { 547 if (data->tag == TAG_PROTOCOL) {
546 GList *l; 548 GList *l;
547 GaimPlugin *plugin; 549 GaimPlugin *plugin;
548 550
551 data->protocol_id = g_strdup(buffer);
549 data->protocol = -1; 552 data->protocol = -1;
550 553
551 for (l = gaim_plugins_get_protocols(); l != NULL; l = l->next) { 554 for (l = gaim_plugins_get_protocols(); l != NULL; l = l->next) {
552 plugin = (GaimPlugin *)l->data; 555 plugin = (GaimPlugin *)l->data;
553 556
559 break; 562 break;
560 } 563 }
561 } 564 }
562 } 565 }
563 } 566 }
564 else if (data->tag == TAG_NAME) 567 else if (data->tag == TAG_NAME) {
565 data->account = gaim_account_new(buffer, data->protocol); 568 data->account = gaim_account_new(buffer, data->protocol);
569 data->account->protocol_id = data->protocol_id;
570
571 data->protocol_id = NULL;
572 }
566 else if (data->tag == TAG_PASSWORD) { 573 else if (data->tag == TAG_PASSWORD) {
567 gaim_account_set_password(data->account, buffer); 574 gaim_account_set_password(data->account, buffer);
568 gaim_account_set_remember_password(data->account, TRUE); 575 gaim_account_set_remember_password(data->account, TRUE);
569 } 576 }
570 else if (data->tag == TAG_ALIAS) 577 else if (data->tag == TAG_ALIAS)
704 } 711 }
705 712
706 static void 713 static void
707 gaim_accounts_write(FILE *fp, GaimAccount *account) 714 gaim_accounts_write(FILE *fp, GaimAccount *account)
708 { 715 {
709 GaimPlugin *plugin;
710 const char *password, *alias, *user_info, *buddy_icon; 716 const char *password, *alias, *user_info, *buddy_icon;
711 char *esc; 717 char *esc;
712 718
713 plugin = gaim_find_prpl(gaim_account_get_protocol(account));
714
715 fprintf(fp, " <account>\n"); 719 fprintf(fp, " <account>\n");
716 fprintf(fp, " <protocol>%s</protocol>\n", 720 fprintf(fp, " <protocol>%s</protocol>\n", account->protocol_id);
717 (plugin != NULL && plugin->info != NULL && plugin->info->id != NULL
718 ? plugin->info->id : "unknown"));
719 esc = g_markup_escape_text(gaim_account_get_username(account), -1); 721 esc = g_markup_escape_text(gaim_account_get_username(account), -1);
720 fprintf(fp, " <name>%s</name>\n", esc); 722 fprintf(fp, " <name>%s</name>\n", esc);
721 g_free(esc); 723 g_free(esc);
722 724
723 if (gaim_account_get_remember_password(account) && 725 if (gaim_account_get_remember_password(account) &&