diff --git a/sample/console/publisher/ConsolePublisher.dproj b/sample/console/publisher/ConsolePublisher.dproj index 9a22f94..e1238e7 100644 --- a/sample/console/publisher/ConsolePublisher.dproj +++ b/sample/console/publisher/ConsolePublisher.dproj @@ -50,8 +50,8 @@ true - .\lib - .\bin + ..\..\..\lib + ..\..\..\bin false false false diff --git a/sample/console/subscriber/ConsoleSubscriber.dproj b/sample/console/subscriber/ConsoleSubscriber.dproj index 5afc157..c7144f5 100644 --- a/sample/console/subscriber/ConsoleSubscriber.dproj +++ b/sample/console/subscriber/ConsoleSubscriber.dproj @@ -50,8 +50,8 @@ true - .\lib - .\bin + ..\..\..\lib + ..\..\..\bin false false false diff --git a/sample/lib/README.md b/sample/openssl/README.md similarity index 100% rename from sample/lib/README.md rename to sample/openssl/README.md diff --git a/sample/lib/lib.zip b/sample/openssl/lib.zip similarity index 100% rename from sample/lib/lib.zip rename to sample/openssl/lib.zip diff --git a/sample/vcl/publisher/Ntfy-54x.ico b/sample/vcl/publisher/Ntfy-54x.ico new file mode 100644 index 0000000..a409f41 Binary files /dev/null and b/sample/vcl/publisher/Ntfy-54x.ico differ diff --git a/sample/vcl/publisher/VCLPublisher.dproj b/sample/vcl/publisher/VCLPublisher.dproj index 789fceb..e9445ca 100644 --- a/sample/vcl/publisher/VCLPublisher.dproj +++ b/sample/vcl/publisher/VCLPublisher.dproj @@ -46,8 +46,8 @@ true - .\lib - .\bin + ..\..\..\lib + ..\..\..\bin false false false @@ -68,9 +68,10 @@ Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) Debug true - CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= - 1033 + VCLPublisher_Icon.ico $(BDS)\bin\default_app.manifest + C:\Users\PRG1\Pictures\Ntfy.png + C:\Users\PRG1\Pictures\Ntfy.png DBXSqliteDriver;IndyIPCommon;RESTComponents;bindcompdbx;DBXInterBaseDriver;vcl;IndyIPServer;vclactnband;vclFireDAC;IndySystem;bindcompvclsmp;tethering;bindcompvclwinx;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;vclimg;FireDAC;vcltouch;vcldb;bindcompfmx;FireDACSqliteDriver;FireDACPgDriver;inetdb;soaprtl;DbxCommonDriver;fmx;FireDACIBDriver;fmxdae;xmlrtl;soapmidas;vcledge;fmxobj;vclwinx;rtl;DbxClientDriver;CustomIPTransport;vcldsnap;dbexpress;IndyCore;vclx;bindcomp;appanalytics;dsnap;FireDACCommon;IndyIPClient;bindcompvcl;RESTBackendComponents;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;vclie;bindengine;DBXMySQLDriver;CloudService;dsnapxml;FireDACMySQLDriver;dbrtl;IndyProtocols;inetdbxpress;FireDACCommonODBC;FireDACCommonDriver;inet;fmxase;$(DCC_UsePackage) @@ -133,6 +134,13 @@ + + + Assets\ + Logo44x44.png + true + + VCLPublisher.exe diff --git a/sample/vcl/publisher/VCLPublisher.res b/sample/vcl/publisher/VCLPublisher.res index 234993f..720799d 100644 Binary files a/sample/vcl/publisher/VCLPublisher.res and b/sample/vcl/publisher/VCLPublisher.res differ diff --git a/sample/vcl/publisher/VCLPublisher_Icon.ico b/sample/vcl/publisher/VCLPublisher_Icon.ico new file mode 100644 index 0000000..a409f41 Binary files /dev/null and b/sample/vcl/publisher/VCLPublisher_Icon.ico differ diff --git a/sample/vcl/publisher/assets/ntfy.png b/sample/vcl/publisher/assets/ntfy.png deleted file mode 100644 index 6b969a8..0000000 Binary files a/sample/vcl/publisher/assets/ntfy.png and /dev/null differ diff --git a/sample/vcl/publisher/src/View.Main.dfm b/sample/vcl/publisher/src/View.Main.dfm index 9daa309..951274d 100644 --- a/sample/vcl/publisher/src/View.Main.dfm +++ b/sample/vcl/publisher/src/View.Main.dfm @@ -214,7 +214,7 @@ object ViewMain: TViewMain EditLabel.Height = 13 EditLabel.Caption = 'Username' TabOrder = 12 - TextHint = 'Only for protected topics/servers' + TextHint = '(optional)' end object LbePassword: TLabeledEdit Left = 364 diff --git a/sample/vcl/subscriber/Ntfy-54x.ico b/sample/vcl/subscriber/Ntfy-54x.ico new file mode 100644 index 0000000..a409f41 Binary files /dev/null and b/sample/vcl/subscriber/Ntfy-54x.ico differ diff --git a/sample/vcl/subscriber/VCLSubscriber.dproj b/sample/vcl/subscriber/VCLSubscriber.dproj index 7fde827..3067a2a 100644 --- a/sample/vcl/subscriber/VCLSubscriber.dproj +++ b/sample/vcl/subscriber/VCLSubscriber.dproj @@ -68,9 +68,12 @@ Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) Debug true - CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= - 1033 + Ntfy-54x.ico + C:\Users\PRG1\Pictures\Ntfy.png $(BDS)\bin\default_app.manifest + C:\Users\PRG1\Pictures\Ntfy.png + ..\..\..\bin + ..\..\..\lib DBXSqliteDriver;IndyIPCommon;RESTComponents;bindcompdbx;DBXInterBaseDriver;vcl;IndyIPServer;vclactnband;vclFireDAC;IndySystem;bindcompvclsmp;tethering;bindcompvclwinx;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;vclimg;FireDAC;vcltouch;vcldb;bindcompfmx;FireDACSqliteDriver;FireDACPgDriver;inetdb;soaprtl;DbxCommonDriver;fmx;FireDACIBDriver;fmxdae;xmlrtl;soapmidas;vcledge;fmxobj;vclwinx;rtl;DbxClientDriver;CustomIPTransport;vcldsnap;dbexpress;IndyCore;vclx;bindcomp;appanalytics;dsnap;FireDACCommon;IndyIPClient;bindcompvcl;RESTBackendComponents;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;vclie;bindengine;DBXMySQLDriver;CloudService;dsnapxml;FireDACMySQLDriver;dbrtl;IndyProtocols;inetdbxpress;FireDACCommonODBC;FireDACCommonDriver;inet;fmxase;$(DCC_UsePackage) @@ -88,6 +91,8 @@ true PerMonitorV2 true + C:\Users\PRG1\Pictures\Ntfy.png + C:\Users\PRG1\Pictures\Ntfy.png false @@ -140,6 +145,13 @@ true + + + Assets\ + Logo44x44.png + true + + 1 diff --git a/sample/vcl/subscriber/VCLSubscriber.res b/sample/vcl/subscriber/VCLSubscriber.res index 08457d7..569dafa 100644 Binary files a/sample/vcl/subscriber/VCLSubscriber.res and b/sample/vcl/subscriber/VCLSubscriber.res differ diff --git a/sample/vcl/subscriber/src/Example.Push.Notifications.pas b/sample/vcl/subscriber/src/Example.Push.Notifications.pas index b7e04b7..1d25eaf 100644 --- a/sample/vcl/subscriber/src/Example.Push.Notifications.pas +++ b/sample/vcl/subscriber/src/Example.Push.Notifications.pas @@ -19,7 +19,7 @@ implementation try LNotification := LNotificationCenter.CreateNotification(); try - LNotification.Name := 'Ntfy'; + LNotification.Name := AEvent.Id; LNotification.Title := AEvent.Title; LNotification.AlertBody := AEvent.MessageContent; LNotificationCenter.PresentNotification(LNotification); diff --git a/sample/vcl/subscriber/src/View.Main.dfm b/sample/vcl/subscriber/src/View.Main.dfm index 3c763d0..71e3135 100644 --- a/sample/vcl/subscriber/src/View.Main.dfm +++ b/sample/vcl/subscriber/src/View.Main.dfm @@ -1,7 +1,7 @@ object ViewMain: TViewMain Left = 960 Top = 256 - Caption = 'Subscriber' + Caption = 'Ntfy Subscriber' ClientHeight = 527 ClientWidth = 724 Color = clBtnFace @@ -18,11 +18,11 @@ object ViewMain: TViewMain PixelsPerInch = 96 TextHeight = 13 object lblTopic: TLabel - Left = 271 - Top = 17 - Width = 164 + Left = 445 + Top = 13 + Width = 260 Height = 13 - Caption = 'Topics - for each topic break a line' + Caption = 'Topics - Break a line for each. Don'#39't leave empty lines.' end object BtnSubscribe: TButton Left = 16 @@ -61,19 +61,36 @@ object ViewMain: TViewMain item Expanded = False FieldName = 'ID' - Width = 67 + Width = 50 + Visible = True + end + item + Expanded = False + FieldName = 'TIME' + Width = 118 + Visible = True + end + item + Expanded = False + FieldName = 'PRIORITY' Visible = True end item Expanded = False FieldName = 'TITLE' - Width = 140 + Width = 146 Visible = True end item Expanded = False FieldName = 'MSG' - Width = 318 + Width = 700 + Visible = True + end + item + Expanded = False + FieldName = 'TOPIC' + Width = 300 Visible = True end> end @@ -88,7 +105,7 @@ object ViewMain: TViewMain object GbSince: TRadioGroup Left = 16 Top = 17 - Width = 249 + Width = 89 Height = 71 Caption = 'Since' Enabled = False @@ -105,7 +122,7 @@ object ViewMain: TViewMain Top = 155 Width = 132 Height = 17 - Caption = 'Fectch only scheduled' + Caption = 'Fectch scheduled only' TabOrder = 5 end object CkSince: TCheckBox @@ -113,7 +130,7 @@ object ViewMain: TViewMain Top = 173 Width = 132 Height = 17 - Caption = 'Fetch Cached Messages' + Caption = 'Fetch cached messages' TabOrder = 6 OnClick = CkSinceClick end @@ -170,15 +187,15 @@ object ViewMain: TViewMain Width = 104 Height = 21 Style = csDropDownList - ItemIndex = 5 + ItemIndex = 0 TabOrder = 3 Items.Strings = ( + '' 'Min' 'Low' 'Default' 'High' - 'Maximum' - '') + 'Maximum') end object lbeFilterTags: TLabeledEdit Left = 15 @@ -192,30 +209,13 @@ object ViewMain: TViewMain TextHint = 'Tags' end end - object DtSince: TDateTimePicker - Left = 114 - Top = 59 - Width = 137 - Height = 21 - Date = 44911.000000000000000000 - Time = 0.858430219908768800 - TabOrder = 8 - end - object EdtSince: TEdit - Left = 114 - Top = 32 - Width = 137 - Height = 21 - TabOrder = 9 - TextHint = 'Message id or Unix time' - end object BtnClearTable: TButton Left = 680 - Top = 63 + Top = 107 Width = 25 Height = 25 Caption = #9851 - TabOrder = 10 + TabOrder = 8 OnClick = BtnClearTableClick end object LbeBaseURL: TLabeledEdit @@ -226,20 +226,20 @@ object ViewMain: TViewMain EditLabel.Width = 45 EditLabel.Height = 13 EditLabel.Caption = 'Base URL' - TabOrder = 11 + TabOrder = 9 Text = 'https://ntfy.sh' TextHint = 'Tags' end object MemTopics: TMemo - Left = 271 - Top = 36 + Left = 462 + Top = 32 Width = 243 Height = 52 BorderStyle = bsNone Lines.Strings = ( 'your-very-secret-topic' 'notify-delphi-integration-8jh27d') - TabOrder = 12 + TabOrder = 10 end object BtnHide: TButton Left = 16 @@ -247,7 +247,7 @@ object ViewMain: TViewMain Width = 132 Height = 25 Caption = 'Hide' - TabOrder = 13 + TabOrder = 11 OnClick = BtnHideClick end object LbeUsername: TLabeledEdit @@ -258,7 +258,7 @@ object ViewMain: TViewMain EditLabel.Width = 48 EditLabel.Height = 13 EditLabel.Caption = 'Username' - TabOrder = 14 + TabOrder = 12 TextHint = '(optional)' end object LbePassword: TLabeledEdit @@ -270,9 +270,26 @@ object ViewMain: TViewMain EditLabel.Height = 13 EditLabel.Caption = 'Password' PasswordChar = '*' - TabOrder = 15 + TabOrder = 13 TextHint = '(optional)' end + object DtSince: TDateTimePicker + Left = 111 + Top = 63 + Width = 137 + Height = 21 + Date = 44911.000000000000000000 + Time = 0.858430219908768800 + TabOrder = 14 + end + object EdtSince: TEdit + Left = 111 + Top = 36 + Width = 137 + Height = 21 + TabOrder = 15 + TextHint = 'Message id or Unix time' + end object TableNotification: TFDMemTable FetchOptions.AssignedValues = [evMode] FetchOptions.Mode = fmAll @@ -284,16 +301,33 @@ object ViewMain: TViewMain Left = 568 Top = 336 object TableNotificationID: TStringField + DisplayLabel = 'Id' FieldName = 'ID' Size = 30 end + object TableNotificationTIME: TStringField + DisplayLabel = 'Time' + FieldName = 'TIME' + end + object TableNotificationPRIORITY: TStringField + DisplayLabel = 'Priority' + FieldName = 'PRIORITY' + Size = 10 + end object TableNotificationTITLE: TStringField + DisplayLabel = 'Title' FieldName = 'TITLE' Size = 50 end object TableNotificationMSG: TStringField + DisplayLabel = 'Message' FieldName = 'MSG' - Size = 60 + Size = 500 + end + object TableNotificationTOPIC: TStringField + DisplayLabel = 'Topic' + FieldName = 'TOPIC' + Size = 100 end end object DsTable: TDataSource diff --git a/sample/vcl/subscriber/src/View.Main.pas b/sample/vcl/subscriber/src/View.Main.pas index f992d9c..2d0404c 100644 --- a/sample/vcl/subscriber/src/View.Main.pas +++ b/sample/vcl/subscriber/src/View.Main.pas @@ -33,8 +33,6 @@ TViewMain = class(TForm) lbPriority: TLabel; lbeFilterTags: TLabeledEdit; lblTopic: TLabel; - DtSince: TDateTimePicker; - EdtSince: TEdit; BtnClearTable: TButton; LbeBaseURL: TLabeledEdit; MemTopics: TMemo; @@ -47,6 +45,11 @@ TViewMain = class(TForm) LbeUsername: TLabeledEdit; LbePassword: TLabeledEdit; PopQuit: TMenuItem; + DtSince: TDateTimePicker; + EdtSince: TEdit; + TableNotificationTIME: TStringField; + TableNotificationTOPIC: TStringField; + TableNotificationPRIORITY: TStringField; procedure BtnSubscribeClick(Sender: TObject); procedure BtnUnsubscribeClick(Sender: TObject); procedure GbSinceClick(Sender: TObject); @@ -77,8 +80,8 @@ implementation {$R *.dfm} uses - Example.Push.Notifications, - System.DateUtils; + System.DateUtils, + Example.Push.Notifications; procedure TViewMain.BtnClearTableClick(Sender: TObject); begin @@ -147,7 +150,7 @@ function TViewMain.CheckPriority: String; begin Result := ''; if CbFilterPriority.ItemIndex > 0 then - IntToStr(CbFilterPriority.ItemIndex + 1); + Result := IntToStr(Ord(TNotifyPriority(CbFilterPriority.ItemIndex))); end; procedure TViewMain.CheckSince; @@ -223,9 +226,13 @@ procedure TViewMain.YourCallBackProcedure(AEvent: INotifyEvent); TableNotification.Open; TableNotification.AppendRecord([ AEvent.Id, + FormatDateTime('dd/MM/yyyy hh:mm:ss', UnixToDateTime(AEvent.Time)), + IntToStr(Ord(AEvent.Priority)), AEvent.Title, - AEvent.MessageContent + AEvent.MessageContent, + AEvent.Topic ]); + PushWindowsNotification(AEvent); end; diff --git a/tests/NtfyForDelphiTests.dproj b/tests/NtfyForDelphiTests.dproj index d43706f..363beb4 100644 --- a/tests/NtfyForDelphiTests.dproj +++ b/tests/NtfyForDelphiTests.dproj @@ -50,8 +50,8 @@ true - .\lib - .\bin + ..\lib + ..\bin false false false @@ -94,7 +94,6 @@ false - 1033 (None) diff --git a/tests/README.md b/tests/README.md index 62d24e0..cb8394a 100644 --- a/tests/README.md +++ b/tests/README.md @@ -21,7 +21,7 @@ docker compose up ## 🧪 DUnit Tests * Access http://localhost:80 in your browser and subscribe to ```notify-delphi-integration-8jh27d```. -* Run ```tests\bin\NtfyForDelphiTests.exe```. You should receive the test messages sent from this project. +* Run ```bin\NtfyForDelphiTests.exe```. You should receive the test messages sent from this project. ``` pascal diff --git a/tests/bin/ntfy-31.12.2022.txt b/tests/bin/ntfy-31.12.2022.txt deleted file mode 100644 index 4c3b3f9..0000000 --- a/tests/bin/ntfy-31.12.2022.txt +++ /dev/null @@ -1,13 +0,0 @@ -12/31/2022 5:05:33 PM : https://ntfy.sh/ -12/31/2022 5:05:33 PM : {"message":"A friendly Delphi library to ntfy.sh","priority":5,"title":"\u26A1 Ntfy for Delphi","topic":"notify-delphi-integration-8jh27d"} -12/31/2022 5:05:33 PM : 200 -12/31/2022 5:05:33 PM : {"id":"RQbyHnkhd9AO","time":1672517133,"event":"message","topic":"notify-delphi-integration-8jh27d","title":"⚡ Ntfy for Delphi","message":"A friendly Delphi library to ntfy.sh","priority":5} - -12/31/2022 5:05:35 PM : https://ntfy.sh/ -12/31/2022 5:05:35 PM : {"priority":3,"topic":"notify-delphi-integration-8jh27d","actions":[{"action":"view","clear":false,"label":"Test Action Header","url":"https:\/\/ntfy.sh","headers":{"cmd":"systeminfo","parameter":"\/FO LIST","systemdate":"date"}}]} -12/31/2022 5:05:35 PM : 200 -12/31/2022 5:06:16 PM : https://ntfy.sh/ -12/31/2022 5:06:16 PM : {"message":"A friendly Delphi library to ntfy.sh","priority":5,"title":"\u26A1 Ntfy for Delphi","topic":"notify-delphi-integration-8jh27d"} -12/31/2022 5:06:16 PM : 200 -12/31/2022 5:06:16 PM : {"id":"LuLW4fRqUxi9","time":1672517176,"event":"message","topic":"notify-delphi-integration-8jh27d","title":"⚡ Ntfy for Delphi","message":"A friendly Delphi library to ntfy.sh","priority":5} - diff --git a/tests/src/Test.Attachments.pas b/tests/src/Test.Attachments.pas index 7e60fe6..70a039e 100644 --- a/tests/src/Test.Attachments.pas +++ b/tests/src/Test.Attachments.pas @@ -66,7 +66,7 @@ procedure TTestAttachments.Publish; procedure TTestAttachments.SetUp; begin inherited; - FFilePath := '..\..\img\delphi-notify.png'; + FFilePath := '..\img\delphi-notify.png'; FFileName := ExtractFileName(FFilePath); end;