Skip to content

Commit 6e1f38d

Browse files
committed
Modified to use v6 of database update web service, which has a revised download file format.
1 parent 99552f5 commit 6e1f38d

File tree

2 files changed

+38
-34
lines changed

2 files changed

+38
-34
lines changed

Src/UFileUpdater.pas

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/
55
*
6-
* Copyright (C) 2006-2013, Peter Johnson (www.delphidabbler.com).
6+
* Copyright (C) 2006-2014, Peter Johnson (www.delphidabbler.com).
77
*
88
* $Rev$
99
* $Date$
@@ -124,23 +124,25 @@ implementation
124124
125125
Format is:
126126
127-
FileCount: SmallInt; - number of files encoded in datastream
127+
FileCount: Int16; - number of files encoded in datastream
128128
129129
followed by FileCount file records of:
130130
131-
Name: SizedString; - name of file
131+
Name: SizedString16; - name of file
132132
UnixDate: Int64; - file's modification date (GMT) in Unix format
133133
(must be converted to local time and DOS date
134134
stamp format)
135-
Content: SizedString; - file contents
135+
Content: SizedString32; - file contents
136136
137137
Data types are:
138138
139-
SmallInt - 16 bit integer encoded as 4 hex digits
139+
Int16 - 16 bit integer encoded as 4 hex digits
140+
Int32 - 32 bit integer encoded as 8 hex digits
140141
Int64 - 64 bit integer encoded as 16 hex digits
141-
SizedString - SmallInt specifying string length followed by specified
142-
number of characters
143-
String[32] - 32 character fixed length string
142+
SizedString16 - Int16 specifying string length followed by specified number
143+
of characters
144+
SizedString32 - Int32 specifying string length followed by specified number
145+
of characters
144146
}
145147

146148

@@ -212,7 +214,7 @@ procedure TFileUpdater.UpdateFile;
212214
// Get info about file from data stream
213215
Name := fReader.ReadSizedString16;
214216
UnixDate := fReader.ReadInt64;
215-
Content := fReader.ReadSizedString16;
217+
Content := fReader.ReadSizedString32;
216218
// and create file
217219
WriteFile(Name, Content, UnixDate);
218220
end;

Src/Web.UDBDownloadMgr.pas

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/
55
*
6-
* Copyright (C) 2005-2013, Peter Johnson (www.delphidabbler.com).
6+
* Copyright (C) 2005-2014, Peter Johnson (www.delphidabbler.com).
77
*
88
* $Rev$
99
* $Date$
@@ -166,7 +166,7 @@ implementation
166166

167167

168168
{
169-
Web service notes: codesnip-updt.php v5
169+
Web service notes: codesnip-updt.php v6
170170
=======================================
171171
172172
This web service enables CodeSnip to check if updated files are available in
@@ -176,13 +176,13 @@ implementation
176176
cmd=<command> [<params>]
177177
where <params> is a list of parameters in form param-name=param-value.
178178
179-
All responses from the v5 service have two parts:
179+
All responses from the v6 service have two parts:
180180
+ Successful responses have '0' on first line followed by optional lines of
181181
data resulting from command.
182182
+ Error responses have +ve error code on first line and error message on 2nd
183183
line.
184184
185-
The web service expects a user agent of "DelphiDabbler-CodeSnip-Updater-v5"
185+
The web service expects a user agent of "DelphiDabbler-CodeSnip-Updater-v6"
186186
and will return a 403 "Forbidden" error if this is not provided.
187187
188188
Table of Commands
@@ -191,42 +191,44 @@ implementation
191191
+-----------+-------|----------------------+---------------------------------|
192192
|logon |cmd |"logon" |OK: Stream of news items which |
193193
| |progid |unique id of program |is ignored |
194-
| |version|program version number|ERROR: CSUPDT_ERR_STDPARAMS if |
195-
| |os |operating system info |required params not provided |
194+
| |version|program version number|ERROR: CSUPDT_ERR_STDPARAMS (8) |
195+
| |os |operating system info |if required params not provided |
196196
| |browser|version of IE browser | |
197197
| |caller |application defined | |
198198
| | |string | |
199199
+-----------+-------+----------------------+---------------------------------+
200200
|filecount |cmd |"filecount" |OK: Integer indication number of |
201201
| |progid |unique id of program |files in remote database |
202-
| |version|program version number|ERROR: CSUPDT_ERR_STDPARAMS if |
203-
| | | |required params not provided |
204-
| | | |ERROR: CSUPDT_ERR_LIST if can't |
205-
| | | |list files in database |
202+
| |version|program version number|ERROR: CSUPDT_ERR_STDPARAMS (8) |
203+
| | | |if required params not provided |
204+
| | | |ERROR: CSUPDT_ERR_LIST (2) if |
205+
| | | |can't list files in database |
206206
+-----------+-------+----------------------+---------------------------------+
207207
|lastupdate |cmd |"lastupdate" |OK: Unix time stamp representing |
208208
| |progid |unique id of program |date on which online database was|
209209
| |version|program version number|last updated |
210-
| | | |ERROR: CSUPDT_ERR_STDPARAMS if |
211-
| | | |required params not provided |
212-
| | | |ERROR: CSUPDT_ERR_LIST if can't |
213-
| | | |list files in database |
214-
| | | |ERROR: CSUPDT_ERR_NOTFOUND if |
215-
| | | |can't access a file in database |
210+
| | | |ERROR: CSUPDT_ERR_STDPARAMS (8) |
211+
| | | |if required params not provided |
212+
| | | |ERROR: CSUPDT_ERR_LIST (2) if |
213+
| | | |can't list files in database |
214+
| | | |ERROR: CSUPDT_ERR_NOTFOUND (7) |
215+
| | | |if can't access a file in |
216+
| | | |database |
216217
+-----------+-------+----------------------+---------------------------------+
217218
|getdatabase|cmd |"getdatabase" |OK: All files from on-line |
218219
| |progid |unique id of program |database combined in single |
219220
| |version|program version number|stream of data. |
220-
| | | |ERROR: CSUPDT_ERR_STDPARAMS if |
221-
| | | |required params not provided |
222-
| | | |ERROR: CSUPDT_ERR_LIST if can't |
223-
| | | |list files in database |
224-
| | | |ERROR: CSUPDT_ERR_NOTFOUND if |
225-
| | | |can't access a file in database |
221+
| | | |ERROR: CSUPDT_ERR_STDPARAMS (8) |
222+
| | | |if required params not provided |
223+
| | | |ERROR: CSUPDT_ERR_LIST (2) if |
224+
| | | |can't list files in database |
225+
| | | |ERROR: CSUPDT_ERR_NOTFOUND (7) |
226+
| | | |if can't access a file in |
227+
| | | |database |
226228
+-----------+-------+----------------------+---------------------------------+
227229
|logoff |cmd |"logoff" |OK: No data |
228-
| |progid |unique id of program |ERRORS: CSUPDT_ERR_STDPARAMS if | |
229-
| |version|program version number|required params not provided |
230+
| |progid |unique id of program |ERRORS: CSUPDT_ERR_STDPARAMS (8) | |
231+
| |version|program version number|if required params not provided |
230232
+-----------+-------+----------------------+---------------------------------+
231233
If any other command (or no command) is specified then error code
232234
CSUPDT_ERR_CMD (1) is returned.
@@ -236,7 +238,7 @@ implementation
236238
const
237239
// Web service info
238240
cScriptURLTplt = 'http://%s/websvc/codesnip-updt';
239-
cUserAgent = 'DelphiDabbler-CodeSnip-Updater-v5';
241+
cUserAgent = 'DelphiDabbler-CodeSnip-Updater-v6';
240242

241243

242244
resourcestring

0 commit comments

Comments
 (0)