Skip to content

Commit c9647a8

Browse files
committed
♻️ Refactoring
- Updated conditional defines for switching between Indy and NetHTTP - Updated readme documentation - FreeAndNil removed from Api classes.
1 parent e15201a commit c9647a8

File tree

11 files changed

+25
-35
lines changed

11 files changed

+25
-35
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ Support to notifications that contains ```broadcast``` actions has not been impl
8989
Ntfy for Delphi uses a few libraries in the messages subscription and publishing mechanism. There is no need to install. The respective credit adviced.
9090

9191
* [NxHorizon](https://github.com/dalijap/nx-horizon) by Dalija Prasnikar.
92-
* [Indy10](https://github.com/IndySockets/Indy) by IndySockets.
9392
* [JsonToDelphiClass](https://github.com/PKGeorgiev) by Petar Georgiev.
94-
* NetHTTP (On development 🛠)
93+
* [NetHTTP](https://docwiki.embarcadero.com/RADStudio/Rio/en/Using_an_HTTP_Client) native components.
94+
* [Indy10](https://github.com/IndySockets/Indy) by IndySockets. (optional)
95+
96+
## ♻ Switching between NetHTTP and Indy
97+
98+
The library's default behavior is to use NetHTTP for managing the HTTP communications. However, if you are like to use Indy over NetHTTP, you can go to `Project > Options > Building > Delphi Compiler > Conditional Defines` and add `NTFY_HTTP_INDY` in the conditional defines list.
99+
95100

96101
## 🌱 Consider Contributing
97102

98103
Ntfy for Delphi it's an open source project under the MIT license. Feel free to use or contribute!
99-
100-
## ⚠ Observations
101-
For the moment this library uses OpenSSL and is necessary to have it in the executable's folder. Support for NetHTTP is on work.

samples/console/publisher/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</div>
44

55
## ⚠ Observations
6-
Provide a topic for publishing messages. You also must have SSL libraries for running this project.
6+
Provide a topic for publishing messages.
77

88
``` pascal
99
Ntfy.Notification(

samples/console/subscriber/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,4 @@ end;
7171
Ntfy.Filter(TNotifyFilter.MESSAGECONTENT, 'some text');
7272
Ntfy.Filter(TNotifyFilter.TAGS, 'some text');
7373
Ntfy.Filter(TNotifyFilter.PRIORITY, IntToStr(Ord(TNotifyPriority.MAX)));
74-
```
75-
76-
## ⚠ Observations
77-
You must have SSL libraries in order to run this project.
74+
```

samples/vcl/publisher/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,4 @@ cd delphi-notify\tests
2020
docker compose create
2121
docker cp .\server.yml ntfy:/etc/ntfy
2222
docker compose up
23-
```
24-
25-
## ⚠ Observations
26-
You must have SSL libraries in order to run this project.
23+
```

samples/vcl/subscriber/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,4 @@ cd delphi-notify\tests
5454
docker compose create
5555
docker cp .\server.yml ntfy:/etc/ntfy
5656
docker compose up
57-
```
58-
59-
## ⚠ Observations
60-
You must have SSL libraries in order to run this project.
57+
```

src/Notify.Api.Factory.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ implementation
2222

2323
function TNotifyApiFactory.Api: INotifyApi;
2424
begin
25-
{$IFDEF INDY}
25+
{$IFDEF NTFY_HTTP_INDY}
2626
Result := TNotifyApiIndy.New
2727
{$ELSE}
2828
Result := TNotifyApiNetHTTP.New;

src/Notify.Api.Indy.pas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ destructor TNotifyApiIndy.Destroy;
214214
try
215215
Destroythread;
216216
finally
217-
FreeAndNil(FResponse);
218-
FreeAndNil(FIdHTTP);
219-
FreeAndNil(FIOHandlerSSL);
220-
FreeAndNil(FURLParametersList);
221-
FreeAndNil(FBodyStream);
217+
FResponse.Free;
218+
FIdHTTP.Free;
219+
FIOHandlerSSL.Free;
220+
FURLParametersList.Free;
221+
FBodyStream.Free;
222222
end;
223223
inherited;
224224
end;

src/Notify.Api.NetHTTP.pas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ destructor TNotifyApiNetHTTP.Destroy;
205205
try
206206
Destroythread;
207207
finally
208-
FreeAndNil(FResponse);
209-
FreeAndNil(FNetClient);
210-
FreeAndNil(FNetHTTPRequest);
211-
FreeAndNil(FURLParametersList);
212-
FreeAndNil(FBodyStream);
208+
FResponse.Free;
209+
FNetClient.Free;
210+
FNetHTTPRequest.Free;
211+
FURLParametersList.Free;
212+
FBodyStream.Free;
213213
end;
214214
inherited;
215215
end;

src/Notify.Core.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function TNotifyCore.DisableFireBase(const AValue: Boolean): INotifyCore;
138138

139139
procedure TNotifyCore.DoLoadLibrary;
140140
begin
141-
{$IF DEFINED(INDY)}
141+
{$IF DEFINED(NTFY_HTTP_INDY)}
142142
try
143143
{$IFDEF WIN32 or WIN64}
144144
LoadLibraries('libeay32.dll');

tests/NtfyForDelphiTests.dproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<DCC_K>false</DCC_K>
6060
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace)</DCC_Namespace>
6161
<DCC_UnitSearchPath>$(BDS)\Source\DUnit\src;..\src\;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
62-
<DCC_Define>CONSOLE_TESTRUNNER;INDY;$(DCC_Define)</DCC_Define>
62+
<DCC_Define>CONSOLE_TESTRUNNER;$(DCC_Define)</DCC_Define>
6363
<VerInfo_Locale>1033</VerInfo_Locale>
6464
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
6565
<SanitizedProjectName>NtfyForDelphiTests</SanitizedProjectName>

tests/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,4 @@ docker compose up
3535
RegisterTest('Send icons', TTestIcons.Suite);
3636
RegisterTest('Send url attachments', TTestURLAttachments.Suite);
3737
```
38-
<br/>
39-
40-
## ⚠ Observations
41-
You must have SSL libraries in order to run this project.
38+
<br/>

0 commit comments

Comments
 (0)