#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include <liberregxml/erregapi.h>
#include "connectionMgrLog.h"
#include "connectionMgr.h"
#include "displayStatus.h"
#include "erbusy.h"
#include "background.h"
#include "gtkSettingItem.h"
#include "gtkInfoItem.h"
#include "editScreen.h"
#include "editScreenOverview.h"
#include "widgetUtils.h"
#include "editScreenProxy.h"
#include "languages.h"
Go to the source code of this file.
Enumerations | |
enum | proxyStatus_t { inputHost_e = 0, inputPort_e, undefStatus_e } |
Functions | |
static void | edit_proxy_set_host (const char *proxyhost) |
static void | edit_proxy_set_port (const char *proxyport) |
static const char * | edit_proxy_get_host (void) |
static const char * | edit_proxy_get_port (void) |
static void | edit_proxy_backup_network_settings (void) |
static void | on_next (GtkToggleButton *button, gpointer data) |
GtkWidget * | edit_proxy_create (void) |
void | edit_proxy_set_text (void) |
static proxyStatus_t | edit_proxy_detect_status (void) |
static void | edit_proxy_determine_status (void) |
void | edit_proxy_set_network_settings (const regNetworkProfile_t *settings) |
void | edit_proxy_set_title (const char *profilename) |
void | edit_proxy_get_network_settings (regNetworkProfile_t *settings) |
gboolean | edit_proxy_check_network_settings (void) |
void | edit_proxy_restore_network_settings (void) |
void | edit_proxy_screen_leave (void) |
static gboolean | on_delayed_next (gpointer data) |
gboolean | on_edit_proxy_keypress (GdkEventKey *event) |
Variables | |
static GtkWidget * | g_proxy = NULL |
static wdtLabelEntry * | g_host = NULL |
static wdtLabelEntry * | g_port = NULL |
static GtkWidget * | g_info = NULL |
static regProxySetting_t * | g_old_settings = NULL |
enum proxyStatus_t |
Definition at line 43 of file editScreenProxy.c.
00044 { 00045 inputHost_e = 0, 00046 inputPort_e, 00047 undefStatus_e 00048 }proxyStatus_t;
static void edit_proxy_backup_network_settings | ( | void | ) | [static] |
Definition at line 421 of file editScreenProxy.c.
00422 { 00423 const char *proxyhost, *proxyport; 00424 00425 CN_LOGPRINTF("entry"); 00426 00427 proxyhost = edit_proxy_get_host(); 00428 proxyport = edit_proxy_get_port(); 00429 00430 if (g_old_settings) 00431 { 00432 g_free(g_old_settings->address); 00433 g_free(g_old_settings->port); 00434 g_free(g_old_settings); 00435 } 00436 00437 g_old_settings = g_new0(regProxySetting_t, 1); 00438 g_assert(g_old_settings != NULL); 00439 g_old_settings->address = g_strdup(proxyhost); 00440 g_old_settings->port = g_strdup(proxyport); 00441 }
gboolean edit_proxy_check_network_settings | ( | void | ) |
Definition at line 404 of file editScreenProxy.c.
00405 { 00406 proxyStatus_t status; 00407 gboolean valid = TRUE; 00408 00409 CN_LOGPRINTF("entry"); 00410 00411 status = edit_proxy_detect_status(); 00412 if (status != undefStatus_e) 00413 { 00414 valid = FALSE; 00415 } 00416 00417 CN_LOGPRINTF("return valid=%d", valid); 00418 return valid; 00419 }
GtkWidget* edit_proxy_create | ( | void | ) |
Definition at line 81 of file editScreenProxy.c.
00082 { 00083 CN_LOGPRINTF("entry"); 00084 00085 GtkWidget *item = NULL; 00086 GtkWidget *topVbox = NULL; 00087 GtkWidget *background = NULL; 00088 GtkWidget *alignment = NULL; 00089 GtkWidget *vbox = NULL; 00090 wdtLabelEntry *host = NULL; 00091 wdtLabelEntry *port = NULL; 00092 GtkWidget *info = NULL; 00093 GtkWidget *widget = NULL; 00094 00095 CN_LOGPRINTF("entry"); 00096 00097 // item 00098 item = gtk_settingitem_new(""); 00099 00100 // topVbox 00101 topVbox = gtk_vbox_new(FALSE, VBOX_SPACING); 00102 gtk_settingitem_add_details(GTK_SETTINGITEM(item), topVbox); 00103 00104 // background 00105 background = gtk_event_box_new(); 00106 gtk_widget_set_name(background, "bk_grey_666_140"); 00107 gtk_widget_set_size_request(background, 00108 BK_666_140_WIDTH, BK_666_140_HEIGHT); 00109 gtk_box_pack_start(GTK_BOX(topVbox), background, FALSE, FALSE, 0); 00110 00111 // alignment 00112 alignment = gtk_alignment_new(0.0, 0.0, 0, 0); 00113 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 00114 PADDING_TOP, PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT); 00115 gtk_container_add(GTK_CONTAINER(background), alignment); 00116 00117 // vbox 00118 vbox = gtk_vbox_new(FALSE, VBOX_SPACING); 00119 gtk_container_add(GTK_CONTAINER(alignment), vbox); 00120 00121 // host 00122 host = wdt_label_entry_new(string_e); 00123 gtk_box_pack_start(GTK_BOX(vbox), host->parent, FALSE, FALSE, 0); 00124 00125 // port 00126 port = wdt_label_entry_new(integer_e); 00127 gtk_box_pack_start(GTK_BOX(vbox), port->parent, FALSE, FALSE, 0); 00128 00129 // info item 00130 info = gtk_infoitem_new(FALSE); 00131 gtk_box_pack_start(GTK_BOX(topVbox), info, FALSE, FALSE, 0); 00132 00133 // signal handlers 00134 widget = port->button; 00135 g_signal_connect_after(G_OBJECT(widget), "toggled", 00136 G_CALLBACK(on_next), NULL); 00137 00138 // show the widgets 00139 gtk_widget_show(item); 00140 gtk_widget_show(topVbox); 00141 gtk_widget_show(background); 00142 gtk_widget_show(alignment); 00143 gtk_widget_show(vbox); 00144 gtk_widget_show(host->parent); 00145 gtk_widget_hide(host->button); 00146 gtk_widget_show(port->parent); 00147 gtk_widget_show(info); 00148 00149 // global variables 00150 g_proxy = item; 00151 g_host = host; 00152 g_port = port; 00153 g_info = info; 00154 00155 CN_LOGPRINTF("done"); 00156 00157 // return 00158 return item; 00159 }
static proxyStatus_t edit_proxy_detect_status | ( | void | ) | [static] |
Definition at line 202 of file editScreenProxy.c.
00203 { 00204 proxyStatus_t status; 00205 00206 CN_LOGPRINTF("entry"); 00207 00208 if (!ergtk_entry_check_field(ERGTK_ENTRY(g_host->entry))) 00209 { 00210 status = inputHost_e; 00211 } 00212 else if (!ergtk_entry_check_field(ERGTK_ENTRY(g_port->entry))) 00213 { 00214 status = inputPort_e; 00215 } 00216 else 00217 { 00218 status = undefStatus_e; 00219 } 00220 00221 CN_LOGPRINTF("return %d", status); 00222 return status; 00223 }
static void edit_proxy_determine_status | ( | void | ) | [static] |
Definition at line 225 of file editScreenProxy.c.
00226 { 00227 proxyStatus_t status; 00228 GtkWidget *widget = NULL; 00229 00230 CN_LOGPRINTF("entry"); 00231 00232 status = edit_proxy_detect_status(); 00233 switch (status) 00234 { 00235 case inputHost_e: 00236 widget = g_host->entry; 00237 break; 00238 case inputPort_e: 00239 widget = g_port->entry; 00240 break; 00241 case undefStatus_e: 00242 widget = g_host->entry; 00243 break; 00244 default: 00245 break; 00246 } 00247 00248 if (widget) 00249 { 00250 gtk_widget_grab_focus(widget); 00251 } 00252 }
static const char * edit_proxy_get_host | ( | void | ) | [static] |
Definition at line 373 of file editScreenProxy.c.
00374 { 00375 GtkWidget *widget; 00376 const char *proxyhost = NULL; 00377 00378 if (g_host) 00379 { 00380 widget = g_host->entry; 00381 proxyhost = gtk_entry_get_text(GTK_ENTRY(widget)); 00382 } 00383 00384 CN_LOGPRINTF("return proxyhost=%s", proxyhost); 00385 return proxyhost; 00386 }
void edit_proxy_get_network_settings | ( | regNetworkProfile_t * | settings | ) |
Definition at line 334 of file editScreenProxy.c.
00335 { 00336 const gchar *proxyhost = NULL; 00337 const gchar *proxyport = NULL; 00338 regProxySetting_t *proxySettings = NULL; 00339 00340 CN_LOGPRINTF("entry [%p]", settings); 00341 00342 g_return_if_fail(settings != NULL); 00343 g_return_if_fail(settings->proxy == TRUE); 00344 00345 // clear proxy settings 00346 proxySettings = settings->proxySettings; 00347 if (proxySettings) 00348 { 00349 g_free(proxySettings->address); 00350 g_free(proxySettings->port); 00351 g_free(proxySettings); 00352 proxySettings = NULL; 00353 settings->proxySettings = NULL; 00354 } 00355 00356 // get current value from screen objects 00357 proxyhost = edit_proxy_get_host(); 00358 proxyport = edit_proxy_get_port(); 00359 00360 // store new settings, if proxy selected 00361 if (settings->proxy == TRUE) 00362 { 00363 proxySettings = g_new0(regProxySetting_t, 1); 00364 if (proxySettings) 00365 { 00366 proxySettings->address = g_strdup(proxyhost); 00367 proxySettings->port = g_strdup(proxyport); 00368 } 00369 settings->proxySettings = proxySettings; 00370 } 00371 }
static const char * edit_proxy_get_port | ( | void | ) | [static] |
Definition at line 388 of file editScreenProxy.c.
00389 { 00390 GtkWidget *widget; 00391 const char *proxyport = NULL; 00392 00393 if (g_port) 00394 { 00395 widget = g_port->entry; 00396 proxyport = gtk_entry_get_text(GTK_ENTRY(widget)); 00397 } 00398 00399 CN_LOGPRINTF("return proxyport=%s", proxyport); 00400 return proxyport; 00401 }
void edit_proxy_restore_network_settings | ( | void | ) |
Definition at line 443 of file editScreenProxy.c.
00444 { 00445 char *host = NULL; 00446 char *port = NULL; 00447 00448 CN_LOGPRINTF("entry"); 00449 00450 if (g_old_settings) 00451 { 00452 host = g_old_settings->address; 00453 port = g_old_settings->port; 00454 } 00455 00456 edit_proxy_set_host(host); 00457 edit_proxy_set_port(port); 00458 }
void edit_proxy_screen_leave | ( | void | ) |
Definition at line 460 of file editScreenProxy.c.
00461 { 00462 gboolean valid = TRUE; 00463 00464 CN_LOGPRINTF("entry"); 00465 00466 valid = edit_proxy_check_network_settings(); 00467 // force overview screen to no-proxy when proxy settings are empty 00468 if (!valid) 00469 { 00470 edit_overview_set_proxy(FALSE); 00471 } 00472 }
static void edit_proxy_set_host | ( | const char * | proxyhost | ) | [static] |
Definition at line 309 of file editScreenProxy.c.
00310 { 00311 GtkWidget *widget; 00312 00313 CN_LOGPRINTF("entry [%s]", proxyhost); 00314 00315 if (g_host) 00316 { 00317 widget = g_host->entry; 00318 gtk_entry_set_text(GTK_ENTRY(widget), proxyhost ? proxyhost : ""); 00319 } 00320 }
void edit_proxy_set_network_settings | ( | const regNetworkProfile_t * | settings | ) |
Definition at line 254 of file editScreenProxy.c.
00255 { 00256 char *profilename = NULL; 00257 char *proxyhost = NULL; 00258 char *proxyport = NULL; 00259 regProxySetting_t *proxySettings; 00260 00261 CN_LOGPRINTF("entry"); 00262 00263 g_return_if_fail(settings != NULL); 00264 // g_return_if_fail(settings->proxy == TRUE); 00265 00266 profilename = settings->name; 00267 00268 proxySettings = settings->proxySettings; 00269 if (proxySettings) 00270 { 00271 proxyhost = proxySettings->address; 00272 proxyport = proxySettings->port; 00273 } 00274 00275 edit_proxy_set_title(profilename); 00276 edit_proxy_set_host(proxyhost); 00277 edit_proxy_set_port(proxyport); 00278 00279 edit_proxy_determine_status(); 00280 00281 // a backup copy of settings 00282 edit_proxy_backup_network_settings(); 00283 }
static void edit_proxy_set_port | ( | const char * | proxyport | ) | [static] |
Definition at line 322 of file editScreenProxy.c.
00323 { 00324 GtkWidget *widget; 00325 00326 CN_LOGPRINTF("entry [%s]", proxyport); 00327 if (g_port) 00328 { 00329 widget = g_port->entry; 00330 gtk_entry_set_text(GTK_ENTRY(widget), proxyport ? proxyport: ""); 00331 } 00332 }
void edit_proxy_set_text | ( | void | ) |
Definition at line 161 of file editScreenProxy.c.
00162 { 00163 GtkWidget *widget = NULL; 00164 00165 CN_LOGPRINTF("entry"); 00166 00167 if (g_proxy) 00168 { 00169 gtk_settingitem_set_header_text(GTK_SETTINGITEM(g_proxy), 00170 _("Network profile")); 00171 } 00172 00173 if (g_host) 00174 { 00175 widget = g_host->label; 00176 gtk_label_set_text(GTK_LABEL(widget), 00177 _("Enter the name or address of the HTTP proxy server:")); 00178 00179 } 00180 00181 if (g_port) 00182 { 00183 widget = g_port->label; 00184 gtk_label_set_text(GTK_LABEL(widget), 00185 _("Enter the port number of the HTTP proxy server:")); 00186 widget = g_port->button; 00187 gtk_button_set_label(GTK_BUTTON(widget), _("Next")); 00188 } 00189 00190 if (g_info) 00191 { 00192 gtk_infoitem_set_text( GTK_INFOITEM(g_info), 00193 _("Do not include the protocol (e.g. http://) " 00194 "and proxy number (e.g. 8080) " 00195 "in the name or address of the HTTP proxy server.\n" 00196 "Hint: If you do not know the proxy settings " 00197 "for this network, " 00198 "please ask your network administrator.")); 00199 } 00200 }
void edit_proxy_set_title | ( | const char * | profilename | ) |
Definition at line 285 of file editScreenProxy.c.
00286 { 00287 char *title = NULL; 00288 00289 CN_LOGPRINTF("entry[%s]", profilename); 00290 00291 if (g_proxy) 00292 { 00293 if (profilename) 00294 { 00295 title = g_strdup_printf(_("Network profile: %s/proxy"), 00296 profilename); 00297 } 00298 else 00299 { 00300 title = g_strdup(_("Network profile: proxy")); 00301 } 00302 00303 gtk_settingitem_set_header_text(GTK_SETTINGITEM(g_proxy), title); 00304 00305 g_free(title); 00306 } 00307 }
static gboolean on_delayed_next | ( | gpointer | data | ) | [static] |
Definition at line 474 of file editScreenProxy.c.
00475 { 00476 gboolean valid; 00477 GtkToggleButton *button; 00478 00479 CN_LOGPRINTF("entry"); 00480 00481 erbusy_blink(); 00482 00483 valid = edit_proxy_check_network_settings(); 00484 if (valid) 00485 { 00486 edit_proxy_backup_network_settings(); 00487 edit_goto_page(editScreenOverview_e); 00488 } 00489 else 00490 { 00491 edit_proxy_determine_status(); 00492 } 00493 00494 button = GTK_TOGGLE_BUTTON(data); 00495 gtk_toggle_button_set_active(button, FALSE); 00496 00497 return FALSE; 00498 }
gboolean on_edit_proxy_keypress | ( | GdkEventKey * | event | ) |
Definition at line 513 of file editScreenProxy.c.
00514 { 00515 GtkToggleButton *button; 00516 gboolean ret = FALSE; 00517 00518 CN_LOGPRINTF("entry"); 00519 00520 switch (event->keyval) 00521 { 00522 case GDK_Return: 00523 // 'Enter' key is pressed 00524 // simulate clicking the 'Next' button 00525 if (g_port) 00526 { 00527 button = GTK_TOGGLE_BUTTON(g_port->button); 00528 gtk_toggle_button_set_active(button, TRUE); 00529 } 00530 ret = TRUE; 00531 break; 00532 00533 case GDK_F5: 00534 // 'UP' key is pressed 00535 // goto the one top level page 00536 cmgr_up_page(); 00537 ret = TRUE; 00538 break; 00539 00540 case GDK_Down: 00541 case GDK_Up: 00542 // avoid the standard GTK behaviour for GtkEntries 00543 erbusy_off(); 00544 ret = TRUE; 00545 00546 default: 00547 erbusy_off(); 00548 break; 00549 } 00550 00551 return ret; 00552 }
static void on_next | ( | GtkToggleButton * | button, | |
gpointer | data | |||
) | [static] |
Definition at line 500 of file editScreenProxy.c.
00501 { 00502 gboolean active; 00503 00504 CN_LOGPRINTF("entry"); 00505 00506 active = gtk_toggle_button_get_active(button); 00507 if (active) 00508 { 00509 g_timeout_add(500, on_delayed_next, button); 00510 } 00511 }
wdtLabelEntry* g_host = NULL [static] |
Definition at line 53 of file editScreenProxy.c.
GtkWidget* g_info = NULL [static] |
Definition at line 56 of file editScreenProxy.c.
regProxySetting_t* g_old_settings = NULL [static] |
Definition at line 59 of file editScreenProxy.c.
wdtLabelEntry* g_port = NULL [static] |
Definition at line 54 of file editScreenProxy.c.
GtkWidget* g_proxy = NULL [static] |
Definition at line 51 of file editScreenProxy.c.