From 77c9efc315845e036073131277fb7dbd2b3c779e Mon Sep 17 00:00:00 2001 From: neil Date: Sat, 5 Apr 2014 19:40:16 +0000 Subject: [PATCH] Mostly changes ported from ABIv0 branch: - Allow editing of host DB. - Allow editing and mounting of SMB shares. - Some files weren't closed. Fixed. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@48909 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/prefs/network/args.c | 2 +- workbench/prefs/network/args.h | 2 +- workbench/prefs/network/catalogs/french.ct | 31 +- workbench/prefs/network/catalogs/german.ct | 16 +- workbench/prefs/network/catalogs/network.cd | 32 +- workbench/prefs/network/host | Bin 0 -> 2293 bytes workbench/prefs/network/locale.c | 2 +- workbench/prefs/network/locale.h | 2 +- workbench/prefs/network/main.c | 9 +- workbench/prefs/network/misc.c | 2 +- workbench/prefs/network/misc.h | 2 +- workbench/prefs/network/mmakefile.src | 3 +- workbench/prefs/network/netpeditor.c | 803 +++++++++++++++++++++++++++- workbench/prefs/network/netpeditor.h | 22 +- workbench/prefs/network/prefsdata.c | 698 ++++++++++++++++++++++-- workbench/prefs/network/prefsdata.h | 88 ++- 16 files changed, 1605 insertions(+), 109 deletions(-) create mode 100644 workbench/prefs/network/host diff --git a/workbench/prefs/network/args.c b/workbench/prefs/network/args.c index f323b6c17f..8051b37b50 100644 --- a/workbench/prefs/network/args.c +++ b/workbench/prefs/network/args.c @@ -1,7 +1,7 @@ /* Copyright © 2009-2013, The AROS Development Team. All rights reserved. $Id$ - */ +*/ #include #include diff --git a/workbench/prefs/network/args.h b/workbench/prefs/network/args.h index b47ea3bf77..8d55f7a1ae 100644 --- a/workbench/prefs/network/args.h +++ b/workbench/prefs/network/args.h @@ -4,7 +4,7 @@ /* Copyright © 2009-2011, The AROS Development Team. All rights reserved. $Id$ - */ +*/ #include diff --git a/workbench/prefs/network/catalogs/french.ct b/workbench/prefs/network/catalogs/french.ct index bff71aa109..478ec67d17 100644 --- a/workbench/prefs/network/catalogs/french.ct +++ b/workbench/prefs/network/catalogs/french.ct @@ -1,4 +1,4 @@ -## version $VER: networkprefs.catalog 3.0 ($TODAY) +## version $VER: networkprefs.catalog 4.0 ($TODAY) ## language français ## codeset 0 ; @@ -52,6 +52,10 @@ MSG_HOST_NAME Nom d'hôte ; Host Name ; +MSG_HOST_NAMES +Noms des hôtes +; Host Names +; MSG_DOMAIN_NAME Nom de domaine ; Domain Name @@ -107,16 +111,19 @@ MSG_TAB_IP_CONFIGURATION Configuration IP ; IP Configuration ; -MSG_TAB_COMPUTER_NAME -Nom de l'ordinateur -; Computer Name +MSG_TAB_COMPUTER_NAMES +Noms des ordinateurs +; Computer Names ; MSG_TAB_WIRELESS -Sans fil +Reseaux sans fil ; MSG_TAB_MOBILE Mobile ; +MSG_TAB_SERVERS +Serveurs de fichiers +; MSG_AUTOSTART_STACK Démarrage automatique ; Autostart @@ -179,10 +186,16 @@ Les pr MSG_IFWINDOW_TITLE Interface ; +MSG_HOSTWINDOW_TITLE +Hôte +; MSG_NETWINDOW_TITLE Réseau sans fil ;Wireless Network ; +MSG_SERVERWINDOW_TITLE +Serveur de fichiers +; MSG_USERNAME Nom d'utilisateur ;Username @@ -191,3 +204,11 @@ MSG_PASSWORD Mot de passe ;Password ; +MSG_WORKGROUP +Groupe de travail +;Workgroup +; +MSG_SERVICE +Service +;Service +; diff --git a/workbench/prefs/network/catalogs/german.ct b/workbench/prefs/network/catalogs/german.ct index 47aee0c9a6..3707e3c802 100644 --- a/workbench/prefs/network/catalogs/german.ct +++ b/workbench/prefs/network/catalogs/german.ct @@ -1,4 +1,4 @@ -## version $VER: networkprefs.catalog 3.0 (17.11.2010) +## version $VER: networkprefs.catalog 4.0 (22.3.2012) ## language deutsch ## codeset 0 ; @@ -54,6 +54,10 @@ MSG_HOST_NAME Hostname ; Host Name ; +MSG_HOST_NAMES +Hostnamen +; Host Name +; MSG_DOMAIN_NAME Domänenname ; Domain Name @@ -114,12 +118,12 @@ MSG_TAB_IP_CONFIGURATION IPv4-Konfiguration ; IPv4 Configuration ; -MSG_TAB_COMPUTER_NAME -Computername +MSG_TAB_COMPUTER_NAMES +Computernamen ; Computer Name ; MSG_TAB_WIRELESS -Drahtlos +Drahtlosnetzwerks ; Wireless ; MSG_AUTOSTART_STACK @@ -194,6 +198,10 @@ MSG_TAB_MOBILE Mobiles Breitband-Netzwerk ; Mobile Broadband ; +MSG_TAB_SERVERS + +; File Servers +; MSG_SERIAL_DEVICE Serielles Gerät ; Serial Device diff --git a/workbench/prefs/network/catalogs/network.cd b/workbench/prefs/network/catalogs/network.cd index 301aecaa4e..01ab709882 100644 --- a/workbench/prefs/network/catalogs/network.cd +++ b/workbench/prefs/network/catalogs/network.cd @@ -37,8 +37,11 @@ Secondary DNS MSG_HOST_NAME (//) Host Name ; +MSG_HOST_NAMES (//) +Host Name and Aliases +; MSG_DOMAIN_NAME (//) -Domain Name +Domain/Workgroup ; MSG_SERIAL_DEVICE (//) Serial Device @@ -88,15 +91,18 @@ Ad-hoc MSG_TAB_IP_CONFIGURATION (//) IPv4 Configuration ; -MSG_TAB_COMPUTER_NAME (//) -Computer Name +MSG_TAB_COMPUTER_NAMES (//) +Local Host Entries ; MSG_TAB_WIRELESS (//) -Wireless +Wireless Networks ; MSG_TAB_MOBILE (//) Mobile Broadband ; +MSG_TAB_SERVERS (//) +Mounted Shares +; MSG_AUTOSTART_STACK (//) Start networking during system boot ; @@ -154,12 +160,30 @@ Preferences have been saved to %s.\nRestart AROS for them to take effect. MSG_IFWINDOW_TITLE (//) Interface ; +MSG_HOSTWINDOW_TITLE (//) +Host Name(s) +; MSG_NETWINDOW_TITLE (//) Wireless Network ; +MSG_SERVERWINDOW_TITLE (//) +Mount Share +; MSG_USERNAME (//) Username ; MSG_PASSWORD (//) Password ; +MSG_WORKGROUP (//) +Domain/Workgroup +; +MSG_SERVICE (//) +Share Name +; +MSG_SERVICE_TYPES (//) +Service Type +; +MSG_SERVICETYPE_CIFS (//) +CIFS/SMB +; diff --git a/workbench/prefs/network/host b/workbench/prefs/network/host new file mode 100644 index 0000000000000000000000000000000000000000..053c02e54a8af42d7da78d3e3ccd0c401237584b GIT binary patch literal 2293 zcwPbZ2nzR!P)4gt#C9L7>286NyU>Nahr{_=aSkWAP&h zmJBEof&93$3+WUS8fwM4v=`ykGggd@kEi2yq7W*JER2Gx$DK5ikAlx8M5O7Y@Ao z<iYell3%2$qLo&Uy1k74cz$8W4_Rkq4jP|tL+G&aq!bKS9ZMe`jypIl-(N~u!Vc~(xU$Qn}4V8 z4fd5n=Gymca-dtTQc_t$oz6N%aZIz<*BURMx>SAZ-0}hjC4&PWb^q@5-0ddn^Miei z>7Xu+jn%2@S4aaa&r?d19<^I*(6ZxjE6TC2Q;#Z!PQb zMqP0K=-!HV=Ioq4`py0ATIlAEW802JK?T+cJxTC}m(~2k5b`bymr4L=ph##}8)=Xq zRPi>)0EM>b632YUHLHB zx~>PnPY}0#g(*ogXbK=yDQ&W${q=8DDWwvb>QO!J_EZxn>1 zlncw~#Jcz56yP@A33B`zUAw&q;h6mZSj`hgYa#OerCbTpZ8BZ?;bCo@Fj+DP%EOsq!cOz(1Xr%z^JN#XN!D?SA=b@%6JKW#)5?*s`qMW4dl8_cH-tAD5_9%%_lY~YC z3*TX4t@f7VCDa>Aqa2+19qrE0^py}nk6-o|{bPM0!%he>CK-qdAq+&8V+7w>?wYosxu$9#NU6LJgrGVskOH@jpBRV`D6q(v z?!|`UW-WopwMwCp&I%x#yAE5FmW5fcmUul0Xw`{&eLofE8}W-ixgg%T$rdJP6tQlr zfC!F=5V^uAO9-qG)OM!;VvTt5j`+N2bB-!~AQ%-B9J*wR4F-D%7G_a%tuUQoAHZrA z)+oa_(PtfR#@i_1n=u~(CuwN3+GdRkZJ6TqK(f|cw@(J1m(l`OLXgF**_7QFEyp{6 zaJ8f$-`32`0%+J+S1PYbCWd*KHB*{5JOhGz22_X~qwtefs?K9%woTLVoK4IF#fxZ= zQ;IYoMXXD(JF^+=nv2e`(@K)a4lHEqwk>Hibax-Y&vC0k5bP?c5ZS} zfJIS^oI2hT7y_rmWI&)cvp0#4xo6dZMnz0QERx}k48p9!x{}R4vKA@ zk(f0PEwBQBJT@JUp$3d;UaqA$dIn*)j(y2NKLFt@)Y=955vH~UA~|q;u~7LPPY}Tyep~{lSk00+;DwTH-A%0Yq?cYD;U0EEj zN*#pNf+QQ_Hs9#9IP5V9@&XDxgR-HSnL@0OH=$ z)6>fL{oDNO1&=@3CI9*U9{X|(U?XhsqPxXk0S8Nii;H7Do2~E@(&o>7ky_6^Z}ux_ z-Q5Jl17ODd#EBD20DBX*KRGJ?_2;MUb8Sy_H>s9(3r0FH85fWLAD|RK9E$kBhF!N8 zXN!xs?-adEm;YQ~0v5V@?AWohuIsM(y1jbHe(x*S)ZwvJ+KE7tQjGM9i|ZmkKnamB zBKI-59Db6RPy{#Vxw+ZPIGla(UmBTF{maRdC)e?B=N%0Av8ChJ4_fan?h+s6BECm1 za<;=0i9WcasU4}P0ziTIg3ZF1u+>`0XD`g$x_fuw4gANLHJSII@CV%=J$lp`A0OX~ zZ{Ig|?ZBx@+rc+PjKxe}HkOj~qF2V@p67KvPpw z)}B3kK84vmkHOEve>d@Z7IaovgNO0%(|G1TB_HE{4($xq=S8$D?Du~IC #include diff --git a/workbench/prefs/network/locale.h b/workbench/prefs/network/locale.h index 5e438ae3bb..f77cd0e304 100644 --- a/workbench/prefs/network/locale.h +++ b/workbench/prefs/network/locale.h @@ -4,7 +4,7 @@ /* Copyright © 2009, The AROS Development Team. All rights reserved. $Id$ - */ +*/ #include diff --git a/workbench/prefs/network/main.c b/workbench/prefs/network/main.c index bd6da60996..d22951c65e 100644 --- a/workbench/prefs/network/main.c +++ b/workbench/prefs/network/main.c @@ -1,14 +1,13 @@ /* - Copyright © 2009-2012, The AROS Development Team. All rights reserved. + Copyright © 2009-2014, The AROS Development Team. All rights reserved. $Id$ - */ +*/ #define MUIMASTER_YES_INLINE_STDARG -#include #include #include - +#include #include #include @@ -17,7 +16,7 @@ #include "netpeditor.h" #include "prefsdata.h" -#define VERSION "$VER: Network 1.14 (3.3.2012) AROS Dev Team" +#define VERSION "$VER: Network 1.21 (5.4.2014) AROS Dev Team" int main(int argc, char **argv) { diff --git a/workbench/prefs/network/misc.c b/workbench/prefs/network/misc.c index a8576185d8..4e7bba5eaa 100644 --- a/workbench/prefs/network/misc.c +++ b/workbench/prefs/network/misc.c @@ -1,7 +1,7 @@ /* Copyright © 2009, The AROS Development Team. All rights reserved. $Id$ - */ +*/ #include #include diff --git a/workbench/prefs/network/misc.h b/workbench/prefs/network/misc.h index 19b3e638fb..9d888f0734 100644 --- a/workbench/prefs/network/misc.h +++ b/workbench/prefs/network/misc.h @@ -1,7 +1,7 @@ /* Copyright © 2009, The AROS Development Team. All rights reserved. $Id$ - */ +*/ #ifndef _MISC_H #define _MISC_H diff --git a/workbench/prefs/network/mmakefile.src b/workbench/prefs/network/mmakefile.src index 5f23d2c406..df17b55c83 100644 --- a/workbench/prefs/network/mmakefile.src +++ b/workbench/prefs/network/mmakefile.src @@ -16,6 +16,7 @@ EXEDIR := $(AROSDIR)/Prefs progname=Network targetdir=$(EXEDIR) \ files=$(FILES) -%copy_files_q mmake=workbench-prefs-network-cpy files="interface wireless" src=. dst=$(AROS_IMAGES) +%copy_files_q mmake=workbench-prefs-network-cpy \ + files="interface host wireless" src=. dst=$(AROS_IMAGES) %common diff --git a/workbench/prefs/network/netpeditor.c b/workbench/prefs/network/netpeditor.c index a46e6ca1af..a4e71107f1 100644 --- a/workbench/prefs/network/netpeditor.c +++ b/workbench/prefs/network/netpeditor.c @@ -1,7 +1,7 @@ /* Copyright © 2009-2012, The AROS Development Team. All rights reserved. $Id$ - */ +*/ #define MUIMASTER_YES_INLINE_STDARG @@ -32,18 +32,25 @@ #include #include -static CONST_STRPTR NetworkTabs[] = { NULL, NULL, NULL, NULL}; +static CONST_STRPTR NetworkTabs[] = { NULL, NULL, NULL, NULL, NULL, NULL}; static CONST_STRPTR DHCPCycle[] = { NULL, NULL, NULL }; static CONST_STRPTR EncCycle[] = { NULL, NULL, NULL, NULL }; static CONST_STRPTR KeyCycle[] = { NULL, NULL, NULL }; +static CONST_STRPTR ServiceTypeCycle[] = { NULL, NULL }; static const TEXT max_ip_str[] = "255.255.255.255 "; static struct Hook netpeditor_displayHook, netpeditor_constructHook, netpeditor_destructHook; +static struct Hook hosts_displayHook, + hosts_constructHook, + hosts_destructHook; static struct Hook wireless_displayHook, wireless_constructHook, wireless_destructHook; +static struct Hook server_displayHook, + server_constructHook, + server_destructHook; /*** Instance Data **********************************************************/ struct NetPEditor_DATA @@ -60,6 +67,10 @@ struct NetPEditor_DATA *netped_editButton, *netped_removeButton, *netped_inputGroup, + *netped_hostList, + *netped_hostAddButton, + *netped_hostEditButton, + *netped_hostRemoveButton, *netped_networkList, *netped_netAddButton, *netped_netEditButton, @@ -68,7 +79,11 @@ struct NetPEditor_DATA *netped_MBBDeviceString, *netped_MBBUnit, *netped_MBBUsername, - *netped_MBBPassword; + *netped_MBBPassword, + *netped_serverList, + *netped_serverAddButton, + *netped_serverEditButton, + *netped_serverRemoveButton; // Interface window Object *netped_ifWindow, @@ -82,7 +97,14 @@ struct NetPEditor_DATA *netped_applyButton, *netped_closeButton; - // SSID window + // Host window + Object *netped_hostWindow, + *netped_hostNamesString, + *netped_hostAddressString, + *netped_hostApplyButton, + *netped_hostCloseButton; + + // Wireless network window Object *netped_netWindow, *netped_sSIDString, *netped_encType, @@ -92,6 +114,19 @@ struct NetPEditor_DATA *netped_adHocState, *netped_netApplyButton, *netped_netCloseButton; + + // File-server window + Object *netped_serverWindow, + *netped_serverServiceType, + *netped_serverDevice, + *netped_serverActive, + *netped_serverHost, + *netped_serverService, + *netped_serverUser, + *netped_serverPass, + *netped_serverGroup, + *netped_serverApplyButton, + *netped_serverCloseButton; }; AROS_UFH3S(APTR, constructFunc, @@ -136,19 +171,69 @@ AROS_UFHA(struct Interface *, entry, A1)) sprintf(unitbuffer, "%d", (int)entry->unit); *array++ = entry->name; *array++ = entry->up ? "*" : ""; - *array++ = entry->ifDHCP ? (STRPTR)"DHCP" : entry->IP; - *array++ = entry->ifDHCP ? (STRPTR)"DHCP" : entry->mask; *array++ = FilePart(entry->device); - *array = unitbuffer; + *array++ = unitbuffer; + *array = entry->ifDHCP ? (STRPTR)_(MSG_IP_MODE_DHCP) : entry->IP; } else { *array++ = (STRPTR)_(MSG_IFNAME); *array++ = (STRPTR)_(MSG_UP); - *array++ = (STRPTR)_(MSG_IP); - *array++ = (STRPTR)_(MSG_MASK); *array++ = (STRPTR)_(MSG_DEVICE); - *array = (STRPTR)_(MSG_UNIT); + *array++ = (STRPTR)_(MSG_UNIT); + *array = (STRPTR)_(MSG_IP); + } + + return 0; + + AROS_USERFUNC_EXIT +} + +AROS_UFH3S(APTR, hostsConstructFunc, +AROS_UFHA(struct Hook *, hook, A0), +AROS_UFHA(APTR, pool, A2), +AROS_UFHA(struct Host *, entry, A1)) +{ + AROS_USERFUNC_INIT + + struct Host *new; + + if ((new = AllocPooled(pool, sizeof(*new)))) + { + *new = *entry; + } + return new; + + AROS_USERFUNC_EXIT +} + +AROS_UFH3S(void, hostsDestructFunc, +AROS_UFHA(struct Hook *, hook, A0), +AROS_UFHA(APTR, pool, A2), +AROS_UFHA(struct Host *, entry, A1)) +{ + AROS_USERFUNC_INIT + + FreePooled(pool, entry, sizeof(struct Host)); + + AROS_USERFUNC_EXIT +} + +AROS_UFH3S(LONG, hostsDisplayFunc, +AROS_UFHA(struct Hook *, hook, A0), +AROS_UFHA(char **, array, A2), +AROS_UFHA(struct Host *, entry, A1)) +{ + AROS_USERFUNC_INIT + if (entry) + { + *array++ = entry->address; + *array++ = entry->names; + } + else + { + *array++ = (STRPTR)_(MSG_IP); + *array++ = (STRPTR)_(MSG_HOST_NAMES); } return 0; @@ -222,6 +307,66 @@ AROS_UFHA(struct Network *, entry, A1)) AROS_USERFUNC_EXIT } +AROS_UFH3S(APTR, serverConstructFunc, +AROS_UFHA(struct Hook *, hook, A0), +AROS_UFHA(APTR, pool, A2), +AROS_UFHA(struct Server *, entry, A1)) +{ + AROS_USERFUNC_INIT + + struct Server *new; + + if ((new = AllocPooled(pool, sizeof(*new)))) + { + *new = *entry; + } + return new; + + AROS_USERFUNC_EXIT +} + +AROS_UFH3S(void, serverDestructFunc, +AROS_UFHA(struct Hook *, hook, A0), +AROS_UFHA(APTR, pool, A2), +AROS_UFHA(struct Server *, entry, A1)) +{ + AROS_USERFUNC_INIT + + FreePooled(pool, entry, sizeof(struct Server)); + + AROS_USERFUNC_EXIT +} + +AROS_UFH3S(LONG, serverDisplayFunc, +AROS_UFHA(struct Hook *, hook, A0), +AROS_UFHA(char **, array, A2), +AROS_UFHA(struct Server *, entry, A1)) +{ + AROS_USERFUNC_INIT + if (entry) + { + *array++ = entry->device; + *array++ = entry->active ? "*" : ""; + *array++ = entry->host; + *array++ = entry->group; + *array++ = entry->service; + *array++ = entry->user; + } + else + { + *array++ = (STRPTR)_(MSG_DEVICE); + *array++ = (STRPTR)_(MSG_UP); + *array++ = (STRPTR)_(MSG_HOST_NAME); + *array++ = (STRPTR)_(MSG_WORKGROUP); + *array++ = (STRPTR)_(MSG_SERVICE); + *array++ = (STRPTR)_(MSG_USERNAME); + } + + return 0; + + AROS_USERFUNC_EXIT +} + BOOL Gadgets2NetworkPrefs(struct NetPEditor_DATA *data) { STRPTR str = NULL; @@ -255,7 +400,7 @@ BOOL Gadgets2NetworkPrefs(struct NetPEditor_DATA *data) GET(data->netped_DNSString[1], MUIA_String_Contents, &str); SetDNS(1, str); GET(data->netped_hostString, MUIA_String_Contents, &str); - SetHost(str); + SetHostname(str); GET(data->netped_domainString, MUIA_String_Contents, &str); SetDomain(str); GET(data->netped_Autostart, MUIA_Selected, &lng); @@ -263,6 +408,21 @@ BOOL Gadgets2NetworkPrefs(struct NetPEditor_DATA *data) GET(data->netped_DHCPState, MUIA_Cycle_Active, &lng); SetDHCP(lng); + entries = XGET(data->netped_hostList, MUIA_List_Entries); + for(i = 0; i < entries; i++) + { + struct Host *host = GetHost(i); + struct Host *hostentry; + DoMethod + ( + data->netped_hostList, + MUIM_List_GetEntry, i, &hostentry + ); + SetHostAddress(host, hostentry->address); + SetHostNames(host, hostentry->names); + } + SetHostCount(entries); + entries = XGET(data->netped_networkList, MUIA_List_Entries); for(i = 0; i < entries; i++) { @@ -298,6 +458,26 @@ BOOL Gadgets2NetworkPrefs(struct NetPEditor_DATA *data) GET(data->netped_MBBPassword, MUIA_String_Contents, &str); SetMobile_password(str); + entries = XGET(data->netped_serverList, MUIA_List_Entries); + for(i = 0; i < entries; i++) + { + struct Server *server = GetServer(i); + struct Server *serverentry; + DoMethod + ( + data->netped_serverList, + MUIM_List_GetEntry, i, &serverentry + ); + SetServerDevice(server, serverentry->device); + SetServerHost(server, serverentry->host); + SetServerService(server, serverentry->service); + SetServerUser(server, serverentry->user); + SetServerGroup(server, serverentry->group); + SetServerPass(server, serverentry->pass); + SetServerActive(server, serverentry->active); + } + SetServerCount(entries); + return TRUE; } @@ -340,11 +520,35 @@ BOOL NetworkPrefs2Gadgets NNSET(data->netped_gateString, MUIA_String_Contents, (IPTR)GetGate()); NNSET(data->netped_DNSString[0], MUIA_String_Contents, (IPTR)GetDNS(0)); NNSET(data->netped_DNSString[1], MUIA_String_Contents, (IPTR)GetDNS(1)); - NNSET(data->netped_hostString, MUIA_String_Contents, (IPTR)GetHost()); + NNSET(data->netped_hostString, MUIA_String_Contents, (IPTR)GetHostname()); NNSET(data->netped_domainString, MUIA_String_Contents, (IPTR)GetDomain()); NNSET(data->netped_Autostart, MUIA_Selected, (IPTR)GetAutostart()); NNSET(data->netped_DHCPState, MUIA_Cycle_Active, (IPTR)GetDHCP() ? 1 : 0); + entries = GetHostCount(); + + SET(data->netped_hostList, MUIA_List_Quiet, TRUE); + DoMethod(data->netped_hostList, MUIM_List_Clear); + for(i = 0; i < entries; i++) + { + struct Host *host = GetHost(i); + struct Host hostentry; + + SetHost + ( + &hostentry, + GetHostNames(host), + GetHostAddress(host) + ); + + DoMethod + ( + data->netped_hostList, + MUIM_List_InsertSingle, &hostentry, MUIV_List_Insert_Bottom + ); + } + SET(data->netped_hostList, MUIA_List_Quiet, FALSE); + SET(data->netped_networkList, MUIA_List_Quiet, TRUE); DoMethod(data->netped_networkList, MUIM_List_Clear); entries = GetNetworkCount(); @@ -387,6 +591,35 @@ BOOL NetworkPrefs2Gadgets NNSET((data->netped_MBBUsername), MUIA_String_Contents, GetMobile_username()); NNSET((data->netped_MBBPassword), MUIA_String_Contents, GetMobile_password()); + SET(data->netped_serverList, MUIA_List_Quiet, TRUE); + DoMethod(data->netped_serverList, MUIM_List_Clear); + entries = GetServerCount(); + for(i = 0; i < entries; i++) + { + struct Server *server = GetServer(i); + struct Server serverentry; + + SetServer + ( + &serverentry, + GetServerDevice(server), + GetServerHost(server), + GetServerService(server), + GetServerUser(server), + GetServerGroup(server), + GetServerPass(server), + GetServerActive(server) + ); + + DoMethod + ( + data->netped_serverList, + MUIM_List_InsertSingle, &serverentry, MUIV_List_Insert_Bottom + ); + } + + SET(data->netped_serverList, MUIA_List_Quiet, FALSE); + return TRUE; } @@ -450,7 +683,9 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) Object *gateString, *DNSString[2], *hostString, *domainString, *autostart, *interfaceList, *DHCPState, *addButton, *editButton, *removeButton, *inputGroup, + *hostList, *hostAddButton, *hostEditButton, *hostRemoveButton, *networkList, *netAddButton, *netEditButton, *netRemoveButton, + *serverList, *serverAddButton, *serverEditButton, *serverRemoveButton, *MBBInitString[MAXATCOMMANDS], *MBBDeviceString, *MBBUnit, *MBBUsername, *MBBPassword; @@ -459,10 +694,19 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) *ifDHCPState, *unitString, *nameString, *upState, *ifWindow, *applyButton, *closeButton; + // host window + Object *hostNamesString, *hostAddressString, *hostWindow, + *hostApplyButton, *hostCloseButton; + // network window Object *sSIDString, *keyString, *encType, *keyType, *hiddenState, *adHocState, *netWindow, *netApplyButton, *netCloseButton; + // file-server window + Object *serverWindow, *serverServiceType, *serverDevice, *serverActive, *serverHost, + *serverService, *serverUser, *serverGroup, *serverPass, + *serverApplyButton, *serverCloseButton; + DHCPCycle[0] = _(MSG_IP_MODE_MANUAL); DHCPCycle[1] = _(MSG_IP_MODE_DHCP); @@ -473,18 +717,30 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) KeyCycle[0] = _(MSG_KEY_TEXT); KeyCycle[1] = _(MSG_KEY_HEX); + ServiceTypeCycle[0] = _(MSG_SERVICETYPE_CIFS); + NetworkTabs[0] = _(MSG_TAB_IP_CONFIGURATION); - NetworkTabs[1] = _(MSG_TAB_WIRELESS); - NetworkTabs[2] = _(MSG_TAB_MOBILE); + NetworkTabs[1] = _(MSG_TAB_COMPUTER_NAMES); + NetworkTabs[2] = _(MSG_TAB_WIRELESS); + NetworkTabs[3] = _(MSG_TAB_MOBILE); + NetworkTabs[4] = _(MSG_TAB_SERVERS); netpeditor_constructHook.h_Entry = (HOOKFUNC)constructFunc; netpeditor_destructHook.h_Entry = (HOOKFUNC)destructFunc; netpeditor_displayHook.h_Entry = (HOOKFUNC)displayFunc; + hosts_constructHook.h_Entry = (HOOKFUNC)hostsConstructFunc; + hosts_destructHook.h_Entry = (HOOKFUNC)hostsDestructFunc; + hosts_displayHook.h_Entry = (HOOKFUNC)hostsDisplayFunc; + wireless_constructHook.h_Entry = (HOOKFUNC)netConstructFunc; wireless_destructHook.h_Entry = (HOOKFUNC)netDestructFunc; wireless_displayHook.h_Entry = (HOOKFUNC)netDisplayFunc; + server_constructHook.h_Entry = (HOOKFUNC)serverConstructFunc; + server_destructHook.h_Entry = (HOOKFUNC)serverDestructFunc; + server_displayHook.h_Entry = (HOOKFUNC)serverDisplayFunc; + self = (Object *)DoSuperNewTags ( CLASS, self, NULL, @@ -493,6 +749,7 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) MUIA_PrefsEditor_Path, (IPTR)"AROSTCP/arostcp.prefs", Child, RegisterGroup((IPTR)NetworkTabs), + Child, (IPTR)VGroup, Child, (IPTR)(HGroup, GroupFrame, @@ -500,7 +757,7 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) MUIA_Listview_List, (IPTR)(interfaceList = (Object *)ListObject, ReadListFrame, MUIA_List_Title, TRUE, - MUIA_List_Format, (IPTR)"BAR,P=\33c BAR,BAR,BAR,BAR,", + MUIA_List_Format, (IPTR)"BAR,P=\33c BAR,BAR,BAR,", MUIA_List_ConstructHook, (IPTR)&netpeditor_constructHook, MUIA_List_DestructHook, (IPTR)&netpeditor_destructHook, MUIA_List_DisplayHook, (IPTR)&netpeditor_displayHook, @@ -514,14 +771,14 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) Child, (IPTR)HVSpace, End), End), - Child, (IPTR)(inputGroup = (Object *)ColGroup(6), + Child, (IPTR)(inputGroup = (Object *)ColGroup(4), GroupFrame, Child, (IPTR)Label2(__(MSG_IP_MODE)), Child, (IPTR)(DHCPState = (Object *)CycleObject, MUIA_Cycle_Entries, (IPTR)DHCPCycle, End), - Child, (IPTR)Label2(__(MSG_DNS1)), - Child, (IPTR)(DNSString[0] = (Object *)StringObject, + Child, (IPTR)Label2(__(MSG_GATE)), + Child, (IPTR)(gateString = (Object *)StringObject, StringFrame, MUIA_String_Accept, (IPTR)IPCHARS, MUIA_CycleChain, 1, @@ -533,13 +790,19 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) MUIA_String_Accept, (IPTR)NAMECHARS, MUIA_CycleChain, 1, End), - Child, (IPTR)Label2(__(MSG_GATE)), - Child, (IPTR)(gateString = (Object *)StringObject, + Child, (IPTR)Label2(__(MSG_DNS1)), + Child, (IPTR)(DNSString[0] = (Object *)StringObject, StringFrame, MUIA_String_Accept, (IPTR)IPCHARS, MUIA_CycleChain, 1, MUIA_FixWidthTxt, (IPTR)max_ip_str, End), + Child, (IPTR)Label2(__(MSG_DOMAIN_NAME)), + Child, (IPTR)(domainString = (Object *)StringObject, + StringFrame, + MUIA_String_Accept, (IPTR)NAMECHARS, + MUIA_CycleChain, 1, + End), Child, (IPTR)Label2(__(MSG_DNS2)), Child, (IPTR)(DNSString[1] = (Object *)StringObject, StringFrame, @@ -547,12 +810,6 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) MUIA_CycleChain, 1, MUIA_FixWidthTxt, (IPTR)max_ip_str, End), - Child, (IPTR)Label2(__(MSG_DOMAIN_NAME)), - Child, (IPTR)(domainString = (Object *)StringObject, - StringFrame, - MUIA_String_Accept, (IPTR)NAMECHARS, - MUIA_CycleChain, 1, - End), End), Child, (IPTR)ColGroup(2), Child, (IPTR)(autostart = MUI_MakeObject(MUIO_Checkmark, NULL)), @@ -567,6 +824,29 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) Child, (IPTR)(HGroup, GroupFrame, Child, (IPTR)ListviewObject, + MUIA_Listview_List, (IPTR)(hostList = (Object *)ListObject, + ReadListFrame, + MUIA_List_Title, TRUE, + MUIA_List_Format, (IPTR)"BAR,", + MUIA_List_ConstructHook, (IPTR)&hosts_constructHook, + MUIA_List_DestructHook, (IPTR)&hosts_destructHook, + MUIA_List_DisplayHook, (IPTR)&hosts_displayHook, + End), + End, + Child, (IPTR)(VGroup, + MUIA_HorizWeight, 0, + Child, (IPTR)(hostAddButton = SimpleButton(_(MSG_BUTTON_ADD))), + Child, (IPTR)(hostEditButton = SimpleButton(_(MSG_BUTTON_EDIT))), + Child, (IPTR)(hostRemoveButton = SimpleButton(_(MSG_BUTTON_REMOVE))), + Child, (IPTR)HVSpace, + End), + End), + End, + + Child, (IPTR)VGroup, + Child, (IPTR)(HGroup, + GroupFrame, + Child, (IPTR)ListviewObject, MUIA_Listview_List, (IPTR)(networkList = (Object *)ListObject, ReadListFrame, MUIA_List_Title, TRUE, @@ -617,6 +897,7 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) Child, (IPTR)Label2(_(MSG_PASSWORD)), Child, (IPTR)(MBBPassword = (Object *)StringObject, StringFrame, + MUIA_String_Secret, TRUE, MUIA_CycleChain, 1, End), End, @@ -657,6 +938,29 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) End, + Child, (IPTR)VGroup, + Child, (IPTR)(HGroup, + GroupFrame, + Child, (IPTR)ListviewObject, + MUIA_Listview_List, (IPTR)(serverList = (Object *)ListObject, + ReadListFrame, + MUIA_List_Title, TRUE, + MUIA_List_Format, (IPTR)"BAR,P=\33c BAR,BAR,BAR,BAR,", + MUIA_List_ConstructHook, (IPTR)&server_constructHook, + MUIA_List_DestructHook, (IPTR)&server_destructHook, + MUIA_List_DisplayHook, (IPTR)&server_displayHook, + End), + End, + Child, (IPTR)(VGroup, + MUIA_HorizWeight, 0, + Child, (IPTR)(serverAddButton = SimpleButton(_(MSG_BUTTON_ADD))), + Child, (IPTR)(serverEditButton = SimpleButton(_(MSG_BUTTON_EDIT))), + Child, (IPTR)(serverRemoveButton = SimpleButton(_(MSG_BUTTON_REMOVE))), + Child, (IPTR)HVSpace, + End), + End), + End, + End, // register TAG_DONE @@ -742,6 +1046,42 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) End, End; + hostWindow = (Object *)WindowObject, + MUIA_Window_Title, __(MSG_HOST_NAMES), + MUIA_Window_ID, MAKE_ID('H', 'O', 'S', 'T'), + MUIA_Window_CloseGadget, FALSE, + MUIA_Window_SizeGadget, TRUE, + WindowContents, (IPTR)VGroup, + GroupFrame, + Child, (IPTR)HGroup, + Child, (IPTR)HVSpace, + Child, (IPTR)ImageObject, + MUIA_Image_Spec, (IPTR)"3:Images:host", + MUIA_FixWidth, 26, + MUIA_FixHeight, 50, + End, + Child, (IPTR)HVSpace, + End, + Child, (IPTR)ColGroup(2), + GroupFrame, + Child, (IPTR)Label2(__(MSG_IP)), + Child, (IPTR)(hostAddressString = (Object *)StringObject, + StringFrame, + MUIA_CycleChain, 1, + End), + Child, (IPTR)Label2(_(MSG_HOSTWINDOW_TITLE)), + Child, (IPTR)(hostNamesString = (Object *)StringObject, + StringFrame, + MUIA_CycleChain, 1, + End), + End, + Child, (IPTR)HGroup, + Child, (IPTR)(hostApplyButton = ImageButton(_(MSG_BUTTON_APPLY), "THEME:Images/Gadgets/Prefs/Save")), + Child, (IPTR)(hostCloseButton = ImageButton(_(MSG_BUTTON_CLOSE), "THEME:Images/Gadgets/Prefs/Cancel")), + End, + End, + End; + netWindow = (Object *)WindowObject, MUIA_Window_Title, __(MSG_NETWINDOW_TITLE), MUIA_Window_ID, MAKE_ID('W', 'I', 'F', 'I'), @@ -777,6 +1117,7 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) Child, (IPTR)Label2(__(MSG_KEY)), Child, (IPTR)(keyString = (Object *)StringObject, StringFrame, + MUIA_String_Secret, TRUE, MUIA_CycleChain, 1, End), Child, (IPTR)HGroup, @@ -797,7 +1138,75 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) End, End; - if (self != NULL && ifWindow != NULL && netWindow != NULL) + serverWindow = (Object *)WindowObject, + MUIA_Window_Title, __(MSG_SERVERWINDOW_TITLE), + MUIA_Window_ID, MAKE_ID('S', 'H', 'R', 'E'), + MUIA_Window_CloseGadget, FALSE, + MUIA_Window_SizeGadget, TRUE, + WindowContents, (IPTR)VGroup, + GroupFrame, + Child, (IPTR)HGroup, + Child, (IPTR)HVSpace, + Child, (IPTR)ImageObject, + MUIA_Image_Spec, (IPTR)"3:Images:host", + MUIA_FixWidth, 26, + MUIA_FixHeight, 50, + End, + Child, (IPTR)HVSpace, + End, + Child, (IPTR)ColGroup(2), + GroupFrame, + Child, (IPTR)Label2(_(MSG_SERVICE_TYPES)), + Child, (IPTR)(serverServiceType = (Object *)CycleObject, + MUIA_Cycle_Entries, (IPTR)ServiceTypeCycle, + End), + Child, (IPTR)Label2(_(MSG_DEVICE)), + Child, (IPTR)(serverDevice = (Object *)StringObject, + StringFrame, + MUIA_CycleChain, 1, + End), + Child, (IPTR)HVSpace, + Child, (IPTR)HGroup, + Child, (IPTR)(serverActive = MUI_MakeObject(MUIO_Checkmark, NULL)), + Child, (IPTR)Label2(_(MSG_UP)), + Child, (IPTR)HVSpace, + End, + Child, (IPTR)Label2(_(MSG_HOST_NAME)), + Child, (IPTR)(serverHost = (Object *)StringObject, + StringFrame, + MUIA_CycleChain, 1, + End), + Child, (IPTR)Label2(__(MSG_WORKGROUP)), + Child, (IPTR)(serverGroup = (Object *)StringObject, + StringFrame, + MUIA_CycleChain, 1, + End), + Child, (IPTR)Label2(__(MSG_SERVICE)), + Child, (IPTR)(serverService = (Object *)StringObject, + StringFrame, + MUIA_CycleChain, 1, + End), + Child, (IPTR)Label2(__(MSG_USERNAME)), + Child, (IPTR)(serverUser = (Object *)StringObject, + StringFrame, + MUIA_CycleChain, 1, + End), + Child, (IPTR)Label2(__(MSG_PASSWORD)), + Child, (IPTR)(serverPass = (Object *)StringObject, + StringFrame, + MUIA_String_Secret, TRUE, + MUIA_CycleChain, 1, + End), + End, + Child, (IPTR)HGroup, + Child, (IPTR)(serverApplyButton = ImageButton(_(MSG_BUTTON_APPLY), "THEME:Images/Gadgets/Prefs/Save")), + Child, (IPTR)(serverCloseButton = ImageButton(_(MSG_BUTTON_CLOSE), "THEME:Images/Gadgets/Prefs/Cancel")), + End, + End, + End; + + if (self != NULL && ifWindow != NULL && hostWindow != NULL + && netWindow != NULL && serverWindow != NULL) { struct NetPEditor_DATA *data = INST_DATA(CLASS, self); @@ -814,10 +1223,18 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) data->netped_addButton = addButton; data->netped_editButton = editButton; data->netped_removeButton = removeButton; + data->netped_hostList = hostList; + data->netped_hostAddButton = hostAddButton; + data->netped_hostEditButton = hostEditButton; + data->netped_hostRemoveButton = hostRemoveButton; data->netped_networkList = networkList; data->netped_netAddButton = netAddButton; data->netped_netEditButton = netEditButton; data->netped_netRemoveButton = netRemoveButton; + data->netped_serverList = serverList; + data->netped_serverAddButton = serverAddButton; + data->netped_serverEditButton = serverEditButton; + data->netped_serverRemoveButton = serverRemoveButton; data->netped_MBBInitString[0] = MBBInitString[0]; data->netped_MBBInitString[1] = MBBInitString[1]; @@ -841,6 +1258,13 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) data->netped_applyButton = applyButton; data->netped_closeButton = closeButton; + // host window + data->netped_hostWindow = hostWindow; + data->netped_hostAddressString = hostAddressString; + data->netped_hostNamesString = hostNamesString; + data->netped_hostApplyButton = hostApplyButton; + data->netped_hostCloseButton = hostCloseButton; + // wireless window data->netped_netWindow = netWindow; data->netped_hiddenState = hiddenState; @@ -852,12 +1276,31 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) data->netped_netApplyButton = netApplyButton; data->netped_netCloseButton = netCloseButton; + // file-server window + data->netped_serverWindow = serverWindow; + data->netped_serverServiceType = serverServiceType; + data->netped_serverDevice = serverDevice; + data->netped_serverActive = serverActive; + data->netped_serverHost = serverHost; + data->netped_serverService = serverService; + data->netped_serverUser = serverUser; + data->netped_serverGroup = serverGroup; + data->netped_serverPass = serverPass; + data->netped_serverApplyButton = serverApplyButton; + data->netped_serverCloseButton = serverCloseButton; + SET(removeButton, MUIA_Disabled, TRUE); SET(editButton, MUIA_Disabled, TRUE); + SET(hostRemoveButton, MUIA_Disabled, TRUE); + SET(hostEditButton, MUIA_Disabled, TRUE); + SET(netRemoveButton, MUIA_Disabled, TRUE); SET(netEditButton, MUIA_Disabled, TRUE); + SET(serverRemoveButton, MUIA_Disabled, TRUE); + SET(serverEditButton, MUIA_Disabled, TRUE); + /*-- Set up notifications ------------------------------------------*/ // main window @@ -926,6 +1369,33 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) DoMethod ( + hostList, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, + (IPTR)self, 1, MUIM_NetPEditor_ShowHostEntry + ); + DoMethod + ( + hostList, MUIM_Notify, MUIA_Listview_DoubleClick, MUIV_EveryTime, + (IPTR)self, 3, MUIM_NetPEditor_EditHostEntry, FALSE + ); + + DoMethod + ( + hostAddButton, MUIM_Notify, MUIA_Pressed, FALSE, + (IPTR)self, 2, MUIM_NetPEditor_EditHostEntry, TRUE + ); + DoMethod + ( + hostEditButton, MUIM_Notify, MUIA_Pressed, FALSE, + (IPTR)self, 1, MUIM_NetPEditor_EditHostEntry, FALSE + ); + DoMethod + ( + hostRemoveButton, MUIM_Notify, MUIA_Pressed, FALSE, + (IPTR)hostList, 2, MUIM_List_Remove, MUIV_List_Remove_Active + ); + + DoMethod + ( networkList, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, (IPTR)self, 1, MUIM_NetPEditor_ShowNetEntry ); @@ -980,6 +1450,33 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) (IPTR)self, 3, MUIM_Set, MUIA_PrefsEditor_Changed, TRUE ); + DoMethod + ( + serverList, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, + (IPTR)self, 1, MUIM_NetPEditor_ShowServerEntry + ); + DoMethod + ( + serverList, MUIM_Notify, MUIA_Listview_DoubleClick, MUIV_EveryTime, + (IPTR)self, 3, MUIM_NetPEditor_EditServerEntry, FALSE + ); + + DoMethod + ( + serverAddButton, MUIM_Notify, MUIA_Pressed, FALSE, + (IPTR)self, 2, MUIM_NetPEditor_EditServerEntry, TRUE + ); + DoMethod + ( + serverEditButton, MUIM_Notify, MUIA_Pressed, FALSE, + (IPTR)self, 1, MUIM_NetPEditor_EditServerEntry, FALSE + ); + DoMethod + ( + serverRemoveButton, MUIM_Notify, MUIA_Pressed, FALSE, + (IPTR)serverList, 2, MUIM_List_Remove, MUIV_List_Remove_Active + ); + // interface window DoMethod ( @@ -1003,6 +1500,18 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) (IPTR)ifWindow, 3, MUIM_Set, MUIA_Window_Open, FALSE ); + // host window + DoMethod + ( + hostApplyButton, MUIM_Notify, MUIA_Pressed, FALSE, + (IPTR)self, 1, MUIM_NetPEditor_ApplyHostEntry + ); + DoMethod + ( + hostCloseButton, MUIM_Notify, MUIA_Pressed, FALSE, + (IPTR)hostWindow, 3, MUIM_Set, MUIA_Window_Open, FALSE + ); + // network window DoMethod ( @@ -1014,6 +1523,18 @@ Object * NetPEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) netCloseButton, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)netWindow, 3, MUIM_Set, MUIA_Window_Open, FALSE ); + + // server window + DoMethod + ( + serverApplyButton, MUIM_Notify, MUIA_Pressed, FALSE, + (IPTR)self, 1, MUIM_NetPEditor_ApplyServerEntry + ); + DoMethod + ( + serverCloseButton, MUIM_Notify, MUIA_Pressed, FALSE, + (IPTR)serverWindow, 3, MUIM_Set, MUIA_Window_Open, FALSE + ); } return self; @@ -1029,7 +1550,9 @@ IPTR NetPEditor__MUIM_Setup if (!DoSuperMethodA(CLASS, self, message)) return FALSE; DoMethod(_app(self), OM_ADDMEMBER, data->netped_ifWindow); + DoMethod(_app(self), OM_ADDMEMBER, data->netped_hostWindow); DoMethod(_app(self), OM_ADDMEMBER, data->netped_netWindow); + DoMethod(_app(self), OM_ADDMEMBER, data->netped_serverWindow); return TRUE; } @@ -1042,7 +1565,9 @@ IPTR NetPEditor__MUIM_Cleanup struct NetPEditor_DATA *data = INST_DATA(CLASS, self); DoMethod(_app(self), OM_REMMEMBER, data->netped_ifWindow); + DoMethod(_app(self), OM_REMMEMBER, data->netped_hostWindow); DoMethod(_app(self), OM_REMMEMBER, data->netped_netWindow); + DoMethod(_app(self), OM_REMMEMBER, data->netped_serverWindow); return DoSuperMethodA(CLASS, self, message); } @@ -1361,6 +1886,107 @@ IPTR NetPEditor__MUIM_NetPEditor_ApplyEntry } /* + Shows content of current list entry in the host window. +*/ +IPTR NetPEditor__MUIM_NetPEditor_ShowHostEntry +( + Class *CLASS, Object *self, + Msg message +) +{ + struct NetPEditor_DATA *data = INST_DATA(CLASS, self); + + struct Host *host; + + DoMethod + ( + data->netped_hostList, + MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &host + ); + if (host) + { + SET(data->netped_hostRemoveButton, MUIA_Disabled, FALSE); + SET(data->netped_hostEditButton, MUIA_Disabled, FALSE); + + SET(data->netped_hostAddressString, MUIA_String_Contents, GetHostAddress(host)); + SET(data->netped_hostNamesString, MUIA_String_Contents, GetHostNames(host)); + } + else + { + SET(data->netped_hostRemoveButton, MUIA_Disabled, TRUE); + SET(data->netped_hostEditButton, MUIA_Disabled, TRUE); + SET(data->netped_hostWindow, MUIA_Window_Open, FALSE); + } + return 0; +} + +IPTR NetPEditor__MUIM_NetPEditor_EditHostEntry +( + Class *CLASS, Object *self, + struct MUIP_NetPEditor_EditEntry *message +) +{ + struct NetPEditor_DATA *data = INST_DATA(CLASS, self); + + if (message->addEntry) + { + /* + Create a new entry and make it the current one + */ + LONG entries = XGET(data->netped_hostList, MUIA_List_Entries); + if (entries < MAXHOSTS) + { + struct Host host; + InitHost(&host); + DoMethod + ( + data->netped_hostList, + MUIM_List_InsertSingle, &host, MUIV_List_Insert_Bottom + ); + } + SET(data->netped_hostList, MUIA_List_Active, entries + 1); + } + + LONG active = XGET(data->netped_hostList, MUIA_List_Active); + if (active != MUIV_List_Active_Off) + { + SET(data->netped_hostWindow, MUIA_Window_Open, TRUE); + } + + return 0; +} + +/* + Store data from host window back in current list entry +*/ +IPTR NetPEditor__MUIM_NetPEditor_ApplyHostEntry +( + Class *CLASS, Object *self, + Msg message +) +{ + struct NetPEditor_DATA *data = INST_DATA(CLASS, self); + + LONG active = XGET(data->netped_hostList, MUIA_List_Active); + if (active != MUIV_List_Active_Off) + { + struct Host host; + SetHost + ( + &host, + (STRPTR)XGET(data->netped_hostNamesString, MUIA_String_Contents), + (STRPTR)XGET(data->netped_hostAddressString, MUIA_String_Contents) + ); + DoMethod(data->netped_hostList, MUIM_List_Remove, active); + DoMethod(data->netped_hostList, MUIM_List_InsertSingle, &host, active); + SET(data->netped_hostList, MUIA_List_Active, active); + SET(self, MUIA_PrefsEditor_Changed, TRUE); + } + + return 0; +} + +/* Shows content of current list entry in the network window. */ IPTR NetPEditor__MUIM_NetPEditor_ShowNetEntry @@ -1469,8 +2095,121 @@ IPTR NetPEditor__MUIM_NetPEditor_ApplyNetEntry return 0; } +/* + Shows content of current list entry in the file-server window. +*/ +IPTR NetPEditor__MUIM_NetPEditor_ShowServerEntry +( + Class *CLASS, Object *self, + Msg message +) +{ + struct NetPEditor_DATA *data = INST_DATA(CLASS, self); + + struct Server *server; + + DoMethod + ( + data->netped_serverList, + MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &server + ); + if (server) + { + SET(data->netped_serverRemoveButton, MUIA_Disabled, FALSE); + SET(data->netped_serverEditButton, MUIA_Disabled, FALSE); + + SET(data->netped_serverDevice, MUIA_String_Contents, GetServerDevice(server)); + SET(data->netped_serverActive, MUIA_Selected, GetServerActive(server) ? 1 : 0); + SET(data->netped_serverHost, MUIA_String_Contents, GetServerHost(server)); + SET(data->netped_serverService, MUIA_String_Contents, GetServerService(server)); + SET(data->netped_serverUser, MUIA_String_Contents, GetServerUser(server)); + SET(data->netped_serverGroup, MUIA_String_Contents, GetServerGroup(server)); + SET(data->netped_serverPass, MUIA_String_Contents, GetServerPass(server)); + } + else + { + SET(data->netped_serverRemoveButton, MUIA_Disabled, TRUE); + SET(data->netped_serverEditButton, MUIA_Disabled, TRUE); + SET(data->netped_serverWindow, MUIA_Window_Open, FALSE); + } + return 0; +} + +IPTR NetPEditor__MUIM_NetPEditor_EditServerEntry +( + Class *CLASS, Object *self, + struct MUIP_NetPEditor_EditEntry *message +) +{ + struct NetPEditor_DATA *data = INST_DATA(CLASS, self); + + if (message->addEntry) + { + /* + Create a new entry and make it the current one + */ + LONG entries = XGET(data->netped_serverList, MUIA_List_Entries); + if (entries < MAXSERVERS) + { + struct Server server; + InitServer(&server, + (STRPTR)XGET(data->netped_domainString, MUIA_String_Contents)); + server.device[strlen(server.device) - 1] += entries; + DoMethod + ( + data->netped_serverList, + MUIM_List_InsertSingle, &server, MUIV_List_Insert_Bottom + ); + } + SET(data->netped_serverList, MUIA_List_Active, entries + 1); + } + + LONG active = XGET(data->netped_serverList, MUIA_List_Active); + if (active != MUIV_List_Active_Off) + { + SET(data->netped_serverWindow, MUIA_Window_Open, TRUE); + } + + return 0; +} + +/* + Store data from file-server window back in current list entry +*/ +IPTR NetPEditor__MUIM_NetPEditor_ApplyServerEntry +( + Class *CLASS, Object *self, + Msg message +) +{ + struct NetPEditor_DATA *data = INST_DATA(CLASS, self); + + LONG active = XGET(data->netped_serverList, MUIA_List_Active); + if (active != MUIV_List_Active_Off) + { + struct Server server; + SetServer + ( + &server, + (STRPTR)XGET(data->netped_serverDevice, MUIA_String_Contents), + (STRPTR)XGET(data->netped_serverHost, MUIA_String_Contents), + (STRPTR)XGET(data->netped_serverService, MUIA_String_Contents), + (STRPTR)XGET(data->netped_serverUser, MUIA_String_Contents), + (STRPTR)XGET(data->netped_serverGroup, MUIA_String_Contents), + (STRPTR)XGET(data->netped_serverPass, MUIA_String_Contents), + XGET(data->netped_serverActive, MUIA_Selected) + ); + DoMethod(data->netped_serverList, MUIM_List_Remove, active); + DoMethod(data->netped_serverList, MUIM_List_InsertSingle, &server, active); + SET(data->netped_serverList, MUIA_List_Active, active); + SET(self, MUIA_PrefsEditor_Changed, TRUE); + } + + return 0; +} + /*** Setup ******************************************************************/ -ZUNE_CUSTOMCLASS_14 +ZUNE_CUSTOMCLASS_20 ( NetPEditor, NULL, MUIC_PrefsEditor, NULL, OM_NEW, struct opSet *, @@ -1484,7 +2223,13 @@ ZUNE_CUSTOMCLASS_14 MUIM_NetPEditor_ShowEntry, Msg, MUIM_NetPEditor_EditEntry, struct MUIP_NetPEditor_EditEntry *, MUIM_NetPEditor_ApplyEntry, Msg, + MUIM_NetPEditor_ShowHostEntry, Msg, + MUIM_NetPEditor_EditHostEntry, struct MUIP_NetPEditor_EditEntry *, + MUIM_NetPEditor_ApplyHostEntry, Msg, MUIM_NetPEditor_ShowNetEntry, Msg, MUIM_NetPEditor_EditNetEntry, struct MUIP_NetPEditor_EditEntry *, - MUIM_NetPEditor_ApplyNetEntry, Msg + MUIM_NetPEditor_ApplyNetEntry, Msg, + MUIM_NetPEditor_ShowServerEntry, Msg, + MUIM_NetPEditor_EditServerEntry, struct MUIP_NetPEditor_EditEntry *, + MUIM_NetPEditor_ApplyServerEntry, Msg ); diff --git a/workbench/prefs/network/netpeditor.h b/workbench/prefs/network/netpeditor.h index 6ed4cf7d46..365502d9d5 100644 --- a/workbench/prefs/network/netpeditor.h +++ b/workbench/prefs/network/netpeditor.h @@ -1,10 +1,10 @@ -#ifndef _FPEDITOR_H_ -#define _FPEDITOR_H_ +#ifndef _NETPEDITOR_H_ +#define _NETPEDITOR_H_ /* - Copyright © 2009-2010, The AROS Development Team. All rights reserved. + Copyright © 2009-2012, The AROS Development Team. All rights reserved. $Id$ - */ +*/ #include #include @@ -22,12 +22,18 @@ extern struct MUI_CustomClass *NetPEditor_CLASS; #define MUIM_NetPEditor_ShowEntry (MUIB_NetPEditor | 0x00000002) #define MUIM_NetPEditor_EditEntry (MUIB_NetPEditor | 0x00000003) #define MUIM_NetPEditor_ApplyEntry (MUIB_NetPEditor | 0x00000004) -#define MUIM_NetPEditor_ShowNetEntry (MUIB_NetPEditor | 0x00000005) -#define MUIM_NetPEditor_EditNetEntry (MUIB_NetPEditor | 0x00000006) -#define MUIM_NetPEditor_ApplyNetEntry (MUIB_NetPEditor | 0x00000007) +#define MUIM_NetPEditor_ShowHostEntry (MUIB_NetPEditor | 0x00000005) +#define MUIM_NetPEditor_EditHostEntry (MUIB_NetPEditor | 0x00000006) +#define MUIM_NetPEditor_ApplyHostEntry (MUIB_NetPEditor | 0x00000007) +#define MUIM_NetPEditor_ShowNetEntry (MUIB_NetPEditor | 0x00000008) +#define MUIM_NetPEditor_EditNetEntry (MUIB_NetPEditor | 0x00000009) +#define MUIM_NetPEditor_ApplyNetEntry (MUIB_NetPEditor | 0x0000000A) +#define MUIM_NetPEditor_ShowServerEntry (MUIB_NetPEditor | 0x0000000B) +#define MUIM_NetPEditor_EditServerEntry (MUIB_NetPEditor | 0x0000000C) +#define MUIM_NetPEditor_ApplyServerEntry (MUIB_NetPEditor | 0x0000000D) struct MUIP_NetPEditor_EditEntry {STACKED ULONG MethodID; STACKED ULONG addEntry;}; struct MUIP_NetPEditor_EditNetEntry {STACKED ULONG MethodID; STACKED ULONG addEntry;}; struct MUIP_NetPEditor_IPModeChanged {STACKED ULONG MethodID; STACKED ULONG interface;}; -#endif /* _FWPEDITOR_H_ */ +#endif /* _NETPEDITOR_H_ */ diff --git a/workbench/prefs/network/prefsdata.c b/workbench/prefs/network/prefsdata.c index dcc19531e8..4e1c88b886 100644 --- a/workbench/prefs/network/prefsdata.c +++ b/workbench/prefs/network/prefsdata.c @@ -1,7 +1,7 @@ /* - Copyright © 2009-2012, The AROS Development Team. All rights reserved. + Copyright © 2009-2014, The AROS Development Team. All rights reserved. $Id$ - */ +*/ #include #include @@ -12,6 +12,114 @@ #include +#define EX_BUF_SIZE 256 + +enum +{ + ARG_HANDLER, + ARG_EHANDLER, + ARG_FILESYSTEM, + ARG_DEVICE, + ARG_UNIT, + ARG_FLAGS, + ARG_BLOCKSIZE, + ARG_SURFACES, + ARG_BLOCKSPERTRACK, + ARG_SECTORSPERBLOCK, + ARG_RESERVED, + ARG_PREALLOC, + ARG_INTERLEAVE, + ARG_LOWCYL, + ARG_HIGHCYL, + ARG_BUFFERS, + ARG_BUFMEMTYPE, + ARG_MAXTRANSFER, + ARG_MASK, + ARG_BOOTPRI, + ARG_DOSTYPE, + ARG_BAUD, + ARG_CONTROL, + ARG_STACKSIZE, + ARG_PRIORITY, + ARG_GLOBVEC, + ARG_STARTUP, + ARG_ACTIVATE, + ARG_FORCELOAD, + NUM_MOUNTARGS +}; + +static const TEXT mount_template[] = + "HANDLER/K," + "EHANDLER/K," + "FILESYSTEM/K," + "DEVICE/K," + "UNIT/K," + "FLAGS/K," + "SECTORSIZE=BLOCKSIZE/K," + "SURFACES/K," + "SECTORSPERTRACK=BLOCKSPERTRACK/K," + "SECTORSPERBLOCK/K," + "RESERVED/K," + "PREALLOC/K," + "INTERLEAVE/K," + "LOWCYL/K," + "HIGHCYL/K," + "BUFFERS/K," + "BUFMEMTYPE/K," + "MAXTRANSFER/K," + "MASK/K," + "BOOTPRI/K," + "DOSTYPE/K," + "BAUD/K," + "CONTROL/K," + "STACKSIZE/K," + "PRIORITY/K," + "GLOBVEC/K," + "STARTUP/K," + "MOUNT=ACTIVATE/K," + "FORCELOAD/K"; + +enum +{ + ARG_WORKGROUP, + ARG_USERNAME, + ARG_PASSWORD, + ARG_CHANGECASE, + ARG_CASESENSITIVE, + ARG_OMITHIDDEN, + ARG_QUIET, + ARG_CLIENTNAME, + ARG_SERVERNAME, + ARG_DEVICENAME, + ARG_VOLUMENAME, + ARG_CACHESIZE, + ARG_DEBUGLEVEL, + ARG_TIMEZONEOFFSET, + ARG_DSTOFFSET, + ARG_TRANSLATIONFILE, + ARG_SERVICE, + NUM_CONTROLARGS +}; + +static const TEXT control_template[] = + "DOMAIN=WORKGROUP/K," + "USER=USERNAME/K," + "PASSWORD/K," + "CHANGECASE/S," + "CASE=CASESENSITIVE/S," + "OMITHIDDEN/S," + "QUIET/S," + "CLIENT=CLIENTNAME/K," + "SERVER=SERVERNAME/K," + "DEVICE=DEVICENAME/K," + "VOLUME=VOLUMENAME/K," + "CACHE=CACHESIZE/N/K," + "DEBUGLEVEL=DEBUG/N/K," + "TZ=TIMEZONEOFFSET/N/K," + "DST=DSTOFFSET/N/K," + "TRANSLATE=TRANSLATIONFILE/K," + "SERVICE/A"; + static struct TCPPrefs prefs; struct Tokenizer @@ -26,6 +134,9 @@ struct Tokenizer /* List of devices that require NOTRACKING option */ static STRPTR notrackingdevices[] = {"prm-rtl8029.device", NULL}; +static BOOL ReadServer(struct Server *server, BPTR file, LONG size); +static CONST_STRPTR GetActiveServers(); + void OpenTokenFile(struct Tokenizer * tok, STRPTR FileName) { tok->tokenizedFile = fopen(FileName, "r"); @@ -90,13 +201,19 @@ void SetDefaultNetworkPrefsValues() } SetInterfaceCount(0); SetDomain(DEFAULTDOMAIN); - SetHost(DEFAULTHOST); + SetHostname(DEFAULTHOST); SetGate(DEFAULTGATE); SetDNS(0, DEFAULTDNS); SetDNS(1, DEFAULTDNS); SetDHCP(FALSE); SetAutostart(FALSE); + + for (i = 0; i < MAXHOSTS; i++) + { + InitHost(GetHost(i)); + } + SetHostCount(0); } void SetDefaultWirelessPrefsValues() @@ -152,7 +269,7 @@ BOOL RecursiveCreateDir(CONST_STRPTR dirpath) CopyMem(dirpath, tmpdirpath, dirpathlen); /* Recurvice directory creation */ - while(TRUE) + while (TRUE) { if (lastdirseparator >= dirpathlen) break; @@ -239,17 +356,19 @@ BOOL WriteNetworkPrefs(CONST_STRPTR destdir) FILE *ConfFile; LONG i; struct Interface *iface; + struct Host *host; ULONG filenamelen = strlen(destdir) + 4 + 20; TEXT filename[filenamelen]; ULONG destdbdirlen = strlen(destdir) + 3 + 1; TEXT destdbdir[destdbdirlen]; LONG interfacecount = GetInterfaceCount(); + LONG hostcount = GetHostCount(); CombinePath2P(destdbdir, destdbdirlen, destdir, "db"); /* Create necessary directories */ - if(!RecursiveCreateDir(destdir)) return FALSE; - if(!RecursiveCreateDir(destdbdir)) return FALSE; + if (!RecursiveCreateDir(destdir)) return FALSE; + if (!RecursiveCreateDir(destdbdir)) return FALSE; /* Write configuration files */ CombinePath2P(filename, filenamelen, destdbdir, "general.config"); @@ -259,7 +378,7 @@ BOOL WriteNetworkPrefs(CONST_STRPTR destdir) fprintf(ConfFile, "DEBUGSANA=NO\n"); fprintf(ConfFile, "USENS=SECOND\n"); fprintf(ConfFile, "GATEWAY=NO\n"); - fprintf(ConfFile, "HOSTNAME=%s.%s\n", GetHost(), GetDomain()); + fprintf(ConfFile, "HOSTNAME=%s.%s\n", GetHostname(), GetDomain()); fprintf(ConfFile, "LOG FILTERFILE=5\n"); fprintf(ConfFile, "GUI PANEL=MUI\n"); fprintf(ConfFile, "OPENGUI=YES\n"); @@ -268,7 +387,7 @@ BOOL WriteNetworkPrefs(CONST_STRPTR destdir) CombinePath2P(filename, filenamelen, destdbdir, "interfaces"); ConfFile = fopen(filename, "w"); if (!ConfFile) return FALSE; - for(i = 0; i < interfacecount; i++) + for (i = 0; i < interfacecount; i++) { iface = GetInterface(i); fprintf @@ -299,7 +418,7 @@ BOOL WriteNetworkPrefs(CONST_STRPTR destdir) ConfFile = fopen(filename, "w"); if (!ConfFile) return FALSE; - for(i = 0; i < interfacecount; i++) + for (i = 0; i < interfacecount; i++) { iface = GetInterface(i); if (!GetIfDHCP(iface)) @@ -307,7 +426,7 @@ BOOL WriteNetworkPrefs(CONST_STRPTR destdir) fprintf ( ConfFile, "HOST %s %s.%s %s\n", - GetIP(iface), GetHost(), GetDomain(), GetHost() + GetIP(iface), GetHostname(), GetDomain(), GetHostname() ); } } @@ -368,6 +487,20 @@ BOOL WriteNetworkPrefs(CONST_STRPTR destdir) fclose(ConfFile); } + CombinePath2P(filename, filenamelen, destdbdir, "hosts"); + ConfFile = fopen(filename, "w"); + if (!ConfFile) return FALSE; + for (i = 0; i < hostcount; i++) + { + host = GetHost(i); + fprintf + ( + ConfFile, "%s %s\n", + GetHostAddress(host), GetHostNames(host) + ); + } + fclose(ConfFile); + return TRUE; } @@ -380,9 +513,9 @@ BOOL WriteWirelessPrefs(CONST_STRPTR destdir) TEXT filename[filenamelen]; /* Write wireless config */ + CombinePath2P(filename, filenamelen, destdir, "Wireless.prefs"); if (prefs.networkCount > 0) { - CombinePath2P(filename, filenamelen, destdir, "Wireless.prefs"); ConfFile = fopen(filename, "w"); if (!ConfFile) return FALSE; @@ -419,6 +552,8 @@ BOOL WriteWirelessPrefs(CONST_STRPTR destdir) fclose(ConfFile); } + else + DeleteFile(filename); return TRUE; } @@ -435,16 +570,18 @@ BOOL WriteMobilePrefs(CONST_STRPTR destdir) ConfFile = fopen(filename, "w"); if (!ConfFile) return FALSE; - if( strlen(GetMobile_devicename()) > 0 ) fprintf(ConfFile, "DEVICE %s\n" ,GetMobile_devicename() ); + if (strlen(GetMobile_devicename()) > 0) + fprintf(ConfFile, "DEVICE %s\n", GetMobile_devicename()); fprintf(ConfFile, "UNIT %d\n" , (int)GetMobile_unit() ); - if( strlen(GetMobile_username()) > 0 ) fprintf(ConfFile, "USERNAME %s\n" ,GetMobile_username() ); - if( strlen(GetMobile_password()) > 0 ) fprintf(ConfFile, "PASSWORD %s\n" ,GetMobile_password() ); + if (strlen(GetMobile_username()) > 0) + fprintf(ConfFile, "USERNAME %s\n", GetMobile_username()); + if (strlen(GetMobile_password()) > 0) + fprintf(ConfFile, "PASSWORD %s\n", GetMobile_password()); for (i = 0; i < MAXATCOMMANDS; i++) { - if( strlen( GetMobile_atcommand(i) ) > 0 ){ - fprintf(ConfFile, "SEND %s\n" ,GetMobile_atcommand(i) ); - } + if (strlen( GetMobile_atcommand(i) ) > 0) + fprintf(ConfFile, "SEND %s\n", GetMobile_atcommand(i)); } fclose(ConfFile); @@ -453,6 +590,51 @@ BOOL WriteMobilePrefs(CONST_STRPTR destdir) } +BOOL WriteServers(CONST_STRPTR destdir, CONST_STRPTR envdir) +{ + FILE *mount_file, *env_file; + LONG i; + struct Server *server; + ULONG filenamelen = strlen(destdir) + 4 + 20; + TEXT filename[filenamelen]; + + CombinePath2P(filename, filenamelen, envdir, "ServerAutoMounts"); + env_file = fopen(filename, "w"); + if (!env_file) return FALSE; + + for (i = 0; i < prefs.serverCount; i++) + { + server = &prefs.servers[i]; + CombinePath2P(filename, filenamelen, destdir, server->device); + mount_file = fopen(filename, "w"); + if (!mount_file) + { + fclose(env_file); + return FALSE; + } + + fprintf(mount_file, "EHandler = " SERVER_HANDLER "\nActivate = 1\n"); + fprintf(mount_file, "Control = \""); + if (server->user[0] != '\0') + fprintf(mount_file, "USER=*\"%s*\" ", server->user); + if (server->group[0] != '\0') + fprintf(mount_file, "WORKGROUP=*\"%s*\" ", server->group); + if (server->pass[0] != '\0') + fprintf(mount_file, "PASSWORD=*\"%s*\" ", server->pass); + fprintf(mount_file, "SERVICE=*\"//%s/%s*\"\"\n", server->host, + server->service); + fclose(mount_file); + + if (server->active) + fprintf(env_file, "%s: ", server->device); + } + + fclose(env_file); + + return TRUE; +} + + #define BUFSIZE 2048 BOOL CopyFile(CONST_STRPTR srcfile, CONST_STRPTR dstfile) { @@ -526,7 +708,7 @@ BOOL RestartStack() /* Check if shutdown successful */ trycount = 0; - while(IsStackRunning()) + while (IsStackRunning()) { if (trycount > 4) return FALSE; Delay(50); @@ -578,7 +760,7 @@ BOOL StopWireless() /* Check if shutdown successful */ trycount = 0; - while(FindTask("C:WirelessManager") != NULL) + while (FindTask("C:WirelessManager") != NULL) { if (trycount > 4) return FALSE; Delay(50); @@ -612,7 +794,7 @@ BOOL StartWireless() /* Check if startup successful */ trycount = 0; - while(FindTask("C:WirelessManager") == NULL) + while (FindTask("C:WirelessManager") == NULL) { if (trycount > 9) return FALSE; Delay(50); @@ -636,7 +818,7 @@ BOOL StopMobile() /* Check if shutdown successful */ trycount = 0; - while(FindTask("C:ModemManager") != NULL) + while (FindTask("C:ModemManager") != NULL) { if (trycount > 4) return FALSE; Delay(50); @@ -667,7 +849,7 @@ BOOL StartMobile() /* Check if startup successful */ trycount = 0; - while(FindTask("C:ModemManager") == NULL) + while (FindTask("C:ModemManager") == NULL) { if (trycount > 9) return FALSE; Delay(50); @@ -678,6 +860,48 @@ BOOL StartMobile() return TRUE; } +static CONST_STRPTR GetActiveServers() +{ + /* Use static variable so that it is initialized only once (and can be returned) */ + static TEXT servers [256] = {0}; + + /* Load variable if needed - this will happen only once */ + if (servers[0] == '\0') + { + GetVar(AUTOMOUNT_VARIABLE, servers, 256, LV_VAR); + } + + return servers; +} + +BOOL MountServers() +{ + BPTR dir; + + dir = Lock(SERVER_PATH_ENV, SHARED_LOCK); + if (dir == BNULL) + return FALSE; + + /* Startup */ + if (GetServerCount() > 0) + { + struct TagItem tags[] = + { + { SYS_Input, (IPTR)NULL }, + { SYS_Output, (IPTR)NULL }, + { SYS_Error, (IPTR)NULL }, + { SYS_Asynch, (IPTR)TRUE }, + { NP_CurrentDir, (IPTR)dir }, + { TAG_DONE, 0 } + }; + + SystemTagList("C:Mount ${AROSTCP/ServerAutoMounts}\n", tags); + } + + /* All ok */ + return TRUE; +} + /* This is not a general use function! It assumes destinations directory exists */ BOOL AddFileFromDefaultStackLocation(CONST_STRPTR filename, CONST_STRPTR dstdir) { @@ -715,7 +939,6 @@ BOOL CopyDefaultConfiguration(CONST_STRPTR destdir) if (!RecursiveCreateDir(destdbdir)) return FALSE; /* Copy files */ - if (!AddFileFromDefaultStackLocation("hosts", destdir)) return FALSE; if (!AddFileFromDefaultStackLocation("inet.access", destdir)) return FALSE; if (!AddFileFromDefaultStackLocation("netdb", destdir)) return FALSE; if (!AddFileFromDefaultStackLocation("networks", destdir)) return FALSE; @@ -731,6 +954,9 @@ enum ErrorCode SaveNetworkPrefs() if (!WriteNetworkPrefs(PREFS_PATH_ENVARC)) return NOT_SAVED_PREFS_ENVARC; if (!WriteWirelessPrefs(WIRELESS_PATH_ENVARC)) return NOT_SAVED_PREFS_ENVARC; if (!WriteMobilePrefs(MOBILEBB_PATH_ENVARC)) return NOT_SAVED_PREFS_ENVARC; + if (!WriteServers(SERVER_PATH_STORAGE, PREFS_PATH_ENVARC)) + return NOT_SAVED_PREFS_ENVARC; + return UseNetworkPrefs(); } @@ -740,13 +966,19 @@ enum ErrorCode UseNetworkPrefs() if (!WriteNetworkPrefs(PREFS_PATH_ENV)) return NOT_SAVED_PREFS_ENV; if (!WriteWirelessPrefs(WIRELESS_PATH_ENV)) return NOT_SAVED_PREFS_ENV; if (!WriteMobilePrefs(MOBILEBB_PATH_ENV)) return NOT_SAVED_PREFS_ENV; - if(StopWireless()) + if (!RecursiveCreateDir(SERVER_PATH_ENV)) return NOT_SAVED_PREFS_ENV; + if (!WriteServers(SERVER_PATH_ENV, PREFS_PATH_ENV)) + return NOT_SAVED_PREFS_ENV; + + if (StopWireless()) if (GetWirelessDevice() != NULL) if (!StartWireless()) return NOT_RESTARTED_WIRELESS; if (!RestartStack()) return NOT_RESTARTED_STACK; - if(StopMobile()) + if (StopMobile()) if (GetMobile_Autostart()) if (!StartMobile()) return NOT_RESTARTED_MOBILE; + MountServers(); + return ALL_OK; } @@ -758,8 +990,9 @@ void ReadNetworkPrefs(CONST_STRPTR directory) BOOL comment = FALSE; STRPTR tstring; struct Tokenizer tok; - LONG interfacecount; + LONG interfacecount, hostcount; struct Interface *iface = NULL; + struct Host *host = NULL; /* This function will not fail. It will load as much data as possible. Rest will be default values */ @@ -779,7 +1012,7 @@ void ReadNetworkPrefs(CONST_STRPTR directory) tstring = strchr(tok.token, '.'); SetDomain(tstring + 1); tstring[0] = 0; - SetHost(tok.token); + SetHostname(tok.token); } } } @@ -914,6 +1147,38 @@ void ReadNetworkPrefs(CONST_STRPTR directory) } } CloseTokenFile(&tok); + + CombinePath3P(filename, filenamelen, directory, "db", "hosts"); + OpenTokenFile(&tok, filename); + + SetHostCount(0); + hostcount = 0; + + while (!tok.fend && (hostcount < MAXHOSTS)) + { + GetNextToken(&tok, " \n"); + if (tok.token) + { + if (tok.newline) comment = FALSE; + if (strncmp(tok.token, "#", 1) == 0) comment = TRUE; + + if (!comment) + { + if (tok.newline) + { + host = GetHost(hostcount); + SetHostAddress(host, tok.token); + hostcount++; + SetHostCount(hostcount); + } + else + { + AddHostName(host, tok.token); + } + } + } + } + CloseTokenFile(&tok); } void ReadWirelessPrefs(CONST_STRPTR directory) @@ -935,7 +1200,7 @@ void ReadWirelessPrefs(CONST_STRPTR directory) while (!tok.fend && (networkCount < MAXNETWORKS)) { - GetNextToken(&tok, " \n\t"); + GetNextToken(&tok, "\n\t"); if (tok.token) { if (tok.newline) comment = FALSE; @@ -1054,6 +1319,191 @@ void ReadMobilePrefs(CONST_STRPTR directory) } +BOOL ReadServers() +{ + BPTR dir, file; + APTR ex_buffer = NULL; + struct ExAllControl *ex_control = NULL; + struct ExAllData *entry; + BOOL success = TRUE, more = TRUE; + LONG i = 0; + struct Server *server; + + dir = Lock(SERVER_PATH_ENV, SHARED_LOCK); + if (dir == BNULL) + { + dir = Lock(SERVER_PATH_STORAGE, SHARED_LOCK); + if (dir == BNULL) + success = FALSE; + else + { + D(bug("[Network Prefs/ReadServers] scan directory " SERVER_PATH_STORAGE "\n")); + } + } + else + { + D(bug("[Network Prefs/ReadServers] scan directory " SERVER_PATH_ENV "\n")); + } + + if (success) + { + ex_buffer = AllocVec(EX_BUF_SIZE, MEMF_PUBLIC); + if (ex_buffer == NULL) + success = FALSE; + + ex_control = AllocDosObject(DOS_EXALLCONTROL, NULL); + if (ex_control == NULL) + success = FALSE; + } + + if (success) + { + ex_control->eac_LastKey = 0; + while (more && i < MAXSERVERS) + { + more = ExAll(dir, ex_buffer, EX_BUF_SIZE, ED_SIZE, ex_control); + + if (!more && (IoErr() != ERROR_NO_MORE_ENTRIES)) + break; + if (ex_control->eac_Entries == 0) + continue; + + entry = ex_buffer; + while (entry != NULL) + { + if (entry->ed_Type < 0) + { + dir = CurrentDir(dir); + D(bug("[Network Prefs/ReadServers] filename %s\n", entry->ed_Name)); + file = Open(entry->ed_Name, MODE_OLDFILE); + if (file != BNULL) + { + server = &prefs.servers[i]; + if (ReadServer(server, file, entry->ed_Size)) + { + i++; + SetServerDevice(server, entry->ed_Name); + if (strstr(GetActiveServers(), entry->ed_Name) + != NULL) + SetServerActive(server, TRUE); + } + Close(file); + } + dir = CurrentDir(dir); + } + entry = entry->ed_Next; + } + } + prefs.serverCount = i; + } + + if (ex_control != NULL) + { + FreeDosObject(DOS_EXALLCONTROL, ex_control); + } + + FreeVec(ex_buffer); + + return success; +} + + +/* Read and parse a server mount file */ +static BOOL ReadServer(struct Server *server, BPTR file, LONG size) +{ + BOOL success = TRUE; + UBYTE *mount_buffer; + IPTR mount_args[NUM_MOUNTARGS] = {0}, control_args[NUM_CONTROLARGS] = {0}; + struct RDArgs *mount_rdargs = NULL, *control_rdargs = NULL; + LONG i; + STRPTR host, service; + + /* Allocate buffer for entire mount file */ + mount_buffer = AllocVec(size+100, MEMF_ANY|MEMF_CLEAR); + if (mount_buffer == NULL) + success = FALSE; + + /* Read mount file into buffer */ + if (success) + { + if (FRead(file, mount_buffer, size, 1) != 1) + success = FALSE; + } + + if (success) + { + for (i = 0; i < size; i++) + if (mount_buffer[i] == '\n') + mount_buffer[i] = ' '; + + mount_rdargs = AllocDosObject(DOS_RDARGS, NULL); + control_rdargs = AllocDosObject(DOS_RDARGS, NULL); + if (mount_rdargs == NULL || control_rdargs == NULL) + success = FALSE; + } + + /* Parse mount parameters */ + if (success) + { + mount_rdargs->RDA_Source.CS_Buffer = mount_buffer; + mount_rdargs->RDA_Source.CS_Length = size+1; + mount_rdargs->RDA_Flags = RDAF_NOPROMPT; + mount_rdargs = + ReadArgs(mount_template, (IPTR *)&mount_args, mount_rdargs); + if (mount_rdargs == NULL) + success = FALSE; + } + + /* Check if this is a server mount */ + if (success) + { + if (strcasecmp((char *)mount_args[ARG_EHANDLER], SERVER_HANDLER) != 0) + success = FALSE; + } + + /* Parse control parameters */ + if (success) + { + control_rdargs->RDA_Source.CS_Buffer = (UBYTE *)mount_args[ARG_CONTROL]; + control_rdargs->RDA_Source.CS_Length = + strlen((STRPTR)mount_args[ARG_CONTROL]); + control_rdargs = + ReadArgs(control_template, (IPTR *)&control_args, control_rdargs); + if (control_rdargs == NULL) + success = FALSE; + } + + /* Extract needed control parameters */ + if (success) + { + service = FilePart((STRPTR)control_args[ARG_SERVICE]); + SetServerService(server, service); + service--; + *service = '\0'; + host = (STRPTR)control_args[ARG_SERVICE] + 2; + SetServerHost(server, host); + + SetServerUser(server, (STRPTR)control_args[ARG_USERNAME]); + SetServerGroup(server, (STRPTR)control_args[ARG_WORKGROUP]); + SetServerPass(server, (STRPTR)control_args[ARG_PASSWORD]); + } + + if (control_rdargs != NULL) + { + FreeArgs(control_rdargs); + FreeDosObject(DOS_RDARGS, control_rdargs); + } + + if (mount_rdargs != NULL) + { + FreeArgs(mount_rdargs); + FreeDosObject(DOS_RDARGS, mount_rdargs); + } + + return success; +} + + void InitNetworkPrefs(CONST_STRPTR directory, BOOL use, BOOL save) { SetDefaultNetworkPrefsValues(); @@ -1063,6 +1513,7 @@ void InitNetworkPrefs(CONST_STRPTR directory, BOOL use, BOOL save) ReadNetworkPrefs(directory); ReadWirelessPrefs(WIRELESS_PATH_ENV); ReadMobilePrefs(MOBILEBB_PATH_ENV); + ReadServers(); if (save) { @@ -1140,7 +1591,6 @@ BOOL GetUp(struct Interface *iface) return iface->up; } - STRPTR GetGate(void) { return prefs.gate; @@ -1151,7 +1601,7 @@ STRPTR GetDNS(LONG m) return prefs.DNS[m]; } -STRPTR GetHost(void) +STRPTR GetHostname(void) { return prefs.host; } @@ -1245,7 +1695,6 @@ void SetUp(struct Interface *iface, BOOL w) iface->up = w; } - void SetGate(STRPTR w) { if (!IsLegal(w, IPCHARS)) @@ -1264,7 +1713,7 @@ void SetDNS(LONG m, STRPTR w) strlcpy(prefs.DNS[m], w, IPBUFLEN); } -void SetHost(STRPTR w) +void SetHostname(STRPTR w) { if (!IsLegal(w, NAMECHARS)) { @@ -1297,6 +1746,12 @@ void SetDHCP(BOOL w) prefs.DHCP = w; } +void InitHost(struct Host *host) +{ + SetHostNames(host, ""); + SetHostAddress(host, ""); +} + void InitNetwork(struct Network *net) { SetNetworkName(net, ""); @@ -1305,9 +1760,43 @@ void InitNetwork(struct Network *net) SetAdHoc(net, FALSE); } +void InitServer(struct Server *server, char *workgroup) +{ + if ((workgroup == NULL) && ((workgroup = GetDomain()) == NULL)) + workgroup = "workgroup"; + + SetServerDevice(server, DEFAULTSERVERDEV); + SetServerHost(server, ""); + SetServerGroup(server, workgroup); + SetServerService(server, "share"); + SetServerUser(server, "guest"); + SetServerPass(server, ""); + SetServerActive(server, TRUE); +} + /* Getters */ +struct Host *GetHost(LONG index) +{ + return &prefs.hosts[index]; +} + +STRPTR GetHostNames(struct Host *host) +{ + return host->names; +} + +STRPTR GetHostAddress(struct Host *host) +{ + return host->address; +} + +LONG GetHostCount(void) +{ + return prefs.hostCount; +} + struct Network *GetNetwork(LONG index) { return &prefs.networks[index]; @@ -1360,7 +1849,7 @@ BOOL GetMobile_Autostart(void) STRPTR GetMobile_atcommand(ULONG i) { - if( i < MAXATCOMMANDS ) + if (i < MAXATCOMMANDS) return prefs.mobile.atcommand[i]; else return ""; } @@ -1369,9 +1858,9 @@ LONG GetMobile_atcommandcount(void) { ULONG count=0; ULONG i; - for (i=0;idevice; +} + +STRPTR GetServerHost(struct Server *server) +{ + return server->host; +} + +STRPTR GetServerService(struct Server *server) +{ + return server->service; +} + +STRPTR GetServerUser(struct Server *server) +{ + return server->user; +} + +STRPTR GetServerGroup(struct Server *server) +{ + return server->group; +} + +STRPTR GetServerPass(struct Server *server) +{ + return server->pass; +} + +BOOL GetServerActive(struct Server *server) +{ + return server->active; +} + +LONG GetServerCount(void) +{ + return prefs.serverCount; +} + /* Setters */ +void SetHost +( + struct Host *host, STRPTR name, STRPTR address +) +{ + SetHostNames(host, name); + SetHostAddress(host, address); +} + +void SetHostNames(struct Host *host, STRPTR w) +{ + strlcpy(host->names, w, NAMEBUFLEN); +} + +void AddHostName(struct Host *host, STRPTR w) +{ + if (host->names[0] != '\0') + strlcat(host->names, " ", NAMEBUFLEN); + strlcat(host->names, w, NAMEBUFLEN); +} + +void SetHostAddress(struct Host *host, STRPTR w) +{ + strlcpy(host->address, w, IPBUFLEN); +} + +void SetHostCount(LONG w) +{ + prefs.hostCount = w; +} + void SetNetwork ( struct Network *net, STRPTR name, UWORD encType, STRPTR key, @@ -1464,24 +2029,26 @@ void SetMobile_Autostart(BOOL w) void SetMobile_atcommand(ULONG i,STRPTR w) { - if( strlen(w) < NAMEBUFLEN && i >= 0 && i < MAXATCOMMANDS ){ + if (strlen(w) < NAMEBUFLEN && i >= 0 && i < MAXATCOMMANDS) strcpy(prefs.mobile.atcommand[i], w); - } } void SetMobile_devicename(STRPTR w) { - if( strlen(w) < NAMEBUFLEN ) strcpy( prefs.mobile.devicename , w ); + if (strlen(w) < NAMEBUFLEN) + strcpy(prefs.mobile.devicename, w); } void SetMobile_username(STRPTR w) { - if( strlen(w) < NAMEBUFLEN ) strcpy( prefs.mobile.username , w ); + if (strlen(w) < NAMEBUFLEN) + strcpy(prefs.mobile.username, w); } void SetMobile_password(STRPTR w) { - if( strlen(w) < NAMEBUFLEN ) strcpy( prefs.mobile.password , w ); + if (strlen(w) < NAMEBUFLEN) + strcpy(prefs.mobile.password, w); } void SetMobile_unit(LONG w) @@ -1494,7 +2061,58 @@ void SetMobile_timeout(LONG w) prefs.mobile.timeout = w; } +void SetServer +( + struct Server *server, STRPTR device, STRPTR host, STRPTR service, + STRPTR user, STRPTR group, STRPTR pass, BOOL active +) +{ + SetServerDevice(server, device); + SetServerHost(server, host); + SetServerService(server, service); + SetServerUser(server, user); + SetServerGroup(server, group); + SetServerPass(server, pass); + SetServerActive(server, active); +} +void SetServerDevice(struct Server *server, STRPTR w) +{ + strlcpy(server->device, w, SMBBUFLEN); +} +void SetServerHost(struct Server *server, STRPTR w) +{ + strlcpy(server->host, w, NAMEBUFLEN); +} +void SetServerService(struct Server *server, STRPTR w) +{ + strlcpy(server->service, w, SMBBUFLEN); +} + +void SetServerUser(struct Server *server, STRPTR w) +{ + strlcpy(server->user, w, SMBBUFLEN); +} + +void SetServerGroup(struct Server *server, STRPTR w) +{ + strlcpy(server->group, w, SMBBUFLEN); +} + +void SetServerPass(struct Server *server, STRPTR w) +{ + strlcpy(server->pass, w, SMBBUFLEN); +} + +void SetServerActive(struct Server *server, BOOL w) +{ + server->active = w; +} + +void SetServerCount(LONG w) +{ + prefs.serverCount = w; +} diff --git a/workbench/prefs/network/prefsdata.h b/workbench/prefs/network/prefsdata.h index cf2c723e40..0764a776ed 100644 --- a/workbench/prefs/network/prefsdata.h +++ b/workbench/prefs/network/prefsdata.h @@ -1,7 +1,7 @@ /* Copyright © 2009-2012, The AROS Development Team. All rights reserved. $Id$ - */ +*/ #include @@ -9,13 +9,15 @@ #define PREFS_PATH_ENVARC "ENVARC:AROSTCP" #define AROSTCP_PACKAGE_VARIABLE "SYS/Packages/AROSTCP" -#define IPBUFLEN 64 -#define NAMEBUFLEN 512 +#define IPBUFLEN (15 + 1) +#define NAMEBUFLEN 128 +#define SMBBUFLEN (16 + 1) #define IPCHARS "0123456789." #define NAMECHARS "0123456789abcdefghijklmnopqrstuvwxyz-" #define MAXINTERFACES 15 +#define MAXHOSTS 30 #define MAXATCOMMANDS 5 #define DEFAULTNAME "net0" @@ -28,16 +30,24 @@ #define DEFAULTDOMAIN "arosnet" #define MAXNETWORKS 100 +#define MAXSERVERS 10 -#define WIRELESS_PATH_ENV "ENV:" -#define WIRELESS_PATH_ENVARC "ENVARC:" +#define WIRELESS_PATH_ENV "ENV:Sys" +#define WIRELESS_PATH_ENVARC "ENVARC:Sys" #define MOBILEBB_PATH_ENV "ENV:" #define MOBILEBB_PATH_ENVARC "ENVARC:" +#define SERVER_PATH_STORAGE "SYS:Storage/DOSDrivers" +#define SERVER_PATH_ENV "ENV:SMB" +#define AUTOMOUNT_VARIABLE "AROSTCP/ServerAutoMounts" +#define SERVER_HANDLER "smb-handler" + #define SSIDBUFLEN (32 + 1) #define KEYBUFLEN (64 + 1) +#define DEFAULTSERVERDEV "SMB0" + enum ErrorCode { ALL_OK, @@ -63,6 +73,12 @@ struct Interface BOOL up; }; +struct Host +{ + TEXT address[IPBUFLEN]; + TEXT names[NAMEBUFLEN]; +}; + struct Network { TEXT name[NAMEBUFLEN]; @@ -84,6 +100,17 @@ struct MobileBroadBand BOOL autostart; }; +struct Server +{ + TEXT device[SMBBUFLEN]; + TEXT host[NAMEBUFLEN]; + TEXT service[SMBBUFLEN]; + TEXT user[SMBBUFLEN]; + TEXT group[SMBBUFLEN]; + TEXT pass[SMBBUFLEN]; + BOOL active; +}; + struct TCPPrefs { struct Interface interface[MAXINTERFACES]; @@ -94,11 +121,15 @@ struct TCPPrefs TEXT host[NAMEBUFLEN]; TEXT domain[NAMEBUFLEN]; BOOL autostart; + struct Host hosts[MAXHOSTS]; + LONG hostCount; struct Network networks[MAXNETWORKS]; LONG networkCount; struct MobileBroadBand mobile; STRPTR wirelessDevice; LONG wirelessUnit; + struct Server servers[MAXSERVERS]; + LONG serverCount; }; void InitNetworkPrefs(CONST_STRPTR directory, BOOL use, BOOL save); @@ -118,7 +149,7 @@ BOOL GetUp(struct Interface *iface); BOOL GetDHCP(void); STRPTR GetGate(void); STRPTR GetDNS(LONG m); -STRPTR GetHost(void); +STRPTR GetHostname(void); STRPTR GetDomain(void); LONG GetInterfaceCount(void); BOOL GetAutostart(void); @@ -139,12 +170,19 @@ void SetUp(struct Interface *iface, BOOL w); void SetDHCP(BOOL w); void SetGate(STRPTR w); void SetDNS(LONG m, STRPTR w); -void SetHost(STRPTR w); +void SetHostname(STRPTR w); void SetDomain(STRPTR w); void SetInterfaceCount(LONG w); void SetAutostart(BOOL w); +void InitHost(struct Host *host); void InitNetwork(struct Network *net); +void InitServer(struct Server *server, char *workgroup); + +struct Host *GetHost(LONG index); +STRPTR GetHostNames(struct Host *host); +STRPTR GetHostAddress(struct Host *host); +LONG GetHostCount(void); struct Network *GetNetwork(LONG index); STRPTR GetNetworkName(struct Network *net); @@ -166,6 +204,27 @@ LONG GetMobile_unit(void); LONG GetMobile_timeout(void); LONG GetMobile_atcommandcount(void); +struct Server *GetServer(LONG index); +STRPTR GetServerDevice(struct Server *server); +STRPTR GetServerHost(struct Server *server); +STRPTR GetServerService(struct Server *server); +STRPTR GetServerUser(struct Server *server); +STRPTR GetServerGroup(struct Server *server); +STRPTR GetServerPass(struct Server *server); +BOOL GetServerActive(struct Server *server); + +LONG GetServerCount(void); + +void SetHost +( + struct Host *host, STRPTR name, STRPTR address +); +void SetHostNames(struct Host *host, STRPTR w); +void AddHostName(struct Host *host, STRPTR w); +void SetHostAddress(struct Host *host, STRPTR w); + +void SetHostCount(LONG w); + void SetNetwork ( struct Network *net, STRPTR name, UWORD encType, STRPTR key, @@ -189,3 +248,18 @@ void SetMobile_password(STRPTR w); void SetMobile_unit(LONG w); void SetMobile_timeout(LONG w); +void SetServer +( + struct Server *server, STRPTR device, STRPTR host, STRPTR service, + STRPTR user, STRPTR group, STRPTR pass, BOOL active +); +void SetServerDevice(struct Server *server, STRPTR w); +void SetServerHost(struct Server *server, STRPTR w); +void SetServerService(struct Server *server, STRPTR w); +void SetServerUser(struct Server *server, STRPTR w); +void SetServerGroup(struct Server *server, STRPTR w); +void SetServerPass(struct Server *server, STRPTR w); +void SetServerActive(struct Server *net, BOOL w); + +void SetServerCount(LONG w); + -- 2.11.4.GIT