#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 "editScreenStatic.h"
#include "languages.h"
Go to the source code of this file.
Copyright (C) 2007 iRex Technologies BV.
Definition in file editScreenStatic.c.
enum staticStatus_t |
Definition at line 44 of file editScreenStatic.c.
00045 { 00046 inputAddr_e = 0, 00047 inputNetmask_e, 00048 inputGateway_e, 00049 inputDns_e, 00050 undefStatus_e 00051 }staticStatus_t;
static void edit_static_backup_network_settings | ( | void | ) | [static] |
Definition at line 532 of file editScreenStatic.c.
00533 { 00534 const char *address, *netmask, *gateway, *dns; 00535 00536 CN_LOGPRINTF("entry"); 00537 00538 address = edit_static_get_address(); 00539 netmask = edit_static_get_netmask(); 00540 gateway = edit_static_get_gateway(); 00541 dns = edit_static_get_dns(); 00542 00543 if (g_old_settings) 00544 { 00545 g_free(g_old_settings->address); 00546 g_free(g_old_settings->netmask); 00547 g_free(g_old_settings->gateway); 00548 g_free(g_old_settings->dns); 00549 g_free(g_old_settings); 00550 } 00551 00552 g_old_settings = g_new0(regIpSetting_t, 1); 00553 g_assert(g_old_settings != NULL); 00554 g_old_settings->address = g_strdup(address); 00555 g_old_settings->netmask = g_strdup(netmask); 00556 g_old_settings->gateway = g_strdup(gateway); 00557 g_old_settings->dns = g_strdup(dns); 00558 }
gboolean edit_static_check_network_settings | ( | void | ) |
Definition at line 513 of file editScreenStatic.c.
00514 { 00515 staticStatus_t status; 00516 gboolean valid = TRUE; 00517 00518 CN_LOGPRINTF("entry"); 00519 00520 status = edit_static_detect_status(); 00521 if (status != undefStatus_e) 00522 { 00523 valid = FALSE; 00524 } 00525 00526 CN_LOGPRINTF("return valid=%d", valid); 00527 return valid; 00528 }
GtkWidget* edit_static_create | ( | void | ) |
Definition at line 93 of file editScreenStatic.c.
00094 { 00095 GtkWidget *item; 00096 GtkWidget *topVbox; 00097 GtkWidget *background; 00098 GtkWidget *alignment; 00099 GtkWidget *vbox; 00100 wdtLabelEntry *address; 00101 wdtLabelEntry *netmask; 00102 wdtLabelEntry *gateway; 00103 wdtLabelEntry *dns; 00104 GtkWidget *info; 00105 GtkWidget *widget; 00106 00107 CN_LOGPRINTF("entry"); 00108 00109 // item 00110 item = gtk_settingitem_new(""); 00111 00112 // topVbox 00113 topVbox = gtk_vbox_new(FALSE, VBOX_SPACING); 00114 gtk_settingitem_add_details(GTK_SETTINGITEM(item), topVbox); 00115 00116 // background 00117 background = gtk_event_box_new(); 00118 gtk_widget_set_name(background, "bk_grey_666_273"); 00119 gtk_widget_set_size_request(background, 00120 BK_666_273_WIDTH, BK_666_273_HEIGHT); 00121 gtk_box_pack_start(GTK_BOX(topVbox), background, FALSE, FALSE, 0); 00122 00123 // alignment 00124 alignment = gtk_alignment_new(0.0, 0.0, 0, 0); 00125 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 00126 PADDING_TOP, PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT); 00127 gtk_container_add(GTK_CONTAINER(background), alignment); 00128 00129 // vbox 00130 vbox = gtk_vbox_new(FALSE, VBOX_SPACING); 00131 gtk_container_add(GTK_CONTAINER(alignment), vbox); 00132 00133 // address 00134 address = wdt_label_entry_new(ipAddress_e); 00135 gtk_box_pack_start(GTK_BOX(vbox), address->parent, FALSE, FALSE, 0); 00136 00137 // netmask 00138 netmask = wdt_label_entry_new(ipAddress_e); 00139 gtk_box_pack_start(GTK_BOX(vbox), netmask->parent, FALSE, FALSE, 0); 00140 00141 // gateway 00142 gateway = wdt_label_entry_new(ipAddress_e); 00143 gtk_box_pack_start(GTK_BOX(vbox), gateway->parent, FALSE, FALSE, 0); 00144 00145 // dns 00146 dns = wdt_label_entry_new(ipAddress_e); 00147 gtk_box_pack_start(GTK_BOX(vbox), dns->parent, FALSE, FALSE, 0); 00148 00149 // info item 00150 info = gtk_infoitem_new(FALSE); 00151 gtk_box_pack_start(GTK_BOX(topVbox), info, FALSE, FALSE, 0); 00152 00153 // signal handlers 00154 widget = dns->button; 00155 g_signal_connect_after(G_OBJECT(widget), "toggled", 00156 G_CALLBACK(on_next), NULL); 00157 00158 // show the widgets 00159 gtk_widget_show(item); 00160 gtk_widget_show(topVbox); 00161 gtk_widget_show(background); 00162 gtk_widget_show(alignment); 00163 gtk_widget_show(vbox); 00164 gtk_widget_show(address->parent); 00165 gtk_widget_hide(address->button); 00166 gtk_widget_show(netmask->parent); 00167 gtk_widget_hide(netmask->button); 00168 gtk_widget_show(gateway->parent); 00169 gtk_widget_hide(gateway->button); 00170 gtk_widget_show(dns->parent); 00171 gtk_widget_show(info); 00172 00173 // set the global variables 00174 g_static = item; 00175 g_address = address; 00176 g_netmask = netmask; 00177 g_gateway = gateway; 00178 g_dns = dns; 00179 g_info = info; 00180 00181 CN_LOGPRINTF("done"); 00182 00183 // return 00184 return item; 00185 }
static staticStatus_t edit_static_detect_status | ( | void | ) | [static] |
Definition at line 238 of file editScreenStatic.c.
00239 { 00240 staticStatus_t status = undefStatus_e; 00241 00242 if (!ergtk_entry_check_field(ERGTK_ENTRY(g_address->entry))) 00243 { 00244 status = inputAddr_e; 00245 } 00246 else if (!ergtk_entry_check_field(ERGTK_ENTRY(g_netmask->entry))) 00247 { 00248 status = inputNetmask_e; 00249 } 00250 else if (!ergtk_entry_check_field(ERGTK_ENTRY(g_gateway->entry))) 00251 { 00252 status = inputGateway_e; 00253 } 00254 else if (!ergtk_entry_check_field(ERGTK_ENTRY(g_dns->entry))) 00255 { 00256 status = inputDns_e; 00257 } 00258 00259 CN_LOGPRINTF("return %d", status); 00260 return status; 00261 }
static void edit_static_determine_status | ( | void | ) | [static] |
Definition at line 263 of file editScreenStatic.c.
00264 { 00265 staticStatus_t status; 00266 GtkWidget *widget = NULL; 00267 00268 status = edit_static_detect_status(); 00269 switch (status) 00270 { 00271 case inputAddr_e: 00272 widget = g_address->entry; 00273 break; 00274 case inputNetmask_e: 00275 widget = g_netmask->entry; 00276 break; 00277 case inputGateway_e: 00278 widget = g_gateway->entry; 00279 break; 00280 case inputDns_e: 00281 widget = g_dns->entry; 00282 break; 00283 default: 00284 widget = g_address->entry; 00285 break; 00286 } 00287 00288 if (widget) 00289 { 00290 gtk_widget_grab_focus(widget); 00291 } 00292 }
static const char * edit_static_get_address | ( | void | ) | [static] |
Definition at line 452 of file editScreenStatic.c.
00453 { 00454 GtkWidget *widget; 00455 const char *address = NULL; 00456 00457 if (g_address) 00458 { 00459 widget = g_address->entry; 00460 address = gtk_entry_get_text(GTK_ENTRY(widget)); 00461 } 00462 00463 CN_LOGPRINTF("return address=%s", address); 00464 00465 return address; 00466 }
static const char * edit_static_get_dns | ( | void | ) | [static] |
Definition at line 498 of file editScreenStatic.c.
00499 { 00500 GtkWidget *widget; 00501 const char *dns = NULL; 00502 00503 if (g_dns) 00504 { 00505 widget = g_dns->entry; 00506 dns = gtk_entry_get_text(GTK_ENTRY(widget)); 00507 } 00508 00509 CN_LOGPRINTF("return dns=%s", dns); 00510 return dns; 00511 }
static const char * edit_static_get_gateway | ( | void | ) | [static] |
Definition at line 483 of file editScreenStatic.c.
00484 { 00485 GtkWidget *widget; 00486 const char *gateway = NULL; 00487 00488 if (g_gateway) 00489 { 00490 widget = g_gateway->entry; 00491 gateway = gtk_entry_get_text(GTK_ENTRY(widget)); 00492 } 00493 00494 CN_LOGPRINTF("return gateway=%s", gateway); 00495 return gateway; 00496 }
static const char * edit_static_get_netmask | ( | void | ) | [static] |
Definition at line 468 of file editScreenStatic.c.
00469 { 00470 GtkWidget *widget; 00471 const char *netmask = NULL; 00472 00473 if (g_netmask) 00474 { 00475 widget = g_netmask->entry; 00476 netmask = gtk_entry_get_text(GTK_ENTRY(widget)); 00477 } 00478 00479 CN_LOGPRINTF("return netmask=%s", netmask); 00480 return netmask; 00481 }
void edit_static_get_network_settings | ( | regNetworkProfile_t * | settings | ) |
Definition at line 408 of file editScreenStatic.c.
00409 { 00410 const gchar *address, *netmask, *gateway, *dns; 00411 regIpSetting_t *ipSettings; 00412 00413 CN_LOGPRINTF("entry"); 00414 00415 g_return_if_fail(settings != NULL); 00416 g_return_if_fail(settings->addressMode == static_t); 00417 00418 // clear static IP settings 00419 ipSettings = settings->ipSettings; 00420 if (ipSettings) 00421 { 00422 g_free(ipSettings->address); 00423 g_free(ipSettings->netmask); 00424 g_free(ipSettings->gateway); 00425 g_free(ipSettings->dns); 00426 g_free(ipSettings); 00427 ipSettings = NULL; 00428 settings->ipSettings = NULL; 00429 } 00430 00431 // get current value from screen objects 00432 address = edit_static_get_address(); 00433 netmask = edit_static_get_netmask(); 00434 gateway = edit_static_get_gateway(); 00435 dns = edit_static_get_dns(); 00436 00437 // store new settings, if static IP selected 00438 if (settings->addressMode == static_t) 00439 { 00440 ipSettings = g_new0(regIpSetting_t, 1); 00441 if (ipSettings) 00442 { 00443 ipSettings->address = g_strdup(address); 00444 ipSettings->netmask = g_strdup(netmask); 00445 ipSettings->gateway = g_strdup(gateway); 00446 ipSettings->dns = g_strdup(dns ); 00447 } 00448 settings->ipSettings = ipSettings; 00449 } 00450 }
void edit_static_restore_network_settings | ( | void | ) |
Definition at line 560 of file editScreenStatic.c.
00561 { 00562 char *address = NULL; 00563 char *netmask = NULL; 00564 char *gateway = NULL; 00565 char *dns = NULL; 00566 00567 CN_LOGPRINTF("entry"); 00568 00569 if (g_old_settings) 00570 { 00571 address = g_old_settings->address; 00572 netmask = g_old_settings->netmask; 00573 gateway = g_old_settings->gateway; 00574 dns = g_old_settings->dns; 00575 } 00576 00577 edit_static_set_address(address); 00578 edit_static_set_netmask(netmask); 00579 edit_static_set_gateway(gateway); 00580 edit_static_set_dns(dns); 00581 }
void edit_static_screen_leave | ( | void | ) |
Definition at line 583 of file editScreenStatic.c.
00584 { 00585 gboolean valid = TRUE; 00586 00587 CN_LOGPRINTF("entry"); 00588 00589 valid = edit_static_check_network_settings(); 00590 00591 // force overview screen to DHCP when no static settings 00592 if (!valid) 00593 { 00594 edit_overview_set_address(dhcp_t); 00595 } 00596 }
static void edit_static_set_address | ( | const char * | address | ) | [static] |
Definition at line 356 of file editScreenStatic.c.
00357 { 00358 GtkWidget *widget; 00359 00360 CN_LOGPRINTF("entry %s", address); 00361 00362 if (g_address) 00363 { 00364 widget = g_address->entry; 00365 gtk_entry_set_text(GTK_ENTRY(widget), address ? address : ""); 00366 } 00367 }
static void edit_static_set_dns | ( | const char * | dns | ) | [static] |
Definition at line 395 of file editScreenStatic.c.
00396 { 00397 GtkWidget *widget; 00398 00399 CN_LOGPRINTF("entry [%s]", dns); 00400 00401 if (g_dns) 00402 { 00403 widget = g_dns->entry; 00404 gtk_entry_set_text(GTK_ENTRY(widget), dns ? dns : ""); 00405 } 00406 }
static void edit_static_set_gateway | ( | const char * | gateway | ) | [static] |
Definition at line 382 of file editScreenStatic.c.
00383 { 00384 GtkWidget *widget; 00385 00386 CN_LOGPRINTF("entry [%s]", gateway); 00387 00388 if (g_gateway) 00389 { 00390 widget = g_gateway->entry; 00391 gtk_entry_set_text(GTK_ENTRY(widget), gateway ? gateway : ""); 00392 } 00393 }
static void edit_static_set_netmask | ( | const char * | netmask | ) | [static] |
Definition at line 369 of file editScreenStatic.c.
00370 { 00371 GtkWidget *widget; 00372 00373 CN_LOGPRINTF("entry [%s]", netmask); 00374 00375 if (g_netmask) 00376 { 00377 widget = g_netmask->entry; 00378 gtk_entry_set_text(GTK_ENTRY(widget), netmask ? netmask : ""); 00379 } 00380 }
void edit_static_set_network_settings | ( | const regNetworkProfile_t * | settings | ) |
Definition at line 295 of file editScreenStatic.c.
00296 { 00297 gchar *profilename = NULL; 00298 gchar *address = NULL; 00299 gchar *netmask = NULL; 00300 gchar *gateway = NULL; 00301 gchar *dns = NULL; 00302 regIpSetting_t* ipSettings; 00303 00304 CN_LOGPRINTF("entry [%p]", settings); 00305 00306 g_return_if_fail(settings != NULL); 00307 // g_return_if_fail(settings->addressMode == static_t); 00308 00309 profilename = settings->name; 00310 00311 ipSettings = settings->ipSettings; 00312 if (ipSettings) 00313 { 00314 address = ipSettings->address; 00315 netmask = ipSettings->netmask; 00316 gateway = ipSettings->gateway; 00317 dns = ipSettings->dns; 00318 } 00319 00320 edit_static_set_title(profilename); 00321 edit_static_set_address(address); 00322 edit_static_set_netmask(netmask); 00323 edit_static_set_gateway(gateway); 00324 edit_static_set_dns(dns); 00325 00326 edit_static_determine_status(); 00327 00328 // a backup copy of settings 00329 edit_static_backup_network_settings(); 00330 }
void edit_static_set_text | ( | void | ) |
Definition at line 187 of file editScreenStatic.c.
00188 { 00189 GtkWidget* widget = NULL; 00190 00191 CN_LOGPRINTF("entry"); 00192 00193 if (g_static) 00194 { 00195 gtk_settingitem_set_header_text(GTK_SETTINGITEM(g_static), 00196 _("Network profile")); 00197 } 00198 00199 if (g_address) 00200 { 00201 widget = g_address->label; 00202 gtk_label_set_text(GTK_LABEL(widget), 00203 _("Enter the iLiad's IP address:")); 00204 } 00205 00206 if (g_netmask) 00207 { 00208 widget = g_netmask->label; 00209 gtk_label_set_text(GTK_LABEL(widget), 00210 _("Enter the iLiad's netmask:")); 00211 } 00212 00213 if (g_gateway) 00214 { 00215 widget = g_gateway->label; 00216 gtk_label_set_text(GTK_LABEL(widget), 00217 _("Enter the default gateway's IP address:")); 00218 } 00219 00220 if (g_dns) 00221 { 00222 widget = g_dns->label; 00223 gtk_label_set_text(GTK_LABEL(widget), 00224 _("Enter the DNS name server's IP address:")); 00225 00226 widget = g_dns->button; 00227 gtk_button_set_label(GTK_BUTTON(widget), _("Next")); 00228 } 00229 00230 if (g_info) 00231 { 00232 gtk_infoitem_set_text(GTK_INFOITEM(g_info), 00233 _("If you do not know the settings for this network, " 00234 "please ask your network administrator.")); 00235 } 00236 }
void edit_static_set_title | ( | const char * | profilename | ) |
Definition at line 332 of file editScreenStatic.c.
00333 { 00334 char *title = NULL; 00335 00336 CN_LOGPRINTF("entry[%s]", profilename); 00337 00338 if (g_static) 00339 { 00340 if (profilename) 00341 { 00342 title = g_strdup_printf(_("Network profile: %s/static"), 00343 profilename); 00344 } 00345 else 00346 { 00347 title = g_strdup(_("Network profile: static")); 00348 } 00349 00350 gtk_settingitem_set_header_text(GTK_SETTINGITEM(g_static), title); 00351 00352 g_free(title); 00353 } 00354 }
static gboolean on_delayed_next | ( | gpointer | data | ) | [static] |
Definition at line 599 of file editScreenStatic.c.
00600 { 00601 gboolean valid; 00602 GtkToggleButton *button; 00603 00604 erbusy_blink(); 00605 00606 valid = edit_static_check_network_settings(); 00607 if (valid) 00608 { 00609 // before leave this page, backup the settings 00610 edit_static_backup_network_settings(); 00611 00612 edit_goto_page(editScreenOverview_e); 00613 edit_overview_update_info_text(inputProxy_e); 00614 } 00615 else 00616 { 00617 edit_static_determine_status(); 00618 } 00619 00620 button = GTK_TOGGLE_BUTTON(data); 00621 gtk_toggle_button_set_active(button, FALSE); 00622 00623 return FALSE; 00624 }
gboolean on_edit_static_keypress | ( | GdkEventKey * | event | ) |
Definition at line 640 of file editScreenStatic.c.
00641 { 00642 GtkToggleButton *button; 00643 gboolean ret = FALSE; 00644 00645 CN_LOGPRINTF("entry"); 00646 00647 switch (event->keyval) 00648 { 00649 case GDK_Return: 00650 // 'Enter' key is pressed 00651 // simulate clicking the 'Next' button 00652 if (g_dns) 00653 { 00654 button = GTK_TOGGLE_BUTTON(g_dns->button); 00655 gtk_toggle_button_set_active(button, TRUE); 00656 } 00657 ret = TRUE; 00658 break; 00659 00660 case GDK_F5: 00661 // 'UP' key is pressed 00662 // goto the one top level page 00663 cmgr_up_page(); 00664 ret = TRUE; 00665 break; 00666 00667 case GDK_Down: 00668 case GDK_Up: 00669 // avoid the standard GTK behaviour for GtkEntries 00670 erbusy_off(); 00671 ret = TRUE; 00672 00673 default: 00674 erbusy_off(); 00675 break; 00676 } 00677 00678 return ret; 00679 }
static void on_next | ( | GtkToggleButton * | button, | |
gpointer | data | |||
) | [static] |
Definition at line 626 of file editScreenStatic.c.
00627 { 00628 gboolean active; 00629 00630 CN_LOGPRINTF("entry"); 00631 00632 active = gtk_toggle_button_get_active(button); 00633 if (active) 00634 { 00635 g_timeout_add(500, on_delayed_next, button); 00636 } 00637 }
wdtLabelEntry* g_address = NULL [static] |
Definition at line 55 of file editScreenStatic.c.
wdtLabelEntry* g_dns = NULL [static] |
Definition at line 58 of file editScreenStatic.c.
wdtLabelEntry* g_gateway = NULL [static] |
Definition at line 57 of file editScreenStatic.c.
GtkWidget* g_info = NULL [static] |
Definition at line 60 of file editScreenStatic.c.
wdtLabelEntry* g_netmask = NULL [static] |
Definition at line 56 of file editScreenStatic.c.
regIpSetting_t* g_old_settings = NULL [static] |
Definition at line 63 of file editScreenStatic.c.
GtkWidget* g_static = NULL [static] |
Definition at line 53 of file editScreenStatic.c.