Compare commits
31 Commits
1.0.0
...
seba76/mas
Author | SHA1 | Date | |
---|---|---|---|
|
2c18f91d68 | ||
|
c7e02655b0 | ||
|
cb55d0148d | ||
|
0155cfb8fc | ||
|
68b0bf3eb9 | ||
|
c2c21e720f | ||
|
67b6e5b607 | ||
|
1a73981d20 | ||
|
79d04b4a58 | ||
|
617f1e658a | ||
|
7f73bd2cd1 | ||
|
d90ddc3be4 | ||
|
b644035433 | ||
|
c4291e6f44 | ||
|
2a0d41759b | ||
|
4e97e81b80 | ||
|
2a8a7e3c0c | ||
|
2b298d6e19 | ||
|
ecbde9509f | ||
|
1e1187e71f | ||
|
fe4ae354b2 | ||
|
294747def5 | ||
|
76031ee868 | ||
|
bba9051b4b | ||
|
012eeaa65f | ||
|
fde9a03887 | ||
|
ed5a43a0e8 | ||
|
5a4dfc01b6 | ||
|
6aa48fdd2f | ||
|
0a11d5a583 | ||
|
b66620c9da |
401
.gitignore
vendored
401
.gitignore
vendored
@@ -1,4 +1,399 @@
|
||||
bin/
|
||||
obj/
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
packages/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
*.ncb
|
||||
*.aps
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
/.idea
|
6
.run/Publish ntfysh_client to folder.run.xml
Normal file
6
.run/Publish ntfysh_client to folder.run.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Publish ntfysh_client to folder" type="DotNetFolderPublish" factoryName="Publish to folder">
|
||||
<riderPublish configuration="Release" delete_existing_files="true" platform="Any CPU" runtime="win-x86" target_folder="./bin/Publish/net6.0-windows" target_framework="net6.0-windows" uuid_high="6492169016564532222" uuid_low="-5168761336838336273" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Lucas Bortoli
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
26
README.md
26
README.md
@@ -1,7 +1,27 @@
|
||||
# ntfy.sh Windows
|
||||
|
||||

|
||||
ntfy.sh Windows is a small lightweight push notification client for notifications sent via https://ntfy.sh compatible servers.
|
||||
|
||||

|
||||
It is capable of receiving notifications from multiple ntfy.sh servers simultaneously via Websocket or HTTP and supports both unauthenticated and authenticated topics.
|
||||
|
||||
A [ntfy.sh](https://ntfy.sh/) client for Windows.
|
||||
## Screenshots
|
||||
### Main Application
|
||||

|
||||

|
||||

|
||||
|
||||
### Example Notifications
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## Command Line Parameters
|
||||
### -h and --help
|
||||
Show the help menu
|
||||
|
||||
### -t and --start-in-tray
|
||||
Start ntfy.sh Windows in the tray, useful for starting with Windows when logging in
|
||||
|
||||
### -m and --allow-multiple-instances
|
||||
Bypass the instance check to allow multiple instances of ntfy.sh Windows to start simultaneously
|
||||
|
101
ntfysh_client/AboutBox.Designer.cs
generated
101
ntfysh_client/AboutBox.Designer.cs
generated
@@ -29,53 +29,107 @@ namespace ntfysh_client
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutBox));
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.aboutPage = new System.Windows.Forms.TabPage();
|
||||
this.richTextBox2 = new System.Windows.Forms.RichTextBox();
|
||||
this.licensePage = new System.Windows.Forms.TabPage();
|
||||
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.aboutPage.SuspendLayout();
|
||||
this.licensePage.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(299, 173);
|
||||
this.button1.Location = new System.Drawing.Point(522, 243);
|
||||
this.button1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.Size = new System.Drawing.Size(88, 27);
|
||||
this.button1.TabIndex = 0;
|
||||
this.button1.Text = "Close";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 49);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(358, 65);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "Copyright © 2022 Lucas Bortoli\r\nAll rights reserved\r\n\r\nThe icons included in this" +
|
||||
" application are property of Microsoft Corporation.\r\n(Visual Studio Image Librar" +
|
||||
"y)";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label2.Location = new System.Drawing.Point(10, 9);
|
||||
this.label2.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.label2.Location = new System.Drawing.Point(12, 9);
|
||||
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(166, 30);
|
||||
this.label2.TabIndex = 2;
|
||||
this.label2.Text = "ntfy.sh Windows";
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
this.tabControl1.Controls.Add(this.aboutPage);
|
||||
this.tabControl1.Controls.Add(this.licensePage);
|
||||
this.tabControl1.Location = new System.Drawing.Point(12, 43);
|
||||
this.tabControl1.Name = "tabControl1";
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
this.tabControl1.Size = new System.Drawing.Size(598, 194);
|
||||
this.tabControl1.TabIndex = 3;
|
||||
//
|
||||
// aboutPage
|
||||
//
|
||||
this.aboutPage.Controls.Add(this.richTextBox2);
|
||||
this.aboutPage.Location = new System.Drawing.Point(4, 24);
|
||||
this.aboutPage.Name = "aboutPage";
|
||||
this.aboutPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.aboutPage.Size = new System.Drawing.Size(590, 166);
|
||||
this.aboutPage.TabIndex = 0;
|
||||
this.aboutPage.Text = "About";
|
||||
this.aboutPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// richTextBox2
|
||||
//
|
||||
this.richTextBox2.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.richTextBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.richTextBox2.Location = new System.Drawing.Point(6, 6);
|
||||
this.richTextBox2.Name = "richTextBox2";
|
||||
this.richTextBox2.ReadOnly = true;
|
||||
this.richTextBox2.Size = new System.Drawing.Size(578, 154);
|
||||
this.richTextBox2.TabIndex = 0;
|
||||
this.richTextBox2.Text = resources.GetString("richTextBox2.Text");
|
||||
//
|
||||
// licensePage
|
||||
//
|
||||
this.licensePage.Controls.Add(this.richTextBox1);
|
||||
this.licensePage.Location = new System.Drawing.Point(4, 24);
|
||||
this.licensePage.Name = "licensePage";
|
||||
this.licensePage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.licensePage.Size = new System.Drawing.Size(590, 166);
|
||||
this.licensePage.TabIndex = 1;
|
||||
this.licensePage.Text = "MIT License\n\n";
|
||||
this.licensePage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// richTextBox1
|
||||
//
|
||||
this.richTextBox1.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.richTextBox1.Location = new System.Drawing.Point(6, 6);
|
||||
this.richTextBox1.Name = "richTextBox1";
|
||||
this.richTextBox1.ReadOnly = true;
|
||||
this.richTextBox1.Size = new System.Drawing.Size(578, 154);
|
||||
this.richTextBox1.TabIndex = 0;
|
||||
this.richTextBox1.Text = resources.GetString("richTextBox1.Text");
|
||||
//
|
||||
// AboutBox
|
||||
//
|
||||
this.AcceptButton = this.button1;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.ClientSize = new System.Drawing.Size(386, 208);
|
||||
this.ClientSize = new System.Drawing.Size(622, 275);
|
||||
this.Controls.Add(this.tabControl1);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.button1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "AboutBox";
|
||||
@@ -83,6 +137,9 @@ namespace ntfysh_client
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "About";
|
||||
this.tabControl1.ResumeLayout(false);
|
||||
this.aboutPage.ResumeLayout(false);
|
||||
this.licensePage.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -91,7 +148,11 @@ namespace ntfysh_client
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TabControl tabControl1;
|
||||
private System.Windows.Forms.TabPage aboutPage;
|
||||
private System.Windows.Forms.TabPage licensePage;
|
||||
private System.Windows.Forms.RichTextBox richTextBox1;
|
||||
private System.Windows.Forms.RichTextBox richTextBox2;
|
||||
}
|
||||
}
|
@@ -1,11 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ntfysh_client
|
||||
|
@@ -1,64 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
@@ -117,4 +57,24 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="richTextBox2.Text" xml:space="preserve">
|
||||
<value>ntfy.sh Windows by Lucas Bortoli and Contributors
|
||||
|
||||
ntfy.sh Windows is a small lightweight push notification client for notifications sent via https://ntfy.sh compatible servers.
|
||||
|
||||
It is capable of receiving notifications from multiple ntfy.sh servers simultaneously via Websocket or HTTP and supports both unauthenticated and authenticated topics.
|
||||
|
||||
Get the latest release and keep track of updates via GitHub at https://github.com/lucas-bortoli/ntfysh-windows</value>
|
||||
</data>
|
||||
<data name="richTextBox1.Text" xml:space="preserve">
|
||||
<value>Copyright © 2022 Lucas Bortoli
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
The icons included in this application are property of Microsoft Corporation (Visual Studio Image Library)</value>
|
||||
</data>
|
||||
</root>
|
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
237
ntfysh_client/Form1.Designer.cs
generated
237
ntfysh_client/Form1.Designer.cs
generated
@@ -1,237 +0,0 @@
|
||||
|
||||
namespace ntfysh_client
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
|
||||
this.subscribeNewTopic = new System.Windows.Forms.Button();
|
||||
this.removeSelectedTopics = new System.Windows.Forms.Button();
|
||||
this.notificationTopics = new System.Windows.Forms.ListBox();
|
||||
this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
|
||||
this.trayContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.showControlWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.exitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ntfyshWebsiteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.trayContextMenu.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// subscribeNewTopic
|
||||
//
|
||||
this.subscribeNewTopic.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.subscribeNewTopic.Location = new System.Drawing.Point(236, 50);
|
||||
this.subscribeNewTopic.Name = "subscribeNewTopic";
|
||||
this.subscribeNewTopic.Size = new System.Drawing.Size(105, 23);
|
||||
this.subscribeNewTopic.TabIndex = 2;
|
||||
this.subscribeNewTopic.Text = "Add";
|
||||
this.subscribeNewTopic.UseVisualStyleBackColor = true;
|
||||
this.subscribeNewTopic.Click += new System.EventHandler(this.subscribeNewTopic_Click);
|
||||
//
|
||||
// removeSelectedTopics
|
||||
//
|
||||
this.removeSelectedTopics.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.removeSelectedTopics.Enabled = false;
|
||||
this.removeSelectedTopics.Location = new System.Drawing.Point(236, 79);
|
||||
this.removeSelectedTopics.Name = "removeSelectedTopics";
|
||||
this.removeSelectedTopics.Size = new System.Drawing.Size(105, 23);
|
||||
this.removeSelectedTopics.TabIndex = 0;
|
||||
this.removeSelectedTopics.Text = "Remove selected";
|
||||
this.removeSelectedTopics.UseVisualStyleBackColor = true;
|
||||
this.removeSelectedTopics.Click += new System.EventHandler(this.removeSelectedTopics_Click);
|
||||
//
|
||||
// notificationTopics
|
||||
//
|
||||
this.notificationTopics.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.notificationTopics.FormattingEnabled = true;
|
||||
this.notificationTopics.Location = new System.Drawing.Point(12, 50);
|
||||
this.notificationTopics.Name = "notificationTopics";
|
||||
this.notificationTopics.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
|
||||
this.notificationTopics.Size = new System.Drawing.Size(145, 173);
|
||||
this.notificationTopics.TabIndex = 3;
|
||||
this.notificationTopics.Click += new System.EventHandler(this.notificationTopics_Click);
|
||||
this.notificationTopics.SelectedValueChanged += new System.EventHandler(this.notificationTopics_SelectedValueChanged);
|
||||
//
|
||||
// notifyIcon
|
||||
//
|
||||
this.notifyIcon.ContextMenuStrip = this.trayContextMenu;
|
||||
this.notifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon.Icon")));
|
||||
this.notifyIcon.Text = "ntfy.sh";
|
||||
this.notifyIcon.Visible = true;
|
||||
this.notifyIcon.Click += new System.EventHandler(this.notifyIcon_Click);
|
||||
//
|
||||
// trayContextMenu
|
||||
//
|
||||
this.trayContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.showControlWindowToolStripMenuItem,
|
||||
this.exitToolStripMenuItem});
|
||||
this.trayContextMenu.Name = "trayContextMenu";
|
||||
this.trayContextMenu.Size = new System.Drawing.Size(190, 48);
|
||||
//
|
||||
// showControlWindowToolStripMenuItem
|
||||
//
|
||||
this.showControlWindowToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("showControlWindowToolStripMenuItem.Image")));
|
||||
this.showControlWindowToolStripMenuItem.Name = "showControlWindowToolStripMenuItem";
|
||||
this.showControlWindowToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
|
||||
this.showControlWindowToolStripMenuItem.Text = "Show control window";
|
||||
this.showControlWindowToolStripMenuItem.Click += new System.EventHandler(this.showControlWindowToolStripMenuItem_Click);
|
||||
//
|
||||
// exitToolStripMenuItem
|
||||
//
|
||||
this.exitToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("exitToolStripMenuItem.Image")));
|
||||
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
||||
this.exitToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
|
||||
this.exitToolStripMenuItem.Text = "Exit";
|
||||
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.BackColor = System.Drawing.Color.White;
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.helpToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(353, 24);
|
||||
this.menuStrip1.TabIndex = 4;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.exitToolStripMenuItem1});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// helpToolStripMenuItem
|
||||
//
|
||||
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.ntfyshWebsiteToolStripMenuItem,
|
||||
this.toolStripMenuItem1,
|
||||
this.aboutToolStripMenuItem});
|
||||
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
|
||||
this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
|
||||
this.helpToolStripMenuItem.Text = "Help";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 34);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(145, 13);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "Subscribed notification topics";
|
||||
//
|
||||
// exitToolStripMenuItem1
|
||||
//
|
||||
this.exitToolStripMenuItem1.Image = ((System.Drawing.Image)(resources.GetObject("exitToolStripMenuItem1.Image")));
|
||||
this.exitToolStripMenuItem1.Name = "exitToolStripMenuItem1";
|
||||
this.exitToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
|
||||
this.exitToolStripMenuItem1.Text = "Exit";
|
||||
//
|
||||
// aboutToolStripMenuItem
|
||||
//
|
||||
this.aboutToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("aboutToolStripMenuItem.Image")));
|
||||
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
|
||||
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
||||
this.aboutToolStripMenuItem.Text = "About";
|
||||
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
|
||||
//
|
||||
// ntfyshWebsiteToolStripMenuItem
|
||||
//
|
||||
this.ntfyshWebsiteToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("ntfyshWebsiteToolStripMenuItem.Image")));
|
||||
this.ntfyshWebsiteToolStripMenuItem.Name = "ntfyshWebsiteToolStripMenuItem";
|
||||
this.ntfyshWebsiteToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
||||
this.ntfyshWebsiteToolStripMenuItem.Text = "Open ntfy.sh website";
|
||||
this.ntfyshWebsiteToolStripMenuItem.Click += new System.EventHandler(this.ntfyshWebsiteToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(182, 6);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.ClientSize = new System.Drawing.Size(353, 236);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.Controls.Add(this.notificationTopics);
|
||||
this.Controls.Add(this.removeSelectedTopics);
|
||||
this.Controls.Add(this.subscribeNewTopic);
|
||||
this.Controls.Add(this.label1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.KeyPreview = true;
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "Form1";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "ntfy.sh";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
|
||||
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
this.trayContextMenu.ResumeLayout(false);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.Button subscribeNewTopic;
|
||||
private System.Windows.Forms.Button removeSelectedTopics;
|
||||
private System.Windows.Forms.ListBox notificationTopics;
|
||||
private System.Windows.Forms.NotifyIcon notifyIcon;
|
||||
private System.Windows.Forms.ContextMenuStrip trayContextMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem showControlWindowToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ntfyshWebsiteToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
|
||||
}
|
||||
}
|
||||
|
@@ -1,167 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ntfysh_client
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
private NotificationListener notificationListener;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
notificationListener = new NotificationListener();
|
||||
notificationListener.OnNotificationReceive += OnNotificationReceive;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.LoadTopics();
|
||||
}
|
||||
|
||||
private void subscribeNewTopic_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var dialog = new SubscribeDialog())
|
||||
{
|
||||
var result = dialog.ShowDialog();
|
||||
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
notificationListener.SubscribeToTopic(dialog.getTopicId());
|
||||
notificationTopics.Items.Add(dialog.getTopicId());
|
||||
this.SaveTopicsToFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeSelectedTopics_Click(object sender, EventArgs e)
|
||||
{
|
||||
while (notificationTopics.SelectedIndex > -1)
|
||||
{
|
||||
var topicId = notificationTopics.Items[notificationTopics.SelectedIndex];
|
||||
notificationListener.RemoveTopic((string)topicId);
|
||||
notificationTopics.Items.RemoveAt(notificationTopics.SelectedIndex);
|
||||
}
|
||||
|
||||
this.SaveTopicsToFile();
|
||||
}
|
||||
|
||||
private void notificationTopics_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
removeSelectedTopics.Enabled = notificationTopics.SelectedIndices.Count > 0;
|
||||
}
|
||||
|
||||
private void notificationTopics_Click(object sender, EventArgs e)
|
||||
{
|
||||
var ev = (MouseEventArgs)e;
|
||||
var clickedItemIndex = notificationTopics.IndexFromPoint(new Point(ev.X, ev.Y));
|
||||
|
||||
if (clickedItemIndex == -1)
|
||||
{
|
||||
notificationTopics.ClearSelected();
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Visible = false;
|
||||
}
|
||||
|
||||
private void notifyIcon_Click(object sender, EventArgs e)
|
||||
{
|
||||
var mouseEv = (MouseEventArgs)e;
|
||||
if (mouseEv.Button == MouseButtons.Left)
|
||||
{
|
||||
this.Visible = !this.Visible;
|
||||
this.BringToFront();
|
||||
}
|
||||
}
|
||||
|
||||
private void showControlWindowToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Visible = true;
|
||||
this.BringToFront();
|
||||
}
|
||||
|
||||
private string GetTopicsFilePath()
|
||||
{
|
||||
string binaryDirectory = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
return Path.Combine(binaryDirectory, "topics.txt");
|
||||
}
|
||||
|
||||
private void SaveTopicsToFile()
|
||||
{
|
||||
using (StreamWriter writer = new StreamWriter(GetTopicsFilePath()))
|
||||
{
|
||||
foreach (string topic in notificationTopics.Items)
|
||||
{
|
||||
writer.WriteLine(topic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadTopics()
|
||||
{
|
||||
if (!File.Exists(GetTopicsFilePath())) return;
|
||||
using (StreamReader reader = new StreamReader(GetTopicsFilePath()))
|
||||
{
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
var topic = reader.ReadLine();
|
||||
notificationListener.SubscribeToTopic(topic);
|
||||
notificationTopics.Items.Add(topic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnNotificationReceive(object sender, NotificationReceiveEventArgs e)
|
||||
{
|
||||
notifyIcon.ShowBalloonTip(3000, e.Title, e.Message, ToolTipIcon.Info);
|
||||
}
|
||||
|
||||
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
notifyIcon.Dispose();
|
||||
}
|
||||
|
||||
private bool trueExit = false;
|
||||
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
// Let it close
|
||||
if (trueExit) return;
|
||||
|
||||
if (e.CloseReason == CloseReason.UserClosing)
|
||||
{
|
||||
this.Visible = false;
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
trueExit = true;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void ntfyshWebsiteToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
System.Diagnostics.Process.Start("https://ntfy.sh/");
|
||||
}
|
||||
|
||||
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var d = new AboutBox();
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
270
ntfysh_client/MainForm.Designer.cs
generated
Normal file
270
ntfysh_client/MainForm.Designer.cs
generated
Normal file
@@ -0,0 +1,270 @@
|
||||
|
||||
namespace ntfysh_client
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||
subscribeNewTopic = new System.Windows.Forms.Button();
|
||||
removeSelectedTopics = new System.Windows.Forms.Button();
|
||||
notificationTopics = new System.Windows.Forms.ListBox();
|
||||
topicContextMenu = new System.Windows.Forms.ContextMenuStrip(components);
|
||||
sendNotificationMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
notifyIcon = new System.Windows.Forms.NotifyIcon(components);
|
||||
trayContextMenu = new System.Windows.Forms.ContextMenuStrip(components);
|
||||
showControlWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
exitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
ntfyshWebsiteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
label1 = new System.Windows.Forms.Label();
|
||||
toolTip = new System.Windows.Forms.ToolTip(components);
|
||||
topicContextMenu.SuspendLayout();
|
||||
trayContextMenu.SuspendLayout();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// subscribeNewTopic
|
||||
//
|
||||
subscribeNewTopic.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
|
||||
subscribeNewTopic.Location = new System.Drawing.Point(211, 251);
|
||||
subscribeNewTopic.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
subscribeNewTopic.Name = "subscribeNewTopic";
|
||||
subscribeNewTopic.Size = new System.Drawing.Size(188, 27);
|
||||
subscribeNewTopic.TabIndex = 2;
|
||||
subscribeNewTopic.Text = "Add";
|
||||
subscribeNewTopic.UseVisualStyleBackColor = true;
|
||||
subscribeNewTopic.Click += subscribeNewTopic_Click;
|
||||
//
|
||||
// removeSelectedTopics
|
||||
//
|
||||
removeSelectedTopics.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
|
||||
removeSelectedTopics.Enabled = false;
|
||||
removeSelectedTopics.Location = new System.Drawing.Point(13, 251);
|
||||
removeSelectedTopics.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
removeSelectedTopics.Name = "removeSelectedTopics";
|
||||
removeSelectedTopics.Size = new System.Drawing.Size(188, 27);
|
||||
removeSelectedTopics.TabIndex = 0;
|
||||
removeSelectedTopics.Text = "Remove selected";
|
||||
removeSelectedTopics.UseVisualStyleBackColor = true;
|
||||
removeSelectedTopics.Click += removeSelectedTopics_Click;
|
||||
//
|
||||
// notificationTopics
|
||||
//
|
||||
notificationTopics.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
notificationTopics.ContextMenuStrip = topicContextMenu;
|
||||
notificationTopics.FormattingEnabled = true;
|
||||
notificationTopics.ItemHeight = 15;
|
||||
notificationTopics.Location = new System.Drawing.Point(13, 46);
|
||||
notificationTopics.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
notificationTopics.Name = "notificationTopics";
|
||||
notificationTopics.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
|
||||
notificationTopics.Size = new System.Drawing.Size(386, 199);
|
||||
notificationTopics.TabIndex = 3;
|
||||
toolTip.SetToolTip(notificationTopics, "Double click topic to send message");
|
||||
notificationTopics.Click += notificationTopics_Click;
|
||||
notificationTopics.SelectedValueChanged += notificationTopics_SelectedValueChanged;
|
||||
notificationTopics.MouseDoubleClick += notificationTopics_MouseDoubleClick;
|
||||
//
|
||||
// topicContextMenu
|
||||
//
|
||||
topicContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { sendNotificationMenuItem });
|
||||
topicContextMenu.Name = "topicContextMenu";
|
||||
topicContextMenu.Size = new System.Drawing.Size(181, 48);
|
||||
//
|
||||
// sendNotificationMenuItem
|
||||
//
|
||||
sendNotificationMenuItem.Image = (System.Drawing.Image)resources.GetObject("sendNotificationMenuItem.Image");
|
||||
sendNotificationMenuItem.Name = "sendNotificationMenuItem";
|
||||
sendNotificationMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
sendNotificationMenuItem.Text = "Send Notification";
|
||||
sendNotificationMenuItem.Click += SendNotificationMenuItem_Click;
|
||||
//
|
||||
// notifyIcon
|
||||
//
|
||||
notifyIcon.ContextMenuStrip = trayContextMenu;
|
||||
notifyIcon.Icon = (System.Drawing.Icon)resources.GetObject("notifyIcon.Icon");
|
||||
notifyIcon.Text = "ntfy.sh";
|
||||
notifyIcon.Visible = true;
|
||||
notifyIcon.Click += notifyIcon_Click;
|
||||
//
|
||||
// trayContextMenu
|
||||
//
|
||||
trayContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { showControlWindowToolStripMenuItem, exitToolStripMenuItem });
|
||||
trayContextMenu.Name = "trayContextMenu";
|
||||
trayContextMenu.Size = new System.Drawing.Size(190, 48);
|
||||
//
|
||||
// showControlWindowToolStripMenuItem
|
||||
//
|
||||
showControlWindowToolStripMenuItem.Image = (System.Drawing.Image)resources.GetObject("showControlWindowToolStripMenuItem.Image");
|
||||
showControlWindowToolStripMenuItem.Name = "showControlWindowToolStripMenuItem";
|
||||
showControlWindowToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
|
||||
showControlWindowToolStripMenuItem.Text = "Show control window";
|
||||
showControlWindowToolStripMenuItem.Click += showControlWindowToolStripMenuItem_Click;
|
||||
//
|
||||
// exitToolStripMenuItem
|
||||
//
|
||||
exitToolStripMenuItem.Image = (System.Drawing.Image)resources.GetObject("exitToolStripMenuItem.Image");
|
||||
exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
||||
exitToolStripMenuItem.Size = new System.Drawing.Size(189, 22);
|
||||
exitToolStripMenuItem.Text = "Exit";
|
||||
exitToolStripMenuItem.Click += exitToolStripMenuItem_Click;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.BackColor = System.Drawing.Color.White;
|
||||
menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { fileToolStripMenuItem, helpToolStripMenuItem });
|
||||
menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2);
|
||||
menuStrip1.Size = new System.Drawing.Size(412, 24);
|
||||
menuStrip1.TabIndex = 4;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { exitToolStripMenuItem1, settingsToolStripMenuItem });
|
||||
fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// exitToolStripMenuItem1
|
||||
//
|
||||
exitToolStripMenuItem1.Image = (System.Drawing.Image)resources.GetObject("exitToolStripMenuItem1.Image");
|
||||
exitToolStripMenuItem1.Name = "exitToolStripMenuItem1";
|
||||
exitToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
|
||||
exitToolStripMenuItem1.Text = "Exit";
|
||||
exitToolStripMenuItem1.Click += exitToolStripMenuItem1_Click;
|
||||
//
|
||||
// settingsToolStripMenuItem
|
||||
//
|
||||
settingsToolStripMenuItem.Image = (System.Drawing.Image)resources.GetObject("settingsToolStripMenuItem.Image");
|
||||
settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
|
||||
settingsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
settingsToolStripMenuItem.Text = "Settings";
|
||||
settingsToolStripMenuItem.Click += settingsToolStripMenuItem_Click;
|
||||
//
|
||||
// helpToolStripMenuItem
|
||||
//
|
||||
helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { ntfyshWebsiteToolStripMenuItem, toolStripMenuItem1, aboutToolStripMenuItem });
|
||||
helpToolStripMenuItem.Name = "helpToolStripMenuItem";
|
||||
helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
|
||||
helpToolStripMenuItem.Text = "Help";
|
||||
//
|
||||
// ntfyshWebsiteToolStripMenuItem
|
||||
//
|
||||
ntfyshWebsiteToolStripMenuItem.Image = (System.Drawing.Image)resources.GetObject("ntfyshWebsiteToolStripMenuItem.Image");
|
||||
ntfyshWebsiteToolStripMenuItem.Name = "ntfyshWebsiteToolStripMenuItem";
|
||||
ntfyshWebsiteToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
||||
ntfyshWebsiteToolStripMenuItem.Text = "Open ntfy.sh website";
|
||||
ntfyshWebsiteToolStripMenuItem.Click += ntfyshWebsiteToolStripMenuItem_Click;
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
toolStripMenuItem1.Size = new System.Drawing.Size(182, 6);
|
||||
//
|
||||
// aboutToolStripMenuItem
|
||||
//
|
||||
aboutToolStripMenuItem.Image = (System.Drawing.Image)resources.GetObject("aboutToolStripMenuItem.Image");
|
||||
aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
|
||||
aboutToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
|
||||
aboutToolStripMenuItem.Text = "About";
|
||||
aboutToolStripMenuItem.Click += aboutToolStripMenuItem_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new System.Drawing.Point(13, 27);
|
||||
label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new System.Drawing.Size(171, 15);
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = "Subscribed Notification Topics:";
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
BackColor = System.Drawing.Color.White;
|
||||
ClientSize = new System.Drawing.Size(412, 288);
|
||||
Controls.Add(menuStrip1);
|
||||
Controls.Add(notificationTopics);
|
||||
Controls.Add(removeSelectedTopics);
|
||||
Controls.Add(subscribeNewTopic);
|
||||
Controls.Add(label1);
|
||||
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
|
||||
KeyPreview = true;
|
||||
MainMenuStrip = menuStrip1;
|
||||
Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
Name = "MainForm";
|
||||
StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
Text = "ntfy.sh";
|
||||
FormClosing += MainForm_FormClosing;
|
||||
FormClosed += MainForm_FormClosed;
|
||||
Load += MainForm_Load;
|
||||
topicContextMenu.ResumeLayout(false);
|
||||
trayContextMenu.ResumeLayout(false);
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.Button subscribeNewTopic;
|
||||
private System.Windows.Forms.Button removeSelectedTopics;
|
||||
private System.Windows.Forms.ListBox notificationTopics;
|
||||
private System.Windows.Forms.NotifyIcon notifyIcon;
|
||||
private System.Windows.Forms.ContextMenuStrip trayContextMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem showControlWindowToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ntfyshWebsiteToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
|
||||
private System.Windows.Forms.ContextMenuStrip topicContextMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem sendNotificationMenuItem;
|
||||
private System.Windows.Forms.ToolTip toolTip;
|
||||
}
|
||||
}
|
||||
|
446
ntfysh_client/MainForm.cs
Normal file
446
ntfysh_client/MainForm.cs
Normal file
@@ -0,0 +1,446 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Newtonsoft.Json;
|
||||
using ntfysh_client.Notifications;
|
||||
|
||||
namespace ntfysh_client
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private readonly NotificationListener _notificationListener;
|
||||
private bool _startInTray;
|
||||
private bool _trueExit;
|
||||
|
||||
public MainForm(NotificationListener notificationListener, bool startInTray = false)
|
||||
{
|
||||
_notificationListener = notificationListener;
|
||||
_startInTray = startInTray;
|
||||
_notificationListener.OnNotificationReceive += OnNotificationReceive;
|
||||
_notificationListener.OnConnectionMultiAttemptFailure += OnConnectionMultiAttemptFailure;
|
||||
_notificationListener.OnConnectionCredentialsFailure += OnConnectionCredentialsFailure;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadSettings();
|
||||
LoadTopics();
|
||||
}
|
||||
|
||||
protected override void SetVisibleCore(bool value)
|
||||
{
|
||||
if (_startInTray)
|
||||
{
|
||||
_startInTray = false;
|
||||
|
||||
/*
|
||||
* TODO This little workaround prevents the window from appearing with a flash, but the taskbar icon appears for a moment.
|
||||
*
|
||||
* TODO This is because we must call SetVisibleCore(true) for the initial load events in the MainForm to fire, which is what triggers the listener
|
||||
*/
|
||||
Opacity = 0;
|
||||
base.SetVisibleCore(true);
|
||||
base.SetVisibleCore(false);
|
||||
Opacity = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
base.SetVisibleCore(value);
|
||||
}
|
||||
|
||||
private void OnNotificationReceive(object sender, NotificationReceiveEventArgs e)
|
||||
{
|
||||
ToolTipIcon priorityIcon = e.Priority switch
|
||||
{
|
||||
NotificationPriority.Max => ToolTipIcon.Error,
|
||||
NotificationPriority.High => ToolTipIcon.Warning,
|
||||
NotificationPriority.Default => ToolTipIcon.Info,
|
||||
NotificationPriority.Low => ToolTipIcon.Info,
|
||||
NotificationPriority.Min => ToolTipIcon.None,
|
||||
_ => throw new ArgumentOutOfRangeException("Unknown priority received")
|
||||
};
|
||||
|
||||
string finalTitle = string.IsNullOrWhiteSpace(e.Title) ? $"{e.Sender.TopicId}@{e.Sender.ServerUrl}" : e.Title;
|
||||
|
||||
notifyIcon.ShowBalloonTip((int)TimeSpan.FromSeconds((double)Program.Settings.Timeout).TotalMilliseconds, finalTitle, e.Message, priorityIcon);
|
||||
}
|
||||
|
||||
private void OnConnectionMultiAttemptFailure(NotificationListener sender, SubscribedTopic topic)
|
||||
{
|
||||
MessageBox.Show($"Connecting to topic ID '{topic.TopicId}' on server '{topic.ServerUrl}' failed after multiple attempts.\n\nThis topic ID will be ignored and you will not receive notifications for it until you restart the application.", "Connection Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
private void OnConnectionCredentialsFailure(NotificationListener sender, SubscribedTopic topic)
|
||||
{
|
||||
string reason = string.IsNullOrWhiteSpace(topic.Username) ? "credentials are required but were not provided" : "the entered credentials are incorrect";
|
||||
|
||||
MessageBox.Show($"Connecting to topic ID '{topic.TopicId}' on server '{topic.ServerUrl}' failed because {reason}.\n\nThis topic ID will be ignored and you will not receive notifications for it until you correct the credentials.", "Connection Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
private void subscribeNewTopic_Click(object sender, EventArgs e)
|
||||
{
|
||||
using SubscribeDialog dialog = new SubscribeDialog(notificationTopics);
|
||||
DialogResult result = dialog.ShowDialog();
|
||||
|
||||
//Do not subscribe on cancelled dialog
|
||||
if (result != DialogResult.OK) return;
|
||||
|
||||
//Convert the reconnection values to ints
|
||||
int reconnectAttempts = Convert.ToInt32(Math.Ceiling(Program.Settings.ReconnectAttempts));
|
||||
int reconnectAttemptDelay = Convert.ToInt32(Math.Ceiling(Program.Settings.ReconnectAttemptDelay));
|
||||
|
||||
//Subscribe
|
||||
if (dialog.UseWebsockets)
|
||||
{
|
||||
_notificationListener.SubscribeToTopicUsingWebsocket(dialog.Unique, dialog.TopicId, dialog.ServerUrl, dialog.Username, dialog.Password, reconnectAttempts, reconnectAttemptDelay);
|
||||
}
|
||||
else
|
||||
{
|
||||
_notificationListener.SubscribeToTopicUsingLongHttpJson(dialog.Unique, dialog.TopicId, dialog.ServerUrl, dialog.Username, dialog.Password, reconnectAttempts, reconnectAttemptDelay);
|
||||
}
|
||||
|
||||
//Add to the user visible list
|
||||
notificationTopics.Items.Add(dialog.Unique);
|
||||
|
||||
//Save the topics persistently
|
||||
SaveTopicsToFile();
|
||||
}
|
||||
|
||||
private async void removeSelectedTopics_Click(object sender, EventArgs e)
|
||||
{
|
||||
while (notificationTopics.SelectedIndex > -1)
|
||||
{
|
||||
string topicUniqueString = (string)notificationTopics.Items[notificationTopics.SelectedIndex];
|
||||
|
||||
await _notificationListener.UnsubscribeFromTopicAsync(topicUniqueString);
|
||||
notificationTopics.Items.Remove(topicUniqueString);
|
||||
}
|
||||
|
||||
SaveTopicsToFile();
|
||||
}
|
||||
|
||||
private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using SettingsDialog dialog = new();
|
||||
|
||||
//Load current settings into dialog
|
||||
dialog.Timeout = Program.Settings.Timeout;
|
||||
dialog.ReconnectAttempts = Program.Settings.ReconnectAttempts;
|
||||
dialog.ReconnectAttemptDelay = Program.Settings.ReconnectAttemptDelay;
|
||||
|
||||
//Show dialog
|
||||
DialogResult result = dialog.ShowDialog();
|
||||
|
||||
//Do not save on cancelled dialog
|
||||
if (result != DialogResult.OK) return;
|
||||
|
||||
//Read new settings from dialog
|
||||
Program.Settings.Timeout = dialog.Timeout;
|
||||
Program.Settings.ReconnectAttempts = dialog.ReconnectAttempts;
|
||||
Program.Settings.ReconnectAttemptDelay = dialog.ReconnectAttemptDelay;
|
||||
|
||||
//Save new settings persistently
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void notificationTopics_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
removeSelectedTopics.Enabled = notificationTopics.SelectedIndices.Count > 0;
|
||||
}
|
||||
|
||||
private void notificationTopics_Click(object sender, EventArgs e)
|
||||
{
|
||||
MouseEventArgs ev = (MouseEventArgs)e;
|
||||
int clickedItemIndex = notificationTopics.IndexFromPoint(new Point(ev.X, ev.Y));
|
||||
|
||||
if (clickedItemIndex == -1) notificationTopics.ClearSelected();
|
||||
}
|
||||
|
||||
private void notifyIcon_Click(object sender, EventArgs e)
|
||||
{
|
||||
MouseEventArgs mouseEv = (MouseEventArgs)e;
|
||||
|
||||
if (mouseEv.Button != MouseButtons.Left) return;
|
||||
|
||||
Visible = !Visible;
|
||||
BringToFront();
|
||||
}
|
||||
|
||||
private void showControlWindowToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Visible = true;
|
||||
BringToFront();
|
||||
}
|
||||
|
||||
private string GetTopicsFilePath()
|
||||
{
|
||||
string binaryDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? throw new InvalidOperationException("Unable to determine path for application");
|
||||
return Path.Combine(binaryDirectory ?? throw new InvalidOperationException("Unable to determine path for topics file"), "topics.json");
|
||||
}
|
||||
|
||||
private string GetLegacyTopicsFilePath()
|
||||
{
|
||||
string binaryDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? throw new InvalidOperationException("Unable to determine path for application");
|
||||
return Path.Combine(binaryDirectory ?? throw new InvalidOperationException("Unable to determine path for legacy topics file"), "topics.txt");
|
||||
}
|
||||
|
||||
private void SaveTopicsToFile()
|
||||
{
|
||||
string topicsSerialised = JsonConvert.SerializeObject(_notificationListener.SubscribedTopicsByUnique.Select(st => st.Value).ToList(), Formatting.Indented);
|
||||
|
||||
File.WriteAllText(GetTopicsFilePath(), topicsSerialised);
|
||||
}
|
||||
|
||||
private string GetSettingsFilePath()
|
||||
{
|
||||
string binaryDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? throw new InvalidOperationException("Unable to determine path for application");
|
||||
return Path.Combine(binaryDirectory ?? throw new InvalidOperationException("Unable to determine path for settings file"), "settings.json");
|
||||
}
|
||||
|
||||
private void SaveSettingsToFile()
|
||||
{
|
||||
string settingsSerialised = JsonConvert.SerializeObject(Program.Settings, Formatting.Indented);
|
||||
|
||||
File.WriteAllText(GetSettingsFilePath(), settingsSerialised);
|
||||
}
|
||||
|
||||
private void LoadTopics()
|
||||
{
|
||||
string legacyTopicsPath = GetLegacyTopicsFilePath();
|
||||
string topicsFilePath = GetTopicsFilePath();
|
||||
|
||||
//If we have an old format topics file. Convert it to the new format!
|
||||
if (File.Exists(legacyTopicsPath))
|
||||
{
|
||||
//Read old format
|
||||
List<string> legacyTopics = new List<string>();
|
||||
|
||||
using (StreamReader reader = new StreamReader(legacyTopicsPath))
|
||||
{
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
string? legacyTopic = reader.ReadLine();
|
||||
if (!string.IsNullOrWhiteSpace(legacyTopic)) legacyTopics.Add(legacyTopic);
|
||||
}
|
||||
}
|
||||
|
||||
//Assemble new format
|
||||
List<SubscribedTopic> newTopics = legacyTopics.Select(lt => new SubscribedTopic(lt, "https://ntfy.sh", null, null)).ToList();
|
||||
|
||||
string newFormatSerialised = JsonConvert.SerializeObject(newTopics, Formatting.Indented);
|
||||
|
||||
//Write new format
|
||||
File.WriteAllText(topicsFilePath, newFormatSerialised);
|
||||
|
||||
//Delete old format
|
||||
File.Delete(legacyTopicsPath);
|
||||
}
|
||||
|
||||
//Check if we have any topics file on disk to load
|
||||
if (!File.Exists(topicsFilePath)) return;
|
||||
|
||||
//We have a topics file. Load it!
|
||||
string topicsSerialised = File.ReadAllText(topicsFilePath);
|
||||
|
||||
//Check if the file is empty
|
||||
if (string.IsNullOrWhiteSpace(topicsSerialised))
|
||||
{
|
||||
//The file is empty. May as well remove it and consider it nonexistent
|
||||
File.Delete(topicsFilePath);
|
||||
return;
|
||||
}
|
||||
|
||||
//Deserialise the topics
|
||||
List<SubscribedTopic>? topics = JsonConvert.DeserializeObject<List<SubscribedTopic>>(topicsSerialised);
|
||||
|
||||
if (topics is null)
|
||||
{
|
||||
//TODO Deserialise error!
|
||||
return;
|
||||
}
|
||||
|
||||
//Convert the reconnection values to ints
|
||||
int reconnectAttempts = Convert.ToInt32(Math.Ceiling(Program.Settings.ReconnectAttempts));
|
||||
int reconnectAttemptDelay = Convert.ToInt32(Math.Ceiling(Program.Settings.ReconnectAttemptDelay));
|
||||
|
||||
//Load them in
|
||||
foreach (SubscribedTopic topic in topics)
|
||||
{
|
||||
string[] parts = topic.ServerUrl.Split("://", 2);
|
||||
|
||||
switch (parts[0].ToLower())
|
||||
{
|
||||
case "ws":
|
||||
case "wss":
|
||||
_notificationListener.SubscribeToTopicUsingWebsocket($"{topic.TopicId}@{topic.ServerUrl}", topic.TopicId, topic.ServerUrl, topic.Username, topic.Password, reconnectAttempts, reconnectAttemptDelay);
|
||||
break;
|
||||
|
||||
case "http":
|
||||
case "https":
|
||||
_notificationListener.SubscribeToTopicUsingLongHttpJson($"{topic.TopicId}@{topic.ServerUrl}", topic.TopicId, topic.ServerUrl, topic.Username, topic.Password, reconnectAttempts, reconnectAttemptDelay);
|
||||
break;
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
notificationTopics.Items.Add($"{topic.TopicId}@{topic.ServerUrl}");
|
||||
}
|
||||
}
|
||||
|
||||
private SettingsModel GetDefaultSettings() => new()
|
||||
{
|
||||
Revision = 1,
|
||||
Timeout = 5,
|
||||
ReconnectAttempts = 10,
|
||||
ReconnectAttemptDelay = 3
|
||||
};
|
||||
|
||||
private void MergeSettingsRevisions(SettingsModel older, SettingsModel newer)
|
||||
{
|
||||
//Apply settings introduced in Revision 1
|
||||
if (older.Revision < 1)
|
||||
{
|
||||
older.ReconnectAttempts = newer.ReconnectAttempts;
|
||||
older.ReconnectAttemptDelay = newer.ReconnectAttemptDelay;
|
||||
}
|
||||
|
||||
//Update the revision
|
||||
older.Revision = newer.Revision;
|
||||
}
|
||||
|
||||
private void LoadSettings()
|
||||
{
|
||||
string settingsFilePath = GetSettingsFilePath();
|
||||
SettingsModel defaultSettings = GetDefaultSettings();
|
||||
|
||||
//Check if we have any settings file on disk to load. If we don't, initialise defaults
|
||||
if (!File.Exists(settingsFilePath))
|
||||
{
|
||||
Program.Settings = defaultSettings;
|
||||
|
||||
SaveSettingsToFile();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//We have a settings file. Load it!
|
||||
string settingsSerialised = File.ReadAllText(settingsFilePath);
|
||||
|
||||
//Check if the file is empty. If it is, initialise default settings
|
||||
if (string.IsNullOrWhiteSpace(settingsSerialised))
|
||||
{
|
||||
Program.Settings = defaultSettings;
|
||||
|
||||
SaveSettingsToFile();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//Deserialise the settings
|
||||
SettingsModel? settings = JsonConvert.DeserializeObject<SettingsModel?>(settingsSerialised);
|
||||
|
||||
//Check if the deserialise succeeded. If it didn't, initialise default settings
|
||||
if (settings is null)
|
||||
{
|
||||
Program.Settings = defaultSettings;
|
||||
|
||||
SaveSettingsToFile();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Program.Settings = settings;
|
||||
|
||||
//Check the settings revision. If it is older than the current latest revision, apply the settings defaults missing from previous revision
|
||||
if (Program.Settings.Revision < defaultSettings.ReconnectAttempts)
|
||||
{
|
||||
MergeSettingsRevisions(Program.Settings, defaultSettings);
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
}
|
||||
|
||||
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
notifyIcon.Dispose();
|
||||
}
|
||||
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
// Let it close
|
||||
if (_trueExit) return;
|
||||
|
||||
if (e.CloseReason != CloseReason.UserClosing) return;
|
||||
|
||||
Visible = false;
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_trueExit = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ntfyshWebsiteToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo("https://ntfy.sh/")
|
||||
{
|
||||
UseShellExecute = true
|
||||
});
|
||||
}
|
||||
|
||||
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using AboutBox d = new AboutBox();
|
||||
d.ShowDialog();
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
{
|
||||
_trueExit = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private async void SendNotificationMenuItem_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
await SendMessage();
|
||||
}
|
||||
|
||||
private async void notificationTopics_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
await SendMessage();
|
||||
}
|
||||
|
||||
private async Task SendMessage()
|
||||
{
|
||||
if (notificationTopics.SelectedItem != null && string.IsNullOrEmpty(notificationTopics.SelectedItem as string) == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
SendMessageForm dlg = new SendMessageForm();
|
||||
DialogResult r = dlg.ShowDialog(this);
|
||||
if (r == DialogResult.OK)
|
||||
{
|
||||
string key = notificationTopics.SelectedItem.ToString();
|
||||
await _notificationListener.SendNotification(key, dlg.Title, dlg.Message);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
@@ -26,36 +26,36 @@
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
@@ -117,13 +117,56 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="topicContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>384, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="sendNotificationMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALtSURBVGhD7ZfPaxNBFMeTkqS9WDyotTHJvjdJ/VUpirQK
|
||||
elFKa1pSK2lNapOrP8BDPRQEL7X+qFjEg2JBEERrEc2hh0jT6EHUo3+DPSi2tV6E4sGmREaSsHlM1iaZ
|
||||
lVnJFz6X3TeZ98lLZhObrZZaaqnF0kHEcUR8rTjjtO+iIOIkImYtwiTtvxBEXBAsUJUF2n8hehEAmELE
|
||||
UZXI9VSeiKZpYU3TmhUjbKqIM/z47Pb9J4BeNwHzRByRF1dt8XTWfubV26a2ENL7kjFHxBF9eY1L5KmL
|
||||
zj6hNZKRL5KfRIHY3KfNnZcP0DrJyBWhk7DF0+t1kcQdx+DMaKVsCt48QvcRIE+kqb2XEQkpOAemR+he
|
||||
AuSJbDvY76dNyOCfi7j97V57fO4jaWTNHku+tw8n31WK69TDKN1LgDwRzpaOyE4qUzc0O+317nLTWsnI
|
||||
FeEIZaKJ+7Tub2w9FG6h1wyQL8IpkomlftQH7wZpjRHOgZkRWzz1raFr4ji9VwJzRDh/ZIaTb+qDt7vo
|
||||
PSOcp59d4sd27k1Yaei+cYzWCDBPpFL47zN+SBQ+mrH57xuYjHoinApkzBHhZz85hqsnllpxtx710b2s
|
||||
JxJPZ/lDl+5lPZFY+qfBfxtzRPgzoLFz7HCl5E6ujF7CFZoy2tcckWpwhe712+Lzq0USfQ8GaR1BPRFH
|
||||
JDFRxiTyqCfCcUQS1zc4iTxqinAau6900GsGqCtSJuWLIGIaEZ8a0CfYSE8vADwSrKsG3lPZIoYAwCoA
|
||||
nBQINDPGLiBihq6RTGkRxhgf3S/BolI8pxIAcA4R1wS1MskwxoZo/0VhjPUwxm6VAhE/6F6wSAQRL5JJ
|
||||
LNP1kuihfZcdxtiYSAQAzpNJLPv9/n10vTIRiVhOgoeKCL7YS4FAoJWuUy56EQD4gojrOomvALCbrlEy
|
||||
ZCJ6lnw+315ar2xKiCxaSoJHILKoadoeWqd8ELENERO5U+ozY6yF1lgqHo9nByJq9Hottfxn+Q2nlJ4k
|
||||
a2hbYwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>537, 17</value>
|
||||
</metadata>
|
||||
<metadata name="notifyIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="trayContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>123, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="showControlWindowToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
|
||||
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA68AAAOvAGVvHJJAAAAgElE
|
||||
QVQ4T2NgoAZQVFR8oKio+J9E/ADZgP9ycnKSpGCQHuoZoKCg8BiLE/FikB5kF+yXkpISJgWD9BBtQIbp
|
||||
ykeZZqv+gzCITbIBII0eWsVaIAxi4zQA2SZk24g2AFkhsmKivYDLAGwYqwG4vIANYzWAFIxuwAqQAIl4
|
||||
BdyAAQUAg96z/bGuwC8AAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="exitToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
|
||||
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA68AAAOvAGVvHJJAAAAhklE
|
||||
QVQ4T2NgoBY4zi6ugC6GDWBVBxI8yiX26jC3uAO6HDIAyYPUYTXkMI+ozREusZdHucWd0OVA4AiPiC0+
|
||||
eTDAZQgucawAXTE6nygA8itYE5doCYgmFDZYAUjzUW7x/yAaXY4goMgF6H5G5+MFuKKKKENwaYYBvIZQ
|
||||
JSViFcQCiFVHPwAA6g5YEuFUY5cAAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="notifyIcon.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
AAABAAEAMjIAAAEAIADIKAAAFgAAACgAAAAyAAAAZAAAAAEAIAAAAAAAECcAACMuAAAjLgAAAAAAAAAA
|
||||
@@ -301,57 +344,51 @@
|
||||
AAAAAcAA4AAAAAABwADgAAAAAAHAAOAAAAAAAcAA4AAAAAABwADgAAAAAAHAAOAAAAAAAcAA4AAAAAAB
|
||||
wADgAAAAAAHAAOAAAAAAAcAA4AAAAAABwADwAAAAAAPAAP///////8AA////////wAD////////AAP//
|
||||
/////8AA////////wAD////////AAA==
|
||||
</value>
|
||||
</data>
|
||||
<data name="showControlWindowToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
|
||||
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAiklE
|
||||
QVQ4T8WPQQqAIBBFvUOrXIhu3dcZOkqtu5R1ia4SdRDrxyyGGKmBIOGBDL6nmk9WCGE9yUpW0q9Ads7V
|
||||
GuCQ/kHAe79joAEO6dcLFmttpQEO6c+Bvpm2oZ0zwB4zVQBiF8cIsMdMDPCb+G2vA/wgP/z6C6WAhBgo
|
||||
fUFCDGi4BxIGShLpvy5jDoPes/0oNG3VAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="exitToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
|
||||
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAgUlE
|
||||
QVQ4T2OgGjjOLq4AZeIFWNWBBI9yib06zC3uABXCCkDyIHVYDTnMI2pzhEvs5VFucSeoEAo4wiNii08e
|
||||
DHAZQshwFICumCTNMADyK1gTl2gJiCYUNlgBSDPQ1v8gGipEPKDIBRSFAa6oIsoQQvGM1xCqpESsglgA
|
||||
seroBRgYAOoOWBJbfVcRAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>269, 17</value>
|
||||
</metadata>
|
||||
<data name="exitToolStripMenuItem1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
|
||||
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA68AAAOvAGVvHJJAAAAhklE
|
||||
QVQ4T2NgoBY4zi6ugC6GDWBVBxI8yiX26jC3uAO6HDIAyYPUYTXkMI+ozREusZdHucWd0OVA4AiPiC0+
|
||||
eTDAZQgucawAXTE6nygA8itYE5doCYgmFDZYAUjzUW7x/yAaXY4goMgF6H5G5+MFuKKKKENwaYYBvIZQ
|
||||
JSViFcQCiFVHPwAA6g5YEuFUY5cAAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="settingsToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
|
||||
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA69AAAOvQFH+5CtAAABQUlE
|
||||
QVQ4T7WTTU4CQRCF5whG48KxnfoqMxfAcyjoDdz4cw1xLXoC2AgnULmPBuMST4B5pEigGeNGK+mkp1+/
|
||||
V1Wva4riv8Ld79x9Eauf460BXAPjlNIu8GpmF1ruPo2zse7kvGUAV8AbMHL3D+DLzDp1XR9r7+4zYAi8
|
||||
t4oAE12oquoA6JnZo/Za2gPdwEaqJOcXZrYjdTM7q+v6CHhQJZF5oDN3P9W32tkgyyT1DMwj2wB4Tikd
|
||||
Nk2T3F3YILC57m4YK6dllvpVmcoi4gqP7LNopxPGLrYEBP4moCRtAn09VTi/bEFlSyTIwu4D04tMt2Zj
|
||||
zcTzMFEis3UTq6o6AT6bptnfICtiSEbxVN2WZ+wFplmY5Pz1QRquBin67UTZOtMMqMqbnL8M4FLqZVnu
|
||||
AS8to/z0IzmPMHb1M93m+J/FN8xxh3CJx7rTAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="ntfyshWebsiteToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
|
||||
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7DAAAOwwHHb6hkAAABDElE
|
||||
QVQ4T91RO3bCQAzUy3uhChdJnTVlCj5FcMsZsF1jmy4XycPrzl6fBLgEXMFp4srRiF0wcaBP5j0VI2m0
|
||||
4zH9EwSq8gPP7ELPNFxtpxrbn9vVPkSsykOkqvHi2QxsWwAevhQTzG8eCb1yD7Glv2I5MlM+sLX0GqEq
|
||||
6+jVPFl6QZz7lOgdJVnzuMq/sEepbsGln2YnR3AAm0IcIE71geJsTO9mcOWAOa3zicxxxGWApXMGabaH
|
||||
WDLwqhmLj8tR8SYzh2Qz5b3TUQSEF7jkLzysdB2o4tPybU8MxB9DdlFb9gNwAJv30HXQg8sAS/jmLiQD
|
||||
PWPxkdabvrMzEBBeQOpI35Vw7t8V/yEQfQPXsZpY9UsnYgAAAABJRU5ErkJggg==
|
||||
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA68AAAOvAGVvHJJAAABCUlE
|
||||
QVQ4T91Ru3LCMBC8yUxcJT+SOhJlCh5FoOUbsKixRcePZJDc2ecvMfwE/ILTxBWZlbFHyBP6sDMqbu/2
|
||||
br0megzEolzEkg9KcqMkX7zXXPl5qOnhxKI4rUU5Xr5x5PdQq/d8gv6fS5QsjhCHvI/ViKdKchXyDkoU
|
||||
9fqDX0KekmxBqT1QaprnTfaDOdL2gtrx2rSO4AA2B2JtT5SYMe04unGw44i22cT1saTLAEN9BtocIXYZ
|
||||
yHKmJJ9Xo/zz5ki6n5I27VIEhAvdX3ja2DoW+fe1rgZiIPl6JW3rkG4BB7B5D76DAboMMIRv9uEysDPS
|
||||
5kzb/dBZDwSEC0gd6XfP1aa6L/5X+AXXsZpYG9LldQAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="aboutToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
|
||||
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAwUlE
|
||||
QVQ4T2OgClBUVHwAxP9JxA+g2sEG/JeTk5MkBYP0QLVTwQAFBYXHIAFSMEgPVDvYBfulpKSEScEgPVDt
|
||||
dDIA6OTNQHX/YXysBjAxMcUxMjKuBrGB9DIgPxqmARhwOUBD3sD4WA0QERGRBHLvCwoKygLpm6KiohIw
|
||||
DVBNz5HY2L0AtHkOEE8F4okgvoyMjDSSJsIGsLOzuwKFfnBycppJS0vLAJ39BUQTbQA6RnYBMkY3YAVI
|
||||
gES8Aqp9QAEDAwCq9oYvtggceQAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="exitToolStripMenuItem1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
|
||||
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAgUlE
|
||||
QVQ4T2OgGjjOLq4AZeIFWNWBBI9yib06zC3uABXCCkDyIHVYDTnMI2pzhEvs5VFucSeoEAo4wiNii08e
|
||||
DHAZQshwFICumCTNMADyK1gTl2gJiCYUNlgBSDPQ1v8gGipEPKDIBRSFAa6oIsoQQvGM1xCqpESsglgA
|
||||
seroBRgYAOoOWBJbfVcRAAAAAElFTkSuQmCC
|
||||
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA68AAAOvAGVvHJJAAAAvklE
|
||||
QVQ4T8WOPQoCMRBGZ9KELRez4CYxzFzCG3gKwRN4GQs7a1mw9ACew8oFCxtLC7uVAZWwSDCw6MAjP/C9
|
||||
+QCGGGZumbnLpI0FXQihzkEywwmI6PyhYhLJxA0O1tpRDpL5rYCI9lI9KVBKLRBxJ3dE3Cql5q9ACGFJ
|
||||
RNekwBhTA8CpLMsJAByrqhrHLZj5khQ8N28QcY2IK3l7712WQGs9A4B7URRT55wnopucXwv6xA1i+oJG
|
||||
PjJp3oK/zgOq9oYvURh7ngAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
@@ -1,146 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace ntfysh_client
|
||||
{
|
||||
class NotificationListener : IDisposable
|
||||
{
|
||||
private HttpClient httpClient;
|
||||
|
||||
private bool disposedValue;
|
||||
|
||||
public Dictionary<string, StreamReader> subscribedTopics;
|
||||
|
||||
public delegate void NotificationReceiveHandler(object sender, NotificationReceiveEventArgs e);
|
||||
public event NotificationReceiveHandler OnNotificationReceive;
|
||||
|
||||
public NotificationListener()
|
||||
{
|
||||
httpClient = new HttpClient();
|
||||
subscribedTopics = new Dictionary<string, StreamReader>();
|
||||
|
||||
ServicePointManager.DefaultConnectionLimit = 100;
|
||||
}
|
||||
|
||||
public async Task SubscribeToTopic(string topicId)
|
||||
{
|
||||
var stream = await httpClient.GetStreamAsync($"https://ntfy.sh/{HttpUtility.UrlEncode(topicId)}/json");
|
||||
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
subscribedTopics.Add(topicId, reader);
|
||||
|
||||
try
|
||||
{
|
||||
// The loop will be broken when this stream is closed
|
||||
while (true)
|
||||
{
|
||||
var line = await reader.ReadLineAsync();
|
||||
|
||||
Debug.WriteLine(line);
|
||||
|
||||
NtfyEventObject nev = JsonConvert.DeserializeObject<NtfyEventObject>(line);
|
||||
|
||||
if (nev.Event == "message")
|
||||
{
|
||||
if (OnNotificationReceive != null)
|
||||
{
|
||||
var evArgs = new NotificationReceiveEventArgs(nev.Title, nev.Message);
|
||||
OnNotificationReceive(this, evArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex);
|
||||
|
||||
// If the topic is still registered, then that stream wasn't mean to be closed (maybe network failure?)
|
||||
// Restart it
|
||||
if (subscribedTopics.ContainsKey(topicId))
|
||||
{
|
||||
SubscribeToTopic(topicId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveTopic(string topicId)
|
||||
{
|
||||
Debug.WriteLine($"Removing topic {topicId}");
|
||||
|
||||
if (subscribedTopics.ContainsKey(topicId))
|
||||
{
|
||||
// Not moronic to store it in a variable; this solves a race condition in SubscribeToTopic
|
||||
var topic = subscribedTopics[topicId];
|
||||
subscribedTopics.Remove(topicId);
|
||||
topic.Close();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// TODO: dispose managed state (managed objects)
|
||||
}
|
||||
|
||||
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
|
||||
// TODO: set large fields to null
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
// // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
|
||||
// ~NotificationListener()
|
||||
// {
|
||||
// // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
// Dispose(disposing: false);
|
||||
// }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class NotificationReceiveEventArgs : EventArgs
|
||||
{
|
||||
public string Title { get; private set; }
|
||||
public string Message { get; private set; }
|
||||
|
||||
public NotificationReceiveEventArgs(string title, string message)
|
||||
{
|
||||
Title = title;
|
||||
Message = message;
|
||||
}
|
||||
}
|
||||
|
||||
public class NtfyEventObject
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
[JsonProperty("time")]
|
||||
public Int64 Time { get; set; }
|
||||
[JsonProperty("event")]
|
||||
public string Event { get; set; }
|
||||
[JsonProperty("topic")]
|
||||
public string Topic { get; set; }
|
||||
[JsonProperty("message")]
|
||||
public string Message { get; set; }
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; }
|
||||
}
|
||||
}
|
375
ntfysh_client/Notifications/NotificationListener.cs
Normal file
375
ntfysh_client/Notifications/NotificationListener.cs
Normal file
@@ -0,0 +1,375 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Net.WebSockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ntfysh_client.Notifications
|
||||
{
|
||||
public class NotificationListener
|
||||
{
|
||||
public readonly Dictionary<string, SubscribedTopic?> SubscribedTopicsByUnique = new();
|
||||
|
||||
public delegate void NotificationReceiveHandler(NotificationListener sender, NotificationReceiveEventArgs e);
|
||||
public event NotificationReceiveHandler? OnNotificationReceive;
|
||||
|
||||
public delegate void ConnectionErrorHandler(NotificationListener sender, SubscribedTopic topic);
|
||||
public event ConnectionErrorHandler? OnConnectionMultiAttemptFailure;
|
||||
public event ConnectionErrorHandler? OnConnectionCredentialsFailure;
|
||||
|
||||
public NotificationListener()
|
||||
{
|
||||
ServicePointManager.DefaultConnectionLimit = 100;
|
||||
}
|
||||
|
||||
private async Task ListenToTopicWithHttpLongJsonAsync(HttpRequestMessage message, SubscribedTopic topic, int reconnectAttempts = 10, int reconnectAttemptDelay = 3, CancellationToken cancellationToken = default)
|
||||
{
|
||||
int connectionAttempts = 0;
|
||||
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
//See if we have exceeded maximum attempts
|
||||
if (reconnectAttempts != 0 && connectionAttempts >= reconnectAttempts)
|
||||
{
|
||||
//<reconnectAttempts> connection failures (1 initial + (<reconnectAttempts> - 1) reattempts)! Do not retry
|
||||
OnConnectionMultiAttemptFailure?.Invoke(this, topic);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//Establish connection
|
||||
using HttpClient client = new();
|
||||
client.Timeout = TimeSpan.FromMilliseconds(Timeout.Infinite); //This will not prevent us from failing to connect, luckily
|
||||
|
||||
using HttpResponseMessage response = await client.SendAsync(message, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
|
||||
await using Stream body = await response.Content.ReadAsStreamAsync(cancellationToken);
|
||||
|
||||
//Ensure successful connect
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
//Reset connection attempts after a successful connect
|
||||
connectionAttempts = 0;
|
||||
|
||||
//Begin listening
|
||||
StringBuilder mainBuffer = new();
|
||||
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
//Read as much as possible
|
||||
byte[] buffer = new byte[8192];
|
||||
int readBytes = await body.ReadAsync(buffer, 0, buffer.Length, cancellationToken);
|
||||
|
||||
//Append it to our main buffer
|
||||
mainBuffer.Append(Encoding.UTF8.GetString(buffer, 0, readBytes));
|
||||
|
||||
List<string> lines = mainBuffer.ToString().Split('\n').ToList();
|
||||
|
||||
//If we have not yet received a full line, meaning theres only 1 part, go back to reading
|
||||
if (lines.Count <= 1) continue;
|
||||
|
||||
//We now have at least 1 line! Count how many full lines. There will always be a partial line at the end, even if that partial line is empty
|
||||
|
||||
//Separate the partial line from the full lines
|
||||
int partialLineIndex = lines.Count - 1;
|
||||
string partialLine = lines[partialLineIndex];
|
||||
lines.RemoveAt(partialLineIndex);
|
||||
|
||||
//Process the full lines
|
||||
foreach (string line in lines) ProcessMessage(topic, line);
|
||||
|
||||
//Write back the partial line
|
||||
mainBuffer.Clear();
|
||||
mainBuffer.Append(partialLine);
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException hre)
|
||||
{
|
||||
if (hre.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
|
||||
{
|
||||
//Our credentials either aren't present when they need to be or are invalid
|
||||
|
||||
//Credential Failure! Do not retry
|
||||
OnConnectionCredentialsFailure?.Invoke(this, topic);
|
||||
return;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
Debug.WriteLine(hre);
|
||||
#endif
|
||||
|
||||
//We will not hit the finally block which will increment the connection failure counter and attempt a reconnect if applicable
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
Debug.WriteLine(e);
|
||||
#endif
|
||||
|
||||
//We will not hit the finally block which will increment the connection failure counter and attempt a reconnect if applicable
|
||||
}
|
||||
finally
|
||||
{
|
||||
//We land here if we fail to connect or our connection gets closed (and if we are canceling, but that gets ignored)
|
||||
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
//Not cancelling, legitimate connection failure or termination
|
||||
|
||||
if (reconnectAttempts == 0 || connectionAttempts != 0)
|
||||
{
|
||||
//On our first reconnect attempt, try instantly (unless we have infinite retries). On consecutive, wait <reconnectAttemptDelay> seconds before each attempt
|
||||
await Task.Delay(TimeSpan.FromSeconds(reconnectAttemptDelay), cancellationToken);
|
||||
}
|
||||
|
||||
//Increment attempts
|
||||
connectionAttempts++;
|
||||
|
||||
//Proceed to reattempt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ListenToTopicWithWebsocketAsync(Uri uri, string? credentials, SubscribedTopic topic, int reconnectAttempts = 10, int reconnectAttemptDelay = 3, CancellationToken cancellationToken = default)
|
||||
{
|
||||
int connectionAttempts = 0;
|
||||
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
//See if we have exceeded maximum attempts
|
||||
if (reconnectAttempts != 0 && connectionAttempts >= reconnectAttempts)
|
||||
{
|
||||
//<reconnectAttempts> connection failures (1 initial + (<reconnectAttempts> - 1) reattempts)! Do not retry
|
||||
OnConnectionMultiAttemptFailure?.Invoke(this, topic);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//Establish connection
|
||||
using ClientWebSocket socket = new();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(credentials)) socket.Options.SetRequestHeader("Authorization", "Basic " + credentials);
|
||||
|
||||
await socket.ConnectAsync(uri, cancellationToken);
|
||||
|
||||
//Reset connection attempts after a successful connect
|
||||
connectionAttempts = 0;
|
||||
|
||||
//Begin listening
|
||||
StringBuilder mainBuffer = new();
|
||||
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
//Read as much as possible
|
||||
byte[] buffer = new byte[8192];
|
||||
WebSocketReceiveResult? result = await socket.ReceiveAsync(new ArraySegment<byte>(buffer), cancellationToken);
|
||||
|
||||
//Append it to our main buffer
|
||||
mainBuffer.Append(Encoding.UTF8.GetString(buffer, 0, result.Count));
|
||||
|
||||
List<string> lines = mainBuffer.ToString().Split('\n').ToList();
|
||||
//If we have not yet received a full line, meaning theres only 1 part, go back to reading
|
||||
if (lines.Count <= 1) continue;
|
||||
|
||||
//We now have at least 1 line! Count how many full lines. There will always be a partial line at the end, even if that partial line is empty
|
||||
//Separate the partial line from the full lines
|
||||
int partialLineIndex = lines.Count - 1;
|
||||
string partialLine = lines[partialLineIndex];
|
||||
lines.RemoveAt(partialLineIndex);
|
||||
|
||||
//Process the full lines
|
||||
foreach (string line in lines) ProcessMessage(topic, line);
|
||||
|
||||
//Write back the partial line
|
||||
mainBuffer.Clear();
|
||||
mainBuffer.Append(partialLine);
|
||||
}
|
||||
}
|
||||
catch (WebSocketException wse)
|
||||
{
|
||||
if (wse.WebSocketErrorCode is WebSocketError.NotAWebSocket)
|
||||
{
|
||||
//We haven't achieved a connection with a websocket. TODO Seems ntfy doesn't report unauthorised properly, and responds 200
|
||||
|
||||
//Credential Failure! Do not retry
|
||||
OnConnectionCredentialsFailure?.Invoke(this, topic);
|
||||
return;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
Debug.WriteLine(wse);
|
||||
#endif
|
||||
|
||||
//We will not hit the finally block which will increment the connection failure counter and attempt a reconnect if applicable
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
Debug.WriteLine(e);
|
||||
#endif
|
||||
|
||||
//We will not hit the finally block which will increment the connection failure counter and attempt a reconnect if applicable
|
||||
}
|
||||
finally
|
||||
{
|
||||
//We land here if we fail to connect or our connection gets closed (and if we are canceling, but that gets ignored)
|
||||
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
//Not cancelling, legitimate connection failure or termination
|
||||
|
||||
if (reconnectAttempts == 0 || connectionAttempts != 0)
|
||||
{
|
||||
//On our first reconnect attempt, try instantly (unless we have infinite retries). On consecutive, wait <reconnectAttemptDelay> seconds before each attempt
|
||||
await Task.Delay(TimeSpan.FromSeconds(reconnectAttemptDelay), cancellationToken);
|
||||
}
|
||||
|
||||
//Increment attempts
|
||||
connectionAttempts++;
|
||||
|
||||
//Proceed to reattempt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessMessage(SubscribedTopic topic, string message)
|
||||
{
|
||||
#if DEBUG
|
||||
Debug.WriteLine(message);
|
||||
#endif
|
||||
|
||||
NtfyEvent? evt = JsonConvert.DeserializeObject<NtfyEvent>(message);
|
||||
|
||||
//If we hit this, ntfy sent us an invalid message
|
||||
if (evt is null) return;
|
||||
|
||||
if (evt.Event == "message")
|
||||
{
|
||||
OnNotificationReceive?.Invoke(this, new NotificationReceiveEventArgs(topic, evt.Title ?? "", evt.Message, evt.Priority ?? NotificationPriority.Default));
|
||||
}
|
||||
}
|
||||
|
||||
public void SubscribeToTopicUsingLongHttpJson(string unique, string topicId, string serverUrl, string? username, string? password, int reconnectAttempts, int reconnectAttemptDelay)
|
||||
{
|
||||
if (SubscribedTopicsByUnique.ContainsKey(unique)) throw new ArgumentException("A topic with this unique already exists", nameof(unique));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(username)) username = null;
|
||||
if (string.IsNullOrWhiteSpace(password)) password = null;
|
||||
|
||||
if (reconnectAttempts < 0) throw new ArgumentException("Reconnect attempts must be 0 or more", nameof(reconnectAttempts));
|
||||
if (reconnectAttemptDelay < 0) throw new ArgumentException("Reconnect attempt delay; must be 0 or more", nameof(reconnectAttemptDelay));
|
||||
|
||||
HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, $"{serverUrl}/{HttpUtility.UrlEncode(topicId)}/json");
|
||||
|
||||
if (username is not null && password is not null)
|
||||
{
|
||||
byte[] boundCredentialsBytes = Encoding.UTF8.GetBytes($"{username}:{password}");
|
||||
|
||||
message.Headers.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(boundCredentialsBytes));
|
||||
}
|
||||
|
||||
SubscribedTopic newTopic = new(topicId, serverUrl, username, password);
|
||||
|
||||
CancellationTokenSource listenCanceller = new();
|
||||
Task listenTask = ListenToTopicWithHttpLongJsonAsync(message, newTopic, reconnectAttempts, reconnectAttemptDelay, listenCanceller.Token);
|
||||
|
||||
newTopic.SetAssociatedRunner(listenTask, listenCanceller);
|
||||
|
||||
SubscribedTopicsByUnique.Add(unique, newTopic);
|
||||
}
|
||||
|
||||
public void SubscribeToTopicUsingWebsocket(string unique, string topicId, string serverUrl, string? username, string? password, int reconnectAttempts, int reconnectAttemptDelay)
|
||||
{
|
||||
if (SubscribedTopicsByUnique.ContainsKey(unique)) throw new ArgumentException("A topic with this unique already exists", nameof(unique));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(username)) username = null;
|
||||
if (string.IsNullOrWhiteSpace(password)) password = null;
|
||||
|
||||
if (reconnectAttempts < 0) throw new ArgumentException("Reconnect attempts must be 0 or more", nameof(reconnectAttempts));
|
||||
if (reconnectAttemptDelay < 0) throw new ArgumentException("Reconnect attempt delay; must be 0 or more", nameof(reconnectAttemptDelay));
|
||||
|
||||
SubscribedTopic newTopic = new(topicId, serverUrl, username, password);
|
||||
|
||||
string? credentials = null;
|
||||
|
||||
if (username is not null && password is not null)
|
||||
{
|
||||
byte[] boundCredentialsBytes = Encoding.UTF8.GetBytes($"{username}:{password}");
|
||||
|
||||
credentials = Convert.ToBase64String(boundCredentialsBytes);
|
||||
}
|
||||
|
||||
CancellationTokenSource listenCanceller = new();
|
||||
Task listenTask = ListenToTopicWithWebsocketAsync(new Uri($"{serverUrl}/{HttpUtility.UrlEncode(topicId)}/ws"), credentials, newTopic, reconnectAttempts, reconnectAttemptDelay, listenCanceller.Token);
|
||||
|
||||
newTopic.SetAssociatedRunner(listenTask, listenCanceller);
|
||||
|
||||
SubscribedTopicsByUnique.Add(unique, newTopic);
|
||||
}
|
||||
|
||||
public async Task UnsubscribeFromTopicAsync(string topicUniqueString)
|
||||
{
|
||||
#if DEBUG
|
||||
Debug.WriteLine($"Removing topic {topicUniqueString}");
|
||||
#endif
|
||||
|
||||
// ReSharper disable once InlineOutVariableDeclaration - Needed to avoid nullable warning
|
||||
SubscribedTopic topic;
|
||||
|
||||
//Topic isn't even subscribed, ignore
|
||||
if (!SubscribedTopicsByUnique.TryGetValue(topicUniqueString, out topic!)) return;
|
||||
|
||||
//Cancel and dispose the task runner
|
||||
topic.RunnerCanceller?.Cancel();
|
||||
|
||||
//Wait for the task runner to shut down
|
||||
try
|
||||
{
|
||||
if (topic.Runner is not null) await topic.Runner;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
//Dispose task
|
||||
topic.Runner?.Dispose();
|
||||
|
||||
//Remove the old topic
|
||||
SubscribedTopicsByUnique.Remove(topicUniqueString);
|
||||
}
|
||||
|
||||
public async Task SendNotification(string key, string title, string message)
|
||||
{
|
||||
if (SubscribedTopicsByUnique.TryGetValue(key, out SubscribedTopic topic))
|
||||
{
|
||||
HttpClient httpClient = new HttpClient();
|
||||
PublishEvent notification = new PublishEvent();
|
||||
notification.Title = title;
|
||||
notification.Message = message;
|
||||
notification.Topic = topic.TopicId;
|
||||
if (!string.IsNullOrEmpty(topic.Username) || !string.IsNullOrEmpty(topic.Password))
|
||||
{
|
||||
string value = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{topic.Username}:{topic.Password}"));
|
||||
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", value);
|
||||
}
|
||||
|
||||
HttpResponseMessage response = await httpClient.PostAsJsonAsync<PublishEvent>(topic.ServerUrl.Replace("wss://", "https://"), notification);
|
||||
response.EnsureSuccessStatusCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
ntfysh_client/Notifications/NotificationPriority.cs
Normal file
11
ntfysh_client/Notifications/NotificationPriority.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace ntfysh_client.Notifications
|
||||
{
|
||||
public enum NotificationPriority
|
||||
{
|
||||
Min = 1,
|
||||
Low = 2,
|
||||
Default = 3,
|
||||
High = 4,
|
||||
Max = 5
|
||||
}
|
||||
}
|
20
ntfysh_client/Notifications/NotificationReceiveEventArgs.cs
Normal file
20
ntfysh_client/Notifications/NotificationReceiveEventArgs.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace ntfysh_client.Notifications
|
||||
{
|
||||
public class NotificationReceiveEventArgs : EventArgs
|
||||
{
|
||||
public SubscribedTopic Sender { get; }
|
||||
public string Title { get; }
|
||||
public string Message { get; }
|
||||
public NotificationPriority Priority { get; set; }
|
||||
|
||||
public NotificationReceiveEventArgs(SubscribedTopic sender, string title, string message, NotificationPriority priority)
|
||||
{
|
||||
Sender = sender;
|
||||
Title = title;
|
||||
Message = message;
|
||||
Priority = priority;
|
||||
}
|
||||
}
|
||||
}
|
28
ntfysh_client/Notifications/NtfyEvent.cs
Normal file
28
ntfysh_client/Notifications/NtfyEvent.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ntfysh_client.Notifications
|
||||
{
|
||||
public class NtfyEvent
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[JsonProperty("time")]
|
||||
public long Time { get; set; }
|
||||
|
||||
[JsonProperty("event")]
|
||||
public string Event { get; set; } = null!;
|
||||
|
||||
[JsonProperty("topic")]
|
||||
public string Topic { get; set; } = null!;
|
||||
|
||||
[JsonProperty("message")]
|
||||
public string Message { get; set; } = null!;
|
||||
|
||||
[JsonProperty("title")]
|
||||
public string? Title { get; set; }
|
||||
|
||||
[JsonProperty("priority")]
|
||||
public NotificationPriority? Priority { get; set; }
|
||||
}
|
||||
}
|
50
ntfysh_client/Notifications/PublishEvent.cs
Normal file
50
ntfysh_client/Notifications/PublishEvent.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace ntfysh_client.Notifications
|
||||
{
|
||||
internal class PublishEvent
|
||||
{
|
||||
[JsonProperty("topic")]
|
||||
public string Topic { get; set; } = null!;
|
||||
|
||||
[JsonProperty("message")]
|
||||
public string? Message { get; set; } = null;
|
||||
|
||||
[JsonProperty("title")]
|
||||
public string? Title { get; set; } = null;
|
||||
|
||||
[JsonProperty("tags")]
|
||||
public string[] Tags { get; set; } = null!;
|
||||
|
||||
[JsonProperty("priority")]
|
||||
public NotificationPriority? Priority { get; set; } = null;
|
||||
|
||||
[JsonProperty("actions")]
|
||||
public JsonArray? Actions { get; set; } = null;
|
||||
|
||||
[JsonProperty("click")]
|
||||
public string? Click { get; set; } = null;
|
||||
|
||||
[JsonProperty("attach")]
|
||||
public string? Attach { get; set; } = null;
|
||||
|
||||
[JsonProperty("markdown")]
|
||||
public bool? Markdown { get; set; } = null;
|
||||
|
||||
[JsonProperty("icon")]
|
||||
public string? Icon { get; set; } = null;
|
||||
|
||||
[JsonProperty("filename")]
|
||||
public string? Filename { get; set; } = null;
|
||||
|
||||
[JsonProperty("delay")]
|
||||
public string? Delay { get; set; } = null;
|
||||
|
||||
[JsonProperty("email")]
|
||||
public string? Email { get; set; } = null;
|
||||
|
||||
[JsonProperty("call")]
|
||||
public string? Call { get; set; } = null;
|
||||
}
|
||||
}
|
37
ntfysh_client/Notifications/SubscribedTopic.cs
Normal file
37
ntfysh_client/Notifications/SubscribedTopic.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ntfysh_client.Notifications
|
||||
{
|
||||
public class SubscribedTopic
|
||||
{
|
||||
public SubscribedTopic(string topicId, string serverUrl, string? username, string? password)
|
||||
{
|
||||
TopicId = topicId;
|
||||
ServerUrl = serverUrl;
|
||||
Username = username;
|
||||
Password = password;
|
||||
}
|
||||
|
||||
public void SetAssociatedRunner(Task runner, CancellationTokenSource runnerCanceller)
|
||||
{
|
||||
if (Runner is not null || RunnerCanceller is not null) throw new InvalidOperationException("Runner already associated");
|
||||
|
||||
Runner = runner;
|
||||
RunnerCanceller = runnerCanceller;
|
||||
}
|
||||
|
||||
public string TopicId { get; }
|
||||
public string ServerUrl { get; }
|
||||
public string? Username { get; }
|
||||
public string? Password { get; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Task? Runner { get; private set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public CancellationTokenSource? RunnerCanceller { get; private set; }
|
||||
}
|
||||
}
|
@@ -1,22 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using ntfysh_client.Notifications;
|
||||
|
||||
namespace ntfysh_client
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
private static readonly NotificationListener NotificationListener = new();
|
||||
public static SettingsModel Settings { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
args = args.Select(a => a.ToLower()).ToArray();
|
||||
|
||||
if (args.Contains("-h") || args.Contains("--help"))
|
||||
{
|
||||
MessageBox.Show("Help:\n -h\n --help\n\nStart in tray:\n -t\n --start-in-tray\n\nAllow multiple instances:\n -m\n --allow-multiple-instances", "Help Menu", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
|
||||
bool startInTray = args.Contains("-t") || args.Contains("--start-in-tray");
|
||||
bool allowMultipleInstances = args.Contains("-m") || args.Contains("--allow-multiple-instances");
|
||||
|
||||
if (Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly()!.Location)).Length > 1)
|
||||
{
|
||||
if (!allowMultipleInstances)
|
||||
{
|
||||
MessageBox.Show("Another instance is already running.\n\nUse -m or --allow-multiple-instances if you wish to start a second duplicate instance.\n\nThis instance will now close.", "Multiple Instances", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new MainForm(NotificationListener, startInTray));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ntfy.sh")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ntfy.sh")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5a18d152-d620-43fe-b844-def30cfa50ef")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
63
ntfysh_client/Properties/Resources.Designer.cs
generated
63
ntfysh_client/Properties/Resources.Designer.cs
generated
@@ -1,63 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ntfysh_client.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ntfysh_client.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
26
ntfysh_client/Properties/Settings.Designer.cs
generated
26
ntfysh_client/Properties/Settings.Designer.cs
generated
@@ -1,26 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ntfysh_client.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
108
ntfysh_client/SendMessageForm.Designer.cs
generated
Normal file
108
ntfysh_client/SendMessageForm.Designer.cs
generated
Normal file
@@ -0,0 +1,108 @@
|
||||
namespace ntfysh_client
|
||||
{
|
||||
partial class SendMessageForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
richTextBox = new System.Windows.Forms.RichTextBox();
|
||||
button2 = new System.Windows.Forms.Button();
|
||||
textBox = new System.Windows.Forms.TextBox();
|
||||
label1 = new System.Windows.Forms.Label();
|
||||
label2 = new System.Windows.Forms.Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// richTextBox
|
||||
//
|
||||
richTextBox.Location = new System.Drawing.Point(12, 71);
|
||||
richTextBox.Name = "richTextBox";
|
||||
richTextBox.Size = new System.Drawing.Size(365, 165);
|
||||
richTextBox.TabIndex = 0;
|
||||
richTextBox.Text = "";
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new System.Drawing.Point(302, 242);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new System.Drawing.Size(75, 23);
|
||||
button2.TabIndex = 2;
|
||||
button2.Text = "Send";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// textBox
|
||||
//
|
||||
textBox.Location = new System.Drawing.Point(12, 27);
|
||||
textBox.Name = "textBox";
|
||||
textBox.Size = new System.Drawing.Size(365, 23);
|
||||
textBox.TabIndex = 3;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new System.Drawing.Point(12, 53);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new System.Drawing.Size(56, 15);
|
||||
label1.TabIndex = 4;
|
||||
label1.Text = "Message:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new System.Drawing.Point(12, 9);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new System.Drawing.Size(33, 15);
|
||||
label2.TabIndex = 5;
|
||||
label2.Text = "Title:";
|
||||
//
|
||||
// SendMessageForm
|
||||
//
|
||||
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
ClientSize = new System.Drawing.Size(389, 277);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(textBox);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(richTextBox);
|
||||
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
Name = "SendMessageForm";
|
||||
Text = "Send Message";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.RichTextBox richTextBox;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.TextBox textBox;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
}
|
||||
}
|
21
ntfysh_client/SendMessageForm.cs
Normal file
21
ntfysh_client/SendMessageForm.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ntfysh_client
|
||||
{
|
||||
public partial class SendMessageForm : Form
|
||||
{
|
||||
public string Message => richTextBox.Text;
|
||||
public string Title => textBox.Text;
|
||||
|
||||
public SendMessageForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
ntfysh_client/SendMessageForm.resx
Normal file
120
ntfysh_client/SendMessageForm.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
175
ntfysh_client/SettingsDialog.Designer.cs
generated
Normal file
175
ntfysh_client/SettingsDialog.Designer.cs
generated
Normal file
@@ -0,0 +1,175 @@
|
||||
|
||||
namespace ntfysh_client
|
||||
{
|
||||
partial class SettingsDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonPanel = new System.Windows.Forms.Panel();
|
||||
cancelButton = new System.Windows.Forms.Button();
|
||||
saveButton = new System.Windows.Forms.Button();
|
||||
timeoutLabel = new System.Windows.Forms.Label();
|
||||
timeout = new System.Windows.Forms.NumericUpDown();
|
||||
reconnectAttempts = new System.Windows.Forms.NumericUpDown();
|
||||
reconnectAttemptsLabel = new System.Windows.Forms.Label();
|
||||
reconnectAttemptDelay = new System.Windows.Forms.NumericUpDown();
|
||||
reconnectAttemptDelayLabel = new System.Windows.Forms.Label();
|
||||
buttonPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)timeout).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)reconnectAttempts).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)reconnectAttemptDelay).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonPanel
|
||||
//
|
||||
buttonPanel.BackColor = System.Drawing.SystemColors.Control;
|
||||
buttonPanel.Controls.Add(cancelButton);
|
||||
buttonPanel.Controls.Add(saveButton);
|
||||
buttonPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
buttonPanel.Location = new System.Drawing.Point(0, 150);
|
||||
buttonPanel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
buttonPanel.Name = "buttonPanel";
|
||||
buttonPanel.Size = new System.Drawing.Size(531, 51);
|
||||
buttonPanel.TabIndex = 0;
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
cancelButton.Location = new System.Drawing.Point(363, 16);
|
||||
cancelButton.Name = "cancelButton";
|
||||
cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
cancelButton.TabIndex = 2;
|
||||
cancelButton.Text = "Cancel";
|
||||
cancelButton.UseVisualStyleBackColor = true;
|
||||
cancelButton.Click += cancelButton_Click;
|
||||
//
|
||||
// saveButton
|
||||
//
|
||||
saveButton.Location = new System.Drawing.Point(444, 16);
|
||||
saveButton.Name = "saveButton";
|
||||
saveButton.Size = new System.Drawing.Size(75, 23);
|
||||
saveButton.TabIndex = 1;
|
||||
saveButton.Text = "Save";
|
||||
saveButton.UseVisualStyleBackColor = true;
|
||||
saveButton.Click += saveButton_Click;
|
||||
//
|
||||
// timeoutLabel
|
||||
//
|
||||
timeoutLabel.AutoSize = true;
|
||||
timeoutLabel.Location = new System.Drawing.Point(13, 9);
|
||||
timeoutLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
timeoutLabel.Name = "timeoutLabel";
|
||||
timeoutLabel.Size = new System.Drawing.Size(488, 15);
|
||||
timeoutLabel.TabIndex = 3;
|
||||
timeoutLabel.Text = "Notification Toast Timeout (seconds, may be ignored by OS based on accessibility settings):";
|
||||
//
|
||||
// timeout
|
||||
//
|
||||
timeout.Location = new System.Drawing.Point(13, 28);
|
||||
timeout.Maximum = new decimal(new int[] { -1981284353, -1966660860, 0, 0 });
|
||||
timeout.Name = "timeout";
|
||||
timeout.Size = new System.Drawing.Size(506, 23);
|
||||
timeout.TabIndex = 4;
|
||||
//
|
||||
// reconnectAttempts
|
||||
//
|
||||
reconnectAttempts.Location = new System.Drawing.Point(12, 73);
|
||||
reconnectAttempts.Maximum = new decimal(new int[] { -1981284353, -1966660860, 0, 0 });
|
||||
reconnectAttempts.Name = "reconnectAttempts";
|
||||
reconnectAttempts.Size = new System.Drawing.Size(506, 23);
|
||||
reconnectAttempts.TabIndex = 6;
|
||||
//
|
||||
// reconnectAttemptsLabel
|
||||
//
|
||||
reconnectAttemptsLabel.AutoSize = true;
|
||||
reconnectAttemptsLabel.Location = new System.Drawing.Point(12, 54);
|
||||
reconnectAttemptsLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
reconnectAttemptsLabel.Name = "reconnectAttemptsLabel";
|
||||
reconnectAttemptsLabel.Size = new System.Drawing.Size(198, 15);
|
||||
reconnectAttemptsLabel.TabIndex = 5;
|
||||
reconnectAttemptsLabel.Text = "Maximum reconnect retry attempts (requires restart):";
|
||||
//
|
||||
// reconnectAttemptDelay
|
||||
//
|
||||
reconnectAttemptDelay.Location = new System.Drawing.Point(12, 118);
|
||||
reconnectAttemptDelay.Maximum = new decimal(new int[] { -1981284353, -1966660860, 0, 0 });
|
||||
reconnectAttemptDelay.Name = "reconnectAttemptDelay";
|
||||
reconnectAttemptDelay.Size = new System.Drawing.Size(506, 23);
|
||||
reconnectAttemptDelay.TabIndex = 8;
|
||||
//
|
||||
// reconnectAttemptDelayLabel
|
||||
//
|
||||
reconnectAttemptDelayLabel.AutoSize = true;
|
||||
reconnectAttemptDelayLabel.Location = new System.Drawing.Point(12, 99);
|
||||
reconnectAttemptDelayLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
reconnectAttemptDelayLabel.Name = "reconnectAttemptDelayLabel";
|
||||
reconnectAttemptDelayLabel.Size = new System.Drawing.Size(191, 15);
|
||||
reconnectAttemptDelayLabel.TabIndex = 7;
|
||||
reconnectAttemptDelayLabel.Text = "Delay between attempts (seconds, requires restart):";
|
||||
//
|
||||
// SettingsDialog
|
||||
//
|
||||
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
BackColor = System.Drawing.Color.White;
|
||||
ClientSize = new System.Drawing.Size(531, 201);
|
||||
Controls.Add(reconnectAttemptDelay);
|
||||
Controls.Add(reconnectAttemptDelayLabel);
|
||||
Controls.Add(reconnectAttempts);
|
||||
Controls.Add(reconnectAttemptsLabel);
|
||||
Controls.Add(timeout);
|
||||
Controls.Add(timeoutLabel);
|
||||
Controls.Add(buttonPanel);
|
||||
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
Name = "SettingsDialog";
|
||||
ShowIcon = false;
|
||||
ShowInTaskbar = false;
|
||||
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
Text = "Settings";
|
||||
buttonPanel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)timeout).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)reconnectAttempts).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)reconnectAttemptDelay).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Panel buttonPanel;
|
||||
private System.Windows.Forms.Label timeoutLabel;
|
||||
private System.Windows.Forms.NumericUpDown timeout;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Button saveButton;
|
||||
private System.Windows.Forms.NumericUpDown reconnectAttempts;
|
||||
private System.Windows.Forms.Label reconnectAttemptsLabel;
|
||||
private System.Windows.Forms.NumericUpDown reconnectAttemptDelay;
|
||||
private System.Windows.Forms.Label reconnectAttemptDelayLabel;
|
||||
}
|
||||
}
|
41
ntfysh_client/SettingsDialog.cs
Normal file
41
ntfysh_client/SettingsDialog.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ntfysh_client
|
||||
{
|
||||
public partial class SettingsDialog : Form
|
||||
{
|
||||
public decimal Timeout
|
||||
{
|
||||
get => timeout.Value;
|
||||
set => timeout.Value = value;
|
||||
}
|
||||
|
||||
public decimal ReconnectAttempts
|
||||
{
|
||||
get => reconnectAttempts.Value;
|
||||
set => reconnectAttempts.Value = value;
|
||||
}
|
||||
|
||||
public decimal ReconnectAttemptDelay
|
||||
{
|
||||
get => reconnectAttemptDelay.Value;
|
||||
set => reconnectAttemptDelay.Value = value;
|
||||
}
|
||||
|
||||
public SettingsDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void saveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
@@ -26,40 +26,41 @@
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
@@ -68,9 +69,10 @@
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
@@ -85,9 +87,10 @@
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
@@ -109,9 +112,9 @@
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
10
ntfysh_client/SettingsModel.cs
Normal file
10
ntfysh_client/SettingsModel.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace ntfysh_client
|
||||
{
|
||||
public class SettingsModel
|
||||
{
|
||||
public uint Revision { get; set; }
|
||||
public decimal Timeout { get; set; }
|
||||
public decimal ReconnectAttempts { get; set; }
|
||||
public decimal ReconnectAttemptDelay { get; set; }
|
||||
}
|
||||
}
|
174
ntfysh_client/SubscribeDialog.Designer.cs
generated
174
ntfysh_client/SubscribeDialog.Designer.cs
generated
@@ -30,10 +30,18 @@ namespace ntfysh_client
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.topicId = new System.Windows.Forms.TextBox();
|
||||
this.serverUrl = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.username = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.password = new System.Windows.Forms.TextBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.connectionType = new System.Windows.Forms.ComboBox();
|
||||
this.panel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@@ -43,64 +51,164 @@ namespace ntfysh_client
|
||||
this.panel1.Controls.Add(this.button2);
|
||||
this.panel1.Controls.Add(this.button1);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 81);
|
||||
this.panel1.Location = new System.Drawing.Point(0, 244);
|
||||
this.panel1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(297, 44);
|
||||
this.panel1.TabIndex = 0;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button1.Location = new System.Drawing.Point(212, 11);
|
||||
this.button1.Margin = new System.Windows.Forms.Padding(3, 10, 10, 10);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 2;
|
||||
this.button1.Text = "Subscribe";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
this.panel1.Size = new System.Drawing.Size(346, 51);
|
||||
this.panel1.TabIndex = 8;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button2.Location = new System.Drawing.Point(131, 11);
|
||||
this.button2.Margin = new System.Windows.Forms.Padding(10, 10, 3, 10);
|
||||
this.button2.Location = new System.Drawing.Point(153, 13);
|
||||
this.button2.Margin = new System.Windows.Forms.Padding(12, 12, 4, 12);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
||||
this.button2.TabIndex = 1;
|
||||
this.button2.Size = new System.Drawing.Size(88, 27);
|
||||
this.button2.TabIndex = 7;
|
||||
this.button2.Text = "Cancel";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button1.Location = new System.Drawing.Point(247, 13);
|
||||
this.button1.Margin = new System.Windows.Forms.Padding(4, 12, 12, 12);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(88, 27);
|
||||
this.button1.TabIndex = 6;
|
||||
this.button1.Text = "Subscribe";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 23);
|
||||
this.label1.Location = new System.Drawing.Point(14, 10);
|
||||
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(51, 13);
|
||||
this.label1.Size = new System.Drawing.Size(52, 15);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "Topic ID:";
|
||||
//
|
||||
// topicId
|
||||
//
|
||||
this.topicId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
this.topicId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.topicId.Location = new System.Drawing.Point(15, 39);
|
||||
this.topicId.Location = new System.Drawing.Point(14, 29);
|
||||
this.topicId.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.topicId.Name = "topicId";
|
||||
this.topicId.Size = new System.Drawing.Size(273, 20);
|
||||
this.topicId.TabIndex = 0;
|
||||
this.topicId.Size = new System.Drawing.Size(318, 23);
|
||||
this.topicId.TabIndex = 1;
|
||||
this.topicId.KeyDown += new System.Windows.Forms.KeyEventHandler(this.topicId_KeyDown);
|
||||
//
|
||||
// serverUrl
|
||||
//
|
||||
this.serverUrl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.serverUrl.Location = new System.Drawing.Point(14, 74);
|
||||
this.serverUrl.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.serverUrl.Name = "serverUrl";
|
||||
this.serverUrl.Size = new System.Drawing.Size(318, 23);
|
||||
this.serverUrl.TabIndex = 2;
|
||||
this.serverUrl.Text = "wss://ntfy.sh";
|
||||
this.serverUrl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.serverUrl_KeyDown);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 55);
|
||||
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(66, 15);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Server URL:";
|
||||
//
|
||||
// username
|
||||
//
|
||||
this.username.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.username.Location = new System.Drawing.Point(14, 119);
|
||||
this.username.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.username.Name = "username";
|
||||
this.username.Size = new System.Drawing.Size(318, 23);
|
||||
this.username.TabIndex = 3;
|
||||
this.username.KeyDown += new System.Windows.Forms.KeyEventHandler(this.username_KeyDown);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(12, 100);
|
||||
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(63, 15);
|
||||
this.label3.TabIndex = 5;
|
||||
this.label3.Text = "Username:";
|
||||
//
|
||||
// password
|
||||
//
|
||||
this.password.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.password.Location = new System.Drawing.Point(14, 164);
|
||||
this.password.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.password.Name = "password";
|
||||
this.password.Size = new System.Drawing.Size(318, 23);
|
||||
this.password.TabIndex = 4;
|
||||
this.password.UseSystemPasswordChar = true;
|
||||
this.password.KeyDown += new System.Windows.Forms.KeyEventHandler(this.password_KeyDown);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(12, 145);
|
||||
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(60, 15);
|
||||
this.label4.TabIndex = 7;
|
||||
this.label4.Text = "Password:";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(12, 190);
|
||||
this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(99, 15);
|
||||
this.label5.TabIndex = 9;
|
||||
this.label5.Text = "Connection Type:";
|
||||
//
|
||||
// connectionType
|
||||
//
|
||||
this.connectionType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.connectionType.FormattingEnabled = true;
|
||||
this.connectionType.Items.AddRange(new object[] {
|
||||
"Websockets (Recommended)",
|
||||
"Long HTTP JSON (Robust)"});
|
||||
this.connectionType.Location = new System.Drawing.Point(14, 208);
|
||||
this.connectionType.Name = "connectionType";
|
||||
this.connectionType.Size = new System.Drawing.Size(318, 23);
|
||||
this.connectionType.TabIndex = 5;
|
||||
this.connectionType.TextChanged += new System.EventHandler(this.connectionType_TextChanged);
|
||||
//
|
||||
// SubscribeDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.ClientSize = new System.Drawing.Size(297, 125);
|
||||
this.ClientSize = new System.Drawing.Size(346, 295);
|
||||
this.Controls.Add(this.connectionType);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.password);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.username);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.serverUrl);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.topicId);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "SubscribeDialog";
|
||||
@@ -108,12 +216,16 @@ namespace ntfysh_client
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Subscribe to new topic";
|
||||
this.Load += new System.EventHandler(this.SubscribeDialog_Load);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
private System.Windows.Forms.TextBox serverUrl;
|
||||
private System.Windows.Forms.Label label2;
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
@@ -121,5 +233,11 @@ namespace ntfysh_client
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox topicId;
|
||||
private System.Windows.Forms.TextBox username;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox password;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.ComboBox connectionType;
|
||||
}
|
||||
}
|
@@ -1,25 +1,121 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ntfysh_client
|
||||
{
|
||||
public partial class SubscribeDialog : Form
|
||||
{
|
||||
public SubscribeDialog()
|
||||
private readonly ListBox _notificationTopics;
|
||||
|
||||
public string TopicId => topicId.Text;
|
||||
|
||||
public string ServerUrl => serverUrl.Text;
|
||||
|
||||
public string Username => username.Text;
|
||||
|
||||
public string Password => password.Text;
|
||||
|
||||
public string Unique => $"{topicId.Text}@{serverUrl.Text}";
|
||||
|
||||
public bool UseWebsockets
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (connectionType.Text)
|
||||
{
|
||||
case "Websockets (Recommended)":
|
||||
return true;
|
||||
|
||||
case "Long HTTP JSON (Robust)":
|
||||
return false;
|
||||
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SubscribeDialog(ListBox notificationTopics)
|
||||
{
|
||||
_notificationTopics = notificationTopics;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public string getTopicId()
|
||||
private void SubscribeDialog_Load(object sender, EventArgs e)
|
||||
{
|
||||
return topicId.Text;
|
||||
connectionType.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private bool ReparseAddress()
|
||||
{
|
||||
//Separate schema and address
|
||||
string[] parts = serverUrl.Text.Split("://", 2);
|
||||
|
||||
//Validate the basic formatting is correct
|
||||
if (parts.Length != 2) return false;
|
||||
|
||||
//Take the schema aside for parsing
|
||||
string schema = parts[0].ToLower();
|
||||
|
||||
//Ensure the schema is actually valid
|
||||
switch (schema)
|
||||
{
|
||||
case "http":
|
||||
case "https":
|
||||
case "ws":
|
||||
case "wss":
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
//Correct the schema based on connection type if required
|
||||
if (UseWebsockets)
|
||||
{
|
||||
switch (schema)
|
||||
{
|
||||
case "http":
|
||||
schema = "ws";
|
||||
break;
|
||||
|
||||
case "https":
|
||||
schema = "wss";
|
||||
break;
|
||||
|
||||
case "ws":
|
||||
case "wss":
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (schema)
|
||||
{
|
||||
case "ws":
|
||||
schema = "http";
|
||||
break;
|
||||
|
||||
case "wss":
|
||||
schema = "https";
|
||||
break;
|
||||
|
||||
case "http":
|
||||
case "https":
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Reconstruct the address
|
||||
string finalAddress = schema + "://" + parts[1];
|
||||
|
||||
//Validate the address
|
||||
if (!Uri.IsWellFormedUriString(finalAddress, UriKind.Absolute)) return false;
|
||||
|
||||
//Set the final address and OK it
|
||||
serverUrl.Text = finalAddress;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
@@ -32,6 +128,58 @@ namespace ntfysh_client
|
||||
return;
|
||||
}
|
||||
|
||||
if (serverUrl.Text.Length < 1)
|
||||
{
|
||||
MessageBox.Show("You must specify a server URL. The default is wss://ntfy.sh", "Server URL not specified", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
DialogResult = DialogResult.None;
|
||||
serverUrl.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (username.Text.Length > 0 && password.Text.Length < 1)
|
||||
{
|
||||
MessageBox.Show("You must specify a password alongside the username", "Password not specified", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
DialogResult = DialogResult.None;
|
||||
password.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.Text.Length > 0 && username.Text.Length < 1)
|
||||
{
|
||||
MessageBox.Show("You must specify a username alongside the password", "Username not specified", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
DialogResult = DialogResult.None;
|
||||
username.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_notificationTopics.Items.Contains(Unique))
|
||||
{
|
||||
MessageBox.Show($"The specified topic '{topicId.Text}' on the server '{serverUrl.Text}' is already subscribed", "Topic already subscribed", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
DialogResult = DialogResult.None;
|
||||
username.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!ReparseAddress())
|
||||
{
|
||||
MessageBox.Show($"The specified server URL is invalid. Accepted schemas are: http:// https:// ws:// wss://", "Invalid Server URL", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
DialogResult = DialogResult.None;
|
||||
connectionType.Focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
MessageBox.Show($"The selected Connection Type '{connectionType.Text}' is invalid.", "Invalid Connection Type", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
DialogResult = DialogResult.None;
|
||||
connectionType.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
@@ -48,5 +196,37 @@ namespace ntfysh_client
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void serverUrl_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyData == Keys.Enter)
|
||||
{
|
||||
button1.PerformClick();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void username_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyData == Keys.Enter)
|
||||
{
|
||||
button1.PerformClick();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void password_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyData == Keys.Enter)
|
||||
{
|
||||
button1.PerformClick();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void connectionType_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
ReparseAddress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,64 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
@@ -1,114 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{5A18D152-D620-43FE-B844-DEF30CFA50EF}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>ntfysh_client</RootNamespace>
|
||||
<AssemblyName>ntfysh</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<ApplicationIcon>NotificationHub.ico</ApplicationIcon>
|
||||
<StartupObject>ntfysh_client.Program</StartupObject>
|
||||
<AssemblyName>ntfy.sh</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AboutBox.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="AboutBox.Designer.cs">
|
||||
<DependentUpon>AboutBox.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="NotificationListener.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SubscribeDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SubscribeDialog.Designer.cs">
|
||||
<DependentUpon>SubscribeDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="AboutBox.resx">
|
||||
<DependentUpon>AboutBox.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="SubscribeDialog.resx">
|
||||
<DependentUpon>SubscribeDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="NotificationHub.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
</Project>
|
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
|
||||
</packages>
|
Reference in New Issue
Block a user