Mercurial > pidgin
annotate src/account.c @ 10828:9cf14a87eedc
[gaim-migrate @ 12494]
La di da di
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Sat, 16 Apr 2005 16:05:40 +0000 |
| parents | d83f745c997b |
| children | 885377f484b7 |
| rev | line source |
|---|---|
|
5865
412c5a0f9ef1
[gaim-migrate @ 6296]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
1 /** |
| 5563 | 2 * @file account.c Account API |
| 3 * @ingroup core | |
| 4 * | |
| 5 * gaim | |
| 6 * | |
| 8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
| 8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 9 * source distribution. | |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
10 * |
| 5563 | 11 * This program is free software; you can redistribute it and/or modify |
| 12 * it under the terms of the GNU General Public License as published by | |
| 13 * the Free Software Foundation; either version 2 of the License, or | |
| 14 * (at your option) any later version. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU General Public License | |
| 22 * along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 */ | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5870
diff
changeset
|
25 #include "internal.h" |
| 5563 | 26 #include "account.h" |
| 5717 | 27 #include "debug.h" |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
28 #include "notify.h" |
| 8235 | 29 #include "pounce.h" |
| 5563 | 30 #include "prefs.h" |
|
5665
132a30783c3d
[gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents:
5659
diff
changeset
|
31 #include "prpl.h" |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
32 #include "request.h" |
| 9944 | 33 #include "server.h" |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
34 #include "signals.h" |
| 9944 | 35 #include "status.h" |
| 5717 | 36 #include "util.h" |
| 10423 | 37 #include "xmlnode.h" |
| 5563 | 38 |
| 10429 | 39 /* TODO: Should use GaimValue instead of this? What about "ui"? */ |
| 5563 | 40 typedef struct |
| 41 { | |
| 42 GaimPrefType type; | |
| 43 | |
|
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
44 char *ui; |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
45 |
| 5563 | 46 union |
| 47 { | |
| 48 int integer; | |
| 49 char *string; | |
| 50 gboolean bool; | |
| 51 | |
| 52 } value; | |
| 53 | |
| 54 } GaimAccountSetting; | |
| 55 | |
|
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
56 |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
57 static GaimAccountUiOps *account_ui_ops = NULL; |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
58 |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
59 static GList *accounts = NULL; |
| 10428 | 60 static guint save_timer = 0; |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
61 static gboolean accounts_loaded = FALSE; |
| 5563 | 62 |
| 10427 | 63 |
| 10428 | 64 /********************************************************************* |
| 10429 | 65 * Writing to disk * |
| 10428 | 66 *********************************************************************/ |
| 10427 | 67 |
| 68 static void | |
| 69 setting_to_xmlnode(gpointer key, gpointer value, gpointer user_data) | |
| 70 { | |
| 71 const char *name; | |
| 72 GaimAccountSetting *setting; | |
| 73 xmlnode *node, *child; | |
| 74 char buf[20]; | |
| 75 | |
| 76 name = (const char *)key; | |
| 77 setting = (GaimAccountSetting *)value; | |
| 78 node = (xmlnode *)user_data; | |
| 79 | |
| 80 child = xmlnode_new_child(node, "setting"); | |
| 81 xmlnode_set_attrib(child, "name", name); | |
| 82 | |
| 83 if (setting->type == GAIM_PREF_INT) { | |
| 84 xmlnode_set_attrib(child, "type", "int"); | |
| 85 snprintf(buf, sizeof(buf), "%d", setting->value.integer); | |
| 86 xmlnode_insert_data(child, buf, -1); | |
| 87 } | |
| 88 else if (setting->type == GAIM_PREF_STRING && setting->value.string != NULL) { | |
| 89 xmlnode_set_attrib(child, "type", "string"); | |
| 90 xmlnode_insert_data(child, setting->value.string, -1); | |
| 91 } | |
| 92 else if (setting->type == GAIM_PREF_BOOLEAN) { | |
| 93 xmlnode_set_attrib(child, "type", "bool"); | |
| 94 snprintf(buf, sizeof(buf), "%d", setting->value.bool); | |
| 95 xmlnode_insert_data(child, buf, -1); | |
| 96 } | |
| 97 } | |
| 98 | |
| 99 static void | |
| 100 ui_setting_to_xmlnode(gpointer key, gpointer value, gpointer user_data) | |
| 101 { | |
| 102 const char *ui; | |
| 103 GHashTable *table; | |
| 104 xmlnode *node, *child; | |
| 105 | |
| 106 ui = (const char *)key; | |
| 107 table = (GHashTable *)value; | |
| 108 node = (xmlnode *)user_data; | |
| 109 | |
| 110 if (g_hash_table_size(table) > 0) | |
| 111 { | |
| 112 child = xmlnode_new_child(node, "settings"); | |
| 113 xmlnode_set_attrib(child, "ui", ui); | |
| 114 g_hash_table_foreach(table, setting_to_xmlnode, child); | |
| 115 } | |
| 116 } | |
| 117 | |
| 118 static xmlnode * | |
| 10738 | 119 status_to_xmlnode(const GaimStatus *status) |
| 120 { | |
| 121 xmlnode *node; | |
| 122 | |
| 123 node = xmlnode_new("status"); | |
| 124 xmlnode_set_attrib(node, "type", gaim_status_get_id(status)); | |
| 125 if (gaim_status_get_name(status) != NULL) | |
| 126 xmlnode_set_attrib(node, "name", gaim_status_get_name(status)); | |
| 127 xmlnode_set_attrib(node, "active", gaim_status_is_active(status) ? "true" : "false"); | |
| 128 | |
| 129 /* QQQ: Need to save status->attr_values */ | |
| 130 | |
| 131 return node; | |
| 132 } | |
| 133 | |
| 134 static xmlnode * | |
| 135 statuses_to_xmlnode(const GaimPresence *presence) | |
| 136 { | |
| 137 xmlnode *node, *child; | |
| 138 const GList *statuses, *status; | |
| 139 | |
| 140 node = xmlnode_new("statuses"); | |
| 141 | |
| 142 statuses = gaim_presence_get_statuses(presence); | |
| 143 for (status = statuses; status != NULL; status = status->next) | |
| 144 { | |
| 145 child = status_to_xmlnode((GaimStatus *)status->data); | |
| 146 xmlnode_insert_child(node, child); | |
| 147 } | |
| 148 | |
| 149 return node; | |
| 150 } | |
| 151 | |
| 152 static xmlnode * | |
| 10427 | 153 proxy_settings_to_xmlnode(GaimProxyInfo *proxy_info) |
| 154 { | |
| 155 xmlnode *node, *child; | |
| 156 GaimProxyType proxy_type; | |
| 157 const char *value; | |
| 158 int int_value; | |
| 159 char buf[20]; | |
| 160 | |
| 161 proxy_type = gaim_proxy_info_get_type(proxy_info); | |
| 162 | |
| 163 node = xmlnode_new("proxy"); | |
| 164 | |
| 165 child = xmlnode_new_child(node, "type"); | |
| 166 xmlnode_insert_data(child, | |
| 167 (proxy_type == GAIM_PROXY_USE_GLOBAL ? "global" : | |
| 168 proxy_type == GAIM_PROXY_NONE ? "none" : | |
| 169 proxy_type == GAIM_PROXY_HTTP ? "http" : | |
| 170 proxy_type == GAIM_PROXY_SOCKS4 ? "socks4" : | |
| 171 proxy_type == GAIM_PROXY_SOCKS5 ? "socks5" : | |
| 172 proxy_type == GAIM_PROXY_USE_ENVVAR ? "envvar" : "unknown"), -1); | |
| 173 | |
| 174 if (proxy_type != GAIM_PROXY_USE_GLOBAL && | |
| 175 proxy_type != GAIM_PROXY_NONE && | |
| 176 proxy_type != GAIM_PROXY_USE_ENVVAR) | |
| 177 { | |
| 178 if ((value = gaim_proxy_info_get_host(proxy_info)) != NULL) | |
| 179 { | |
| 180 child = xmlnode_new_child(node, "host"); | |
| 181 xmlnode_insert_data(child, value, -1); | |
| 182 } | |
| 183 | |
| 184 if ((int_value = gaim_proxy_info_get_port(proxy_info)) != 0) | |
| 185 { | |
| 186 snprintf(buf, sizeof(buf), "%d", int_value); | |
| 187 child = xmlnode_new_child(node, "port"); | |
| 188 xmlnode_insert_data(child, buf, -1); | |
| 189 } | |
| 190 | |
| 191 if ((value = gaim_proxy_info_get_username(proxy_info)) != NULL) | |
| 192 { | |
| 193 child = xmlnode_new_child(node, "username"); | |
| 194 xmlnode_insert_data(child, value, -1); | |
| 195 } | |
| 196 | |
| 197 if ((value = gaim_proxy_info_get_password(proxy_info)) != NULL) | |
| 198 { | |
| 199 child = xmlnode_new_child(node, "password"); | |
| 200 xmlnode_insert_data(child, value, -1); | |
| 201 } | |
| 202 } | |
| 203 | |
| 204 return node; | |
| 205 } | |
| 206 | |
| 207 static xmlnode * | |
| 208 account_to_xmlnode(GaimAccount *account) | |
| 209 { | |
| 210 xmlnode *node, *child; | |
| 211 const char *tmp; | |
| 10738 | 212 GaimPresence *presence; |
| 10427 | 213 GaimProxyInfo *proxy_info; |
| 214 | |
| 215 node = xmlnode_new("account"); | |
| 216 | |
| 217 child = xmlnode_new_child(node, "protocol"); | |
| 218 xmlnode_insert_data(child, gaim_account_get_protocol_id(account), -1); | |
| 219 | |
| 220 child = xmlnode_new_child(node, "name"); | |
| 221 xmlnode_insert_data(child, gaim_account_get_username(account), -1); | |
| 222 | |
| 223 if (gaim_account_get_remember_password(account) && | |
| 224 ((tmp = gaim_account_get_password(account)) != NULL)) | |
| 225 { | |
| 226 child = xmlnode_new_child(node, "password"); | |
| 227 xmlnode_insert_data(child, tmp, -1); | |
| 228 } | |
| 229 | |
| 230 if ((tmp = gaim_account_get_alias(account)) != NULL) | |
| 231 { | |
| 232 child = xmlnode_new_child(node, "alias"); | |
| 233 xmlnode_insert_data(child, tmp, -1); | |
| 234 } | |
| 235 | |
| 10738 | 236 if ((presence = gaim_account_get_presence(account)) != NULL) |
| 237 { | |
| 238 child = statuses_to_xmlnode(presence); | |
| 239 xmlnode_insert_child(node, child); | |
| 240 } | |
| 241 | |
| 10427 | 242 if ((tmp = gaim_account_get_user_info(account)) != NULL) |
| 243 { | |
| 244 /* TODO: Do we need to call gaim_str_strip_cr(tmp) here? */ | |
| 245 child = xmlnode_new_child(node, "userinfo"); | |
| 246 xmlnode_insert_data(child, tmp, -1); | |
| 247 } | |
| 248 | |
| 249 if ((tmp = gaim_account_get_buddy_icon(account)) != NULL) | |
| 250 { | |
| 251 child = xmlnode_new_child(node, "buddyicon"); | |
| 252 xmlnode_insert_data(child, tmp, -1); | |
| 253 } | |
| 254 | |
| 255 if (g_hash_table_size(account->settings) > 0) | |
| 256 { | |
| 257 child = xmlnode_new_child(node, "settings"); | |
| 258 g_hash_table_foreach(account->settings, setting_to_xmlnode, child); | |
| 259 } | |
| 260 | |
| 261 if (g_hash_table_size(account->ui_settings) > 0) | |
| 262 { | |
| 263 g_hash_table_foreach(account->ui_settings, ui_setting_to_xmlnode, node); | |
| 264 } | |
| 265 | |
| 266 if ((proxy_info = gaim_account_get_proxy_info(account)) != NULL) | |
| 267 { | |
| 268 child = proxy_settings_to_xmlnode(proxy_info); | |
| 269 xmlnode_insert_child(node, child); | |
| 270 } | |
| 271 | |
| 272 return node; | |
| 273 } | |
| 274 | |
| 275 static xmlnode * | |
| 276 accounts_to_xmlnode(void) | |
| 277 { | |
| 278 xmlnode *node, *child; | |
| 279 GList *cur; | |
| 280 | |
| 10760 | 281 node = xmlnode_new("account"); |
| 10427 | 282 xmlnode_set_attrib(node, "version", "1.0"); |
| 283 | |
| 284 for (cur = gaim_accounts_get_all(); cur != NULL; cur = cur->next) | |
| 285 { | |
| 286 child = account_to_xmlnode(cur->data); | |
| 287 xmlnode_insert_child(node, child); | |
| 288 } | |
| 289 | |
| 290 return node; | |
| 291 } | |
| 292 | |
| 293 static void | |
| 294 sync_accounts(void) | |
| 295 { | |
| 296 xmlnode *node; | |
| 297 char *data; | |
| 298 | |
| 10428 | 299 if (!accounts_loaded) |
| 300 { | |
| 10760 | 301 gaim_debug_error("account", "Attempted to save accounts before " |
| 10443 | 302 "they were read!\n"); |
| 303 return; | |
| 10427 | 304 } |
| 305 | |
| 306 node = accounts_to_xmlnode(); | |
| 307 data = xmlnode_to_formatted_str(node, NULL); | |
| 308 gaim_util_write_data_to_file("accounts.xml", data, -1); | |
| 309 g_free(data); | |
| 310 xmlnode_free(node); | |
| 311 } | |
| 312 | |
| 313 static gboolean | |
| 314 save_cb(gpointer data) | |
| 315 { | |
| 316 sync_accounts(); | |
| 10428 | 317 save_timer = 0; |
| 10427 | 318 return FALSE; |
| 319 } | |
| 320 | |
| 321 static void | |
| 322 schedule_accounts_save() | |
| 323 { | |
| 10428 | 324 if (save_timer == 0) |
| 325 save_timer = gaim_timeout_add(5000, save_cb, NULL); | |
| 10427 | 326 } |
| 327 | |
| 328 | |
| 10428 | 329 /********************************************************************* |
| 330 * Reading from disk * | |
| 331 *********************************************************************/ | |
| 10427 | 332 |
| 333 static void | |
| 334 parse_settings(xmlnode *node, GaimAccount *account) | |
| 335 { | |
| 336 const char *ui; | |
| 337 xmlnode *child; | |
| 338 | |
| 339 /* Get the UI string, if these are UI settings */ | |
| 340 ui = xmlnode_get_attrib(node, "ui"); | |
| 341 | |
| 342 /* Read settings, one by one */ | |
| 343 for (child = xmlnode_get_child(node, "setting"); child != NULL; | |
| 344 child = xmlnode_get_next_twin(child)) | |
| 345 { | |
| 346 const char *name, *str_type; | |
| 347 GaimPrefType type; | |
| 348 char *data; | |
| 349 | |
| 350 name = xmlnode_get_attrib(child, "name"); | |
| 351 if (name == NULL) | |
| 352 /* Ignore this setting */ | |
| 353 continue; | |
| 354 | |
| 355 str_type = xmlnode_get_attrib(child, "type"); | |
| 10448 | 356 if (str_type == NULL) |
| 357 /* Ignore this setting */ | |
| 358 continue; | |
| 359 | |
| 10427 | 360 if (!strcmp(str_type, "string")) |
| 361 type = GAIM_PREF_STRING; | |
| 362 else if (!strcmp(str_type, "int")) | |
| 363 type = GAIM_PREF_INT; | |
| 364 else if (!strcmp(str_type, "bool")) | |
| 365 type = GAIM_PREF_BOOLEAN; | |
| 366 else | |
| 367 /* Ignore this setting */ | |
| 368 continue; | |
| 369 | |
| 370 data = xmlnode_get_data(child); | |
| 371 if (data == NULL) | |
| 372 /* Ignore this setting */ | |
| 373 continue; | |
| 374 | |
| 375 if (ui == NULL) | |
| 376 { | |
| 377 if (type == GAIM_PREF_STRING) | |
| 378 gaim_account_set_string(account, name, data); | |
| 379 else if (type == GAIM_PREF_INT) | |
| 380 gaim_account_set_int(account, name, atoi(data)); | |
| 381 else if (type == GAIM_PREF_BOOLEAN) | |
| 382 gaim_account_set_bool(account, name, | |
| 383 (*data == '0' ? FALSE : TRUE)); | |
| 384 } else { | |
| 385 if (type == GAIM_PREF_STRING) | |
| 386 gaim_account_set_ui_string(account, ui, name, data); | |
| 387 else if (type == GAIM_PREF_INT) | |
| 388 gaim_account_set_ui_int(account, ui, name, atoi(data)); | |
| 389 else if (type == GAIM_PREF_BOOLEAN) | |
| 390 gaim_account_set_ui_bool(account, ui, name, | |
| 391 (*data == '0' ? FALSE : TRUE)); | |
| 392 } | |
| 393 | |
| 394 g_free(data); | |
| 395 } | |
| 396 } | |
| 397 | |
| 398 static void | |
| 10738 | 399 parse_status(xmlnode *node, GaimAccount *account) |
| 400 { | |
| 401 gboolean active = FALSE; | |
| 402 const char *data; | |
| 403 const char *type; | |
| 404 xmlnode *child; | |
| 405 | |
| 406 /* Get the active/inactive state */ | |
| 407 child = xmlnode_get_child(node, "active"); | |
| 408 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
| 409 { | |
| 410 if (strcasecmp(data, "true") == 0) | |
| 411 active = TRUE; | |
| 412 else if (strcasecmp(data, "false") == 0) | |
| 413 active = FALSE; | |
| 414 else | |
| 415 return; | |
| 416 } | |
| 417 else | |
| 418 return; | |
| 419 | |
| 420 /* Get the type of the status */ | |
| 421 child = xmlnode_get_child(node, "type"); | |
| 422 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
| 423 { | |
| 424 type = data; | |
| 425 } | |
| 426 else | |
| 427 return; | |
| 428 | |
| 429 /* QQQ: Need to read attributes into a vargs */ | |
| 430 | |
| 431 /* QQQ: This needs to do a better job of adding attributes and stuff */ | |
| 432 /* Use gaim_account_set_status_vargs(); */ | |
| 433 gaim_account_set_status(account, type, active); | |
| 434 } | |
| 435 | |
| 436 static void | |
| 437 parse_statuses(xmlnode *node, GaimAccount *account) | |
| 438 { | |
| 439 xmlnode *child; | |
| 440 | |
| 441 for (child = xmlnode_get_child(node, "status"); child != NULL; | |
| 442 child = xmlnode_get_next_twin(child)) | |
| 443 { | |
| 444 parse_status(child, account); | |
| 445 } | |
| 446 } | |
| 447 | |
| 448 static void | |
| 10427 | 449 parse_proxy_info(xmlnode *node, GaimAccount *account) |
| 450 { | |
| 451 GaimProxyInfo *proxy_info; | |
| 452 xmlnode *child; | |
| 453 char *data; | |
| 454 | |
| 455 proxy_info = gaim_proxy_info_new(); | |
| 456 | |
| 457 /* Use the global proxy settings, by default */ | |
| 458 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_USE_GLOBAL); | |
| 459 | |
| 460 /* Read proxy type */ | |
| 461 child = xmlnode_get_child(node, "type"); | |
| 462 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
| 463 { | |
| 464 if (!strcmp(data, "global")) | |
| 465 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_USE_GLOBAL); | |
| 466 else if (!strcmp(data, "none")) | |
| 467 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_NONE); | |
| 468 else if (!strcmp(data, "http")) | |
| 469 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_HTTP); | |
| 470 else if (!strcmp(data, "socks4")) | |
| 471 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_SOCKS4); | |
| 472 else if (!strcmp(data, "socks5")) | |
| 473 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_SOCKS5); | |
| 474 else if (!strcmp(data, "envvar")) | |
| 475 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_USE_ENVVAR); | |
| 476 else | |
| 477 { | |
| 478 gaim_debug_error("account", "Invalid proxy type found when " | |
| 479 "loading account information for %s\n", | |
| 480 gaim_account_get_username(account)); | |
| 481 } | |
| 482 g_free(data); | |
| 483 } | |
| 484 | |
| 485 /* Read proxy host */ | |
| 486 child = xmlnode_get_child(node, "host"); | |
| 487 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
| 488 { | |
| 489 gaim_proxy_info_set_host(proxy_info, data); | |
| 490 g_free(data); | |
| 491 } | |
| 492 | |
| 493 /* Read proxy port */ | |
| 494 child = xmlnode_get_child(node, "port"); | |
| 495 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
| 496 { | |
| 497 gaim_proxy_info_set_port(proxy_info, atoi(data)); | |
| 498 g_free(data); | |
| 499 } | |
| 500 | |
| 501 /* Read proxy username */ | |
| 502 child = xmlnode_get_child(node, "username"); | |
| 503 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
| 504 { | |
| 505 gaim_proxy_info_set_username(proxy_info, data); | |
| 506 g_free(data); | |
| 507 } | |
| 508 | |
| 509 /* Read proxy password */ | |
| 510 child = xmlnode_get_child(node, "password"); | |
| 511 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
| 512 { | |
| 513 gaim_proxy_info_set_password(proxy_info, data); | |
| 514 g_free(data); | |
| 515 } | |
| 516 | |
| 517 /* If there are no values set then proxy_infourn NULL */ | |
| 518 if ((gaim_proxy_info_get_type(proxy_info) == GAIM_PROXY_USE_GLOBAL) && | |
| 519 (gaim_proxy_info_get_host(proxy_info) == NULL) && | |
| 520 (gaim_proxy_info_get_port(proxy_info) == 0) && | |
| 521 (gaim_proxy_info_get_username(proxy_info) == NULL) && | |
| 522 (gaim_proxy_info_get_password(proxy_info) == NULL)) | |
| 523 { | |
| 524 gaim_proxy_info_destroy(proxy_info); | |
| 525 return; | |
| 526 } | |
| 527 | |
| 528 gaim_account_set_proxy_info(account, proxy_info); | |
| 529 } | |
| 530 | |
| 531 static GaimAccount * | |
| 532 parse_account(xmlnode *node) | |
| 533 { | |
| 534 GaimAccount *ret; | |
| 535 xmlnode *child; | |
| 536 char *protocol_id = NULL; | |
| 537 char *name = NULL; | |
| 538 char *data; | |
| 539 | |
| 540 child = xmlnode_get_child(node, "protocol"); | |
| 541 if (child != NULL) | |
| 542 protocol_id = xmlnode_get_data(child); | |
| 543 | |
| 544 child = xmlnode_get_child(node, "name"); | |
| 545 if (child != NULL) | |
| 546 name = xmlnode_get_data(child); | |
| 547 if (name == NULL) | |
| 548 { | |
| 549 /* Do we really need to do this? */ | |
| 550 child = xmlnode_get_child(node, "username"); | |
| 551 if (child != NULL) | |
| 552 name = xmlnode_get_data(child); | |
| 553 } | |
| 554 | |
| 555 if ((protocol_id == NULL) || (name == NULL)) | |
| 556 { | |
| 557 free(protocol_id); | |
| 558 free(name); | |
| 559 return NULL; | |
| 560 } | |
| 561 | |
| 562 ret = gaim_account_new(name, protocol_id); | |
| 563 free(name); | |
| 564 free(protocol_id); | |
| 565 | |
| 566 /* Read the password */ | |
| 567 child = xmlnode_get_child(node, "password"); | |
| 568 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
| 569 { | |
| 10743 | 570 gaim_account_set_remember_password(ret, TRUE); |
| 10427 | 571 gaim_account_set_password(ret, data); |
| 572 g_free(data); | |
| 573 } | |
| 574 | |
| 575 /* Read the alias */ | |
| 576 child = xmlnode_get_child(node, "alias"); | |
| 577 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
| 578 { | |
| 579 gaim_account_set_alias(ret, data); | |
| 580 g_free(data); | |
| 581 } | |
| 582 | |
| 10738 | 583 /* Read the statuses */ |
| 584 child = xmlnode_get_child(node, "statuses"); | |
| 585 if (child != NULL) | |
| 586 { | |
| 587 parse_statuses(child, ret); | |
| 588 } | |
| 589 | |
| 10427 | 590 /* Read the userinfo */ |
| 591 child = xmlnode_get_child(node, "userinfo"); | |
| 592 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
| 593 { | |
| 594 gaim_account_set_user_info(ret, data); | |
| 595 g_free(data); | |
| 596 } | |
| 597 | |
| 598 /* Read the buddyicon */ | |
| 599 child = xmlnode_get_child(node, "buddyicon"); | |
| 600 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
| 601 { | |
| 602 gaim_account_set_buddy_icon(ret, data); | |
| 603 g_free(data); | |
| 604 } | |
| 605 | |
| 606 /* Read settings (both core and UI) */ | |
| 607 for (child = xmlnode_get_child(node, "settings"); child != NULL; | |
| 608 child = xmlnode_get_next_twin(child)) | |
| 609 { | |
| 610 parse_settings(child, ret); | |
| 611 } | |
| 612 | |
| 613 /* Read proxy */ | |
| 614 child = xmlnode_get_child(node, "proxy"); | |
| 615 if (child != NULL) | |
| 616 { | |
| 617 parse_proxy_info(child, ret); | |
| 618 } | |
| 619 | |
| 620 return ret; | |
| 621 } | |
| 622 | |
| 623 static void | |
| 624 load_accounts(void) | |
| 625 { | |
| 626 xmlnode *node, *child; | |
| 627 | |
| 628 accounts_loaded = TRUE; | |
| 629 | |
| 630 node = gaim_util_read_xml_from_file("accounts.xml", _("accounts")); | |
| 631 | |
| 632 if (node == NULL) | |
| 633 return; | |
| 634 | |
| 635 for (child = xmlnode_get_child(node, "account"); child != NULL; | |
| 636 child = xmlnode_get_next_twin(child)) | |
| 637 { | |
| 10490 | 638 GaimAccount *new_acct; |
| 639 new_acct = parse_account(child); | |
| 640 gaim_accounts_add(new_acct); | |
| 10427 | 641 } |
| 642 } | |
| 643 | |
| 644 | |
| 5563 | 645 static void |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
646 delete_setting(void *data) |
| 5563 | 647 { |
| 648 GaimAccountSetting *setting = (GaimAccountSetting *)data; | |
| 649 | |
|
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
650 if (setting->ui != NULL) |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
651 g_free(setting->ui); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
652 |
| 5563 | 653 if (setting->type == GAIM_PREF_STRING) |
| 654 g_free(setting->value.string); | |
| 655 | |
| 656 g_free(setting); | |
| 657 } | |
| 658 | |
| 659 GaimAccount * | |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
660 gaim_account_new(const char *username, const char *protocol_id) |
| 5563 | 661 { |
| 6067 | 662 GaimAccount *account = NULL; |
| 10012 | 663 GaimPlugin *prpl = NULL; |
| 664 GaimPluginProtocolInfo *prpl_info = NULL; | |
| 5563 | 665 |
| 9944 | 666 g_return_val_if_fail(username != NULL, NULL); |
| 9971 | 667 g_return_val_if_fail(protocol_id != NULL, NULL); |
| 5563 | 668 |
| 9971 | 669 account = gaim_accounts_find(username, protocol_id); |
|
5867
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
670 |
|
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
671 if (account != NULL) |
|
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
672 return account; |
|
5867
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
673 |
| 5563 | 674 account = g_new0(GaimAccount, 1); |
| 675 | |
| 6067 | 676 gaim_account_set_username(account, username); |
| 677 | |
| 9971 | 678 gaim_account_set_protocol_id(account, protocol_id); |
| 5563 | 679 |
| 680 account->settings = g_hash_table_new_full(g_str_hash, g_str_equal, | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
681 g_free, delete_setting); |
|
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
682 account->ui_settings = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
683 g_free, (GDestroyNotify)g_hash_table_destroy); |
| 8573 | 684 account->system_log = NULL; |
| 10720 | 685 |
| 9944 | 686 account->presence = gaim_presence_new_for_account(account); |
| 687 | |
| 10447 | 688 prpl = gaim_find_prpl(protocol_id); |
| 10052 | 689 |
| 10012 | 690 if (prpl == NULL) |
| 691 return account; | |
| 10052 | 692 |
| 10738 | 693 /* TODO: Should maybe use gaim_prpl_get_statuses()? */ |
| 10012 | 694 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
| 10738 | 695 if (prpl_info != NULL && prpl_info->status_types != NULL) |
| 10012 | 696 gaim_account_set_status_types(account, prpl_info->status_types(account)); |
| 697 | |
| 10052 | 698 gaim_presence_set_status_active(account->presence, "offline", TRUE); |
| 699 | |
| 5563 | 700 return account; |
| 701 } | |
| 702 | |
| 703 void | |
| 704 gaim_account_destroy(GaimAccount *account) | |
| 705 { | |
|
7324
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
706 GList *l; |
|
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
707 |
| 5563 | 708 g_return_if_fail(account != NULL); |
| 709 | |
| 9944 | 710 gaim_debug_info("account", "Destroying account %p\n", account); |
|
5930
03f1d6cd784c
[gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents:
5926
diff
changeset
|
711 |
| 10742 | 712 if (gaim_account_is_connected(account)) |
| 713 gaim_account_disconnect(account); | |
| 5563 | 714 |
| 9944 | 715 gaim_debug_info("account", "Continuing to destroy account %p\n", account); |
|
5930
03f1d6cd784c
[gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents:
5926
diff
changeset
|
716 |
|
7324
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
717 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
|
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
718 { |
|
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
719 GaimConversation *conv = (GaimConversation *)l->data; |
|
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
720 |
|
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
721 if (gaim_conversation_get_account(conv) == account) |
|
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
722 gaim_conversation_set_account(conv, NULL); |
|
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
723 } |
|
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
724 |
|
5643
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
725 if (account->username != NULL) g_free(account->username); |
|
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
726 if (account->alias != NULL) g_free(account->alias); |
|
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
727 if (account->password != NULL) g_free(account->password); |
|
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
728 if (account->user_info != NULL) g_free(account->user_info); |
|
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
729 if (account->protocol_id != NULL) g_free(account->protocol_id); |
| 5563 | 730 |
| 731 g_hash_table_destroy(account->settings); | |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
732 g_hash_table_destroy(account->ui_settings); |
| 5563 | 733 |
| 9944 | 734 gaim_account_set_status_types(account, NULL); |
| 735 | |
| 736 gaim_presence_destroy(account->presence); | |
| 737 | |
| 8573 | 738 if(account->system_log) |
| 739 gaim_log_free(account->system_log); | |
| 740 | |
| 5563 | 741 g_free(account); |
| 742 } | |
| 743 | |
| 10740 | 744 void |
| 6581 | 745 gaim_account_register(GaimAccount *account) |
| 746 { | |
| 10740 | 747 g_return_if_fail(account != NULL); |
| 6581 | 748 |
| 10740 | 749 gaim_debug_info("account", "Registering account %s\n", |
| 750 gaim_account_get_username(account)); | |
| 6581 | 751 |
| 10740 | 752 gaim_connection_new(account, TRUE, NULL); |
| 753 } | |
| 6581 | 754 |
| 10740 | 755 static void |
| 756 request_password_ok_cb(GaimAccount *account, const char *entry) | |
| 757 { | |
| 758 if (!entry || !*entry) | |
| 759 { | |
| 760 gaim_notify_error(account, NULL, _("Password is required to sign on."), NULL); | |
| 761 return; | |
| 762 } | |
| 6581 | 763 |
| 10740 | 764 if (gaim_account_get_remember_password(account)) |
| 765 gaim_account_set_password(account, entry); | |
| 6581 | 766 |
| 10740 | 767 gaim_connection_new(account, FALSE, entry); |
| 6581 | 768 } |
| 769 | |
| 10758 | 770 /* |
| 771 * TODO: Make the entry box a required field, and add a | |
| 772 * "save password" checkbox. | |
| 773 */ | |
| 10740 | 774 static void |
| 775 request_password(GaimAccount *account) | |
| 776 { | |
| 777 gchar *primary; | |
| 778 const gchar *username; | |
| 779 | |
| 10758 | 780 /* Close any previous password request windows */ |
| 781 gaim_request_close_with_handle(account); | |
| 782 | |
| 10740 | 783 username = gaim_account_get_username(account); |
| 10774 | 784 primary = g_strdup_printf(_("Enter password for %s (%s)"), username, |
| 10740 | 785 gaim_account_get_protocol_name(account)); |
| 786 gaim_request_input(account, _("Enter Password"), primary, NULL, NULL, | |
| 787 FALSE, TRUE, NULL, | |
| 788 _("OK"), G_CALLBACK(request_password_ok_cb), | |
| 789 _("Cancel"), NULL, account); | |
| 790 g_free(primary); | |
| 791 } | |
| 792 | |
| 793 void | |
| 10738 | 794 gaim_account_connect(GaimAccount *account) |
| 5563 | 795 { |
| 10740 | 796 GaimPlugin *prpl; |
| 797 GaimPluginProtocolInfo *prpl_info; | |
| 798 const char *password; | |
| 799 | |
| 800 g_return_if_fail(account != NULL); | |
| 5563 | 801 |
| 10740 | 802 gaim_debug_info("account", "Connecting to account %s\n", |
| 803 gaim_account_get_username(account)); | |
| 5563 | 804 |
| 10740 | 805 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
| 806 if (prpl == NULL) | |
| 807 { | |
| 808 gchar *message; | |
| 6036 | 809 |
| 10740 | 810 message = g_strdup_printf(_("Missing protocol plugin for %s"), |
| 811 gaim_account_get_username(account)); | |
| 10758 | 812 gaim_notify_error(account, _("Connection Error"), message, NULL); |
| 10740 | 813 g_free(message); |
| 814 return; | |
| 815 } | |
| 5563 | 816 |
| 10740 | 817 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
| 818 password = gaim_account_get_password(account); | |
| 819 if ((password == NULL) && | |
| 820 !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && | |
| 821 !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) | |
| 822 request_password(account); | |
| 823 else | |
| 824 gaim_connection_new(account, FALSE, password); | |
| 5563 | 825 } |
| 826 | |
| 827 void | |
| 828 gaim_account_disconnect(GaimAccount *account) | |
| 829 { | |
|
5926
6c22d37c6a3c
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
830 GaimConnection *gc; |
|
6c22d37c6a3c
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
831 |
| 5563 | 832 g_return_if_fail(account != NULL); |
| 833 g_return_if_fail(gaim_account_is_connected(account)); | |
| 834 | |
| 9944 | 835 gaim_debug_info("account", "Disconnecting account %p\n", account); |
|
5930
03f1d6cd784c
[gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents:
5926
diff
changeset
|
836 |
| 10384 | 837 account->disconnecting = TRUE; |
| 5563 | 838 |
| 10742 | 839 gc = gaim_account_get_connection(account); |
| 840 gaim_connection_destroy(gc); | |
| 841 gaim_account_set_connection(account, NULL); | |
| 10384 | 842 |
| 843 account->disconnecting = FALSE; | |
| 5563 | 844 } |
| 845 | |
| 846 void | |
| 7166 | 847 gaim_account_notify_added(GaimAccount *account, const char *id, |
| 848 const char *remote_user, const char *alias, | |
|
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
849 const char *message) |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
850 { |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
851 GaimAccountUiOps *ui_ops; |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
852 |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
853 g_return_if_fail(account != NULL); |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
854 g_return_if_fail(remote_user != NULL); |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
855 |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
856 ui_ops = gaim_accounts_get_ui_ops(); |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
857 |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
858 if (ui_ops != NULL && ui_ops->notify_added != NULL) |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
859 ui_ops->notify_added(account, remote_user, id, alias, message); |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
860 } |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
861 |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
862 static void |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
863 change_password_cb(GaimAccount *account, GaimRequestFields *fields) |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
864 { |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
865 const char *orig_pass, *new_pass_1, *new_pass_2; |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
866 |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
867 orig_pass = gaim_request_fields_get_string(fields, "password"); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
868 new_pass_1 = gaim_request_fields_get_string(fields, "new_password_1"); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
869 new_pass_2 = gaim_request_fields_get_string(fields, "new_password_2"); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
870 |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
871 if (g_utf8_collate(new_pass_1, new_pass_2)) |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
872 { |
| 10758 | 873 gaim_notify_error(account, NULL, |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
874 _("New passwords do not match."), NULL); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
875 |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
876 return; |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
877 } |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
878 |
| 8638 | 879 if (orig_pass == NULL || new_pass_1 == NULL || new_pass_2 == NULL || |
| 880 *orig_pass == '\0' || *new_pass_1 == '\0' || *new_pass_2 == '\0') | |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
881 { |
| 10758 | 882 gaim_notify_error(account, NULL, |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
883 _("Fill out all fields completely."), NULL); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
884 return; |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
885 } |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
886 |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
887 serv_change_passwd(gaim_account_get_connection(account), |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
888 orig_pass, new_pass_1); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
889 gaim_account_set_password(account, new_pass_1); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
890 } |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
891 |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
892 void |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
893 gaim_account_request_change_password(GaimAccount *account) |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
894 { |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
895 GaimRequestFields *fields; |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
896 GaimRequestFieldGroup *group; |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
897 GaimRequestField *field; |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
898 char primary[256]; |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
899 |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
900 g_return_if_fail(account != NULL); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
901 g_return_if_fail(gaim_account_is_connected(account)); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
902 |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
903 fields = gaim_request_fields_new(); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
904 |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
905 group = gaim_request_field_group_new(NULL); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
906 gaim_request_fields_add_group(fields, group); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
907 |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
908 field = gaim_request_field_string_new("password", _("Original password"), |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
909 NULL, FALSE); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
910 gaim_request_field_string_set_masked(field, TRUE); |
| 8638 | 911 gaim_request_field_set_required(field, TRUE); |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
912 gaim_request_field_group_add_field(group, field); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
913 |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
914 field = gaim_request_field_string_new("new_password_1", |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
915 _("New password"), |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
916 NULL, FALSE); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
917 gaim_request_field_string_set_masked(field, TRUE); |
| 8638 | 918 gaim_request_field_set_required(field, TRUE); |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
919 gaim_request_field_group_add_field(group, field); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
920 |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
921 field = gaim_request_field_string_new("new_password_2", |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
922 _("New password (again)"), |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
923 NULL, FALSE); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
924 gaim_request_field_string_set_masked(field, TRUE); |
| 8638 | 925 gaim_request_field_set_required(field, TRUE); |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
926 gaim_request_field_group_add_field(group, field); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
927 |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
928 g_snprintf(primary, sizeof(primary), _("Change password for %s"), |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
929 gaim_account_get_username(account)); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
930 |
| 7755 | 931 /* I'm sticking this somewhere in the code: bologna */ |
| 932 | |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
933 gaim_request_fields(gaim_account_get_connection(account), |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
934 NULL, |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
935 primary, |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
936 _("Please enter your current password and your " |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
937 "new password."), |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
938 fields, |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
939 _("OK"), G_CALLBACK(change_password_cb), |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
940 _("Cancel"), NULL, |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
941 account); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
942 } |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
943 |
|
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
944 static void |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
945 set_user_info_cb(GaimAccount *account, const char *user_info) |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
946 { |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
947 GaimConnection *gc; |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
948 |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
949 gaim_account_set_user_info(account, user_info); |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
950 |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
951 gc = gaim_account_get_connection(account); |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
952 |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
953 if (gc != NULL) |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
954 serv_set_info(gaim_account_get_connection(account), user_info); |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
955 } |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
956 |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
957 void |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
958 gaim_account_request_change_user_info(GaimAccount *account) |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
959 { |
| 8697 | 960 GaimConnection *gc; |
|
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
961 char primary[256]; |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
962 |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
963 g_return_if_fail(account != NULL); |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
964 g_return_if_fail(gaim_account_is_connected(account)); |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
965 |
| 8697 | 966 gc = gaim_account_get_connection(account); |
| 967 | |
|
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
968 g_snprintf(primary, sizeof(primary), |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
969 _("Change user information for %s"), |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
970 gaim_account_get_username(account)); |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
971 |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
972 gaim_request_input(gaim_account_get_connection(account), |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
973 NULL, primary, NULL, |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
974 gaim_account_get_user_info(account), |
| 8697 | 975 TRUE, FALSE, ((gc != NULL) && |
| 976 (gc->flags & GAIM_CONNECTION_HTML) ? "html" : NULL), | |
|
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
977 _("Save"), G_CALLBACK(set_user_info_cb), |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
978 _("Cancel"), NULL, account); |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
979 } |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
980 |
|
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
981 void |
| 5563 | 982 gaim_account_set_username(GaimAccount *account, const char *username) |
| 983 { | |
|
5711
e33778b9d395
[gaim-migrate @ 6132]
Christian Hammond <chipx86@chipx86.com>
parents:
5710
diff
changeset
|
984 g_return_if_fail(account != NULL); |
| 5563 | 985 |
| 10740 | 986 g_free(account->username); |
| 5563 | 987 account->username = (username == NULL ? NULL : g_strdup(username)); |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
988 |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
989 schedule_accounts_save(); |
| 5563 | 990 } |
| 991 | |
| 992 void | |
| 993 gaim_account_set_password(GaimAccount *account, const char *password) | |
| 994 { | |
|
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
995 g_return_if_fail(account != NULL); |
| 5563 | 996 |
| 10740 | 997 g_free(account->password); |
| 998 account->password = NULL; | |
| 999 | |
| 1000 if (!gaim_account_get_remember_password(account)) | |
| 1001 return; | |
| 5563 | 1002 |
| 1003 account->password = (password == NULL ? NULL : g_strdup(password)); | |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1004 |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1005 schedule_accounts_save(); |
| 5563 | 1006 } |
| 1007 | |
| 1008 void | |
| 1009 gaim_account_set_alias(GaimAccount *account, const char *alias) | |
| 1010 { | |
| 1011 g_return_if_fail(account != NULL); | |
| 1012 | |
| 10740 | 1013 g_free(account->alias); |
| 5563 | 1014 account->alias = (alias == NULL ? NULL : g_strdup(alias)); |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1015 |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1016 schedule_accounts_save(); |
| 5563 | 1017 } |
| 1018 | |
| 1019 void | |
| 1020 gaim_account_set_user_info(GaimAccount *account, const char *user_info) | |
| 1021 { | |
|
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1022 g_return_if_fail(account != NULL); |
| 5563 | 1023 |
| 10740 | 1024 g_free(account->user_info); |
| 5563 | 1025 account->user_info = (user_info == NULL ? NULL : g_strdup(user_info)); |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1026 |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1027 schedule_accounts_save(); |
| 5563 | 1028 } |
| 1029 | |
| 1030 void | |
| 1031 gaim_account_set_buddy_icon(GaimAccount *account, const char *icon) | |
| 1032 { | |
| 1033 g_return_if_fail(account != NULL); | |
| 1034 | |
| 10740 | 1035 g_free(account->buddy_icon); |
| 5563 | 1036 account->buddy_icon = (icon == NULL ? NULL : g_strdup(icon)); |
| 10740 | 1037 if (gaim_account_is_connected(account)) |
| 10742 | 1038 serv_set_buddyicon(gaim_account_get_connection(account), icon); |
| 10418 | 1039 |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1040 schedule_accounts_save(); |
| 5563 | 1041 } |
| 1042 | |
| 1043 void | |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1044 gaim_account_set_protocol_id(GaimAccount *account, const char *protocol_id) |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1045 { |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1046 g_return_if_fail(account != NULL); |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1047 g_return_if_fail(protocol_id != NULL); |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1048 |
| 10740 | 1049 g_free(account->protocol_id); |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1050 account->protocol_id = g_strdup(protocol_id); |
|
5665
132a30783c3d
[gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents:
5659
diff
changeset
|
1051 |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1052 schedule_accounts_save(); |
| 5563 | 1053 } |
| 1054 | |
| 1055 void | |
| 1056 gaim_account_set_connection(GaimAccount *account, GaimConnection *gc) | |
| 1057 { | |
| 1058 g_return_if_fail(account != NULL); | |
| 1059 | |
| 1060 account->gc = gc; | |
| 1061 } | |
| 1062 | |
| 1063 void | |
| 1064 gaim_account_set_remember_password(GaimAccount *account, gboolean value) | |
| 1065 { | |
| 1066 g_return_if_fail(account != NULL); | |
| 1067 | |
| 1068 account->remember_pass = value; | |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1069 |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1070 schedule_accounts_save(); |
| 5563 | 1071 } |
| 1072 | |
| 1073 void | |
|
5659
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1074 gaim_account_set_check_mail(GaimAccount *account, gboolean value) |
|
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1075 { |
|
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1076 g_return_if_fail(account != NULL); |
|
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1077 |
|
5977
2d34c02d2031
[gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents:
5953
diff
changeset
|
1078 gaim_account_set_bool(account, "check-mail", value); |
|
5659
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1079 } |
|
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1080 |
|
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1081 void |
| 10400 | 1082 gaim_account_set_enabled(GaimAccount *account, const char *ui, |
| 1083 gboolean value) | |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1084 { |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1085 g_return_if_fail(account != NULL); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1086 g_return_if_fail(ui != NULL); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1087 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1088 gaim_account_set_ui_bool(account, ui, "auto-login", value); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1089 } |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1090 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1091 void |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1092 gaim_account_set_proxy_info(GaimAccount *account, GaimProxyInfo *info) |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1093 { |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1094 g_return_if_fail(account != NULL); |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1095 |
|
5695
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1096 if (account->proxy_info != NULL) |
|
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1097 gaim_proxy_info_destroy(account->proxy_info); |
|
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1098 |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1099 account->proxy_info = info; |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1100 |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1101 schedule_accounts_save(); |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1102 } |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1103 |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1104 void |
| 9944 | 1105 gaim_account_set_status_types(GaimAccount *account, GList *status_types) |
| 1106 { | |
| 1107 g_return_if_fail(account != NULL); | |
| 1108 | |
| 10005 | 1109 /* Old with the old... */ |
| 9944 | 1110 if (account->status_types != NULL) |
| 1111 { | |
| 1112 GList *l; | |
| 1113 | |
| 1114 for (l = account->status_types; l != NULL; l = l->next) | |
| 1115 gaim_status_type_destroy((GaimStatusType *)l->data); | |
| 1116 | |
| 1117 g_list_free(account->status_types); | |
| 1118 } | |
| 1119 | |
| 10005 | 1120 /* In with the new... */ |
| 9944 | 1121 account->status_types = status_types; |
| 1122 } | |
| 1123 | |
| 1124 void | |
| 1125 gaim_account_set_status(GaimAccount *account, const char *status_id, | |
| 1126 gboolean active, ...) | |
| 1127 { | |
| 10738 | 1128 va_list args; |
| 1129 | |
| 1130 va_start(args, active); | |
| 1131 gaim_account_set_status_vargs(account, status_id, active, args); | |
| 1132 va_end(args); | |
| 1133 } | |
| 1134 | |
| 1135 void | |
| 1136 gaim_account_set_status_vargs(GaimAccount *account, const char *status_id, | |
| 1137 gboolean active, va_list args) | |
| 1138 { | |
| 9944 | 1139 GaimStatus *status; |
| 1140 | |
| 1141 g_return_if_fail(account != NULL); | |
| 1142 g_return_if_fail(status_id != NULL); | |
| 1143 | |
| 10760 | 1144 gaim_debug_info("account", "Changing status for %s, setting %s to %d\n", |
| 1145 gaim_account_get_username(account), status_id, active); | |
| 1146 | |
| 9944 | 1147 status = gaim_account_get_status(account, status_id); |
| 1148 if (status == NULL) | |
| 1149 { | |
| 10760 | 1150 gaim_debug_error("account", |
| 9944 | 1151 "Invalid status ID %s for account %s (%s)\n", |
| 1152 status_id, gaim_account_get_username(account), | |
| 1153 gaim_account_get_protocol_id(account)); | |
| 1154 return; | |
| 1155 } | |
| 10720 | 1156 |
| 10754 | 1157 /* Our current statuses are saved to accounts.xml */ |
| 1158 schedule_accounts_save(); | |
| 9944 | 1159 |
| 10754 | 1160 if (active || gaim_status_is_independent(status)) |
| 1161 gaim_status_set_active_with_attrs(status, active, args); | |
| 9944 | 1162 } |
| 1163 | |
| 1164 void | |
|
5694
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1165 gaim_account_clear_settings(GaimAccount *account) |
|
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1166 { |
|
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1167 g_return_if_fail(account != NULL); |
|
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1168 |
|
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1169 g_hash_table_destroy(account->settings); |
|
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1170 |
|
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1171 account->settings = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1172 g_free, delete_setting); |
|
5694
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1173 } |
|
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1174 |
|
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1175 void |
| 5563 | 1176 gaim_account_set_int(GaimAccount *account, const char *name, int value) |
| 1177 { | |
| 1178 GaimAccountSetting *setting; | |
| 1179 | |
| 1180 g_return_if_fail(account != NULL); | |
| 1181 g_return_if_fail(name != NULL); | |
| 1182 | |
| 1183 setting = g_new0(GaimAccountSetting, 1); | |
| 1184 | |
| 1185 setting->type = GAIM_PREF_INT; | |
| 1186 setting->value.integer = value; | |
| 1187 | |
| 1188 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1189 |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1190 schedule_accounts_save(); |
| 5563 | 1191 } |
| 1192 | |
| 1193 void | |
| 1194 gaim_account_set_string(GaimAccount *account, const char *name, | |
| 1195 const char *value) | |
| 1196 { | |
| 1197 GaimAccountSetting *setting; | |
| 1198 | |
| 1199 g_return_if_fail(account != NULL); | |
| 1200 g_return_if_fail(name != NULL); | |
| 1201 | |
| 1202 setting = g_new0(GaimAccountSetting, 1); | |
| 1203 | |
| 1204 setting->type = GAIM_PREF_STRING; | |
| 1205 setting->value.string = g_strdup(value); | |
| 1206 | |
| 1207 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1208 |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1209 schedule_accounts_save(); |
| 5563 | 1210 } |
| 1211 | |
| 1212 void | |
| 1213 gaim_account_set_bool(GaimAccount *account, const char *name, gboolean value) | |
| 1214 { | |
| 1215 GaimAccountSetting *setting; | |
| 1216 | |
| 1217 g_return_if_fail(account != NULL); | |
| 1218 g_return_if_fail(name != NULL); | |
| 1219 | |
| 1220 setting = g_new0(GaimAccountSetting, 1); | |
| 1221 | |
| 1222 setting->type = GAIM_PREF_BOOLEAN; | |
| 1223 setting->value.bool = value; | |
| 1224 | |
| 1225 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1226 |
|
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1227 schedule_accounts_save(); |
| 5563 | 1228 } |
| 1229 | |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1230 static GHashTable * |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1231 get_ui_settings_table(GaimAccount *account, const char *ui) |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1232 { |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1233 GHashTable *table; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1234 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1235 table = g_hash_table_lookup(account->ui_settings, ui); |
|
5979
49ae70ffcea5
[gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents:
5977
diff
changeset
|
1236 |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1237 if (table == NULL) { |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1238 table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1239 delete_setting); |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1240 g_hash_table_insert(account->ui_settings, g_strdup(ui), table); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1241 } |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1242 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1243 return table; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1244 } |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1245 |
|
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1246 void |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1247 gaim_account_set_ui_int(GaimAccount *account, const char *ui, |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1248 const char *name, int value) |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1249 { |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1250 GaimAccountSetting *setting; |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1251 GHashTable *table; |
|
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1252 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1253 g_return_if_fail(account != NULL); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1254 g_return_if_fail(ui != NULL); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1255 g_return_if_fail(name != NULL); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1256 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1257 setting = g_new0(GaimAccountSetting, 1); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1258 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1259 setting->type = GAIM_PREF_INT; |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1260 setting->ui = g_strdup(ui); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1261 setting->value.integer = value; |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1262 |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1263 table = get_ui_settings_table(account, ui); |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1264 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1265 g_hash_table_insert(table, g_strdup(name), setting); |
|
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1266 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1267 schedule_accounts_save(); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1268 } |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1269 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1270 void |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1271 gaim_account_set_ui_string(GaimAccount *account, const char *ui, |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1272 const char *name, const char *value) |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1273 { |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1274 GaimAccountSetting *setting; |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1275 GHashTable *table; |
|
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1276 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1277 g_return_if_fail(account != NULL); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1278 g_return_if_fail(ui != NULL); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1279 g_return_if_fail(name != NULL); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1280 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1281 setting = g_new0(GaimAccountSetting, 1); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1282 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1283 setting->type = GAIM_PREF_STRING; |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1284 setting->ui = g_strdup(ui); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1285 setting->value.string = g_strdup(value); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1286 |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1287 table = get_ui_settings_table(account, ui); |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1288 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1289 g_hash_table_insert(table, g_strdup(name), setting); |
|
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1290 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1291 schedule_accounts_save(); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1292 } |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1293 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1294 void |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1295 gaim_account_set_ui_bool(GaimAccount *account, const char *ui, |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1296 const char *name, gboolean value) |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1297 { |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1298 GaimAccountSetting *setting; |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1299 GHashTable *table; |
|
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1300 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1301 g_return_if_fail(account != NULL); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1302 g_return_if_fail(ui != NULL); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1303 g_return_if_fail(name != NULL); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1304 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1305 setting = g_new0(GaimAccountSetting, 1); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1306 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1307 setting->type = GAIM_PREF_BOOLEAN; |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1308 setting->ui = g_strdup(ui); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1309 setting->value.bool = value; |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1310 |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1311 table = get_ui_settings_table(account, ui); |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1312 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1313 g_hash_table_insert(table, g_strdup(name), setting); |
|
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1314 |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1315 schedule_accounts_save(); |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1316 } |
|
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1317 |
| 5563 | 1318 gboolean |
| 1319 gaim_account_is_connected(const GaimAccount *account) | |
| 1320 { | |
| 9019 | 1321 GaimConnection *gc; |
| 1322 | |
| 5563 | 1323 g_return_val_if_fail(account != NULL, FALSE); |
| 1324 | |
| 9019 | 1325 gc = gaim_account_get_connection(account); |
| 1326 | |
| 10428 | 1327 /* TODO: The first way is better... but it doesn't work quite right yet */ |
| 9021 | 1328 /* return ((gc != NULL) && GAIM_CONNECTION_IS_CONNECTED(gc)); */ |
| 1329 return ((gc != NULL) && gaim_connection_get_state(gc) != GAIM_DISCONNECTED); | |
| 5563 | 1330 } |
| 1331 | |
| 1332 const char * | |
| 1333 gaim_account_get_username(const GaimAccount *account) | |
| 1334 { | |
| 1335 g_return_val_if_fail(account != NULL, NULL); | |
| 1336 | |
| 1337 return account->username; | |
| 1338 } | |
| 1339 | |
| 1340 const char * | |
| 1341 gaim_account_get_password(const GaimAccount *account) | |
| 1342 { | |
| 1343 g_return_val_if_fail(account != NULL, NULL); | |
| 1344 | |
| 1345 return account->password; | |
| 1346 } | |
| 1347 | |
| 1348 const char * | |
| 1349 gaim_account_get_alias(const GaimAccount *account) | |
| 1350 { | |
| 1351 g_return_val_if_fail(account != NULL, NULL); | |
| 1352 | |
| 1353 return account->alias; | |
| 1354 } | |
| 1355 | |
| 1356 const char * | |
| 1357 gaim_account_get_user_info(const GaimAccount *account) | |
| 1358 { | |
| 1359 g_return_val_if_fail(account != NULL, NULL); | |
| 1360 | |
| 1361 return account->user_info; | |
| 1362 } | |
| 1363 | |
| 1364 const char * | |
| 1365 gaim_account_get_buddy_icon(const GaimAccount *account) | |
| 1366 { | |
| 1367 g_return_val_if_fail(account != NULL, NULL); | |
| 1368 | |
| 1369 return account->buddy_icon; | |
| 1370 } | |
| 1371 | |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1372 const char * |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1373 gaim_account_get_protocol_id(const GaimAccount *account) |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1374 { |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1375 g_return_val_if_fail(account != NULL, NULL); |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1376 |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1377 return account->protocol_id; |
| 5563 | 1378 } |
| 1379 | |
| 9699 | 1380 const char * |
| 1381 gaim_account_get_protocol_name(const GaimAccount *account) | |
| 1382 { | |
| 9720 | 1383 GaimPlugin *p; |
| 1384 | |
| 9699 | 1385 g_return_val_if_fail(account != NULL, NULL); |
| 1386 | |
| 9989 | 1387 p = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
| 9988 | 1388 |
| 1389 return ((p && p->info->name) ? _(p->info->name) : _("Unknown")); | |
| 1390 } | |
| 1391 | |
| 5563 | 1392 GaimConnection * |
| 1393 gaim_account_get_connection(const GaimAccount *account) | |
| 1394 { | |
| 1395 g_return_val_if_fail(account != NULL, NULL); | |
| 1396 | |
| 1397 return account->gc; | |
| 1398 } | |
| 1399 | |
| 1400 gboolean | |
| 1401 gaim_account_get_remember_password(const GaimAccount *account) | |
| 1402 { | |
| 1403 g_return_val_if_fail(account != NULL, FALSE); | |
| 1404 | |
| 1405 return account->remember_pass; | |
| 1406 } | |
| 1407 | |
|
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1408 gboolean |
|
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1409 gaim_account_get_check_mail(const GaimAccount *account) |
|
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1410 { |
|
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1411 g_return_val_if_fail(account != NULL, FALSE); |
|
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1412 |
|
5977
2d34c02d2031
[gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents:
5953
diff
changeset
|
1413 return gaim_account_get_bool(account, "check-mail", FALSE); |
|
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1414 } |
|
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1415 |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1416 gboolean |
| 10400 | 1417 gaim_account_get_enabled(const GaimAccount *account, const char *ui) |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1418 { |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1419 g_return_val_if_fail(account != NULL, FALSE); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1420 g_return_val_if_fail(ui != NULL, FALSE); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1421 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1422 return gaim_account_get_ui_bool(account, ui, "auto-login", FALSE); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1423 } |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1424 |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1425 GaimProxyInfo * |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1426 gaim_account_get_proxy_info(const GaimAccount *account) |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1427 { |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1428 g_return_val_if_fail(account != NULL, NULL); |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1429 |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1430 return account->proxy_info; |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1431 } |
|
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1432 |
| 9944 | 1433 GaimStatus * |
| 10738 | 1434 gaim_account_get_active_status(const GaimAccount *account) |
| 1435 { | |
| 1436 g_return_val_if_fail(account != NULL, NULL); | |
| 1437 | |
| 1438 return gaim_presence_get_active_status(account->presence); | |
| 1439 } | |
| 1440 | |
| 1441 GaimStatus * | |
| 9944 | 1442 gaim_account_get_status(const GaimAccount *account, const char *status_id) |
| 1443 { | |
| 1444 g_return_val_if_fail(account != NULL, NULL); | |
| 1445 g_return_val_if_fail(status_id != NULL, NULL); | |
| 1446 | |
| 1447 return gaim_presence_get_status(account->presence, status_id); | |
| 1448 } | |
| 1449 | |
| 1450 GaimStatusType * | |
| 1451 gaim_account_get_status_type(const GaimAccount *account, const char *id) | |
| 1452 { | |
| 1453 const GList *l; | |
| 1454 | |
| 1455 g_return_val_if_fail(account != NULL, NULL); | |
| 1456 g_return_val_if_fail(id != NULL, NULL); | |
| 1457 | |
| 1458 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) | |
| 1459 { | |
| 1460 GaimStatusType *status_type = (GaimStatusType *)l->data; | |
| 1461 | |
| 1462 if (!strcmp(gaim_status_type_get_id(status_type), id)) | |
| 1463 return status_type; | |
| 1464 } | |
| 1465 | |
| 1466 return NULL; | |
| 1467 } | |
| 1468 | |
| 1469 GaimPresence * | |
| 1470 gaim_account_get_presence(const GaimAccount *account) | |
| 1471 { | |
| 1472 g_return_val_if_fail(account != NULL, NULL); | |
| 1473 | |
| 1474 return account->presence; | |
| 1475 } | |
| 1476 | |
| 1477 gboolean | |
| 1478 gaim_account_is_status_active(const GaimAccount *account, | |
| 1479 const char *status_id) | |
| 1480 { | |
| 1481 g_return_val_if_fail(account != NULL, FALSE); | |
| 1482 g_return_val_if_fail(status_id != NULL, FALSE); | |
| 1483 | |
| 1484 return gaim_presence_is_status_active(account->presence, status_id); | |
| 1485 } | |
| 1486 | |
| 1487 const GList * | |
| 1488 gaim_account_get_status_types(const GaimAccount *account) | |
| 1489 { | |
| 1490 g_return_val_if_fail(account != NULL, NULL); | |
| 1491 | |
| 1492 return account->status_types; | |
| 1493 } | |
| 1494 | |
| 5563 | 1495 int |
|
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1496 gaim_account_get_int(const GaimAccount *account, const char *name, |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1497 int default_value) |
| 5563 | 1498 { |
| 1499 GaimAccountSetting *setting; | |
| 1500 | |
|
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1501 g_return_val_if_fail(account != NULL, default_value); |
|
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1502 g_return_val_if_fail(name != NULL, default_value); |
| 5563 | 1503 |
| 1504 setting = g_hash_table_lookup(account->settings, name); | |
| 1505 | |
|
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1506 if (setting == NULL) |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1507 return default_value; |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1508 |
|
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1509 g_return_val_if_fail(setting->type == GAIM_PREF_INT, default_value); |
| 5563 | 1510 |
| 1511 return setting->value.integer; | |
| 1512 } | |
| 1513 | |
| 1514 const char * | |
|
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1515 gaim_account_get_string(const GaimAccount *account, const char *name, |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1516 const char *default_value) |
| 5563 | 1517 { |
| 1518 GaimAccountSetting *setting; | |
| 1519 | |
|
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1520 g_return_val_if_fail(account != NULL, default_value); |
|
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1521 g_return_val_if_fail(name != NULL, default_value); |
| 5563 | 1522 |
| 1523 setting = g_hash_table_lookup(account->settings, name); | |
| 1524 | |
|
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1525 if (setting == NULL) |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1526 return default_value; |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1527 |
|
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1528 g_return_val_if_fail(setting->type == GAIM_PREF_STRING, default_value); |
| 5563 | 1529 |
| 1530 return setting->value.string; | |
| 1531 } | |
| 1532 | |
| 1533 gboolean | |
|
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1534 gaim_account_get_bool(const GaimAccount *account, const char *name, |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1535 gboolean default_value) |
| 5563 | 1536 { |
| 1537 GaimAccountSetting *setting; | |
| 1538 | |
|
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1539 g_return_val_if_fail(account != NULL, default_value); |
|
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1540 g_return_val_if_fail(name != NULL, default_value); |
| 5563 | 1541 |
| 1542 setting = g_hash_table_lookup(account->settings, name); | |
| 1543 | |
|
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1544 if (setting == NULL) |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1545 return default_value; |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1546 |
|
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1547 g_return_val_if_fail(setting->type == GAIM_PREF_BOOLEAN, default_value); |
| 5563 | 1548 |
| 1549 return setting->value.bool; | |
| 1550 } | |
| 1551 | |
|
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1552 int |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1553 gaim_account_get_ui_int(const GaimAccount *account, const char *ui, |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1554 const char *name, int default_value) |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1555 { |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1556 GaimAccountSetting *setting; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1557 GHashTable *table; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1558 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1559 g_return_val_if_fail(account != NULL, default_value); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1560 g_return_val_if_fail(ui != NULL, default_value); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1561 g_return_val_if_fail(name != NULL, default_value); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1562 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1563 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1564 return default_value; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1565 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1566 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1567 return default_value; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1568 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1569 g_return_val_if_fail(setting->type == GAIM_PREF_INT, default_value); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1570 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1571 return setting->value.integer; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1572 } |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1573 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1574 const char * |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1575 gaim_account_get_ui_string(const GaimAccount *account, const char *ui, |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1576 const char *name, const char *default_value) |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1577 { |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1578 GaimAccountSetting *setting; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1579 GHashTable *table; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1580 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1581 g_return_val_if_fail(account != NULL, default_value); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1582 g_return_val_if_fail(ui != NULL, default_value); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1583 g_return_val_if_fail(name != NULL, default_value); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1584 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1585 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1586 return default_value; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1587 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1588 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1589 return default_value; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1590 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1591 g_return_val_if_fail(setting->type == GAIM_PREF_STRING, default_value); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1592 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1593 return setting->value.string; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1594 } |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1595 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1596 gboolean |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1597 gaim_account_get_ui_bool(const GaimAccount *account, const char *ui, |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1598 const char *name, gboolean default_value) |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1599 { |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1600 GaimAccountSetting *setting; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1601 GHashTable *table; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1602 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1603 g_return_val_if_fail(account != NULL, default_value); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1604 g_return_val_if_fail(ui != NULL, default_value); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1605 g_return_val_if_fail(name != NULL, default_value); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1606 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1607 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1608 return default_value; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1609 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1610 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1611 return default_value; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1612 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1613 g_return_val_if_fail(setting->type == GAIM_PREF_BOOLEAN, default_value); |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1614 |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1615 return setting->value.bool; |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1616 } |
|
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1617 |
| 8573 | 1618 GaimLog * |
| 1619 gaim_account_get_log(GaimAccount *account) | |
| 1620 { | |
| 1621 g_return_val_if_fail(account != NULL, NULL); | |
| 1622 | |
| 1623 if(!account->system_log){ | |
| 8658 | 1624 GaimConnection *gc; |
| 1625 | |
| 1626 gc = gaim_account_get_connection(account); | |
| 1627 | |
| 8635 | 1628 account->system_log = gaim_log_new(GAIM_LOG_SYSTEM, |
| 1629 gaim_account_get_username(account), account, | |
| 8658 | 1630 gc != NULL ? gc->login_time : time(NULL)); |
| 8573 | 1631 } |
| 1632 | |
| 1633 return account->system_log; | |
| 1634 } | |
| 1635 | |
| 1636 void | |
| 1637 gaim_account_destroy_log(GaimAccount *account) | |
| 1638 { | |
| 1639 g_return_if_fail(account != NULL); | |
| 1640 | |
| 1641 if(account->system_log){ | |
| 1642 gaim_log_free(account->system_log); | |
| 1643 account->system_log = NULL; | |
| 1644 } | |
| 1645 } | |
| 1646 | |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1647 void |
|
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1648 gaim_accounts_add(GaimAccount *account) |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1649 { |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1650 g_return_if_fail(account != NULL); |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1651 |
|
5867
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
1652 if (g_list_find(accounts, account) != NULL) |
|
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
1653 return; |
|
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
1654 |
|
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1655 accounts = g_list_append(accounts, account); |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1656 |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1657 schedule_accounts_save(); |
| 8134 | 1658 |
| 1659 gaim_signal_emit(gaim_accounts_get_handle(), "account-added", account); | |
|
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1660 } |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1661 |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1662 void |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1663 gaim_accounts_remove(GaimAccount *account) |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1664 { |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1665 g_return_if_fail(account != NULL); |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1666 |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1667 accounts = g_list_remove(accounts, account); |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1668 |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1669 schedule_accounts_save(); |
| 8134 | 1670 |
| 1671 gaim_signal_emit(gaim_accounts_get_handle(), "account-removed", account); | |
|
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1672 } |
|
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1673 |
|
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1674 void |
|
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1675 gaim_accounts_delete(GaimAccount *account) |
|
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1676 { |
| 6695 | 1677 GaimBlistNode *gnode, *cnode, *bnode; |
|
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1678 |
|
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1679 g_return_if_fail(account != NULL); |
|
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1680 |
| 10758 | 1681 gaim_notify_close_with_handle(account); |
| 1682 gaim_request_close_with_handle(account); | |
| 1683 | |
|
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1684 gaim_accounts_remove(account); |
|
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1685 |
| 8235 | 1686 /* Remove this account's buddies */ |
|
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1687 for (gnode = gaim_get_blist()->root; gnode != NULL; gnode = gnode->next) { |
|
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1688 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
|
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1689 continue; |
|
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1690 |
|
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1691 cnode = gnode->child; |
|
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1692 while (cnode) { |
|
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1693 GaimBlistNode *cnode_next = cnode->next; |
|
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1694 |
| 6695 | 1695 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { |
|
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1696 bnode = cnode->child; |
|
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1697 while (bnode) { |
|
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1698 GaimBlistNode *bnode_next = bnode->next; |
|
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1699 |
| 6695 | 1700 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) { |
| 1701 GaimBuddy *b = (GaimBuddy *)bnode; | |
|
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1702 |
| 6695 | 1703 if (b->account == account) |
| 1704 gaim_blist_remove_buddy(b); | |
| 1705 } | |
|
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1706 bnode = bnode_next; |
| 6695 | 1707 } |
| 1708 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
1709 GaimChat *c = (GaimChat *)cnode; |
|
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1710 |
|
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1711 if (c->account == account) |
|
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1712 gaim_blist_remove_chat(c); |
|
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1713 } |
|
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1714 cnode = cnode_next; |
|
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1715 } |
|
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1716 } |
|
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1717 |
| 8235 | 1718 /* Remove this account's pounces */ |
| 1719 gaim_pounce_destroy_all_by_account(account); | |
|
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1720 |
|
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1721 gaim_account_destroy(account); |
|
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1722 } |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1723 |
|
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1724 void |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1725 gaim_accounts_reorder(GaimAccount *account, size_t new_index) |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1726 { |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1727 size_t index; |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1728 GList *l; |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1729 |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1730 g_return_if_fail(account != NULL); |
|
5620
c9724982ce45
[gaim-migrate @ 6027]
Christian Hammond <chipx86@chipx86.com>
parents:
5610
diff
changeset
|
1731 g_return_if_fail(new_index >= 0 && new_index <= g_list_length(accounts)); |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1732 |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1733 index = g_list_index(accounts, account); |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1734 |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1735 if (index == -1) { |
| 10760 | 1736 gaim_debug_error("account", |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1737 "Unregistered account (%s) discovered during reorder!\n", |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1738 gaim_account_get_username(account)); |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1739 return; |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1740 } |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1741 |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1742 l = g_list_nth(accounts, index); |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1743 |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1744 if (new_index > index) |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1745 new_index--; |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1746 |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1747 /* Remove the old one. */ |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1748 accounts = g_list_delete_link(accounts, l); |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1749 |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1750 /* Insert it where it should go. */ |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1751 accounts = g_list_insert(accounts, account, new_index); |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1752 |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1753 schedule_accounts_save(); |
|
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1754 } |
|
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1755 |
| 5563 | 1756 GList * |
| 1757 gaim_accounts_get_all(void) | |
| 1758 { | |
| 1759 return accounts; | |
| 1760 } | |
|
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1761 |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1762 GaimAccount * |
| 7132 | 1763 gaim_accounts_find(const char *name, const char *protocol_id) |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1764 { |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1765 GaimAccount *account = NULL; |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1766 GList *l; |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1767 char *who; |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1768 |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1769 g_return_val_if_fail(name != NULL, NULL); |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1770 |
| 7261 | 1771 who = g_strdup(gaim_normalize(NULL, name)); |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1772 |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1773 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1774 account = (GaimAccount *)l->data; |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1775 |
| 7261 | 1776 if (!strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who) && |
| 7132 | 1777 (!protocol_id || !strcmp(account->protocol_id, protocol_id))) { |
|
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1778 |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1779 break; |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1780 } |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1781 |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1782 account = NULL; |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1783 } |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1784 |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1785 g_free(who); |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1786 |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1787 return account; |
|
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1788 } |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1789 |
|
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1790 void |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1791 gaim_accounts_set_ui_ops(GaimAccountUiOps *ops) |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1792 { |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1793 account_ui_ops = ops; |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1794 } |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1795 |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1796 GaimAccountUiOps * |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1797 gaim_accounts_get_ui_ops(void) |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1798 { |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1799 return account_ui_ops; |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1800 } |
|
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1801 |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1802 void * |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1803 gaim_accounts_get_handle(void) |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1804 { |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1805 static int handle; |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1806 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1807 return &handle; |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1808 } |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1809 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1810 void |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1811 gaim_accounts_init(void) |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1812 { |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1813 void *handle = gaim_accounts_get_handle(); |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1814 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1815 gaim_signal_register(handle, "account-connecting", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1816 gaim_marshal_VOID__POINTER, NULL, 1, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1817 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1818 GAIM_SUBTYPE_ACCOUNT)); |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1819 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1820 gaim_signal_register(handle, "account-away", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1821 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1822 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1823 GAIM_SUBTYPE_ACCOUNT), |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1824 gaim_value_new(GAIM_TYPE_STRING), |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1825 gaim_value_new(GAIM_TYPE_STRING)); |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1826 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1827 gaim_signal_register(handle, "account-setting-info", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1828 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1829 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1830 GAIM_SUBTYPE_ACCOUNT), |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1831 gaim_value_new(GAIM_TYPE_STRING)); |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1832 |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1833 gaim_signal_register(handle, "account-set-info", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1834 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1835 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1836 GAIM_SUBTYPE_ACCOUNT), |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1837 gaim_value_new(GAIM_TYPE_STRING)); |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1838 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1839 gaim_signal_register(handle, "account-warned", |
|
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1840 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1841 gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1842 GAIM_SUBTYPE_ACCOUNT), |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1843 gaim_value_new(GAIM_TYPE_STRING), |
|
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1844 gaim_value_new(GAIM_TYPE_UINT)); |
| 8134 | 1845 |
| 1846 gaim_signal_register(handle, "account-added", | |
| 10447 | 1847 gaim_marshal_VOID__POINTER, NULL, 1, |
| 1848 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT)); | |
| 8134 | 1849 |
| 1850 gaim_signal_register(handle, "account-removed", | |
| 10447 | 1851 gaim_marshal_VOID__POINTER, NULL, 1, |
| 1852 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT)); | |
| 10490 | 1853 |
| 1854 load_accounts(); | |
| 1855 | |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1856 } |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1857 |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1858 void |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1859 gaim_accounts_uninit(void) |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1860 { |
| 10428 | 1861 if (save_timer != 0) |
| 10427 | 1862 { |
| 10428 | 1863 gaim_timeout_remove(save_timer); |
| 1864 save_timer = 0; | |
| 10427 | 1865 sync_accounts(); |
| 8235 | 1866 } |
| 1867 | |
|
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1868 gaim_signals_unregister_by_instance(gaim_accounts_get_handle()); |
|
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1869 } |
