gtk/gtkaccount.c

changeset 15041
18a6f6cdce33
parent 14921
6db4b2320423
child 15053
6b35684275a6
equal deleted inserted replaced
15040:433e06134a7b 15041:18a6f6cdce33
1002 1002
1003 if (dialog->account != NULL && 1003 if (dialog->account != NULL &&
1004 (proxy_info = gaim_account_get_proxy_info(dialog->account)) != NULL) { 1004 (proxy_info = gaim_account_get_proxy_info(dialog->account)) != NULL) {
1005 1005
1006 GaimProxyType type = gaim_proxy_info_get_type(proxy_info); 1006 GaimProxyType type = gaim_proxy_info_get_type(proxy_info);
1007 const char *value;
1008 int int_val;
1007 1009
1008 /* Hah! */ 1010 /* Hah! */
1009 /* I dunno what you're laughing about, fuzz ball. */ 1011 /* I dunno what you're laughing about, fuzz ball. */
1010 dialog->new_proxy_type = type; 1012 dialog->new_proxy_type = type;
1011 gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->proxy_dropdown), 1013 gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->proxy_dropdown),
1012 type + 1); 1014 type + 1);
1013 1015
1014 if (type == GAIM_PROXY_USE_GLOBAL || type == GAIM_PROXY_NONE || 1016 if (type == GAIM_PROXY_USE_GLOBAL || type == GAIM_PROXY_NONE ||
1015 type == GAIM_PROXY_USE_ENVVAR) { 1017 type == GAIM_PROXY_USE_ENVVAR)
1016 gtk_widget_hide_all(vbox2); 1018 gtk_widget_hide_all(vbox2);
1019
1020
1021 if ((value = gaim_proxy_info_get_host(proxy_info)) != NULL)
1022 gtk_entry_set_text(GTK_ENTRY(dialog->proxy_host_entry), value);
1023
1024 if ((int_val = gaim_proxy_info_get_port(proxy_info)) != 0) {
1025 char buf[11];
1026
1027 g_snprintf(buf, sizeof(buf), "%d", int_val);
1028
1029 gtk_entry_set_text(GTK_ENTRY(dialog->proxy_port_entry), buf);
1017 } 1030 }
1018 else { 1031
1019 const char *value; 1032 if ((value = gaim_proxy_info_get_username(proxy_info)) != NULL)
1020 int int_val; 1033 gtk_entry_set_text(GTK_ENTRY(dialog->proxy_user_entry), value);
1021 1034
1022 if ((value = gaim_proxy_info_get_host(proxy_info)) != NULL) 1035 if ((value = gaim_proxy_info_get_password(proxy_info)) != NULL)
1023 gtk_entry_set_text(GTK_ENTRY(dialog->proxy_host_entry), value); 1036 gtk_entry_set_text(GTK_ENTRY(dialog->proxy_pass_entry), value);
1024
1025 if ((int_val = gaim_proxy_info_get_port(proxy_info)) != 0) {
1026 char buf[32];
1027
1028 g_snprintf(buf, sizeof(buf), "%d", int_val);
1029
1030 gtk_entry_set_text(GTK_ENTRY(dialog->proxy_port_entry), buf);
1031 }
1032
1033 if ((value = gaim_proxy_info_get_username(proxy_info)) != NULL)
1034 gtk_entry_set_text(GTK_ENTRY(dialog->proxy_user_entry), value);
1035
1036 if ((value = gaim_proxy_info_get_password(proxy_info)) != NULL)
1037 gtk_entry_set_text(GTK_ENTRY(dialog->proxy_pass_entry), value);
1038 }
1039 } 1037 }
1040 else { 1038 else {
1041 dialog->new_proxy_type = GAIM_PROXY_USE_GLOBAL; 1039 dialog->new_proxy_type = GAIM_PROXY_USE_GLOBAL;
1042 gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->proxy_dropdown), 1040 gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->proxy_dropdown),
1043 dialog->new_proxy_type + 1); 1041 dialog->new_proxy_type + 1);
1256 } 1254 }
1257 } 1255 }
1258 } 1256 }
1259 1257
1260 /* Set the proxy stuff. */ 1258 /* Set the proxy stuff. */
1261 if (dialog->new_proxy_type == GAIM_PROXY_USE_GLOBAL) { 1259 proxy_info = gaim_account_get_proxy_info(account);
1260
1261 /* Create the proxy info if it doesn't exist. */
1262 if (proxy_info == NULL) {
1263 proxy_info = gaim_proxy_info_new();
1264 gaim_account_set_proxy_info(account, proxy_info);
1265 }
1266
1267 /* Set the proxy info type. */
1268 gaim_proxy_info_set_type(proxy_info, dialog->new_proxy_type);
1269
1270 /* Host */
1271 value = gtk_entry_get_text(GTK_ENTRY(dialog->proxy_host_entry));
1272
1273 if (*value != '\0')
1274 gaim_proxy_info_set_host(proxy_info, value);
1275 else
1276 gaim_proxy_info_set_host(proxy_info, NULL);
1277
1278 /* Port */
1279 value = gtk_entry_get_text(GTK_ENTRY(dialog->proxy_port_entry));
1280
1281 if (*value != '\0')
1282 gaim_proxy_info_set_port(proxy_info, atoi(value));
1283 else
1284 gaim_proxy_info_set_port(proxy_info, 0);
1285
1286 /* Username */
1287 value = gtk_entry_get_text(GTK_ENTRY(dialog->proxy_user_entry));
1288
1289 if (*value != '\0')
1290 gaim_proxy_info_set_username(proxy_info, value);
1291 else
1292 gaim_proxy_info_set_username(proxy_info, NULL);
1293
1294 /* Password */
1295 value = gtk_entry_get_text(GTK_ENTRY(dialog->proxy_pass_entry));
1296
1297 if (*value != '\0')
1298 gaim_proxy_info_set_password(proxy_info, value);
1299 else
1300 gaim_proxy_info_set_password(proxy_info, NULL);
1301
1302 /* If there are no values set then proxy_info NULL */
1303 if ((gaim_proxy_info_get_type(proxy_info) == GAIM_PROXY_USE_GLOBAL) &&
1304 (gaim_proxy_info_get_host(proxy_info) == NULL) &&
1305 (gaim_proxy_info_get_port(proxy_info) == 0) &&
1306 (gaim_proxy_info_get_username(proxy_info) == NULL) &&
1307 (gaim_proxy_info_get_password(proxy_info) == NULL))
1308 {
1262 gaim_account_set_proxy_info(account, NULL); 1309 gaim_account_set_proxy_info(account, NULL);
1263 } 1310 proxy_info = NULL;
1264 else { 1311 }
1265 proxy_info = gaim_account_get_proxy_info(account); 1312
1266
1267 /* Create the proxy info if it doesn't exist. */
1268 if (proxy_info == NULL) {
1269 proxy_info = gaim_proxy_info_new();
1270 gaim_account_set_proxy_info(account, proxy_info);
1271 }
1272
1273 /* Set the proxy info type. */
1274 gaim_proxy_info_set_type(proxy_info, dialog->new_proxy_type);
1275
1276 /* Host */
1277 value = gtk_entry_get_text(GTK_ENTRY(dialog->proxy_host_entry));
1278
1279 if (*value != '\0')
1280 gaim_proxy_info_set_host(proxy_info, value);
1281 else
1282 gaim_proxy_info_set_host(proxy_info, NULL);
1283
1284 /* Port */
1285 value = gtk_entry_get_text(GTK_ENTRY(dialog->proxy_port_entry));
1286
1287 if (*value != '\0')
1288 gaim_proxy_info_set_port(proxy_info, atoi(value));
1289 else
1290 gaim_proxy_info_set_port(proxy_info, 0);
1291
1292 /* Username */
1293 value = gtk_entry_get_text(GTK_ENTRY(dialog->proxy_user_entry));
1294
1295 if (*value != '\0')
1296 gaim_proxy_info_set_username(proxy_info, value);
1297 else
1298 gaim_proxy_info_set_username(proxy_info, NULL);
1299
1300 /* Password */
1301 value = gtk_entry_get_text(GTK_ENTRY(dialog->proxy_pass_entry));
1302
1303 if (*value != '\0')
1304 gaim_proxy_info_set_password(proxy_info, value);
1305 else
1306 gaim_proxy_info_set_password(proxy_info, NULL);
1307 }
1308 1313
1309 /* We no longer need the data from the dialog window */ 1314 /* We no longer need the data from the dialog window */
1310 account_win_destroy_cb(NULL, NULL, dialog); 1315 account_win_destroy_cb(NULL, NULL, dialog);
1311 1316
1312 /* If this is a new account, add it to our list */ 1317 /* If this is a new account, add it to our list */

mercurial