- Timestamp:
- Aug 24, 2019, 10:44:11 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:ignore
set to
Android
Win32
__recovery
__history
-
Property svn:ignore
set to
-
trunk/OdorikApi.dpr
r2 r3 6 6 UFormMain in 'UFormMain.pas' {FormMain}, 7 7 UFormSettings in 'UFormSettings.pas' {FormSettings}, 8 UFormCalls in 'UFormCalls.pas' {FormCalls}; 8 UFormCalls in 'UFormCalls.pas' {FormCalls}, 9 UOdorikApi in 'UOdorikApi.pas'; 9 10 10 11 {$R *.res} -
trunk/OdorikApi.dproj
r2 r3 7 7 <Base>True</Base> 8 8 <Config Condition="'$(Config)'==''">Debug</Config> 9 <Platform Condition="'$(Platform)'==''"> Android</Platform>9 <Platform Condition="'$(Platform)'==''">Win32</Platform> 10 10 <TargetedPlatforms>19</TargetedPlatforms> 11 11 <AppType>Application</AppType> … … 169 169 <FormType>fmx</FormType> 170 170 </DCCReference> 171 <DCCReference Include="UOdorikApi.pas"/> 171 172 <BuildConfiguration Include="Release"> 172 173 <Key>Cfg_2</Key> … … 197 198 </Platform> 198 199 </DeployFile> 200 <DeployFile LocalName="libeay32.dll" Configuration="Debug" Class="File"> 201 <Platform Name="Win32"> 202 <RemoteName>libeay32.dll</RemoteName> 203 <Overwrite>true</Overwrite> 204 </Platform> 205 </DeployFile> 199 206 <DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_LauncherIcon_72x72.png" Configuration="Debug" Class="Android_LauncherIcon72"> 200 207 <Platform Name="Android"> … … 333 340 <Platform Name="Android"> 334 341 <RemoteName>ic_launcher.png</RemoteName> 342 <Overwrite>true</Overwrite> 343 </Platform> 344 </DeployFile> 345 <DeployFile LocalName="ssleay32.dll" Configuration="Debug" Class="File"> 346 <Platform Name="Win32"> 347 <RemoteName>ssleay32.dll</RemoteName> 335 348 <Overwrite>true</Overwrite> 336 349 </Platform> -
trunk/UFormCalls.fmx
r2 r3 28 28 Size.Height = 48.000000000000000000 29 29 Size.PlatformDefault = False 30 Text = ' Settings'30 Text = 'Calls' 31 31 TabOrder = 1 32 32 end … … 60 60 TabOrder = 0 61 61 Text = 'History' 62 ExplicitSize.cx = 98.000000000000000000 63 ExplicitSize.cy = 49.000000000000000000 62 64 object ListView1: TListView 63 65 ItemAppearanceClassName = 'TListItemAppearance' … … 87 89 TabOrder = 0 88 90 Text = 'Active' 91 ExplicitSize.cx = 98.000000000000000000 92 ExplicitSize.cy = 49.000000000000000000 89 93 end 90 94 object TabItemStatistics: TTabItem … … 99 103 TabOrder = 0 100 104 Text = 'Statistics' 105 ExplicitSize.cx = 100.000000000000000000 106 ExplicitSize.cy = 49.000000000000000000 101 107 end 102 108 end -
trunk/UFormCalls.pas
r2 r3 82 82 IntervalTo := Now; 83 83 IntervalFrom := IntervalTo - OneHour * 24; 84 Response := FormMain. SendGet('/calls.json', 'from=' + DateTimeToXMLTime(IntervalFrom) +84 Response := FormMain.OdorikApi.SendGet('/calls.json', 'from=' + DateTimeToXMLTime(IntervalFrom) + 85 85 '&to=' + DateTimeToXMLTime(IntervalTo)); 86 86 LJsonResponse := TJSONObject.ParseJSONValue(Response); -
trunk/UFormMain.fmx
r2 r3 57 57 end 58 58 end 59 object Timer1: TTimer 60 OnTimer = Timer1Timer 61 Left = 328 62 Top = 344 63 end 59 64 object MultiView1: TMultiView 60 65 MasterButton = SpeedButtonMenu … … 64 69 Size.Height = 473.000000000000000000 65 70 Size.PlatformDefault = False 71 Visible = False 66 72 TabOrder = 0 67 73 object Rectangle1: TRectangle … … 124 130 end 125 131 end 126 object IdHTTP1: TIdHTTP127 IOHandler = IdSSLIOHandlerSocketOpenSSL1128 AllowCookies = True129 ProxyParams.BasicAuthentication = False130 ProxyParams.ProxyPort = 0131 Request.ContentLength = -1132 Request.ContentRangeEnd = -1133 Request.ContentRangeStart = -1134 Request.ContentRangeInstanceLength = -1135 Request.Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'136 Request.BasicAuthentication = False137 Request.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)'138 Request.Ranges.Units = 'bytes'139 Request.Ranges = <>140 HTTPOptions = [hoForceEncodeParams]141 Left = 192142 Top = 336143 end144 object Timer1: TTimer145 OnTimer = Timer1Timer146 Left = 328147 Top = 344148 end149 object IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL150 MaxLineAction = maException151 Port = 0152 DefaultPort = 0153 SSLOptions.Mode = sslmUnassigned154 SSLOptions.VerifyMode = []155 SSLOptions.VerifyDepth = 0156 Left = 192157 Top = 280158 end159 132 end -
trunk/UFormMain.pas
r2 r3 7 7 FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, 8 8 FMX.Layouts, FMX.Objects, FMX.Controls.Presentation, FMX.MultiView, IniFiles, 9 System.IOUtils, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, 10 IdHTTP{$IFDEF ANDROID},IdSSLOpenSSLHeaders{$endif}, IdIOHandler, IdIOHandlerSocket, 11 IdIOHandlerStack, IdSSL, IdSSLOpenSSL; 9 System.IOUtils, UOdorikApi; 12 10 13 11 type … … 23 21 VertScrollBox2: TVertScrollBox; 24 22 LabelCredit: TLabel; 25 IdHTTP1: TIdHTTP;26 23 Timer1: TTimer; 27 IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;28 24 RectangleCalls: TRectangle; 29 25 Label1: TLabel; … … 31 27 procedure FormCreate(Sender: TObject); 32 28 procedure FormSaveState(Sender: TObject); 33 procedure ButtonReloadCreditClick(Sender: TObject);34 29 procedure Timer1Timer(Sender: TObject); 35 30 procedure FormShow(Sender: TObject); … … 38 33 { Private declarations } 39 34 public 40 UserName: string; 41 Password: string; 42 ServerUrl: string; 35 OdorikApi: TOdorikApi; 43 36 Credit: Double; 44 37 ConfigFileName: string; … … 46 39 procedure LoadConfig; 47 40 procedure SaveConfig; 48 procedure GetCredit;49 function SendGet(Path: string; Parameters: string = ''): string;50 41 end; 51 42 … … 61 52 UFormSettings, UFormCalls; 62 53 63 procedure TFormMain.ButtonReloadCreditClick(Sender: TObject);64 begin65 GetCredit;66 end;67 68 54 procedure TFormMain.FormCreate(Sender: TObject); 69 55 begin 70 {$IFDEF ANDROID} 71 IdOpenSSLSetLibPath(System.IOUtils.TPath.GetDocumentsPath); 72 {$ENDIF} 56 OdorikApi := TOdorikApi.Create(nil); 73 57 ConfigFileName := TPath.Combine(TPath.GetHomePath, 'OdorikApi.ini'); 74 58 LoadConfig; … … 85 69 procedure 86 70 begin 87 GetCredit;71 Credit := OdorikApi.GetCredit; 88 72 end).Start; 89 end;90 91 procedure TFormMain.GetCredit;92 var93 Response: string;94 Value: Extended;95 begin96 Response := SendGet('/balance');97 if Response <> '' then begin98 Response := StringReplace(Response, '.', FormatSettings.DecimalSeparator, [rfReplaceAll]);99 if TryStrToFloat(Response, Value) then100 Credit := Value101 else Credit := 0;102 end else Credit := 0;103 73 end; 104 74 … … 110 80 with IniFile do 111 81 try 112 UserName := ReadString('General', 'UserName', '');113 Password := ReadString('General', 'Password', '');114 ServerUrl := ReadString('General', 'ServerUrl', 'https://www.odorik.cz/api/v1');82 OdorikApi.UserName := ReadString('General', 'UserName', ''); 83 OdorikApi.Password := ReadString('General', 'Password', ''); 84 OdorikApi.ServerUrl := ReadString('General', 'ServerUrl', 'https://www.odorik.cz/api/v1'); 115 85 finally 116 86 IniFile.Free; … … 137 107 with IniFile do 138 108 try 139 WriteString('General', 'UserName', UserName);140 WriteString('General', 'Password', Password);141 WriteString('General', 'ServerUrl', ServerUrl);109 WriteString('General', 'UserName', OdorikApi.UserName); 110 WriteString('General', 'Password', OdorikApi.Password); 111 WriteString('General', 'ServerUrl', OdorikApi.ServerUrl); 142 112 finally 143 113 IniFile.Free; … … 145 115 end; 146 116 147 function TFormMain.SendGet(Path: string; Parameters: string = ''): string;148 var149 Url: string;150 begin151 if (ServerUrl <> '') and (UserName <> '') and (Password <> '') then begin152 Url := ServerUrl + Path + '?user=' + UserName + '&password=' + Password;153 if Parameters <> '' then Url := Url + '&' + Parameters;154 Result := IdHTTP1.Get(Url);155 end else Result := '';156 end;157 117 158 118 procedure TFormMain.Timer1Timer(Sender: TObject); … … 160 120 if ReloadPending then begin 161 121 ReloadPending := False; 162 GetCredit;122 Credit := OdorikApi.GetCredit; 163 123 end; 164 124 LabelCredit.Text := 'Credit: ' + FloatToStr(Credit) + ' Kè'; -
trunk/UFormSettings.pas
r2 r3 57 57 begin 58 58 if AResult = mrOk then 59 FormMain. Password := AValues[0];59 FormMain.OdorikApi.Password := AValues[0]; 60 60 end; 61 61 62 62 procedure TFormSettings.RectanglePasswordClick(Sender: TObject); 63 63 begin 64 TDialogService.InputQuery('Password', ['Password'], [FormMain. Password], PasswordQuery);64 TDialogService.InputQuery('Password', ['Password'], [FormMain.OdorikApi.Password], PasswordQuery); 65 65 end; 66 66 67 67 procedure TFormSettings.RectangleServerUrlClick(Sender: TObject); 68 68 begin 69 TDialogService.InputQuery('Server URL', ['Server URL'], [FormMain. ServerUrl], ServerUrlQuery);69 TDialogService.InputQuery('Server URL', ['Server URL'], [FormMain.OdorikApi.ServerUrl], ServerUrlQuery); 70 70 end; 71 71 72 72 procedure TFormSettings.RectangleUserNameClick(Sender: TObject); 73 73 begin 74 TDialogService.InputQuery('User name', ['User name'], [FormMain. UserName], UserNameQuery);74 TDialogService.InputQuery('User name', ['User name'], [FormMain.OdorikApi.UserName], UserNameQuery); 75 75 end; 76 76 … … 79 79 begin 80 80 if AResult = mrOk then 81 FormMain. ServerUrl := AValues[0];81 FormMain.OdorikApi.ServerUrl := AValues[0]; 82 82 end; 83 83 … … 91 91 begin 92 92 if AResult = mrOk then 93 FormMain. UserName := AValues[0];93 FormMain.OdorikApi.UserName := AValues[0]; 94 94 end; 95 95
Note:
See TracChangeset
for help on using the changeset viewer.