| 134 GtkWidget *proxy_host_entry; |
134 GtkWidget *proxy_host_entry; |
| 135 GtkWidget *proxy_port_entry; |
135 GtkWidget *proxy_port_entry; |
| 136 GtkWidget *proxy_user_entry; |
136 GtkWidget *proxy_user_entry; |
| 137 GtkWidget *proxy_pass_entry; |
137 GtkWidget *proxy_pass_entry; |
| 138 |
138 |
| 139 /* Are we registering? */ |
|
| 140 gboolean registering; |
|
| 141 |
|
| 142 } AccountPrefsDialog; |
139 } AccountPrefsDialog; |
| 143 |
140 |
| 144 typedef struct |
141 typedef struct |
| 145 { |
142 { |
| 146 GdkPixbuf *online_pixbuf; |
143 GdkPixbuf *online_pixbuf; |
| 1145 cancel_account_prefs_cb(GtkWidget *w, AccountPrefsDialog *dialog) |
1142 cancel_account_prefs_cb(GtkWidget *w, AccountPrefsDialog *dialog) |
| 1146 { |
1143 { |
| 1147 account_win_destroy_cb(NULL, NULL, dialog); |
1144 account_win_destroy_cb(NULL, NULL, dialog); |
| 1148 } |
1145 } |
| 1149 |
1146 |
| 1150 static PurpleAccount* |
1147 static void |
| 1151 ok_account_prefs_cb(GtkWidget *w, AccountPrefsDialog *dialog) |
1148 ok_account_prefs_cb(GtkWidget *w, AccountPrefsDialog *dialog) |
| 1152 { |
1149 { |
| 1153 PurpleProxyInfo *proxy_info = NULL; |
1150 PurpleProxyInfo *proxy_info = NULL; |
| 1154 GList *l, *l2; |
1151 GList *l, *l2; |
| 1155 const char *value; |
1152 const char *value; |
| 1156 char *username; |
1153 char *username; |
| 1157 char *tmp; |
1154 char *tmp; |
| 1158 gboolean new = FALSE, icon_change = FALSE; |
1155 gboolean new_acct = FALSE, icon_change = FALSE; |
| 1159 PurpleAccount *account; |
1156 PurpleAccount *account; |
| 1160 PurplePluginProtocolInfo *prpl_info; |
1157 PurplePluginProtocolInfo *prpl_info; |
| 1161 |
1158 |
| |
1159 /* Build the username string. */ |
| |
1160 username = g_strdup(gtk_entry_get_text(GTK_ENTRY(dialog->screenname_entry))); |
| |
1161 |
| |
1162 if (dialog->prpl_info != NULL) |
| |
1163 { |
| |
1164 for (l = dialog->prpl_info->user_splits, |
| |
1165 l2 = dialog->user_split_entries; |
| |
1166 l != NULL && l2 != NULL; |
| |
1167 l = l->next, l2 = l2->next) |
| |
1168 { |
| |
1169 PurpleAccountUserSplit *split = l->data; |
| |
1170 GtkEntry *entry = l2->data; |
| |
1171 char sep[2] = " "; |
| |
1172 |
| |
1173 value = gtk_entry_get_text(entry); |
| |
1174 |
| |
1175 *sep = purple_account_user_split_get_separator(split); |
| |
1176 |
| |
1177 tmp = g_strconcat(username, sep, |
| |
1178 (*value ? value : |
| |
1179 purple_account_user_split_get_default_value(split)), |
| |
1180 NULL); |
| |
1181 |
| |
1182 g_free(username); |
| |
1183 username = tmp; |
| |
1184 } |
| |
1185 } |
| |
1186 |
| 1162 if (dialog->account == NULL) |
1187 if (dialog->account == NULL) |
| 1163 { |
1188 { |
| 1164 const char *screenname; |
1189 if (purple_accounts_find(username, dialog->protocol_id) != NULL) { |
| |
1190 purple_debug_warning("gtkaccount", "Trying to add a duplicate %s account (%s).\n", |
| |
1191 dialog->protocol_id, username); |
| |
1192 |
| |
1193 purple_notify_error(NULL, NULL, _("Unable to save new account"), |
| |
1194 _("An account already exists with the specified criteria.")); |
| |
1195 |
| |
1196 g_free(username); |
| |
1197 return; |
| |
1198 } |
| 1165 |
1199 |
| 1166 if (purple_accounts_get_all() == NULL) { |
1200 if (purple_accounts_get_all() == NULL) { |
| 1167 /* We're adding our first account. Be polite and show the buddy list */ |
1201 /* We're adding our first account. Be polite and show the buddy list */ |
| 1168 purple_blist_set_visible(TRUE); |
1202 purple_blist_set_visible(TRUE); |
| 1169 } |
1203 } |
| 1170 |
1204 |
| 1171 screenname = gtk_entry_get_text(GTK_ENTRY(dialog->screenname_entry)); |
1205 account = purple_account_new(username, dialog->protocol_id); |
| 1172 account = purple_account_new(screenname, dialog->protocol_id); |
1206 new_acct = TRUE; |
| 1173 new = TRUE; |
|
| 1174 } |
1207 } |
| 1175 else |
1208 else |
| 1176 { |
1209 { |
| 1177 account = dialog->account; |
1210 account = dialog->account; |
| 1178 |
1211 |
| 1192 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(dialog->plugin); |
1225 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(dialog->plugin); |
| 1193 if (prpl_info != NULL && prpl_info->icon_spec.format != NULL) |
1226 if (prpl_info != NULL && prpl_info->icon_spec.format != NULL) |
| 1194 { |
1227 { |
| 1195 const char *filename; |
1228 const char *filename; |
| 1196 |
1229 |
| 1197 if (new || purple_account_get_bool(account, "use-global-buddyicon", TRUE) == |
1230 if (new_acct || purple_account_get_bool(account, "use-global-buddyicon", TRUE) == |
| 1198 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))) |
1231 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))) |
| 1199 { |
1232 { |
| 1200 icon_change = TRUE; |
1233 icon_change = TRUE; |
| 1201 } |
1234 } |
| 1202 purple_account_set_bool(account, "use-global-buddyicon", !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))); |
1235 purple_account_set_bool(account, "use-global-buddyicon", !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check))); |
| 1245 * We set the password if this is a new account because new accounts |
1278 * We set the password if this is a new account because new accounts |
| 1246 * will be set to online, and if the user has entered a password into |
1279 * will be set to online, and if the user has entered a password into |
| 1247 * the account editor (but has not checked the 'save' box), then we |
1280 * the account editor (but has not checked the 'save' box), then we |
| 1248 * don't want to prompt them. |
1281 * don't want to prompt them. |
| 1249 */ |
1282 */ |
| 1250 if ((purple_account_get_remember_password(account) || new) && (*value != '\0')) |
1283 if ((purple_account_get_remember_password(account) || new_acct) && (*value != '\0')) |
| 1251 purple_account_set_password(account, value); |
1284 purple_account_set_password(account, value); |
| 1252 else |
1285 else |
| 1253 purple_account_set_password(account, NULL); |
1286 purple_account_set_password(account, NULL); |
| 1254 |
|
| 1255 /* Build the username string. */ |
|
| 1256 username = |
|
| 1257 g_strdup(gtk_entry_get_text(GTK_ENTRY(dialog->screenname_entry))); |
|
| 1258 |
|
| 1259 if (dialog->prpl_info != NULL) |
|
| 1260 { |
|
| 1261 for (l = dialog->prpl_info->user_splits, |
|
| 1262 l2 = dialog->user_split_entries; |
|
| 1263 l != NULL && l2 != NULL; |
|
| 1264 l = l->next, l2 = l2->next) |
|
| 1265 { |
|
| 1266 PurpleAccountUserSplit *split = l->data; |
|
| 1267 GtkEntry *entry = l2->data; |
|
| 1268 char sep[2] = " "; |
|
| 1269 |
|
| 1270 value = gtk_entry_get_text(entry); |
|
| 1271 |
|
| 1272 *sep = purple_account_user_split_get_separator(split); |
|
| 1273 |
|
| 1274 tmp = g_strconcat(username, sep, |
|
| 1275 (*value ? value : |
|
| 1276 purple_account_user_split_get_default_value(split)), |
|
| 1277 NULL); |
|
| 1278 |
|
| 1279 g_free(username); |
|
| 1280 username = tmp; |
|
| 1281 } |
|
| 1282 } |
|
| 1283 |
1287 |
| 1284 purple_account_set_username(account, username); |
1288 purple_account_set_username(account, username); |
| 1285 g_free(username); |
1289 g_free(username); |
| 1286 |
1290 |
| 1287 /* Add the protocol settings */ |
1291 /* Add the protocol settings */ |
| 1387 purple_account_set_proxy_info(account, NULL); |
1391 purple_account_set_proxy_info(account, NULL); |
| 1388 proxy_info = NULL; |
1392 proxy_info = NULL; |
| 1389 } |
1393 } |
| 1390 |
1394 |
| 1391 /* If this is a new account, add it to our list */ |
1395 /* If this is a new account, add it to our list */ |
| 1392 if (new) |
1396 if (new_acct) |
| 1393 purple_accounts_add(account); |
1397 purple_accounts_add(account); |
| 1394 else |
1398 else |
| 1395 purple_signal_emit(pidgin_account_get_handle(), "account-modified", account); |
1399 purple_signal_emit(pidgin_account_get_handle(), "account-modified", account); |
| 1396 |
1400 |
| 1397 /* If this is a new account, then sign on! */ |
1401 /* If this is a new account, then sign on! */ |
| 1398 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->register_button))) { |
1402 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->register_button))) { |
| 1399 purple_account_register(account); |
1403 purple_account_register(account); |
| 1400 } else if (new) { |
1404 } else if (new_acct) { |
| 1401 const PurpleSavedStatus *saved_status; |
1405 const PurpleSavedStatus *saved_status; |
| 1402 |
1406 |
| 1403 saved_status = purple_savedstatus_get_current(); |
1407 saved_status = purple_savedstatus_get_current(); |
| 1404 if (saved_status != NULL) { |
1408 if (saved_status != NULL) { |
| 1405 purple_savedstatus_activate_for_account(saved_status, account); |
1409 purple_savedstatus_activate_for_account(saved_status, account); |
| 1408 } |
1412 } |
| 1409 |
1413 |
| 1410 /* We no longer need the data from the dialog window */ |
1414 /* We no longer need the data from the dialog window */ |
| 1411 account_win_destroy_cb(NULL, NULL, dialog); |
1415 account_win_destroy_cb(NULL, NULL, dialog); |
| 1412 |
1416 |
| 1413 return account; |
|
| 1414 } |
1417 } |
| 1415 |
1418 |
| 1416 static const GtkTargetEntry dnd_targets[] = { |
1419 static const GtkTargetEntry dnd_targets[] = { |
| 1417 {"text/plain", 0, 0}, |
1420 {"text/plain", 0, 0}, |
| 1418 {"text/uri-list", 0, 1}, |
1421 {"text/uri-list", 0, 1}, |