Skip to content

Commit

Permalink
Merge branch 'main' into net-http
Browse files Browse the repository at this point in the history
  • Loading branch information
p-samuel committed Sep 23, 2023
2 parents 66ac058 + ab49f27 commit 6c09f15
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="./img/delphi-notify.png" width="80%">
</div>

Ntfy was made by [Philipp C. Heckel](https://github.com/binwiederhier). Consider leaving a star in [his project](https://github.com/binwiederhier/ntfy). As [Philipp C. Heckel](https://github.com/binwiederhier) stated, this service will stay free, so any kind of support to afford costs help with cloud hosting will be warmly received. You can also self-host ntfy server. Visit [docs.ntfy.sh](https://docs.ntfy.sh/) to get started with documentation.
Ntfy was made by [Philipp C. Heckel](https://github.com/binwiederhier). Consider leaving a star on [his project](https://github.com/binwiederhier/ntfy). As [Philipp C. Heckel](https://github.com/binwiederhier) stated, this service will stay free, so any kind of support to afford costs help with cloud hosting will be warmly received. You can also self-host ntfy server. Visit [docs.ntfy.sh](https://docs.ntfy.sh/) to get started with documentation.

## 🔔 Ntfy for Delphi

Expand Down
11 changes: 10 additions & 1 deletion src/Notify.Api.Indy.pas
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ function TNotifyApiIndy.Config(const AValue: INotifyConfig): INotifyApi;
begin
Result := Self;
FNotifyConfig := AValue;

if AValue.ProxyServer <> '' then
begin
FIdHttp.ProxyParams.ProxyServer := AValue.ProxyServer;
FIdHttp.ProxyParams.ProxyUsername := AValue.ProxyUser;
FIdHttp.ProxyParams.ProxyPassword := AValue.ProxyPassword;
FIdHttp.ProxyParams.ProxyPort := AValue.ProxyPort;
end;

end;

constructor TNotifyApiIndy.Create;
Expand Down Expand Up @@ -256,7 +265,7 @@ function TNotifyApiIndy.Get: INotifyApi;
FConnectionThread.Start;
end;

{$IFDEF CONSOLE}
{$IFDEF CONSOLE OR CONSOLE_TESTRUNNER}
FConnectionThread.WaitFor;
{$ENDIF}

Expand Down
5 changes: 5 additions & 0 deletions src/Notify.Config.Contract.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ interface
function LogPath(const AValue: String): INotifyConfig; overload;
function SubscriptionType: TNotifySubscriptionType; overload;
function SubscriptionType(const AValue: TNotifySubscriptionType): INotifyConfig; overload;
function ProxyServer: string; overload;
function ProxyUser: string; overload;
function ProxyPassword: string; overload;
function ProxyPort: integer; overload;
function Proxy(const aProxyServer, aProxyUser, aProxyPassword: string; const aProxyPort: integer): INotifyConfig; overload;
end;

implementation
Expand Down
35 changes: 35 additions & 0 deletions src/Notify.Config.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ TNotifyConfig = class sealed(TInterfacedObject, INotifyConfig)
FSaveLog: Boolean;
FLogPath: String;
FSubscriptionType: TNotifySubscriptionType;
FProxyServer, FProxyUser, FProxyPassword: string;
FProxyPort: integer;
public
class function New: INotifyConfig;
private
Expand All @@ -37,6 +39,11 @@ TNotifyConfig = class sealed(TInterfacedObject, INotifyConfig)
function LogPath(const AValue: String): INotifyConfig; overload;
function SubscriptionType: TNotifySubscriptionType; overload;
function SubscriptionType(const AValue: TNotifySubscriptionType): INotifyConfig; overload;
function ProxyServer: string; overload;
function ProxyUser: string; overload;
function ProxyPassword: string; overload;
function ProxyPort: integer; overload;
function Proxy(const aProxyServer, aProxyUser, aProxyPassword: string; const aProxyPort: integer): INotifyConfig; overload;
end;

implementation
Expand Down Expand Up @@ -114,6 +121,34 @@ function TNotifyConfig.Password(const AValue: String): INotifyConfig;
FPassword := AValue;
end;

function TNotifyConfig.Proxy(const AProxyServer, AProxyUser, AProxyPassword: string; const aProxyPort: integer): INotifyConfig;
begin
FProxyServer := AProxyServer;
FProxyUser := AProxyUser;
FProxyPassword := AProxyPassword;
FProxyPort := AProxyPort;
end;

function TNotifyConfig.ProxyPassword: string;
begin
Result := FProxyPassword;
end;

function TNotifyConfig.ProxyPort: integer;
begin
Result := FProxyPort;
end;

function TNotifyConfig.ProxyServer: string;
begin
Result := FProxyServer;
end;

function TNotifyConfig.ProxyUser: string;
begin
Result := FProxyUser;
end;

function TNotifyConfig.SaveLog(const AValue: Boolean): INotifyConfig;
begin
Result := Self;
Expand Down
1 change: 1 addition & 0 deletions src/Notify.Core.Contract.pas
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface
function Scheduled(const AValue: Boolean): INotifyCore; overload;
function Response: TNotifyApiResponse;
function Disconnect: INotifyCore;
function Proxy(const AProxyServer, AProxyUser, AProxyPassword: String; const AProxyPort: Integer): INotifyCore; overload;
end;

INotifyCoreFacade = interface
Expand Down
7 changes: 7 additions & 0 deletions src/Notify.Core.pas
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ TNotifyCore = class sealed(TInterfacedObject, INotifyCore)
function UserName(const AValue: String): INotifyCore;
function Password(const AValue: String): INotifyCore;
function BaseURL(const AValue: String): INotifyCore;
function Proxy(const aProxyServer, aProxyUser, aProxyPassword: string; const aProxyPort: integer): INotifyCore;
function DisableFireBase(const AValue: Boolean): INotifyCore;
function Notification(const ANotification: INotifyNotification): INotifyCore; overload;
function Filter(const AFilterType: TNotifyFilter; const AValue: String): INotifyCore;
Expand Down Expand Up @@ -375,6 +376,12 @@ function TNotifyCore.Poll(const AValue: Boolean): INotifyCore;
FPoll := AValue;
end;

function TNotifyCore.Proxy(const aProxyServer, aProxyUser,
aProxyPassword: string; const aProxyPort: integer): INotifyCore;
begin
FConfig.Proxy(aProxyServer, aProxyUser, aProxyPassword, aProxyPort);
end;

function TNotifyCore.Publish: INotifyCore;
begin
Result := Self;
Expand Down

0 comments on commit 6c09f15

Please sign in to comment.