Compare commits

..

110 Commits

Author SHA1 Message Date
ca502fd411 Remove schedule test buttons 2025-07-05 18:18:36 -07:00
c8a1128e11 Widen default help window size 2025-07-05 17:47:49 -07:00
b9a2202c68 Make version field full-width 2025-07-05 17:47:30 -07:00
671844723f Don't error if station doesn't have dir when deleted 2025-07-05 17:47:18 -07:00
7a0ce063f1 Add deletion of station schedule info when station is removed
Task scheduler entry for Windows, cron entry for *nix
2025-07-05 17:46:56 -07:00
62bfbb1923 Add log path to settings load error
Since they wouldn't be able to run the application to see the log path.

Also make no the default option
2025-07-05 17:44:49 -07:00
2992572651 Remove some unnecessary printlns 2025-07-05 13:47:51 -07:00
b25fea4549 Remove jitter todo from settings page 2025-06-08 12:28:57 -07:00
a45ffdd864 Remove todo on captureProcessOutput() 2025-06-07 21:44:42 -07:00
c918d98a3c Fix tab order 2025-06-07 21:20:55 -07:00
afb02dcb3d Add accessibility text for all fields 2025-06-07 20:50:49 -07:00
1c7069c737 Add linux schedule management functions 2025-05-29 00:45:41 -07:00
bf754c79d6 Update crontab call 2025-05-26 21:51:12 -07:00
d5e33d2a39 Add alert for unsupported OS 2025-05-26 21:51:11 -07:00
456348d520 Remove TODOs 2025-05-26 21:51:11 -07:00
769f80ec72 Remove testing statement 2025-05-26 21:41:42 -07:00
b6a6ec5e3a Add setting reinitialization if loading fails 2025-05-26 21:41:01 -07:00
392d10c587 Add git version to log and --version output 2025-05-25 23:37:01 -07:00
430b89bdda Remove some testing logs 2025-05-25 23:37:01 -07:00
2a7f9813a1 Fix log statement 2025-05-25 23:37:00 -07:00
553edc8b6c Add external program timeout as station setting
Leaving it without a UI implementation for now
2025-05-25 23:35:47 -07:00
645b1f2414 Fix bug when trying to remove station & none selected 2025-05-21 22:49:05 -07:00
306f169d08 Combine schedule start date/time fields into a single time-zoned field 2025-05-21 22:48:39 -07:00
4cd70e02c7 Set minimum dimensions for windows 2025-05-20 09:02:08 -07:00
44f5d51cb1 Add .gitignore 2025-05-19 20:08:48 -07:00
47d89cb32c Update overview image 2025-05-19 20:08:39 -07:00
961cdc897a Move divider between app controls and station controls 2025-05-19 20:08:29 -07:00
13ab7b82db Flesh out help 2025-05-19 19:28:55 -07:00
d138ea3ad6 Add about page 2025-05-19 19:28:34 -07:00
13355ce401 Factor out config path 2025-05-19 19:28:05 -07:00
e559508507 Change feed type to atom 2025-04-21 19:37:35 -07:00
e0a8a237a4 Fix some text alignment 2025-04-17 22:04:59 -07:00
8bd9e4c356 Add readme
Mostly project-tracking stuff right now
2025-04-17 21:33:50 -07:00
30456c7b7e Add UI mock-up
For posterity
2025-04-17 21:33:21 -07:00
a2fece0143 Add initial attempt at rss feed generation 2025-04-16 22:58:01 -07:00
897dcac243 Log station run complete 2025-04-15 22:41:29 -07:00
a7148e247c Implement external program call 2025-04-15 22:41:09 -07:00
c8aa18338a Down-size icon to 256x256 2025-04-15 21:24:05 -07:00
c55cfbef42 Fix Station Settings button anchor 2025-04-15 21:24:05 -07:00
183d9c9794 Implement next send time label 2025-04-15 21:24:05 -07:00
9f6d4171a5 Add icon to repo 2025-04-09 19:30:32 -07:00
3a1a6223bf Adjust GUI layout for linux rendering 2025-04-09 19:26:14 -07:00
ab48e726af Add basic help page
lsafej
2025-04-09 19:26:14 -07:00
af555112b2 Add icon to window 2025-03-23 15:50:04 -07:00
c480239636 Update schedulers to use process's executable path for invocation 2025-03-22 23:35:09 -07:00
670779a3aa Added check for argument parsing failure 2025-03-22 23:35:09 -07:00
947bccb6da Add missing MainRun.java 2025-03-10 22:55:13 -07:00
998357385e Minor WindowsScheduler updates 2025-03-10 22:54:56 -07:00
7e2d4ca1a4 Add Linux scheduler 2025-03-10 22:54:34 -07:00
0594a64812 Remove unused portions of pom.xml
They were different attempts to get it working, so might be useful to
reference in the future.
2025-03-09 15:18:14 -07:00
48790790b4 Add pom.xml and set up jar packaging
FXML loading needed to change when resources were packaged in jar.
2025-03-09 15:18:14 -07:00
81b347eb41 Rearrange main view so message box grows 2025-03-08 19:37:07 -08:00
49aa06fb03 Update launch path again 2025-03-05 22:46:29 -08:00
1347f313c7 Remove stray newline 2025-03-05 22:46:13 -08:00
dbba2d2285 Set up basic SFTP upload 2025-03-05 22:46:03 -08:00
d7852e281d Update launch path 2025-03-03 21:39:54 -08:00
8d1e910cc5 Delete scheduled task when schedule is managed externally 2025-03-03 21:39:36 -08:00
6c43289860 Add removal methods to WindowsScheduler and StationSettings 2025-03-03 21:10:07 -08:00
e74ddc99ca Use enter or esc to select station or cancel dialog 2025-02-24 20:56:24 -08:00
89181c0fa9 Fix wordpress connection test 2025-02-24 20:01:01 -08:00
705620d0a2 Handle unsaved changes in message editor
Window title shows asterisk of changes are unsaved.

Anything that would erase/overwrite message prompts a confirmation
dialog.
2025-02-23 14:24:39 -08:00
97c3cc3243 Show notification for error while running station 2025-02-22 19:29:10 -08:00
18b3e5d0d9 Fix argument quoting in run.sh 2025-02-22 19:21:22 -08:00
917be83ddc Change all buttons to use onAction
Covers more activation cases. I initially tried to use onAction, but
that didn't seem to work at the time, but I must've been mistaken.
2025-02-22 18:51:21 -08:00
12df6d97fa Load next message file to message buffer 2025-02-22 14:20:39 -08:00
e4ad5d16d6 Add split pane so user can adjust number of text columns 2025-02-20 22:57:47 -08:00
307620a930 Update layout to work on linux 2025-02-19 22:31:03 -08:00
5703d9bce4 Remove module path logging 2025-02-19 22:30:31 -08:00
edbbec1527 Reference stylesheet in fxml directly 2025-02-19 22:21:29 -08:00
9553c2a854 Add build/run scripts for linux 2025-02-19 22:21:29 -08:00
26fa5e34cd Move .fxml files to resources 2025-02-19 21:10:17 -08:00
7ba68c5ec1 Simplify lib path 2025-02-17 22:29:05 -08:00
6e86e660a7 Format settings file
See this answer https://stackoverflow.com/questions/22950542/pretty-printing-xml-with-jackson-library
2025-02-17 22:28:53 -08:00
15192e04e4 Exit application when notification dismissed 2025-02-17 21:55:52 -08:00
59625b773c Exit process when application closes 2025-02-17 21:55:40 -08:00
cb3f0b0938 Add notifications and some basic usage
Since I can't rely on platform specific notifications, I'll just have to open
a custom window that stays until dismissed.
2025-02-16 23:13:32 -08:00
3aea6f1281 Factor out argument parsing
and encapsulate the result in a class
2025-02-16 23:10:35 -08:00
8f5d5be291 Move build/run scripts to root 2025-02-09 18:08:03 -08:00
23f81b4b5c Anchor settings button to right 2025-02-09 18:08:03 -08:00
7cff7e7559 Reorder modules alphabetically 2025-02-08 17:50:10 -08:00
475808acd8 Move data directory when station is renamed 2025-02-08 17:28:52 -08:00
8af3162f46 Remove spurious test statements 2025-02-08 17:13:04 -08:00
00832e92bf Fix bug when selected station doesn't exist 2025-02-08 17:12:05 -08:00
741055b200 Add confirmation to station delete
And actually delete the station dir
2025-02-08 17:04:14 -08:00
fa0130b4b4 Add checks on station name when editing 2025-02-08 17:03:51 -08:00
53d6132ecd Add checks on station name when adding 2025-02-08 14:12:47 -08:00
c0028b2978 Add prefix-checking to message
We want to make sure the message doesn't match any of the station's listed prefixes.

Also, we give a finite number of tries to generate a valid message just in case prefixes somehow cover all messages.
Make it a setting so it can be increased if needed.
2025-02-08 12:38:55 -08:00
eb07e42ab0 Basic commandline invocation working 2025-02-04 20:25:34 -08:00
e2d9878e8e Set message textbox font style to mono 2025-02-04 20:25:34 -08:00
bbca33246a Get wordpress posting working via xml-rpc
whoops
2025-02-04 20:25:34 -08:00
fccec5faa6 Remove FTP/SCP and replace with Wordpress 2025-02-04 20:25:34 -08:00
ebf8a6b7c1 Add main settings button 2025-02-04 20:25:34 -08:00
e70be5c54c Remove some unused code 2025-02-04 20:25:34 -08:00
02b23c0e6d 'handleSettingsButtonPress' -> 'hanleStationSettingsButtonPress' 2025-02-04 20:25:34 -08:00
fa78b6ba45 Add default values for station settings 2025-02-04 20:25:34 -08:00
abac552971 Add catch for exception in start() 2025-02-04 20:25:34 -08:00
f7314290db Implement Set as next message button 2025-02-04 20:25:34 -08:00
a7169b49cc Add connecion test for SFTP 2025-02-04 20:25:34 -08:00
b563adea7b Add OS check to schedule registration 2025-02-04 20:25:34 -08:00
25aa91685f Add logging to StationSettingsController 2025-02-04 20:25:34 -08:00
792baa9d3a MainSettings(View|Controller) -> StationSettings(View|Controller)
We want to reserve those to be associated with the actual main settings (i.e. the overall settings rather than specific to one station)
2025-02-04 20:25:33 -08:00
b9d95acd04 Add period to Windows scheduled task 2025-02-04 20:25:33 -08:00
c7fb317e05 Fix bug in updateStationSettings 2025-02-04 20:25:33 -08:00
e5877c8a34 Get registering and running task scheduler task working 2025-02-04 20:25:33 -08:00
4defb7d3a0 Split build script into build and run
So run can be invoked by task manager as a stop-gap launch method
2025-02-04 20:25:33 -08:00
a68952653c Start implementing task scheduler 2025-02-04 20:25:33 -08:00
591d431226 Add argument parsing 2025-01-24 23:24:09 -08:00
5a3df459f9 Add logging 2025-01-20 22:38:01 -08:00
1ae75d4891 Implement station selection cancel button 2025-01-20 20:41:29 -08:00
0704a4a931 Use XDG_CONFIG_HOME 2025-01-20 20:13:44 -08:00
44 changed files with 4034 additions and 311 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
target/

20
build.ps1 Normal file
View File

@ -0,0 +1,20 @@
$Env:JAVA_HOME = "C:\Users\nathanm\Downloads\openjdk-23.0.1_windows-x64_bin\jdk-23.0.1"
$Env:PATH = "C:\Users\nathanm\Downloads\openjdk-23.0.1_windows-x64_bin\jdk-23.0.1\bin;$($Env:PATH)"
$Env:PATH_TO_FX="C:\Users\nathanm\Downloads\openjfx-23.0.1_windows-x64_bin-sdk\javafx-sdk-23.0.1\lib"
$modulePath = "$Env:PATH_TO_FX;$PSScriptRoot\lib"
$modules = $(
"com.ctc.wstx",
"com.fasterxml.jackson.annotation",
"com.fasterxml.jackson.core",
"com.fasterxml.jackson.dataformat.xml",
"com.fasterxml.jackson.datatype.jsr310",
"com.jcraft.jsch",
"javafx.controls",
"javafx.fxml",
"org.apache.commons.cli",
"result",
"wordpress.xmlrpc.client"
)
$addModules = $modules -join ","
javac --module-path $modulePath --add-modules $addModules src/main/java/name/nathanmcrae/numbersstation/*.java -d out
cp -Recurse src/main/resources/* out/name/nathanmcrae/numbersstation

10
build.sh Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env sh
JAVA_HOME=/home/nathanmcrae/Downloads/jdk-23.0.2/
PATH=$JAVA_HOME/bin:$PATH
PATH_TO_FX=/home/nathanmcrae/Downloads/javafx-sdk-23.0.2/lib/
MODULE_PATH=$PATH_TO_FX:$(dirname "$0")/lib
MODULES=com.ctc.wstx,com.fasterxml.jackson.annotation,com.fasterxml.jackson.core,com.fasterxml.jackson.dataformat.xml,com.fasterxml.jackson.datatype.jsr310,com.jcraft.jsch,javafx.controls,javafx.fxml,org.apache.commons.cli,result,wordpress.xmlrpc.client
javac --module-path $MODULE_PATH --add-modules $MODULES src/main/java/name/nathanmcrae/numbersstation/*.java -d out
cp -r src/main/resources/* out/name/nathanmcrae/numbersstation

BIN
icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

573
icon.svg Normal file
View File

@ -0,0 +1,573 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100mm"
height="100mm"
viewBox="0 0 120.61599 120.61599"
version="1.1"
id="svg5"
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
sodipodi:docname="icon.svg"
inkscape:export-filename="icon.png"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="0.38440305"
inkscape:cx="411.02692"
inkscape:cy="811.6481"
inkscape:window-width="1920"
inkscape:window-height="1017"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
showborder="false" />
<defs
id="defs2" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-7.9375088,-7.408341)">
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-2"
cx="193.98369"
cy="386.86728"
r="33.423893" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52182;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-3-1-2"
cx="193.98369"
cy="386.86728"
r="57.547085" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="rect8264"
width="191.3741"
height="176.11113"
x="-26.110645"
y="-15.779624" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197"
cx="50.340813"
cy="35.43071"
r="21.362293" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4"
cx="50.340813"
cy="35.43071"
r="33.423893" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52182;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-3"
cx="50.340813"
cy="35.43071"
r="45.485489" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52182;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-3-1"
cx="50.340813"
cy="35.43071"
r="57.547085" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-3-1-8"
cx="50.340813"
cy="35.43071"
r="69.608681" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1"
d="M 71.151636,105.72285 31.071711,90.879581 62.529625,75.226192 41.856598,60.164404"
id="path972" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="M 4.1202833,139.94932 3.6002366,31.429567 28.401163,69.024276 40.229105,35.873141 c 7.327309,-2.217798 12.340034,-1.841604 19.784483,-1.495272 l 5.95116,19.120364 8.848187,-3.99902 h 59.920415 l 0.27744,91.818087 z"
id="path245-8"
sodipodi:nodetypes="cccccccccc" />
<path
id="rect1543-9"
style="fill:#c5b57e;fill-opacity:1;stroke:#000000;stroke-width:2.98886;stroke-linecap:square;stroke-dasharray:none;stop-color:#000000"
d="m 71.602087,69.248079 48.036433,-4.241388 1.79134,4.241388 -24.376175,52.861551 H 47.22591 l -3.411052,-3.29058 z"
sodipodi:nodetypes="ccccccc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="M 22.1863,116.1851 50.949735,34.267295 74.802333,118.63562"
id="path245" />
<ellipse
style="fill:#000000;fill-opacity:1;stroke-width:2.98886;stroke-linecap:square;stroke-dasharray:none;stop-color:#000000;stroke:#000000;stroke-opacity:1"
id="path853"
cx="50.476528"
cy="35.456188"
rx="7.7170177"
ry="7.7016726" />
<path
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.5218;stroke-linecap:square;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path853-6"
sodipodi:type="arc"
sodipodi:cx="-193.72717"
sodipodi:cy="188.47533"
sodipodi:rx="35.968002"
sodipodi:ry="35.896484"
sodipodi:start="2.2123045"
sodipodi:end="0.46632985"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="m -215.25059,217.23538 a 35.968002,35.896484 0 0 1 -8.50092,-48.52563 35.968002,35.896484 0 0 1 48.04333,-11.3015 35.968002,35.896484 0 0 1 14.10851,47.20653" />
<path
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.5218;stroke-linecap:square;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path853-6-9"
sodipodi:type="arc"
sodipodi:cx="-192.98309"
sodipodi:cy="187.93011"
sodipodi:rx="23.261015"
sodipodi:ry="23.100607"
sodipodi:start="2.3033806"
sodipodi:end="0.71651673"
sodipodi:arc-type="arc"
d="m -208.5399,205.10423 a 23.261015,23.100607 0 0 1 -1.81963,-32.53144 23.261015,23.100607 0 0 1 32.74711,-1.98129 23.261015,23.100607 0 0 1 2.17041,32.51021"
sodipodi:open="true" />
<path
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.5218;stroke-linecap:square;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path853-6-5"
sodipodi:type="arc"
sodipodi:cx="-193.4792"
sodipodi:cy="190.24304"
sodipodi:rx="48.598015"
sodipodi:ry="48.614838"
sodipodi:start="4.1762494"
sodipodi:end="0.27695909"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="m -218.30409,148.44949 a 48.598015,48.614838 0 0 1 54.45995,3.26359 48.598015,48.614838 0 0 1 17.11095,51.82281" />
<path
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.5218;stroke-linecap:square;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path853-6-5-7"
sodipodi:type="arc"
sodipodi:cx="-188.99826"
sodipodi:cy="187.44801"
sodipodi:rx="58.32296"
sodipodi:ry="58.406055"
sodipodi:start="4.1762494"
sodipodi:end="0.27695909"
sodipodi:open="true"
sodipodi:arc-type="arc"
d="m -218.79086,137.23708 a 58.32296,58.406055 0 0 1 65.35793,3.92089 58.32296,58.406055 0 0 1 20.53502,62.26012" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="M 41.856598,60.802664 H 58.271362"
id="path1483" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="M 36.568017,75.226192 H 62.529625"
id="path1485" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="M 31.071711,90.879581 H 66.955147"
id="path1487" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1"
d="M 71.151636,105.72285 H 25.85986 L 66.955147,90.879581 36.568017,75.226194 58.271362,60.164404"
id="path1489" />
<rect
style="fill:#ffeba4;fill-opacity:1;stroke:#000000;stroke-width:3.13646;stroke-linecap:square;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="rect1543"
width="49.827774"
height="58.211109"
x="98.453468"
y="71.399696"
transform="matrix(1,0,-0.41875465,0.90809941,0,0)" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 61.248006,92.370426 38.105048,0.175037"
id="path1870-9"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 57.363875,100.05021 38.105042,0.17504"
id="path1870-2"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 53.479743,107.73002 38.105041,0.17503"
id="path1870-8"
sodipodi:nodetypes="cc" />
<path
id="path1597"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 70.450097,69.118849 c -2.302994,-1.054345 -3.617601,-4.211752 -3.040314,-7.302189 0.577288,-3.090435 2.85846,-5.10743 5.275707,-4.664735 2.417251,0.442694 4.18334,3.200902 4.084469,6.378954"
sodipodi:nodetypes="cssc" />
<path
id="path1597-5"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 77.277919,69.118849 c -2.302999,-1.054345 -3.617595,-4.211752 -3.040316,-7.302189 0.577289,-3.090435 2.858458,-5.10743 5.275706,-4.664735 2.417255,0.442694 4.183347,3.200902 4.084468,6.378954"
sodipodi:nodetypes="cssc" />
<path
id="path1597-5-7"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 84.105737,69.118849 c -2.302996,-1.054345 -3.617594,-4.211752 -3.040316,-7.302189 0.577291,-3.090435 2.858461,-5.10743 5.275712,-4.664735 2.417253,0.442694 4.183345,3.200902 4.084468,6.378954"
sodipodi:nodetypes="cssc" />
<path
id="path1597-3-3"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 90.933559,69.118849 c -2.302995,-1.054345 -3.617605,-4.211752 -3.040315,-7.302189 0.577289,-3.090435 2.858457,-5.10743 5.275709,-4.664735 2.417243,0.442694 4.183336,3.200902 4.084471,6.378954"
sodipodi:nodetypes="cssc" />
<path
id="path1597-5-7-1"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 97.761377,69.118849 c -2.302998,-1.054345 -3.617594,-4.211752 -3.040315,-7.302189 0.57729,-3.090435 2.858453,-5.10743 5.275708,-4.664735 2.41725,0.442694 4.18336,3.200902 4.08447,6.378954"
sodipodi:nodetypes="cssc" />
<path
id="path1597-3-3-8"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 104.5892,69.118849 c -2.30299,-1.054345 -3.6176,-4.211752 -3.04031,-7.302189 0.57728,-3.090435 2.85845,-5.10743 5.27571,-4.664735 2.41725,0.442694 4.18334,3.200902 4.08446,6.378954"
sodipodi:nodetypes="cssc" />
<path
id="path1597-5-7-1-0"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 111.41703,69.118849 c -2.30301,-1.054345 -3.6176,-4.211752 -3.04033,-7.302189 0.5773,-3.090435 2.85848,-5.10743 5.27572,-4.664735 2.41726,0.442694 4.18334,3.200902 4.08447,6.378954"
sodipodi:nodetypes="cssc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 69.016271,77.01084 38.105039,0.175038"
id="path1870"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="M 65.132138,84.690634 103.23718,84.86567"
id="path1870-4"
sodipodi:nodetypes="cc" />
<path
id="rect3438"
style="fill:#ffffff;stroke:none;stroke-width:2.73195;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stop-color:#000000;fill-opacity:1"
d="M -48.100937 -65.648699 L -48.100937 190.05156 L 193.48656 190.05156 L 193.48656 -65.648699 L -48.100937 -65.648699 z M 10.843335 9.8990494 L 125.82543 9.8990494 L 125.82543 125.29626 L 10.843335 125.29626 L 10.843335 9.8990494 z " />
<circle
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path5194"
cx="8.8180647"
cy="11.224082"
r="8.5120382" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="rect8264-5"
width="191.3741"
height="176.11113"
x="315.93002"
y="-26.572329" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-3-1-8-7-8"
cx="529.05237"
cy="19.290052"
r="69.608681" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-3-1-8-7-8-8"
cx="516.25659"
cy="19.290052"
r="69.608681" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-3-1-8-7-8-8-2"
cx="490.66495"
cy="19.290052"
r="69.608681" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-3-1-8-7-8-8-2-5"
cx="477.86914"
cy="19.290052"
r="69.608681" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-3-1-8-7-8-8-2-5-8"
cx="465.07333"
cy="19.290052"
r="69.608681" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-3-1-8-7-8-8-2-5-2"
cx="452.27753"
cy="19.290052"
r="69.608681" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-3-1-8-7-8-8-5"
cx="503.46075"
cy="19.290052"
r="69.608681" />
<path
id="rect12036"
style="fill:#ffffff;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stop-color:#000000"
d="m 382.76068,49.026981 h 22.7733 l -0.20405,-10.212154 h 67.24742 v 68.976853 h -89.81667 z"
sodipodi:nodetypes="ccccccc" />
<g
id="g13446"
transform="translate(-23.615614,-1.9147788)">
<rect
style="fill:#dddddd;fill-opacity:1;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="rect12307"
width="56.649075"
height="47.843525"
x="382.56964"
y="59.053787" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="M 394.42489,59.201904 V 20.27731"
id="path12465"
sodipodi:nodetypes="cc" />
<ellipse
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:2.98886;stroke-linecap:square;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path853-4"
cx="394.31458"
cy="20.402958"
rx="4.62993"
ry="4.6197276" />
<rect
style="fill:#3f9000;fill-opacity:1;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="rect12489"
width="45.595596"
height="8.2185192"
x="388.32666"
y="66.685265" />
<circle
style="fill:#909090;fill-opacity:1;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path13427"
cx="396.65854"
cy="90.753792"
r="7.6314826" />
</g>
<g
id="g13462"
transform="translate(3.1912979)">
<path
id="rect1543-9-5"
style="fill:#c5b57e;fill-opacity:1;stroke:#000000;stroke-width:2.98886;stroke-linecap:square;stroke-dasharray:none;stop-color:#000000"
d="m 413.64274,58.455374 48.03643,-4.24139 1.79134,4.24139 -24.37618,52.861546 h -49.82777 l -3.41105,-3.29058 z"
sodipodi:nodetypes="ccccccc" />
<rect
style="fill:#ffeba4;fill-opacity:1;stroke:#000000;stroke-width:3.13646;stroke-linecap:square;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="rect1543-7"
width="49.827774"
height="58.211109"
x="435.51724"
y="59.514755"
transform="matrix(1,0,-0.41875465,0.90809941,0,0)" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 403.28866,81.577724 38.10504,0.17503"
id="path1870-9-2"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 399.40453,89.257504 38.10504,0.17504"
id="path1870-2-0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 395.52039,96.937314 38.10504,0.17503"
id="path1870-8-7"
sodipodi:nodetypes="cc" />
<path
id="path1597-59"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 412.49075,58.326144 c -2.303,-1.05435 -3.6176,-4.21175 -3.04032,-7.30219 0.57729,-3.09044 2.85846,-5.10743 5.27571,-4.66474 2.41725,0.4427 4.18334,3.20091 4.08447,6.37896"
sodipodi:nodetypes="cssc" />
<path
id="path1597-5-9"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 419.31857,58.326144 c -2.303,-1.05435 -3.6176,-4.21175 -3.04032,-7.30219 0.57729,-3.09044 2.85846,-5.10743 5.27571,-4.66474 2.41725,0.4427 4.18335,3.20091 4.08447,6.37896"
sodipodi:nodetypes="cssc" />
<path
id="path1597-5-7-7"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 426.14639,58.326144 c -2.303,-1.05435 -3.6176,-4.21175 -3.04032,-7.30219 0.57729,-3.09044 2.85846,-5.10743 5.27571,-4.66474 2.41726,0.4427 4.18335,3.20091 4.08447,6.37896"
sodipodi:nodetypes="cssc" />
<path
id="path1597-3-3-2"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 432.97421,58.326144 c -2.303,-1.05435 -3.61761,-4.21175 -3.04032,-7.30219 0.57729,-3.09044 2.85846,-5.10743 5.27571,-4.66474 2.41725,0.4427 4.18334,3.20091 4.08447,6.37896"
sodipodi:nodetypes="cssc" />
<path
id="path1597-5-7-1-7"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 439.80203,58.326144 c -2.303,-1.05435 -3.6176,-4.21175 -3.04032,-7.30219 0.57729,-3.09044 2.85846,-5.10743 5.27571,-4.66474 2.41725,0.4427 4.18336,3.20091 4.08447,6.37896"
sodipodi:nodetypes="cssc" />
<path
id="path1597-3-3-8-4"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 446.62985,58.326144 c -2.30299,-1.05435 -3.6176,-4.21175 -3.04031,-7.30219 0.57728,-3.09044 2.85845,-5.10743 5.27571,-4.66474 2.41725,0.4427 4.18334,3.20091 4.08446,6.37896"
sodipodi:nodetypes="cssc" />
<path
id="path1597-5-7-1-0-5"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 453.45768,58.326144 c -2.30301,-1.05435 -3.6176,-4.21175 -3.04033,-7.30219 0.5773,-3.09044 2.85848,-5.10743 5.27572,-4.66474 2.41726,0.4427 4.18334,3.20091 4.08447,6.37896"
sodipodi:nodetypes="cssc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 411.05692,66.218134 38.10504,0.17504"
id="path1870-80"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 407.17279,73.897924 38.10504,0.17504"
id="path1870-4-5"
sodipodi:nodetypes="cc" />
</g>
<path
id="rect3438-0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2.73195;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stop-color:#000000"
d="M 293.93971,-76.441405 V 179.25885 h 241.5875 V -76.441405 Z m 58.94428,75.54774851 H 467.86608 V 114.50355 H 352.88399 Z" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:5.5218;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="rect8264-9"
width="198.01566"
height="196.86601"
x="97.607521"
y="298.29813" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-5"
cx="193.98369"
cy="386.86728"
r="21.362293" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52182;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-3-2"
cx="193.98369"
cy="386.86728"
r="45.485489" />
<circle
style="fill:none;fill-opacity:1;stroke:#4f9ade;stroke-width:5.52181;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path4197-4-3-1-8-3"
cx="193.98369"
cy="386.86728"
r="69.608681" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1"
d="m 214.79451,457.15943 -40.07993,-14.84327 31.45791,-15.65339 -20.67302,-15.06179"
id="path972-9" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 147.76315,491.3859 24.28088,-70.92504 11.82794,-33.15114 c 7.32731,-2.2178 12.34004,-1.8416 19.78449,-1.49527 l 5.95116,19.12036 8.84818,-3.99902 h 59.92042 l 0.27744,91.81809 z"
id="path245-8-5"
sodipodi:nodetypes="ccccccccc" />
<path
id="rect1543-9-1"
style="fill:#c5b57e;fill-opacity:1;stroke:#000000;stroke-width:2.98886;stroke-linecap:square;stroke-dasharray:none;stop-color:#000000"
d="m 215.24496,420.68466 48.03643,-4.24139 1.79134,4.24139 -24.37618,52.86155 h -49.82777 l -3.41105,-3.29058 z"
sodipodi:nodetypes="ccccccc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 165.82917,467.62168 28.76343,-81.91781 23.8526,84.36833"
id="path245-1" />
<ellipse
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:2.98886;stroke-linecap:square;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="path853-3"
cx="194.1194"
cy="386.89276"
rx="7.7170177"
ry="7.7016726" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 185.49947,412.23924 h 16.41476"
id="path1483-1" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 180.21089,426.66277 h 25.9616"
id="path1485-3" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 174.71458,442.31616 h 35.88344"
id="path1487-5" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1"
d="m 214.79451,457.15943 h -45.29178 l 41.09529,-14.84327 -30.38713,-15.65339 21.70334,-15.06179"
id="path1489-2" />
<rect
style="fill:#ffeba4;fill-opacity:1;stroke:#000000;stroke-width:3.13646;stroke-linecap:square;stroke-dasharray:none;stroke-opacity:1;stop-color:#000000"
id="rect1543-2"
width="49.827774"
height="58.211109"
x="404.15536"
y="458.40201"
transform="matrix(1,0,-0.41875465,0.90809941,0,0)" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 204.89088,443.80701 38.10504,0.17503"
id="path1870-9-8"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 201.00674,451.48679 38.10505,0.17504"
id="path1870-2-1"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 197.12261,459.1666 38.10504,0.17503"
id="path1870-8-0"
sodipodi:nodetypes="cc" />
<path
id="path1597-9"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 214.09297,420.55543 c -2.303,-1.05435 -3.6176,-4.21175 -3.04032,-7.30219 0.57729,-3.09044 2.85846,-5.10743 5.27571,-4.66474 2.41725,0.4427 4.18334,3.20091 4.08447,6.37896"
sodipodi:nodetypes="cssc" />
<path
id="path1597-5-5"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 220.92079,420.55543 c -2.303,-1.05435 -3.6176,-4.21175 -3.04032,-7.30219 0.57729,-3.09044 2.85846,-5.10743 5.27571,-4.66474 2.41725,0.4427 4.18335,3.20091 4.08447,6.37896"
sodipodi:nodetypes="cssc" />
<path
id="path1597-5-7-79"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 227.74861,420.55543 c -2.303,-1.05435 -3.6176,-4.21175 -3.04032,-7.30219 0.57729,-3.09044 2.85846,-5.10743 5.27571,-4.66474 2.41726,0.4427 4.18335,3.20091 4.08447,6.37896"
sodipodi:nodetypes="cssc" />
<path
id="path1597-3-3-7"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 234.57643,420.55543 c -2.303,-1.05435 -3.61761,-4.21175 -3.04032,-7.30219 0.57729,-3.09044 2.85846,-5.10743 5.27571,-4.66474 2.41725,0.4427 4.18334,3.20091 4.08447,6.37896"
sodipodi:nodetypes="cssc" />
<path
id="path1597-5-7-1-5"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 241.40425,420.55543 c -2.303,-1.05435 -3.6176,-4.21175 -3.04032,-7.30219 0.57729,-3.09044 2.85845,-5.10743 5.27571,-4.66474 2.41725,0.4427 4.18336,3.20091 4.08447,6.37896"
sodipodi:nodetypes="cssc" />
<path
id="path1597-3-3-8-7"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 248.23207,420.55543 c -2.30299,-1.05435 -3.6176,-4.21175 -3.04031,-7.30219 0.57728,-3.09044 2.85845,-5.10743 5.27571,-4.66474 2.41725,0.4427 4.18334,3.20091 4.08446,6.37896"
sodipodi:nodetypes="cssc" />
<path
id="path1597-5-7-1-0-57"
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:round;stroke-dasharray:none;stop-color:#000000"
d="m 255.0599,420.55543 c -2.30301,-1.05435 -3.6176,-4.21175 -3.04033,-7.30219 0.5773,-3.09044 2.85848,-5.10743 5.27572,-4.66474 2.41726,0.4427 4.18334,3.20091 4.08447,6.37896"
sodipodi:nodetypes="cssc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 212.65914,428.44742 38.10504,0.17504"
id="path1870-5"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:2.98886;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 208.77501,436.12721 38.10504,0.17504"
id="path1870-4-7"
sodipodi:nodetypes="cc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 31 KiB

397
mockup.drawio Normal file
View File

@ -0,0 +1,397 @@
<mxfile host="Electron" modified="2025-01-11T07:22:18.441Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/22.0.3 Chrome/114.0.5735.289 Electron/25.8.4 Safari/537.36" etag="-S0tjDxWuqk8ykO7LYgZ" version="22.0.3" type="device" pages="4">
<diagram id="KgfOMPHdpzIXCQJiCugH" name="number-station">
<mxGraphModel dx="1407" dy="818" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="400" pageHeight="400" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="KV5Y_ph4G12SrxRSiY-e-1" value="Select Station" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="175" y="10" width="95" height="30" as="geometry" />
</mxCell>
<mxCell id="2tEYRVNANGzc1R6FI9Mg-2" value="My Station" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="70" y="10" width="95" height="30" as="geometry" />
</mxCell>
<mxCell id="2tEYRVNANGzc1R6FI9Mg-3" value="Station:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="10" y="15" width="60" height="20" as="geometry" />
</mxCell>
<mxCell id="2tEYRVNANGzc1R6FI9Mg-5" value="" style="endArrow=none;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="10" y="50" as="sourcePoint" />
<mxPoint x="390" y="50" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="aKKJJGnMUioiqIyPZD_M-1" value="0000 0000 0000 0000&lt;br style=&quot;font-size: 27px;&quot;&gt;0000 0000 0000 0000&lt;br style=&quot;font-size: 27px;&quot;&gt;0000 0000 0000 0000&lt;br style=&quot;font-size: 27px;&quot;&gt;0000 0000 0000 0000&lt;br style=&quot;font-size: 27px;&quot;&gt;0000 0000 0000 0000" style="rounded=0;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fontSize=27;" parent="1" vertex="1">
<mxGeometry x="10" y="100" width="380" height="250" as="geometry" />
</mxCell>
<mxCell id="OoXu6EN54UF7In_Oly40-1" value="⚙" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="360" y="59" width="30" height="30" as="geometry" />
</mxCell>
<mxCell id="fAEDDr1aK9oPJae2LnTb-1" value="Set as next message" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="270" y="360" width="120" height="30" as="geometry" />
</mxCell>
<mxCell id="F0W2USit5zVsF5LBhS4k-1" value="Next run time: 2024-12-24T14:17:28" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="10" y="59" width="220" height="30" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
<diagram id="k80YQdDor6Hn9XSC-wS4" name="number-station-config">
<mxGraphModel dx="366" dy="658" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="400" pageHeight="400" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="qGrX5IwpEfruhJfUPI0G-1" value="Select Station" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="175" y="10" width="95" height="30" as="geometry" />
</mxCell>
<mxCell id="m5zdCg8UaHyb6ajvu_Qv-2" value="My Station" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="70" y="10" width="95" height="30" as="geometry" />
</mxCell>
<mxCell id="m5zdCg8UaHyb6ajvu_Qv-3" value="Station:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="10" y="15" width="60" height="20" as="geometry" />
</mxCell>
<mxCell id="m5zdCg8UaHyb6ajvu_Qv-5" value="" style="endArrow=none;html=1;rounded=0;" parent="1" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="10" y="50" as="sourcePoint" />
<mxPoint x="390" y="50" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="b2T8TMgS7kride2Pq7S0-1" value="Digit group size:&lt;br&gt;(only for display)" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="10" y="70" width="100" height="20" as="geometry" />
</mxCell>
<mxCell id="b2T8TMgS7kride2Pq7S0-2" value="4" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="110" y="65" width="30" height="30" as="geometry" />
</mxCell>
<mxCell id="b2T8TMgS7kride2Pq7S0-3" value="⬆" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="150" y="65" width="20" height="15" as="geometry" />
</mxCell>
<mxCell id="b2T8TMgS7kride2Pq7S0-4" value="⬇" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="150" y="80" width="20" height="15" as="geometry" />
</mxCell>
<mxCell id="O_Ejp8n0P8FWgRvxlbZu-1" value="Save" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="760" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="-kJYHnf-wgmOerafxR5x-1" value="Number station address:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="140" y="160" width="145" height="30" as="geometry" />
</mxCell>
<mxCell id="-kJYHnf-wgmOerafxR5x-2" value="https://my-number-station.com/blog.html" style="rounded=0;whiteSpace=wrap;html=1;align=left;" parent="1" vertex="1">
<mxGeometry x="150" y="190" width="241.25" height="30" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-1" value="Send messages via:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="10" y="160" width="120" height="30" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-2" value="FTP" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="50" y="190" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-3" value="SFTP" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="50" y="220" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-4" value="SCP" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="50" y="250" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-5" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;labelBackgroundColor=none;fillColor=#000000;" parent="1" vertex="1">
<mxGeometry x="30" y="200" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-6" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="30" y="230" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-7" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="30" y="260" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-8" value="Username:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="218.75" y="230" width="67.5" height="30" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-9" value="Password:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="218.75" y="260" width="67.5" height="30" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-10" value="user" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="296.25" y="235" width="95" height="20" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-11" value="pass" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="296.25" y="265" width="95" height="20" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-12" value="Message length:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="190" y="70" width="100" height="20" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-13" value="80" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="290" y="65" width="30" height="30" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-14" value="⬆" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="65" width="20" height="15" as="geometry" />
</mxCell>
<mxCell id="qLbXf6SKdaKwf-JNIX5Q-15" value="⬇" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="80" width="20" height="15" as="geometry" />
</mxCell>
<mxCell id="LwcL28te8jDykbwldkZH-1" value="Prefixes:&lt;br&gt;(dummy messages won&#39;t be sent with these prefixes)" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="20" y="350" width="290" height="50" as="geometry" />
</mxCell>
<mxCell id="LwcL28te8jDykbwldkZH-2" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="20" y="395" width="260" height="170" as="geometry" />
</mxCell>
<mxCell id="LwcL28te8jDykbwldkZH-3" value="9293 8500" style="rounded=0;whiteSpace=wrap;html=1;align=left;" parent="1" vertex="1">
<mxGeometry x="30" y="405" width="240" height="30" as="geometry" />
</mxCell>
<mxCell id="LwcL28te8jDykbwldkZH-4" value="0032 9381" style="rounded=0;whiteSpace=wrap;html=1;align=left;" parent="1" vertex="1">
<mxGeometry x="30" y="435" width="240" height="30" as="geometry" />
</mxCell>
<mxCell id="LwcL28te8jDykbwldkZH-5" value="..." style="rounded=0;whiteSpace=wrap;html=1;align=left;" parent="1" vertex="1">
<mxGeometry x="30" y="465" width="240" height="30" as="geometry" />
</mxCell>
<mxCell id="LwcL28te8jDykbwldkZH-6" value="+" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="240" y="525" width="30" height="30" as="geometry" />
</mxCell>
<mxCell id="LwcL28te8jDykbwldkZH-7" value="-" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="240" y="405" width="30" height="30" as="geometry" />
</mxCell>
<mxCell id="LwcL28te8jDykbwldkZH-8" value="-" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="240" y="435" width="30" height="30" as="geometry" />
</mxCell>
<mxCell id="enA9nok_1hsDVz6vXJ0Y-1" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="10" y="580" width="380" height="150" as="geometry" />
</mxCell>
<mxCell id="enA9nok_1hsDVz6vXJ0Y-2" value="Schedule:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="10" y="580" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="enA9nok_1hsDVz6vXJ0Y-3" value="" style="whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="20" y="610" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="enA9nok_1hsDVz6vXJ0Y-4" value="Manage schedule externally" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="30" y="600" width="160" height="30" as="geometry" />
</mxCell>
<mxCell id="enA9nok_1hsDVz6vXJ0Y-5" value="Daily" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="50" y="630" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="enA9nok_1hsDVz6vXJ0Y-6" value="Weekly" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="50" y="660" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="enA9nok_1hsDVz6vXJ0Y-7" value="Monthly" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="50" y="690" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="enA9nok_1hsDVz6vXJ0Y-8" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;labelBackgroundColor=none;fillColor=#000000;" parent="1" vertex="1">
<mxGeometry x="30" y="640" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="enA9nok_1hsDVz6vXJ0Y-9" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="30" y="670" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="enA9nok_1hsDVz6vXJ0Y-10" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="30" y="700" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="enA9nok_1hsDVz6vXJ0Y-11" value="Start date:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="120" y="630" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="enA9nok_1hsDVz6vXJ0Y-12" value="2024-12-25 08:10:36" style="rounded=0;whiteSpace=wrap;html=1;align=left;" parent="1" vertex="1">
<mxGeometry x="120" y="660" width="170" height="30" as="geometry" />
</mxCell>
<mxCell id="enA9nok_1hsDVz6vXJ0Y-13" value="✍" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="300" y="660" width="30" height="30" as="geometry" />
</mxCell>
<mxCell id="yshJ9rjgNk4pQpEHdTG9-1" value="External program" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="50" y="280" width="100" height="30" as="geometry" />
</mxCell>
<mxCell id="yshJ9rjgNk4pQpEHdTG9-2" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="30" y="290" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="yshJ9rjgNk4pQpEHdTG9-4" value="program-to-execute" style="rounded=0;whiteSpace=wrap;html=1;align=left;" parent="1" vertex="1">
<mxGeometry x="50" y="310" width="340" height="30" as="geometry" />
</mxCell>
<mxCell id="lrg_OsaujHVCrS9Fx4xL-1" value="Groups in line:&lt;br&gt;(only for display)" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="10" y="115" width="100" height="20" as="geometry" />
</mxCell>
<mxCell id="lrg_OsaujHVCrS9Fx4xL-2" value="4" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="110" y="110" width="30" height="30" as="geometry" />
</mxCell>
<mxCell id="lrg_OsaujHVCrS9Fx4xL-3" value="⬆" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="150" y="110" width="20" height="15" as="geometry" />
</mxCell>
<mxCell id="lrg_OsaujHVCrS9Fx4xL-4" value="⬇" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="150" y="125" width="20" height="15" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
<diagram name="listener" id="lENoe73DJEgTFmveM3ib">
<mxGraphModel dx="1235" dy="723" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="400" pageHeight="400" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="SujNhtosm1HRNQAcBG4O-1" value="Select Station" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="175" y="10" width="95" height="30" as="geometry" />
</mxCell>
<mxCell id="wbM6wd7tqMI0IAmKtTY0-1" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="10" y="119" width="380" height="270" as="geometry" />
</mxCell>
<mxCell id="wbM6wd7tqMI0IAmKtTY0-2" value="9293 8500 &lt;font color=&quot;#9c9c9c&quot;&gt;1823 2298 2301&lt;/font&gt;" style="rounded=0;whiteSpace=wrap;html=1;align=left;" vertex="1" parent="1">
<mxGeometry x="20" y="129" width="360" height="30" as="geometry" />
</mxCell>
<mxCell id="wbM6wd7tqMI0IAmKtTY0-3" value="..." style="rounded=0;whiteSpace=wrap;html=1;align=left;" vertex="1" parent="1">
<mxGeometry x="20" y="159" width="360" height="30" as="geometry" />
</mxCell>
<mxCell id="wbM6wd7tqMI0IAmKtTY0-4" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="20" y="189" width="360" height="30" as="geometry" />
</mxCell>
<mxCell id="wbM6wd7tqMI0IAmKtTY0-5" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="20" y="219" width="360" height="30" as="geometry" />
</mxCell>
<mxCell id="wbM6wd7tqMI0IAmKtTY0-6" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="20" y="249" width="360" height="30" as="geometry" />
</mxCell>
<mxCell id="wbM6wd7tqMI0IAmKtTY0-7" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="20" y="279" width="360" height="30" as="geometry" />
</mxCell>
<mxCell id="wbM6wd7tqMI0IAmKtTY0-8" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="20" y="309" width="360" height="30" as="geometry" />
</mxCell>
<mxCell id="wbM6wd7tqMI0IAmKtTY0-9" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="20" y="339" width="360" height="30" as="geometry" />
</mxCell>
<mxCell id="wbM6wd7tqMI0IAmKtTY0-10" value="Retrieve Now" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="230" y="59" width="100" height="30" as="geometry" />
</mxCell>
<mxCell id="wbM6wd7tqMI0IAmKtTY0-17" value="My Station" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="70" y="10" width="95" height="30" as="geometry" />
</mxCell>
<mxCell id="4qhGAahRBXyE9qeNDtCE-1" value="Last retrieved: 2024-12-24T14:17:28" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="10" y="59" width="220" height="30" as="geometry" />
</mxCell>
<mxCell id="4qhGAahRBXyE9qeNDtCE-2" value="Messages:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="10" y="89" width="80" height="30" as="geometry" />
</mxCell>
<mxCell id="4qhGAahRBXyE9qeNDtCE-3" value="Station:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="10" y="15" width="60" height="20" as="geometry" />
</mxCell>
<mxCell id="gv7KOfe7MxGHTGDHY-RI-1" value="⚙" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="360" y="59" width="30" height="30" as="geometry" />
</mxCell>
<mxCell id="gv7KOfe7MxGHTGDHY-RI-2" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="10" y="50" as="sourcePoint" />
<mxPoint x="390" y="50" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="v50buFrmnss8UQ5S-Iks-1" value="2024-12-24" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="300" y="129" width="80" height="30" as="geometry" />
</mxCell>
<mxCell id="v50buFrmnss8UQ5S-Iks-2" value="2024-12-23" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="300" y="159" width="80" height="30" as="geometry" />
</mxCell>
<mxCell id="v50buFrmnss8UQ5S-Iks-3" value="2024-12-22" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="300" y="189" width="80" height="30" as="geometry" />
</mxCell>
<mxCell id="v50buFrmnss8UQ5S-Iks-4" value="2024-12-21" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="300" y="219" width="80" height="30" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
<diagram id="E8TrwcYXImFw0jUs4Aw0" name="listener-config">
<mxGraphModel dx="811" dy="475" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="400" pageHeight="400" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="rOGrzmU35Bv_lXtv-dQQ-1" value="Prefixes:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="20" y="220" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="rOGrzmU35Bv_lXtv-dQQ-2" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="10" y="250" width="260" height="170" as="geometry" />
</mxCell>
<mxCell id="rOGrzmU35Bv_lXtv-dQQ-3" value="9293 8500" style="rounded=0;whiteSpace=wrap;html=1;align=left;" vertex="1" parent="1">
<mxGeometry x="20" y="260" width="240" height="30" as="geometry" />
</mxCell>
<mxCell id="rOGrzmU35Bv_lXtv-dQQ-4" value="0032 9381" style="rounded=0;whiteSpace=wrap;html=1;align=left;" vertex="1" parent="1">
<mxGeometry x="20" y="290" width="240" height="30" as="geometry" />
</mxCell>
<mxCell id="rOGrzmU35Bv_lXtv-dQQ-5" value="..." style="rounded=0;whiteSpace=wrap;html=1;align=left;" vertex="1" parent="1">
<mxGeometry x="20" y="320" width="240" height="30" as="geometry" />
</mxCell>
<mxCell id="rOGrzmU35Bv_lXtv-dQQ-7" value="https://my-number-station.com/blog.html" style="rounded=0;whiteSpace=wrap;html=1;align=left;" vertex="1" parent="1">
<mxGeometry x="30" y="120" width="350" height="30" as="geometry" />
</mxCell>
<mxCell id="dexWjz7qNybDygiiIq_V-1" value="My Station" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="70" y="10" width="95" height="30" as="geometry" />
</mxCell>
<mxCell id="dexWjz7qNybDygiiIq_V-2" value="Station:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="10" y="15" width="60" height="20" as="geometry" />
</mxCell>
<mxCell id="dexWjz7qNybDygiiIq_V-3" value="Select Station" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="175" y="10" width="95" height="30" as="geometry" />
</mxCell>
<mxCell id="Gh-GtSVz8Y2JwdWB56_--1" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="10" y="50" as="sourcePoint" />
<mxPoint x="390" y="50" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="6y2arMDsUTsDNsxs1FtR-2" value="+" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="230" y="380" width="30" height="30" as="geometry" />
</mxCell>
<mxCell id="6y2arMDsUTsDNsxs1FtR-3" value="-" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="230" y="260" width="30" height="30" as="geometry" />
</mxCell>
<mxCell id="6y2arMDsUTsDNsxs1FtR-4" value="-" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="230" y="290" width="30" height="30" as="geometry" />
</mxCell>
<mxCell id="6y2arMDsUTsDNsxs1FtR-5" value="Save" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="330" y="760" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="skUOlehON0tLIMdoaJ7T-1" value="Retrieve messages from:" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="10" y="60" width="180" height="30" as="geometry" />
</mxCell>
<mxCell id="skUOlehON0tLIMdoaJ7T-2" value="Website" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="30" y="86" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="skUOlehON0tLIMdoaJ7T-3" value="External program" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="30" y="160" width="100" height="30" as="geometry" />
</mxCell>
<mxCell id="skUOlehON0tLIMdoaJ7T-4" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;labelBackgroundColor=none;fillColor=#000000;" vertex="1" parent="1">
<mxGeometry x="10" y="96" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="skUOlehON0tLIMdoaJ7T-5" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="10" y="170" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="skUOlehON0tLIMdoaJ7T-6" value="program-to-execute" style="rounded=0;whiteSpace=wrap;html=1;align=left;" vertex="1" parent="1">
<mxGeometry x="30" y="190" width="350" height="30" as="geometry" />
</mxCell>
<mxCell id="skUOlehON0tLIMdoaJ7T-7" value="?" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="130" y="165" width="20" height="20" as="geometry" />
</mxCell>
<mxCell id="6MllUsjUtkag9fbClZZq-1" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="10" y="430" width="380" height="150" as="geometry" />
</mxCell>
<mxCell id="6MllUsjUtkag9fbClZZq-2" value="Schedule:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="10" y="430" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="6MllUsjUtkag9fbClZZq-3" value="" style="whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="20" y="460" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="6MllUsjUtkag9fbClZZq-4" value="Manage schedule externally" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="30" y="450" width="160" height="30" as="geometry" />
</mxCell>
<mxCell id="6MllUsjUtkag9fbClZZq-5" value="Daily" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="50" y="480" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="6MllUsjUtkag9fbClZZq-6" value="Weekly" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="50" y="510" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="6MllUsjUtkag9fbClZZq-7" value="Monthly" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="50" y="540" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="6MllUsjUtkag9fbClZZq-8" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;labelBackgroundColor=none;fillColor=#000000;" vertex="1" parent="1">
<mxGeometry x="30" y="490" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="6MllUsjUtkag9fbClZZq-9" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="30" y="520" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="6MllUsjUtkag9fbClZZq-10" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="30" y="550" width="10" height="10" as="geometry" />
</mxCell>
<mxCell id="6MllUsjUtkag9fbClZZq-11" value="Start date:" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="120" y="480" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="6MllUsjUtkag9fbClZZq-12" value="2024-12-25 08:10:36" style="rounded=0;whiteSpace=wrap;html=1;align=left;" vertex="1" parent="1">
<mxGeometry x="120" y="510" width="170" height="30" as="geometry" />
</mxCell>
<mxCell id="6MllUsjUtkag9fbClZZq-13" value="✍" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="300" y="510" width="30" height="30" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

150
pom.xml Normal file
View File

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>name.nathanmcrae</groupId>
<artifactId>numbersstation</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>23</maven.compiler.source>
<maven.compiler.target>23</maven.compiler.target>
<javafx.version>23.0.2</javafx.version>
</properties>
<repositories>
<repository>
<id>my-local-repo</id>
<url>file://${project.basedir}/mvn-repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.fasterxml.woodstox</groupId>
<artifactId>woodstox-core</artifactId>
<version>7.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.18.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.18.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.18.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.18.2</version>
</dependency>
<dependency>
<groupId>com.github.mwiede</groupId>
<artifactId>jsch</artifactId>
<version>0.2.23</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>wordpress</groupId>
<artifactId>xmlrpc-client</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>com.tearsofaunicorn.wordpress</groupId>
<artifactId>wordpress-xmlrpc-client</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xmlrpc-common</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>com.leakyabstractions</groupId>
<artifactId>result</artifactId>
<version>1.0.0.0</version>
</dependency>
<dependency>
<groupId>com.rometools</groupId>
<artifactId>rome</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>name.nathanmcrae.numbersstation.MainRun</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>9.0.1</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<commitIdGenerationMode>full</commitIdGenerationMode>
</configuration>
</plugin>
</plugins>
</build>
</project>

144
readme.txt Normal file
View File

@ -0,0 +1,144 @@
For sending secret messages and dummy messages regularly. It is meant to be used in conjunction with one-time pads. One-time pads provide perfect security for the message itself (if they are handled properly), but adversaries can still tell that messages are being sent, and when they are being sent. To avoid this, dummy messages are uploaded to a website on a regular basis. The messages can also be hidden using steganography.
This application should not be considered secure, and no sensitive information should be entered into it.
Baseline is that the number station will generate a dummy random message, optionally obscure it via steganography, then upload it to an (s)ftp/scp server.
The random message generation actually happens last, so that, next time it is run, the existing message will be uploaded. This way a real message can be generated in the meantime and the next upload time the real message will be uploaded. Because the real message looks random to anyone without the corresponding one-time pad, it cannot be distinguished from the dummy messages.
# Number Station Listener
This application periodically checks a site for numbers and stores them so the user can check whether the message matches any pads.
# Notes
Should have sane defaults, but be built to be part of a more extensible system. Should be able to run other commands for message generation / upload.
Need to be able to support multiple profiles for each.
## Tech
- Installers: JPackage
- Notifications: https://github.com/sshtools/two-slices/blob/master/README.md
- Post to wordpress: https://github.com/ashri/java-wordpress-api/tree/master
## Security considerations
If someone were to take any part of the number station (this software, the server, or intercepting on the way to the recipient), then they could make sure no messages get through (though they couldn't spoof messages without access to the one-time pads).
This weakness is true of nearly all communication methods though. The only way to be certain a message was received is to receive an acknowledgement back.
# Settings/State Format
$XDG_CONFIG_HOME/numbers-station/main-settings.xml
$XDG_CONFIG_HOME/numbers-station/listener-settings.xml
$XDG_STATE_HOME/numbers-station/main.log
$XDG_STATE_HOME/numbers-station/listener.log
$XDG_STATE_HOME/numbers-station/<station-id>-main/next-message.txt
$XDG_STATE_HOME/numbers-station/<station-id>-main/20250114T091633.txt
$XDG_STATE_HOME/numbers-station/<station-id>-listener/20250114T091735.txt
$XDG_STATE_HOME/numbers-station/<station-id>-listener/20250114T091748-read.txt
XDG dirs:
https://superuser.com/a/1767882
On Windows:
https://stackoverflow.com/questions/43853548/xdg-basedir-directories-for-windows
Library to use:
https://github.com/dirs-dev/directories-jvm
# TODO
- [ ] Undo/Redo in message editing
- [ ] Disable/commandeer right-click menu items for message text (otherwise you can wreck the formatting).
- [ ] Make sure numpad works in message editing
And in prefix editing
- [x] Catch and log all exceptions
- [ ] Add a check that the way we set up the scheduler to run the application will actually work. (need a flag argument that will output something particular we can look for).
- [x] Be able to narrow message area so that columns can match whatever message format you're using (minimum window width would keep you from doing that).
- [x] When station is removed/renamed, need to also remove/rename the scheduled task and the corresponding state directory.
- [x] Check for duplicate station names when creating or renaming
- [ ] Test task scheduler task creation for a windows user not on a domain (author needs to include domain when on domain e.g. EI\nathanm)
- [x] Station names with quotes shouldn't be allowed (or we'll need to do escaping for the launch command)
- [ ] Need to be able to handle case where application is open and the scheduled task runs. There's at least contention for the log file (maybe? doesn't seem to mind if multiple instances of the application are running)
- [ ] In all controllers, error handling should be 1. log error 2. Pop up dialog to warn user
- [x] Settings external schedule management should remove the scheduled task
- [ ] Add tests for generateMessage()
- [x] Load message from next-message
- [x] When making changes to the message, show the changes as unsaved until saved.
- [ ] Ensure all GUI elements have accessibility text
- [ ] Embed versioning info
- [ ] Factor out scheduling into a wrapper class that handles all the os-specific stuff internally.
- [ ] If a station name is run which doesn't exist in settings, but has associated files, then prompt the user to delete the files.
- [ ] Fix behavior when settings file is empty
- [ ] Store schedule time with time zone
- [ ] Add tests for StationSettings.nextSendTime()
Note on jars and javafx: https://stackoverflow.com/a/23121897
# 2025-01-27 JAR packaging
```
$modulePath = "$Env:PATH_TO_FX;P:\personal_root\projects\number-station\lib"
$modules = $(
"com.fasterxml.jackson.annotation",
"com.fasterxml.jackson.core",
"com.fasterxml.jackson.dataformat.xml",
"com.fasterxml.jackson.datatype.jsr310",
"result",
"javafx.controls",
"javafx.fxml",
"org.apache.commons.cli"
)
$addModules = $modules -join ","
java/>jar --create --file numbers-station.jar --manifest .\manifest.txt -C out .
java/>java --module-path $modulePath --add-modules $addModules -jar .\numbers-station.jar
```
TODO: package lib jars with this jar
also:
```
jpackage --input . --name numbers-station --main-jar .\numbers-station.jar --main-class name.nathanmcrae.numbersstation.Main --module-path "$Env:PATH_TO_FX;P:\personal_root\projects\number-station\lib" --add-modules javafx.controls,javafx.fxml,com.fasterxml.jackson.annotation,com.fasterxml.jackson.core,com.fasterxml.jackson.dataformat.xml,com.fasterxml.jackson.datatype.jsr310 --type exe
```
# 2025-02-16
Tried to compile a jfx hello world using the openjdk and openjfx packaged in guix, but ran into issues. It looks like more up-to-date versions of openjfx are not available guix.
Might be the next best step is to depend on a binary release of openjfx and see if I can compile on linux like that. Could even have a custom guix package which depends on the openjfx binary release if needed.
# 2025-03-03
Tried some more packaging, but was getting a lot of "Error: automatic module cannot be used with jlink" issues. Not sure if I just wasn't getting those before or what, but the jpackage command above doesn't work now.
The issue seems to be with having non-modular dependencies. This page has some notes at the bottom about packaging non-modular applications: https://openjfx.io/openjfx-docs/#modular
# 2025-03-09
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=lib/wordpress-xmlrpc-client-1.1-SNAPSHOT.jar -DgroupId=com.tearsofaunicorn.wordpress -DartifactId=wordpress-xmlrpc-client -Dversion=1.1 -Dpackaging=jar -DlocalRepositoryPath=mvn-repo
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=lib/xmlrpc-client-3.1.3.jar -DgroupId=wordpress -DartifactId=xmlrpc-client -Dversion=3.1.3 -Dpackaging=jar -DlocalRepositoryPath=mvn-repo
# 2025-03-17
Appears to work. Launch is extremely slow
jpackage --input . --name numbers-station --main-jar .\target\numbersstation-1.0-SNAPSHOT.jar --main-class name.nathanmcrae.numbersstation.MainRun --type app-image --dest $HOME/temp/20250316T153044
Failed to generate msi this time :(
numbers-station/>jpackage --input . --name numbers-station --main-jar .\target\numbersstation-1.0-SNAPSHOT.jar --main-class name.nathanmcrae.numbersstation.MainRun --type exe --dest $HOME/temp/20250317T200941
java.io.IOException: Command [C:\Program Files (x86)\WiX Toolset v3.11\bin\candle.exe, -nologo, C:\Users\nathanm\AppData\Local\Temp\jdk.jpackage911481192111528806\config\bundle.wxf, -ext, WixUtilExtension, -arch, x64, -out, C:\Users\nathanm\AppData\Local\Temp\jdk.jpackage911481192111528806\wixobj\bundle.wixobj] in C:\Users\nathanm\AppData\Local\Temp\jdk.jpackage911481192111528806\images\win-msi.image\numbers-station exited with 1 code
# 2025-03-22
Did a clean clone and build and it worked.
jpackage --input . --name numbers-station --main-jar .\target\numbersstation-1.0-SNAPSHOT.jar --main-class name.nathanmcrae.numbersstation.MainRun --type exe --win-menu --win-per-user-install --win-shortcut --win-shortcut-prompt --win-upgrade-uuid 956c711b-01f1-46a2-9355-4a6b63ec1ec9 --icon "P:\personal_root\projects\numbers-station\icon.ico" --description "Tool to periodically upload encrypted messages to a website/blog"
---
2025-03-22T20:50:38.212-07:00 INFO name.nathanmcrae.numbersstation.Main main Executable Path: C:\Users\nathanm\AppData\Local\numbers-station\numbers-station.exe

21
run.ps1 Normal file
View File

@ -0,0 +1,21 @@
cd $PSScriptRoot
$Env:JAVA_HOME = "C:\Users\nathanm\Downloads\openjdk-23.0.1_windows-x64_bin\jdk-23.0.1"
$Env:PATH = "C:\Users\nathanm\Downloads\openjdk-23.0.1_windows-x64_bin\jdk-23.0.1\bin;$($Env:PATH)"
$Env:PATH_TO_FX="C:\Users\nathanm\Downloads\openjfx-23.0.1_windows-x64_bin-sdk\javafx-sdk-23.0.1\lib"
$modulePath = "$Env:PATH_TO_FX;$PSScriptRoot\lib"
$modules = $(
"com.ctc.wstx",
"com.fasterxml.jackson.annotation",
"com.fasterxml.jackson.core",
"com.fasterxml.jackson.dataformat.xml",
"com.fasterxml.jackson.datatype.jsr310",
"com.jcraft.jsch",
"javafx.controls",
"javafx.fxml",
"org.apache.commons.cli",
"result",
"wordpress.xmlrpc.client",
"xmlrpc.common"
)
$addModules = $modules -join ","
java --module-path $modulePath --add-modules $addModules -cp out name.nathanmcrae.numbersstation.Main @args

9
run.sh Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env sh
JAVA_HOME=/home/nathanmcrae/Downloads/jdk-23.0.2/
PATH=$JAVA_HOME/bin:$PATH
PATH_TO_FX=/home/nathanmcrae/Downloads/javafx-sdk-23.0.2/lib/
MODULE_PATH=$PATH_TO_FX:$(dirname "$0")/lib
MODULES=com.ctc.wstx,com.fasterxml.jackson.annotation,com.fasterxml.jackson.core,com.fasterxml.jackson.dataformat.xml,com.fasterxml.jackson.datatype.jsr310,com.jcraft.jsch,javafx.controls,javafx.fxml,org.apache.commons.cli,result,wordpress.xmlrpc.client
java --module-path $MODULE_PATH --add-modules $MODULES -cp out name.nathanmcrae.numbersstation.Main "$@"

View File

@ -1,6 +0,0 @@
$Env:JAVA_HOME = "C:\Users\nathanm\Downloads\openjdk-23.0.1_windows-x64_bin\jdk-23.0.1"
$Env:PATH = "C:\Users\nathanm\Downloads\openjdk-23.0.1_windows-x64_bin\jdk-23.0.1\bin;$($Env:PATH)"
$Env:PATH_TO_FX="C:\Users\nathanm\Downloads\openjfx-23.0.1_windows-x64_bin-sdk\javafx-sdk-23.0.1\lib"
javac --module-path "$Env:PATH_TO_FX;P:\personal_root\projects\number-station\lib" --add-modules javafx.controls,javafx.fxml,com.fasterxml.jackson.annotation,com.fasterxml.jackson.core,com.fasterxml.jackson.dataformat.xml,com.fasterxml.jackson.datatype.jsr310 .\name\nathanmcrae\numbersstation\*.java -d out
cp name/nathanmcrae/numbersstation/*.fxml out/name/nathanmcrae/numbersstation
java --module-path "$Env:PATH_TO_FX;P:\personal_root\projects\number-station\lib" --add-modules javafx.controls,javafx.fxml,com.fasterxml.jackson.annotation,com.fasterxml.jackson.core,com.fasterxml.jackson.dataformat.xml,com.fasterxml.jackson.datatype.jsr310 -cp out name.nathanmcrae.numbersstation.Main

View File

@ -0,0 +1,71 @@
package name.nathanmcrae.numbersstation;
import java.awt.datatransfer.StringSelection;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.Properties;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.TextField;
public class AboutController {
private static final Logger logger = Logger.getLogger(Main.class.getName());
@FXML
private TextField directoryTextField;
@FXML
private TextField executableTextField;
@FXML
private TextField homepageURLTextField;
@FXML
private TextField logPathTextField;
@FXML
private TextField versionTextField;
@FXML
private void initialize() {
directoryTextField.setText(Main.getConfigPath().toString());
String processName = ManagementFactory.getRuntimeMXBean().getName();
long pid = Long.parseLong(processName.split("@")[0]);
ProcessHandle currentProcess = ProcessHandle.of(pid).orElseThrow();
Path executablePath = currentProcess.info().command().map(Paths::get).orElseThrow();
executableTextField.setText(executablePath.toString());
Properties properties = new Properties();
try {
properties.load(getClass().getClassLoader().getResourceAsStream("git.properties"));
} catch (IOException e) {
logger.log(Level.SEVERE, "Failed to load git information", e);
}
versionTextField.setText(String.valueOf(properties.get("git.commit.id.full")));
homepageURLTextField.setText("https://git.nathanmcrae.name/nathanmcrae/numbers-station");
logPathTextField.setText(Main.getStatePath().resolve("main.log").toString());
}
public void handleAppExecutableButtonPress() {
}
public void handleConfigDirectoryButtonPress() {
}
public void handleLogFilePathButtonPress() {
}
}

View File

@ -20,14 +20,14 @@
private Button cancelButton; private Button cancelButton;
private int digitsPerGroup; private int digitsPerGroup;
private MainSettingsController mainSettingsController; private StationSettingsController stationSettingsController;
public void setDigitsPerGroup(int newDigitsPerGroup) { public void setDigitsPerGroup(int newDigitsPerGroup) {
digitsPerGroup = newDigitsPerGroup; digitsPerGroup = newDigitsPerGroup;
} }
public void setMainSettingsController(MainSettingsController mainSettingsController) { public void setStationSettingsController(StationSettingsController stationSettingsController) {
this.mainSettingsController = mainSettingsController; this.stationSettingsController = stationSettingsController;
} }
@FXML @FXML
@ -129,7 +129,7 @@
private void handleOkButtonPress() { private void handleOkButtonPress() {
String prefix = prefixField.getText(); String prefix = prefixField.getText();
if (prefix != null && !prefix.isEmpty()) { if (prefix != null && !prefix.isEmpty()) {
mainSettingsController.addPrefix(prefix.replaceAll(" ", "")); stationSettingsController.addPrefix(prefix.replaceAll(" ", ""));
closeWindow(); closeWindow();
} }
} }

View File

@ -0,0 +1,34 @@
package name.nathanmcrae.numbersstation;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
public class CustomFormatter extends Formatter {
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
@Override
public String format(LogRecord record) {
String timestamp = dateFormat.format(new Date(record.getMillis()));
String logLevel = record.getLevel().getName();
String className = record.getSourceClassName();
String methodName = record.getSourceMethodName();
String message = formatMessage(record);
StringBuilder logMessage = new StringBuilder();
logMessage.append(String.format("%s\t%s\t%s\t%s\t%s", timestamp, logLevel, className, methodName, message));
if (record.getThrown() != null) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
record.getThrown().printStackTrace(pw);
logMessage.append("\n\t").append(sw.toString());
}
logMessage.append(System.lineSeparator());
return logMessage.toString();
}
}

View File

@ -0,0 +1,19 @@
package name.nathanmcrae.numbersstation;
import java.util.logging.Logger;
import javafx.fxml.FXML;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class HelpController {
private static final Logger logger = Logger.getLogger(Main.class.getName());
@FXML
WebView webView;
@FXML
public void initialize() throws Exception {
String url = HelpController.class.getResource("/help-index.html").toExternalForm();
webView.getEngine().load(url);
}
}

View File

@ -0,0 +1,246 @@
package name.nathanmcrae.numbersstation;
import com.leakyabstractions.result.api.Result;
import com.leakyabstractions.result.core.Results;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.lang.management.ManagementFactory;
import java.lang.ProcessHandle;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javafx.util.Pair;
public class LinuxScheduler {
private static final Logger logger = Logger.getLogger(Main.class.getName());
public static Result<Boolean, String> registerSchedule(StationSettings settings) {
try {
String taskName = "numbers-station-main_" + settings.getName();
Process listProcess = new ProcessBuilder("crontab", "-l").start();
if (!listProcess.waitFor(5, TimeUnit.SECONDS)) {
String message = "Failed to query " + taskName + " task: process timed out";
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
Pair<String, String> output = WindowsScheduler.captureProcessOutput(listProcess);
if(listProcess.exitValue() != 0) {
String message = "Failed to get user id. Exit code: " + listProcess.exitValue() + ". stdout: " + output.getKey() + "\n\tstderr: " + output.getValue();
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
String currentCrontab = output.getKey();
String cronEntry = "# " + taskName + "\n" + cronExpression(settings) + "\n\n";
Pattern pattern = Pattern.compile("# " + taskName + "\\n[^\\n]+\\n\\n");
Matcher matcher = pattern.matcher(currentCrontab);
StringBuilder sb = new StringBuilder();
if (matcher.find()) {
matcher.appendReplacement(sb, cronEntry);
boolean foundMultiple = false;
while (matcher.find()) {
foundMultiple = true;
matcher.appendReplacement(sb, "");
}
if (foundMultiple) {
logger.log(Level.WARNING, "Found multiple instances of '" + taskName + "' prior to replacement");
}
matcher.appendTail(sb);
} else {
sb.append(currentCrontab);
sb.append(cronEntry);
}
String newCrontab = sb.toString();
Process addProcess = new ProcessBuilder("crontab", "-").start();
Writer w = new OutputStreamWriter(addProcess.getOutputStream(), "UTF-8");
System.out.println(newCrontab);
w.write(newCrontab);
w.flush();
w.close();
if (!addProcess.waitFor(5, TimeUnit.SECONDS)) {
String message = "Failed to register " + taskName + " task: process timed out";
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
if(addProcess.exitValue() != 0) {
Pair<String, String> addOutput = WindowsScheduler.captureProcessOutput(addProcess);
String message = "Failed to get user id. Exit code: " + addProcess.exitValue() + ". stdout: " + addOutput.getKey() + ". stderr: " + addOutput.getValue();
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
} catch (CronExpressionException | IOException | InterruptedException e) {
String message = "Exception while registering schedule";
logger.log(Level.SEVERE, message, e);
return Results.failure(message);
}
return Results.success(true);
}
public static Result<Boolean, String> scheduleExists(StationSettings settings) {
try {
String taskName = "numbers-station-main_" + settings.getName();
Process listProcess = new ProcessBuilder("crontab", "-l").start();
if (!listProcess.waitFor(5, TimeUnit.SECONDS)) {
String message = "Failed to query " + taskName + " task: process timed out";
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
Pair<String, String> output = WindowsScheduler.captureProcessOutput(listProcess);
if(listProcess.exitValue() != 0) {
String message = "Failed to get user id. Exit code: " + listProcess.exitValue() + ". stdout: " + output.getKey() + "\n\tstderr: " + output.getValue();
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
String currentCrontab = output.getKey();
String cronEntry = "# " + taskName + "\n" + cronExpression(settings) + "\n\n";
Pattern pattern = Pattern.compile("# " + taskName + "\\n[^\\n]+\\n\\n");
Matcher matcher = pattern.matcher(currentCrontab);
if (matcher.find()) {
return Results.success(true);
} else {
return Results.success(true);
}
} catch (CronExpressionException | IOException | InterruptedException e) {
String message = "Exception while checking for schedule";
logger.log(Level.SEVERE, message, e);
return Results.failure(message);
}
}
public static Result<Boolean, String> removeSchedule(StationSettings settings) {
try {
String taskName = "numbers-station-main_" + settings.getName();
Process listProcess = new ProcessBuilder("crontab", "-l").start();
if (!listProcess.waitFor(5, TimeUnit.SECONDS)) {
String message = "Failed to query " + taskName + " task: process timed out";
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
Pair<String, String> output = WindowsScheduler.captureProcessOutput(listProcess);
if(listProcess.exitValue() != 0) {
String message = "Failed to get user id. Exit code: " + listProcess.exitValue() + ". stdout: " + output.getKey() + "\n\tstderr: " + output.getValue();
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
String currentCrontab = output.getKey();
String cronEntry = "# " + taskName + "\n" + cronExpression(settings) + "\n\n";
Pattern pattern = Pattern.compile("# " + taskName + "\\n[^\\n]+\\n\\n");
Matcher matcher = pattern.matcher(currentCrontab);
StringBuilder sb = new StringBuilder();
while (matcher.find()) {
matcher.appendReplacement(sb, "");
}
String newCrontab = sb.toString();
Process addProcess = new ProcessBuilder("crontab", "-").start();
Writer w = new OutputStreamWriter(addProcess.getOutputStream(), "UTF-8");
System.out.println(newCrontab);
w.write(newCrontab);
w.flush();
w.close();
if (!addProcess.waitFor(5, TimeUnit.SECONDS)) {
String message = "Failed to register " + taskName + " task: process timed out";
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
if(addProcess.exitValue() != 0) {
Pair<String, String> addOutput = WindowsScheduler.captureProcessOutput(addProcess);
String message = "Failed to get user id. Exit code: " + addProcess.exitValue() + ". stdout: " + addOutput.getKey() + ". stderr: " + addOutput.getValue();
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
} catch (CronExpressionException | IOException | InterruptedException e) {
String message = "Exception while removing schedule";
logger.log(Level.SEVERE, message, e);
return Results.failure(message);
}
return Results.success(true);
}
/**
* * * * * * {command to execute}
* | | | | |
* | | | | day of the week (06) (Sunday to Saturday;
* | | | month (112) 7 is also Sunday on some systems)
* | | day of the month (131)
* | hour (023)
* minute (059)
*/
public static String cronExpression(StationSettings settings) throws CronExpressionException {
LocalDateTime scheduleDateTime = settings.getScheduleStart().withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime();
String minute = Integer.toString(scheduleDateTime.getMinute());
String hour = Integer.toString(scheduleDateTime.getHour());
String dayOfMonth = Integer.toString(scheduleDateTime.getDayOfMonth());
String dayOfWeek = Integer.toString(scheduleDateTime.getDayOfMonth());
String scheduleString = "";
switch(settings.getMessagePeriod()) {
case DAILY:
scheduleString = minute + " " + hour + " * * *";
break;
case WEEKLY:
scheduleString = minute + " " + hour + " * * " + dayOfWeek;
break;
case MONTHLY:
scheduleString = minute + " " + hour + " " + dayOfMonth + " * *";
break;
default:
throw new CronExpressionException("Message period not implemented: '" + settings.getMessagePeriod() + "'");
}
String processName = ManagementFactory.getRuntimeMXBean().getName();
long pid = Long.parseLong(processName.split("@")[0]);
ProcessHandle currentProcess = ProcessHandle.of(pid).orElseThrow();
Path executablePath = currentProcess.info().command().map(Paths::get).orElseThrow();
logger.info("Executable Path: " + executablePath);
return scheduleString + " " + executablePath.toString() + " --station \"" + settings.getName() + "\"";
}
public static class CronExpressionException extends Exception {
public CronExpressionException(String message) {
super(message);
}
}
}

View File

@ -1,21 +1,385 @@
package name.nathanmcrae.numbersstation; package name.nathanmcrae.numbersstation;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.SftpException;
import com.leakyabstractions.result.api.Result;
import com.leakyabstractions.result.core.Results;
import com.rometools.rome.feed.synd.SyndContent;
import com.rometools.rome.feed.synd.SyndContentImpl;
import com.rometools.rome.feed.synd.SyndEntry;
import com.rometools.rome.feed.synd.SyndEntryImpl;
import com.rometools.rome.feed.synd.SyndFeed;
import com.rometools.rome.feed.synd.SyndFeedImpl;
import com.rometools.rome.io.SyndFeedInput;
import com.rometools.rome.io.SyndFeedOutput;
import com.tearsofaunicorn.wordpress.api.model.Post;
import com.tearsofaunicorn.wordpress.api.WordpressClient;
import java.io.IOException;
import java.io.File;
import java.io.Writer;
import java.io.FileWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.ZoneOffset;
import java.util.concurrent.TimeUnit;
import java.util.Date;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.Optional;
import java.util.Properties;
import javafx.application.Application; import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.image.Image;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.util.Pair;
import org.apache.commons.cli.*;
public class Main extends Application { public class Main extends Application {
public record StartParameters (Optional<NotificationController.NotificationParameters> notification) {}
private static final Logger logger = Logger.getLogger(Main.class.getName());
private static Path configPath = null;
private static Path statePath = null;
public static Path getConfigPath() {
if (configPath == null) {
String configHome = System.getenv("XDG_CONFIG_HOME");
if (configHome != null && !configHome.isEmpty() && Paths.get(configHome).isAbsolute()) {
configPath = Paths.get(configHome, "numbers-station");
} else {
String userHome = System.getProperty("user.home");
configPath = Paths.get(userHome, ".config", "numbers-station");
}
}
return configPath;
}
public static Path getStatePath() {
if (statePath == null) {
String stateHome = System.getenv("XDG_STATE_HOME");
if (stateHome == null || stateHome.isEmpty() || !Paths.get(stateHome).isAbsolute()) {
String userHome = System.getProperty("user.home");
statePath = Paths.get(userHome, ".local", "state", "numbers-station");
} else {
statePath = Paths.get(stateHome, "numbers-station");
}
}
return statePath;
}
private static StartParameters startParams = new StartParameters(Optional.empty());
@Override @Override
public void start(Stage primaryStage) throws Exception { public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("MainView.fxml")); primaryStage.setOnCloseRequest(e -> {
Platform.exit();
});
try {
if (startParams.notification().isPresent()){
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/NotificationView.fxml"));
Parent root = fxmlLoader.load();
NotificationController controller = fxmlLoader.getController();
controller.setNotification(startParams.notification().get());
primaryStage.setMinWidth(350);
primaryStage.setMinHeight(200);
primaryStage.setTitle("Numbers Station"); primaryStage.setTitle("Numbers Station");
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/icon.png")));
primaryStage.setScene(new Scene(root)); primaryStage.setScene(new Scene(root));
primaryStage.show(); primaryStage.show();
} else {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/MainView.fxml"));
Parent root = fxmlLoader.load();
MainController controller = fxmlLoader.getController();
primaryStage.setMinWidth(480);
primaryStage.setMinHeight(200);
primaryStage.setOnCloseRequest(e -> {
if (!controller.handleCloseRequest()) {
e.consume();
} else {
Platform.exit();
}
});
primaryStage.setTitle("Numbers Station");
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/icon.png")));
primaryStage.setScene(new Scene(root));
primaryStage.titleProperty().bindBidirectional(controller.windowTitle);
primaryStage.show();
logger.info("Application started");
Properties properties = new Properties();
try {
properties.load(getClass().getClassLoader().getResourceAsStream("git.properties"));
logger.info("Application version: " + String.valueOf(properties.get("git.commit.id.full")));
} catch (IOException e) {
logger.log(Level.SEVERE, "Failed to load git information", e);
}
}
} catch (IOException e) {
logger.log(Level.SEVERE, "Failed to load main view", e);
}
}
private static void setupLogger() {
try {
Path logFile = getStatePath().resolve("main.log");
if (!Files.exists(logFile.getParent())) {
Files.createDirectories(logFile.getParent());
}
FileHandler fileHandler = new FileHandler(logFile.toString(), true);
fileHandler.setFormatter(new CustomFormatter());
logger.addHandler(fileHandler);
} catch (IOException e) {
System.out.println("Failed to set up logger: " + e.getMessage());
}
} }
public static void main(String[] args) { public static void main(String[] args) {
MainParsedArguments parsedArgs = new MainParsedArguments(args);
if (parsedArgs.getParseException() != null) {
logger.log(Level.SEVERE, "Failed when parsing arguments", parsedArgs.getParseException());
parsedArgs.printHelp();
System.exit(0);
}
if (parsedArgs.getHelpFlag()) {
parsedArgs.printHelp();
System.exit(0);
}
if (parsedArgs.getVersionFlag()) {
Properties properties = new Properties();
try {
properties.load(Main.class.getClassLoader().getResourceAsStream("git.properties"));
System.out.println(String.valueOf(properties.get("git.commit.id.full")));
} catch (IOException e) {
System.out.println("Failed to get git information");
}
System.exit(0);
}
Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
logger.log(Level.SEVERE, "Unhandled exception caught", throwable);
});
Platform.setImplicitExit(false);
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> {
logger.log(Level.SEVERE, "Unhandled exception in JavaFX application thread", throwable);
});
setupLogger();
if (parsedArgs.getStationName() != null) {
try {
runStation(parsedArgs);
} catch (StationRunException e) {
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
String message = "Attempted to run station '" +
parsedArgs.getStationName() +
"' at " +
LocalDateTime.now().format(dateFormatter) +
"\n\n" +
e.getMessage();
var notification = new NotificationController.NotificationParameters("Error running station '" + parsedArgs.getStationName() + "'",
message,
NotificationController.NotificationType.ERROR,
Optional.empty());
startParams = new StartParameters(Optional.of(notification));
launch(args);
System.exit(1);
}
} else {
launch(args); launch(args);
} }
}
public static class StationRunException extends Exception {
public StationRunException(String message) {
super(message);
}
public StationRunException(Throwable cause) {
super(cause);
}
public StationRunException(String message, Throwable cause) {
super(message, cause);
}
}
public static void runStation(MainParsedArguments parsedArgs) throws StationRunException {
if (parsedArgs.getStationName() == null || parsedArgs.getStationName() == "") {
String message = "Station name must be provided and not empty";
logger.log(Level.SEVERE, message);
throw new StationRunException(message);
}
Result<MainSettings, Exception> result = MainSettings.load();
if (!result.hasSuccess()) {
String message = "Unable to load settings";
logger.log(Level.SEVERE, message);
throw new StationRunException(message);
}
MainSettings settings = result.getSuccess().get();
StationSettings loadedStation = settings.getStations().stream()
.filter(station -> station.getName().equals(parsedArgs.getStationName()))
.findFirst()
.orElse(null);
if (loadedStation == null) {
String message = "Unable to find station '" + parsedArgs.getStationName() + "'";
logger.log(Level.SEVERE, message);
throw new StationRunException(message);
}
logger.info("Loaded station " + parsedArgs.getStationName());
Path stationDirPath = loadedStation.stationPath();
try {
boolean generateMessage = false;
if (!Files.exists(stationDirPath)) {
Files.createDirectories(stationDirPath);
}
Path nextMessagePath = stationDirPath.resolve("next-message.txt");
String messageText;
if (!Files.exists(nextMessagePath)) {
messageText = loadedStation.generateMessage(settings.getMessageGenerationAttempts());
} else {
messageText = new String(Files.readAllBytes(nextMessagePath));
}
switch (loadedStation.getMessageMethod()) {
case StationSettings.MessageMethod.EXTERNAL_PROGRAM:
Process process = new ProcessBuilder(loadedStation.getExternalProgramCommand(), nextMessagePath.toString()).start();
if (!process.waitFor(loadedStation.getExternalProgramTimeout().getSeconds(), TimeUnit.SECONDS)) {
throw new StationRunException("Timeout while running external program " + loadedStation.getExternalProgramCommand());
}
Pair<String, String> output = WindowsScheduler.captureProcessOutput(process);
if(process.exitValue() != 0) {
String message = "External program non-zero exit code. Exit code: " + process.exitValue() + ". stdout: " + output.getKey() + "\n\tstderr: " + output.getValue();
logger.log(Level.SEVERE, message);
throw new StationRunException(message);
}
break;
case StationSettings.MessageMethod.SFTP:
//loadedStation.uploadNextMessageToSFTP();
Path rssPath = stationDirPath.resolve("feed.xml");
SyndFeed feed;
if (Files.exists(rssPath)) {
SyndFeedInput input = new SyndFeedInput();
feed = input.build(new File(rssPath.toString()));
} else {
feed = new SyndFeedImpl();
feed.setFeedType("atom_1.0");
feed.setTitle("Blog");
feed.setLink(loadedStation.getAddress());
feed.setDescription("Sample blog");
}
SyndEntry entry = new SyndEntryImpl();
String timestamp = ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT);
entry.setTitle(timestamp);
entry.setLink(loadedStation.getAddress());
SyndContent description = new SyndContentImpl();
description.setType("text/html");
description.setValue(messageText);
entry.setDescription(description);
feed.getEntries().add(entry);
feed.setPublishedDate(new Date());
Writer writer = new FileWriter(rssPath.toString());
SyndFeedOutput syndFeedOutput = new SyndFeedOutput();
syndFeedOutput.output(feed, writer);
writer.close();
JSch jsch = new JSch();
try {
Session session = jsch.getSession(loadedStation.getUsername(), loadedStation.getAddress(), 22);
session.setPassword(loadedStation.getPassword());
session.setConfig("StrictHostKeyChecking", "no");
session.connect(30000); // 30 seconds timeout
if (session.isConnected()) {
ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");
channel.connect();
String localFile = loadedStation.nextMessagePath().toString();
channel.put(localFile, "www/message.txt");
channel.put(rssPath.toString(), "www/feed.xml");
channel.exit();
session.disconnect();
} else {
logger.log(Level.SEVERE, "SFTP connection failed");
}
} catch (JSchException e) {
logger.log(Level.SEVERE, "SFTP connection failed", e);
}
break;
case StationSettings.MessageMethod.WORDPRESS:
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String dateStr = dateFormat.format(new Date());
System.setProperty("wordpress.username", loadedStation.getUsername());
System.setProperty("wordpress.password", loadedStation.getPassword());
System.setProperty("wordpress.url", loadedStation.getAddress());
Post post = new Post(dateStr, messageText);
WordpressClient client = new WordpressClient();
String newPostId = client.newPost(post);
break;
default:
String message = "Message method " + loadedStation.getMessageMethod() + " not supported";
logger.log(Level.SEVERE, message);
throw new StationRunException(message);
}
String newMessageText = loadedStation.generateMessage(settings.getMessageGenerationAttempts());
Files.write(nextMessagePath, newMessageText.getBytes(StandardCharsets.UTF_8));
} catch (Exception e) {
String message = "Exception while posting message to station " + parsedArgs.getStationName();
logger.log(Level.SEVERE, message, e);
throw new StationRunException(message);
}
logger.info("Completed station run");
System.exit(0);
}
} }

View File

@ -1,43 +1,64 @@
package name.nathanmcrae.numbersstation; package name.nathanmcrae.numbersstation;
import com.fasterxml.jackson.databind.ObjectMapper; import com.leakyabstractions.result.api.Result;
import com.fasterxml.jackson.databind.json.JsonMapper; import com.leakyabstractions.result.core.Results;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.Optional;
import java.util.Random; import java.util.Random;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.TextArea; import javafx.scene.control.TextArea;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.input.KeyEvent; import javafx.scene.input.KeyEvent;
import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCode;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.SplitPane;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
public class MainController implements Initializable { public class MainController implements Initializable {
private static final Logger logger = Logger.getLogger(Main.class.getName());
private Stage aboutStage;
private Stage helpStage;
private Stage settingsStage; private Stage settingsStage;
private Stage selectStationStage; private Stage selectStationStage;
private MainSettings settings; private MainSettings settings;
private StationSettings selectedStation; private StationSettings selectedStation;
private StringProperty nextSendTime = new SimpleStringProperty();
private StringProperty selectedStationName = new SimpleStringProperty(); private StringProperty selectedStationName = new SimpleStringProperty();
private SimpleBooleanProperty unsavedChanges = new SimpleBooleanProperty();
public StringProperty windowTitle = new SimpleStringProperty("Numbers Station");
@FXML @FXML
private Label lastRetrievedLabel; private Label nextSendTimeLabel;
@FXML @FXML
private TextArea messageTextArea; private TextArea messageTextArea;
@ -46,16 +67,16 @@ public class MainController implements Initializable {
private TextField stationNameField; private TextField stationNameField;
@FXML @FXML
private void handleSettingsButtonPress() { private SplitPane splitPane;
System.out.println("Button pressed!");
lastRetrievedLabel.setText("Button pressed!");
@FXML
private void handleStationSettingsButtonPress() {
if (settingsStage == null || !settingsStage.isShowing()) { if (settingsStage == null || !settingsStage.isShowing()) {
try { try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MainSettingsView.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/StationSettingsView.fxml"));
Parent root = fxmlLoader.load(); Parent root = fxmlLoader.load();
MainSettingsController controller = fxmlLoader.getController(); StationSettingsController controller = fxmlLoader.getController();
if (selectedStation == null) { if (selectedStation == null) {
Alert alert = new Alert(Alert.AlertType.WARNING); Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Invalid Station Selected"); alert.setTitle("Invalid Station Selected");
@ -65,17 +86,21 @@ public class MainController implements Initializable {
return; return;
} }
controller.setStationSettings(selectedStation); controller.setStationSettings(selectedStation);
controller.setStationNameList(settings.getStations().stream().map(StationSettings::toString).toList());
settingsStage = new Stage(); settingsStage = new Stage();
settingsStage.setMinWidth(600);
settingsStage.setMinHeight(300);
settingsStage.initModality(Modality.APPLICATION_MODAL); settingsStage.initModality(Modality.APPLICATION_MODAL);
settingsStage.setTitle("Numbers Station Settings"); settingsStage.setTitle("Numbers Station Settings");
settingsStage.getIcons().add(new Image(getClass().getResourceAsStream("/icon.png")));
settingsStage.setScene(new Scene(root)); settingsStage.setScene(new Scene(root));
settingsStage.show(); settingsStage.show();
settingsStage.setOnHiding(event -> { settingsStage.setOnHiding(event -> {
updateStationSettings(selectedStation); updateStationSettings(selectedStation);
}); });
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.log(Level.SEVERE, "Exception while opening settings", e);
} }
} else { } else {
settingsStage.toFront(); settingsStage.toFront();
@ -83,23 +108,37 @@ public class MainController implements Initializable {
} }
@FXML @FXML
private void handleSelectStationButtonPress() { private void handleSelectStationButtonPress() throws Exception {
if (selectStationStage == null || !selectStationStage.isShowing()) { if (selectStationStage == null || !selectStationStage.isShowing()) {
try { try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("StationSelectionView.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/StationSelectionView.fxml"));
Parent root = fxmlLoader.load(); Parent root = fxmlLoader.load();
StationSelectionController controller = fxmlLoader.getController(); StationSelectionController controller = fxmlLoader.getController();
controller.setSettings(settings); controller.setSettings(settings);
selectStationStage = new Stage(); selectStationStage = new Stage();
selectStationStage.setMinWidth(300);
selectStationStage.setMinHeight(200);
selectStationStage.initModality(Modality.APPLICATION_MODAL); selectStationStage.initModality(Modality.APPLICATION_MODAL);
selectStationStage.setUserData("test"); selectStationStage.setUserData(null);
selectStationStage.setTitle("Numbers Station Selection"); selectStationStage.setTitle("Numbers Station Selection");
selectStationStage.setScene(new Scene(root)); selectStationStage.getIcons().add(new Image(getClass().getResourceAsStream("/icon.png")));
Scene scene = new Scene(root);
scene.addEventFilter(KeyEvent.KEY_PRESSED, (e) -> controller.handleKeyPressed(e));
selectStationStage.setScene(scene);
selectStationStage.show(); selectStationStage.show();
selectStationStage.setOnHiding(event -> { selectStationStage.setOnHiding(event -> {
String newStationName = (String)selectStationStage.getUserData(); String newStationName = (String)selectStationStage.getUserData();
if (newStationName == null) {
return;
}
if (unsavedChanges.get()) {
if (!confirmSaveChanges()) {
return;
}
}
StationSettings newSelectedStation = settings.getStations().stream() StationSettings newSelectedStation = settings.getStations().stream()
.filter(station -> station.getName().equals(newStationName)) .filter(station -> station.getName().equals(newStationName))
.findFirst() .findFirst()
@ -107,54 +146,71 @@ public class MainController implements Initializable {
updateStationSettings(newSelectedStation); updateStationSettings(newSelectedStation);
}); });
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.log(Level.SEVERE, "Exception while selecting station", e);
} }
} else { } else {
selectStationStage.toFront(); selectStationStage.toFront();
} }
} }
private void loadSettings() throws IOException { @FXML
XmlMapper xmlMapper = new XmlMapper(); private void handleSetAsNextMessageButtonPress() {
xmlMapper.registerModule(new JavaTimeModule()); saveMessage();
String userHome = System.getProperty("user.home"); }
// TODO: XDG
Path directoryPath = Paths.get(userHome, ".numbers-station"); private void saveMessage() {
Path filePath = directoryPath.resolve("settings.xml");
try { try {
if (!Files.exists(selectedStation.stationPath())) {
// Create the directory if it doesn't exist Files.createDirectories(selectedStation.stationPath());
if (!Files.exists(directoryPath)) {
Files.createDirectories(directoryPath);
} }
if (!Files.exists(filePath)) { Files.write(selectedStation.nextMessagePath(), messageTextArea.getText().getBytes());
settings = new MainSettings(); unsavedChanges.set(false);
xmlMapper.writeValue(new File(filePath.toString()), settings);
} else {
settings = xmlMapper.readValue(new File(filePath.toString()), MainSettings.class);
for (StationSettings station : settings.getStations()) {
if (station.getDigitsPerGroup() == 0) {
station.setDigitsPerGroup(4);
}
}
}
} catch (IOException e) { } catch (IOException e) {
// Print the contents of filePath String message = "Failed to write next message to " + selectedStation.nextMessagePath().toString();
System.out.println("File contents: " + Files.readString(filePath)); logger.log(Level.SEVERE, message, e);
e.printStackTrace(); Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Exception");
alert.setHeaderText(null);
alert.setContentText(message);
alert.showAndWait();
} }
} }
@Override @Override
public void initialize(URL location, ResourceBundle resources) { public void initialize(URL location, ResourceBundle resources) {
stationNameField.textProperty().bindBidirectional(selectedStationName); stationNameField.textProperty().bindBidirectional(selectedStationName);
nextSendTimeLabel.textProperty().bind(nextSendTime);
try { Result<MainSettings, Exception> result = MainSettings.load();
loadSettings(); if (!result.hasSuccess()) {
} catch (IOException e) { String logPath = Main.getStatePath().resolve("main.log").toString();
e.printStackTrace(); String message = "Unable to load settings file. See log file at " + logPath + " for details. Reinitialize settings? This may overwrite existing settings.";
Alert alert = new Alert(Alert.AlertType.ERROR, message, ButtonType.NO, ButtonType.YES);
alert.setTitle("Settings load error");
alert.setHeaderText(null);
//Deactivate Defaultbehavior for yes-Button:
Button yesButton = (Button) alert.getDialogPane().lookupButton( ButtonType.YES );
yesButton.setDefaultButton( false );
//Activate Defaultbehavior for no-Button:
Button noButton = (Button) alert.getDialogPane().lookupButton( ButtonType.NO );
noButton.setDefaultButton( true );
Optional<ButtonType> promptResult = alert.showAndWait();
if (!promptResult.isPresent()) {
System.exit(1);
}
if (promptResult.get() == ButtonType.NO) {
System.exit(1);
}
settings = new MainSettings();
} else {
settings = result.getSuccess().get();
} }
selectedStationName.set(settings.getSelectedStationName()); selectedStationName.set(settings.getSelectedStationName());
@ -170,9 +226,13 @@ public class MainController implements Initializable {
.orElse(null); .orElse(null);
if (selectedStation == null) { if (selectedStation == null) {
// TODO: create a new station and save it? logger.log(Level.SEVERE, "Selected station '" + selectedStationName.get() + "' not found");
selectedStation = settings.getStations().get(0);
selectedStationName.set(selectedStation.getName());
} }
updateStationSettings(selectedStation);
messageTextArea.addEventFilter(KeyEvent.ANY, event -> { messageTextArea.addEventFilter(KeyEvent.ANY, event -> {
int cursorPosition = messageTextArea.getCaretPosition(); int cursorPosition = messageTextArea.getCaretPosition();
@ -204,6 +264,7 @@ public class MainController implements Initializable {
code == KeyCode.DIGIT7 || code == KeyCode.DIGIT7 ||
code == KeyCode.DIGIT8 || code == KeyCode.DIGIT8 ||
code == KeyCode.DIGIT9)) { code == KeyCode.DIGIT9)) {
unsavedChanges.set(true);
if (cursorPosition < messageTextArea.getLength()) { if (cursorPosition < messageTextArea.getLength()) {
char currentChar = messageTextArea.getText().charAt(cursorPosition); char currentChar = messageTextArea.getText().charAt(cursorPosition);
@ -215,6 +276,29 @@ public class MainController implements Initializable {
} }
} }
}); });
// The SplitPane allows the user to set the number of columns of
// numbers, which can help align with their pads.
//
// The splitpane doesn't seem to stick at 1.0 when resizing though,
// so we snap it to the right when it's close.
splitPane.widthProperty().addListener((obs, oldVal, newVal) -> {
if (splitPane.getDividerPositions()[0] > 0.95) {
splitPane.setDividerPositions(1.0);
}
});
unsavedChanges.addListener((obs2, wasUnsaved, isNowUnsaved) -> {
if (isNowUnsaved) {
if (!windowTitle.get().startsWith("*")) {
windowTitle.set("*" + windowTitle.get());
}
} else {
if (windowTitle.get().startsWith("*")) {
windowTitle.set(windowTitle.get().substring(1, windowTitle.get().length()));
}
}
});
} }
private void updateStationSettings(StationSettings newStationSettings) { private void updateStationSettings(StationSettings newStationSettings) {
@ -222,25 +306,160 @@ public class MainController implements Initializable {
return; return;
} }
logger.info("Updating station settings: " + newStationSettings.getName());
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
try {
nextSendTime.set(newStationSettings.nextSendTime().format(dateFormatter));
} catch (StationSettings.StationSettingsException e) {
String errMessage = "Failed to calculate next message time";
logger.log(Level.SEVERE, errMessage, e);
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Exception");
alert.setHeaderText(null);
alert.setContentText(errMessage + ": " + e.getMessage());
alert.showAndWait();
return;
}
selectedStation = newStationSettings; selectedStation = newStationSettings;
selectedStationName.set(newStationSettings.getName()); selectedStationName.set(newStationSettings.getName());
settings.setSelectedStationName(selectedStationName.get()); settings.setSelectedStationName(selectedStationName.get());
settings.save(); settings.save();
// TODO: Load message from file Path nextMessagePath = selectedStation.stationPath().resolve("next-message.txt");
// If the message we're overwriting is different from its file, then prompt to confirm
Random random = new Random(); String messageText;
StringBuilder messageBuilder = new StringBuilder(); if (!Files.exists(nextMessagePath)) {
try {
for (int i = 0; i < selectedStation.getMessageLength(); i++) { messageText = selectedStation.generateMessage(settings.getMessageGenerationAttempts());
if (i > 0 && i % selectedStation.getDigitsPerGroup() == 0) { } catch (StationSettings.MessageGenerationException e) {
messageBuilder.append(" "); String errMessage = "Failed to generate message";
} logger.log(Level.SEVERE, errMessage, e);
messageBuilder.append(random.nextInt(10)); Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Exception");
alert.setHeaderText(null);
alert.setContentText(errMessage + ": " + e.getMessage());
alert.showAndWait();
return;
} }
messageTextArea.setText(messageBuilder.toString()); try {
if (!Files.exists(selectedStation.stationPath())) {
Files.createDirectories(selectedStation.stationPath());
}
Files.write(nextMessagePath, messageText.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
String errMessage = "Failed to save message";
logger.log(Level.SEVERE, errMessage, e);
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Exception");
alert.setHeaderText(null);
alert.setContentText(errMessage + ": " + e.getMessage());
alert.showAndWait();
return;
}
} else {
try {
messageText = new String(Files.readAllBytes(nextMessagePath));
} catch (IOException e) {
String errMessage = "Failed to read message";
logger.log(Level.SEVERE, errMessage, e);
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Exception");
alert.setHeaderText(null);
alert.setContentText(errMessage + ": " + e.getMessage());
alert.showAndWait();
return;
}
}
unsavedChanges.set(false);
messageTextArea.setText(messageText);
}
/**
* @return Whether to continue with the action that prompted the confirmation
*/
public boolean confirmSaveChanges() {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Do you want to save your changes to the message?", ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
alert.setHeaderText(null);
Optional<ButtonType> result = alert.showAndWait();
if (!result.isPresent()) {
return false;
}
if (result.get() == ButtonType.YES) {
saveMessage();
return true;
} else if (result.get() == ButtonType.NO) {
return true;
} else {
return false;
}
}
/**
* @return whether close should continue or not
*/
public boolean handleCloseRequest() {
if (unsavedChanges.get()) {
return confirmSaveChanges();
}
return true;
}
public void handleAboutButtonPress() {
try {
if (aboutStage == null) {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/AboutView.fxml"));
Parent root = fxmlLoader.load();
aboutStage = new Stage();
aboutStage.setMinWidth(250);
aboutStage.setMinHeight(230);
aboutStage.setTitle("About Numbers Station");
aboutStage.getIcons().add(new Image(getClass().getResourceAsStream("/icon.png")));
aboutStage.setScene(new Scene(root));
}
if (aboutStage.isShowing()) {
aboutStage.toFront();
} else {
aboutStage.show();
}
} catch (IOException e) {
logger.log(Level.SEVERE, "Exception while opening application about screen", e);
}
}
public void handleHelpButtonPress() {
try {
if (helpStage == null) {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/HelpView.fxml"));
Parent root = fxmlLoader.load();
helpStage = new Stage();
helpStage.setMinWidth(400);
helpStage.setMinHeight(400);
helpStage.setTitle("Numbers Station Help");
helpStage.getIcons().add(new Image(getClass().getResourceAsStream("/icon.png")));
helpStage.setScene(new Scene(root));
}
if (helpStage.isShowing()) {
helpStage.toFront();
} else {
helpStage.show();
}
} catch (IOException e) {
logger.log(Level.SEVERE, "Exception while opening help", e);
}
} }
} }

View File

@ -0,0 +1,59 @@
package name.nathanmcrae.numbersstation;
import org.apache.commons.cli.*;
public class MainParsedArguments {
private boolean helpFlag = false;
private HelpFormatter formatter;
private Options options;
private ParseException parseException = null;
private String stationName;
private boolean versionFlag = false;
public MainParsedArguments (String[] args) {
options = new Options();
Option help = new Option("h", "help", false, "Show help");
options.addOption(help);
Option version = new Option("v", "version", false, "Show version");
options.addOption(version);
Option station = new Option("s", "station", true, "Specify station name");
station.setArgName("station-name");
options.addOption(station);
CommandLineParser parser = new DefaultParser();
formatter = new HelpFormatter();
try {
CommandLine cmd = parser.parse(options, args);
this.helpFlag = cmd.hasOption("help");
this.versionFlag = cmd.hasOption("version");
this.stationName = cmd.getOptionValue("station");
} catch (ParseException e) {
this.parseException = e;
}
}
public boolean getHelpFlag() {
return helpFlag;
}
public ParseException getParseException() {
return parseException;
}
public String getStationName() {
return stationName;
}
public boolean getVersionFlag() {
return versionFlag;
}
public void printHelp() {
formatter.printHelp("numbers-station", options);
}
}

View File

@ -0,0 +1,7 @@
package name.nathanmcrae.numbersstation;
public class MainRun {
public static void main(String[] args) {
Main.main(args);
}
}

View File

@ -1,21 +1,25 @@
package name.nathanmcrae.numbersstation; package name.nathanmcrae.numbersstation;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.leakyabstractions.result.api.Result;
import com.leakyabstractions.result.core.Results;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Logger;
import java.util.logging.Level;
public class MainSettings { public class MainSettings {
private static final Logger logger = Logger.getLogger(Main.class.getName());
private int digitsPerGroup; private int digitsPerGroup;
private int messageGenerationAttempts;
private String username; private String username;
private int refreshInterval;
private String selectedStationName; private String selectedStationName;
private ArrayList<StationSettings> stations; private ArrayList<StationSettings> stations;
@ -23,12 +27,25 @@ public class MainSettings {
public MainSettings() { public MainSettings() {
stations = new ArrayList<>(); stations = new ArrayList<>();
stations.add(new StationSettings("Station 1")); stations.add(new StationSettings("Station 1"));
messageGenerationAttempts = 5;
}
public static Path getSettingsFilePath() {
return Main.getConfigPath().resolve("main-settings.xml");
} }
public ArrayList<StationSettings> getStations() { public ArrayList<StationSettings> getStations() {
return stations; return stations;
} }
public int getMessageGenerationAttempts() {
return messageGenerationAttempts;
}
public void setMessageGenerationAttempts(int messageGenerationAttempts) {
this.messageGenerationAttempts = messageGenerationAttempts;
}
public String getUsername() { public String getUsername() {
return username; return username;
} }
@ -37,14 +54,6 @@ public class MainSettings {
this.username = username; this.username = username;
} }
public int getRefreshInterval() {
return refreshInterval;
}
public void setRefreshInterval(int refreshInterval) {
this.refreshInterval = refreshInterval;
}
public String getSelectedStationName() { public String getSelectedStationName() {
return selectedStationName; return selectedStationName;
} }
@ -53,21 +62,56 @@ public class MainSettings {
this.selectedStationName = selectedStationName; this.selectedStationName = selectedStationName;
} }
public static Result<MainSettings, Exception> load() {
XmlMapper xmlMapper = new XmlMapper();
xmlMapper.registerModule(new JavaTimeModule());
String userHome = System.getProperty("user.home");
MainSettings settings;
Path filePath = MainSettings.getSettingsFilePath();
Path directoryPath = filePath.getParent();
try {
if (!Files.exists(directoryPath)) {
Files.createDirectories(directoryPath);
}
if (!Files.exists(filePath)) {
settings = new MainSettings();
xmlMapper.writeValue(new File(filePath.toString()), settings);
} else {
settings = xmlMapper.readValue(new File(filePath.toString()), MainSettings.class);
for (StationSettings station : settings.getStations()) {
if (station.getDigitsPerGroup() == 0) {
station.setDigitsPerGroup(4);
}
}
}
} catch (IOException e) {
logger.log(Level.SEVERE, "Failed to load settings from " + filePath.toString(), e);
return Results.failure(e);
}
return Results.success(settings);
}
public void save() { public void save() {
XmlMapper xmlMapper = new XmlMapper(); XmlMapper xmlMapper = new XmlMapper();
xmlMapper.registerModule(new JavaTimeModule()); xmlMapper.registerModule(new JavaTimeModule());
xmlMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); xmlMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
xmlMapper.configure(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS, false);
xmlMapper.enable(SerializationFeature.INDENT_OUTPUT);
try { try {
String userHome = System.getProperty("user.home"); Path filePath = getSettingsFilePath();
Path directoryPath = Paths.get(userHome, ".numbers-station"); Path directoryPath = filePath.getParent();
Path filePath = directoryPath.resolve("settings.xml");
// Create the directory if it doesn't exist
if (!Files.exists(directoryPath)) { if (!Files.exists(directoryPath)) {
Files.createDirectories(directoryPath); Files.createDirectories(directoryPath);
} }
xmlMapper.writeValue(new File(filePath.toString()), this); xmlMapper.writeValue(new File(filePath.toString()), this);
logger.info("Settings saved to " + filePath.toString());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -1,96 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015, 2019, Gluon and/or its affiliates.
All rights reserved. Use is subject to license terms.
This file is available and licensed under the following license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 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.
- Neither the name of Oracle Corporation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"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 COPYRIGHT
OWNER OR CONTRIBUTORS 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.
-->
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<AnchorPane xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.MainController">
<children>
<VBox maxHeight="1.7976931348623157E308" minWidth="400.0" prefHeight="400.0" prefWidth="640.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<AnchorPane>
<VBox.margin>
<Insets bottom="10.0" />
</VBox.margin>
<children>
<Button layoutX="209.0" layoutY="1.0" mnemonicParsing="false" onAction="#handleSelectStationButtonPress" text="Select Station" />
<Label layoutY="5.0" prefHeight="17.0" prefWidth="49.0" text="Station: " />
<TextField fx:id="stationNameField" editable="false" layoutX="49.0" style="-fx-background-color: #EEEEEE; -fx-border-color: #AAAAAA;" text="My Station" />
<Button layoutX="602.0" layoutY="1.0" mnemonicParsing="false" text="Help" AnchorPane.rightAnchor="0.0" />
</children>
</AnchorPane>
<Separator prefWidth="200.0" />
<AnchorPane prefHeight="50.0" prefWidth="640.0">
<children>
<Label layoutX="14.0" text="Next message will be sent:" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="14.0">
<font>
<Font size="14.0" />
</font>
</Label>
<Label fx:id="lastRetrievedLabel" layoutX="183.0" layoutY="14.0" text="2024-12-25T12:59:47" AnchorPane.leftAnchor="183.0" AnchorPane.topAnchor="14.0">
<font>
<Font size="14.0" />
</font>
</Label>
<Button layoutX="534.0" layoutY="13.0" mnemonicParsing="false" onMouseClicked="#handleSettingsButtonPress" text="Station Settings" AnchorPane.rightAnchor="6.5" AnchorPane.topAnchor="13.0" />
</children>
</AnchorPane>
</children>
<padding>
<Insets bottom="10.0" />
</padding>
</VBox>
<TextArea fx:id="messageTextArea" layoutY="110.0" prefHeight="270.0" prefWidth="640.0" text="0239 0480 2938 0928&#10;3093 2298 3923 8933" wrapText="true" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="90.0">
<font>
<Font size="30.0" />
</font>
</TextArea>
<FlowPane alignment="CENTER_RIGHT" prefHeight="34.0" prefWidth="620.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children>
<Button mnemonicParsing="false" text="Set as next message" />
</children>
</FlowPane>
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</AnchorPane>

View File

@ -0,0 +1,86 @@
package name.nathanmcrae.numbersstation;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.Optional;
import javafx.application.Platform;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.DialogPane;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class NotificationController {
public enum NotificationType {
INFO,
ERROR
}
private static final Logger logger = Logger.getLogger(Main.class.getName());
private static final String informationString = "🛈";
private static final String errorString = "";
private Runnable openCallback;
@FXML
TextArea descriptionTextArea;
@FXML
Label iconLabel;
@FXML
Button openButton;
@FXML
Label titleLabel;
@FXML
private ImageView iconImageView;
public void handleOpenButtonPressed() {
if (openCallback != null) {
openCallback.run();
}
}
public void handleDismissButtonPressed(Event event) {
Node node = (Node) event.getSource();
Stage stage = (Stage) node.getScene().getWindow();
stage.close();
Platform.exit();
}
public record NotificationParameters(String title,
String description,
NotificationType type,
Optional<Runnable> openAction) {}
public void setNotification(NotificationParameters params) throws IllegalArgumentException {
titleLabel.setText(params.title());
descriptionTextArea.setText(params.description());
switch (params.type()) {
case INFO:
iconLabel.setText(informationString);
iconLabel.setTextFill(Color.color(0.2, 0.47, 0.73));
break;
case ERROR:
iconLabel.setText(errorString);
break;
default:
throw new IllegalArgumentException("Invalid notification type: " + params.type());
}
if (params.openAction().isPresent()) {
openButton.setVisible(true);
this.openCallback = params.openAction().get();
}
}
}

View File

@ -1,19 +1,27 @@
package name.nathanmcrae.numbersstation; package name.nathanmcrae.numbersstation;
import java.io.IOException;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.Optional; import java.util.Optional;
import javafx.collections.ListChangeListener; import javafx.collections.ListChangeListener;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.ListCell; import javafx.scene.control.ListCell;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.control.TextInputDialog; import javafx.scene.control.TextInputDialog;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.event.Event; import javafx.event.Event;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.stage.Stage; import javafx.stage.Stage;
public class StationSelectionController { public class StationSelectionController {
private static final Logger logger = Logger.getLogger(Main.class.getName());
private MainSettings settings; private MainSettings settings;
@ -58,42 +66,94 @@ public class StationSelectionController {
Optional<String> result = dialog.showAndWait(); Optional<String> result = dialog.showAndWait();
result.ifPresent(stationName -> { result.ifPresent(stationName -> {
if (stationName == null || stationName.equals("")) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Invalid station name");
alert.setHeaderText(null);
alert.setContentText("Station name must not be empty");
alert.showAndWait();
return;
}
for (StationSettings station : stationList) {
if (stationName.toLowerCase().equals(station.getName().toLowerCase())) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Invalid station name");
alert.setHeaderText(null);
alert.setContentText("Station name '" + stationName + "' is already used.");
alert.showAndWait();
return;
}
}
StationSettings newStation = new StationSettings(stationName); StationSettings newStation = new StationSettings(stationName);
stationList.add(newStation); stationList.add(newStation);
}); });
} }
@FXML
private void handleCancelButtonPress(Event event) {
Node node = (Node) event.getSource();
Stage stage = (Stage) node.getScene().getWindow();
stage.close();
}
@FXML
public void handleKeyPressed(KeyEvent event) {
KeyCode code = event.getCode();
if (code == KeyCode.ENTER) {
selectHighlightedStation();
} else if (code == KeyCode.ESCAPE) {
Stage stage = (Stage) stationListView.getScene().getWindow();
stage.close();
}
}
@FXML @FXML
private void handleRemoveButtonPress(ActionEvent event) { private void handleRemoveButtonPress(ActionEvent event) {
int selectedIndex = stationListView.getSelectionModel().getSelectedIndex(); int selectedIndex = stationListView.getSelectionModel().getSelectedIndex();
if (selectedIndex >= 0) { if (selectedIndex < 0) {
return;
}
StationSettings station = stationList.get(selectedIndex);
String stationName = station.toString();
String message = "Delete station '" + stationName + "'? All data will be erased.";
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, message, ButtonType.YES, ButtonType.NO);
alert.setTitle("Delete station?");
alert.setHeaderText(null);
alert.showAndWait();
if (selectedIndex >= 0 && alert.getResult() == ButtonType.YES) {
stationList.remove(selectedIndex); stationList.remove(selectedIndex);
} }
} }
@FXML @FXML
private void handleSelectButtonPress(Event e) { private void handleSelectButtonPress(Event e) {
Node node = (Node) e.getSource(); selectHighlightedStation();
Stage stage = (Stage) node.getScene().getWindow();
StationSettings selectedStation = stationListView.getSelectionModel().getSelectedItem();
if (selectedStation != null) {
stage.setUserData(selectedStation.getName());
System.out.println("Selected Station: " + selectedStation.getName());
}
stage.close();
} }
private void onStationListChanged(ListChangeListener.Change<? extends StationSettings> change) { private void onStationListChanged(ListChangeListener.Change<? extends StationSettings> change) {
while (change.next()) { while (change.next()) {
if (change.wasAdded()) { if (change.wasAdded()) {
for (StationSettings addedStation : change.getAddedSubList()) { for (StationSettings addedStation : change.getAddedSubList()) {
System.out.println("Added: " + addedStation.getName());
} }
} }
if (change.wasRemoved()) { if (change.wasRemoved()) {
for (StationSettings removedStation : change.getRemoved()) { for (StationSettings removedStation : change.getRemoved()) {
System.out.println("Removed: " + removedStation.getName()); try {
StationSettings.deleteStationData(removedStation.getName());
removedStation.deleteDir();
} catch (IOException e) {
logger.log(Level.SEVERE, "Exception when removing station directory", e);
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error removing station");
alert.setHeaderText(null);
alert.setContentText("Exception when removing station directory: " + e.getMessage());
alert.showAndWait();
return;
}
} }
} }
} }
@ -101,4 +161,14 @@ public class StationSelectionController {
settings.getStations().addAll(stationList); settings.getStations().addAll(stationList);
settings.save(); settings.save();
} }
private void selectHighlightedStation() {
Stage stage = (Stage) stationListView.getScene().getWindow();
StationSettings selectedStation = stationListView.getSelectionModel().getSelectedItem();
if (selectedStation != null) {
stage.setUserData(selectedStation.getName());
}
stage.close();
}
} }

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="437.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.StationSelectionController">
<children>
<Label layoutX="14.0" layoutY="14.0" text="Numbers Stations">
<font>
<Font size="20.0" />
</font>
</Label>
<Button layoutX="358.0" layoutY="17.0" mnemonicParsing="false" text="+" AnchorPane.rightAnchor="54.5" AnchorPane.topAnchor="17.0" onAction="#handleAddButtonPress"/>
<Button layoutX="391.0" layoutY="17.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="25.0" text="-" AnchorPane.rightAnchor="21.0" AnchorPane.topAnchor="17.0" onAction="#handleRemoveButtonPress"/>
<ListView fx:id="stationListView" layoutX="14.0" layoutY="57.0" prefHeight="301.0" prefWidth="409.0" AnchorPane.bottomAnchor="42.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="57.0" />
<Button layoutX="313.0" layoutY="365.0" mnemonicParsing="false" onMousePressed="#handleSelectButtonPress" text="Select" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="76.5" />
<Button layoutX="370.0" layoutY="365.0" mnemonicParsing="false" text="Cancel" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="15.5" />
</children>
</AnchorPane>

View File

@ -1,13 +1,34 @@
package name.nathanmcrae.numbersstation; package name.nathanmcrae.numbersstation;
import com.leakyabstractions.result.api.Result;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.Files;
import java.nio.file.FileVisitResult;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.security.SecureRandom;
import java.time.Duration;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.ZoneId;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.Period;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.Random;
public class StationSettings { public class StationSettings {
private static final Logger logger = Logger.getLogger(Main.class.getName());
private String address; private String address;
private int digitsPerGroup; private int digitsPerGroup;
private String externalProgramCommand; private String externalProgramCommand;
private Duration externalProgramTimeout;
private boolean manageScheduleExternally; private boolean manageScheduleExternally;
private int messageLength; private int messageLength;
private MessageMethod messageMethod; private MessageMethod messageMethod;
@ -15,15 +36,13 @@ public class StationSettings {
private String name; private String name;
private String password; private String password;
private ArrayList<String> prefixes; private ArrayList<String> prefixes;
private LocalDate scheduleStartDate; private ZonedDateTime scheduleStart;
private LocalTime scheduleStartTime;
private String username; private String username;
public enum MessageMethod { public enum MessageMethod {
FTP, EXTERNAL_PROGRAM,
SFTP, SFTP,
SCP, WORDPRESS
EXTERNAL_PROGRAM
} }
public enum MessagePeriod { public enum MessagePeriod {
@ -34,10 +53,186 @@ public class StationSettings {
public StationSettings() { public StationSettings() {
prefixes = new ArrayList<String>(); prefixes = new ArrayList<String>();
digitsPerGroup = 4;
messageLength = 100;
externalProgramTimeout = Duration.ofSeconds(5);
messageMethod = MessageMethod.SFTP;
messagePeriod = MessagePeriod.DAILY;
scheduleStart = ZonedDateTime.now();
} }
public StationSettings(String newName) { public StationSettings(String newName) {
name = newName; name = newName;
prefixes = new ArrayList<String>();
digitsPerGroup = 4;
externalProgramTimeout = Duration.ofSeconds(5);
messageLength = 100;
messageMethod = MessageMethod.SFTP;
messagePeriod = MessagePeriod.DAILY;
scheduleStart = ZonedDateTime.now();
}
public static void deleteStationData(String stationName) throws IOException {
StationSettings temp = new StationSettings(stationName);
temp.deleteDir();
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("win")) {
WindowsScheduler.removeSchedule(temp);
} else if (osName.contains("nix") || osName.contains("nux") || osName.contains("aix")) {
LinuxScheduler.removeSchedule(temp);
} else {
logger.log(Level.SEVERE, "Unsupported OS " + osName);
}
}
public static boolean stationDataExists(String stationName) {
StationSettings temp = new StationSettings(stationName);
if (Files.exists(temp.stationPath())) {
return true;
}
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("win")) {
Result<Boolean, String> result = WindowsScheduler.scheduleExists(temp);
if (result.hasSuccess() && result.getSuccess().get()) {
return true;
}
} else if (osName.contains("nix") || osName.contains("nux") || osName.contains("aix")) {
Result<Boolean, String> result = LinuxScheduler.scheduleExists(temp);
if (result.hasSuccess() && result.getSuccess().get()) {
return true;
}
} else {
logger.log(Level.SEVERE, "Unsupported OS " + osName);
}
return false;
}
public void deleteDir() throws IOException {
if (!Files.exists(stationPath())) {
return;
}
Files.walkFileTree(stationPath(), new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.delete(dir);
return FileVisitResult.CONTINUE;
}
});
}
public Path nextMessagePath() {
return stationPath().resolve("next-message.txt");
}
public Path stationPath() {
String stationDirName = null;
try {
stationDirName = java.net.URLEncoder.encode(name, "UTF-8");
} catch(UnsupportedEncodingException e) {} // We know UTF-8 is supported
return Main.getConfigPath().resolve(stationDirName);
}
public String generateMessage(int generationAttempts) throws MessageGenerationException {
SecureRandom random = new SecureRandom();
StringBuilder messageBuilder = new StringBuilder();
int attemptsLeft = generationAttempts;
boolean noPrefixCollisions = false;
while (!noPrefixCollisions) {
messageBuilder = new StringBuilder();
for (int i = 0; i < messageLength; i++) {
messageBuilder.append(random.nextInt(10));
}
String message = messageBuilder.toString();
boolean prefixCollision = false;
for (String prefix : prefixes) {
if (message.startsWith(prefix)) {
prefixCollision = true;
}
}
if (!prefixCollision) {
noPrefixCollisions = true;
}
attemptsLeft--;
if (prefixCollision && attemptsLeft <= 0) {
throw new MessageGenerationException("Failed " + generationAttempts + " attempts to generate message without matching prefixes. Ensure prefixes are valid.");
}
}
String messageNoSpaces = messageBuilder.toString();
StringBuilder messageFormattedBuilder = new StringBuilder();
for (int i = 0; i < messageNoSpaces.length(); i++) {
if (i > 0 && i % digitsPerGroup == 0) {
messageFormattedBuilder.append(" ");
}
messageFormattedBuilder.append(messageNoSpaces.charAt(i));
}
return messageFormattedBuilder.toString();
}
public LocalDateTime nextSendTime() throws StationSettingsException {
LocalDate startDate = scheduleStart.withZoneSameInstant(ZoneId.systemDefault()).toLocalDate();
LocalTime startTime = scheduleStart.withZoneSameInstant(ZoneId.systemDefault()).toLocalTime();
Period sinceScheduleStart = Period.between(startDate, LocalDate.now());
// If this period's time has not yet passed, then show that time.
// Otherwise, show the next period's time.
switch (messagePeriod) {
case DAILY:
if (LocalTime.now().isBefore(startTime)) {
return LocalDate.now().atTime(startTime);
} else {
return LocalDate.now().plusDays(1).atTime(startTime);
}
case WEEKLY:
int weekdayDifference = startDate.getDayOfWeek().getValue() - LocalDate.now().getDayOfWeek().getValue();
if (weekdayDifference > 0) {
return LocalDate.now().plusDays(weekdayDifference).atTime(startTime);
} else if (weekdayDifference == 0){
if (LocalTime.now().isBefore(startTime)) {
return LocalDate.now().atTime(startTime);
} else {
return LocalDate.now().plusWeeks(1).atTime(startTime);
}
} else {
return LocalDate.now().plusDays(7 + weekdayDifference).atTime(startTime);
}
case MONTHLY:
int monthdayDifference = startDate.getDayOfMonth() - LocalDate.now().getDayOfMonth();
if (monthdayDifference > 0) {
return LocalDate.now().plusDays(monthdayDifference).atTime(startTime);
} else if (monthdayDifference == 0) {
if (LocalTime.now().isBefore(startTime)) {
return LocalDate.now().atTime(startTime);
} else {
return LocalDate.now().plusMonths(1).atTime(startTime);
}
} else {
return LocalDate.now().plusMonths(1).plusDays(monthdayDifference).atTime(startTime);
}
default:
throw new StationSettingsException("Invalid period value: " + messagePeriod);
}
} }
public String getAddress() { public String getAddress() {
@ -64,6 +259,14 @@ public class StationSettings {
externalProgramCommand = newExternalProgramCommand; externalProgramCommand = newExternalProgramCommand;
} }
public Duration getExternalProgramTimeout() {
return externalProgramTimeout;
}
public void setExternalProgramTimeout(Duration newExternalProgramTimeout) {
externalProgramTimeout = newExternalProgramTimeout;
}
public boolean getManageScheduleExternally() { public boolean getManageScheduleExternally() {
return manageScheduleExternally; return manageScheduleExternally;
} }
@ -119,20 +322,12 @@ public class StationSettings {
return prefixes; return prefixes;
} }
public LocalDate getScheduleStartDate() { public ZonedDateTime getScheduleStart() {
return scheduleStartDate; return scheduleStart;
} }
public void setScheduleStartDate(LocalDate newScheduleStartDate) { public void setScheduleStart(ZonedDateTime newScheduleStart) {
scheduleStartDate = newScheduleStartDate; scheduleStart = newScheduleStart;
}
public LocalTime getScheduleStartTime() {
return scheduleStartTime;
}
public void setScheduleStartTime(LocalTime newScheduleStartTime) {
scheduleStartTime = newScheduleStartTime;
} }
public String getUsername() { public String getUsername() {
@ -147,4 +342,17 @@ public class StationSettings {
public String toString() { public String toString() {
return name; return name;
} }
public class MessageGenerationException extends Exception {
public MessageGenerationException(String message) {
super(message);
}
}
public static class StationSettingsException extends Exception {
public StationSettingsException(String message) {
super(message);
}
}
} }

View File

@ -3,12 +3,27 @@ package name.nathanmcrae.numbersstation;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.tearsofaunicorn.wordpress.api.model.Post;
import com.tearsofaunicorn.wordpress.api.WordpressClient;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.ZonedDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.Optional; import java.util.Optional;
import javafx.beans.binding.Bindings;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty; import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty; import javafx.beans.property.ObjectProperty;
@ -22,9 +37,11 @@ import javafx.collections.ObservableList;
import javafx.event.Event; import javafx.event.Event;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.control.Alert;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.CheckBox; import javafx.scene.control.CheckBox;
import javafx.scene.control.DatePicker; import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell; import javafx.scene.control.ListCell;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.control.RadioButton; import javafx.scene.control.RadioButton;
@ -33,6 +50,7 @@ import javafx.scene.control.SpinnerValueFactory;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.control.TextInputDialog; import javafx.scene.control.TextInputDialog;
import javafx.scene.control.ToggleGroup; import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image;
import javafx.scene.input.KeyEvent; import javafx.scene.input.KeyEvent;
import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCode;
import javafx.scene.Node; import javafx.scene.Node;
@ -42,7 +60,15 @@ import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.util.Callback; import javafx.util.Callback;
public class MainSettingsController { public class StationSettingsController {
public enum ConnectionStatus {
SUCCESS, FAILURE, NEUTRAL
}
private static final Logger logger = Logger.getLogger(Main.class.getName());
private ObjectProperty<ConnectionStatus> connectionTestStatus = new SimpleObjectProperty<>(ConnectionStatus.NEUTRAL);
private StringProperty connectionTestDescription = new SimpleStringProperty();
private IntegerProperty digitsPerGroup = new SimpleIntegerProperty(); private IntegerProperty digitsPerGroup = new SimpleIntegerProperty();
private StringProperty externalProgramCommand = new SimpleStringProperty(); private StringProperty externalProgramCommand = new SimpleStringProperty();
private BooleanProperty manageScheduleExternally = new SimpleBooleanProperty(); private BooleanProperty manageScheduleExternally = new SimpleBooleanProperty();
@ -57,6 +83,11 @@ public class MainSettingsController {
private StringProperty scheduleStartTime = new SimpleStringProperty(); private StringProperty scheduleStartTime = new SimpleStringProperty();
private StringProperty username = new SimpleStringProperty(); private StringProperty username = new SimpleStringProperty();
private ArrayList<String> stationNames = new ArrayList<String>();
@FXML
private Label connectionTestStatusLabel;
@FXML @FXML
private TextField stationNameField; private TextField stationNameField;
@ -87,15 +118,9 @@ public class MainSettingsController {
@FXML @FXML
private RadioButton monthlyRadioButton; private RadioButton monthlyRadioButton;
@FXML
private RadioButton ftpRadioButton;
@FXML @FXML
private RadioButton sftpRadioButton; private RadioButton sftpRadioButton;
@FXML
private RadioButton scpRadioButton;
@FXML @FXML
private TextField scheduleStartTimeField; private TextField scheduleStartTimeField;
@ -120,10 +145,24 @@ public class MainSettingsController {
@FXML @FXML
private RadioButton weeklyRadioButton; private RadioButton weeklyRadioButton;
public MainSettingsController() { } @FXML
private RadioButton wordpressRadioButton;
public StationSettingsController() { }
@FXML @FXML
private void initialize() { private void initialize() {
connectionTestStatusLabel.styleProperty().bind(Bindings.createStringBinding(() -> {
switch (connectionTestStatus.get()) {
case SUCCESS:
return "-fx-text-fill: green;";
case FAILURE:
return "-fx-text-fill: red;";
default:
return "-fx-text-fill: black;";
}
}, connectionTestStatus));
connectionTestStatusLabel.textProperty().bindBidirectional(connectionTestDescription);
externalProgramCommandField.textProperty().bindBidirectional(externalProgramCommand); externalProgramCommandField.textProperty().bindBidirectional(externalProgramCommand);
manageScheduleExternallyCheckBox.selectedProperty().bindBidirectional(manageScheduleExternally); manageScheduleExternallyCheckBox.selectedProperty().bindBidirectional(manageScheduleExternally);
stationNameField.textProperty().bindBidirectional(stationName); stationNameField.textProperty().bindBidirectional(stationName);
@ -238,26 +277,22 @@ public class MainSettingsController {
}); });
messageMethodGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> { messageMethodGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> {
if (newValue == ftpRadioButton) { if (newValue == externalProgramRadioButton) {
messageMethod.set(StationSettings.MessageMethod.FTP); messageMethod.set(StationSettings.MessageMethod.EXTERNAL_PROGRAM);
} else if (newValue == sftpRadioButton) { } else if (newValue == sftpRadioButton) {
messageMethod.set(StationSettings.MessageMethod.SFTP); messageMethod.set(StationSettings.MessageMethod.SFTP);
} else if (newValue == scpRadioButton) { } else if (newValue == wordpressRadioButton) {
messageMethod.set(StationSettings.MessageMethod.SCP); messageMethod.set(StationSettings.MessageMethod.WORDPRESS);
} else if (newValue == externalProgramRadioButton) {
messageMethod.set(StationSettings.MessageMethod.EXTERNAL_PROGRAM);
} }
}); });
messageMethod.addListener((observable, oldValue, newValue) -> { messageMethod.addListener((observable, oldValue, newValue) -> {
if (newValue == StationSettings.MessageMethod.FTP) { if (newValue == StationSettings.MessageMethod.EXTERNAL_PROGRAM) {
messageMethodGroup.selectToggle(ftpRadioButton); messageMethodGroup.selectToggle(externalProgramRadioButton);
} else if (newValue == StationSettings.MessageMethod.SFTP) { } else if (newValue == StationSettings.MessageMethod.SFTP) {
messageMethodGroup.selectToggle(sftpRadioButton); messageMethodGroup.selectToggle(sftpRadioButton);
} else if (newValue == StationSettings.MessageMethod.SCP) { } else if (newValue == StationSettings.MessageMethod.WORDPRESS) {
messageMethodGroup.selectToggle(scpRadioButton); messageMethodGroup.selectToggle(wordpressRadioButton);
} else if (newValue == StationSettings.MessageMethod.EXTERNAL_PROGRAM) {
messageMethodGroup.selectToggle(externalProgramRadioButton);
} }
}); });
@ -299,7 +334,6 @@ public class MainSettingsController {
if (empty || item == null) { if (empty || item == null) {
setText(null); setText(null);
} else { } else {
String newText = item.replaceAll(" ", ""); String newText = item.replaceAll(" ", "");
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -327,20 +361,21 @@ public class MainSettingsController {
@FXML @FXML
private void handleAddPrefixButtonPress() { private void handleAddPrefixButtonPress() {
try { try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("AddPrefixView.fxml")); FXMLLoader loader = new FXMLLoader(getClass().getResource("/AddPrefixView.fxml"));
Parent root = loader.load(); Parent root = loader.load();
AddPrefixController controller = loader.getController(); AddPrefixController controller = loader.getController();
controller.setMainSettingsController(this); controller.setStationSettingsController(this);
controller.setDigitsPerGroup(settings.getDigitsPerGroup()); controller.setDigitsPerGroup(settings.getDigitsPerGroup());
Stage stage = new Stage(); Stage stage = new Stage();
stage.setTitle("New prefix"); stage.setTitle("New prefix");
stage.getIcons().add(new Image(getClass().getResourceAsStream("/icon.png")));
stage.setScene(new Scene(root)); stage.setScene(new Scene(root));
stage.initModality(Modality.APPLICATION_MODAL); stage.initModality(Modality.APPLICATION_MODAL);
stage.showAndWait(); stage.showAndWait();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.log(Level.SEVERE, "Error loading AddPrefixView", e);
} }
} }
@ -367,6 +402,29 @@ public class MainSettingsController {
@FXML @FXML
private void handleSaveButtonPress(Event e) { private void handleSaveButtonPress(Event e) {
if (stationName.get() == null || stationName.get().equals("")) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Invalid station name");
alert.setHeaderText(null);
alert.setContentText("Station name must not be empty");
alert.showAndWait();
return;
}
if (!stationName.get().toLowerCase().equals(settings.getName().toLowerCase())) {
for (String otherStationName : stationNames) {
if (stationName.get().toLowerCase().equals(otherStationName.toLowerCase())) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Invalid station name");
alert.setHeaderText(null);
alert.setContentText("Station name '" + stationName.get() + "' is already used.");
alert.showAndWait();
return;
}
}
}
Path oldDirectory = settings.stationPath();
settings.setAddress(stationAddress.get()); settings.setAddress(stationAddress.get());
settings.setDigitsPerGroup(digitsPerGroup.get()); settings.setDigitsPerGroup(digitsPerGroup.get());
settings.setExternalProgramCommand(externalProgramCommand.get()); settings.setExternalProgramCommand(externalProgramCommand.get());
@ -378,15 +436,40 @@ public class MainSettingsController {
settings.setPassword(password.get()); settings.setPassword(password.get());
settings.getPrefixes().clear(); settings.getPrefixes().clear();
settings.getPrefixes().addAll(prefixListView.getItems()); settings.getPrefixes().addAll(prefixListView.getItems());
settings.setScheduleStartDate(scheduleStartDatePicker.getValue());
settings.setUsername(username.get()); settings.setUsername(username.get());
try {
if (!oldDirectory.toString().equals(settings.stationPath().toString())) {
Files.move(oldDirectory, settings.stationPath());
}
} catch (IOException ex) {
logger.log(Level.SEVERE, "Failed to move directory", ex);
}
try { try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
LocalTime startTime = LocalTime.parse(scheduleStartTimeField.getText(), formatter); LocalTime startTime = LocalTime.parse(scheduleStartTimeField.getText(), formatter);
settings.setScheduleStartTime(startTime); ZonedDateTime scheduleStart = ZonedDateTime.of(scheduleStartDatePicker.getValue(), startTime, ZoneId.systemDefault());
settings.setScheduleStart(scheduleStart.withZoneSameInstant(ZoneOffset.UTC));
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); logger.log(Level.SEVERE, "Error parsing schedule start time", ex);
}
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("win")) {
WindowsScheduler.registerSchedule(settings);
} else if (osName.contains("nix") || osName.contains("nux") || osName.contains("aix")) {
LinuxScheduler.registerSchedule(settings);
} else {
String message = "Unsupported OS " + osName;
logger.log(Level.SEVERE, message);
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle(message);
alert.setHeaderText(null);
alert.setContentText(message);
alert.showAndWait();
} }
Node node = (Node) e.getSource(); Node node = (Node) e.getSource();
@ -397,13 +480,68 @@ public class MainSettingsController {
@FXML @FXML
private void handleTestConnectionButtonPress() { private void handleTestConnectionButtonPress() {
// TODO if (messageMethod.get() == StationSettings.MessageMethod.SFTP) {
String host = stationAddress.get();
String user = username.get();
String pass = password.get();
connectionTestDescription.set("Testing connection");
connectionTestStatus.set(ConnectionStatus.NEUTRAL);
JSch jsch = new JSch();
try {
Session session = jsch.getSession(user, host, 22);
session.setPassword(pass);
session.setConfig("StrictHostKeyChecking", "no");
session.connect(30000); // 30 seconds timeout
if (session.isConnected()) {
logger.log(Level.INFO, "SFTP connection successful");
connectionTestDescription.set("Connection succeeded");
connectionTestStatus.set(ConnectionStatus.SUCCESS);
session.disconnect();
} else {
connectionTestDescription.set("No error, but not connected");
connectionTestStatus.set(ConnectionStatus.FAILURE);
logger.log(Level.SEVERE, "SFTP connection failed");
}
} catch (JSchException e) {
connectionTestDescription.set(e.getMessage());
connectionTestStatus.set(ConnectionStatus.FAILURE);
logger.log(Level.SEVERE, "SFTP connection failed", e);
}
} else if (messageMethod.get() == StationSettings.MessageMethod.WORDPRESS) {
connectionTestDescription.set("Testing connection");
connectionTestStatus.set(ConnectionStatus.NEUTRAL);
System.setProperty("wordpress.username", username.get());
System.setProperty("wordpress.password", password.get());
System.setProperty("wordpress.url", stationAddress.get());
Post post = new Post("Title of post", "content to post");
try {
WordpressClient client = new WordpressClient();
var postTypes = client.getPostTypes();
logger.log(Level.INFO, "Wordpress connection successful");
connectionTestDescription.set("Connection succeeded");
connectionTestStatus.set(ConnectionStatus.SUCCESS);
} catch (Exception e) {
connectionTestDescription.set("Worpress connection failed");
connectionTestStatus.set(ConnectionStatus.FAILURE);
logger.log(Level.SEVERE, "Wordpress connection failed", e);
}
}
} }
public StringProperty stationAddressProperty() { public StringProperty stationAddressProperty() {
return stationAddress; return stationAddress;
} }
public void setStationNameList(List<String> newStationNames) {
stationNames.clear();
stationNames.addAll(newStationNames);
}
public void setStationSettings(StationSettings newSettings) { public void setStationSettings(StationSettings newSettings) {
settings = newSettings; settings = newSettings;
@ -417,11 +555,10 @@ public class MainSettingsController {
messagePeriod.set(settings.getMessagePeriod()); messagePeriod.set(settings.getMessagePeriod());
username.set(settings.getUsername()); username.set(settings.getUsername());
password.set(settings.getPassword()); password.set(settings.getPassword());
System.out.println(settings.getPrefixes());
prefixListView.getItems().addAll(settings.getPrefixes()); prefixListView.getItems().addAll(settings.getPrefixes());
scheduleStartDate.set(settings.getScheduleStartDate()); scheduleStartDate.set(settings.getScheduleStart().withZoneSameInstant(ZoneId.systemDefault()).toLocalDate());
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
LocalTime startTime = settings.getScheduleStartTime(); LocalTime startTime = settings.getScheduleStart().withZoneSameInstant(ZoneId.systemDefault()).toLocalTime();
if (startTime == null) { if (startTime == null) {
startTime = LocalTime.now(); startTime = LocalTime.now();
} }

View File

@ -0,0 +1,459 @@
package name.nathanmcrae.numbersstation;
import com.leakyabstractions.result.api.Result;
import com.leakyabstractions.result.core.Results;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.lang.ProcessHandle;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.time.format.DateTimeFormatter;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import javafx.util.Pair;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class WindowsScheduler {
private static final Logger logger = Logger.getLogger(Main.class.getName());
public static Document generateScheduleDocument(String authorName, String userId, StationSettings station) throws ParserConfigurationException {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
// Root element
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("Task");
rootElement.setAttribute("version", "1.2");
rootElement.setAttribute("xmlns", "http://schemas.microsoft.com/windows/2004/02/mit/task");
doc.appendChild(rootElement);
LocalDateTime scheduleDateTime = station.getScheduleStart().withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime();
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
// RegistrationInfo element
Element registrationInfo = doc.createElement("RegistrationInfo");
rootElement.appendChild(registrationInfo);
Element date = doc.createElement("Date");
date.appendChild(doc.createTextNode(scheduleDateTime.format(dateFormatter)));
registrationInfo.appendChild(date);
Element author = doc.createElement("Author");
author.appendChild(doc.createTextNode(authorName));
registrationInfo.appendChild(author);
Element uri = doc.createElement("URI");
uri.appendChild(doc.createTextNode("\\test task"));
registrationInfo.appendChild(uri);
// Triggers element
Element triggers = doc.createElement("Triggers");
rootElement.appendChild(triggers);
Element calendarTrigger = doc.createElement("CalendarTrigger");
triggers.appendChild(calendarTrigger);
Element startBoundary = doc.createElement("StartBoundary");
startBoundary.appendChild(doc.createTextNode(scheduleDateTime.format(dateFormatter)));
calendarTrigger.appendChild(startBoundary);
Element enabled = doc.createElement("Enabled");
enabled.appendChild(doc.createTextNode("true"));
calendarTrigger.appendChild(enabled);
Element randomDelay = doc.createElement("RandomDelay");
randomDelay.appendChild(doc.createTextNode("PT1H"));
calendarTrigger.appendChild(randomDelay);
switch(station.getMessagePeriod()) {
case DAILY:
{
Element scheduleByDay = doc.createElement("ScheduleByDay");
calendarTrigger.appendChild(scheduleByDay);
Element daysInterval = doc.createElement("DaysInterval");
daysInterval.appendChild(doc.createTextNode("1"));
scheduleByDay.appendChild(daysInterval);
}
break;
case WEEKLY:
{
Element scheduleByDay = doc.createElement("ScheduleByDay");
calendarTrigger.appendChild(scheduleByDay);
Element daysInterval = doc.createElement("DaysInterval");
daysInterval.appendChild(doc.createTextNode("7"));
scheduleByDay.appendChild(daysInterval);
}
break;
case MONTHLY:
Element scheduleByMonth = doc.createElement("ScheduleByMonth");
calendarTrigger.appendChild(scheduleByMonth);
Element daysOfMonth = doc.createElement("DaysOfMonth");
scheduleByMonth.appendChild(daysOfMonth);
Element day = doc.createElement("Day");
LocalDate startDate = station.getScheduleStart().withZoneSameInstant(ZoneId.systemDefault()).toLocalDate();
day.appendChild(doc.createTextNode(String.valueOf(startDate.getDayOfMonth())));
daysOfMonth.appendChild(day);
Element months = doc.createElement("Months");
String[] monthNames = {
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
};
for (String monthName : monthNames) {
Element month = doc.createElement(monthName);
months.appendChild(month);
}
scheduleByMonth.appendChild(months);
break;
}
// Principals element
Element principals = doc.createElement("Principals");
rootElement.appendChild(principals);
Element principal = doc.createElement("Principal");
principal.setAttribute("id", "Author");
principals.appendChild(principal);
Element userIdElement = doc.createElement("UserId");
userIdElement.appendChild(doc.createTextNode(userId));
principal.appendChild(userIdElement);
Element logonType = doc.createElement("LogonType");
logonType.appendChild(doc.createTextNode("InteractiveToken"));
principal.appendChild(logonType);
Element runLevel = doc.createElement("RunLevel");
runLevel.appendChild(doc.createTextNode("LeastPrivilege"));
principal.appendChild(runLevel);
// Settings element
Element settings = doc.createElement("Settings");
rootElement.appendChild(settings);
Element multipleInstancesPolicy = doc.createElement("MultipleInstancesPolicy");
multipleInstancesPolicy.appendChild(doc.createTextNode("IgnoreNew"));
settings.appendChild(multipleInstancesPolicy);
Element disallowStartIfOnBatteries = doc.createElement("DisallowStartIfOnBatteries");
disallowStartIfOnBatteries.appendChild(doc.createTextNode("true"));
settings.appendChild(disallowStartIfOnBatteries);
Element stopIfGoingOnBatteries = doc.createElement("StopIfGoingOnBatteries");
stopIfGoingOnBatteries.appendChild(doc.createTextNode("true"));
settings.appendChild(stopIfGoingOnBatteries);
Element allowHardTerminate = doc.createElement("AllowHardTerminate");
allowHardTerminate.appendChild(doc.createTextNode("true"));
settings.appendChild(allowHardTerminate);
Element startWhenAvailable = doc.createElement("StartWhenAvailable");
startWhenAvailable.appendChild(doc.createTextNode("false"));
settings.appendChild(startWhenAvailable);
Element runOnlyIfNetworkAvailable = doc.createElement("RunOnlyIfNetworkAvailable");
runOnlyIfNetworkAvailable.appendChild(doc.createTextNode("false"));
settings.appendChild(runOnlyIfNetworkAvailable);
Element idleSettings = doc.createElement("IdleSettings");
settings.appendChild(idleSettings);
Element stopOnIdleEnd = doc.createElement("StopOnIdleEnd");
stopOnIdleEnd.appendChild(doc.createTextNode("true"));
idleSettings.appendChild(stopOnIdleEnd);
Element restartOnIdle = doc.createElement("RestartOnIdle");
restartOnIdle.appendChild(doc.createTextNode("false"));
idleSettings.appendChild(restartOnIdle);
Element allowStartOnDemand = doc.createElement("AllowStartOnDemand");
allowStartOnDemand.appendChild(doc.createTextNode("true"));
settings.appendChild(allowStartOnDemand);
Element enabledSetting = doc.createElement("Enabled");
enabledSetting.appendChild(doc.createTextNode("true"));
settings.appendChild(enabledSetting);
Element hidden = doc.createElement("Hidden");
hidden.appendChild(doc.createTextNode("false"));
settings.appendChild(hidden);
Element runOnlyIfIdle = doc.createElement("RunOnlyIfIdle");
runOnlyIfIdle.appendChild(doc.createTextNode("false"));
settings.appendChild(runOnlyIfIdle);
Element wakeToRun = doc.createElement("WakeToRun");
wakeToRun.appendChild(doc.createTextNode("false"));
settings.appendChild(wakeToRun);
Element executionTimeLimit = doc.createElement("ExecutionTimeLimit");
executionTimeLimit.appendChild(doc.createTextNode("PT72H"));
settings.appendChild(executionTimeLimit);
Element priority = doc.createElement("Priority");
priority.appendChild(doc.createTextNode("7"));
settings.appendChild(priority);
// Actions element
Element actions = doc.createElement("Actions");
actions.setAttribute("Context", "Author");
rootElement.appendChild(actions);
Element exec = doc.createElement("Exec");
actions.appendChild(exec);
String processName = ManagementFactory.getRuntimeMXBean().getName();
long pid = Long.parseLong(processName.split("@")[0]);
ProcessHandle currentProcess = ProcessHandle.of(pid).orElseThrow();
Path executablePath = currentProcess.info().command().map(Paths::get).orElseThrow();
logger.info("Executable Path: " + executablePath);
Element command = doc.createElement("Command");
command.appendChild(doc.createTextNode(executablePath.toString()));
exec.appendChild(command);
Element arguments = doc.createElement("Arguments");
arguments.appendChild(doc.createTextNode("--station \"" + station.getName() + "\""));
exec.appendChild(arguments);
return doc;
}
public static Result<String, String> getUserId() throws IOException, InterruptedException {
Process process = new ProcessBuilder("whoami", "/user").start();
if(!process.waitFor(5, TimeUnit.SECONDS)) {
String message = "Failed to get user id: process timed out";
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
if(process.exitValue() != 0) {
Pair<String, String> output = captureProcessOutput(process);
String message = "Failed to get user id. Exit code: " + process.exitValue() + ". stdout: " + output.getKey() + "\n\tstderr: " + output.getValue();
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
String line;
while ((line = reader.readLine()) != null) {
if (line.contains("S-")) {
return Results.success(line.split("\\s+")[1]);
}
}
}
return Results.failure("Failed to get user id: no user id found");
}
public static Result<Boolean, String> registerSchedule(StationSettings settings) {
Path tempFile = null;
try {
String taskName = "numbers-station-main_" + settings.getName();
Process queryTaskProcess = new ProcessBuilder("schtasks.exe", "/query", "/tn", taskName).start();
if (!queryTaskProcess.waitFor(5, TimeUnit.SECONDS)) {
String message = "Failed to query " + taskName + " task: process timed out";
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
// Remove previous instance of task if it exists
if (queryTaskProcess.exitValue() == 0) {
Process removeTaskProcess = new ProcessBuilder("schtasks.exe", "/delete", "/f", "/tn", taskName).start();
if (!removeTaskProcess.waitFor(5, TimeUnit.SECONDS)) {
String message = "Failed to remove " + taskName + " task: process timed out";
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
if (removeTaskProcess.exitValue() == 0) {
logger.info(taskName + " task removed successfully.");
} else {
Pair<String, String> output = captureProcessOutput(removeTaskProcess);
String message = "Failed to remove " + taskName + " task. Exit code: " + removeTaskProcess.exitValue() + ". stdout: " + output.getKey() + "\n\tstderr: " + output.getValue();
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
}
if (settings.getManageScheduleExternally()) {
return Results.success(true);
}
Result<String, String> userIdResult = getUserId();
if (!userIdResult.hasSuccess()) {
return Results.failure(userIdResult.getFailure().get());
}
String userId = userIdResult.getSuccess().get();
Document doc = generateScheduleDocument(System.getProperty("user.name"), userId, settings);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
DOMSource source = new DOMSource(doc);
tempFile = Files.createTempFile("task", ".xml");
StreamResult result = new StreamResult(tempFile.toFile());
try (BufferedWriter writer = Files.newBufferedWriter(tempFile)) {
writer.write("<?xml version=\"1.0\"?>\n");
transformer.transform(source, new StreamResult(writer));
} catch (IOException | TransformerException e) {
String message = "Failed to write schedule to temporary file";
logger.log(Level.SEVERE, message, e);
return Results.failure(message);
}
Process process = new ProcessBuilder("schtasks.exe", "/create", "/tn", taskName, "/xml", tempFile.toString()).start();
if (!process.waitFor(5, TimeUnit.SECONDS)) {
String message = "Failed to register " + taskName + " task: process timed out";
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
if (process.exitValue() == 0) {
logger.info(taskName + " task registered successfully.");
} else {
String message = "Failed to register " + taskName + " task. Exit code: " + process.exitValue();
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
} catch (ParserConfigurationException | TransformerException | IOException | InterruptedException e) {
String message = "Exception while registering schedule";
logger.log(Level.SEVERE, message, e);
return Results.failure(message);
} finally {
if (tempFile != null) {
try {
Files.delete(tempFile);
} catch (IOException e) {
logger.log(Level.SEVERE, "Failed to delete temporary file", e);
}
}
}
return Results.success(true);
}
public static Result<Boolean, String> removeSchedule(StationSettings settings) {
Path tempFile = null;
try {
String taskName = "numbers-station-main_" + settings.getName();
Process queryTaskProcess = new ProcessBuilder("schtasks.exe", "/query", "/tn", taskName).start();
if (!queryTaskProcess.waitFor(5, TimeUnit.SECONDS)) {
String message = "Failed to query " + taskName + " task: process timed out";
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
// Remove previous instance of task if it exists
if (queryTaskProcess.exitValue() == 0) {
Process removeTaskProcess = new ProcessBuilder("schtasks.exe", "/delete", "/f", "/tn", taskName).start();
if (!removeTaskProcess.waitFor(5, TimeUnit.SECONDS)) {
String message = "Failed to remove " + taskName + " task: process timed out";
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
if (removeTaskProcess.exitValue() == 0) {
logger.info(taskName + " task removed successfully.");
} else {
Pair<String, String> output = captureProcessOutput(removeTaskProcess);
String message = "Failed to remove " + taskName + " task. Exit code: " + removeTaskProcess.exitValue() + ". stdout: " + output.getKey() + "\n\tstderr: " + output.getValue();
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
}
} catch (IOException | InterruptedException e) {
String message = "Exception while registering schedule";
logger.log(Level.SEVERE, message, e);
return Results.failure(message);
} finally {
if (tempFile != null) {
try {
Files.delete(tempFile);
} catch (IOException e) {
logger.log(Level.SEVERE, "Failed to delete temporary file", e);
}
}
}
return Results.success(true);
}
public static Result<Boolean, String> runSchedule(StationSettings settings) {
String taskName = "numbers-station-main_" + settings.getName();
try {
Process taskProcess = new ProcessBuilder("schtasks.exe", "/run", "/tn", taskName).start();
} catch (IOException e) {
String message = "Failed to run " + taskName + " task";
logger.log(Level.SEVERE, message, e);
return Results.failure(message);
}
return Results.success(true);
}
public static Result<Boolean, String> scheduleExists(StationSettings settings) {
try {
String taskName = "numbers-station-main_" + settings.getName();
Process queryTaskProcess = new ProcessBuilder("schtasks.exe", "/query", "/tn", taskName).start();
if (!queryTaskProcess.waitFor(5, TimeUnit.SECONDS)) {
String message = "Failed to query " + taskName + " task: process timed out";
logger.log(Level.SEVERE, message);
return Results.failure(message);
}
return Results.success(queryTaskProcess.exitValue() == 0);
} catch (InterruptedException | IOException e) {
String message = "Exception while querying schedule";
logger.log(Level.SEVERE, message, e);
return Results.failure(message);
}
}
/**
* @return (stdout contents, stderr contents)
* Note that caller should check that process has exited
*/
public static Pair<String, String> captureProcessOutput(Process process) throws IOException {
StringBuilder output = new StringBuilder();
StringBuilder error = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
BufferedReader errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream()))) {
String line;
while ((line = reader.readLine()) != null) {
output.append(line + "\n");
}
while ((line = errorReader.readLine()) != null) {
error.append(line + "\n");
}
}
return new Pair<>(output.toString(), error.toString());
}
}

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="209.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.AboutController">
<children>
<Label layoutX="19.0" layoutY="10.0" text="Application Information">
<font>
<Font size="18.0" />
</font>
</Label>
<Label layoutX="20.0" layoutY="50.0" text="Homepage:" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="50.0" />
<TextField fx:id="homepageURLTextField" accessibleText="Homepage URL field" editable="false" layoutX="89.0" layoutY="46.0" prefHeight="25.0" prefWidth="501.0" text="asefa" AnchorPane.leftAnchor="89.0" AnchorPane.rightAnchor="10.0" />
<Label layoutX="20.0" layoutY="80.0" text="Version:" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="80.0" />
<TextField fx:id="versionTextField" accessibleText="Application version field" editable="false" layoutX="72.0" layoutY="76.0" text="asefa" AnchorPane.leftAnchor="89.0" AnchorPane.rightAnchor="10.0" />
<Label layoutX="20.0" layoutY="110.0" text="Application executable: " AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="110.0" />
<TextField fx:id="executableTextField" accessibleText="Application executable path field" editable="false" layoutX="153.0" layoutY="106.0" prefHeight="25.0" prefWidth="403.0" text="sflejk" AnchorPane.leftAnchor="153.0" AnchorPane.rightAnchor="10.0" />
<Label layoutX="20.0" layoutY="140.0" text="Config directory: " AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="140.0" />
<TextField fx:id="directoryTextField" accessibleText="Configuration directory path field" editable="false" layoutX="118.0" layoutY="136.0" prefHeight="25.0" prefWidth="437.0" text="afseijl" AnchorPane.leftAnchor="118.0" AnchorPane.rightAnchor="10.0" />
<Label layoutX="20.0" layoutY="168.0" text="Log file: " AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="170.0" />
<TextField fx:id="logPathTextField" accessibleText="Log file path field" editable="false" layoutX="70.0" layoutY="166.0" prefHeight="25.0" prefWidth="485.0" text="afseijl" AnchorPane.leftAnchor="70.0" AnchorPane.rightAnchor="10.0" />
</children>
</AnchorPane>

View File

@ -5,15 +5,19 @@
<?import javafx.scene.control.TextField?> <?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="92.0" prefWidth="312.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.AddPrefixController"> <VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="92.0" prefWidth="367.0" stylesheets="@css/application.css" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.AddPrefixController">
<children> <children>
<AnchorPane prefHeight="200.0" prefWidth="312.0"> <AnchorPane prefHeight="200.0" prefWidth="312.0">
<children> <children>
<Label layoutX="14.0" layoutY="14.0" text="Enter a message prefix / identifier:">
<font>
<Font name="Liberation Sans" size="13.0" />
</font></Label>
<TextField fx:id="prefixField" accessibleText="Prefix field" layoutX="216.0" layoutY="10.0" prefHeight="25.0" prefWidth="86.0" AnchorPane.leftAnchor="216.0" AnchorPane.rightAnchor="10.0" />
<Button fx:id="okButton" layoutX="89.0" layoutY="67.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="65.0" text="OK" AnchorPane.bottomAnchor="15.0" AnchorPane.rightAnchor="89.0" /> <Button fx:id="okButton" layoutX="89.0" layoutY="67.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="65.0" text="OK" AnchorPane.bottomAnchor="15.0" AnchorPane.rightAnchor="89.0" />
<Button fx:id="cancelButton" layoutX="169.0" layoutY="67.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="65.0" text="Cancel" AnchorPane.bottomAnchor="15.0" AnchorPane.rightAnchor="9.0" /> <Button fx:id="cancelButton" layoutX="169.0" layoutY="67.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="65.0" text="Cancel" AnchorPane.bottomAnchor="15.0" AnchorPane.rightAnchor="9.0" />
<Label layoutX="14.0" layoutY="14.0" text="Enter a message prefix / identifier:" />
<TextField fx:id="prefixField" layoutX="203.0" layoutY="10.0" prefHeight="25.0" prefWidth="105.0" AnchorPane.leftAnchor="203.0" AnchorPane.rightAnchor="10.0" />
</children> </children>
</AnchorPane> </AnchorPane>
</children> </children>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.web.WebView?>
<WebView fx:id="webView" prefHeight="597.0" prefWidth="652.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.HelpController" />

View File

@ -15,8 +15,7 @@
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<AnchorPane prefHeight="700.0" prefWidth="600.0" stylesheets="@css/application.css" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1">
<AnchorPane prefHeight="700.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<ScrollPane fitToWidth="true" hbarPolicy="NEVER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="297.0" prefWidth="600.0" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <ScrollPane fitToWidth="true" hbarPolicy="NEVER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="297.0" prefWidth="600.0" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content> <content>

View File

@ -44,8 +44,7 @@
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<AnchorPane stylesheets="@css/application.css" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1">
<AnchorPane xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<VBox maxHeight="1.7976931348623157E308" minWidth="400.0" prefHeight="400.0" prefWidth="640.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"> <VBox maxHeight="1.7976931348623157E308" minWidth="400.0" prefHeight="400.0" prefWidth="640.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children> <children>
@ -77,7 +76,7 @@
</font> </font>
</Label> </Label>
<Button layoutX="554.0" layoutY="14.0" mnemonicParsing="false" text="Staton Settings" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0" /> <Button layoutX="554.0" layoutY="14.0" mnemonicParsing="false" text="Staton Settings" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0" />
<Button layoutX="414.0" layoutY="14.0" mnemonicParsing="false" text="Retrieve now" AnchorPane.rightAnchor="121.0" AnchorPane.topAnchor="14.0" /> <Button layoutX="403.0" layoutY="14.0" mnemonicParsing="false" text="Retrieve now" AnchorPane.rightAnchor="123.0" AnchorPane.topAnchor="14.0" />
</children> </children>
</AnchorPane> </AnchorPane>
<Label text="Messages"> <Label text="Messages">

View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015, 2019, Gluon and/or its affiliates.
All rights reserved. Use is subject to license terms.
This file is available and licensed under the following license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 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.
- Neither the name of Oracle Corporation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"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 COPYRIGHT
OWNER OR CONTRIBUTORS 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.
-->
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?>
<?scenebuilder-stylesheet css/application.css?>
<AnchorPane prefHeight="429.0" prefWidth="660.0" stylesheets="@css/application.css" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.MainController">
<children>
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="26.5" vgrow="NEVER" />
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="15.0" vgrow="NEVER" />
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="42.0" vgrow="NEVER" />
<RowConstraints maxHeight="1.7976931348623157E308" minHeight="10.0" prefHeight="285.0" vgrow="ALWAYS" />
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="37.0" vgrow="NEVER" />
</rowConstraints>
<children>
<AnchorPane>
<children>
<Button layoutX="228.0" layoutY="1.0" mnemonicParsing="false" onAction="#handleSelectStationButtonPress" text="Select Station" />
<Label alignment="CENTER_RIGHT" layoutY="5.0" prefHeight="17.0" prefWidth="60.0" text="Station: " textAlignment="RIGHT" />
<TextField id="teststationnamefield" fx:id="stationNameField" accessibleText="Station name field" editable="false" layoutX="68.0" prefHeight="25.0" prefWidth="153.0" style="-fx-background-color: #EEEEEE; -fx-border-color: #AAAAAA;" text="My Station" />
<Button layoutX="602.0" layoutY="1.0" mnemonicParsing="false" onAction="#handleHelpButtonPress" text="Help" AnchorPane.rightAnchor="0.0" />
<Button layoutX="516.0" layoutY="1.0" mnemonicParsing="false" onAction="#handleAboutButtonPress" text="About" AnchorPane.rightAnchor="52.0" />
</children>
</AnchorPane>
<AnchorPane prefHeight="50.0" prefWidth="640.0" GridPane.rowIndex="2">
<children>
<Label layoutX="10.0" layoutY="7.0" text="Next message will be sent:" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="7.0">
<font>
<Font size="14.0" />
</font>
</Label>
<Label fx:id="nextSendTimeLabel" layoutX="202.0" layoutY="7.0" text="2024-12-25T12:59:47" AnchorPane.leftAnchor="202.0" AnchorPane.topAnchor="7.0">
<font>
<Font size="14.0" />
</font>
</Label>
<Button layoutX="540.5" layoutY="3.0" mnemonicParsing="false" onAction="#handleStationSettingsButtonPress" text="Station Settings" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="3.0" />
</children>
</AnchorPane>
<Separator prefHeight="10.0" prefWidth="640.0" GridPane.rowIndex="1" />
<SplitPane fx:id="splitPane" dividerPositions="1.0" prefHeight="272.0" prefWidth="640.0" GridPane.rowIndex="3">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<TextArea fx:id="messageTextArea" accessibleText="Next message editor" prefHeight="270.0" text="0239 0480 2938 0928&#10;3093 2298 3923 8933" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Liberation Mono" size="30.0" />
</font>
</TextArea>
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" />
</items>
</SplitPane>
<FlowPane alignment="CENTER_RIGHT" prefHeight="34.0" prefWidth="620.0" GridPane.rowIndex="4">
<children>
<Button mnemonicParsing="false" onAction="#handleSetAsNextMessageButtonPress" text="Set as next message" />
</children>
</FlowPane>
</children>
</GridPane>
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</AnchorPane>

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015, 2019, Gluon and/or its affiliates.
All rights reserved. Use is subject to license terms.
This file is available and licensed under the following license:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 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.
- Neither the name of Oracle Corporation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"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 COPYRIGHT
OWNER OR CONTRIBUTORS 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.
-->
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="250.0" prefWidth="395.0" stylesheets="@css/application.css" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.NotificationController">
<children>
<Label fx:id="iconLabel" alignment="CENTER" contentDisplay="CENTER" layoutX="14.0" layoutY="5.0" prefHeight="60.0" prefWidth="65.0" text="⚠" textAlignment="CENTER" textFill="RED">
<font>
<Font size="42.0" />
</font>
</Label>
<Label fx:id="titleLabel" layoutX="86.0" layoutY="24.0" text="Notification title (this sure is a title)">
<font>
<Font name="Liberation Sans Bold" size="16.0" />
</font>
</Label>
<TextArea fx:id="descriptionTextArea" accessibleText="Notification text field" editable="false" layoutX="14.0" layoutY="67.0" prefHeight="62.0" prefWidth="367.0" style="-fx-background-color: EEEEEE;" text="Quidem repellendus perferendis quos ipsum. Nihil nobis esse aperiam. Modi optio quia repudiandae quaerat fugit accusamus. Qui sint qui cupiditate rerum quisquam aspernatur illum. Deleniti voluptatum nam alias fugiat.Ab in iste dolores. Ad nostrum quia quisquam deleniti dolorum sequi. Est ut id et enim.Repellat nemo velit modi sunt provident neque neque. Est consequatur est beatae voluptates tempore commodi voluptas. Dicta asperiores deserunt veritatis quia officia. Reiciendis et qui placeat est minus." wrapText="true" AnchorPane.bottomAnchor="49.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="67.0" />
<Button fx:id="openButton" layoutX="270.0" layoutY="139.0" mnemonicParsing="false" onAction="#handleOpenButtonPressed" text="Open" visible="false" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="79.5" />
<Button fx:id="dismissButton" layoutX="325.0" layoutY="139.0" mnemonicParsing="false" onAction="#handleDismissButtonPressed" text="Dismiss" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="14.0" />
</children>
</AnchorPane>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="437.0" stylesheets="@css/application.css" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.StationSelectionController">
<children>
<Label layoutX="14.0" layoutY="14.0" text="Numbers Stations">
<font>
<Font size="20.0" />
</font>
</Label>
<Button accessibleText="Add new station button" layoutX="358.0" layoutY="17.0" mnemonicParsing="false" onAction="#handleAddButtonPress" prefHeight="25.0" prefWidth="26.0" text="+" AnchorPane.rightAnchor="55.0" AnchorPane.topAnchor="17.0" />
<Button accessibleText="Remove selected station button" layoutX="391.0" layoutY="17.0" mnemonicParsing="false" onAction="#handleRemoveButtonPress" prefHeight="25.0" prefWidth="25.0" text="-" AnchorPane.rightAnchor="21.0" AnchorPane.topAnchor="17.0" />
<ListView fx:id="stationListView" accessibleText="Station selection list" layoutX="14.0" layoutY="57.0" prefHeight="301.0" prefWidth="409.0" AnchorPane.bottomAnchor="42.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="57.0" />
<Button layoutX="293.0" layoutY="366.0" mnemonicParsing="false" onAction="#handleSelectButtonPress" text="Select" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="85.0" />
<Button layoutX="370.0" layoutY="365.0" mnemonicParsing="false" onAction="#handleCancelButtonPress" text="Cancel" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="15.5" />
</children>
</AnchorPane>

View File

@ -18,7 +18,7 @@
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<AnchorPane prefHeight="700.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.MainSettingsController"> <AnchorPane prefHeight="700.0" prefWidth="600.0" stylesheets="@css/application.css" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="name.nathanmcrae.numbersstation.StationSettingsController">
<children> <children>
<ScrollPane fitToWidth="true" hbarPolicy="NEVER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0" prefWidth="600.0" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <ScrollPane fitToWidth="true" hbarPolicy="NEVER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0" prefWidth="600.0" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content> <content>
@ -26,8 +26,8 @@
<children> <children>
<FlowPane alignment="CENTER_LEFT" prefHeight="41.0" prefWidth="640.0"> <FlowPane alignment="CENTER_LEFT" prefHeight="41.0" prefWidth="640.0">
<children> <children>
<Label prefHeight="17.0" prefWidth="49.0" text="Station: " /> <Label alignment="CENTER_RIGHT" prefHeight="17.0" prefWidth="58.0" text="Station: " />
<TextField fx:id="stationNameField" style="-fx-border-color: #AAAAAA;" text="My Station"> <TextField fx:id="stationNameField" accessibleText="Station name field" style="-fx-border-color: #AAAAAA;" text="My Station">
<FlowPane.margin> <FlowPane.margin>
<Insets right="10.0" /> <Insets right="10.0" />
</FlowPane.margin> </FlowPane.margin>
@ -40,64 +40,60 @@
<Separator prefWidth="200.0" /> <Separator prefWidth="200.0" />
<AnchorPane prefHeight="77.0" prefWidth="578.0"> <AnchorPane prefHeight="77.0" prefWidth="578.0">
<children> <children>
<FlowPane alignment="CENTER_LEFT" layoutX="8.0" layoutY="7.0" prefHeight="63.0" prefWidth="216.0"> <FlowPane alignment="CENTER_LEFT" layoutX="8.0" layoutY="7.0" prefHeight="63.0" prefWidth="229.0">
<children> <children>
<Label prefHeight="38.0" prefWidth="103.0" text="Digit group size: (only for display)" textAlignment="RIGHT" textOverrun="CLIP" wrapText="true"> <Label prefHeight="38.0" prefWidth="116.0" text="Digit group size: (only for display)" textAlignment="RIGHT" textOverrun="CLIP" wrapText="true">
<FlowPane.margin> <FlowPane.margin>
<Insets right="10.0" /> <Insets right="10.0" />
</FlowPane.margin> </FlowPane.margin>
</Label> </Label>
<Spinner fx:id="digitsPerGroupSpinner" editable="true" prefHeight="25.0" prefWidth="96.0" /> <Spinner fx:id="digitsPerGroupSpinner" accessibleText="Digit group size field" editable="true" prefHeight="25.0" prefWidth="96.0" />
</children> </children>
</FlowPane> </FlowPane>
<FlowPane alignment="CENTER_LEFT" layoutX="233.0" layoutY="7.0" prefHeight="63.0" prefWidth="216.0"> <FlowPane alignment="CENTER_LEFT" layoutX="244.0" layoutY="7.0" prefHeight="63.0" prefWidth="216.0">
<children> <children>
<Label prefHeight="38.0" prefWidth="109.0" text="Message length:" textAlignment="RIGHT" textOverrun="CLIP"> <Label alignment="CENTER_RIGHT" prefHeight="38.0" prefWidth="109.0" text="Message length:" textAlignment="RIGHT" textOverrun="CLIP">
<FlowPane.margin> <FlowPane.margin>
<Insets right="10.0" /> <Insets right="10.0" />
</FlowPane.margin> </FlowPane.margin>
</Label> </Label>
<Spinner fx:id="messageLengthSpinner" editable="true" prefHeight="25.0" prefWidth="96.0" /> <Spinner fx:id="messageLengthSpinner" accessibleText="Message length field" editable="true" prefHeight="25.0" prefWidth="96.0" />
</children> </children>
</FlowPane> </FlowPane>
</children> </children>
</AnchorPane> </AnchorPane>
<Separator prefWidth="200.0" /> <Separator prefWidth="200.0" />
<AnchorPane prefHeight="170.0" prefWidth="578.0"> <AnchorPane prefHeight="167.0" prefWidth="578.0">
<children> <children>
<Label layoutY="6.0" text="Send messages via:"> <Label layoutY="6.0" text="Send messages via:">
<font> <font>
<Font size="14.0" /> <Font size="14.0" />
</font> </font>
</Label> </Label>
<Label layoutX="170.0" layoutY="9.0" text="Numbers station address:" /> <Label fx:id="connectionTestStatusLabel" accessibleText="Test connection result" alignment="CENTER_RIGHT" layoutX="136.0" layoutY="11.0" prefHeight="17.0" prefWidth="317.0" textAlignment="RIGHT" AnchorPane.leftAnchor="136.0" AnchorPane.rightAnchor="125.0" />
<TextField fx:id="stationAddressField" layoutX="188.0" layoutY="33.0" prefHeight="25.0" prefWidth="390.0" AnchorPane.leftAnchor="188.0" AnchorPane.rightAnchor="0.0" /> <Button fx:id="testConnectionButton" layoutX="464.0" layoutY="7.0" mnemonicParsing="false" onAction="#handleTestConnectionButtonPress" text="Test connection" AnchorPane.rightAnchor="0.0" />
<RadioButton fx:id="ftpRadioButton" layoutX="16.0" layoutY="44.0" mnemonicParsing="false" text="FTP"> <RadioButton fx:id="sftpRadioButton" layoutX="16.0" layoutY="42.0" mnemonicParsing="false" text="SFTP">
<toggleGroup> <toggleGroup>
<ToggleGroup fx:id="messageMethodGroup" /> <ToggleGroup fx:id="messageMethodGroup" />
</toggleGroup> </toggleGroup>
</RadioButton> </RadioButton>
<RadioButton fx:id="sftpRadioButton" layoutX="16.0" layoutY="74.0" mnemonicParsing="false" text="SFTP"> <RadioButton fx:id="wordpressRadioButton" layoutX="16.0" layoutY="72.0" mnemonicParsing="false" text="Wordpress">
<toggleGroup> <toggleGroup>
<fx:reference source="messageMethodGroup" /> <fx:reference source="messageMethodGroup" />
</toggleGroup> </toggleGroup>
</RadioButton> </RadioButton>
<RadioButton fx:id="scpRadioButton" layoutX="16.0" layoutY="104.0" mnemonicParsing="false" text="SCP"> <RadioButton fx:id="externalProgramRadioButton" layoutX="16.0" layoutY="102.0" mnemonicParsing="false" text="External program:">
<toggleGroup> <toggleGroup>
<fx:reference source="messageMethodGroup" /> <fx:reference source="messageMethodGroup" />
</toggleGroup> </toggleGroup>
</RadioButton> </RadioButton>
<RadioButton fx:id="externalProgramRadioButton" layoutX="16.0" layoutY="134.0" mnemonicParsing="false" text="External program:"> <Label layoutX="170.0" layoutY="39.0" text="Numbers station address:" />
<toggleGroup> <TextField fx:id="stationAddressField" accessibleText="Number station address field" layoutX="189.0" layoutY="63.0" prefHeight="25.0" prefWidth="390.0" AnchorPane.leftAnchor="189.0" AnchorPane.rightAnchor="-1.0" />
<fx:reference source="messageMethodGroup" /> <Label layoutX="182.0" layoutY="99.0" text="Username:" AnchorPane.rightAnchor="340.0" />
</toggleGroup> <TextField fx:id="usernameField" accessibleText="Numbers station username field" layoutX="245.0" layoutY="95.0" prefHeight="25.0" prefWidth="124.0" AnchorPane.rightAnchor="209.0" />
</RadioButton>
<Label layoutX="380.0" layoutY="69.0" text="Username:" AnchorPane.rightAnchor="142.0" />
<Label layoutX="380.0" layoutY="99.0" text="Password:" AnchorPane.rightAnchor="142.0" /> <Label layoutX="380.0" layoutY="99.0" text="Password:" AnchorPane.rightAnchor="142.0" />
<TextField fx:id="usernameField" layoutX="444.0" layoutY="65.0" prefHeight="25.0" prefWidth="135.0" AnchorPane.rightAnchor="0.0" /> <PasswordField fx:id="passwordField" accessibleText="Numbers station password field" layoutX="444.0" layoutY="95.0" prefHeight="25.0" prefWidth="135.0" AnchorPane.rightAnchor="0.0" />
<PasswordField fx:id="passwordField" layoutX="444.0" layoutY="95.0" prefHeight="25.0" prefWidth="135.0" AnchorPane.rightAnchor="0.0" /> <TextField fx:id="externalProgramCommandField" accessibleText="Numbers station external program field" layoutX="-2.0" layoutY="131.0" prefHeight="25.0" prefWidth="580.0" AnchorPane.leftAnchor="-2.0" AnchorPane.rightAnchor="0.0" />
<TextField fx:id="externalProgramCommandField" layoutX="140.0" layoutY="131.0" prefHeight="25.0" prefWidth="438.0" AnchorPane.leftAnchor="140.0" AnchorPane.rightAnchor="0.0" />
<Button fx:id="testConnectionButton" layoutX="188.0" layoutY="65.0" mnemonicParsing="false" onMousePressed="#handleTestConnectionButtonPress" text="Test connection" />
</children> </children>
<VBox.margin> <VBox.margin>
@ -112,14 +108,14 @@
<Font size="14.0" /> <Font size="14.0" />
</font> </font>
</Label> </Label>
<Button layoutX="520.5" layoutY="4.0" mnemonicParsing="false" onMousePressed="#handleAddPrefixButtonPress" text="+" AnchorPane.rightAnchor="33.0" /> <Button accessibleText="Add prefix field" layoutX="520.5" layoutY="4.0" mnemonicParsing="false" onAction="#handleAddPrefixButtonPress" text="+" AnchorPane.rightAnchor="33.0" />
<Button layoutX="552.0" layoutY="4.0" mnemonicParsing="false" onMousePressed="#handleRemovePrefixButtonPress" prefHeight="25.0" prefWidth="25.0" text="-" AnchorPane.rightAnchor="1.0" /> <Button accessibleText="Remove selected prefix button" layoutX="552.0" layoutY="4.0" mnemonicParsing="false" onAction="#handleRemovePrefixButtonPress" prefHeight="25.0" prefWidth="25.0" text="-" AnchorPane.rightAnchor="1.0" />
</children> </children>
<VBox.margin> <VBox.margin>
<Insets bottom="10.0" /> <Insets bottom="10.0" />
</VBox.margin> </VBox.margin>
</AnchorPane> </AnchorPane>
<ListView fx:id="prefixListView" prefHeight="103.0" prefWidth="578.0" /> <ListView fx:id="prefixListView" accessibleText="Prefix list" prefHeight="103.0" prefWidth="578.0" />
<Separator prefWidth="200.0"> <Separator prefWidth="200.0">
<VBox.margin> <VBox.margin>
<Insets bottom="10.0" top="10.0" /> <Insets bottom="10.0" top="10.0" />
@ -133,25 +129,24 @@
<AnchorPane prefHeight="152.0" prefWidth="578.0"> <AnchorPane prefHeight="152.0" prefWidth="578.0">
<children> <children>
<CheckBox fx:id="manageScheduleExternallyCheckBox" layoutX="395.0" mnemonicParsing="false" text="Manage schedule externally" AnchorPane.rightAnchor="14.5" /> <CheckBox fx:id="manageScheduleExternallyCheckBox" layoutX="395.0" mnemonicParsing="false" text="Manage schedule externally" AnchorPane.rightAnchor="14.5" />
<RadioButton fx:id="dailyRadioButton" layoutX="14.0" layoutY="8.0" mnemonicParsing="false" text="Daily" disable="${manageScheduleExternallyCheckBox.selected}"> <RadioButton fx:id="dailyRadioButton" disable="${manageScheduleExternallyCheckBox.selected}" layoutX="14.0" layoutY="8.0" mnemonicParsing="false" text="Daily">
<toggleGroup> <toggleGroup>
<ToggleGroup fx:id="messagePeriodGroup" /> <ToggleGroup fx:id="messagePeriodGroup" />
</toggleGroup> </toggleGroup>
</RadioButton> </RadioButton>
<RadioButton fx:id="weeklyRadioButton" layoutX="14.0" layoutY="38.0" mnemonicParsing="false" text="Weekly" disable="${manageScheduleExternallyCheckBox.selected}"> <RadioButton fx:id="weeklyRadioButton" disable="${manageScheduleExternallyCheckBox.selected}" layoutX="14.0" layoutY="38.0" mnemonicParsing="false" text="Weekly">
<toggleGroup> <toggleGroup>
<fx:reference source="messagePeriodGroup" /> <fx:reference source="messagePeriodGroup" />
</toggleGroup> </toggleGroup>
</RadioButton> </RadioButton>
<RadioButton fx:id="monthlyRadioButton" layoutX="14.0" layoutY="68.0" mnemonicParsing="false" text="Monthly" disable="${manageScheduleExternallyCheckBox.selected}"> <RadioButton fx:id="monthlyRadioButton" disable="${manageScheduleExternallyCheckBox.selected}" layoutX="14.0" layoutY="68.0" mnemonicParsing="false" text="Monthly">
<toggleGroup> <toggleGroup>
<fx:reference source="messagePeriodGroup" /> <fx:reference source="messagePeriodGroup" />
</toggleGroup> </toggleGroup>
</RadioButton> </RadioButton>
<DatePicker fx:id="scheduleStartDatePicker" layoutX="115.0" layoutY="34.0" disable="${manageScheduleExternallyCheckBox.selected}" />
<Label layoutX="115.0" layoutY="8.0" text="Starting from:" /> <Label layoutX="115.0" layoutY="8.0" text="Starting from:" />
<TextField fx:id="scheduleStartTimeField" layoutX="115.0" layoutY="64.0" text="23:24:49" disable="${manageScheduleExternallyCheckBox.selected}" /> <DatePicker fx:id="scheduleStartDatePicker" accessibleText="Message schedule start date" disable="${manageScheduleExternallyCheckBox.selected}" layoutX="115.0" layoutY="34.0" />
<Label layoutX="48.0" layoutY="102.0" text="TODO: Jitter" /> <TextField fx:id="scheduleStartTimeField" accessibleText="Message schedule start time" disable="${manageScheduleExternallyCheckBox.selected}" layoutX="115.0" layoutY="64.0" text="23:24:49" />
</children> </children>
</AnchorPane> </AnchorPane>
@ -164,12 +159,12 @@
</ScrollPane> </ScrollPane>
<FlowPane alignment="CENTER_RIGHT" prefHeight="40.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"> <FlowPane alignment="CENTER_RIGHT" prefHeight="40.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children> <children>
<Button mnemonicParsing="false" onMousePressed="#handleSaveButtonPress" text="Save" textAlignment="RIGHT"> <Button mnemonicParsing="false" onAction="#handleSaveButtonPress" text="Save" textAlignment="RIGHT">
<FlowPane.margin> <FlowPane.margin>
<Insets right="10.0" /> <Insets right="10.0" />
</FlowPane.margin> </FlowPane.margin>
</Button> </Button>
<Button mnemonicParsing="false" onMousePressed="#handleCancelButtonPress" text="Cancel"> <Button mnemonicParsing="false" onAction="#handleCancelButtonPress" text="Cancel">
<opaqueInsets> <opaqueInsets>
<Insets /> <Insets />
</opaqueInsets> </opaqueInsets>

View File

@ -0,0 +1,231 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Numbers Station Help</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Numbers Station Help</h1>
<p>
The Numbers Station application is a tool to upload messages to a website/blog on a regular schedule. For why you would want this, see <a href="#motivation">Motivation</a>. To get started, see <a href="#quick-start">Quick Start</a>.
</p>
<img src="overview.png"/>
<h2 class="caution">Caution</h2>
<p>
This application assumes you will be using your own encryption scheme where the encrypted messages are made up of digits 0-9. Typically these will be one-time pad messages such as described <a href="https://nathanmcrae.name/blog/practical-one-time-pad.html">here</a>. This application performs no encryption of it's own and should not be trusted with unencrypted messages.
</p>
<h2>Quick Start</h2>
<p>
Before you start, you'll need to have a method of encrypting messages. Unencrypted messages should never be entered into the application. For a method to securely encrypt messages, see <a href="https://nathanmcrae.name/blog/practical-one-time-pad.html">here</a>.
</p>
<p>
For the sake of example, this will walk you through setting up a wordpress blog and creating a numbers station which will periodically post to it. There are also other options for uploading posts.
</p>
<h3>Start a Wordpress.com Blog</h3>
<p>
Wordpress is free blogging software, and one of the most popular at that. Many web hosts provide wordpress blogs for free and Wordpress.com is just one of those hosts, but that's the one we're going to use for this example since it's fairly straightforward.
</p>
<ol>
<li>
Go to <a href="https://wordpress.com/start/free">wordpress.com</a>
</li>
<li>
Create an account using whatever method you prefer
<ul>
<li>It will prompt you to search for a domain to rent, but you don't need one. To skip that, start a domain search and at the bottom select the 'Choose my domain later'</li>
</ul>
</li>
<li>
For 'What would you like to create?' at the bottom, press 'Skip to dashboard'
<ul>
<li>You should now have a basic wordpress site</li>
</ul>
</li>
<li>
You will need a password in order to allow the Numbers Station application to post for you. Go you your Wordpress.com account settings and under Security, set a password.
<ul>
<li>You may need to verify you email in order to post</li>
</ul>
</li>
</ol>
<h3>Set up a Numbers Station</h3>
<img src="station-settings.png"/>
<p>
Now that you have a blog to post to, you will need to set up your numbers station settings.
</p>
<ol>
<li>
<a href="https://git.nathanmcrae.name/nathanmcrae/numbers-station">Download</a>, install, and run the Numbers Station application
</li>
<li>
Select or create your desired station in the 'Select Station' dialog
</li>
<li>Open 'Station Settings'</li>
<li>Set connection information
<ol>
<li>
Choose the 'Wordpress option'
</li>
<li>
Enter your blog address (which can be found by selecting 'Visit Site' from the Wordpress.com dashboard) ending with <code>/xmlrpc.php</code>
<ul>
<li>So if your Wordpress.com site is <code>example.wordpress.com</code>, then the address to enter would be <code>https://example.wordpress.com/xmlrpc.php</code></li>
<li>Note that other wordpress instances may need XML-RPC to be enabled for this to work. Please see documentation for your instance.</li>
</ul>
</li>
<li>
Enter your Wordpress.com username (your email address if you registered with email) and password
<p class="caution">Your password is stored in your user files. Anyone with access to your user files would also be able to post to the blog</p>
</li>
<li>
Press the 'Test connection' button
</li>
</ol>
</li>
<li>
Set schedule
<ul>
<li>Your schedule will start at the given date and time, and will publish a message to the station on the given period (daily, weekly, monthly)</li>
</ul>
</li>
<li>
Set other options (See application reference for details)
</li>
</ol>
<h3>
Set a message for delivery
</h3>
<p>
Once you save your station settings, the application should now run on the given schedule and upload messages. Each time it runs it will generate a random message to be sent next time. Whenever you would like to send a real message, all you need to do is replace the stored one with the real message.
</p>
<ol>
<li>
Open the application and select the station you want to send a message via
</li>
<li>
The main window will show the current message which will be sent next. To replace it, simply type in the real message (which should already be encrypted).
</li>
<li>
Press 'Set as next message'
</li>
</ol>
<p>
Now the real message is saved and will be sent at the next appointed time.
</p>
<h2>Motivation</h2>
<p>
Suppose you have secret messages you are sending. Even if you are able to encrypt your messages perfectly, an adversary will still be able to tell <i>when</i> messages are sent which can reveal important information.
</p>
<p>
Suppose you are planning a protest and send many messages in the days leading up to the protest. For someone monitoring your communication, even if they don't know the content of the messages they can guess that you were somehow involved in the protest.
</p>
<p>
The solution to this problem is to send messages regularly. The messages can just be dummies most of the time, but then when you need to send a real message, an adversary won't be able to tell that anything is different.
</p>
<p>
This is the technique used by <a href="https://en.wikipedia.org/wiki/Numbers_station">numbers stations</a>, which are radio stations suspected to be run by governments to send messages to their spies abroad. The reason they are so mysterious is also the reason they are so effective: you have no idea if or when they are sending a real message.
</p>
<p>
--
The main requirement is that the messages which you do send are indistinguishable from random messages because otherwise an adversary could tell the real and fake messages apart.
</p>
<h2>Application Reference</h2>
<h3>Main Window</h3>
<img src="main-window-labelled.png"/>
<p>
The main window shows a label for the current station name (1) and a button to open the station selection window (2). The 'Settings' button (3) opens application settings, while the 'Station Settings' (5) button opens settings specific to the current selected station. The 'Help' button (4) should open this help document.
</p>
<p>
The message display area (6) shows the contents of the message which will be sent at the next scheduled time. This message can be edited, and then saved via (7).
</p>
<h3>Station Selection Window</h3>
<img src="station-selection-window.png"/>
<h3>Station Settings Window</h3>
The station name can be edited as well as group size used to break up messages for display.
Choosing the message length is important. You should aim to use a message length longer than the longest message you will send via the station. Ideally you should never have to adjust the message length after a station has started regular usage.
<h4>Upload Settings</h4>
<p class="caution">
The username an password entered here are stored unencrypted. Anyone with access to your computer account would be able to access the resources accessible via the credentials.
</p>
<p>
Currently two method of upload are supported: SFTP and wordpress.
</p>
<p>
SFTP uploads the file to the specified server as <code>www/message.txt</code>. It also generates an atom feed file and uploads it as <code>www/feed.xml</code> (subsequent runs will add to the feed file instead of overwriting it).
</p>
<p>
Wordpress will upload the message directly to the specified wordpress blog using XML-RPC. XML-RPC should be available on most wordpress installations, though it may need to be enabled.
</p>
<p>
Alternatively you can opt to run an external program to handle the message. The external program/script will recieve the path to message file as an argument. You could use this to run the message through a blog generator such as Pelican (Note that the external program will have to handle uploading the message as well).
</p>
<h4>Prefixes</h4>
<p>
Prefixes provide a way for the randomly generated messages to avoid using valid message identifiers. To do this, simply add message identifiers to the prefix list, dummy messages will subsequently be generated ensuring they don't start with the listed prefixes.
</p>
<p>
For background, one-time pad cypers typically use a message identifier as the first part of the message. This allows the recipient to determine which one-time pad to use for decryption. If a dummy message generated randomly accidentally starts with a valid message identifier, then the recipient might try to decrypt a nonsense message resulting in confusion.
</p>
<p>
The downside of storing the prefixes on the computer is that anyone with access to the computer (e.g. via malware) would be able to tell when a real message was sent (vs. otherwise they might only know <b>that</b> secret messages are likely being sent).
</p>
<p>
The alternative to providing prefixes is to use one-time pads with long enough message identifiers that the odds of a random message colliding with them is negligible.
</p>
<h4>Message Schedule</h4>
<p>
From the given start date and time, each station is run on the specified period. This means that it will upload the stored message according to the upload settings, then a new dummy message will be generated for the next time the station is run.
</p>
<p>
If the "Manage schedule externally" checkbox is ticked, then the Numbers Station application won't schedule the station to run. Instead, an external scheduler (e.g. Windows Task Scheduler, or cron for *nix systems) can be used. The station can be triggered by running <code>{numbers station executable} --station "{station name}"</code>. The application executable path can be found in the about screen.
</p>
</body>
</html>

BIN
src/main/resources/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View File

@ -0,0 +1,46 @@
.caution {
background-color: #fff3cd;
border-color: #ffeeba;
color: #856404;
border: 1px solid transparent;
border-radius: 4px;
padding: 1rem;
margin: 20px 0;
}
.caution::before {
content: "⚠ ";
Cautio
margin-right: 8px;
}
body {
font-family: system-ui, -apple-system, sans-serif;
line-height: 1.6;
color: #333;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
code {
background-color: #f5f5f5;
border-radius: 4px;
overflow-x: auto;
font-family: monospace;
margin: 20px 0;
}
h1, h2, h3 {
color: #222;
margin-bottom: 1rem;
}
img {
width: 100%;
max-width: 30em;
}
p {
margin-bottom: 1rem;
}