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) 2012-2013 , Peter Johnson (www.delphidabbler.com).
6+ * Copyright (C) 2012-2014 , Peter Johnson (www.delphidabbler.com).
77 *
88 * $Rev$
99 * $Date$
@@ -26,7 +26,7 @@ interface
2626
2727type
2828 // / <summary>Provides an interface to the DelphiDabbler CodeSnip program
29- // / update web service.</summary>
29+ // / update web service using the v2 API .</summary>
3030 // / <remarks>This class provides a public method for every command exposed by
3131 // / the web service.</remarks>
3232 TProgramUpdateMgr = class sealed(TStdWebService)
@@ -36,8 +36,12 @@ TProgramUpdateMgr = class sealed(TStdWebService)
3636 ScriptURLTplt = ' http://codesnip.%s/websvc/prog-update' ;
3737 // / <summary>User agent sent to web service.</summary>
3838 UserAgent = ' CodeSnip' ;
39+ // / <summary>API version of web service.</summary>
40+ ApiVersion = ' 2' ;
3941 // / <summary>API key required for all calls to web service.</summary>
4042 ApiKey = ' 9EE3A4D85A2F46F79AE2AAB1012A7678' ;
43+ // / <summary>Release channel sent to web service.</summary>
44+ Channel = ' 4' ;
4145 // / <summary>Program edition sent to web service.</summary>
4246 { $IFDEF PORTABLE}
4347 Edition = ' portable' ;
@@ -50,6 +54,9 @@ TProgramUpdateMgr = class sealed(TStdWebService)
5054 // / </summary>
5155 // / <remarks>Callers must free the returned object.</remarks>
5256 function CreateParams : TURIParams;
57+ // / <summary>Adds channel and edition parameters to the given parameters.
58+ // / </summary>
59+ procedure AddUpdateStreamParams (Params: TURIParams);
5360 public
5461 // / <summary>Creates a new object instance with the correct URL and
5562 // / suitable user agent.</summary>
@@ -83,6 +90,13 @@ implementation
8390
8491{ TProgramUpdateMgr }
8592
93+ procedure TProgramUpdateMgr.AddUpdateStreamParams (Params: TURIParams);
94+ begin
95+ Assert(Assigned(Params), ClassName + ' .AddUpdateStreamParams: Params is nil' );
96+ Params.Add(' channel' , Channel);
97+ Params.Add(' edition' , Edition);
98+ end ;
99+
86100constructor TProgramUpdateMgr.Create;
87101begin
88102 inherited Create(TWebServiceInfo.Create(ScriptURLTplt, UserAgent));
@@ -91,6 +105,7 @@ constructor TProgramUpdateMgr.Create;
91105function TProgramUpdateMgr.CreateParams : TURIParams;
92106begin
93107 Result := TURIParams.Create;
108+ Result.Add(' api' , ApiVersion);
94109 Result.Add(' key' , ApiKey);
95110 Result.Add(' prog-id' , TAppInfo.ProgramKey);
96111end ;
@@ -102,7 +117,7 @@ function TProgramUpdateMgr.DownloadURL: string;
102117begin
103118 Params := CreateParams;
104119 try
105- Params.Add( ' edition ' , Edition );
120+ AddUpdateStreamParams(Params );
106121 Response := TStringList.Create;
107122 try
108123 PostCommand(' downloadurl' , Params, Response);
@@ -122,7 +137,7 @@ function TProgramUpdateMgr.LatestProgramVersion: string;
122137begin
123138 Params := CreateParams;
124139 try
125- Params.Add( ' edition ' , Edition );
140+ AddUpdateStreamParams(Params );
126141 Response := TStringList.Create;
127142 try
128143 PostCommand(' version' , Params, Response);
0 commit comments