2 Commits
Author SHA1 Message Date
rainlance c5adeca556 Release 1.07 2021-01-12 22:53:12 +01:00
rainlance d97541e72e Release 1.06 2021-01-12 22:50:54 +01:00
30 changed files with 960 additions and 499 deletions
+9 -2
View File
@@ -1,13 +1,20 @@
AmiTimeKeeper Change Log
v1.05 06.08.2018
v1.07 15.02.2019
- Support commodity hotkey and popup options
- Hide advanced setting with new expert option
v1.06 08.02.2019
- Adjust layout in settings window
v1.05 06.08.2018 LTS
- Preferences can now be saved from settings window
- Time zone is shown as UTC offset in settings window
- Running multiple instances no longer creates zombie processes
- Low water option renamed to threshold and high water option removed
- New option for sending log messages to file instead of to screen
- Some incorrect NTP log messages no longer appears
- Read-only options is now applied consistently
- Read-only option is now applied consistently
- Potential race condition in memory allocation fixed
- Other minor enhancements
+1 -1
View File
@@ -1,7 +1,7 @@
Copyright (c) 2001, 02 Motoyuki Kasahara
Copyright (c) 2007 TANDBERG Telecom AS
Copyright (c) 2008-2009 Dag-Erling Smørgrav <des@des.no>
Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
+289
View File
@@ -0,0 +1,289 @@
@database TimeKeeper.guide
@$VER: TimeKeeper.guide 1.06 (2019-02-08)
@(c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
@author Carsten Sonne Larsen
@rem Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
@rem All rights reserved.
@rem
@rem Redistribution and use in source and binary forms, with or without
@rem modification, are permitted provided that the following conditions
@rem are met:
@rem 1. Redistributions of source code must retain the above copyright
@rem notice, this list of conditions and the following disclaimer.
@rem 2. Redistributions in binary form must reproduce the above copyright
@rem notice, this list of conditions and the following disclaimer in the
@rem documentation and/or other materials provided with the distribution.
@rem
@rem THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
@rem IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@rem OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@rem IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
@rem INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
@rem NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@rem DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@rem THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
@rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
@rem THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@Width 74
@Node Main "TimeKeeper.guide"
@Next "Configuring the client"
AmiTimeKeeper is a small program which keeps the time right on your
machine. No installation is required.
AmiTimeKeeper is operated as a commodity and is controlled by AmigaOS.
An AmiTCP compatible TCP/IP stack is required for AmiTimeKeeper to work.
AmiTimeKeeper can be configured through several settings. This can be
done either directly from the command line or by using the tooltypes
of an icon. Preferences can also be saved between reboots.
@{"Configuring the client" Link "Configuring the client"}
@{"Using tooltypes of an icon" Link "Using tooltypes of an icon"}
@{"Saving preferences" Link "Saving preferences"}
@{"Change Log / Change History" Link "Change Log"}
@{"Software License" Link "Software License"}
@{"Contacting the author" Link "Contacting the author"}
@EndNode
@Node "Configuring the client" "TimeKeeper.guide/Configuring the client"
@Toc "Main"
@Prev "Main"
@Next "Using tooltypes of an icon"
@{b}Server Address@{ub}
NTP servers are managed by several organizations. The pool.ntp.org
project and Network Time Foundation are probably the two most famous.
The pool.ntp.org project organize servers into pools whereas Network
Time Foundation maintains a list of valid NTP servers. The servers are
divided into two categories: Stratum 1 and Stratum 2.
The NTP pool servers are divided into zones. If you want to use a server
in Europe you can use set the server address to europe.pool.ntp.org.
For North America the server address is north-america.pool.ntp.org.
Zones also exists for countries. To use a server in for example Germany
the server address should be set to de.pool.ntp.org. For Switzerland
the address should be ch.pool.ntp.org.
Network Time Foundation has a website on http://support.ntp.org/
The pool.ntp.org project website is located at https://www.ntppool.org/
@{b}Server Port@{ub}
NTP servers use port 123 as default. Only under special circumstances
are the NTP server port different from 123.
@{b}Interval between requests@{ub}
The Amiga hardware clock will slowly drift away from true time. The
drift is determined by several factors and is small, but the drift is not
insignificant. Request are repeatedly sent to the NTP server in order to
keep the Amiga hardware clock as close to true time as possible.
The requests are sent in certain intervals defined by the interval
parameter. The interval should be specified using milliseconds. One
thousand (1.000) milliseconds are equal to one second.
@{b}Threshold@{ub}
Due to the accuracy of NTP servers and the nature of Amiga CPUs it does
not make sense to adjust the Amiga clock on every response from the NTP
server. Processing the response could take longer time than anticipated.
The amount of accepted inaccuracy is set using the threshold parameter.
The threshold should be specified using microsecond. One million
microseconds (1.000.000) are equal to one second.
@{b}Read Only@{ub}
It is possible to send request to the NTP server without setting the
Amiga hardware clock. This option can be handy when debugging time zone
setup and other time related parameters.
@{b}Connection Timeout@{ub}
In some cases, a connection to the NTP server cannot be established or
the NTP server simply does respond. To avoid an infinitive wait for a
response the connection will instead make a time out. The timeout
interval should be specified using milliseconds. One thousand (1.000)
milliseconds are equal to one second.
@{b}Verbosity@{ub}
The level of logging can be adjusted from none to all. Expressed as a
numeric value verbose can be 0, 1, 2 or 3, where 0 is equal to none and
3 is equal to maximum verbosity.
@{b}Log file@{ub}
It is possible to send log messages to a file instead of sending them to
a console window.
@EndNode
@Node "Using tooltypes of an icon" "TimeKeeper.guide/Using tooltypes of an icon"
@Toc "Main"
@Prev "Configuring the client"
@Next "Saving preferences"
Settings can be changes by setting tooltypes in the TimeKeeper icon.
Add the following line to the icon tooltypes in order to set the server
to an European pool server:
SERVER=europe.pool.ntp.org
The available tooltypes are the same as the available command line
parameters.
@{b}Parameter@{ub} | @{b}Short description@{ub}
-----------------------------------------
SERVER | Server Address
PORT | Server Port
THRESHOLD | Adjustment threshold
INTERVAL | Interval between requests
CX_PRIORITY | Commodity priority
READONLY | Read only option
TIMEOUT | Connection Timeout
VERBOSE | Log verbosity
LOGFILE | Log file location
@{b}Caveats@{ub}
Settings can be overridden and are set in the following order:
1. Preference file
2. Icon tooltypes
3. CLI parameters
CLI parameters has highest precedence and will always override settings
from icon tooltypes and from the preference file.
@EndNode
@Node "Saving preferences" "TimeKeeper.guide/Saving preferences"
@Toc "Main"
@Prev "Using tooltypes of an icon"
@Next "Change Log"
Preferences from the setting window are saved in the file
ENV:timekeeper.prefs
Preferences are also persisted between reboots in the file
ENVARC:timekeeper.prefs
Depending on the setup the content of timekeeper.prefs could be:
CX_PRIORITY=25
THRESHOLD=1000000
SERVER=de.pool.ntp.org
PORT=123
TIMEOUT=5000
INTERVAL=17500
VERBOSE=3
READONLY=0
LOGFILE=RAM:log
The preference file should not be edited under normal circumstances.
@{b}Caveats@{ub}
If LOGFILE is set in the preference file, no messages will be emitted
to screen (unless overridden by CLI or Icon tooltype with LOGFILE=NO).
@EndNode
@Node "Change Log" "TimeKeeper.guide/Change Log"
@Toc "Main"
@Prev "Saving preferences"
@Next "Software License"
@{b}v1.06 08.02.2019@{ub}
- Adjust layout in settings window
@{b}v1.05 06.08.2018@{ub}
- Preferences can now be saved from settings window
- Time zone is shown as UTC offset in settings window
- Running multiple instances no longer create zombie processes
- Low water option renamed to threshold and high water option removed
- New option for sending log messages to file instead of to screen
- Some incorrect NTP log messages no longer appears
- Read-only option is now applied consistently
- Potential race condition in memory allocation fixed
- Other minor enhancements
@{b}v1.04 15.12.2017@{ub}
- Default settings adjusted to comply better with AmigaOS
- Bugs in threshold settings (high/low water) fixed
- Bugs in opening and closing of libraries fixed
- New and more accurate error and log messages
@{b}v1.03 09.12.2017@{ub}
- Settings window
@{b}v1.02 29.11.2017@{ub}
- AROS code compliance
@{b}v1.01 28.11.2017@{ub}
- Handle network disconnection
- Fix infinity timeout problem
- Support hardware clock
- Improved error messages
@{b}v1.00 26.11.2017@{ub}
- First public release
@EndNode
@Node "Software License" "TimeKeeper.guide/Software License"
@Prev "Change Log"
@Next "Contacting the author"
@Toc "Main"
@{b}Simplified BSD License / 2-clause BSD license@{ub}
Copyright (c) 2001, 02 Motoyuki Kasahara
Copyright (c) 2007 TANDBERG Telecom AS
Copyright (c) 2008-2009 Dag-Erling Smørgrav <des@des.no>
Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@EndNode
@Node "Contacting the author" "TimeKeeper.guide/Contacting the author"
@Toc "Main"
@Prev "Software License"
The author of AmiTimeKeeper can be contacted using the following
email addresses: <carsten.larsen@mail.com> or <cs@innolan.net>.
Please notice <cs@innolan.net> is a member of several high volume
mailing lists and should not be used under normal circumstances.
Feel free to send suggestions, feature request and bug reports.
General comment and questions are also welcome.
Carsten Sonne Larsen
February 2019
@EndNode
+116 -30
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,11 @@
#include "mem.h"
#include "win.h"
#define EVT_HOTKEY 1L
static void ProcessMsg(void);
static void InitBroker(void);
static void CleanupBroker(void);
static struct NewBroker newBroker = {
NB_VERSION,
@@ -44,6 +48,9 @@ void StartBroker(void)
{
LONG error;
struct Message *msg;
CxObj *filter, *sender, *translate;
InitBroker();
Globals->Broker->BrokerPort = CreateMsgPort();
if (Globals->Broker->BrokerPort == NULL)
@@ -56,8 +63,7 @@ void StartBroker(void)
if (Globals->Broker->UserPort == NULL)
{
LogError("Could not allocate broker user port");
DeleteMsgPort(Globals->Broker->BrokerPort);
Globals->Broker->BrokerPort = NULL;
CleanupBroker();
return;
}
@@ -65,10 +71,7 @@ void StartBroker(void)
if (Globals->Broker->ReplyPort == NULL)
{
LogError("Could not allocate broker reply port");
DeleteMsgPort(Globals->Broker->BrokerPort);
DeleteMsgPort(Globals->Broker->UserPort);
Globals->Broker->BrokerPort = NULL;
Globals->Broker->UserPort = NULL;
CleanupBroker();
return;
}
@@ -76,12 +79,7 @@ void StartBroker(void)
if (Globals->Broker->ShutdownSigBit == -1)
{
SendErrorMessage("Could not allocate signal for broker");
DeleteMsgPort(Globals->Broker->BrokerPort);
DeleteMsgPort(Globals->Broker->UserPort);
DeleteMsgPort(Globals->Broker->ReplyPort);
Globals->Broker->BrokerPort = NULL;
Globals->Broker->UserPort = NULL;
Globals->Broker->ReplyPort = NULL;
CleanupBroker();
return;
}
@@ -97,23 +95,64 @@ void StartBroker(void)
LogError("System problems (CBERR_SYSERR). Could not allocate broker object");
break;
case CBERR_DUP:
LogWarning(APP_SHORT_NAME " already running");
LogWarning(APP_SHORT_NAME " is already running");
break;
default:
LogError("Could not allocate broker object (error code: %ld)", error);
break;
}
DeleteMsgPort(Globals->Broker->BrokerPort);
DeleteMsgPort(Globals->Broker->UserPort);
DeleteMsgPort(Globals->Broker->ReplyPort);
Globals->Broker->BrokerPort = NULL;
Globals->Broker->UserPort = NULL;
Globals->Broker->ReplyPort = NULL;
Globals->Broker->Object = NULL;
CleanupBroker();
return;
}
filter = CxFilter(Globals->Settings->PopKey);
if (filter == NULL)
{
LogError("Could not allocate broker filter object");
CleanupBroker();
return;
}
AttachCxObj(Globals->Broker->Object, filter);
sender = CxSender(Globals->Broker->BrokerPort, EVT_HOTKEY);
if (sender == NULL)
{
LogError("Could not allocate broker sender object");
CleanupBroker();
return;
}
AttachCxObj(filter, sender);
translate = CxTranslate(NULL);
if (translate == NULL)
{
LogError("Could not allocate broker translate object");
CleanupBroker();
return;
}
AttachCxObj(filter, translate);
error = CxObjError(filter);
if (error != 0)
{
switch (error)
{
case CBERR_SYSERR:
LogWarning("Commodity filter problems (CBERR_SYSERR)");
break;
case COERR_BADFILTER:
LogWarning("Commodity HOTKEY error");
break;
default:
LogWarning("Commodity filter error (error code: %ld)", error);
break;
}
}
Globals->Broker->Task = FindTask(NULL);
StartCom();
@@ -128,15 +167,7 @@ void StartBroker(void)
while ((msg = GetMsg(Globals->Broker->ReplyPort)))
ReplyMsg(msg);
DeleteCxObj(Globals->Broker->Object);
FreeSignal(Globals->Broker->ShutdownSigBit);
DeleteMsgPort(Globals->Broker->BrokerPort);
DeleteMsgPort(Globals->Broker->UserPort);
DeleteMsgPort(Globals->Broker->ReplyPort);
Globals->Broker->BrokerPort = NULL;
Globals->Broker->UserPort = NULL;
Globals->Broker->ReplyPort = NULL;
Globals->Broker->Object = NULL;
CleanupBroker();
}
void ShutdownBroker(void)
@@ -195,6 +226,11 @@ static void ProcessMsg(void)
ActivateCxObj(Globals->Broker->Object, 1);
Globals->Active = true;
if (Globals->Settings->Popup)
{
ShowSettingWindow();
}
do
{
ULONG sigrcvd = Wait(sigmask);
@@ -211,6 +247,13 @@ static void ProcessMsg(void)
switch (msgtype)
{
case CXM_IEVENT:
switch (msgid)
{
case EVT_HOTKEY:
LogTrace("Show window");
ShowSettingWindow();
break;
}
break;
case CXM_COMMAND:
switch (msgid)
@@ -329,3 +372,46 @@ static void ProcessMsg(void)
}
} while (run);
}
static void InitBroker(void)
{
Globals->Broker->Object = NULL;
Globals->Broker->ShutdownSigBit = -1;
Globals->Broker->Task = NULL;
Globals->Broker->BrokerPort = NULL;
Globals->Broker->UserPort = NULL;
Globals->Broker->ReplyPort = NULL;
}
static void CleanupBroker(void)
{
if (Globals->Broker->Object != NULL)
{
DeleteCxObjAll(Globals->Broker->Object);
Globals->Broker->Object = NULL;
}
if (Globals->Broker->ShutdownSigBit != -1)
{
FreeSignal(Globals->Broker->ShutdownSigBit);
Globals->Broker->ShutdownSigBit = -1;
}
if (Globals->Broker->BrokerPort != NULL)
{
DeleteMsgPort(Globals->Broker->BrokerPort);
Globals->Broker->BrokerPort = NULL;
}
if (Globals->Broker->UserPort != NULL)
{
DeleteMsgPort(Globals->Broker->UserPort);
Globals->Broker->UserPort = NULL;
}
if (Globals->Broker->ReplyPort != NULL)
{
DeleteMsgPort(Globals->Broker->ReplyPort);
Globals->Broker->ReplyPort = NULL;
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2014-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+23 -12
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,8 @@
#include <resources/battclock.h>
#include <libraries/asl.h>
#include <libraries/commodities.h>
#include <graphics/text.h>
#include <graphics/rastport.h>
#include <dos/dos.h>
#include <dos/dostags.h>
#include <proto/dos.h>
@@ -48,6 +50,7 @@
#include <proto/intuition.h>
#include <proto/battclock.h>
#include <proto/commodities.h>
#include <clib/graphics_protos.h>
#include <stdio.h>
#include <stdlib.h>
@@ -127,11 +130,6 @@ int poll(struct pollfd *, nfds_t, int);
#if AOS3
#define IPTR ULONG
#endif
#if AOS3
#define VARSIZE 0
#else
#define VARSIZE 1
#endif
#ifdef AROS
#define VSNPrintf(str, n, format, args) vsnprintf(str, n, format, args)
@@ -143,10 +141,16 @@ int poll(struct pollfd *, nfds_t, int);
#define LIB_ERROR -1
#define COM_ERROR -1
#ifdef AROS
#define APP_SHORT_NAME "ArosTimeKeeper"
#define APP_LONG_NAME "AROS Time Keeper"
#else
#define APP_SHORT_NAME "AmiTimeKeeper"
#define APP_LONG_NAME "Amiga Time Keeper"
#define APP_VERSION "1.05"
#define APP_DATE_VERSION "1.05 (06.08.2018)"
#endif
#define APP_VERSION "1.07"
#define APP_DATE_VERSION "1.07 (15.02.2019)"
#define APP_ID APP_SHORT_NAME " " APP_DATE_VERSION
#define APP_TITLE APP_LONG_NAME " " APP_DATE_VERSION
#define APP_TITLE_VERSION APP_LONG_NAME " " APP_VERSION
@@ -155,13 +159,16 @@ int poll(struct pollfd *, nfds_t, int);
#include "state.h"
#include "string.h"
#define KEYWORD_COUNT 9
#define KEYWORD_COUNT 12
#define KEYWORD_SERVER "SERVER"
#define KEYWORD_PORT "PORT"
#define KEYWORD_THRESHOLD "THRESHOLD"
#define KEYWORD_INTERVAL "INTERVAL"
#define KEYWORD_PRIORITY "CX_PRIORITY"
#define KEYWORD_POPKEY "CX_POPKEY"
#define KEYWORD_POPUP "CX_POPUP"
#define KEYWORD_READONLY "READONLY"
#define KEYWORD_EXPERT "EXPERT"
#define KEYWORD_TIMEOUT "TIMEOUT"
#define KEYWORD_VERBOSE "VERBOSE"
#define KEYWORD_LOGFILE "LOGFILE"
@@ -176,6 +183,7 @@ int poll(struct pollfd *, nfds_t, int);
#define PRIORITY_DEF 25
#define PRIORITY_MAX 127
#define READONLY_DEF 0
#define EXPERT_DEF 1
#define TIMEOUT_MIN 100
#define TIMEOUT_DEF 5000
#define TIMEOUT_MAX 30000
@@ -183,10 +191,13 @@ int poll(struct pollfd *, nfds_t, int);
#define VERBOSE_DEF 0
#define VERBOSE_MAX 3
#define LOGFILE_DEF NULL
#define POPKEY_DEF "lshift control t"
#define POPUP_DEF 0
#define KEYWORD_TEMPLATE_1 KEYWORD_READONLY "/S," KEYWORD_SERVER "/K," KEYWORD_PORT "/K," KEYWORD_TIMEOUT "/N/K," KEYWORD_THRESHOLD "/K,"
#define KEYWORD_TEMPLATE_2 KEYWORD_INTERVAL "/N/K," KEYWORD_VERBOSE "/N/K," KEYWORD_PRIORITY "/N/K," KEYWORD_LOGFILE "/K"
#define KEYWORD_TEMPLATE KEYWORD_TEMPLATE_1 KEYWORD_TEMPLATE_2
#define KEYWORD_TEMPLATE_1 KEYWORD_READONLY "/S," KEYWORD_EXPERT "/S," KEYWORD_SERVER "/K," KEYWORD_PORT "/K," KEYWORD_TIMEOUT "/N/K,"
#define KEYWORD_TEMPLATE_2 KEYWORD_THRESHOLD "/K," KEYWORD_INTERVAL "/N/K," KEYWORD_VERBOSE "/N/K,"
#define KEYWORD_TEMPLATE_3 KEYWORD_PRIORITY "/N/K," KEYWORD_POPKEY "/K," KEYWORD_POPUP "/K," KEYWORD_LOGFILE "/K"
#define KEYWORD_TEMPLATE KEYWORD_TEMPLATE_1 KEYWORD_TEMPLATE_2 KEYWORD_TEMPLATE_3
/* broker.c */
void StartBroker(void);
+26 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,7 @@
/* Library identifiers */
static const char *dosName = "dos.library";
static const char *aslName = "asl.library";
static const char *gfxName = "graphics.library";
static const char *iconName = "icon.library";
static const char *commoditiesName = "commodities.library";
static const char *localeName = "locale.library";
@@ -46,6 +47,7 @@ static const char *mathName = "mathieeedoubbas.library";
#define UtilityBase __FX_UtilityBase
#define IntuitionBase __FX_IntuitionBase
#define CxBase __FX_CxBase
#define GfxBase __FX_GfxBase
#define AslBase __FX_AslBase
#define IconBase __FX_IconBase
#define GadToolsBase __FX_GadToolsBase
@@ -60,6 +62,7 @@ struct LocaleBase *LocaleBase = NULL;
struct UtilityBase *UtilityBase = NULL;
struct IntuitionBase *IntuitionBase = NULL;
struct Library *CxBase = NULL;
struct Library *GfxBase = NULL;
struct Library *AslBase = NULL;
struct Library *IconBase = NULL;
struct Library *GadToolsBase = NULL;
@@ -70,6 +73,8 @@ struct UtilityBase *__UtilityBase = NULL;
#define DOSLIB_REV 36L
#define ASLLIB_NAME ((STRPTR)aslName)
#define ASLLIB_REV 37L
#define GFXLIB_NAME ((STRPTR)gfxName)
#define GFXLIB_REV 37L
#define ICONLIB_NAME ((STRPTR)iconName)
#define ICONLIB_REV 36L
#define COMMODLIB_NAME ((STRPTR)commoditiesName)
@@ -125,6 +130,8 @@ static void ClosingResource(const char *name)
int OpenLibraries(void)
{
LogInfo("Starting up");
// DOS Library
if (!(DOSBase = (struct DosLibrary *)OpenLibrary((STRPTR)DOSLIB_NAME, DOSLIB_REV)))
{
@@ -217,6 +224,15 @@ int OpenLibraries(void)
OpenLibrarySuccess(GadToolsBase->lib_IdString);
// Graphics Library
if (!(GfxBase = OpenLibrary((STRPTR)GFXLIB_NAME, GFXLIB_REV)))
{
OpenLibraryError(GFXLIB_NAME, GFXLIB_REV);
return LIB_ERROR;
}
OpenLibrarySuccess(GfxBase->lib_IdString);
// Locale
if (!(Globals->Locale = OpenLocale(NULL)))
{
@@ -251,6 +267,8 @@ int OpenLibraries(void)
void CloseLibraries(void)
{
LogInfo("Shutting down");
if (TimerDevice != NULL)
{
ClosingResource((const char *)TIMERNAME);
@@ -308,6 +326,13 @@ void CloseLibraries(void)
GadToolsBase = NULL;
}
if (GfxBase != NULL)
{
ClosingLibrary(GfxBase->lib_IdString);
CloseLibrary(GfxBase);
GfxBase = NULL;
}
if (IntuitionBase != NULL)
{
ClosingLibrary(((struct Library *)IntuitionBase)->lib_IdString);
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2014-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2014-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2001, 02 Motoyuki Kasahara
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2001, 02 Motoyuki Kasahara
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,7 +1,7 @@
/*-
* Copyright (c) 2007 TANDBERG Telecom AS
* Copyright (c) 2008-2009 Dag-Erling Smørgrav <des@des.no>
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,7 +1,7 @@
/*-
* Copyright (c) 2007 TANDBERG Telecom AS
* Copyright (c) 2008-2009 Dag-Erling Smørgrav <des@des.no>
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+248 -225
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,7 +36,10 @@ static const struct AppSettingKeys SettingKeyStruct = {
.Threshold = KEYWORD_THRESHOLD,
.Interval = KEYWORD_INTERVAL,
.Priority = KEYWORD_PRIORITY,
.PopKey = KEYWORD_POPKEY,
.Popup = KEYWORD_POPUP,
.Readonly = KEYWORD_READONLY,
.Expert = KEYWORD_EXPERT,
.Timeout = KEYWORD_TIMEOUT,
.Verbose = KEYWORD_VERBOSE,
.LogFile = KEYWORD_LOGFILE};
@@ -47,8 +50,11 @@ const struct AppSettings DefaultSettings = {
.DestinationPort = (char *)PORT_DEF,
.Timeout = TIMEOUT_DEF,
.Interval = INTERVAL_DEF,
.PopKey = POPKEY_DEF,
.Popup = POPUP_DEF,
.Verbose = VERBOSE_DEF,
.Readonly = READONLY_DEF,
.Expert = EXPERT_DEF,
.Priority = PRIORITY_DEF,
.Threshold = THRESHOLD_DEF,
.LogFile = (char *)LOGFILE_DEF,
@@ -62,11 +68,15 @@ static void SetThresholdSetting(struct AppSettings *, void *);
static void SetDestinationAddressSetting(struct AppSettings *, void *);
static void SetDestinationPortSetting(struct AppSettings *, void *);
static void SetReadOnlySetting(struct AppSettings *, void *);
static void SetExpertSetting(struct AppSettings *, void *);
static void SetLogFileSetting(struct AppSettings *, void *);
static void SetPopupSetting(struct AppSettings *, void *);
static void SetPopKeySetting(struct AppSettings *, void *);
// Keyword order in settingFunctions needs to match order in keyword template
const struct SettingFunc settingFunctions[] = {
{KEYWORD_READONLY, SetReadOnlySetting},
{KEYWORD_EXPERT, SetExpertSetting},
{KEYWORD_SERVER, SetDestinationAddressSetting},
{KEYWORD_PORT, SetDestinationPortSetting},
{KEYWORD_TIMEOUT, SetTimeoutSetting},
@@ -74,6 +84,8 @@ const struct SettingFunc settingFunctions[] = {
{KEYWORD_INTERVAL, SetIntervalSetting},
{KEYWORD_VERBOSE, SetVerboseSetting},
{KEYWORD_PRIORITY, SetPrioritySetting},
{KEYWORD_POPKEY, SetPopKeySetting},
{KEYWORD_POPUP, SetPopupSetting},
{KEYWORD_LOGFILE, SetLogFileSetting}};
static const char *prefsFile = "ENV:timekeeper.prefs";
@@ -91,12 +103,12 @@ static const char *foundSetting = "Found %s in preference file";
static const char *foundWbSetting = "Found tooltype from icon: %s";
static const char *foundCliSetting = "Got %s from CLI";
static const char *integerError = "Value should be an integer: %s";
static const char *yesNoError = "Value should be YES or NO: %s";
static const char *applyDefaultSettings = "Applying default values";
static const char *applyFileSettings = "Applying values from preference file";
static const char *applyCliSettings = "Applying values from CLI";
static const char *applyWbSettings = "Applying values from tooltypes";
static const char *effectiveSettings = "Listing runtime values";
static const char *noLogFile = "(none)";
static const char *settingTooLow = "%s < %ld (too low)";
static const char *settingTooHigh = "%s > %ld (too high)";
static const char *settingGreaterThan = "%s > %s";
@@ -109,6 +121,10 @@ static const char *settingValueString = "%s=%s";
static const char *saveValueLong = "%s=%ld\n";
static const char *saveValueString = "%s=%s\n";
static const char *noLogFile = "(none)";
static const char *noValueString = "NO";
static const char *yesValueString = "YES";
#define MAXSETTINGLINELEN 256
static struct AppSettings *fileSettings;
@@ -139,11 +155,18 @@ void DestroyState(void)
FreeMemSafe((void *)Globals);
}
static char *BooleanAsText(bool value)
{
return (char *)(value ? yesValueString : noValueString);
}
void ShowAppSettings(struct AppSettings *settings)
{
char low[MAXLONGLONGCHARSIZE];
LongLongToStr(settings->Threshold, low);
LogTrace(settingValueString, SettingKeys->Popup, BooleanAsText(settings->Popup));
LogTrace(settingValueString, SettingKeys->PopKey, settings->PopKey);
LogTrace(settingValueLong, SettingKeys->Priority, settings->Priority);
LogTrace(settingValueString, SettingKeys->Threshold, low);
LogTrace(settingValueString, SettingKeys->DestinationAddress, settings->DestinationAddress);
@@ -151,7 +174,8 @@ void ShowAppSettings(struct AppSettings *settings)
LogTrace(settingValueLong, SettingKeys->Timeout, settings->Timeout);
LogTrace(settingValueLong, SettingKeys->Interval, settings->Interval);
LogTrace(settingValueLong, SettingKeys->Verbose, settings->Verbose);
LogTrace(settingValueLong, SettingKeys->Readonly, settings->Readonly);
LogTrace(settingValueString, SettingKeys->Readonly, BooleanAsText(settings->Readonly));
LogTrace(settingValueString, SettingKeys->Expert, BooleanAsText(settings->Expert));
LogTrace(settingValueString, SettingKeys->LogFile,
settings->LogFile ? settings->LogFile : noLogFile);
}
@@ -166,7 +190,7 @@ void LogFoundSetting(long type, const char *name)
{
switch (type)
{
case FileSettingType:
case PrefsSettingType:
LogTrace(foundSetting, name);
break;
case CliSettingType:
@@ -180,144 +204,161 @@ void LogFoundSetting(long type, const char *name)
}
}
static void SetPrioritySetting(struct AppSettings *setting, void *value)
static void ParseLongSetting(
struct AppSettings *settings,
long flag,
const char *keyword,
long *valueField,
void *value)
{
LogFoundSetting(setting->Type, SettingKeys->Priority);
if (setting->Type == CliSettingType)
LogFoundSetting(settings->Type, keyword);
if (settings->Type == CliSettingType)
{
setting->Priority = *(long *)value;
setting->Values |= PrioritySet;
*valueField = *(long *)value;
settings->Values |= flag;
return;
}
if (TryParseLong((char *)value, &setting->Priority))
if (TryParseLong((char *)value, valueField))
{
setting->Values |= PrioritySet;
settings->Values |= flag;
return;
}
LogWarning(integerError, value);
}
static void SetVerboseSetting(struct AppSettings *setting, void *value)
static void ParseBooleanSetting(
struct AppSettings *settings,
long flag,
const char *keyword,
long *valueField,
void *value,
bool yesNo)
{
LogFoundSetting(setting->Type, SettingKeys->Verbose);
if (setting->Type == CliSettingType)
LogFoundSetting(settings->Type, SettingKeys->Popup);
// CLI switch is always a long value
if (settings->Type == CliSettingType && !yesNo)
{
setting->Verbose = *(long *)value;
setting->Values |= VerboseSet;
*valueField = (*valueField != 0 ? true : false);
settings->Values |= flag;
return;
}
if (TryParseLong((char *)value, &setting->Verbose))
if (value == NULL || *((const char *)value) == '\0')
{
setting->Values |= VerboseSet;
LogWarning(yesNoError, '\0');
return;
}
if (Stricmp((STRPTR)noValueString, (STRPTR)value) == 0 || Stricmp("0", (STRPTR)value) == 0)
{
*valueField = false;
settings->Values |= flag;
return;
}
if (Stricmp((STRPTR)yesValueString, (STRPTR)value) == 0 || Stricmp("1", (STRPTR)value) == 0)
{
*valueField = true;
settings->Values |= flag;
return;
}
LogWarning(yesNoError, value);
}
static void SetPrioritySetting(struct AppSettings *settings, void *value)
{
ParseLongSetting(settings, PrioritySet, SettingKeys->Priority,
&settings->Priority, value);
}
static void SetVerboseSetting(struct AppSettings *settings, void *value)
{
ParseLongSetting(settings, VerboseSet, SettingKeys->Verbose,
&settings->Verbose, value);
}
static void SetIntervalSetting(struct AppSettings *settings, void *value)
{
ParseLongSetting(settings, IntervalSet, SettingKeys->Interval,
&settings->Interval, value);
}
static void SetTimeoutSetting(struct AppSettings *settings, void *value)
{
ParseLongSetting(settings, TimeoutSet, SettingKeys->Timeout,
&settings->Timeout, value);
}
static void SetThresholdSetting(struct AppSettings *settings, void *value)
{
LogFoundSetting(settings->Type, SettingKeys->Threshold);
if (TryParseLongLong((char *)value, &settings->Threshold))
{
settings->Values |= ThresholdSet;
return;
}
LogWarning(integerError, value);
}
static void SetIntervalSetting(struct AppSettings *setting, void *value)
static void SetDestinationAddressSetting(struct AppSettings *settings, void *value)
{
LogFoundSetting(setting->Type, SettingKeys->Interval);
if (setting->Type == CliSettingType)
{
setting->Interval = *(long *)value;
setting->Values |= IntervalSet;
return;
}
if (TryParseLong((char *)value, &setting->Interval))
{
setting->Values |= IntervalSet;
return;
}
LogWarning(integerError, value);
LogFoundSetting(settings->Type, SettingKeys->DestinationAddress);
settings->DestinationAddress = StrDupSafe((const char *)value);
settings->Values |= DestinationAddressSet;
}
static void SetTimeoutSetting(struct AppSettings *setting, void *value)
static void SetPopKeySetting(struct AppSettings *settings, void *value)
{
LogFoundSetting(setting->Type, SettingKeys->Timeout);
if (setting->Type == CliSettingType)
{
setting->Timeout = *(long *)value;
setting->Values |= TimeoutSet;
return;
}
if (TryParseLong((char *)value, &setting->Timeout))
{
setting->Values |= TimeoutSet;
return;
}
LogWarning(integerError, value);
LogFoundSetting(settings->Type, SettingKeys->PopKey);
settings->PopKey = StrDupSafe((const char *)value);
settings->Values |= PopKeySet;
}
static void SetThresholdSetting(struct AppSettings *setting, void *value)
static void SetDestinationPortSetting(struct AppSettings *settings, void *value)
{
LogFoundSetting(setting->Type, SettingKeys->Threshold);
if (TryParseLongLong((char *)value, &setting->Threshold))
{
setting->Values |= ThresholdSet;
return;
}
LogWarning(integerError, value);
LogFoundSetting(settings->Type, SettingKeys->DestinationPort);
settings->DestinationPort = StrDupSafe((const char *)value);
settings->Values |= DestinationPortSet;
}
static void SetDestinationAddressSetting(struct AppSettings *setting, void *value)
static void SetReadOnlySetting(struct AppSettings *settings, void *value)
{
LogFoundSetting(setting->Type, SettingKeys->DestinationAddress);
setting->DestinationAddress = StrDupSafe((const char *)value);
setting->Values |= DestinationAddressSet;
ParseBooleanSetting(settings, ReadonlySet, SettingKeys->Readonly,
&settings->Readonly, value, true);
}
static void SetDestinationPortSetting(struct AppSettings *setting, void *value)
static void SetExpertSetting(struct AppSettings *settings, void *value)
{
LogFoundSetting(setting->Type, SettingKeys->DestinationPort);
setting->DestinationPort = StrDupSafe((const char *)value);
setting->Values |= DestinationPortSet;
ParseBooleanSetting(settings, ExpertSet, SettingKeys->Expert,
&settings->Expert, value, true);
}
static void SetReadOnlySetting(struct AppSettings *setting, void *value)
static void SetPopupSetting(struct AppSettings *settings, void *value)
{
LogFoundSetting(setting->Type, SettingKeys->Readonly);
if (setting->Type == CliSettingType)
{
setting->Readonly = value != 0 ? true : false;
setting->Values |= ReadonlySet;
return;
}
if (TryParseLong((char *)value, &setting->Readonly))
{
setting->Readonly = setting->Readonly != 0 ? true : false;
setting->Values |= ReadonlySet;
return;
}
LogWarning(integerError, value);
ParseBooleanSetting(settings, PopUpSet, SettingKeys->Popup,
&settings->Popup, value, false);
}
static void SetLogFileSetting(struct AppSettings *setting, void *value)
static void SetLogFileSetting(struct AppSettings *settings, void *value)
{
static const char *no = "no";
LogFoundSetting(setting->Type, SettingKeys->LogFile);
LogFoundSetting(settings->Type, SettingKeys->LogFile);
if (value == NULL || *((const char *)value) == '\0' ||
Stricmp((STRPTR)no, (STRPTR)value) == 0 ||
Stricmp((STRPTR)noValueString, (STRPTR)value) == 0 ||
Stricmp((STRPTR)noLogFile, (STRPTR)value) == 0)
{
setting->LogFile = NULL;
settings->LogFile = NULL;
}
else
{
setting->LogFile = StrDupSafe((const char *)value);
settings->LogFile = StrDupSafe((const char *)value);
}
setting->Values |= LogFileSet;
settings->Values |= LogFileSet;
}
static void ParseSetting(struct AppSettings *settings, char *line)
@@ -386,7 +427,7 @@ void LoadSettings(void)
LogInfo(prefsFileFound);
settings = CreateSettings(FileSettingType);
settings = CreateSettings(PrefsSettingType);
do
{
@@ -449,6 +490,8 @@ void SaveSettings(bool persist)
LogInfo(prefsFileSave, fileName);
LongLongToStr(Globals->Settings->Threshold, low);
WriteSetting(file, saveValueString, SettingKeys->Popup, BooleanAsText(Globals->Settings->Popup));
WriteSetting(file, saveValueString, SettingKeys->PopKey, Globals->Settings->PopKey);
WriteSetting(file, saveValueLong, SettingKeys->Priority, Globals->Settings->Priority);
WriteSetting(file, saveValueString, SettingKeys->Threshold, low);
WriteSetting(file, saveValueString, SettingKeys->DestinationAddress, Globals->Settings->DestinationAddress);
@@ -456,7 +499,8 @@ void SaveSettings(bool persist)
WriteSetting(file, saveValueLong, SettingKeys->Timeout, Globals->Settings->Timeout);
WriteSetting(file, saveValueLong, SettingKeys->Interval, Globals->Settings->Interval);
WriteSetting(file, saveValueLong, SettingKeys->Verbose, Globals->Settings->Verbose);
WriteSetting(file, saveValueLong, SettingKeys->Readonly, Globals->Settings->Readonly);
WriteSetting(file, saveValueString, SettingKeys->Readonly, BooleanAsText(Globals->Settings->Readonly));
WriteSetting(file, saveValueString, SettingKeys->Expert, BooleanAsText(Globals->Settings->Expert));
WriteSetting(file, saveValueString, SettingKeys->LogFile, Globals->Settings->LogFile);
Close(file);
@@ -476,6 +520,7 @@ struct AppSettings *CopySettings(const struct AppSettings *settings)
CopyMem((void *)settings, s, sizeof(struct AppSettings));
s->DestinationAddress = StrDupSafe(settings->DestinationAddress);
s->DestinationPort = StrDupSafe(settings->DestinationPort);
s->PopKey = StrDupSafe(settings->PopKey);
if (s->LogFile != NULL)
{
s->LogFile = StrDupSafe(settings->LogFile);
@@ -496,6 +541,11 @@ void FreeSettings(struct AppSettings *settings)
FreeMemSafe(settings->DestinationPort);
}
if (settings->PopKey != NULL)
{
FreeMemSafe(settings->PopKey);
}
if (settings->LogFile != NULL)
{
FreeMemSafe(settings->LogFile);
@@ -504,6 +554,89 @@ void FreeSettings(struct AppSettings *settings)
FreeMemSafe(settings);
}
static void ApplyLongSetting(
struct AppSettings *settings,
long flag,
const char *keyword,
long *curValue,
long *newValue,
bool quiet)
{
if ((settings->Values & flag) == flag)
{
if (settings->Type == DefaultSettingType)
{
LogTrace(settingValueLong, keyword, *newValue);
}
else if (*curValue != *newValue)
{
LogInfo(settingChangedLong, keyword, *curValue, *newValue);
}
else if (!quiet)
{
LogTrace(settingSetLong, keyword, *newValue);
}
*curValue = *newValue;
}
}
static void ApplyBooleanSetting(
struct AppSettings *settings,
long flag,
const char *keyword,
long *curValue,
long *newValue,
bool quiet)
{
if ((settings->Values & flag) == flag)
{
if (settings->Type == DefaultSettingType)
{
LogTrace(settingValueString, keyword, BooleanAsText(*newValue));
}
else if (*curValue != *newValue)
{
LogInfo(settingChangedString, keyword, BooleanAsText(*curValue), BooleanAsText(*newValue));
}
else if (!quiet)
{
LogTrace(settingValueString, keyword, BooleanAsText(*newValue));
}
*curValue = *newValue;
}
}
static void ApplyStringSetting(
struct AppSettings *settings,
long flag,
const char *keyword,
char **curValue,
char *newValue,
bool quiet)
{
if ((settings->Values & flag) == flag)
{
if (settings->Type == DefaultSettingType)
{
LogTrace(settingValueString, keyword, newValue);
}
else if (Stricmp((STRPTR)*curValue, (STRPTR)newValue) != 0)
{
LogInfo(settingChangedString, keyword, *curValue, newValue);
}
else if (!quiet)
{
LogTrace(settingSetString, keyword, newValue);
}
if (*curValue != NULL)
{
FreeMemSafe(*curValue);
}
*curValue = StrDupSafe(newValue);
}
}
void ApplyAppSettings(struct AppSettings *settings, bool quiet)
{
switch (settings->Type)
@@ -511,7 +644,7 @@ void ApplyAppSettings(struct AppSettings *settings, bool quiet)
case DefaultSettingType:
LogInfo(applyDefaultSettings);
break;
case FileSettingType:
case PrefsSettingType:
LogInfo(applyFileSettings);
break;
case CliSettingType:
@@ -524,145 +657,35 @@ void ApplyAppSettings(struct AppSettings *settings, bool quiet)
break;
}
if ((settings->Values & PrioritySet) == PrioritySet)
{
if (settings->Type == DefaultSettingType)
{
LogTrace(settingValueLong, SettingKeys->Priority, settings->Priority);
}
else if (Globals->Settings->Priority != settings->Priority)
{
LogInfo(settingChangedLong, SettingKeys->Priority, Globals->Settings->Priority,
settings->Priority);
}
else if (!quiet)
{
LogTrace(settingSetLong, SettingKeys->Priority, settings->Priority);
}
Globals->Settings->Priority = settings->Priority;
}
ApplyBooleanSetting(settings, PopUpSet, SettingKeys->Popup,
&Globals->Settings->Popup, &settings->Popup, quiet);
if ((settings->Values & VerboseSet) == VerboseSet)
{
if (settings->Type == DefaultSettingType)
{
LogTrace(settingValueLong, SettingKeys->Verbose, settings->Verbose);
}
else if (Globals->Settings->Verbose != settings->Verbose)
{
LogInfo(settingChangedLong, SettingKeys->Verbose, Globals->Settings->Verbose,
settings->Verbose);
}
else if (!quiet)
{
LogTrace(settingSetLong, SettingKeys->Verbose, settings->Verbose);
}
Globals->Settings->Verbose = settings->Verbose;
}
ApplyStringSetting(settings, PopKeySet, SettingKeys->PopKey,
&Globals->Settings->PopKey, settings->PopKey, quiet);
if ((settings->Values & TimeoutSet) == TimeoutSet)
{
if (settings->Type == DefaultSettingType)
{
LogTrace(settingValueLong, SettingKeys->Timeout, settings->Timeout);
}
else if (Globals->Settings->Timeout != settings->Timeout)
{
LogInfo(settingChangedLong, SettingKeys->Timeout, Globals->Settings->Timeout,
settings->Timeout);
}
else if (!quiet)
{
LogTrace(settingSetLong, SettingKeys->Timeout, settings->Timeout);
}
Globals->Settings->Timeout = settings->Timeout;
}
ApplyLongSetting(settings, PrioritySet, SettingKeys->Priority,
&Globals->Settings->Priority, &settings->Priority, quiet);
if ((settings->Values & IntervalSet) == IntervalSet)
{
if (settings->Type == DefaultSettingType)
{
LogTrace(settingValueLong, SettingKeys->Interval, settings->Interval);
}
else if (Globals->Settings->Interval != settings->Interval)
{
LogInfo(settingChangedLong, SettingKeys->Interval, Globals->Settings->Interval,
settings->Interval);
}
else if (!quiet)
{
LogTrace(settingSetLong, SettingKeys->Interval, settings->Interval);
}
Globals->Settings->Interval = settings->Interval;
}
ApplyLongSetting(settings, VerboseSet, SettingKeys->Verbose,
&Globals->Settings->Verbose, &settings->Verbose, quiet);
if ((settings->Values & ReadonlySet) == ReadonlySet)
{
if (settings->Type == DefaultSettingType)
{
LogTrace(settingValueLong, SettingKeys->Readonly, settings->Readonly);
}
else if (Globals->Settings->Readonly != settings->Readonly)
{
LogInfo(settingChangedLong, SettingKeys->Readonly, Globals->Settings->Readonly,
settings->Readonly);
}
else if (!quiet)
{
LogTrace(settingSetLong, SettingKeys->Readonly, settings->Readonly);
}
Globals->Settings->Readonly = settings->Readonly;
}
ApplyLongSetting(settings, TimeoutSet, SettingKeys->Timeout,
&Globals->Settings->Timeout, &settings->Timeout, quiet);
if ((settings->Values & DestinationAddressSet) == DestinationAddressSet)
{
if (settings->Type == DefaultSettingType)
{
LogTrace(settingValueString, SettingKeys->DestinationAddress,
settings->DestinationAddress);
}
else if (Stricmp((STRPTR)Globals->Settings->DestinationAddress,
(STRPTR)settings->DestinationAddress) != 0)
{
LogInfo(settingChangedString, SettingKeys->DestinationAddress,
Globals->Settings->DestinationAddress, settings->DestinationAddress);
}
else if (!quiet)
{
LogTrace(settingSetString, SettingKeys->DestinationAddress, settings->DestinationAddress);
}
ApplyLongSetting(settings, IntervalSet, SettingKeys->Interval,
&Globals->Settings->Interval, &settings->Interval, quiet);
if (Globals->Settings->DestinationAddress != NULL)
{
FreeMemSafe(Globals->Settings->DestinationAddress);
}
Globals->Settings->DestinationAddress = StrDupSafe(settings->DestinationAddress);
}
ApplyBooleanSetting(settings, ReadonlySet, SettingKeys->Readonly,
&Globals->Settings->Readonly, &settings->Readonly, quiet);
if ((settings->Values & DestinationPortSet) == DestinationPortSet)
{
if (settings->Type == DefaultSettingType)
{
LogTrace(settingValueString, SettingKeys->DestinationPort,
settings->DestinationPort);
}
else if (Stricmp((STRPTR)Globals->Settings->DestinationPort,
(STRPTR)settings->DestinationPort) != 0)
{
LogInfo(settingChangedString, SettingKeys->DestinationPort,
Globals->Settings->DestinationPort, settings->DestinationPort);
}
else if (!quiet)
{
LogTrace(settingSetString, SettingKeys->DestinationPort, settings->DestinationPort);
}
ApplyBooleanSetting(settings, ExpertSet, SettingKeys->Expert,
&Globals->Settings->Expert, &settings->Expert, quiet);
if (Globals->Settings->DestinationPort != NULL)
{
FreeMemSafe(Globals->Settings->DestinationPort);
}
Globals->Settings->DestinationPort = StrDupSafe(settings->DestinationPort);
}
ApplyStringSetting(settings, DestinationAddressSet, SettingKeys->DestinationAddress,
&Globals->Settings->DestinationAddress, settings->DestinationAddress, quiet);
ApplyStringSetting(settings, DestinationPortSet, SettingKeys->DestinationPort,
&Globals->Settings->DestinationPort, settings->DestinationPort, quiet);
if ((settings->Values & ThresholdSet) == ThresholdSet)
{
+15 -6
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,13 +34,16 @@
#define TimeoutSet 0x004
#define IntervalSet 0x008
#define ReadonlySet 0x010
#define DestinationAddressSet 0x020
#define DestinationPortSet 0x040
#define ThresholdSet 0x080
#define LogFileSet 0x200
#define ExpertSet 0x020
#define DestinationAddressSet 0x040
#define DestinationPortSet 0x080
#define ThresholdSet 0x100
#define PopKeySet 0x200
#define PopUpSet 0x400
#define LogFileSet 0x800
#define DefaultSettingType 0x01
#define FileSettingType 0x02
#define PrefsSettingType 0x02
#define CliSettingType 0x03
#define WbSettingType 0x04
#define GlobalSettingType 0x10
@@ -82,10 +85,13 @@ struct AppSettings
long Timeout;
long Interval;
long Readonly;
long Expert;
long long Threshold;
char *DestinationAddress;
char *DestinationPort;
char *LogFile;
char *PopKey;
long Popup;
long Values;
long Type;
};
@@ -110,10 +116,13 @@ struct AppSettingKeys
const char *Timeout;
const char *Interval;
const char *Readonly;
const char *Expert;
const char *DestinationAddress;
const char *DestinationPort;
const char *Threshold;
const char *LogFile;
const char *PopKey;
const char *Popup;
};
typedef void (*ParseSettingFunction)(struct AppSettings *, void *);
+5 -2
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -346,6 +346,8 @@ int SNPrintf(char *str, size_t size, const char *format, ...)
#endif
// Not curretly in used
#if 0
/*
* Split filename in path and filename.
*/
@@ -388,4 +390,5 @@ void SplitFileName(const char *s, char *path, char *name)
*(char *)(path + x) = '\0';
CopyMem((char *)s, path, x);
CopyMem(++c, name, y);
}
}
#endif
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
+208 -200
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -57,6 +57,18 @@ static const char *saveLabel = "Save";
static const char *useLabel = "Use";
static const char *cancelLabel = "Cancel";
static const char **textLabels[] = {
&serverLabel,
&portLabel,
&timeoutLabel,
&intervalLabel,
&thresholdLabel,
&verboseLabel,
&priorityLabel,
&timeZoneLabel,
&lastSyncLabel,
NULL};
static char *verboseLevel[] = {
"Show none (0)",
"Show some (1)",
@@ -64,11 +76,33 @@ static char *verboseLevel[] = {
"Show all (3)",
NULL};
int GetLabelWidth(struct RastPort *rp)
{
int len, max = 0;
int c, i = 0;
const char **label = textLabels[0];
while (**label != NULL)
{
c = StrLen(*label);
len = TextLength(rp, *label, c);
if (len > max)
{
max = len;
}
label = textLabels[++i];
}
return max;
}
bool CreateGadgets(void)
{
struct Gadget *gadget;
struct NewGadget *ng;
long x, y, w, h;
long x, y, h;
long labelWidth;
long textWidth, boxWidth;
long col1, col2;
long labelId;
@@ -89,17 +123,17 @@ bool CreateGadgets(void)
ng->ng_TextAttr = Globals->Window->Screen->Font;
ng->ng_Flags = 0;
w = Globals->Window->Screen->RastPort.TxWidth;
h = Globals->Window->Screen->RastPort.TxHeight;
x = Globals->Window->Screen->WBorLeft + 8;
y = Globals->Window->Screen->WBorTop + h + 9;
col1 = x;
textWidth = 13 + VARSIZE;
labelWidth = GetLabelWidth(&Globals->Window->Screen->RastPort);
col2 = col1 + w * textWidth;
boxWidth = 13 + VARSIZE * 2;
col1 = x;
textWidth = labelWidth + Globals->Window->Screen->RastPort.TxWidth / 2;
col2 = col1 + textWidth;
boxWidth = labelWidth;
ng->ng_TopEdge = y;
ng->ng_Height = h + 6;
@@ -108,7 +142,7 @@ bool CreateGadgets(void)
// Server
ng->ng_LeftEdge = col1;
ng->ng_Width = textWidth * w + 20;
ng->ng_Width = textWidth;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
@@ -118,7 +152,7 @@ bool CreateGadgets(void)
return false;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth * w + 20;
ng->ng_Width = boxWidth + 20;
ng->ng_GadgetID = GID_SERVER;
gadget = CreateGadget(
STRING_KIND, gadget, ng,
@@ -129,164 +163,168 @@ bool CreateGadgets(void)
Globals->Window->Gadgets->ServerGadget = gadget;
// Port
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth * w + 20;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTTX_Text, (IPTR)portLabel,
TAG_END);
if (!gadget)
return false;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth * w + 20;
ng->ng_GadgetID = GID_PORT;
gadget = CreateGadget(
STRING_KIND, gadget, ng,
GTST_String, (IPTR)Globals->Settings->DestinationPort,
TAG_END);
if (!gadget)
return false;
if (Globals->Settings->Expert)
{
// Port
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTTX_Text, (IPTR)portLabel,
TAG_END);
if (!gadget)
return false;
Globals->Window->Gadgets->PortGadget = gadget;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth + 20;
ng->ng_GadgetID = GID_PORT;
gadget = CreateGadget(
STRING_KIND, gadget, ng,
GTST_String, (IPTR)Globals->Settings->DestinationPort,
TAG_END);
if (!gadget)
return false;
// Interval
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth * w + 20;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTNM_MaxNumberLen, 8,
GTTX_Text, (IPTR)intervalLabel,
TAG_END);
if (!gadget)
return false;
Globals->Window->Gadgets->PortGadget = gadget;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth * w + 20;
ng->ng_GadgetID = GID_INTERVAL;
gadget = CreateGadget(
INTEGER_KIND, gadget, ng,
GTNM_MaxNumberLen, 8,
GTIN_Number, Globals->Settings->Interval,
TAG_END);
if (!gadget)
return false;
// Interval
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTNM_MaxNumberLen, 8,
GTTX_Text, (IPTR)intervalLabel,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->IntervalGadget = gadget;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth + 20;
ng->ng_GadgetID = GID_INTERVAL;
gadget = CreateGadget(
INTEGER_KIND, gadget, ng,
GTNM_MaxNumberLen, 8,
GTIN_Number, Globals->Settings->Interval,
TAG_END);
if (!gadget)
return false;
// Timeout
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth * w + 20;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTTX_Text, (IPTR)timeoutLabel,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->IntervalGadget = gadget;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth * w + 20;
ng->ng_GadgetID = GID_TIMEOUT;
gadget = CreateGadget(
INTEGER_KIND, gadget, ng,
GTNM_MaxNumberLen, 8,
GTIN_Number, Globals->Settings->Timeout,
TAG_END);
if (!gadget)
return false;
// Timeout
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTTX_Text, (IPTR)timeoutLabel,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->TimeoutGadget = gadget;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth + 20;
ng->ng_GadgetID = GID_TIMEOUT;
gadget = CreateGadget(
INTEGER_KIND, gadget, ng,
GTNM_MaxNumberLen, 8,
GTIN_Number, Globals->Settings->Timeout,
TAG_END);
if (!gadget)
return false;
// Threshold
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth * w + 20;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTTX_Text, (IPTR)thresholdLabel,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->TimeoutGadget = gadget;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth * w + 20;
ng->ng_GadgetID = GID_THRESHOLD;
gadget = CreateGadget(
STRING_KIND, gadget, ng,
GTST_String, (IPTR)Globals->Window->ThresholdText,
TAG_END);
if (!gadget)
return false;
// Threshold
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTTX_Text, (IPTR)thresholdLabel,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->ThresholdGadget = gadget;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth + 20;
ng->ng_GadgetID = GID_THRESHOLD;
gadget = CreateGadget(
STRING_KIND, gadget, ng,
GTST_String, (IPTR)Globals->Window->ThresholdText,
TAG_END);
if (!gadget)
return false;
// Verbose
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth * w + 20;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTTX_Text, (IPTR)verboseLabel,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->ThresholdGadget = gadget;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth * w + 20;
ng->ng_GadgetID = GID_VERBOSE;
gadget = CreateGadget(
CYCLE_KIND, gadget, ng,
GTCY_Labels, (IPTR)verboseLevel,
GTCY_Active, Globals->Settings->Verbose,
TAG_END);
if (!gadget)
return false;
// Verbose
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTTX_Text, (IPTR)verboseLabel,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->VerboseGadget = gadget;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth + 20;
ng->ng_GadgetID = GID_VERBOSE;
gadget = CreateGadget(
CYCLE_KIND, gadget, ng,
GTCY_Labels, (IPTR)verboseLevel,
GTCY_Active, Globals->Settings->Verbose,
TAG_END);
if (!gadget)
return false;
// Priority
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth * w + 20;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTTX_Text, (IPTR)priorityLabel,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->VerboseGadget = gadget;
ng->ng_LeftEdge = col2;
ng->ng_Width = (boxWidth * w + 20) / 2;
ng->ng_GadgetID = GID_PRIORITY;
// Priority
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTTX_Text, (IPTR)priorityLabel,
TAG_END);
if (!gadget)
return false;
gadget = CreateGadget(
STRING_KIND, gadget, ng,
GTST_String, (IPTR)Globals->Window->PriorityText,
TAG_END);
if (!gadget)
return false;
ng->ng_LeftEdge = col2;
ng->ng_Width = (boxWidth + 20) / 2;
ng->ng_GadgetID = GID_PRIORITY;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->PriorityGadget = gadget;
gadget = CreateGadget(
STRING_KIND, gadget, ng,
GTST_String, (IPTR)Globals->Window->PriorityText,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->PriorityGadget = gadget;
}
// Time zone
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth * w + 20;
ng->ng_Width = textWidth;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
@@ -296,7 +334,7 @@ bool CreateGadgets(void)
return false;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth * w + 20;
ng->ng_Width = boxWidth + 20;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
@@ -310,7 +348,7 @@ bool CreateGadgets(void)
// Last sync
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth * w + 20;
ng->ng_Width = textWidth;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
@@ -320,7 +358,7 @@ bool CreateGadgets(void)
return false;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth * w + 20;
ng->ng_Width = boxWidth + 20;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
@@ -358,7 +396,7 @@ bool CreateGadgets(void)
return false;
Globals->Window->Height = ng->ng_TopEdge + ng->ng_Height;
Globals->Window->Width = textWidth * w + boxWidth * w;
Globals->Window->Width = textWidth + boxWidth;
FreeMemSafe(ng);
return true;
@@ -415,6 +453,9 @@ void SetPort(void)
{
char *port, *text;
if (Globals->Window->Gadgets->PortGadget == NULL)
return;
GT_GetGadgetAttrs(
Globals->Window->Gadgets->PortGadget,
Globals->Window->SettingWindow, NULL,
@@ -437,6 +478,9 @@ void SetInterval(void)
{
unsigned long value;
if (Globals->Window->Gadgets->IntervalGadget == NULL)
return;
GT_GetGadgetAttrs(
Globals->Window->Gadgets->IntervalGadget,
Globals->Window->SettingWindow, NULL,
@@ -463,6 +507,10 @@ void SetInterval(void)
void SetTimeout(void)
{
unsigned long value;
if (Globals->Window->Gadgets->TimeoutGadget == NULL)
return;
GT_GetGadgetAttrs(
Globals->Window->Gadgets->TimeoutGadget,
Globals->Window->SettingWindow, NULL,
@@ -494,6 +542,9 @@ void SetThreshold(void)
char *tempString;
int result;
if (Globals->Window->Gadgets->ThresholdGadget == NULL)
return;
GT_GetGadgetAttrs(
Globals->Window->Gadgets->ThresholdGadget,
Globals->Window->SettingWindow, NULL,
@@ -519,6 +570,10 @@ void SetThreshold(void)
void SetVerbose(void)
{
long value;
if (Globals->Window->Gadgets->VerboseGadget == NULL)
return;
GT_GetGadgetAttrs(
Globals->Window->Gadgets->VerboseGadget,
Globals->Window->SettingWindow, NULL,
@@ -550,6 +605,9 @@ void SetCxPriority(void)
char *tempString;
int result;
if (Globals->Window->Gadgets->PriorityGadget == NULL)
return;
GT_GetGadgetAttrs(
Globals->Window->Gadgets->PriorityGadget,
Globals->Window->SettingWindow, NULL,
@@ -634,53 +692,3 @@ void ShowLastSync(void)
GTTX_Text, (IPTR)label,
TAG_END);
}
void SetDefaultSettings(void)
{
static char priorityText[MAXLONGCHARSIZE];
static char thresholdText[MAXLONGLONGCHARSIZE];
GT_SetGadgetAttrs(
Globals->Window->Gadgets->ServerGadget,
Globals->Window->SettingWindow, NULL,
GTST_String, (IPTR)DefaultSettings.DestinationAddress,
TAG_END);
GT_SetGadgetAttrs(
Globals->Window->Gadgets->PortGadget,
Globals->Window->SettingWindow, NULL,
GTST_String, (IPTR)DefaultSettings.DestinationPort,
TAG_END);
GT_SetGadgetAttrs(
Globals->Window->Gadgets->TimeoutGadget,
Globals->Window->SettingWindow, NULL,
GTIN_Number, DefaultSettings.Timeout,
TAG_END);
GT_SetGadgetAttrs(
Globals->Window->Gadgets->IntervalGadget,
Globals->Window->SettingWindow, NULL,
GTIN_Number, DefaultSettings.Interval,
TAG_END);
LongLongToStr(DefaultSettings.Threshold, thresholdText);
GT_SetGadgetAttrs(
Globals->Window->Gadgets->ThresholdGadget,
Globals->Window->SettingWindow, NULL,
GTST_String, (IPTR)thresholdText,
TAG_END);
GT_SetGadgetAttrs(
Globals->Window->Gadgets->VerboseGadget,
Globals->Window->SettingWindow, NULL,
GTCY_Active, DefaultSettings.Verbose,
TAG_END);
LongToStr(DefaultSettings.Priority, priorityText);
GT_SetGadgetAttrs(
Globals->Window->Gadgets->PriorityGadget,
Globals->Window->SettingWindow, NULL,
GTST_String, (IPTR)priorityText,
TAG_END);
}
+1 -1
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2018 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without