-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNetworkState.pas
More file actions
79 lines (62 loc) · 1.61 KB
/
NetworkState.pas
File metadata and controls
79 lines (62 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
unit NetworkState;
interface
type
TCustomNetworkState = class(TObject)
function CurrentSSID: string; virtual; abstract;
function IsConnected: Boolean; virtual; abstract;
function IsWifiConnected: Boolean; virtual; abstract;
function IsMobileConnected: Boolean; virtual; abstract;
end;
TNetworkState = class(TCustomNetworkState)
private
FPlatformNetworkState: TCustomNetworkState;
public
constructor Create;
destructor Destroy; override;
function CurrentSSID: string;
function IsConnected: Boolean; override;
function IsWifiConnected: Boolean; override;
function IsMobileConnected: Boolean; override;
end;
implementation
{$IFDEF IOS}
uses
NetworkState.iOS;
{$ENDIF}
{$IFDEF ANDROID}
uses
NetworkState.Android;
{$ENDIF}
{ TNetworkState }
constructor TNetworkState.Create;
begin
inherited;
{$IFDEF IOS}
FPlatformNetworkState := TPlatformNetworkState.Create;
{$ENDIF}
{$IFDEF ANDROID}
FPlatformNetworkState := TPlatformNetworkState.Create;
{$ENDIF}
end;
destructor TNetworkState.Destroy;
begin
FPlatformNetworkState.Free;
inherited;
end;
function TNetworkState.CurrentSSID: string;
begin
Result := FPlatformNetworkState.CurrentSSID;
end;
function TNetworkState.IsConnected: Boolean;
begin
Result := FPlatformNetworkState.IsConnected;
end;
function TNetworkState.IsMobileConnected: Boolean;
begin
Result := FPlatformNetworkState.IsMobileConnected;
end;
function TNetworkState.IsWifiConnected: Boolean;
begin
Result := FPlatformNetworkState.IsWifiConnected;
end;
end.