unit SUAccounts interface type UAccount class private constructor Crea

  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
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
unit SUAccounts;
interface
type
UAccount = class
private
constructor Create();
function Sin_GetAutoconnectMode: Boolean;
function Sin_GetConnectionStatus: Boolean;
function Sin_GetLastLogin: TDateTime;
function Sin_GetLastLogout: TDateTime;
function Sin_GetProfileName: String;
function Sin_GetProxyIP: string;
function Sin_GetProxyPort: Word;
function Sin_GetProxyStatus: Boolean;
procedure Sin_SetAutoconnectMode(const Value: Boolean);
function Sin_GetPauseScriptOnDisconnectStatus: Boolean;
procedure Sin_SetPauseScriptOnDisconnectStatus(const Value: Boolean);
function Sin_GetProfileShardName: String;
function Sin_GetShardName: String;
public
class function Generate():UAccount;
property ProfileName : String read Sin_GetProfileName;
property ShardName : String read Sin_GetShardName;
property ProfileShard : String read Sin_GetProfileShardName;
property LastLogin : TDateTime read Sin_GetLastLogin;
property LastLogout : TDateTime read Sin_GetLastLogout;
property Connected : Boolean read Sin_GetConnectionStatus;
property AutoConnectMode : Boolean read Sin_GetAutoconnectMode write Sin_SetAutoconnectMode;
property AllowOfflineScripts : Boolean read Sin_GetPauseScriptOnDisconnectStatus write Sin_SetPauseScriptOnDisconnectStatus;
property ProxiIP : string read Sin_GetProxyIP;
property ProxyPort : Word read Sin_GetProxyPort;
property IsProxyActive : Boolean read Sin_GetProxyStatus;
function Change(NewProfileName:string;MaxTimeOut:Cardinal = 0): Integer;
function Login(MaxTimeOut:Cardinal):Boolean;
function Logout(MaxTimeOut:Cardinal):Boolean;
end;
var
Account : UAccount;
implementation
uses stealth_script,System.SysUtils,Winapi.Windows;
{ UAccount }
{
Representing States :
* 1 : Profile Already selected
* 0 : Everything worked
* -1 : Internal Error
* -2 : Unable to Change Profile : Char either not Disconnected or Disconnection failed
* -3 : More then one Script were running. Unable to Change Profile
* -4 : The selected Profile doesnt exist
*
}
function UAccount.Change(NewProfileName:string;MaxTimeOut:Cardinal = 0): Integer;
begin
if(ProfileName = NewProfileName)then
begin
Result := 1;
end else begin
if(Connected)then
begin
if(not Logout(MaxTimeOut)) then
begin
Result := -2;
exit;
end;
end;
Result := Script.Connection.ChangeProfile(NewProfileName);
end;
end;
constructor UAccount.Create;
begin
//Virtual
end;
class function UAccount.Generate: UAccount;
begin
Result := UAccount.Create();
end;
function UAccount.Login(MaxTimeOut: Cardinal): Boolean;
var
val : Cardinal;
begin
Result := False;
if(Connected)and(not Result) then
begin
Result := True;
end else begin
val := GetTickCount + MaxTimeOut;
Script.Connection.Connect;
while(GetTickCount < val)and(not Connected) do
begin
Script.Wait(25);
end;
Result := (Connected);
end;
end;
function UAccount.Logout(MaxTimeOut: Cardinal): Boolean;
var
val : Cardinal;
begin
Result := False;
if(not Connected)and(not Result) then
begin
Result := True;
end else begin
val := GetTickCount + MaxTimeOut;
Script.Connection.Disconnect;
while(GetTickCount < val)and(Connected) do
begin
Script.Wait(25);
end;
Result := (not Connected);
end;
end;
function UAccount.Sin_GetAutoconnectMode: Boolean;
begin
Result := Script.Connection.ARStatus;
end;
function UAccount.Sin_GetConnectionStatus: Boolean;
begin
Result := Script.Connection.Connected;
end;
function UAccount.Sin_GetLastLogin: TDateTime;
begin
Result := Script.Connection.ConnectedTime;
end;
function UAccount.Sin_GetLastLogout: TDateTime;
begin
Result := Script.Connection.DisconnectedTime;
end;
function UAccount.Sin_GetPauseScriptOnDisconnectStatus: Boolean;
begin
Result := Script.Connection.PauseScriptOnDisconnectStatus
end;
function UAccount.Sin_GetProfileName: String;
begin
Result := Script.Connection.ProfileName();
end;
function UAccount.Sin_GetProfileShardName: String;
begin
Result := Script.Connection.ProfileShardName;
end;
function UAccount.Sin_GetProxyIP : string;
begin
Result := Script.Connection.ProxyIP;
end;
function UAccount.Sin_GetProxyPort: Word;
begin
Result := Script.Connection.ProxyPort;
end;
function UAccount.Sin_GetProxyStatus: Boolean;
begin
Result := Script.Connection.ProxyUsed;
end;
function UAccount.Sin_GetShardName: String;
begin
Result := Script.Connection.ShardName;
end;
procedure UAccount.Sin_SetAutoconnectMode(const Value: Boolean);
begin
Script.Connection.ARStatus := Value;
end;
procedure UAccount.Sin_SetPauseScriptOnDisconnectStatus(const Value: Boolean);
begin
Script.Connection.PauseScriptOnDisconnectStatus := Value;
end;
initialization
Account := UAccount.Generate();
finalization
if(Assigned(Account)) then FreeAndNil(Account);
end.