blob: e3aa78be83bd81d8d3ee65f40a1720b675eae798 [file] [log] [blame]
oliverschmidt76872e82004-12-26 14:13:34 +00001/*
2 * Copyright (c) 2004, Adam Dunkels.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer in the documentation and/or other materials provided
13 * with the distribution.
14 * 3. All advertising materials mentioning features or use of this
15 * software must display the following acknowledgement:
16 * This product includes software developed by Adam Dunkels.
17 * 4. The name of the author may not be used to endorse or promote
18 * products derived from this software without specific prior
19 * written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * This file is part of the Contiki desktop environment
34 *
oliverschmidte31aaa92006-06-28 23:10:43 +000035 * $Id: configedit.c,v 1.12 2006/06/28 23:10:45 oliverschmidt Exp $
oliverschmidt76872e82004-12-26 14:13:34 +000036 *
37 */
38
39
40#include <string.h>
oliverschmidt76872e82004-12-26 14:13:34 +000041
42#include "uiplib.h"
43#include "resolv.h"
oliverschmidtd5011942005-05-13 00:00:16 +000044#include "uip_arp.h"
oliverschmidt76872e82004-12-26 14:13:34 +000045#include "ctk.h"
46
oliverschmidt2fa33232005-01-26 21:33:29 +000047#include "program-handler.h"
48#include "packet-service.h"
oliverschmidtbc1dc142005-04-12 21:54:08 +000049#include "kfs.h"
oliverschmidt4c19ccb2005-03-20 00:23:28 +000050#include "cfs.h"
oliverschmidt2fa33232005-01-26 21:33:29 +000051
oliverschmidt0dca9282005-05-06 00:05:46 +000052#include "ctk-textentry-checkbox.h"
53
oliverschmidt76872e82004-12-26 14:13:34 +000054#include "config.h"
55
56
57static config_t config;
58static struct ctk_window window;
59
60#ifdef __APPLE2ENH__
61
62static struct ctk_label backgroundlabel =
oliverschmidtd5011942005-05-13 00:00:16 +000063 {CTK_LABEL(0, 1, 11, 1, "Background")};
oliverschmidt76872e82004-12-26 14:13:34 +000064static char bkgnd[2];
65static struct ctk_textentry backgroundtextentry =
oliverschmidtd5011942005-05-13 00:00:16 +000066 {CTK_TEXTENTRY_INPUT(12, 1, 1, 1, bkgnd, 1, ctk_textentry_checkbox_input)};
oliverschmidt76872e82004-12-26 14:13:34 +000067static struct ctk_label backgrounddescr =
68 {CTK_LABEL(16, 1, 12, 1, "('x' or ' ')")};
69
70#endif /* __APPLE2ENH__ */
71
oliverschmidtd5011942005-05-13 00:00:16 +000072static struct ctk_label screensaverlabel =
73 {CTK_LABEL(0, 3, 11, 1, "Screensaver")};
74static char screensaver[16];
75static struct ctk_textentry screensavertextentry =
76 {CTK_TEXTENTRY(12, 3, 15, 1, screensaver, 15)};
77
78static struct ctk_label timeoutlabel =
79 {CTK_LABEL(0, 4, 11, 1, "Timeout")};
80static char timeout[2];
81static struct ctk_textentry timeouttextentry =
82 {CTK_TEXTENTRY(12, 4, 1, 1, timeout, 1)};
83static struct ctk_label timeoutdescr =
84 {CTK_LABEL(16, 4, 12, 1, "(in Minutes)")};
oliverschmidt76872e82004-12-26 14:13:34 +000085
oliverschmidt2fa33232005-01-26 21:33:29 +000086static struct ctk_label driverlabel =
oliverschmidtd5011942005-05-13 00:00:16 +000087 {CTK_LABEL(0, 6, 11, 1, "LAN driver")};
oliverschmidt2fa33232005-01-26 21:33:29 +000088static char driver[16];
89static struct ctk_textentry drivertextentry =
oliverschmidtd5011942005-05-13 00:00:16 +000090 {CTK_TEXTENTRY(12, 6, 15, 1, driver, 15)};
91
92static struct ctk_label slotlabel =
93 {CTK_LABEL(0, 7, 11, 1, "LAN slot")};
94static char slot[2];
95static struct ctk_textentry slottextentry =
96 {CTK_TEXTENTRY(12, 7, 1, 1, slot, 1)};
97static struct ctk_label slotdescr =
98 {CTK_LABEL(16, 7, 12, 1, "('1' to '7')")};
oliverschmidt2fa33232005-01-26 21:33:29 +000099
oliverschmidt1a1e6282006-05-25 00:11:10 +0000100static struct ctk_label prefixlabel =
101 {CTK_LABEL(0, 9, 11, 1, "DOS Prefix")};
102static char prefix[65];
103static struct ctk_textentry prefixtextentry =
104 {CTK_TEXTENTRY(12, 9, 15, 1, prefix, 65)};
105
oliverschmidt76872e82004-12-26 14:13:34 +0000106static struct ctk_label ipaddrlabel =
oliverschmidt1a1e6282006-05-25 00:11:10 +0000107 {CTK_LABEL(0, 11, 10, 1, "IP address")};
oliverschmidt76872e82004-12-26 14:13:34 +0000108static char ipaddr[16];
109static struct ctk_textentry ipaddrtextentry =
oliverschmidt1a1e6282006-05-25 00:11:10 +0000110 {CTK_TEXTENTRY(12, 11, 15, 1, ipaddr, 15)};
oliverschmidt76872e82004-12-26 14:13:34 +0000111
112#ifdef WITH_ETHERNET
113
114static struct ctk_label netmasklabel =
oliverschmidt1a1e6282006-05-25 00:11:10 +0000115 {CTK_LABEL(0, 12, 11, 1, "Netmask")};
oliverschmidt76872e82004-12-26 14:13:34 +0000116static char netmask[16];
117static struct ctk_textentry netmasktextentry =
oliverschmidt1a1e6282006-05-25 00:11:10 +0000118 {CTK_TEXTENTRY(12, 12, 15, 1, netmask, 15)};
oliverschmidt76872e82004-12-26 14:13:34 +0000119
120static struct ctk_label gatewaylabel =
oliverschmidt1a1e6282006-05-25 00:11:10 +0000121 {CTK_LABEL(0, 13, 11, 1, "Gateway")};
oliverschmidt76872e82004-12-26 14:13:34 +0000122static char gateway[16];
123static struct ctk_textentry gatewaytextentry =
oliverschmidt1a1e6282006-05-25 00:11:10 +0000124 {CTK_TEXTENTRY(12, 13, 15, 1, gateway, 15)};
125
126static struct ctk_label dnsserverlabel =
127 {CTK_LABEL(0, 14, 11, 1, "DNS server")};
128static char dnsserver[16];
129static struct ctk_textentry dnsservertextentry =
130 {CTK_TEXTENTRY(12, 14, 15, 1, dnsserver, 15)};
131
132static struct ctk_label maclsblabel =
133 {CTK_LABEL(0, 16, 11, 1, "MAC address")};
134static char maclsb[4];
135static struct ctk_textentry maclsbtextentry =
136 {CTK_TEXTENTRY(12, 16, 3, 1, maclsb, 3)};
137static struct ctk_label maclsbdescr =
138 {CTK_LABEL(18, 16, 10, 1, "(LSB only)")};
139
140#else /* WITH_ETHERNET */
oliverschmidt76872e82004-12-26 14:13:34 +0000141
142static struct ctk_label dnsserverlabel =
oliverschmidtd5011942005-05-13 00:00:16 +0000143 {CTK_LABEL(0, 12, 11, 1, "DNS server")};
oliverschmidt76872e82004-12-26 14:13:34 +0000144static char dnsserver[16];
145static struct ctk_textentry dnsservertextentry =
oliverschmidtd5011942005-05-13 00:00:16 +0000146 {CTK_TEXTENTRY(12, 12, 15, 1, dnsserver, 15)};
147
oliverschmidt76872e82004-12-26 14:13:34 +0000148#endif /* WITH_ETHERNET */
149
150static struct ctk_button okbutton =
oliverschmidt1a1e6282006-05-25 00:11:10 +0000151 {CTK_BUTTON(0, 18, 12, "Save & close")};
oliverschmidt76872e82004-12-26 14:13:34 +0000152static struct ctk_button cancelbutton =
oliverschmidt1a1e6282006-05-25 00:11:10 +0000153 {CTK_BUTTON(22, 18, 6, "Cancel")};
oliverschmidt76872e82004-12-26 14:13:34 +0000154
oliverschmidt356f3662005-05-22 14:04:00 +0000155
156static struct ctk_window errordialog;
157
158static struct ctk_label errormsg =
159 {CTK_LABEL(0, 1, 19, 1, "Error saving config")};
160static struct ctk_button errorokbutton =
161 {CTK_BUTTON(7, 3, 2, "Ok")};
162
163
oliverschmidt76872e82004-12-26 14:13:34 +0000164EK_EVENTHANDLER(config_eventhandler, ev, data);
165EK_PROCESS(p, "Configuration", EK_PRIO_NORMAL,
166 config_eventhandler, NULL, NULL);
167static ek_id_t id = EK_ID_NONE;
oliverschmidt3b308a62005-02-01 00:21:36 +0000168static ek_id_t driverid = EK_ID_NONE;
oliverschmidt76872e82004-12-26 14:13:34 +0000169
170/*-----------------------------------------------------------------------------------*/
171LOADER_INIT_FUNC(config_init, arg)
172{
173 arg_free(arg);
174
175 if(id == EK_ID_NONE) {
176 id = ek_start(&p);
177 }
178}
179/*-----------------------------------------------------------------------------------*/
180static char *
181makebyte(u8_t byte, char *str)
182{
183 if(byte >= 100) {
184 *str++ = (byte / 100 ) % 10 + '0';
185 }
186 if(byte >= 10) {
187 *str++ = (byte / 10) % 10 + '0';
188 }
189 *str++ = (byte % 10) + '0';
190
191 return str;
192}
193/*-----------------------------------------------------------------------------------*/
194static void
195makeaddr(u16_t *addr, char *str)
196{
197 str = makebyte(HTONS(addr[0]) >> 8, str);
198 *str++ = '.';
199 str = makebyte(HTONS(addr[0]) & 0xff, str);
200 *str++ = '.';
201 str = makebyte(HTONS(addr[1]) >> 8, str);
202 *str++ = '.';
203 str = makebyte(HTONS(addr[1]) & 0xff, str);
204 *str++ = 0;
205}
206/*-----------------------------------------------------------------------------------*/
oliverschmidt2fa33232005-01-26 21:33:29 +0000207static int
208makedriver(const char *name, char *str)
209{
210 char *pattern = PACKET_SERVICE_NAME ": ";
211
212 while(*pattern) {
213 if(*name++ != *pattern++) {
214 return 0;
215 }
216 }
217
218 while(*name) {
219 *str++ = *name++;
220 }
221 strcpy(str, ".drv");
222
223 return 1;
224}
225/*-----------------------------------------------------------------------------------*/
oliverschmidt76872e82004-12-26 14:13:34 +0000226static void
227makestrings(void)
228{
229 u16_t addr[2], *addrptr;
oliverschmidt2fa33232005-01-26 21:33:29 +0000230 struct ek_proc *p;
oliverschmidt76872e82004-12-26 14:13:34 +0000231
232#ifdef __APPLE2ENH__
233
234 if(ctk_draw_getbackground()) {
235 *bkgnd = 'x';
236 }
237
238#endif /* __APPLE2ENH__ */
239
oliverschmidtd5011942005-05-13 00:00:16 +0000240 strncpy(screensaver, program_handler_getscreensaver(), sizeof(screensaver));
241
242 *timeout = (CTK_SCREENSAVER_TIMEOUT() / 60) % 10 + '0';
oliverschmidt2fa33232005-01-26 21:33:29 +0000243
244 for(p = EK_PROCS(); p != NULL; p = p->next) {
245 if(makedriver(p->name, driver)) {
oliverschmidt3b308a62005-02-01 00:21:36 +0000246 driverid = p->id;
oliverschmidt2fa33232005-01-26 21:33:29 +0000247 break;
248 }
249 }
250
oliverschmidt356f3662005-05-22 14:04:00 +0000251 if(config_getlanslot() != 0) {
252 *slot = config_getlanslot() + '0';
253 }
oliverschmidtd5011942005-05-13 00:00:16 +0000254
oliverschmidte31aaa92006-06-28 23:10:43 +0000255 if(config_getprefixok()) {
oliverschmidt1a1e6282006-05-25 00:11:10 +0000256 getcwd(prefix, sizeof(prefix));
257 }
258
oliverschmidt76872e82004-12-26 14:13:34 +0000259#ifdef WITH_UIP
260
261 uip_gethostaddr(addr);
262 makeaddr(addr, ipaddr);
263
264#ifdef WITH_ETHERNET
265
266 uip_getnetmask(addr);
267 makeaddr(addr, netmask);
268
269 uip_getdraddr(addr);
270 makeaddr(addr, gateway);
271
oliverschmidtd5011942005-05-13 00:00:16 +0000272 makebyte(uip_ethaddr.addr[5], maclsb);
273
oliverschmidt76872e82004-12-26 14:13:34 +0000274#endif /* WITH_ETHERNET */
275
276 addrptr = resolv_getserver();
277 if(addrptr != NULL) {
278 makeaddr(addrptr, dnsserver);
279 }
280
281#endif /* WITH_UIP */
oliverschmidt76872e82004-12-26 14:13:34 +0000282}
283/*-----------------------------------------------------------------------------------*/
284static void
285nullterminate(char *cptr)
286{
287 /* Find the first space character in the ipaddr and put a zero there
288 to end the string. */
289 for(; *cptr != ' ' && *cptr != 0; ++cptr);
290 *cptr = 0;
291}
292/*-----------------------------------------------------------------------------------*/
293static void
294makeconfig(void)
295{
296 u16_t addr[2];
oliverschmidtd5011942005-05-13 00:00:16 +0000297 char *cptr;
298 u8_t tmp;
oliverschmidt76872e82004-12-26 14:13:34 +0000299
300#ifdef __APPLE2ENH__
301
oliverschmidt0dca9282005-05-06 00:05:46 +0000302 config.bkgnd = (*bkgnd == 'x');
oliverschmidt76872e82004-12-26 14:13:34 +0000303
304#endif /* __APPLE2ENH__ */
305
oliverschmidtd5011942005-05-13 00:00:16 +0000306 nullterminate(screensaver);
307 strcpy(config.screensaver, screensaver);
308
309 if(*timeout >= '1' && *timeout <= '9') {
310 config.timeout = *timeout - '0';
oliverschmidt76872e82004-12-26 14:13:34 +0000311 }
312
oliverschmidt2fa33232005-01-26 21:33:29 +0000313 nullterminate(driver);
314 strcpy(config.driver, driver);
315
oliverschmidtd5011942005-05-13 00:00:16 +0000316 if(*slot >= '1' && *slot <= '7') {
317 config.slot = *slot - '0';
oliverschmidt356f3662005-05-22 14:04:00 +0000318 } else {
319 config.slot = 0;
oliverschmidtd5011942005-05-13 00:00:16 +0000320 }
321
oliverschmidt1a1e6282006-05-25 00:11:10 +0000322 nullterminate(prefix);
323 strcpy(config.prefix, prefix);
324
oliverschmidt76872e82004-12-26 14:13:34 +0000325#ifdef WITH_UIP
326
327 nullterminate(ipaddr);
328 if(uiplib_ipaddrconv(ipaddr, (unsigned char *)addr)) {
329 config.ipaddr[0] = addr[0];
330 config.ipaddr[1] = addr[1];
331 }
332
333#ifdef WITH_ETHERNET
334
335 nullterminate(netmask);
336 if(uiplib_ipaddrconv(netmask, (unsigned char *)addr)) {
337 config.netmask[0] = addr[0];
338 config.netmask[1] = addr[1];
339 }
340
341 nullterminate(gateway);
342 if(uiplib_ipaddrconv(gateway, (unsigned char *)addr)) {
343 config.gateway[0] = addr[0];
344 config.gateway[1] = addr[1];
345 }
346
oliverschmidtd5011942005-05-13 00:00:16 +0000347 tmp = 0;
348 for(cptr = maclsb; *cptr >= '0' && *cptr <= '9'; ++cptr) {
349 tmp = (tmp * 10) + (*cptr - '0');
350 }
351 if(tmp != 0) {
352 config.maclsb = tmp;
353 }
354
oliverschmidt76872e82004-12-26 14:13:34 +0000355#endif /* WITH_ETHERNET */
356
357 nullterminate(dnsserver);
358 if(uiplib_ipaddrconv(dnsserver, (unsigned char *)addr)) {
359 config.dnsserver[0] = addr[0];
360 config.dnsserver[1] = addr[1];
361 }
362
363#endif /* WITH_UIP */
364}
365/*-----------------------------------------------------------------------------------*/
366static void
367config_apply(void)
368{
369#ifdef __APPLE2ENH__
370
371 ctk_draw_setbackground(config.bkgnd);
372
373#endif /* __APPLE2ENH__ */
374
oliverschmidtd5011942005-05-13 00:00:16 +0000375 program_handler_setscreensaver(config.screensaver);
376
377 CTK_SCREENSAVER_SET_TIMEOUT(config.timeout * 60);
378
oliverschmidt3b308a62005-02-01 00:21:36 +0000379 if(driverid != EK_ID_NONE) {
380 ek_post(driverid, EK_EVENT_REQUEST_EXIT, NULL);
381 }
382
oliverschmidt2fa33232005-01-26 21:33:29 +0000383 config_setlanslot(config.slot);
384
385 if(*config.driver) {
386 program_handler_load(config.driver, NULL);
387 }
388
oliverschmidte31aaa92006-06-28 23:10:43 +0000389 if(*config.prefix == '/') {
390 config_setprefixok(chdir(config.prefix) == 0);
oliverschmidt1a1e6282006-05-25 00:11:10 +0000391 }
392
oliverschmidt76872e82004-12-26 14:13:34 +0000393#ifdef WITH_UIP
394
395 uip_sethostaddr(config.ipaddr);
396
397#ifdef WITH_ETHERNET
398
399 uip_setnetmask(config.netmask);
400 uip_setdraddr(config.gateway);
oliverschmidtd5011942005-05-13 00:00:16 +0000401 uip_ethaddr.addr[5] = config.maclsb;
oliverschmidt76872e82004-12-26 14:13:34 +0000402
403#endif /* WITH_ETHERNET */
404
405 resolv_conf(config.dnsserver);
406
407#endif /* WITH_UIP */
408}
409/*-----------------------------------------------------------------------------------*/
oliverschmidt356f3662005-05-22 14:04:00 +0000410static int
oliverschmidt76872e82004-12-26 14:13:34 +0000411config_save(void)
412{
oliverschmidt356f3662005-05-22 14:04:00 +0000413 int fd, written = 0;
oliverschmidt76872e82004-12-26 14:13:34 +0000414
oliverschmidtbc1dc142005-04-12 21:54:08 +0000415 fd = cfs_open(strcat(kfs_getdir(), "contiki.cfg"), CFS_WRITE);
oliverschmidt356f3662005-05-22 14:04:00 +0000416 if(fd != -1) {
417 written = cfs_write(fd, &config, sizeof(config));
418 cfs_close(fd);
oliverschmidt76872e82004-12-26 14:13:34 +0000419 }
oliverschmidt356f3662005-05-22 14:04:00 +0000420 return written == sizeof(config);
oliverschmidt76872e82004-12-26 14:13:34 +0000421}
422/*-----------------------------------------------------------------------------------*/
423EK_EVENTHANDLER(config_eventhandler, ev, data)
424{
425 EK_EVENTHANDLER_ARGS(ev, data);
426
427 if(ev == EK_EVENT_INIT) {
oliverschmidt1a1e6282006-05-25 00:11:10 +0000428 ctk_window_new(&window, 30, 19, "Config editor");
oliverschmidt76872e82004-12-26 14:13:34 +0000429#ifdef __APPLE2ENH__
430 CTK_WIDGET_ADD(&window, &backgroundlabel);
431 CTK_WIDGET_ADD(&window, &backgroundtextentry);
432 CTK_WIDGET_ADD(&window, &backgrounddescr);
433#endif /* __APPLE2ENH__ */
oliverschmidtd5011942005-05-13 00:00:16 +0000434 CTK_WIDGET_ADD(&window, &screensaverlabel);
435 CTK_WIDGET_ADD(&window, &screensavertextentry);
436 CTK_WIDGET_ADD(&window, &timeoutlabel);
437 CTK_WIDGET_ADD(&window, &timeouttextentry);
438 CTK_WIDGET_ADD(&window, &timeoutdescr);
439 CTK_WIDGET_ADD(&window, &driverlabel);
440 CTK_WIDGET_ADD(&window, &drivertextentry);
oliverschmidt76872e82004-12-26 14:13:34 +0000441 CTK_WIDGET_ADD(&window, &slotlabel);
442 CTK_WIDGET_ADD(&window, &slottextentry);
443 CTK_WIDGET_ADD(&window, &slotdescr);
oliverschmidt1a1e6282006-05-25 00:11:10 +0000444 CTK_WIDGET_ADD(&window, &prefixlabel);
445 CTK_WIDGET_ADD(&window, &prefixtextentry);
oliverschmidt2fa33232005-01-26 21:33:29 +0000446 CTK_WIDGET_ADD(&window, &ipaddrlabel);
oliverschmidt76872e82004-12-26 14:13:34 +0000447 CTK_WIDGET_ADD(&window, &ipaddrtextentry);
448#ifdef WITH_ETHERNET
449 CTK_WIDGET_ADD(&window, &netmasklabel);
450 CTK_WIDGET_ADD(&window, &netmasktextentry);
451 CTK_WIDGET_ADD(&window, &gatewaylabel);
452 CTK_WIDGET_ADD(&window, &gatewaytextentry);
453#endif /* WITH_ETHERNET */
454 CTK_WIDGET_ADD(&window, &dnsserverlabel);
455 CTK_WIDGET_ADD(&window, &dnsservertextentry);
oliverschmidtd5011942005-05-13 00:00:16 +0000456#ifdef WITH_ETHERNET
457 CTK_WIDGET_ADD(&window, &maclsblabel);
458 CTK_WIDGET_ADD(&window, &maclsbtextentry);
oliverschmidteb79d842005-05-16 12:56:14 +0000459 CTK_WIDGET_ADD(&window, &maclsbdescr);
oliverschmidtd5011942005-05-13 00:00:16 +0000460#endif /* WITH_ETHERNET */
oliverschmidt76872e82004-12-26 14:13:34 +0000461 CTK_WIDGET_ADD(&window, &okbutton);
462 CTK_WIDGET_ADD(&window, &cancelbutton);
463#ifdef __APPLE2ENH__
464 CTK_WIDGET_FOCUS(&window, &backgroundtextentry);
465#else /* __APPLE2ENH__ */
oliverschmidtd5011942005-05-13 00:00:16 +0000466 CTK_WIDGET_FOCUS(&window, &screensavertextentry);
oliverschmidt76872e82004-12-26 14:13:34 +0000467#endif /* __APPLE2ENH__ */
468
oliverschmidt356f3662005-05-22 14:04:00 +0000469 ctk_dialog_new(&errordialog, 19, 5);
470 CTK_WIDGET_ADD(&errordialog, &errormsg);
471 CTK_WIDGET_ADD(&errordialog, &errorokbutton);
472 CTK_WIDGET_FOCUS(&errordialog, &errorokbutton);
473
oliverschmidt76872e82004-12-26 14:13:34 +0000474 /* Fill the configuration strings with values from the current
475 configuration */
476 makestrings();
477 ctk_window_open(&window);
478 } else if(ev == ctk_signal_button_activate) {
479 if(data == (ek_data_t)&okbutton) {
480
481 /* Fill the configuration with values from the current
482 configuration strings */
483 makeconfig();
oliverschmidta6c17c22006-05-28 20:50:13 +0000484 config_apply();
oliverschmidt356f3662005-05-22 14:04:00 +0000485 if(config_save()) {
oliverschmidt356f3662005-05-22 14:04:00 +0000486 goto quit;
487 }
488 ctk_dialog_open(&errordialog);
489 } else if(data == (ek_data_t)&errorokbutton) {
490 ctk_dialog_close();
oliverschmidt76872e82004-12-26 14:13:34 +0000491 goto quit;
492 } else if(data == (ek_data_t)&cancelbutton) {
493 goto quit;
494 }
495
496 } else if(ev == ctk_signal_window_close ||
497 ev == EK_EVENT_REQUEST_EXIT) {
498 goto quit;
499 }
500 return;
501
502quit:
503 ctk_window_close(&window);
504 ek_exit();
505 id = EK_ID_NONE;
506 LOADER_UNLOAD();
507}
508/*-----------------------------------------------------------------------------------*/