revert between 56095 -> 55830 in arch
[AROS.git] / workbench / prefs / network / netpeditor.c
blob961b51898a2519c7259aa84322f65424d4e1c347
1 /*
2 Copyright © 2009-2012, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define MUIMASTER_YES_INLINE_STDARG
8 #include <exec/types.h>
9 #include <utility/tagitem.h>
10 #include <libraries/asl.h>
11 #include <libraries/locale.h>
12 #include <libraries/mui.h>
13 #include <prefs/prefhdr.h>
14 #include <zune/customclasses.h>
15 #include <zune/prefseditor.h>
17 #include <proto/exec.h>
18 #include <proto/intuition.h>
19 #include <proto/utility.h>
20 #include <proto/muimaster.h>
21 #include <proto/dos.h>
22 #include <proto/iffparse.h>
24 #include <string.h>
25 #include <stdio.h>
27 #include "misc.h"
28 #include "locale.h"
29 #include "netpeditor.h"
30 #include "prefsdata.h"
32 #include <proto/alib.h>
33 #include <utility/hooks.h>
35 static CONST_STRPTR NetworkTabs[] = { NULL, NULL, NULL, NULL, NULL, NULL};
36 static CONST_STRPTR DHCPCycle[] = { NULL, NULL, NULL };
37 static CONST_STRPTR EncCycle[] = { NULL, NULL, NULL, NULL };
38 static CONST_STRPTR KeyCycle[] = { NULL, NULL, NULL };
39 static CONST_STRPTR ServiceTypeCycle[] = { NULL, NULL };
40 static const TEXT max_ip_str[] = "255.255.255.255 ";
42 static struct Hook netpeditor_displayHook,
43 netpeditor_constructHook,
44 netpeditor_destructHook;
45 static struct Hook hosts_displayHook,
46 hosts_constructHook,
47 hosts_destructHook;
48 static struct Hook wireless_displayHook,
49 wireless_constructHook,
50 wireless_destructHook;
51 static struct Hook server_displayHook,
52 server_constructHook,
53 server_destructHook;
55 /*** Instance Data **********************************************************/
56 struct NetPEditor_DATA
58 // Main window
59 Object *netped_interfaceList,
60 *netped_DHCPState,
61 *netped_gateString,
62 *netped_DNSString[2],
63 *netped_hostString,
64 *netped_domainString,
65 *netped_Autostart,
66 *netped_addButton,
67 *netped_editButton,
68 *netped_removeButton,
69 *netped_inputGroup,
70 *netped_hostList,
71 *netped_hostAddButton,
72 *netped_hostEditButton,
73 *netped_hostRemoveButton,
74 *netped_networkList,
75 *netped_netAddButton,
76 *netped_netEditButton,
77 *netped_netRemoveButton,
78 *netped_MBBInitString[MAXATCOMMANDS],
79 *netped_MBBDeviceString,
80 *netped_MBBUnit,
81 *netped_MBBUsername,
82 *netped_MBBPassword,
83 *netped_serverList,
84 *netped_serverAddButton,
85 *netped_serverEditButton,
86 *netped_serverRemoveButton;
88 // Interface window
89 Object *netped_ifWindow,
90 *netped_upState,
91 *netped_ifDHCPState,
92 *netped_nameString,
93 *netped_deviceString,
94 *netped_unitString,
95 *netped_IPString,
96 *netped_maskString,
97 *netped_applyButton,
98 *netped_closeButton;
100 // Host window
101 Object *netped_hostWindow,
102 *netped_hostNamesString,
103 *netped_hostAddressString,
104 *netped_hostApplyButton,
105 *netped_hostCloseButton;
107 // Wireless network window
108 Object *netped_netWindow,
109 *netped_sSIDString,
110 *netped_encType,
111 *netped_keyType,
112 *netped_keyString,
113 *netped_hiddenState,
114 *netped_adHocState,
115 *netped_netApplyButton,
116 *netped_netCloseButton;
118 // File-server window
119 Object *netped_serverWindow,
120 *netped_serverServiceType,
121 *netped_serverDevice,
122 *netped_serverActive,
123 *netped_serverHost,
124 *netped_serverService,
125 *netped_serverUser,
126 *netped_serverPass,
127 *netped_serverGroup,
128 *netped_serverApplyButton,
129 *netped_serverCloseButton;
132 AROS_UFH3S(APTR, constructFunc,
133 AROS_UFHA(struct Hook *, hook, A0),
134 AROS_UFHA(APTR, pool, A2),
135 AROS_UFHA(struct Interface *, entry, A1))
137 AROS_USERFUNC_INIT
139 struct Interface *new;
141 if ((new = AllocPooled(pool, sizeof(*new))))
143 *new = *entry;
145 return new;
147 AROS_USERFUNC_EXIT
150 AROS_UFH3S(void, destructFunc,
151 AROS_UFHA(struct Hook *, hook, A0),
152 AROS_UFHA(APTR, pool, A2),
153 AROS_UFHA(struct Interface *, entry, A1))
155 AROS_USERFUNC_INIT
157 FreePooled(pool, entry, sizeof(struct Interface));
159 AROS_USERFUNC_EXIT
162 AROS_UFH3S(LONG, displayFunc,
163 AROS_UFHA(struct Hook *, hook, A0),
164 AROS_UFHA(char **, array, A2),
165 AROS_UFHA(struct Interface *, entry, A1))
167 AROS_USERFUNC_INIT
168 if (entry)
170 static char unitbuffer[20];
171 sprintf(unitbuffer, "%d", (int)entry->unit);
172 *array++ = entry->name;
173 *array++ = entry->up ? "*" : "";
174 *array++ = FilePart(entry->device);
175 *array++ = unitbuffer;
176 *array = entry->ifDHCP ? (STRPTR)_(MSG_IP_MODE_DHCP) : entry->IP;
178 else
180 *array++ = (STRPTR)_(MSG_IFNAME);
181 *array++ = (STRPTR)_(MSG_UP);
182 *array++ = (STRPTR)_(MSG_DEVICE);
183 *array++ = (STRPTR)_(MSG_UNIT);
184 *array = (STRPTR)_(MSG_IP);
187 return 0;
189 AROS_USERFUNC_EXIT
192 AROS_UFH3S(APTR, hostsConstructFunc,
193 AROS_UFHA(struct Hook *, hook, A0),
194 AROS_UFHA(APTR, pool, A2),
195 AROS_UFHA(struct Host *, entry, A1))
197 AROS_USERFUNC_INIT
199 struct Host *new;
201 if ((new = AllocPooled(pool, sizeof(*new))))
203 *new = *entry;
205 return new;
207 AROS_USERFUNC_EXIT
210 AROS_UFH3S(void, hostsDestructFunc,
211 AROS_UFHA(struct Hook *, hook, A0),
212 AROS_UFHA(APTR, pool, A2),
213 AROS_UFHA(struct Host *, entry, A1))
215 AROS_USERFUNC_INIT
217 FreePooled(pool, entry, sizeof(struct Host));
219 AROS_USERFUNC_EXIT
222 AROS_UFH3S(LONG, hostsDisplayFunc,
223 AROS_UFHA(struct Hook *, hook, A0),
224 AROS_UFHA(char **, array, A2),
225 AROS_UFHA(struct Host *, entry, A1))
227 AROS_USERFUNC_INIT
228 if (entry)
230 *array++ = entry->address;
231 *array++ = entry->names;
233 else
235 *array++ = (STRPTR)_(MSG_IP);
236 *array++ = (STRPTR)_(MSG_HOST_NAMES);
239 return 0;
241 AROS_USERFUNC_EXIT
244 AROS_UFH3S(APTR, netConstructFunc,
245 AROS_UFHA(struct Hook *, hook, A0),
246 AROS_UFHA(APTR, pool, A2),
247 AROS_UFHA(struct Network *, entry, A1))
249 AROS_USERFUNC_INIT
251 struct Network *new;
253 if ((new = AllocPooled(pool, sizeof(*new))))
255 *new = *entry;
257 return new;
259 AROS_USERFUNC_EXIT
262 AROS_UFH3S(void, netDestructFunc,
263 AROS_UFHA(struct Hook *, hook, A0),
264 AROS_UFHA(APTR, pool, A2),
265 AROS_UFHA(struct Network *, entry, A1))
267 AROS_USERFUNC_INIT
269 FreePooled(pool, entry, sizeof(struct Network));
271 AROS_USERFUNC_EXIT
274 AROS_UFH3S(LONG, netDisplayFunc,
275 AROS_UFHA(struct Hook *, hook, A0),
276 AROS_UFHA(char **, array, A2),
277 AROS_UFHA(struct Network *, entry, A1))
279 AROS_USERFUNC_INIT
280 if (entry)
282 *array++ = entry->name;
283 switch(entry->encType)
285 case 2:
286 *array++ = (STRPTR)_(MSG_ENC_WPA);
287 break;
288 case 1:
289 *array++ = (STRPTR)_(MSG_ENC_WEP);
290 break;
291 default:
292 *array++ = (STRPTR)_(MSG_ENC_NONE);
294 *array++ = (STRPTR)L_(entry->hidden ? YESSTR : NOSTR);
295 *array++ = (STRPTR)L_(entry->adHoc ? YESSTR : NOSTR);
297 else
299 *array++ = (STRPTR)_(MSG_SSID);
300 *array++ = (STRPTR)_(MSG_ENCTYPE);
301 *array++ = (STRPTR)_(MSG_HIDDEN);
302 *array++ = (STRPTR)_(MSG_ADHOC);
305 return 0;
307 AROS_USERFUNC_EXIT
310 AROS_UFH3S(APTR, serverConstructFunc,
311 AROS_UFHA(struct Hook *, hook, A0),
312 AROS_UFHA(APTR, pool, A2),
313 AROS_UFHA(struct Server *, entry, A1))
315 AROS_USERFUNC_INIT
317 struct Server *new;
319 if ((new = AllocPooled(pool, sizeof(*new))))
321 *new = *entry;
323 return new;
325 AROS_USERFUNC_EXIT
328 AROS_UFH3S(void, serverDestructFunc,
329 AROS_UFHA(struct Hook *, hook, A0),
330 AROS_UFHA(APTR, pool, A2),
331 AROS_UFHA(struct Server *, entry, A1))
333 AROS_USERFUNC_INIT
335 FreePooled(pool, entry, sizeof(struct Server));
337 AROS_USERFUNC_EXIT
340 AROS_UFH3S(LONG, serverDisplayFunc,
341 AROS_UFHA(struct Hook *, hook, A0),
342 AROS_UFHA(char **, array, A2),
343 AROS_UFHA(struct Server *, entry, A1))
345 AROS_USERFUNC_INIT
346 if (entry)
348 *array++ = entry->device;
349 *array++ = entry->active ? "*" : "";
350 *array++ = entry->host;
351 *array++ = entry->group;
352 *array++ = entry->service;
353 *array++ = entry->user;
355 else
357 *array++ = (STRPTR)_(MSG_DEVICE);
358 *array++ = (STRPTR)_(MSG_UP);
359 *array++ = (STRPTR)_(MSG_HOST_NAME);
360 *array++ = (STRPTR)_(MSG_WORKGROUP);
361 *array++ = (STRPTR)_(MSG_SERVICE);
362 *array++ = (STRPTR)_(MSG_USERNAME);
365 return 0;
367 AROS_USERFUNC_EXIT
370 BOOL Gadgets2NetworkPrefs(struct NetPEditor_DATA *data)
372 STRPTR str = NULL;
373 IPTR lng = 0;
374 LONG i,a;
376 LONG entries = XGET(data->netped_interfaceList, MUIA_List_Entries);
377 for(i = 0; i < entries; i++)
379 struct Interface *iface = GetInterface(i);
380 struct Interface *ifaceentry;
381 DoMethod
383 data->netped_interfaceList,
384 MUIM_List_GetEntry, i, &ifaceentry
386 SetName(iface, ifaceentry->name);
387 SetUp(iface, ifaceentry->up);
388 SetIfDHCP(iface, ifaceentry->ifDHCP);
389 SetDevice(iface, ifaceentry->device);
390 SetUnit(iface, ifaceentry->unit);
391 SetIP(iface, ifaceentry->IP);
392 SetMask(iface, ifaceentry->mask);
394 SetInterfaceCount(entries);
396 GET(data->netped_gateString, MUIA_String_Contents, &str);
397 SetGate(str);
398 GET(data->netped_DNSString[0], MUIA_String_Contents, &str);
399 SetDNS(0, str);
400 GET(data->netped_DNSString[1], MUIA_String_Contents, &str);
401 SetDNS(1, str);
402 GET(data->netped_hostString, MUIA_String_Contents, &str);
403 SetHostname(str);
404 GET(data->netped_domainString, MUIA_String_Contents, &str);
405 SetDomain(str);
406 GET(data->netped_Autostart, MUIA_Selected, &lng);
407 SetAutostart(lng);
408 GET(data->netped_DHCPState, MUIA_Cycle_Active, &lng);
409 SetDHCP(lng);
411 entries = XGET(data->netped_hostList, MUIA_List_Entries);
412 for(i = 0; i < entries; i++)
414 struct Host *host = GetHost(i);
415 struct Host *hostentry;
416 DoMethod
418 data->netped_hostList,
419 MUIM_List_GetEntry, i, &hostentry
421 SetHostAddress(host, hostentry->address);
422 SetHostNames(host, hostentry->names);
424 SetHostCount(entries);
426 entries = XGET(data->netped_networkList, MUIA_List_Entries);
427 for(i = 0; i < entries; i++)
429 struct Network *net = GetNetwork(i);
430 struct Network *netentry;
431 DoMethod
433 data->netped_networkList,
434 MUIM_List_GetEntry, i, &netentry
436 SetNetworkName(net, netentry->name);
437 SetEncType(net, netentry->encType);
438 SetKey(net, netentry->key, netentry->keyIsHex);
439 SetHidden(net, netentry->hidden);
440 SetAdHoc(net, netentry->adHoc);
442 SetNetworkCount(entries);
444 for(i = 0 ; i < MAXATCOMMANDS; i++) SetMobile_atcommand(i,"");
446 a = 0;
447 for(i = 0 ; i < MAXATCOMMANDS; i++)
449 GET(data->netped_MBBInitString[i], MUIA_String_Contents, &str);
450 if( strlen(str) > 0 ) SetMobile_atcommand( a++ , str );
452 GET(data->netped_MBBDeviceString, MUIA_String_Contents, &str);
453 SetMobile_devicename(str);
454 GET(data->netped_MBBUnit, MUIA_Numeric_Value , &lng);
455 SetMobile_unit(lng);
456 GET(data->netped_MBBUsername, MUIA_String_Contents, &str);
457 SetMobile_username(str);
458 GET(data->netped_MBBPassword, MUIA_String_Contents, &str);
459 SetMobile_password(str);
461 entries = XGET(data->netped_serverList, MUIA_List_Entries);
462 for(i = 0; i < entries; i++)
464 struct Server *server = GetServer(i);
465 struct Server *serverentry;
466 DoMethod
468 data->netped_serverList,
469 MUIM_List_GetEntry, i, &serverentry
471 SetServerDevice(server, serverentry->device);
472 SetServerHost(server, serverentry->host);
473 SetServerService(server, serverentry->service);
474 SetServerUser(server, serverentry->user);
475 SetServerGroup(server, serverentry->group);
476 SetServerPass(server, serverentry->pass);
477 SetServerActive(server, serverentry->active);
479 SetServerCount(entries);
481 return TRUE;
484 BOOL NetworkPrefs2Gadgets
486 struct NetPEditor_DATA *data
489 LONG i;
490 LONG entries = GetInterfaceCount();
492 SET(data->netped_interfaceList, MUIA_List_Quiet, TRUE);
493 DoMethod(data->netped_interfaceList, MUIM_List_Clear);
494 for(i = 0; i < entries; i++)
496 struct Interface *iface = GetInterface(i);
497 struct Interface ifaceentry;
499 SetInterface
501 &ifaceentry,
502 GetName(iface),
503 GetIfDHCP(iface),
504 GetIP(iface),
505 GetMask(iface),
506 GetDevice(iface),
507 GetUnit(iface),
508 GetUp(iface)
511 DoMethod
513 data->netped_interfaceList,
514 MUIM_List_InsertSingle, &ifaceentry, MUIV_List_Insert_Bottom
518 SET(data->netped_interfaceList, MUIA_List_Quiet, FALSE);
520 NNSET(data->netped_gateString, MUIA_String_Contents, (IPTR)GetGate());
521 NNSET(data->netped_DNSString[0], MUIA_String_Contents, (IPTR)GetDNS(0));
522 NNSET(data->netped_DNSString[1], MUIA_String_Contents, (IPTR)GetDNS(1));
523 NNSET(data->netped_hostString, MUIA_String_Contents, (IPTR)GetHostname());
524 NNSET(data->netped_domainString, MUIA_String_Contents, (IPTR)GetDomain());
525 NNSET(data->netped_Autostart, MUIA_Selected, (IPTR)GetAutostart());
526 NNSET(data->netped_DHCPState, MUIA_Cycle_Active, (IPTR)GetDHCP() ? 1 : 0);
528 entries = GetHostCount();
530 SET(data->netped_hostList, MUIA_List_Quiet, TRUE);
531 DoMethod(data->netped_hostList, MUIM_List_Clear);
532 for(i = 0; i < entries; i++)
534 struct Host *host = GetHost(i);
535 struct Host hostentry;
537 SetHost
539 &hostentry,
540 GetHostNames(host),
541 GetHostAddress(host)
544 DoMethod
546 data->netped_hostList,
547 MUIM_List_InsertSingle, &hostentry, MUIV_List_Insert_Bottom
550 SET(data->netped_hostList, MUIA_List_Quiet, FALSE);
552 SET(data->netped_networkList, MUIA_List_Quiet, TRUE);
553 DoMethod(data->netped_networkList, MUIM_List_Clear);
554 entries = GetNetworkCount();
555 for(i = 0; i < entries; i++)
557 struct Network *net = GetNetwork(i);
558 struct Network netentry;
560 SetNetwork
562 &netentry,
563 GetNetworkName(net),
564 GetEncType(net),
565 GetKey(net),
566 net->keyIsHex,
567 GetHidden(net),
568 GetAdHoc(net)
571 DoMethod
573 data->netped_networkList,
574 MUIM_List_InsertSingle, &netentry, MUIV_List_Insert_Bottom
578 SET(data->netped_networkList, MUIA_List_Quiet, FALSE);
580 for(i = 0 ; i < MAXATCOMMANDS; i++)
581 NNSET((data->netped_MBBInitString[i]), MUIA_String_Contents, "");
583 entries = GetMobile_atcommandcount();
584 for(i = 0 ; i < entries; i++)
586 NNSET((data->netped_MBBInitString[i+MAXATCOMMANDS-entries]), MUIA_String_Contents, GetMobile_atcommand(i));
589 NNSET((data->netped_MBBDeviceString), MUIA_String_Contents, GetMobile_devicename());
590 NNSET((data->netped_MBBUnit), MUIA_Numeric_Value, GetMobile_unit());
591 NNSET((data->netped_MBBUsername), MUIA_String_Contents, GetMobile_username());
592 NNSET((data->netped_MBBPassword), MUIA_String_Contents, GetMobile_password());
594 SET(data->netped_serverList, MUIA_List_Quiet, TRUE);
595 DoMethod(data->netped_serverList, MUIM_List_Clear);
596 entries = GetServerCount();
597 for(i = 0; i < entries; i++)
599 struct Server *server = GetServer(i);
600 struct Server serverentry;
602 SetServer
604 &serverentry,
605 GetServerDevice(server),
606 GetServerHost(server),
607 GetServerService(server),
608 GetServerUser(server),
609 GetServerGroup(server),
610 GetServerPass(server),
611 GetServerActive(server)
614 DoMethod
616 data->netped_serverList,
617 MUIM_List_InsertSingle, &serverentry, MUIV_List_Insert_Bottom
621 SET(data->netped_serverList, MUIA_List_Quiet, FALSE);
623 return TRUE;
626 void DisplayErrorMessage(Object * obj, enum ErrorCode errorcode)
628 CONST_STRPTR title = _(MSG_ERROR_TITLE);
629 CONST_STRPTR errormessage = NULL;
630 CONST_STRPTR additionaldata = NULL;
631 Object * app = NULL;
632 Object * wnd = NULL;
634 GET(obj, MUIA_ApplicationObject, &app);
635 GET(obj, MUIA_Window_Window, &wnd);
637 switch(errorcode)
639 case UNKNOWN_ERROR:
640 errormessage = _(MSG_ERR_UNKNOWN_ERROR);
641 break;
642 case NOT_RESTARTED_WIRELESS:
643 errormessage = _(MSG_ERR_NOT_RESTARTED_WIRELESS);
644 break;
645 case NOT_RESTARTED_MOBILE:
646 errormessage = _(MSG_ERR_NOT_RESTARTED_MOBILE);
647 break;
648 case NOT_RESTARTED_STACK:
649 errormessage = _(MSG_ERR_NOT_RESTARTED_STACK);
650 break;
651 case NOT_SAVED_PREFS_ENV:
652 errormessage = _(MSG_ERR_NOT_SAVED_PREFS);
653 additionaldata = PREFS_PATH_ENV;
654 break;
655 case NOT_SAVED_PREFS_ENVARC:
656 errormessage = _(MSG_ERR_NOT_SAVED_PREFS);
657 additionaldata = PREFS_PATH_ENVARC;
658 break;
659 case NOT_COPIED_FILES_ENV:
660 errormessage = _(MSG_ERR_NOT_COPIED_FILES);
661 additionaldata = PREFS_PATH_ENV;
662 break;
663 case NOT_COPIED_FILES_ENVARC:
664 errormessage = _(MSG_ERR_NOT_COPIED_FILES);
665 additionaldata = PREFS_PATH_ENVARC;
666 break;
667 case MULTIPLE_IFACES:
668 errormessage = _(MSG_WARN_MULTIPLE_IFACES);
669 title = _(MSG_WARNING_TITLE);
670 break;
671 case ALL_OK:
672 return;
675 MUI_Request(app, wnd, 0, title, _(MSG_BUTTON_OK), errormessage,
676 additionaldata);
679 /*** Methods ****************************************************************/
680 Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message)
682 // main window
683 Object *gateString, *DNSString[2], *hostString, *domainString,
684 *autostart, *interfaceList, *DHCPState,
685 *addButton, *editButton, *removeButton, *inputGroup,
686 *hostList, *hostAddButton, *hostEditButton, *hostRemoveButton,
687 *networkList, *netAddButton, *netEditButton, *netRemoveButton,
688 *serverList, *serverAddButton, *serverEditButton, *serverRemoveButton,
689 *MBBInitString[MAXATCOMMANDS], *MBBDeviceString, *MBBUnit,
690 *MBBUsername, *MBBPassword;
692 // inferface window
693 Object *deviceString, *IPString, *maskString,
694 *ifDHCPState, *unitString, *nameString, *upState,
695 *ifWindow, *applyButton, *closeButton;
697 // host window
698 Object *hostNamesString, *hostAddressString, *hostWindow,
699 *hostApplyButton, *hostCloseButton;
701 // network window
702 Object *sSIDString, *keyString, *encType, *keyType, *hiddenState,
703 *adHocState, *netWindow, *netApplyButton, *netCloseButton;
705 // file-server window
706 Object *serverWindow, *serverServiceType, *serverDevice, *serverActive, *serverHost,
707 *serverService, *serverUser, *serverGroup, *serverPass,
708 *serverApplyButton, *serverCloseButton;
710 DHCPCycle[0] = _(MSG_IP_MODE_MANUAL);
711 DHCPCycle[1] = _(MSG_IP_MODE_DHCP);
713 EncCycle[0] = _(MSG_ENC_NONE);
714 EncCycle[1] = _(MSG_ENC_WEP);
715 EncCycle[2] = _(MSG_ENC_WPA);
717 KeyCycle[0] = _(MSG_KEY_TEXT);
718 KeyCycle[1] = _(MSG_KEY_HEX);
720 ServiceTypeCycle[0] = _(MSG_SERVICETYPE_CIFS);
722 NetworkTabs[0] = _(MSG_TAB_IP_CONFIGURATION);
723 NetworkTabs[1] = _(MSG_TAB_COMPUTER_NAMES);
724 NetworkTabs[2] = _(MSG_TAB_WIRELESS);
725 NetworkTabs[3] = _(MSG_TAB_MOBILE);
726 NetworkTabs[4] = _(MSG_TAB_SERVERS);
728 netpeditor_constructHook.h_Entry = (HOOKFUNC)constructFunc;
729 netpeditor_destructHook.h_Entry = (HOOKFUNC)destructFunc;
730 netpeditor_displayHook.h_Entry = (HOOKFUNC)displayFunc;
732 hosts_constructHook.h_Entry = (HOOKFUNC)hostsConstructFunc;
733 hosts_destructHook.h_Entry = (HOOKFUNC)hostsDestructFunc;
734 hosts_displayHook.h_Entry = (HOOKFUNC)hostsDisplayFunc;
736 wireless_constructHook.h_Entry = (HOOKFUNC)netConstructFunc;
737 wireless_destructHook.h_Entry = (HOOKFUNC)netDestructFunc;
738 wireless_displayHook.h_Entry = (HOOKFUNC)netDisplayFunc;
740 server_constructHook.h_Entry = (HOOKFUNC)serverConstructFunc;
741 server_destructHook.h_Entry = (HOOKFUNC)serverDestructFunc;
742 server_displayHook.h_Entry = (HOOKFUNC)serverDisplayFunc;
744 self = (Object *)DoSuperNewTags
746 CLASS, self, NULL,
748 MUIA_PrefsEditor_Name, __(MSG_NAME),
749 MUIA_PrefsEditor_Path, (IPTR)"AROSTCP/arostcp.prefs",
751 Child, RegisterGroup((IPTR)NetworkTabs),
753 Child, (IPTR)VGroup,
754 Child, (IPTR)(HGroup,
755 GroupFrame,
756 Child, (IPTR)ListviewObject,
757 MUIA_Listview_List, (IPTR)(interfaceList = (Object *)ListObject,
758 ReadListFrame,
759 MUIA_List_Title, TRUE,
760 MUIA_List_Format, (IPTR)"BAR,P=\33c BAR,BAR,BAR,",
761 MUIA_List_ConstructHook, (IPTR)&netpeditor_constructHook,
762 MUIA_List_DestructHook, (IPTR)&netpeditor_destructHook,
763 MUIA_List_DisplayHook, (IPTR)&netpeditor_displayHook,
764 End),
765 End,
766 Child, (IPTR)(VGroup,
767 MUIA_HorizWeight, 0,
768 Child, (IPTR)(addButton = SimpleButton(_(MSG_BUTTON_ADD))),
769 Child, (IPTR)(editButton = SimpleButton(_(MSG_BUTTON_EDIT))),
770 Child, (IPTR)(removeButton = SimpleButton(_(MSG_BUTTON_REMOVE))),
771 Child, (IPTR)HVSpace,
772 End),
773 End),
774 Child, (IPTR)(inputGroup = (Object *)ColGroup(4),
775 GroupFrame,
776 Child, (IPTR)Label2(__(MSG_IP_MODE)),
777 Child, (IPTR)(DHCPState = (Object *)CycleObject,
778 MUIA_Cycle_Entries, (IPTR)DHCPCycle,
779 End),
780 Child, (IPTR)Label2(__(MSG_GATE)),
781 Child, (IPTR)(gateString = (Object *)StringObject,
782 StringFrame,
783 MUIA_String_Accept, (IPTR)IPCHARS,
784 MUIA_CycleChain, 1,
785 MUIA_FixWidthTxt, (IPTR)max_ip_str,
786 End),
787 Child, (IPTR)Label2(__(MSG_HOST_NAME)),
788 Child, (IPTR)(hostString = (Object *)StringObject,
789 StringFrame,
790 MUIA_String_Accept, (IPTR)NAMECHARS,
791 MUIA_CycleChain, 1,
792 End),
793 Child, (IPTR)Label2(__(MSG_DNS1)),
794 Child, (IPTR)(DNSString[0] = (Object *)StringObject,
795 StringFrame,
796 MUIA_String_Accept, (IPTR)IPCHARS,
797 MUIA_CycleChain, 1,
798 MUIA_FixWidthTxt, (IPTR)max_ip_str,
799 End),
800 Child, (IPTR)Label2(__(MSG_DOMAIN_NAME)),
801 Child, (IPTR)(domainString = (Object *)StringObject,
802 StringFrame,
803 MUIA_String_Accept, (IPTR)NAMECHARS,
804 MUIA_CycleChain, 1,
805 End),
806 Child, (IPTR)Label2(__(MSG_DNS2)),
807 Child, (IPTR)(DNSString[1] = (Object *)StringObject,
808 StringFrame,
809 MUIA_String_Accept, (IPTR)IPCHARS,
810 MUIA_CycleChain, 1,
811 MUIA_FixWidthTxt, (IPTR)max_ip_str,
812 End),
813 End),
814 Child, (IPTR)ColGroup(2),
815 Child, (IPTR)(autostart = MUI_MakeObject(MUIO_Checkmark, NULL)),
816 Child, (IPTR)HGroup,
817 Child, (IPTR)Label2(__(MSG_AUTOSTART_STACK)),
818 Child, (IPTR)HVSpace,
819 End,
820 End,
821 End,
823 Child, (IPTR)VGroup,
824 Child, (IPTR)(HGroup,
825 GroupFrame,
826 Child, (IPTR)ListviewObject,
827 MUIA_Listview_List, (IPTR)(hostList = (Object *)ListObject,
828 ReadListFrame,
829 MUIA_List_Title, TRUE,
830 MUIA_List_Format, (IPTR)"BAR,",
831 MUIA_List_ConstructHook, (IPTR)&hosts_constructHook,
832 MUIA_List_DestructHook, (IPTR)&hosts_destructHook,
833 MUIA_List_DisplayHook, (IPTR)&hosts_displayHook,
834 End),
835 End,
836 Child, (IPTR)(VGroup,
837 MUIA_HorizWeight, 0,
838 Child, (IPTR)(hostAddButton = SimpleButton(_(MSG_BUTTON_ADD))),
839 Child, (IPTR)(hostEditButton = SimpleButton(_(MSG_BUTTON_EDIT))),
840 Child, (IPTR)(hostRemoveButton = SimpleButton(_(MSG_BUTTON_REMOVE))),
841 Child, (IPTR)HVSpace,
842 End),
843 End),
844 End,
846 Child, (IPTR)VGroup,
847 Child, (IPTR)(HGroup,
848 GroupFrame,
849 Child, (IPTR)ListviewObject,
850 MUIA_Listview_List, (IPTR)(networkList = (Object *)ListObject,
851 ReadListFrame,
852 MUIA_List_Title, TRUE,
853 MUIA_List_Format, (IPTR)"BAR,BAR,BAR,",
854 MUIA_List_ConstructHook, (IPTR)&wireless_constructHook,
855 MUIA_List_DestructHook, (IPTR)&wireless_destructHook,
856 MUIA_List_DisplayHook, (IPTR)&wireless_displayHook,
857 End),
858 End,
859 Child, (IPTR)(VGroup,
860 MUIA_HorizWeight, 0,
861 Child, (IPTR)(netAddButton = SimpleButton(_(MSG_BUTTON_ADD))),
862 Child, (IPTR)(netEditButton = SimpleButton(_(MSG_BUTTON_EDIT))),
863 Child, (IPTR)(netRemoveButton = SimpleButton(_(MSG_BUTTON_REMOVE))),
864 Child, (IPTR)HVSpace,
865 End),
866 End),
867 End,
869 Child, (IPTR)VGroup,
871 Child, (IPTR)ColGroup(2),
872 GroupFrame,
873 Child, (IPTR)HGroup,
874 Child, (IPTR)Label2(_(MSG_SERIAL_DEVICE)),
875 Child, (IPTR)(MBBDeviceString = (Object *)StringObject,
876 StringFrame,
877 MUIA_CycleChain, 1,
878 End),
880 Child, (IPTR)Label2(_(MSG_UNIT_NUMBER)),
881 Child, (IPTR)(MBBUnit = (Object *)NumericbuttonObject,
882 MUIA_Numeric_Min, 0,
883 MUIA_Numeric_Max, 100,
884 End),
886 End,
887 End,
889 Child, (IPTR)ColGroup(2),
890 GroupFrame,
891 Child, (IPTR)HGroup,
892 Child, (IPTR)Label2(_(MSG_USERNAME)),
893 Child, (IPTR)(MBBUsername = (Object *)StringObject,
894 StringFrame,
895 MUIA_CycleChain, 1,
896 End),
897 Child, (IPTR)Label2(_(MSG_PASSWORD)),
898 Child, (IPTR)(MBBPassword = (Object *)StringObject,
899 StringFrame,
900 MUIA_String_Secret, TRUE,
901 MUIA_CycleChain, 1,
902 End),
903 End,
904 End,
906 Child, (IPTR)ColGroup(2),
907 GroupFrame,
908 Child, (IPTR)Label2("Init1"),
909 Child, (IPTR)(MBBInitString[0] = (Object *)StringObject,
910 StringFrame,
911 MUIA_CycleChain, 1,
912 End),
914 Child, (IPTR)Label2("Init2"),
915 Child, (IPTR)(MBBInitString[1] = (Object *)StringObject,
916 StringFrame,
917 MUIA_CycleChain, 1,
918 End),
920 Child, (IPTR)Label2("Init3"),
921 Child, (IPTR)(MBBInitString[2] = (Object *)StringObject,
922 StringFrame,
923 MUIA_CycleChain, 1,
924 End),
926 Child, (IPTR)Label2("Init4"),
927 Child, (IPTR)(MBBInitString[3] = (Object *)StringObject,
928 StringFrame,
929 MUIA_CycleChain, 1,
930 End),
932 Child, (IPTR)Label2("Init5"),
933 Child, (IPTR)(MBBInitString[4] = (Object *)StringObject,
934 StringFrame,
935 MUIA_CycleChain, 1,
936 End),
937 End,
939 End,
941 Child, (IPTR)VGroup,
942 Child, (IPTR)(HGroup,
943 GroupFrame,
944 Child, (IPTR)ListviewObject,
945 MUIA_Listview_List, (IPTR)(serverList = (Object *)ListObject,
946 ReadListFrame,
947 MUIA_List_Title, TRUE,
948 MUIA_List_Format, (IPTR)"BAR,P=\33c BAR,BAR,BAR,BAR,",
949 MUIA_List_ConstructHook, (IPTR)&server_constructHook,
950 MUIA_List_DestructHook, (IPTR)&server_destructHook,
951 MUIA_List_DisplayHook, (IPTR)&server_displayHook,
952 End),
953 End,
954 Child, (IPTR)(VGroup,
955 MUIA_HorizWeight, 0,
956 Child, (IPTR)(serverAddButton = SimpleButton(_(MSG_BUTTON_ADD))),
957 Child, (IPTR)(serverEditButton = SimpleButton(_(MSG_BUTTON_EDIT))),
958 Child, (IPTR)(serverRemoveButton = SimpleButton(_(MSG_BUTTON_REMOVE))),
959 Child, (IPTR)HVSpace,
960 End),
961 End),
962 End,
964 End, // register
966 TAG_DONE
969 ifWindow = (Object *)WindowObject,
970 MUIA_Window_Title, __(MSG_IFWINDOW_TITLE),
971 MUIA_Window_ID, MAKE_ID('I', 'P', 'W', 'I'),
972 MUIA_Window_CloseGadget, FALSE,
973 WindowContents, (IPTR)VGroup,
974 GroupFrame,
975 Child, (IPTR)HGroup,
976 Child, (IPTR)HVSpace,
977 Child, (IPTR)ImageObject,
978 MUIA_Image_Spec, (IPTR)"3:Images:interface",
979 MUIA_FixWidth, 52,
980 MUIA_FixHeight, 48,
981 End,
982 Child, (IPTR)HVSpace,
983 End,
984 Child, (IPTR)ColGroup(2),
985 GroupFrame,
986 Child, (IPTR)Label2(_(MSG_IFNAME)),
987 Child, (IPTR)HGroup,
988 Child, (IPTR)(nameString = (Object *)StringObject,
989 StringFrame,
990 MUIA_String_Accept, (IPTR)NAMECHARS,
991 MUIA_CycleChain, 1,
992 End),
993 Child, (IPTR)(upState = MUI_MakeObject(MUIO_Checkmark, NULL)),
994 Child, (IPTR)Label2(_(MSG_UP)),
995 Child, (IPTR)HVSpace,
996 End,
997 Child, (IPTR)Label2(__(MSG_DEVICE)),
998 Child, (IPTR)PopaslObject,
999 MUIA_Popasl_Type, ASL_FileRequest,
1000 ASLFO_MaxHeight, 100,
1001 MUIA_Popstring_String, (IPTR)(deviceString = (Object *)StringObject,
1002 StringFrame,
1003 MUIA_Background, MUII_TextBack,
1004 MUIA_CycleChain, 1,
1005 End),
1006 MUIA_Popstring_Button, (IPTR)PopButton(MUII_PopUp),
1007 End,
1008 Child, (IPTR)Label2(_(MSG_UNIT)),
1009 Child, (IPTR)HGroup,
1010 Child, (IPTR)(unitString = (Object *)StringObject,
1011 StringFrame,
1012 MUIA_String_Accept, (IPTR)"0123456789",
1013 MUIA_CycleChain, 1,
1014 MUIA_FixWidthTxt, (IPTR)"0",
1015 End),
1016 Child, (IPTR)HVSpace,
1017 End,
1018 End,
1019 Child, (IPTR)ColGroup(4),
1020 GroupFrame,
1021 Child, (IPTR)Label2(__(MSG_IP_MODE)),
1022 Child, (IPTR)(ifDHCPState = (Object *)CycleObject,
1023 MUIA_Cycle_Entries, (IPTR)DHCPCycle,
1024 End),
1025 Child, (IPTR)Label2(__(MSG_IP)),
1026 Child, (IPTR)(IPString = (Object *)StringObject,
1027 StringFrame,
1028 MUIA_String_Accept, (IPTR)IPCHARS,
1029 MUIA_CycleChain, 1,
1030 MUIA_FixWidthTxt, (IPTR)max_ip_str,
1031 End),
1032 Child, (IPTR)HVSpace,
1033 Child, (IPTR)HVSpace,
1034 Child, (IPTR)Label2(__(MSG_MASK)),
1035 Child, (IPTR)(maskString = (Object *)StringObject,
1036 StringFrame,
1037 MUIA_String_Accept, (IPTR)IPCHARS,
1038 MUIA_CycleChain, 1,
1039 MUIA_FixWidthTxt, (IPTR)max_ip_str,
1040 End),
1041 End,
1042 Child, (IPTR)HGroup,
1043 Child, (IPTR)(applyButton = ImageButton(_(MSG_BUTTON_APPLY), "THEME:Images/Gadgets/Prefs/Save")),
1044 Child, (IPTR)(closeButton = ImageButton(_(MSG_BUTTON_CLOSE), "THEME:Images/Gadgets/Prefs/Cancel")),
1045 End,
1046 End,
1047 End;
1049 hostWindow = (Object *)WindowObject,
1050 MUIA_Window_Title, __(MSG_HOST_NAMES),
1051 MUIA_Window_ID, MAKE_ID('H', 'O', 'S', 'T'),
1052 MUIA_Window_CloseGadget, FALSE,
1053 MUIA_Window_SizeGadget, TRUE,
1054 WindowContents, (IPTR)VGroup,
1055 GroupFrame,
1056 Child, (IPTR)HGroup,
1057 Child, (IPTR)HVSpace,
1058 Child, (IPTR)ImageObject,
1059 MUIA_Image_Spec, (IPTR)"3:Images:host",
1060 MUIA_FixWidth, 26,
1061 MUIA_FixHeight, 50,
1062 End,
1063 Child, (IPTR)HVSpace,
1064 End,
1065 Child, (IPTR)ColGroup(2),
1066 GroupFrame,
1067 Child, (IPTR)Label2(__(MSG_IP)),
1068 Child, (IPTR)(hostAddressString = (Object *)StringObject,
1069 StringFrame,
1070 MUIA_CycleChain, 1,
1071 End),
1072 Child, (IPTR)Label2(_(MSG_HOSTWINDOW_TITLE)),
1073 Child, (IPTR)(hostNamesString = (Object *)StringObject,
1074 StringFrame,
1075 MUIA_CycleChain, 1,
1076 End),
1077 End,
1078 Child, (IPTR)HGroup,
1079 Child, (IPTR)(hostApplyButton = ImageButton(_(MSG_BUTTON_APPLY), "THEME:Images/Gadgets/Save")),
1080 Child, (IPTR)(hostCloseButton = ImageButton(_(MSG_BUTTON_CLOSE), "THEME:Images/Gadgets/Cancel")),
1081 End,
1082 End,
1083 End;
1085 netWindow = (Object *)WindowObject,
1086 MUIA_Window_Title, __(MSG_NETWINDOW_TITLE),
1087 MUIA_Window_ID, MAKE_ID('W', 'I', 'F', 'I'),
1088 MUIA_Window_CloseGadget, FALSE,
1089 MUIA_Window_SizeGadget, TRUE,
1090 WindowContents, (IPTR)VGroup,
1091 GroupFrame,
1092 Child, (IPTR)HGroup,
1093 Child, (IPTR)HVSpace,
1094 Child, (IPTR)ImageObject,
1095 MUIA_Image_Spec, (IPTR)"3:Images:wireless",
1096 MUIA_FixWidth, 50,
1097 MUIA_FixHeight, 50,
1098 End,
1099 Child, (IPTR)HVSpace,
1100 End,
1101 Child, (IPTR)ColGroup(2),
1102 GroupFrame,
1103 Child, (IPTR)Label2(_(MSG_SSID)),
1104 Child, (IPTR)(sSIDString = (Object *)StringObject,
1105 StringFrame,
1106 MUIA_CycleChain, 1,
1107 End),
1109 Child, (IPTR)Label2(__(MSG_ENCTYPE)),
1110 Child, (IPTR)(encType = (Object *)CycleObject,
1111 MUIA_Cycle_Entries, (IPTR)EncCycle,
1112 End),
1113 Child, (IPTR)Label2(__(MSG_KEYTYPE)),
1114 Child, (IPTR)(keyType = (Object *)CycleObject,
1115 MUIA_Cycle_Entries, (IPTR)KeyCycle,
1116 End),
1117 Child, (IPTR)Label2(__(MSG_KEY)),
1118 Child, (IPTR)(keyString = (Object *)StringObject,
1119 StringFrame,
1120 MUIA_String_Secret, TRUE,
1121 MUIA_CycleChain, 1,
1122 End),
1123 Child, (IPTR)HGroup,
1124 Child, (IPTR)(hiddenState = MUI_MakeObject(MUIO_Checkmark, NULL)),
1125 Child, (IPTR)Label2(_(MSG_HIDDEN)),
1126 Child, (IPTR)HVSpace,
1127 End,
1128 Child, (IPTR)HGroup,
1129 Child, (IPTR)(adHocState = MUI_MakeObject(MUIO_Checkmark, NULL)),
1130 Child, (IPTR)Label2(_(MSG_ADHOC)),
1131 Child, (IPTR)HVSpace,
1132 End,
1133 End,
1134 Child, (IPTR)HGroup,
1135 Child, (IPTR)(netApplyButton = ImageButton(_(MSG_BUTTON_APPLY), "THEME:Images/Gadgets/Save")),
1136 Child, (IPTR)(netCloseButton = ImageButton(_(MSG_BUTTON_CLOSE), "THEME:Images/Gadgets/Cancel")),
1137 End,
1138 End,
1139 End;
1141 serverWindow = (Object *)WindowObject,
1142 MUIA_Window_Title, __(MSG_SERVERWINDOW_TITLE),
1143 MUIA_Window_ID, MAKE_ID('S', 'H', 'R', 'E'),
1144 MUIA_Window_CloseGadget, FALSE,
1145 MUIA_Window_SizeGadget, TRUE,
1146 WindowContents, (IPTR)VGroup,
1147 GroupFrame,
1148 Child, (IPTR)HGroup,
1149 Child, (IPTR)HVSpace,
1150 Child, (IPTR)ImageObject,
1151 MUIA_Image_Spec, (IPTR)"3:Images:host",
1152 MUIA_FixWidth, 26,
1153 MUIA_FixHeight, 50,
1154 End,
1155 Child, (IPTR)HVSpace,
1156 End,
1157 Child, (IPTR)ColGroup(2),
1158 GroupFrame,
1159 Child, (IPTR)Label2(_(MSG_SERVICE_TYPES)),
1160 Child, (IPTR)(serverServiceType = (Object *)CycleObject,
1161 MUIA_Cycle_Entries, (IPTR)ServiceTypeCycle,
1162 End),
1163 Child, (IPTR)Label2(_(MSG_DEVICE)),
1164 Child, (IPTR)(serverDevice = (Object *)StringObject,
1165 StringFrame,
1166 MUIA_CycleChain, 1,
1167 End),
1168 Child, (IPTR)HVSpace,
1169 Child, (IPTR)HGroup,
1170 Child, (IPTR)(serverActive = MUI_MakeObject(MUIO_Checkmark, NULL)),
1171 Child, (IPTR)Label2(_(MSG_UP)),
1172 Child, (IPTR)HVSpace,
1173 End,
1174 Child, (IPTR)Label2(_(MSG_HOST_NAME)),
1175 Child, (IPTR)(serverHost = (Object *)StringObject,
1176 StringFrame,
1177 MUIA_CycleChain, 1,
1178 End),
1179 Child, (IPTR)Label2(__(MSG_WORKGROUP)),
1180 Child, (IPTR)(serverGroup = (Object *)StringObject,
1181 StringFrame,
1182 MUIA_CycleChain, 1,
1183 End),
1184 Child, (IPTR)Label2(__(MSG_SERVICE)),
1185 Child, (IPTR)(serverService = (Object *)StringObject,
1186 StringFrame,
1187 MUIA_CycleChain, 1,
1188 End),
1189 Child, (IPTR)Label2(__(MSG_USERNAME)),
1190 Child, (IPTR)(serverUser = (Object *)StringObject,
1191 StringFrame,
1192 MUIA_CycleChain, 1,
1193 End),
1194 Child, (IPTR)Label2(__(MSG_PASSWORD)),
1195 Child, (IPTR)(serverPass = (Object *)StringObject,
1196 StringFrame,
1197 MUIA_String_Secret, TRUE,
1198 MUIA_CycleChain, 1,
1199 End),
1200 End,
1201 Child, (IPTR)HGroup,
1202 Child, (IPTR)(serverApplyButton = ImageButton(_(MSG_BUTTON_APPLY), "THEME:Images/Gadgets/Save")),
1203 Child, (IPTR)(serverCloseButton = ImageButton(_(MSG_BUTTON_CLOSE), "THEME:Images/Gadgets/Cancel")),
1204 End,
1205 End,
1206 End;
1208 if (self != NULL && ifWindow != NULL && hostWindow != NULL
1209 && netWindow != NULL && serverWindow != NULL)
1211 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1213 // main window
1214 data->netped_DHCPState = DHCPState;
1215 data->netped_gateString = gateString;
1216 data->netped_DNSString[0] = DNSString[0];
1217 data->netped_DNSString[1] = DNSString[1];
1218 data->netped_hostString = hostString;
1219 data->netped_domainString = domainString;
1220 data->netped_Autostart = autostart;
1221 data->netped_interfaceList = interfaceList;
1222 data->netped_inputGroup = inputGroup;
1223 data->netped_addButton = addButton;
1224 data->netped_editButton = editButton;
1225 data->netped_removeButton = removeButton;
1226 data->netped_hostList = hostList;
1227 data->netped_hostAddButton = hostAddButton;
1228 data->netped_hostEditButton = hostEditButton;
1229 data->netped_hostRemoveButton = hostRemoveButton;
1230 data->netped_networkList = networkList;
1231 data->netped_netAddButton = netAddButton;
1232 data->netped_netEditButton = netEditButton;
1233 data->netped_netRemoveButton = netRemoveButton;
1234 data->netped_serverList = serverList;
1235 data->netped_serverAddButton = serverAddButton;
1236 data->netped_serverEditButton = serverEditButton;
1237 data->netped_serverRemoveButton = serverRemoveButton;
1239 data->netped_MBBInitString[0] = MBBInitString[0];
1240 data->netped_MBBInitString[1] = MBBInitString[1];
1241 data->netped_MBBInitString[2] = MBBInitString[2];
1242 data->netped_MBBInitString[3] = MBBInitString[3];
1243 data->netped_MBBInitString[4] = MBBInitString[4];
1244 data->netped_MBBDeviceString = MBBDeviceString;
1245 data->netped_MBBUnit = MBBUnit;
1246 data->netped_MBBUsername = MBBUsername;
1247 data->netped_MBBPassword = MBBPassword;
1249 // interface window
1250 data->netped_ifWindow = ifWindow;
1251 data->netped_upState = upState;
1252 data->netped_ifDHCPState = ifDHCPState;
1253 data->netped_nameString = nameString;
1254 data->netped_deviceString = deviceString;
1255 data->netped_unitString = unitString;
1256 data->netped_IPString = IPString;
1257 data->netped_maskString = maskString;
1258 data->netped_applyButton = applyButton;
1259 data->netped_closeButton = closeButton;
1261 // host window
1262 data->netped_hostWindow = hostWindow;
1263 data->netped_hostAddressString = hostAddressString;
1264 data->netped_hostNamesString = hostNamesString;
1265 data->netped_hostApplyButton = hostApplyButton;
1266 data->netped_hostCloseButton = hostCloseButton;
1268 // wireless window
1269 data->netped_netWindow = netWindow;
1270 data->netped_hiddenState = hiddenState;
1271 data->netped_adHocState = adHocState;
1272 data->netped_sSIDString = sSIDString;
1273 data->netped_encType = encType;
1274 data->netped_keyType = keyType;
1275 data->netped_keyString = keyString;
1276 data->netped_netApplyButton = netApplyButton;
1277 data->netped_netCloseButton = netCloseButton;
1279 // file-server window
1280 data->netped_serverWindow = serverWindow;
1281 data->netped_serverServiceType = serverServiceType;
1282 data->netped_serverDevice = serverDevice;
1283 data->netped_serverActive = serverActive;
1284 data->netped_serverHost = serverHost;
1285 data->netped_serverService = serverService;
1286 data->netped_serverUser = serverUser;
1287 data->netped_serverGroup = serverGroup;
1288 data->netped_serverPass = serverPass;
1289 data->netped_serverApplyButton = serverApplyButton;
1290 data->netped_serverCloseButton = serverCloseButton;
1292 SET(removeButton, MUIA_Disabled, TRUE);
1293 SET(editButton, MUIA_Disabled, TRUE);
1295 SET(hostRemoveButton, MUIA_Disabled, TRUE);
1296 SET(hostEditButton, MUIA_Disabled, TRUE);
1298 SET(netRemoveButton, MUIA_Disabled, TRUE);
1299 SET(netEditButton, MUIA_Disabled, TRUE);
1301 SET(serverRemoveButton, MUIA_Disabled, TRUE);
1302 SET(serverEditButton, MUIA_Disabled, TRUE);
1304 /*-- Set up notifications ------------------------------------------*/
1306 // main window
1307 DoMethod
1309 interfaceList, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime,
1310 (IPTR)self, 1, MUIM_NetPEditor_ShowEntry
1312 DoMethod
1314 interfaceList, MUIM_Notify, MUIA_Listview_DoubleClick, MUIV_EveryTime,
1315 (IPTR)self, 3, MUIM_NetPEditor_EditEntry, FALSE
1318 DoMethod
1320 gateString, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
1321 (IPTR)self, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
1323 DoMethod
1325 DNSString[0], MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
1326 (IPTR)self, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
1328 DoMethod
1330 DNSString[1], MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
1331 (IPTR)self, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
1333 DoMethod
1335 hostString, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
1336 (IPTR)self, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
1338 DoMethod
1340 domainString, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
1341 (IPTR)self, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
1343 DoMethod
1345 autostart, MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
1346 (IPTR)self, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
1348 DoMethod
1350 DHCPState, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime,
1351 (IPTR)self, 2, MUIM_NetPEditor_IPModeChanged, FALSE
1354 DoMethod
1356 addButton, MUIM_Notify, MUIA_Pressed, FALSE,
1357 (IPTR)self, 2, MUIM_NetPEditor_EditEntry, TRUE
1359 DoMethod
1361 editButton, MUIM_Notify, MUIA_Pressed, FALSE,
1362 (IPTR)self, 2, MUIM_NetPEditor_EditEntry, FALSE
1364 DoMethod
1366 removeButton, MUIM_Notify, MUIA_Pressed, FALSE,
1367 (IPTR)interfaceList, 2, MUIM_List_Remove, MUIV_List_Remove_Active
1370 DoMethod
1372 hostList, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime,
1373 (IPTR)self, 1, MUIM_NetPEditor_ShowHostEntry
1375 DoMethod
1377 hostList, MUIM_Notify, MUIA_Listview_DoubleClick, MUIV_EveryTime,
1378 (IPTR)self, 3, MUIM_NetPEditor_EditHostEntry, FALSE
1381 DoMethod
1383 hostAddButton, MUIM_Notify, MUIA_Pressed, FALSE,
1384 (IPTR)self, 2, MUIM_NetPEditor_EditHostEntry, TRUE
1386 DoMethod
1388 hostEditButton, MUIM_Notify, MUIA_Pressed, FALSE,
1389 (IPTR)self, 1, MUIM_NetPEditor_EditHostEntry, FALSE
1391 DoMethod
1393 hostRemoveButton, MUIM_Notify, MUIA_Pressed, FALSE,
1394 (IPTR)hostList, 2, MUIM_List_Remove, MUIV_List_Remove_Active
1397 DoMethod
1399 networkList, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime,
1400 (IPTR)self, 1, MUIM_NetPEditor_ShowNetEntry
1402 DoMethod
1404 networkList, MUIM_Notify, MUIA_Listview_DoubleClick, MUIV_EveryTime,
1405 (IPTR)self, 3, MUIM_NetPEditor_EditNetEntry, FALSE
1408 DoMethod
1410 netAddButton, MUIM_Notify, MUIA_Pressed, FALSE,
1411 (IPTR)self, 2, MUIM_NetPEditor_EditNetEntry, TRUE
1413 DoMethod
1415 netEditButton, MUIM_Notify, MUIA_Pressed, FALSE,
1416 (IPTR)self, 1, MUIM_NetPEditor_EditNetEntry, FALSE
1418 DoMethod
1420 netRemoveButton, MUIM_Notify, MUIA_Pressed, FALSE,
1421 (IPTR)networkList, 2, MUIM_List_Remove, MUIV_List_Remove_Active
1424 DoMethod
1426 MBBDeviceString, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
1427 (IPTR)self, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
1430 DoMethod
1432 MBBUnit, MUIM_Notify, MUIA_Numeric_Value, MUIV_EveryTime,
1433 (IPTR)self, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
1435 DoMethod
1437 MBBUsername, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
1438 (IPTR)self, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
1440 DoMethod
1442 MBBPassword, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
1443 (IPTR)self, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
1445 LONG i;
1446 for(i=0;i<MAXATCOMMANDS;i++)
1447 DoMethod
1449 MBBInitString[i], MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
1450 (IPTR)self, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
1453 DoMethod
1455 serverList, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime,
1456 (IPTR)self, 1, MUIM_NetPEditor_ShowServerEntry
1458 DoMethod
1460 serverList, MUIM_Notify, MUIA_Listview_DoubleClick, MUIV_EveryTime,
1461 (IPTR)self, 3, MUIM_NetPEditor_EditServerEntry, FALSE
1464 DoMethod
1466 serverAddButton, MUIM_Notify, MUIA_Pressed, FALSE,
1467 (IPTR)self, 2, MUIM_NetPEditor_EditServerEntry, TRUE
1469 DoMethod
1471 serverEditButton, MUIM_Notify, MUIA_Pressed, FALSE,
1472 (IPTR)self, 1, MUIM_NetPEditor_EditServerEntry, FALSE
1474 DoMethod
1476 serverRemoveButton, MUIM_Notify, MUIA_Pressed, FALSE,
1477 (IPTR)serverList, 2, MUIM_List_Remove, MUIV_List_Remove_Active
1480 // interface window
1481 DoMethod
1483 ifDHCPState, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime,
1484 (IPTR)self, 2, MUIM_NetPEditor_IPModeChanged, TRUE
1486 DoMethod
1488 upState, MUIM_Notify, MUIA_Selected, MUIV_EveryTime,
1489 (IPTR)self, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE
1492 DoMethod
1494 applyButton, MUIM_Notify, MUIA_Pressed, FALSE,
1495 (IPTR)self, 1, MUIM_NetPEditor_ApplyEntry
1497 DoMethod
1499 closeButton, MUIM_Notify, MUIA_Pressed, FALSE,
1500 (IPTR)ifWindow, 3, MUIM_Set, MUIA_Window_Open, FALSE
1503 // host window
1504 DoMethod
1506 hostApplyButton, MUIM_Notify, MUIA_Pressed, FALSE,
1507 (IPTR)self, 1, MUIM_NetPEditor_ApplyHostEntry
1509 DoMethod
1511 hostCloseButton, MUIM_Notify, MUIA_Pressed, FALSE,
1512 (IPTR)hostWindow, 3, MUIM_Set, MUIA_Window_Open, FALSE
1515 // network window
1516 DoMethod
1518 netApplyButton, MUIM_Notify, MUIA_Pressed, FALSE,
1519 (IPTR)self, 1, MUIM_NetPEditor_ApplyNetEntry
1521 DoMethod
1523 netCloseButton, MUIM_Notify, MUIA_Pressed, FALSE,
1524 (IPTR)netWindow, 3, MUIM_Set, MUIA_Window_Open, FALSE
1527 // server window
1528 DoMethod
1530 serverApplyButton, MUIM_Notify, MUIA_Pressed, FALSE,
1531 (IPTR)self, 1, MUIM_NetPEditor_ApplyServerEntry
1533 DoMethod
1535 serverCloseButton, MUIM_Notify, MUIA_Pressed, FALSE,
1536 (IPTR)serverWindow, 3, MUIM_Set, MUIA_Window_Open, FALSE
1540 return self;
1543 IPTR NetPEditor__MUIM_Setup
1545 Class *CLASS, Object *self, Msg message
1548 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1550 if (!DoSuperMethodA(CLASS, self, message)) return FALSE;
1552 DoMethod(_app(self), OM_ADDMEMBER, data->netped_ifWindow);
1553 DoMethod(_app(self), OM_ADDMEMBER, data->netped_hostWindow);
1554 DoMethod(_app(self), OM_ADDMEMBER, data->netped_netWindow);
1555 DoMethod(_app(self), OM_ADDMEMBER, data->netped_serverWindow);
1557 return TRUE;
1560 IPTR NetPEditor__MUIM_Cleanup
1562 Class *CLASS, Object *self, Msg message
1565 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1567 DoMethod(_app(self), OM_REMMEMBER, data->netped_ifWindow);
1568 DoMethod(_app(self), OM_REMMEMBER, data->netped_hostWindow);
1569 DoMethod(_app(self), OM_REMMEMBER, data->netped_netWindow);
1570 DoMethod(_app(self), OM_REMMEMBER, data->netped_serverWindow);
1572 return DoSuperMethodA(CLASS, self, message);
1575 IPTR NetPEditor__MUIM_PrefsEditor_Save
1577 Class *CLASS, Object *self, Msg message
1580 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1581 enum ErrorCode errorcode = UNKNOWN_ERROR;
1583 Gadgets2NetworkPrefs(data);
1585 if ((errorcode = SaveNetworkPrefs()) == ALL_OK)
1587 SET(self, MUIA_PrefsEditor_Changed, FALSE);
1588 SET(self, MUIA_PrefsEditor_Testing, FALSE);
1589 return TRUE;
1592 DisplayErrorMessage(self, errorcode);
1594 /* Prefs saved to disk, but stack not restarted. Inform about restart will 'apply' changes */
1595 if (errorcode == NOT_RESTARTED_STACK)
1597 Object * app = NULL;
1598 Object * wnd = NULL;
1600 GET(self, MUIA_ApplicationObject, &app);
1601 GET(self, MUIA_Window_Window, &wnd);
1603 MUI_Request(app, wnd, 0, _(MSG_INFO_TITLE), _(MSG_BUTTON_OK),
1604 _(MSG_PREFS_SAVED_RESTART), PREFS_PATH_ENVARC);
1606 return TRUE;
1609 return FALSE;
1612 IPTR NetPEditor__MUIM_PrefsEditor_Use
1614 Class *CLASS, Object *self, Msg message
1617 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1618 enum ErrorCode errorcode = UNKNOWN_ERROR;
1620 Gadgets2NetworkPrefs(data);
1622 if ((errorcode = UseNetworkPrefs()) == ALL_OK)
1624 SET(self, MUIA_PrefsEditor_Changed, FALSE);
1625 SET(self, MUIA_PrefsEditor_Testing, FALSE);
1626 return TRUE;
1629 DisplayErrorMessage(self, errorcode);
1631 return FALSE;
1634 IPTR NetPEditor__MUIM_PrefsEditor_ImportFH
1636 Class *CLASS, Object *self,
1637 struct MUIP_PrefsEditor_ImportFH *message
1640 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1641 BOOL success = TRUE;
1643 NetworkPrefs2Gadgets(data);
1645 DoMethod(self, MUIM_NetPEditor_IPModeChanged, TRUE);
1646 DoMethod(self, MUIM_NetPEditor_IPModeChanged, FALSE);
1648 return success;
1651 IPTR NetPEditor__MUIM_PrefsEditor_ExportFH
1653 Class *CLASS, Object *self,
1654 struct MUIP_PrefsEditor_ExportFH *message
1657 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1658 BOOL success = TRUE;
1660 NetworkPrefs2Gadgets(data);
1662 DoMethod(self, MUIM_NetPEditor_IPModeChanged, TRUE);
1663 DoMethod(self, MUIM_NetPEditor_IPModeChanged, FALSE);
1665 return success;
1668 IPTR NetPEditor__MUIM_NetPEditor_IPModeChanged
1670 Class *CLASS, Object *self,
1671 struct MUIP_NetPEditor_IPModeChanged *message
1674 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1675 STRPTR str = NULL;
1676 IPTR lng = 0;
1677 struct Interface *iface;
1679 if (message->interface)
1681 DoMethod
1683 data->netped_interfaceList,
1684 MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &iface
1686 GetAttr(MUIA_Cycle_Active, data->netped_ifDHCPState, &lng);
1688 if (iface != NULL)
1690 if (lng == 1)
1692 /* Clear and disable text boxes, but keep their values for
1693 * later */
1695 SET(data->netped_IPString, MUIA_Disabled, TRUE);
1696 GET(data->netped_IPString, MUIA_String_Contents, &str);
1697 SetIP(iface, str);
1698 SET(data->netped_IPString, MUIA_String_Contents, "");
1700 SET(data->netped_maskString, MUIA_Disabled, TRUE);
1701 GET(data->netped_maskString, MUIA_String_Contents, &str);
1702 SetMask(iface, str);
1703 SET(data->netped_maskString, MUIA_String_Contents, "");
1705 else
1707 /* Enable text boxes, and reset their previous values */
1709 SET(data->netped_IPString, MUIA_Disabled, FALSE);
1710 SET(data->netped_IPString, MUIA_String_Contents,
1711 GetIP(iface));
1713 SET(data->netped_maskString, MUIA_Disabled, FALSE);
1714 SET(data->netped_maskString, MUIA_String_Contents,
1715 GetMask(iface));
1719 else
1721 GetAttr(MUIA_Cycle_Active, data->netped_DHCPState, &lng);
1723 if (lng == 1)
1725 /* Clear and disable text boxes, but keep their values for later */
1727 SET(data->netped_gateString, MUIA_Disabled, TRUE);
1728 GET(data->netped_gateString, MUIA_String_Contents, &str);
1729 SetGate(str);
1730 SET(data->netped_gateString, MUIA_String_Contents, "");
1732 SET(data->netped_DNSString[0], MUIA_Disabled, TRUE);
1733 GET(data->netped_DNSString[0], MUIA_String_Contents, &str);
1734 SetDNS(0, str);
1735 SET(data->netped_DNSString[0], MUIA_String_Contents, "");
1737 SET(data->netped_DNSString[1], MUIA_Disabled, TRUE);
1738 GET(data->netped_DNSString[1], MUIA_String_Contents, &str);
1739 SetDNS(1, str);
1740 SET(data->netped_DNSString[1], MUIA_String_Contents, "");
1742 else
1744 /* Enable text boxes, and reset their previous values */
1746 SET(data->netped_gateString, MUIA_Disabled, FALSE);
1747 SET(data->netped_gateString, MUIA_String_Contents, GetGate());
1749 SET(data->netped_DNSString[0], MUIA_Disabled, FALSE);
1750 SET(data->netped_DNSString[0], MUIA_String_Contents, GetDNS(0));
1752 SET(data->netped_DNSString[1], MUIA_Disabled, FALSE);
1753 SET(data->netped_DNSString[1], MUIA_String_Contents, GetDNS(1));
1757 SET(self, MUIA_PrefsEditor_Changed, TRUE);
1759 return TRUE;
1763 Shows content of current list entry in the interface window.
1765 IPTR NetPEditor__MUIM_NetPEditor_ShowEntry
1767 Class *CLASS, Object *self,
1768 Msg message
1771 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1773 struct Interface *iface;
1775 DoMethod
1777 data->netped_interfaceList,
1778 MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &iface
1780 if (iface)
1782 SET(data->netped_removeButton, MUIA_Disabled, FALSE);
1783 SET(data->netped_editButton, MUIA_Disabled, FALSE);
1785 if (GetIfDHCP(iface))
1787 SET(data->netped_IPString, MUIA_String_Contents, "");
1788 SET(data->netped_maskString, MUIA_String_Contents, "");
1790 else
1792 SET(data->netped_IPString, MUIA_String_Contents, GetIP(iface));
1793 SET(data->netped_maskString, MUIA_String_Contents, GetMask(iface));
1795 SET(data->netped_nameString, MUIA_String_Contents, GetName(iface));
1796 SET(data->netped_upState, MUIA_Selected, GetUp(iface) ? 1 : 0);
1797 SET(data->netped_ifDHCPState, MUIA_Cycle_Active, GetIfDHCP(iface) ? 1 : 0);
1798 SET(data->netped_deviceString, MUIA_String_Contents, GetDevice(iface));
1799 SET(data->netped_unitString, MUIA_String_Integer, GetUnit(iface));
1801 else
1803 SET(data->netped_removeButton, MUIA_Disabled, TRUE);
1804 SET(data->netped_editButton, MUIA_Disabled, TRUE);
1805 SET(data->netped_ifWindow, MUIA_Window_Open, FALSE);
1807 return 0;
1810 IPTR NetPEditor__MUIM_NetPEditor_EditEntry
1812 Class *CLASS, Object *self,
1813 struct MUIP_NetPEditor_EditEntry *message
1816 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1818 if (message->addEntry)
1821 Create a new entry and make it the current one
1823 LONG entries = XGET(data->netped_interfaceList, MUIA_List_Entries);
1824 if (entries < MAXINTERFACES)
1826 struct Interface iface;
1827 InitInterface(&iface);
1828 iface.name[strlen(iface.name) - 1] += entries;
1829 SetUp(&iface, TRUE); // new entries are UP
1830 DoMethod
1832 data->netped_interfaceList,
1833 MUIM_List_InsertSingle, &iface, MUIV_List_Insert_Bottom
1837 /* Warn about DHCP limitations with more than one interface */
1838 if (entries == 1)
1839 DisplayErrorMessage(self, MULTIPLE_IFACES);
1841 SET(data->netped_interfaceList, MUIA_List_Active, entries + 1);
1844 LONG active = XGET(data->netped_interfaceList, MUIA_List_Active);
1845 if (active != MUIV_List_Active_Off)
1847 SET(data->netped_ifWindow, MUIA_Window_Open, TRUE);
1850 return 0;
1854 Store data from interface window back in current list entry
1856 IPTR NetPEditor__MUIM_NetPEditor_ApplyEntry
1858 Class *CLASS, Object *self,
1859 Msg message
1862 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1864 LONG active = XGET(data->netped_interfaceList, MUIA_List_Active);
1865 if (active != MUIV_List_Active_Off)
1867 struct Interface iface;
1868 SetInterface
1870 &iface,
1871 (STRPTR)XGET(data->netped_nameString, MUIA_String_Contents),
1872 XGET(data->netped_ifDHCPState, MUIA_Cycle_Active),
1873 (STRPTR)XGET(data->netped_IPString, MUIA_String_Contents),
1874 (STRPTR)XGET(data->netped_maskString, MUIA_String_Contents),
1875 (STRPTR)XGET(data->netped_deviceString, MUIA_String_Contents),
1876 XGET(data->netped_unitString, MUIA_String_Integer),
1877 XGET(data->netped_upState, MUIA_Selected)
1879 DoMethod(data->netped_interfaceList, MUIM_List_Remove, active);
1880 DoMethod(data->netped_interfaceList, MUIM_List_InsertSingle, &iface, active);
1881 SET(data->netped_interfaceList, MUIA_List_Active, active);
1882 SET(self, MUIA_PrefsEditor_Changed, TRUE);
1885 return 0;
1889 Shows content of current list entry in the host window.
1891 IPTR NetPEditor__MUIM_NetPEditor_ShowHostEntry
1893 Class *CLASS, Object *self,
1894 Msg message
1897 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1899 struct Host *host;
1901 DoMethod
1903 data->netped_hostList,
1904 MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &host
1906 if (host)
1908 SET(data->netped_hostRemoveButton, MUIA_Disabled, FALSE);
1909 SET(data->netped_hostEditButton, MUIA_Disabled, FALSE);
1911 SET(data->netped_hostAddressString, MUIA_String_Contents, GetHostAddress(host));
1912 SET(data->netped_hostNamesString, MUIA_String_Contents, GetHostNames(host));
1914 else
1916 SET(data->netped_hostRemoveButton, MUIA_Disabled, TRUE);
1917 SET(data->netped_hostEditButton, MUIA_Disabled, TRUE);
1918 SET(data->netped_hostWindow, MUIA_Window_Open, FALSE);
1920 return 0;
1923 IPTR NetPEditor__MUIM_NetPEditor_EditHostEntry
1925 Class *CLASS, Object *self,
1926 struct MUIP_NetPEditor_EditEntry *message
1929 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1931 if (message->addEntry)
1934 Create a new entry and make it the current one
1936 LONG entries = XGET(data->netped_hostList, MUIA_List_Entries);
1937 if (entries < MAXHOSTS)
1939 struct Host host;
1940 InitHost(&host);
1941 DoMethod
1943 data->netped_hostList,
1944 MUIM_List_InsertSingle, &host, MUIV_List_Insert_Bottom
1947 SET(data->netped_hostList, MUIA_List_Active, entries + 1);
1950 LONG active = XGET(data->netped_hostList, MUIA_List_Active);
1951 if (active != MUIV_List_Active_Off)
1953 SET(data->netped_hostWindow, MUIA_Window_Open, TRUE);
1956 return 0;
1960 Store data from host window back in current list entry
1962 IPTR NetPEditor__MUIM_NetPEditor_ApplyHostEntry
1964 Class *CLASS, Object *self,
1965 Msg message
1968 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
1970 LONG active = XGET(data->netped_hostList, MUIA_List_Active);
1971 if (active != MUIV_List_Active_Off)
1973 struct Host host;
1974 SetHost
1976 &host,
1977 (STRPTR)XGET(data->netped_hostNamesString, MUIA_String_Contents),
1978 (STRPTR)XGET(data->netped_hostAddressString, MUIA_String_Contents)
1980 DoMethod(data->netped_hostList, MUIM_List_Remove, active);
1981 DoMethod(data->netped_hostList, MUIM_List_InsertSingle, &host, active);
1982 SET(data->netped_hostList, MUIA_List_Active, active);
1983 SET(self, MUIA_PrefsEditor_Changed, TRUE);
1986 return 0;
1990 Shows content of current list entry in the network window.
1992 IPTR NetPEditor__MUIM_NetPEditor_ShowNetEntry
1994 Class *CLASS, Object *self,
1995 Msg message
1998 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
2000 struct Network *net;
2002 DoMethod
2004 data->netped_networkList,
2005 MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &net
2007 if (net)
2009 SET(data->netped_netRemoveButton, MUIA_Disabled, FALSE);
2010 SET(data->netped_netEditButton, MUIA_Disabled, FALSE);
2012 SET(data->netped_sSIDString, MUIA_String_Contents, GetNetworkName(net));
2013 SET(data->netped_encType, MUIA_Cycle_Active, GetEncType(net));
2014 SET(data->netped_keyType, MUIA_Cycle_Active, net->keyIsHex ? 1 : 0);
2015 SET(data->netped_keyString, MUIA_String_Contents, GetKey(net));
2016 SET(data->netped_adHocState, MUIA_Selected, GetAdHoc(net) ? 1 : 0);
2017 SET(data->netped_hiddenState, MUIA_Selected, GetHidden(net) ? 1 : 0);
2019 else
2021 SET(data->netped_netRemoveButton, MUIA_Disabled, TRUE);
2022 SET(data->netped_netEditButton, MUIA_Disabled, TRUE);
2023 SET(data->netped_netWindow, MUIA_Window_Open, FALSE);
2025 return 0;
2028 IPTR NetPEditor__MUIM_NetPEditor_EditNetEntry
2030 Class *CLASS, Object *self,
2031 struct MUIP_NetPEditor_EditEntry *message
2034 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
2036 if (message->addEntry)
2039 Create a new entry and make it the current one
2041 LONG entries = XGET(data->netped_networkList, MUIA_List_Entries);
2042 if (entries < MAXNETWORKS)
2044 struct Network net;
2045 InitNetwork(&net);
2046 DoMethod
2048 data->netped_networkList,
2049 MUIM_List_InsertSingle, &net, MUIV_List_Insert_Bottom
2052 SET(data->netped_networkList, MUIA_List_Active, entries + 1);
2055 LONG active = XGET(data->netped_networkList, MUIA_List_Active);
2056 if (active != MUIV_List_Active_Off)
2058 SET(data->netped_netWindow, MUIA_Window_Open, TRUE);
2061 return 0;
2065 Store data from network window back in current list entry
2067 IPTR NetPEditor__MUIM_NetPEditor_ApplyNetEntry
2069 Class *CLASS, Object *self,
2070 Msg message
2073 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
2075 LONG active = XGET(data->netped_networkList, MUIA_List_Active);
2076 if (active != MUIV_List_Active_Off)
2078 struct Network net;
2079 SetNetwork
2081 &net,
2082 (STRPTR)XGET(data->netped_sSIDString, MUIA_String_Contents),
2083 XGET(data->netped_encType, MUIA_Cycle_Active),
2084 (STRPTR)XGET(data->netped_keyString, MUIA_String_Contents),
2085 XGET(data->netped_keyType, MUIA_Cycle_Active),
2086 XGET(data->netped_hiddenState, MUIA_Selected),
2087 XGET(data->netped_adHocState, MUIA_Selected)
2089 DoMethod(data->netped_networkList, MUIM_List_Remove, active);
2090 DoMethod(data->netped_networkList, MUIM_List_InsertSingle, &net, active);
2091 SET(data->netped_networkList, MUIA_List_Active, active);
2092 SET(self, MUIA_PrefsEditor_Changed, TRUE);
2095 return 0;
2099 Shows content of current list entry in the file-server window.
2101 IPTR NetPEditor__MUIM_NetPEditor_ShowServerEntry
2103 Class *CLASS, Object *self,
2104 Msg message
2107 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
2109 struct Server *server;
2111 DoMethod
2113 data->netped_serverList,
2114 MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &server
2116 if (server)
2118 SET(data->netped_serverRemoveButton, MUIA_Disabled, FALSE);
2119 SET(data->netped_serverEditButton, MUIA_Disabled, FALSE);
2121 SET(data->netped_serverDevice, MUIA_String_Contents, GetServerDevice(server));
2122 SET(data->netped_serverActive, MUIA_Selected, GetServerActive(server) ? 1 : 0);
2123 SET(data->netped_serverHost, MUIA_String_Contents, GetServerHost(server));
2124 SET(data->netped_serverService, MUIA_String_Contents, GetServerService(server));
2125 SET(data->netped_serverUser, MUIA_String_Contents, GetServerUser(server));
2126 SET(data->netped_serverGroup, MUIA_String_Contents, GetServerGroup(server));
2127 SET(data->netped_serverPass, MUIA_String_Contents, GetServerPass(server));
2129 else
2131 SET(data->netped_serverRemoveButton, MUIA_Disabled, TRUE);
2132 SET(data->netped_serverEditButton, MUIA_Disabled, TRUE);
2133 SET(data->netped_serverWindow, MUIA_Window_Open, FALSE);
2135 return 0;
2138 IPTR NetPEditor__MUIM_NetPEditor_EditServerEntry
2140 Class *CLASS, Object *self,
2141 struct MUIP_NetPEditor_EditEntry *message
2144 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
2146 if (message->addEntry)
2149 Create a new entry and make it the current one
2151 LONG entries = XGET(data->netped_serverList, MUIA_List_Entries);
2152 if (entries < MAXSERVERS)
2154 struct Server server;
2155 InitServer(&server,
2156 (STRPTR)XGET(data->netped_domainString, MUIA_String_Contents));
2157 server.device[strlen(server.device) - 1] += entries;
2158 DoMethod
2160 data->netped_serverList,
2161 MUIM_List_InsertSingle, &server, MUIV_List_Insert_Bottom
2164 SET(data->netped_serverList, MUIA_List_Active, entries + 1);
2167 LONG active = XGET(data->netped_serverList, MUIA_List_Active);
2168 if (active != MUIV_List_Active_Off)
2170 SET(data->netped_serverWindow, MUIA_Window_Open, TRUE);
2173 return 0;
2177 Store data from file-server window back in current list entry
2179 IPTR NetPEditor__MUIM_NetPEditor_ApplyServerEntry
2181 Class *CLASS, Object *self,
2182 Msg message
2185 struct NetPEditor_DATA *data = INST_DATA(CLASS, self);
2187 LONG active = XGET(data->netped_serverList, MUIA_List_Active);
2188 if (active != MUIV_List_Active_Off)
2190 struct Server server;
2191 SetServer
2193 &server,
2194 (STRPTR)XGET(data->netped_serverDevice, MUIA_String_Contents),
2195 (STRPTR)XGET(data->netped_serverHost, MUIA_String_Contents),
2196 (STRPTR)XGET(data->netped_serverService, MUIA_String_Contents),
2197 (STRPTR)XGET(data->netped_serverUser, MUIA_String_Contents),
2198 (STRPTR)XGET(data->netped_serverGroup, MUIA_String_Contents),
2199 (STRPTR)XGET(data->netped_serverPass, MUIA_String_Contents),
2200 XGET(data->netped_serverActive, MUIA_Selected)
2202 DoMethod(data->netped_serverList, MUIM_List_Remove, active);
2203 DoMethod(data->netped_serverList, MUIM_List_InsertSingle, &server, active);
2204 SET(data->netped_serverList, MUIA_List_Active, active);
2205 SET(self, MUIA_PrefsEditor_Changed, TRUE);
2208 return 0;
2211 /*** Setup ******************************************************************/
2212 ZUNE_CUSTOMCLASS_20
2214 NetPEditor, NULL, MUIC_PrefsEditor, NULL,
2215 OM_NEW, struct opSet *,
2216 MUIM_Setup, Msg,
2217 MUIM_Cleanup, Msg,
2218 MUIM_PrefsEditor_ImportFH, struct MUIP_PrefsEditor_ImportFH *,
2219 MUIM_PrefsEditor_ExportFH, struct MUIP_PrefsEditor_ExportFH *,
2220 MUIM_PrefsEditor_Save, Msg,
2221 MUIM_PrefsEditor_Use, Msg,
2222 MUIM_NetPEditor_IPModeChanged, struct MUIP_NetPEditor_IPModeChanged *,
2223 MUIM_NetPEditor_ShowEntry, Msg,
2224 MUIM_NetPEditor_EditEntry, struct MUIP_NetPEditor_EditEntry *,
2225 MUIM_NetPEditor_ApplyEntry, Msg,
2226 MUIM_NetPEditor_ShowHostEntry, Msg,
2227 MUIM_NetPEditor_EditHostEntry, struct MUIP_NetPEditor_EditEntry *,
2228 MUIM_NetPEditor_ApplyHostEntry, Msg,
2229 MUIM_NetPEditor_ShowNetEntry, Msg,
2230 MUIM_NetPEditor_EditNetEntry, struct MUIP_NetPEditor_EditEntry *,
2231 MUIM_NetPEditor_ApplyNetEntry, Msg,
2232 MUIM_NetPEditor_ShowServerEntry, Msg,
2233 MUIM_NetPEditor_EditServerEntry, struct MUIP_NetPEditor_EditEntry *,
2234 MUIM_NetPEditor_ApplyServerEntry, Msg