Merge lp:~mandel/ubuntuone-windows-installer/add_create_update_build into lp:ubuntuone-windows-installer/beta
- add_create_update_build
- Merge into beta
Proposed by
Manuel de la Peña
Status: | Merged |
---|---|
Approved by: | Rick McBride |
Approved revision: | 54 |
Merged at revision: | 68 |
Proposed branch: | lp:~mandel/ubuntuone-windows-installer/add_create_update_build |
Merge into: | lp:ubuntuone-windows-installer/beta |
Diff against target: |
929 lines (+467/-60) 20 files modified
README.txt (+12/-0) main.build (+33/-1) src/Canonical.UbuntuOne.Client.Views/Update/DownloadingView.xaml.cs (+28/-0) src/Canonical.UbuntuOne.Client.Views/Update/UpdatingView.xaml.cs (+32/-1) src/Canonical.UbuntuOne.Common.Tests/Canonical.UbuntuOne.Common.Tests.csproj (+4/-0) src/Canonical.UbuntuOne.Common.Tests/TestDispatcher.cs (+69/-0) src/Canonical.UbuntuOne.Common.Tests/Update/DownloadingPresenterFixture.cs (+13/-1) src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj (+2/-0) src/Canonical.UbuntuOne.Common/Threading/IDispatcher.cs (+48/-0) src/Canonical.UbuntuOne.Common/Threading/WpfDispatcher.cs (+89/-0) src/Canonical.UbuntuOne.Common/Update/DotUpdaterWrapper.cs (+47/-4) src/Canonical.UbuntuOne.Common/Update/DownloadingPresenter.cs (+27/-11) src/Canonical.UbuntuOne.Common/Update/IDownloadingView.cs (+9/-1) src/Canonical.UbuntuOne.Common/Update/IUpdatingPresenter.cs (+1/-1) src/Canonical.UbuntuOne.Common/Update/IUpdatingView.cs (+27/-17) src/Canonical.UbuntuOne.Common/Update/Updater.cs (+2/-2) src/Canonical.UbuntuOne.Common/objects.xml (+1/-1) src/UbuntuOneClient/objects.xml (+1/-1) utils/rss_templates.py (+6/-6) utils/upload_new_update.py (+16/-13) |
To merge this branch: | bzr merge lp:~mandel/ubuntuone-windows-installer/add_create_update_build |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John Lenton (community) | Approve | ||
Vincenzo Di Somma (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
Changes required to make the selfupda as expected, specially ensuring that the async calls can modify objects that have been created in a diff branch.
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
John Lenton (chipaca) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'README.txt' | |||
2 | --- README.txt 2010-07-19 10:19:22 +0000 | |||
3 | +++ README.txt 2010-08-24 15:18:39 +0000 | |||
4 | @@ -39,6 +39,18 @@ | |||
5 | 39 | 2.6 bootstrapper | 39 | 2.6 bootstrapper |
6 | 40 | 40 | ||
7 | 41 | Crates a boot strapper that will allow to install a bundle with UbuntuOne that includes Tomboy and Gtk sharp if needed. | 41 | Crates a boot strapper that will allow to install a bundle with UbuntuOne that includes Tomboy and Gtk sharp if needed. |
8 | 42 | |||
9 | 43 | 2.7 create_update | ||
10 | 44 | |||
11 | 45 | Creates the msi that will be used to update the application, updates the rss used to notify updates an uploads the data to the server. | ||
12 | 46 | |||
13 | 47 | Bare in mind that to be able to execute create_update you have to have the rights to update the data in canonicals S3. In order to do that | ||
14 | 48 | you have to set the following enviroment valirables in your windows machine: | ||
15 | 49 | |||
16 | 50 | AWS_ACCESS_KEY_ID: The account Id | ||
17 | 51 | AWS_SECRET_ACCESS_KEY: The secret required to use the account. | ||
18 | 52 | |||
19 | 53 | In order to run the script you will need to have boto () to be able to use S3. | ||
20 | 42 | 54 | ||
21 | 43 | In order to execute the build script execute at the root of the project | 55 | In order to execute the build script execute at the root of the project |
22 | 44 | 56 | ||
23 | 45 | 57 | ||
24 | === added file 'lib/DotUpdater/DotUpdater.pdb' | |||
25 | 46 | Binary files lib/DotUpdater/DotUpdater.pdb 1970-01-01 00:00:00 +0000 and lib/DotUpdater/DotUpdater.pdb 2010-08-24 15:18:39 +0000 differ | 58 | Binary files lib/DotUpdater/DotUpdater.pdb 1970-01-01 00:00:00 +0000 and lib/DotUpdater/DotUpdater.pdb 2010-08-24 15:18:39 +0000 differ |
26 | === modified file 'main.build' | |||
27 | --- main.build 2010-08-18 09:39:49 +0000 | |||
28 | +++ main.build 2010-08-24 15:18:39 +0000 | |||
29 | @@ -4,11 +4,19 @@ | |||
30 | 4 | <property name="enviroment" value="debug" /> | 4 | <property name="enviroment" value="debug" /> |
31 | 5 | <!-- property that allows to pass where to place the build results --> | 5 | <!-- property that allows to pass where to place the build results --> |
32 | 6 | <property name="build_results" value="install/build_results" /> | 6 | <property name="build_results" value="install/build_results" /> |
33 | 7 | <!-- property thas allows to pass the location used to build the api docs. --> | ||
34 | 7 | <property name="docs_api" value="docs/api" /> | 8 | <property name="docs_api" value="docs/api" /> |
35 | 9 | <!-- property that allows to point to the location in which sandcastle was installed --> | ||
36 | 8 | <property name="sandcastle_path" value="C:\Program Files\Sandcastle" /> | 10 | <property name="sandcastle_path" value="C:\Program Files\Sandcastle" /> |
37 | 11 | <!-- property that allows to point to the location in which the html workshop was installer --> | ||
38 | 9 | <property name="html_help_compiler_path" value="C:\Program Files\HTML Help Workshop" /> | 12 | <property name="html_help_compiler_path" value="C:\Program Files\HTML Help Workshop" /> |
39 | 10 | <!-- property that allows to pass the number for the current build. --> | 13 | <!-- property that allows to pass the number for the current build. --> |
40 | 11 | <property name="build" value="0" /> | 14 | <property name="build" value="0" /> |
41 | 15 | <!-- property that allows to point to the location in which python was installer --> | ||
42 | 16 | <property name="python_path" value="C:\Python26" /> | ||
43 | 17 | <!-- property that allows to pass the location to be used to update the package. --> | ||
44 | 18 | <property name="upload_path" value="http://s3.amazonaws.com/u1wintest/UbuntuOne.msi" /> | ||
45 | 19 | |||
46 | 12 | <target name="clean" | 20 | <target name="clean" |
47 | 13 | description="Removes all the different results of the last comilation if they exist"> | 21 | description="Removes all the different results of the last comilation if they exist"> |
48 | 14 | <!-- delete all the different results from the previous build --> | 22 | <!-- delete all the different results from the previous build --> |
49 | @@ -206,7 +214,7 @@ | |||
50 | 206 | 214 | ||
51 | 207 | <target name="installer" | 215 | <target name="installer" |
52 | 208 | description="Compiles the solution and create a merge installer that allows to install the solution and other related apps." | 216 | description="Compiles the solution and create a merge installer that allows to install the solution and other related apps." |
54 | 209 | depends="build"> | 217 | depends="tests"> |
55 | 210 | 218 | ||
56 | 211 | <mkdir dir="${build_results}" /> | 219 | <mkdir dir="${build_results}" /> |
57 | 212 | 220 | ||
58 | @@ -279,6 +287,30 @@ | |||
59 | 279 | commandline="/Output:setup.exe /Template:dotNetInstaller.exe /Configuration:InstallerProject.xml /Embed+" /> | 287 | commandline="/Output:setup.exe /Template:dotNetInstaller.exe /Configuration:InstallerProject.xml /Embed+" /> |
60 | 280 | </target> | 288 | </target> |
61 | 281 | 289 | ||
62 | 290 | <target name="create_update" | ||
63 | 291 | description="Creates the msi that will be used to update the application, updates the rss used to notify updates an uploads the data to the server." | ||
64 | 292 | depends="installer"> | ||
65 | 293 | |||
66 | 294 | <echo message="Creating update for version ${buildnumber.major}.${buildnumber.minor}.${buildnumber.build}.${buildnumber.revision}"/> | ||
67 | 295 | |||
68 | 296 | <!-- call the utils script that was created using python to allows the update and rss generation --> | ||
69 | 297 | |||
70 | 298 | <echo message='Executing: python upload_new_update.py ../install/UbuntuOne.msi ${buildnumber.major}.${buildnumber.minor}.${buildnumber.build}.${buildnumber.revision} "${upload_path}"'/> | ||
71 | 299 | |||
72 | 300 | <!-- copy the installer, otherwhise the script has issues when uploading, windows is funny --> | ||
73 | 301 | <copy file="install/UbuntuOne.msi" | ||
74 | 302 | tofile="utils/UbuntuOne.msi" /> | ||
75 | 303 | |||
76 | 304 | <exec basedir="${python_path}" | ||
77 | 305 | managed="false" | ||
78 | 306 | workingdir="utils" | ||
79 | 307 | program="python.exe" | ||
80 | 308 | commandline='upload_new_update.py UbuntuOne.msi ${buildnumber.major}.${buildnumber.minor}.${buildnumber.build}.${buildnumber.revision} "${upload_path}"' /> | ||
81 | 309 | |||
82 | 310 | <!-- delete the copied file --> | ||
83 | 311 | <delete file="utils/UbuntuOne.msi" /> | ||
84 | 312 | |||
85 | 313 | </target> | ||
86 | 282 | <target name="documentation" | 314 | <target name="documentation" |
87 | 283 | description="Generates the documentation using the xml documents." | 315 | description="Generates the documentation using the xml documents." |
88 | 284 | depends="build"> | 316 | depends="build"> |
89 | 285 | 317 | ||
90 | === modified file 'src/Canonical.UbuntuOne.Client.Views/Update/DownloadingView.xaml.cs' | |||
91 | --- src/Canonical.UbuntuOne.Client.Views/Update/DownloadingView.xaml.cs 2010-08-05 08:15:00 +0000 | |||
92 | +++ src/Canonical.UbuntuOne.Client.Views/Update/DownloadingView.xaml.cs 2010-08-24 15:18:39 +0000 | |||
93 | @@ -16,6 +16,7 @@ | |||
94 | 16 | // | 16 | // |
95 | 17 | // Authors: Manuel de la Peña <manuel.delapena@canonical.com> | 17 | // Authors: Manuel de la Peña <manuel.delapena@canonical.com> |
96 | 18 | using System; | 18 | using System; |
97 | 19 | using Canonical.UbuntuOne.Common.Threading; | ||
98 | 19 | using Canonical.UbuntuOne.Common.Update; | 20 | using Canonical.UbuntuOne.Common.Update; |
99 | 20 | using StaticResources = Canonical.UbuntuOne.Client.Views.Resources.Resources; | 21 | using StaticResources = Canonical.UbuntuOne.Client.Views.Resources.Resources; |
100 | 21 | namespace Canonical.UbuntuOne.Client.Views.Update | 22 | namespace Canonical.UbuntuOne.Client.Views.Update |
101 | @@ -25,6 +26,13 @@ | |||
102 | 25 | /// </summary> | 26 | /// </summary> |
103 | 26 | public partial class DownloadingView : IDownloadingView | 27 | public partial class DownloadingView : IDownloadingView |
104 | 27 | { | 28 | { |
105 | 29 | #region Variables | ||
106 | 30 | |||
107 | 31 | private IDispatcher _dispatcher; | ||
108 | 32 | private readonly object _dispatcherLock = new object(); | ||
109 | 33 | |||
110 | 34 | #endregion | ||
111 | 35 | |||
112 | 28 | /// <summary> | 36 | /// <summary> |
113 | 29 | /// Initializes a new instance of the DownloadingView class. | 37 | /// Initializes a new instance of the DownloadingView class. |
114 | 30 | /// </summary> | 38 | /// </summary> |
115 | @@ -35,6 +43,26 @@ | |||
116 | 35 | } | 43 | } |
117 | 36 | 44 | ||
118 | 37 | /// <summary> | 45 | /// <summary> |
119 | 46 | /// Gets the dispatcher that can be used to call actions on the object from a | ||
120 | 47 | /// different thread. | ||
121 | 48 | /// </summary> | ||
122 | 49 | public IDispatcher ViewDispatcher | ||
123 | 50 | { | ||
124 | 51 | get | ||
125 | 52 | { | ||
126 | 53 | if(_dispatcher == null) | ||
127 | 54 | { | ||
128 | 55 | lock (_dispatcherLock) | ||
129 | 56 | { | ||
130 | 57 | _dispatcher = new WpfDispatcher(Dispatcher); | ||
131 | 58 | } | ||
132 | 59 | } | ||
133 | 60 | return _dispatcher; | ||
134 | 61 | } | ||
135 | 62 | set { _dispatcher = value; } | ||
136 | 63 | } | ||
137 | 64 | |||
138 | 65 | /// <summary> | ||
139 | 38 | /// Gets and sets if the close button is enabled. | 66 | /// Gets and sets if the close button is enabled. |
140 | 39 | /// </summary> | 67 | /// </summary> |
141 | 40 | public bool CloseButtonIsEnabled | 68 | public bool CloseButtonIsEnabled |
142 | 41 | 69 | ||
143 | === modified file 'src/Canonical.UbuntuOne.Client.Views/Update/UpdatingView.xaml.cs' | |||
144 | --- src/Canonical.UbuntuOne.Client.Views/Update/UpdatingView.xaml.cs 2010-08-05 08:15:00 +0000 | |||
145 | +++ src/Canonical.UbuntuOne.Client.Views/Update/UpdatingView.xaml.cs 2010-08-24 15:18:39 +0000 | |||
146 | @@ -16,6 +16,7 @@ | |||
147 | 16 | // | 16 | // |
148 | 17 | // Authors: Manuel de la Peña <manuel.delapena@canonical.com> | 17 | // Authors: Manuel de la Peña <manuel.delapena@canonical.com> |
149 | 18 | using System; | 18 | using System; |
150 | 19 | using Canonical.UbuntuOne.Common.Threading; | ||
151 | 19 | using Canonical.UbuntuOne.Common.Update; | 20 | using Canonical.UbuntuOne.Common.Update; |
152 | 20 | 21 | ||
153 | 21 | namespace Canonical.UbuntuOne.Client.Views.Update | 22 | namespace Canonical.UbuntuOne.Client.Views.Update |
154 | @@ -25,6 +26,36 @@ | |||
155 | 25 | /// </summary> | 26 | /// </summary> |
156 | 26 | public partial class UpdatingView : IUpdatingView | 27 | public partial class UpdatingView : IUpdatingView |
157 | 27 | { | 28 | { |
158 | 29 | #region Variables | ||
159 | 30 | |||
160 | 31 | private IDispatcher _dispatcher; | ||
161 | 32 | private readonly object _dispatcherLock = new object(); | ||
162 | 33 | |||
163 | 34 | #endregion | ||
164 | 35 | |||
165 | 36 | #region DI Properties | ||
166 | 37 | |||
167 | 38 | /// <summary> | ||
168 | 39 | /// Gets and sets a dispatcher that can be used by the view in a multithreaded env. | ||
169 | 40 | /// </summary> | ||
170 | 41 | public IDispatcher ViewDispatcher | ||
171 | 42 | { | ||
172 | 43 | get | ||
173 | 44 | { | ||
174 | 45 | if(_dispatcher == null) | ||
175 | 46 | { | ||
176 | 47 | lock (_dispatcherLock) | ||
177 | 48 | { | ||
178 | 49 | _dispatcher = new WpfDispatcher(Dispatcher); | ||
179 | 50 | } | ||
180 | 51 | } | ||
181 | 52 | return _dispatcher; | ||
182 | 53 | } | ||
183 | 54 | set { _dispatcher = value; } | ||
184 | 55 | } | ||
185 | 56 | |||
186 | 57 | #endregion | ||
187 | 58 | |||
188 | 28 | /// <summary> | 59 | /// <summary> |
189 | 29 | /// Initializes a new instance of the UpdatingView class. | 60 | /// Initializes a new instance of the UpdatingView class. |
190 | 30 | /// </summary> | 61 | /// </summary> |
191 | @@ -51,7 +82,7 @@ | |||
192 | 51 | /// </summary> | 82 | /// </summary> |
193 | 52 | public string UpdatingText | 83 | public string UpdatingText |
194 | 53 | { | 84 | { |
196 | 54 | get { return (String) MessageLabel.Content; } | 85 | get { return (String)MessageLabel.Content; } |
197 | 55 | set { MessageLabel.Content = value; } | 86 | set { MessageLabel.Content = value; } |
198 | 56 | } | 87 | } |
199 | 57 | } | 88 | } |
200 | 58 | 89 | ||
201 | === modified file 'src/Canonical.UbuntuOne.Common.Tests/Canonical.UbuntuOne.Common.Tests.csproj' | |||
202 | --- src/Canonical.UbuntuOne.Common.Tests/Canonical.UbuntuOne.Common.Tests.csproj 2010-08-05 08:15:00 +0000 | |||
203 | +++ src/Canonical.UbuntuOne.Common.Tests/Canonical.UbuntuOne.Common.Tests.csproj 2010-08-24 15:18:39 +0000 | |||
204 | @@ -44,6 +44,7 @@ | |||
205 | 44 | <Compile Include="ProcessManagementExceptionFixture.cs" /> | 44 | <Compile Include="ProcessManagementExceptionFixture.cs" /> |
206 | 45 | <Compile Include="Properties\AssemblyInfo.cs" /> | 45 | <Compile Include="Properties\AssemblyInfo.cs" /> |
207 | 46 | <Compile Include="SyncDaemonExceptionFixture.cs" /> | 46 | <Compile Include="SyncDaemonExceptionFixture.cs" /> |
208 | 47 | <Compile Include="TestDispatcher.cs" /> | ||
209 | 47 | <Compile Include="Update\DownloadingPresenterFixture.cs" /> | 48 | <Compile Include="Update\DownloadingPresenterFixture.cs" /> |
210 | 48 | <Compile Include="Update\SelfUpdateExceptionFixture.cs" /> | 49 | <Compile Include="Update\SelfUpdateExceptionFixture.cs" /> |
211 | 49 | <Compile Include="Update\UpdaterFixture.cs" /> | 50 | <Compile Include="Update\UpdaterFixture.cs" /> |
212 | @@ -82,6 +83,9 @@ | |||
213 | 82 | <HintPath>..\..\lib\Spring.Net\Spring.Core.dll</HintPath> | 83 | <HintPath>..\..\lib\Spring.Net\Spring.Core.dll</HintPath> |
214 | 83 | </Reference> | 84 | </Reference> |
215 | 84 | <Reference Include="System" /> | 85 | <Reference Include="System" /> |
216 | 86 | <Reference Include="System.Core"> | ||
217 | 87 | <RequiredTargetFramework>3.5</RequiredTargetFramework> | ||
218 | 88 | </Reference> | ||
219 | 85 | <Reference Include="System.Data" /> | 89 | <Reference Include="System.Data" /> |
220 | 86 | <Reference Include="System.Xml" /> | 90 | <Reference Include="System.Xml" /> |
221 | 87 | </ItemGroup> | 91 | </ItemGroup> |
222 | 88 | 92 | ||
223 | === added file 'src/Canonical.UbuntuOne.Common.Tests/TestDispatcher.cs' | |||
224 | --- src/Canonical.UbuntuOne.Common.Tests/TestDispatcher.cs 1970-01-01 00:00:00 +0000 | |||
225 | +++ src/Canonical.UbuntuOne.Common.Tests/TestDispatcher.cs 2010-08-24 15:18:39 +0000 | |||
226 | @@ -0,0 +1,69 @@ | |||
227 | 1 | /* | ||
228 | 2 | * Copyright 2010 Canonical Ltd. | ||
229 | 3 | * | ||
230 | 4 | * This file is part of UbuntuOne on Windows. | ||
231 | 5 | * | ||
232 | 6 | * UbuntuOne on Windows is free software: you can redistribute it and/or modify | ||
233 | 7 | * it under the terms of the GNU Lesser General Public License version | ||
234 | 8 | * as published by the Free Software Foundation. | ||
235 | 9 | * | ||
236 | 10 | * Ubuntu One on Windows is distributed in the hope that it will be useful, | ||
237 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
238 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
239 | 13 | * GNU Lesser General Public License for more details. | ||
240 | 14 | * | ||
241 | 15 | * You should have received a copy of the GNU Lesser General Public License | ||
242 | 16 | * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>. | ||
243 | 17 | * | ||
244 | 18 | * Authors: Manuel de la Peña <manuel.delapena@canonical.com> | ||
245 | 19 | */ | ||
246 | 20 | using System; | ||
247 | 21 | using Canonical.UbuntuOne.Common.Threading; | ||
248 | 22 | |||
249 | 23 | namespace Canonical.UbuntuOne.Common.Tests | ||
250 | 24 | { | ||
251 | 25 | /// <summary> | ||
252 | 26 | /// Dummy implementation of the IDispatcher that is used for test puposes. | ||
253 | 27 | /// </summary> | ||
254 | 28 | internal class TestDispatcher : IDispatcher | ||
255 | 29 | { | ||
256 | 30 | #region Implementation of IDispatcher | ||
257 | 31 | |||
258 | 32 | /// <summary> | ||
259 | 33 | /// Dispatches the specified action to the thread. | ||
260 | 34 | /// </summary> | ||
261 | 35 | /// <param name="actionToInvoke">The action to invoke.</param> | ||
262 | 36 | public void Dispatch(Action actionToInvoke) | ||
263 | 37 | { | ||
264 | 38 | actionToInvoke(); | ||
265 | 39 | } | ||
266 | 40 | |||
267 | 41 | #endregion | ||
268 | 42 | |||
269 | 43 | #region Implementation of IDispatcher | ||
270 | 44 | |||
271 | 45 | /// <summary> | ||
272 | 46 | /// Dispatches the specified action to the thread. | ||
273 | 47 | /// </summary> | ||
274 | 48 | /// <param name="actionToInvoke">The action to invoke.</param> | ||
275 | 49 | public TResult Dispatch<TResult>(Func<TResult> actionToInvoke) | ||
276 | 50 | { | ||
277 | 51 | return actionToInvoke(); | ||
278 | 52 | } | ||
279 | 53 | |||
280 | 54 | #endregion | ||
281 | 55 | |||
282 | 56 | #region Implementation of IDispatcher | ||
283 | 57 | |||
284 | 58 | /// <summary> | ||
285 | 59 | /// Checks whether the thread invoking the method . | ||
286 | 60 | /// </summary> | ||
287 | 61 | /// <returns></returns> | ||
288 | 62 | public bool DispatchRequired() | ||
289 | 63 | { | ||
290 | 64 | return false; | ||
291 | 65 | } | ||
292 | 66 | |||
293 | 67 | #endregion | ||
294 | 68 | } | ||
295 | 69 | } | ||
296 | 0 | 70 | ||
297 | === modified file 'src/Canonical.UbuntuOne.Common.Tests/Update/DownloadingPresenterFixture.cs' | |||
298 | --- src/Canonical.UbuntuOne.Common.Tests/Update/DownloadingPresenterFixture.cs 2010-07-29 16:38:26 +0000 | |||
299 | +++ src/Canonical.UbuntuOne.Common.Tests/Update/DownloadingPresenterFixture.cs 2010-08-24 15:18:39 +0000 | |||
300 | @@ -1,4 +1,4 @@ | |||
302 | 1 | /** | 1 | /* |
303 | 2 | * Copyright 2010 Canonical Ltd. | 2 | * Copyright 2010 Canonical Ltd. |
304 | 3 | * | 3 | * |
305 | 4 | * This file is part of UbuntuOne on Windows. | 4 | * This file is part of UbuntuOne on Windows. |
306 | @@ -18,6 +18,7 @@ | |||
307 | 18 | * Authors: Manuel de la Peña <manuel.delapena@canonical.com> | 18 | * Authors: Manuel de la Peña <manuel.delapena@canonical.com> |
308 | 19 | */ | 19 | */ |
309 | 20 | using System; | 20 | using System; |
310 | 21 | using Canonical.UbuntuOne.Common.Threading; | ||
311 | 21 | using Canonical.UbuntuOne.Common.Update; | 22 | using Canonical.UbuntuOne.Common.Update; |
312 | 22 | using Microsoft.ApplicationBlocks.Updater; | 23 | using Microsoft.ApplicationBlocks.Updater; |
313 | 23 | using NUnit.Framework; | 24 | using NUnit.Framework; |
314 | @@ -31,6 +32,7 @@ | |||
315 | 31 | 32 | ||
316 | 32 | private MockRepository _mocks; | 33 | private MockRepository _mocks; |
317 | 33 | private IDownloadingView _view; | 34 | private IDownloadingView _view; |
318 | 35 | private IDispatcher _dispatcher; | ||
319 | 34 | private DownloadingPresenter _presenter; | 36 | private DownloadingPresenter _presenter; |
320 | 35 | 37 | ||
321 | 36 | #endregion | 38 | #endregion |
322 | @@ -42,6 +44,7 @@ | |||
323 | 42 | { | 44 | { |
324 | 43 | _mocks = new MockRepository(); | 45 | _mocks = new MockRepository(); |
325 | 44 | _view = _mocks.DynamicMock<IDownloadingView>(); | 46 | _view = _mocks.DynamicMock<IDownloadingView>(); |
326 | 47 | _dispatcher = new TestDispatcher(); | ||
327 | 45 | _presenter = new DownloadingPresenter | 48 | _presenter = new DownloadingPresenter |
328 | 46 | { | 49 | { |
329 | 47 | View = _view | 50 | View = _view |
330 | @@ -78,6 +81,9 @@ | |||
331 | 78 | { | 81 | { |
332 | 79 | SetupResult.For(_view.IsShown) | 82 | SetupResult.For(_view.IsShown) |
333 | 80 | .Return(true); | 83 | .Return(true); |
334 | 84 | SetupResult.For(_view.ViewDispatcher) | ||
335 | 85 | .Return(_dispatcher); | ||
336 | 86 | |||
337 | 81 | _view.DownloadingMessage = UpdateResources.DownloadInProgress; | 87 | _view.DownloadingMessage = UpdateResources.DownloadInProgress; |
338 | 82 | _view.Progress = (progress * DownloadingPresenter.MaximumValue) / total; | 88 | _view.Progress = (progress * DownloadingPresenter.MaximumValue) / total; |
339 | 83 | } | 89 | } |
340 | @@ -98,6 +104,8 @@ | |||
341 | 98 | .Return(false); | 104 | .Return(false); |
342 | 99 | Expect.Call(() => _view.Show()) | 105 | Expect.Call(() => _view.Show()) |
343 | 100 | .Repeat.Once(); | 106 | .Repeat.Once(); |
344 | 107 | SetupResult.For(_view.ViewDispatcher) | ||
345 | 108 | .Return(_dispatcher); | ||
346 | 101 | _view.DownloadingMessage = UpdateResources.DownloadInProgress; | 109 | _view.DownloadingMessage = UpdateResources.DownloadInProgress; |
347 | 102 | _view.Progress = (progress * DownloadingPresenter.MaximumValue) / total; | 110 | _view.Progress = (progress * DownloadingPresenter.MaximumValue) / total; |
348 | 103 | } | 111 | } |
349 | @@ -112,6 +120,8 @@ | |||
350 | 112 | { | 120 | { |
351 | 113 | using (_mocks.Record()) | 121 | using (_mocks.Record()) |
352 | 114 | { | 122 | { |
353 | 123 | SetupResult.For(_view.ViewDispatcher) | ||
354 | 124 | .Return(_dispatcher); | ||
355 | 115 | _view.DownloadingMessage = UpdateResources.DownloadError; | 125 | _view.DownloadingMessage = UpdateResources.DownloadError; |
356 | 116 | _view.CloseButtonIsEnabled = true; | 126 | _view.CloseButtonIsEnabled = true; |
357 | 117 | _view.Progress = DownloadingPresenter.MinimumValue; | 127 | _view.Progress = DownloadingPresenter.MinimumValue; |
358 | @@ -127,6 +137,8 @@ | |||
359 | 127 | { | 137 | { |
360 | 128 | using (_mocks.Record()) | 138 | using (_mocks.Record()) |
361 | 129 | { | 139 | { |
362 | 140 | SetupResult.For(_view.ViewDispatcher) | ||
363 | 141 | .Return(_dispatcher); | ||
364 | 130 | _view.DownloadingMessage = UpdateResources.DownloadCompleted; | 142 | _view.DownloadingMessage = UpdateResources.DownloadCompleted; |
365 | 131 | _view.Progress = DownloadingPresenter.MaximumValue; | 143 | _view.Progress = DownloadingPresenter.MaximumValue; |
366 | 132 | _view.Close(); | 144 | _view.Close(); |
367 | 133 | 145 | ||
368 | === modified file 'src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj' | |||
369 | --- src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj 2010-08-16 12:46:11 +0000 | |||
370 | +++ src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj 2010-08-24 15:18:39 +0000 | |||
371 | @@ -59,6 +59,8 @@ | |||
372 | 59 | <Compile Include="Container\UnsatisfiedDependencyException.cs" /> | 59 | <Compile Include="Container\UnsatisfiedDependencyException.cs" /> |
373 | 60 | <Compile Include="IAuthentication.cs" /> | 60 | <Compile Include="IAuthentication.cs" /> |
374 | 61 | <Compile Include="OperationContracts\IEventNotifier.cs" /> | 61 | <Compile Include="OperationContracts\IEventNotifier.cs" /> |
375 | 62 | <Compile Include="Threading\IDispatcher.cs" /> | ||
376 | 63 | <Compile Include="Threading\WpfDispatcher.cs" /> | ||
377 | 62 | <Compile Include="Utils\ApplicationWrapper.cs" /> | 64 | <Compile Include="Utils\ApplicationWrapper.cs" /> |
378 | 63 | <Compile Include="Utils\Explorer.cs" /> | 65 | <Compile Include="Utils\Explorer.cs" /> |
379 | 64 | <Compile Include="Utils\ExplorerException.cs" /> | 66 | <Compile Include="Utils\ExplorerException.cs" /> |
380 | 65 | 67 | ||
381 | === added directory 'src/Canonical.UbuntuOne.Common/Threading' | |||
382 | === added file 'src/Canonical.UbuntuOne.Common/Threading/IDispatcher.cs' | |||
383 | --- src/Canonical.UbuntuOne.Common/Threading/IDispatcher.cs 1970-01-01 00:00:00 +0000 | |||
384 | +++ src/Canonical.UbuntuOne.Common/Threading/IDispatcher.cs 2010-08-24 15:18:39 +0000 | |||
385 | @@ -0,0 +1,48 @@ | |||
386 | 1 | /* | ||
387 | 2 | * Copyright 2010 Canonical Ltd. | ||
388 | 3 | * | ||
389 | 4 | * This file is part of UbuntuOne on Windows. | ||
390 | 5 | * | ||
391 | 6 | * UbuntuOne on Windows is free software: you can redistribute it and/or modify | ||
392 | 7 | * it under the terms of the GNU Lesser General Public License version | ||
393 | 8 | * as published by the Free Software Foundation. | ||
394 | 9 | * | ||
395 | 10 | * Ubuntu One on Windows is distributed in the hope that it will be useful, | ||
396 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
397 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
398 | 13 | * GNU Lesser General Public License for more details. | ||
399 | 14 | * | ||
400 | 15 | * You should have received a copy of the GNU Lesser General Public License | ||
401 | 16 | * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>. | ||
402 | 17 | * | ||
403 | 18 | * Authors: Manuel de la Peña <manuel.delapena@canonical.com> | ||
404 | 19 | */ | ||
405 | 20 | using System; | ||
406 | 21 | |||
407 | 22 | namespace Canonical.UbuntuOne.Common.Threading | ||
408 | 23 | { | ||
409 | 24 | /// <summary> | ||
410 | 25 | /// Provides a wrapper around the process of dispatching actions onto | ||
411 | 26 | /// different threads, primarily for unit testing. | ||
412 | 27 | /// </summary> | ||
413 | 28 | public interface IDispatcher | ||
414 | 29 | { | ||
415 | 30 | /// <summary> | ||
416 | 31 | /// Dispatches the specified action to the thread. | ||
417 | 32 | /// </summary> | ||
418 | 33 | /// <param name="actionToInvoke">The action to invoke.</param> | ||
419 | 34 | void Dispatch(Action actionToInvoke); | ||
420 | 35 | |||
421 | 36 | /// <summary> | ||
422 | 37 | /// Dispatches the specified action to the thread. | ||
423 | 38 | /// </summary> | ||
424 | 39 | /// <param name="actionToInvoke">The action to invoke.</param> | ||
425 | 40 | TResult Dispatch<TResult>(Func<TResult> actionToInvoke); | ||
426 | 41 | |||
427 | 42 | /// <summary> | ||
428 | 43 | /// Checks whether the thread invoking the method . | ||
429 | 44 | /// </summary> | ||
430 | 45 | /// <returns></returns> | ||
431 | 46 | bool DispatchRequired(); | ||
432 | 47 | } | ||
433 | 48 | } | ||
434 | 0 | 49 | ||
435 | === added file 'src/Canonical.UbuntuOne.Common/Threading/WpfDispatcher.cs' | |||
436 | --- src/Canonical.UbuntuOne.Common/Threading/WpfDispatcher.cs 1970-01-01 00:00:00 +0000 | |||
437 | +++ src/Canonical.UbuntuOne.Common/Threading/WpfDispatcher.cs 2010-08-24 15:18:39 +0000 | |||
438 | @@ -0,0 +1,89 @@ | |||
439 | 1 | /* | ||
440 | 2 | * Copyright 2010 Canonical Ltd. | ||
441 | 3 | * | ||
442 | 4 | * This file is part of UbuntuOne on Windows. | ||
443 | 5 | * | ||
444 | 6 | * UbuntuOne on Windows is free software: you can redistribute it and/or modify | ||
445 | 7 | * it under the terms of the GNU Lesser General Public License version | ||
446 | 8 | * as published by the Free Software Foundation. | ||
447 | 9 | * | ||
448 | 10 | * Ubuntu One on Windows is distributed in the hope that it will be useful, | ||
449 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
450 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
451 | 13 | * GNU Lesser General Public License for more details. | ||
452 | 14 | * | ||
453 | 15 | * You should have received a copy of the GNU Lesser General Public License | ||
454 | 16 | * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>. | ||
455 | 17 | * | ||
456 | 18 | * Authors: Manuel de la Peña <manuel.delapena@canonical.com> | ||
457 | 19 | */ | ||
458 | 20 | |||
459 | 21 | using System; | ||
460 | 22 | using System.Windows.Threading; | ||
461 | 23 | |||
462 | 24 | namespace Canonical.UbuntuOne.Common.Threading | ||
463 | 25 | { | ||
464 | 26 | /// <summary> | ||
465 | 27 | /// This dispatcher is used at runtime by both Windows Forms and WPF. The WPF Dispatcher | ||
466 | 28 | /// class works within Windows Forms, so this appears to be safe. | ||
467 | 29 | /// </summary> | ||
468 | 30 | public class WpfDispatcher : IDispatcher | ||
469 | 31 | { | ||
470 | 32 | private readonly Dispatcher _dispatcher; | ||
471 | 33 | |||
472 | 34 | /// <summary> | ||
473 | 35 | /// Initializes a new instance of the <see cref="WpfDispatcher"/> class. | ||
474 | 36 | /// </summary> | ||
475 | 37 | public WpfDispatcher() | ||
476 | 38 | : this(Dispatcher.CurrentDispatcher) { } | ||
477 | 39 | |||
478 | 40 | /// <summary> | ||
479 | 41 | /// Initializes a new instance of the <see cref="WpfDispatcher"/> class. | ||
480 | 42 | /// </summary> | ||
481 | 43 | /// <param name="dispatcher">The dispatcher.</param> | ||
482 | 44 | public WpfDispatcher(Dispatcher dispatcher) | ||
483 | 45 | { | ||
484 | 46 | _dispatcher = dispatcher; | ||
485 | 47 | } | ||
486 | 48 | |||
487 | 49 | /// <summary> | ||
488 | 50 | /// Dispatches the specified action to the thread. | ||
489 | 51 | /// </summary> | ||
490 | 52 | /// <param name="actionToInvoke">The action to invoke.</param> | ||
491 | 53 | public void Dispatch(Action actionToInvoke) | ||
492 | 54 | { | ||
493 | 55 | if (!DispatchRequired()) | ||
494 | 56 | { | ||
495 | 57 | actionToInvoke(); | ||
496 | 58 | } | ||
497 | 59 | else | ||
498 | 60 | { | ||
499 | 61 | _dispatcher.Invoke(DispatcherPriority.Normal, actionToInvoke); | ||
500 | 62 | } | ||
501 | 63 | } | ||
502 | 64 | |||
503 | 65 | /// <summary> | ||
504 | 66 | /// Dispatches the specified action to the thread. | ||
505 | 67 | /// </summary> | ||
506 | 68 | /// <typeparam name="TResult"></typeparam> | ||
507 | 69 | /// <param name="actionToInvoke">The action to invoke.</param> | ||
508 | 70 | /// <returns></returns> | ||
509 | 71 | public TResult Dispatch<TResult>(Func<TResult> actionToInvoke) | ||
510 | 72 | { | ||
511 | 73 | if (_dispatcher.CheckAccess()) | ||
512 | 74 | { | ||
513 | 75 | return actionToInvoke(); | ||
514 | 76 | } | ||
515 | 77 | return (TResult)_dispatcher.Invoke(DispatcherPriority.Normal, actionToInvoke); | ||
516 | 78 | } | ||
517 | 79 | |||
518 | 80 | /// <summary> | ||
519 | 81 | /// Checks whether the thread invoking the method. | ||
520 | 82 | /// </summary> | ||
521 | 83 | /// <returns></returns> | ||
522 | 84 | public bool DispatchRequired() | ||
523 | 85 | { | ||
524 | 86 | return !_dispatcher.CheckAccess(); | ||
525 | 87 | } | ||
526 | 88 | } | ||
527 | 89 | } | ||
528 | 0 | 90 | ||
529 | === modified file 'src/Canonical.UbuntuOne.Common/Update/DotUpdaterWrapper.cs' | |||
530 | --- src/Canonical.UbuntuOne.Common/Update/DotUpdaterWrapper.cs 2010-07-21 10:07:22 +0000 | |||
531 | +++ src/Canonical.UbuntuOne.Common/Update/DotUpdaterWrapper.cs 2010-08-24 15:18:39 +0000 | |||
532 | @@ -1,4 +1,4 @@ | |||
534 | 1 | /** | 1 | /* |
535 | 2 | * Copyright 2010 Canonical Ltd. | 2 | * Copyright 2010 Canonical Ltd. |
536 | 3 | * | 3 | * |
537 | 4 | * This file is part of UbuntuOne on Windows. | 4 | * This file is part of UbuntuOne on Windows. |
538 | @@ -39,12 +39,55 @@ | |||
539 | 39 | 39 | ||
540 | 40 | #endregion | 40 | #endregion |
541 | 41 | 41 | ||
542 | 42 | #region Helpers | ||
543 | 43 | |||
544 | 44 | /// <summary> | ||
545 | 45 | /// Helper used to propagate the event from the wrapped object. | ||
546 | 46 | /// </summary> | ||
547 | 47 | /// <param name="sender">The sender of the event.</param> | ||
548 | 48 | /// <param name="args">The aruments about the completed task.</param> | ||
549 | 49 | private void DownloadCompletedHandler(object sender, TaskEventArgs args) | ||
550 | 50 | { | ||
551 | 51 | if(OnDownloadCompleted != null) | ||
552 | 52 | { | ||
553 | 53 | OnDownloadCompleted(sender, args); | ||
554 | 54 | } | ||
555 | 55 | } | ||
556 | 56 | |||
557 | 57 | /// <summary> | ||
558 | 58 | /// Helper used to propagate the event from the wrapped object. | ||
559 | 59 | /// </summary> | ||
560 | 60 | /// <param name="sender">The sender of the event.</param> | ||
561 | 61 | /// <param name="args">The arguments with the completed information.</param> | ||
562 | 62 | private void DownloadProgressHandler(object sender, DownloadTaskProgressEventArgs args) | ||
563 | 63 | { | ||
564 | 64 | if(OnDownloadProgress != null) | ||
565 | 65 | { | ||
566 | 66 | OnDownloadProgress(sender, args); | ||
567 | 67 | } | ||
568 | 68 | } | ||
569 | 69 | |||
570 | 70 | /// <summary> | ||
571 | 71 | /// Helper used to propagate the event from the wrapped object. | ||
572 | 72 | /// </summary> | ||
573 | 73 | /// <param name="sender">The sender of the event.</param> | ||
574 | 74 | /// <param name="args">The arguments with the error information.</param> | ||
575 | 75 | private void DownloadErrorHandler(object sender, DownloadTaskErrorEventArgs args) | ||
576 | 76 | { | ||
577 | 77 | if(OnDownloadError != null) | ||
578 | 78 | { | ||
579 | 79 | OnDownloadError(sender, args); | ||
580 | 80 | } | ||
581 | 81 | } | ||
582 | 82 | |||
583 | 83 | #endregion | ||
584 | 84 | |||
585 | 42 | public DotUpdaterWrapper(Logger logger, string rss) | 85 | public DotUpdaterWrapper(Logger logger, string rss) |
586 | 43 | { | 86 | { |
587 | 44 | _updater = new DotUpdater.Updater(logger, rss); | 87 | _updater = new DotUpdater.Updater(logger, rss); |
591 | 45 | OnDownloadCompleted = _updater.OnDownloadCompleted; | 88 | _updater.OnDownloadCompleted += DownloadCompletedHandler; |
592 | 46 | OnDownloadProgress = _updater.OnDownloadProgress; | 89 | _updater.OnDownloadProgress += DownloadProgressHandler; |
593 | 47 | OnDownloadError = _updater.OnDownloadError; | 90 | _updater.OnDownloadError += DownloadErrorHandler; |
594 | 48 | } | 91 | } |
595 | 49 | 92 | ||
596 | 50 | public UpdaterTask CheckForUpdates() | 93 | public UpdaterTask CheckForUpdates() |
597 | 51 | 94 | ||
598 | === modified file 'src/Canonical.UbuntuOne.Common/Update/DownloadingPresenter.cs' | |||
599 | --- src/Canonical.UbuntuOne.Common/Update/DownloadingPresenter.cs 2010-08-05 08:01:59 +0000 | |||
600 | +++ src/Canonical.UbuntuOne.Common/Update/DownloadingPresenter.cs 2010-08-24 15:18:39 +0000 | |||
601 | @@ -1,4 +1,4 @@ | |||
603 | 1 | /** | 1 | /* |
604 | 2 | * Copyright 2010 Canonical Ltd. | 2 | * Copyright 2010 Canonical Ltd. |
605 | 3 | * | 3 | * |
606 | 4 | * This file is part of UbuntuOne on Windows. | 4 | * This file is part of UbuntuOne on Windows. |
607 | @@ -75,10 +75,18 @@ | |||
608 | 75 | /// <param name="args">The arguments that provide information regarding the changes in the download.</param> | 75 | /// <param name="args">The arguments that provide information regarding the changes in the download.</param> |
609 | 76 | public void DownloadProgressHandler(object sender, DownloadTaskProgressEventArgs args) | 76 | public void DownloadProgressHandler(object sender, DownloadTaskProgressEventArgs args) |
610 | 77 | { | 77 | { |
615 | 78 | if(!View.IsShown) | 78 | if (!View.IsShown) |
616 | 79 | View.Show(); | 79 | { |
617 | 80 | View.DownloadingMessage = UpdateResources.DownloadInProgress; | 80 | // dispatch to the correct thread to show the view |
618 | 81 | View.Progress = (args.BytesTransferred * MaximumValue) / args.BytesTotal; | 81 | View.ViewDispatcher.Dispatch(() => View.Show()); |
619 | 82 | } | ||
620 | 83 | // dispatch to the correct thread to set the data | ||
621 | 84 | View.ViewDispatcher.Dispatch( | ||
622 | 85 | () => | ||
623 | 86 | { | ||
624 | 87 | View.DownloadingMessage = UpdateResources.DownloadInProgress; | ||
625 | 88 | View.Progress = (args.BytesTransferred * MaximumValue) / args.BytesTotal; | ||
626 | 89 | }); | ||
627 | 82 | } | 90 | } |
628 | 83 | 91 | ||
629 | 84 | /// <summary> | 92 | /// <summary> |
630 | @@ -88,9 +96,13 @@ | |||
631 | 88 | /// <param name="args">The arguments that provide information regarding the error.</param> | 96 | /// <param name="args">The arguments that provide information regarding the error.</param> |
632 | 89 | public void DownloadErrorHandler(object sender, DownloadTaskErrorEventArgs args) | 97 | public void DownloadErrorHandler(object sender, DownloadTaskErrorEventArgs args) |
633 | 90 | { | 98 | { |
637 | 91 | View.DownloadingMessage = UpdateResources.DownloadError; | 99 | View.ViewDispatcher.Dispatch( |
638 | 92 | View.Progress = MinimumValue; | 100 | () => |
639 | 93 | View.CloseButtonIsEnabled = true; | 101 | { |
640 | 102 | View.DownloadingMessage = UpdateResources.DownloadError; | ||
641 | 103 | View.Progress = MinimumValue; | ||
642 | 104 | View.CloseButtonIsEnabled = true; | ||
643 | 105 | }); | ||
644 | 94 | } | 106 | } |
645 | 95 | 107 | ||
646 | 96 | /// <summary> | 108 | /// <summary> |
647 | @@ -100,11 +112,15 @@ | |||
648 | 100 | /// <param name="e">The arguments that provide more information about the comleted task.</param> | 112 | /// <param name="e">The arguments that provide more information about the comleted task.</param> |
649 | 101 | public void DownloadUpdateCompleted(object sender, TaskEventArgs e) | 113 | public void DownloadUpdateCompleted(object sender, TaskEventArgs e) |
650 | 102 | { | 114 | { |
653 | 103 | View.DownloadingMessage = UpdateResources.DownloadCompleted; | 115 | View.ViewDispatcher.Dispatch( |
654 | 104 | View.Progress = MaximumValue; | 116 | () => |
655 | 117 | { | ||
656 | 118 | View.DownloadingMessage = UpdateResources.DownloadCompleted; | ||
657 | 119 | View.Progress = MaximumValue; | ||
658 | 120 | }); | ||
659 | 105 | // let the user know | 121 | // let the user know |
660 | 106 | Thread.Sleep(100); | 122 | Thread.Sleep(100); |
662 | 107 | View.Close(); | 123 | View.ViewDispatcher.Dispatch(() => View.Close()); |
663 | 108 | } | 124 | } |
664 | 109 | } | 125 | } |
665 | 110 | } | 126 | } |
666 | 111 | 127 | ||
667 | === modified file 'src/Canonical.UbuntuOne.Common/Update/IDownloadingView.cs' | |||
668 | --- src/Canonical.UbuntuOne.Common/Update/IDownloadingView.cs 2010-07-29 16:33:39 +0000 | |||
669 | +++ src/Canonical.UbuntuOne.Common/Update/IDownloadingView.cs 2010-08-24 15:18:39 +0000 | |||
670 | @@ -1,4 +1,4 @@ | |||
672 | 1 | /** | 1 | /* |
673 | 2 | * Copyright 2010 Canonical Ltd. | 2 | * Copyright 2010 Canonical Ltd. |
674 | 3 | * | 3 | * |
675 | 4 | * This file is part of UbuntuOne on Windows. | 4 | * This file is part of UbuntuOne on Windows. |
676 | @@ -17,6 +17,8 @@ | |||
677 | 17 | * | 17 | * |
678 | 18 | * Authors: Manuel de la Peña <manuel.delapena@canonical.com> | 18 | * Authors: Manuel de la Peña <manuel.delapena@canonical.com> |
679 | 19 | */ | 19 | */ |
680 | 20 | using Canonical.UbuntuOne.Common.Threading; | ||
681 | 21 | |||
682 | 20 | namespace Canonical.UbuntuOne.Common.Update | 22 | namespace Canonical.UbuntuOne.Common.Update |
683 | 21 | { | 23 | { |
684 | 22 | /// <summary> | 24 | /// <summary> |
685 | @@ -25,6 +27,12 @@ | |||
686 | 25 | public interface IDownloadingView | 27 | public interface IDownloadingView |
687 | 26 | { | 28 | { |
688 | 27 | /// <summary> | 29 | /// <summary> |
689 | 30 | /// Gets the dispatcher that can be used to call actions on the object from a | ||
690 | 31 | /// different thread. | ||
691 | 32 | /// </summary> | ||
692 | 33 | IDispatcher ViewDispatcher { get; } | ||
693 | 34 | |||
694 | 35 | /// <summary> | ||
695 | 28 | /// Gets and sets if the close button is enabled. | 36 | /// Gets and sets if the close button is enabled. |
696 | 29 | /// </summary> | 37 | /// </summary> |
697 | 30 | bool CloseButtonIsEnabled { get; set; } | 38 | bool CloseButtonIsEnabled { get; set; } |
698 | 31 | 39 | ||
699 | === modified file 'src/Canonical.UbuntuOne.Common/Update/IUpdatingPresenter.cs' | |||
700 | --- src/Canonical.UbuntuOne.Common/Update/IUpdatingPresenter.cs 2010-08-05 07:13:28 +0000 | |||
701 | +++ src/Canonical.UbuntuOne.Common/Update/IUpdatingPresenter.cs 2010-08-24 15:18:39 +0000 | |||
702 | @@ -1,4 +1,4 @@ | |||
704 | 1 | /** | 1 | /* |
705 | 2 | * Copyright 2010 Canonical Ltd. | 2 | * Copyright 2010 Canonical Ltd. |
706 | 3 | * | 3 | * |
707 | 4 | * This file is part of UbuntuOne on Windows. | 4 | * This file is part of UbuntuOne on Windows. |
708 | 5 | 5 | ||
709 | === modified file 'src/Canonical.UbuntuOne.Common/Update/IUpdatingView.cs' | |||
710 | --- src/Canonical.UbuntuOne.Common/Update/IUpdatingView.cs 2010-08-05 08:15:00 +0000 | |||
711 | +++ src/Canonical.UbuntuOne.Common/Update/IUpdatingView.cs 2010-08-24 15:18:39 +0000 | |||
712 | @@ -1,20 +1,24 @@ | |||
730 | 1 | // Copyright 2010 Canonical Ltd. | 1 | /* |
731 | 2 | // | 2 | * Copyright 2010 Canonical Ltd. |
732 | 3 | // This file is part of UbuntuOne on Windows. | 3 | * |
733 | 4 | // | 4 | * This file is part of UbuntuOne on Windows. |
734 | 5 | // UbuntuOne on Windows is free software: you can redistribute it and/or modify | 5 | * |
735 | 6 | // it under the terms of the GNU Lesser General Public License version | 6 | * UbuntuOne on Windows is free software: you can redistribute it and/or modify |
736 | 7 | // as published by the Free Software Foundation. | 7 | * it under the terms of the GNU Lesser General Public License version |
737 | 8 | // | 8 | * as published by the Free Software Foundation. |
738 | 9 | // Ubuntu One on Windows is distributed in the hope that it will be useful, | 9 | * |
739 | 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * Ubuntu One on Windows is distributed in the hope that it will be useful, |
740 | 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
741 | 12 | // GNU Lesser General Public License for more details. | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
742 | 13 | // | 13 | * GNU Lesser General Public License for more details. |
743 | 14 | // You should have received a copy of the GNU Lesser General Public License | 14 | * |
744 | 15 | // along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>. | 15 | * You should have received a copy of the GNU Lesser General Public License |
745 | 16 | // | 16 | * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>. |
746 | 17 | // Authors: Manuel de la Peña <manuel.delapena@canonical.com> | 17 | * |
747 | 18 | * Authors: Manuel de la Peña <manuel.delapena@canonical.com> | ||
748 | 19 | */ | ||
749 | 20 | |||
750 | 21 | using Canonical.UbuntuOne.Common.Threading; | ||
751 | 18 | 22 | ||
752 | 19 | namespace Canonical.UbuntuOne.Common.Update | 23 | namespace Canonical.UbuntuOne.Common.Update |
753 | 20 | { | 24 | { |
754 | @@ -25,6 +29,12 @@ | |||
755 | 25 | public interface IUpdatingView | 29 | public interface IUpdatingView |
756 | 26 | { | 30 | { |
757 | 27 | /// <summary> | 31 | /// <summary> |
758 | 32 | /// Gets the dispatcher that can be used to call actions on the object from a | ||
759 | 33 | /// different thread. | ||
760 | 34 | /// </summary> | ||
761 | 35 | IDispatcher ViewDispatcher { get; } | ||
762 | 36 | |||
763 | 37 | /// <summary> | ||
764 | 28 | /// Gets and sets if the view is visible | 38 | /// Gets and sets if the view is visible |
765 | 29 | /// </summary> | 39 | /// </summary> |
766 | 30 | bool IsShown { get; } | 40 | bool IsShown { get; } |
767 | 31 | 41 | ||
768 | === modified file 'src/Canonical.UbuntuOne.Common/Update/Updater.cs' | |||
769 | --- src/Canonical.UbuntuOne.Common/Update/Updater.cs 2010-08-05 07:13:28 +0000 | |||
770 | +++ src/Canonical.UbuntuOne.Common/Update/Updater.cs 2010-08-24 15:18:39 +0000 | |||
771 | @@ -154,7 +154,7 @@ | |||
772 | 154 | private void DownloadErrorHandler(object sender, DownloadTaskErrorEventArgs args) | 154 | private void DownloadErrorHandler(object sender, DownloadTaskErrorEventArgs args) |
773 | 155 | { | 155 | { |
774 | 156 | Logger.Error(args.Exception.Message); | 156 | Logger.Error(args.Exception.Message); |
776 | 157 | throw new SelfUpdateException(UpdateResources.DownloadError, args.Exception); | 157 | //throw new SelfUpdateException(UpdateResources.DownloadError, args.Exception); |
777 | 158 | } | 158 | } |
778 | 159 | 159 | ||
779 | 160 | /// <summary> | 160 | /// <summary> |
780 | @@ -240,7 +240,6 @@ | |||
781 | 240 | try | 240 | try |
782 | 241 | { | 241 | { |
783 | 242 | _downloadingUpdate = true; | 242 | _downloadingUpdate = true; |
784 | 243 | DotUpdater.BeginDownload(_task); | ||
785 | 244 | // provide the handler for the progress of the download as well as the | 243 | // provide the handler for the progress of the download as well as the |
786 | 245 | // error and finish | 244 | // error and finish |
787 | 246 | DotUpdater.OnDownloadProgress += DownloadingPresenter.DownloadProgressHandler; | 245 | DotUpdater.OnDownloadProgress += DownloadingPresenter.DownloadProgressHandler; |
788 | @@ -252,6 +251,7 @@ | |||
789 | 252 | // one for the updater that will handle the error. | 251 | // one for the updater that will handle the error. |
790 | 253 | DotUpdater.OnDownloadError += DownloadingPresenter.DownloadErrorHandler; | 252 | DotUpdater.OnDownloadError += DownloadingPresenter.DownloadErrorHandler; |
791 | 254 | DotUpdater.OnDownloadError += DownloadErrorHandler; | 253 | DotUpdater.OnDownloadError += DownloadErrorHandler; |
792 | 254 | DotUpdater.BeginDownload(_task); | ||
793 | 255 | } | 255 | } |
794 | 256 | catch (UpdaterException e) | 256 | catch (UpdaterException e) |
795 | 257 | { | 257 | { |
796 | 258 | 258 | ||
797 | === modified file 'src/Canonical.UbuntuOne.Common/objects.xml' | |||
798 | --- src/Canonical.UbuntuOne.Common/objects.xml 2010-08-02 14:31:39 +0000 | |||
799 | +++ src/Canonical.UbuntuOne.Common/objects.xml 2010-08-24 15:18:39 +0000 | |||
800 | @@ -29,7 +29,7 @@ | |||
801 | 29 | type="Canonical.UbuntuOne.Common.Update.Updater, Canonical.UbuntuOne.Common" | 29 | type="Canonical.UbuntuOne.Common.Update.Updater, Canonical.UbuntuOne.Common" |
802 | 30 | autowire="autodetect"> | 30 | autowire="autodetect"> |
803 | 31 | <property name="RSSFeed" | 31 | <property name="RSSFeed" |
805 | 32 | value="http://path/to/rss.feed"/> <!-- Provide a way to set this through config ????--> | 32 | value="http://s3.amazonaws.com/u1wintest/rss"/> <!-- Provide a way to set this through config ????--> |
806 | 33 | </object> | 33 | </object> |
807 | 34 | 34 | ||
808 | 35 | <!-- ######################################################################################## --> | 35 | <!-- ######################################################################################## --> |
809 | 36 | 36 | ||
810 | === modified file 'src/UbuntuOneClient/objects.xml' | |||
811 | --- src/UbuntuOneClient/objects.xml 2010-07-30 16:32:54 +0000 | |||
812 | +++ src/UbuntuOneClient/objects.xml 2010-08-24 15:18:39 +0000 | |||
813 | @@ -5,7 +5,7 @@ | |||
814 | 5 | type="Canonical.UbuntuOne.Common.Update.Updater, Canonical.UbuntuOne.Common" | 5 | type="Canonical.UbuntuOne.Common.Update.Updater, Canonical.UbuntuOne.Common" |
815 | 6 | autowire="autodetect"> | 6 | autowire="autodetect"> |
816 | 7 | <property name="RSSFeed" | 7 | <property name="RSSFeed" |
818 | 8 | value="http://path/to/rss.feed"/> | 8 | value="http://s3.amazonaws.com/u1wintest/rss"/> |
819 | 9 | </object> | 9 | </object> |
820 | 10 | 10 | ||
821 | 11 | <object id="Application" | 11 | <object id="Application" |
822 | 12 | 12 | ||
823 | === modified file 'utils/rss_templates.py' | |||
824 | --- utils/rss_templates.py 2010-07-29 12:20:01 +0000 | |||
825 | +++ utils/rss_templates.py 2010-08-24 15:18:39 +0000 | |||
826 | @@ -7,8 +7,8 @@ | |||
827 | 7 | - version | 7 | - version |
828 | 8 | - enclosure url | 8 | - enclosure url |
829 | 9 | - enclosure lenght | 9 | - enclosure lenght |
832 | 10 | - sha | 10 | - md5 |
833 | 11 | 11 | - uuid | |
834 | 12 | """ | 12 | """ |
835 | 13 | 13 | ||
836 | 14 | from string import Template | 14 | from string import Template |
837 | @@ -21,16 +21,16 @@ | |||
838 | 21 | <generator>WiX Toolset's ClickThrough for Isolated Applications</generator> | 21 | <generator>WiX Toolset's ClickThrough for Isolated Applications</generator> |
839 | 22 | <lastBuildDate>$lastBuildDate</lastBuildDate> | 22 | <lastBuildDate>$lastBuildDate</lastBuildDate> |
840 | 23 | <ttl>1440</ttl> | 23 | <ttl>1440</ttl> |
842 | 24 | <as:application type="application/vnd.ms-msi">7bb74cea-a4a3-4904-9706-8f4dc764b368</as:application> | 24 | <as:application type="application/vnd.ms-msi">bd2e11b5-5e83-45e4-88cd-4f7c414d71c7</as:application> |
843 | 25 | <item> | 25 | <item> |
845 | 26 | <guid isPermaLink="false">urn:msi:7bb74cea-a4a3-4904-9706-8f4dc764b368/$version</guid> | 26 | <guid isPermaLink="false">urn:msi:bd2e11b5-5e83-45e4-88cd-4f7c414d71c7/$version</guid> |
846 | 27 | <pubDate>$pubDate</pubDate> | 27 | <pubDate>$pubDate</pubDate> |
847 | 28 | <title>Ubuntu One Windows Client</title> | 28 | <title>Ubuntu One Windows Client</title> |
848 | 29 | <description>Ubuntu One Windows Client</description> | 29 | <description>Ubuntu One Windows Client</description> |
850 | 30 | <as:application type="application/vnd.ms-msi">58cdea62-96b2-482b-b046-d884583c8ccd</as:application> | 30 | <as:application type="application/vnd.ms-msi">$uuid</as:application> |
851 | 31 | <as:version>$version</as:version> | 31 | <as:version>$version</as:version> |
852 | 32 | <enclosure url="$url" length="$lenght" type="application/octet-stream" /> | 32 | <enclosure url="$url" length="$lenght" type="application/octet-stream" /> |
854 | 33 | <as:digest algorithm="sha256">$sha</as:digest> | 33 | <as:digest algorithm="md5">$md5</as:digest> |
855 | 34 | </item> | 34 | </item> |
856 | 35 | </channel> | 35 | </channel> |
857 | 36 | </rss> | 36 | </rss> |
858 | 37 | 37 | ||
859 | === modified file 'utils/upload_new_update.py' | |||
860 | --- utils/upload_new_update.py 2010-07-29 12:20:01 +0000 | |||
861 | +++ utils/upload_new_update.py 2010-08-24 15:18:39 +0000 | |||
862 | @@ -3,10 +3,12 @@ | |||
863 | 3 | 3 | ||
864 | 4 | """This utilities release an Ubuntu One windows update.""" | 4 | """This utilities release an Ubuntu One windows update.""" |
865 | 5 | 5 | ||
866 | 6 | import base64 | ||
867 | 7 | import hashlib | ||
868 | 6 | import os | 8 | import os |
869 | 9 | import sys | ||
870 | 7 | import time | 10 | import time |
873 | 8 | import hashlib | 11 | from uuid import uuid1 |
872 | 9 | import sys | ||
874 | 10 | 12 | ||
875 | 11 | import boto | 13 | import boto |
876 | 12 | from boto.s3.key import Key | 14 | from boto.s3.key import Key |
877 | @@ -20,18 +22,16 @@ | |||
878 | 20 | RSS_FILE_NAME = 'rss' | 22 | RSS_FILE_NAME = 'rss' |
879 | 21 | 23 | ||
880 | 22 | 24 | ||
882 | 23 | def upload_package(bucket, filename): | 25 | def upload_package(bucket, filename, rss_params): |
883 | 24 | """Upload the package""" | 26 | """Upload the package""" |
884 | 25 | try: | ||
885 | 26 | print 'Removing %s...' % filename | ||
886 | 27 | bucket.delete_key(filename) | ||
887 | 28 | except S3ResponseError: | ||
888 | 29 | print 'No previous upload.' | ||
889 | 30 | print 'Uploading %s...' % filename | ||
890 | 31 | k = Key(bucket) | 27 | k = Key(bucket) |
892 | 32 | k.key = filename | 28 | path = filename.split('\\') |
893 | 29 | name = path[len(path) -1] | ||
894 | 30 | keyname = rss_params['version'] + '/' + name | ||
895 | 31 | k.key = keyname | ||
896 | 32 | print 'Uploading %s...' % name | ||
897 | 33 | k.set_contents_from_filename(filename) | 33 | k.set_contents_from_filename(filename) |
899 | 34 | bucket.set_acl('public-read', filename) | 34 | bucket.set_acl('public-read', keyname) |
900 | 35 | print "Uploaded!" | 35 | print "Uploaded!" |
901 | 36 | 36 | ||
902 | 37 | 37 | ||
903 | @@ -40,8 +40,10 @@ | |||
904 | 40 | now = time.strftime('%d %b %Y %H:%M:%S %Z') | 40 | now = time.strftime('%d %b %Y %H:%M:%S %Z') |
905 | 41 | rss_params['lastBuildDate'] = rss_params['pubDate'] = now | 41 | rss_params['lastBuildDate'] = rss_params['pubDate'] = now |
906 | 42 | fd = open(filename,'r') | 42 | fd = open(filename,'r') |
908 | 43 | rss_params['sha'] = hashlib.sha1(fd.read()).hexdigest() | 43 | md5_hash = hashlib.md5(fd.read()).digest() |
909 | 44 | rss_params['md5'] = base64.urlsafe_b64encode(md5_hash) | ||
910 | 44 | rss_params['lenght'] = os.path.getsize(filename) | 45 | rss_params['lenght'] = os.path.getsize(filename) |
911 | 46 | rss_params['url'] = rss_params['url'] | ||
912 | 45 | try: | 47 | try: |
913 | 46 | print 'Removing rss...' | 48 | print 'Removing rss...' |
914 | 47 | bucket.delete_key(RSS_FILE_NAME) | 49 | bucket.delete_key(RSS_FILE_NAME) |
915 | @@ -64,7 +66,7 @@ | |||
916 | 64 | conn = boto.connect_s3() | 66 | conn = boto.connect_s3() |
917 | 65 | print 'Connected!' | 67 | print 'Connected!' |
918 | 66 | bucket = conn.get_bucket(BUCKET) | 68 | bucket = conn.get_bucket(BUCKET) |
920 | 67 | upload_package(bucket, filename) | 69 | upload_package(bucket, filename, rss_params) |
921 | 68 | upload_rss(bucket, filename, rss_params) | 70 | upload_rss(bucket, filename, rss_params) |
922 | 69 | 71 | ||
923 | 70 | 72 | ||
924 | @@ -80,4 +82,5 @@ | |||
925 | 80 | rss_params = {} | 82 | rss_params = {} |
926 | 81 | rss_params['version'] = argv[2] | 83 | rss_params['version'] = argv[2] |
927 | 82 | rss_params['url'] = argv[3] | 84 | rss_params['url'] = argv[3] |
928 | 85 | rss_params['uuid'] = str(uuid1()) | ||
929 | 83 | sys.exit(main(filename=argv[1], rss_params=rss_params)) | 86 | sys.exit(main(filename=argv[1], rss_params=rss_params)) |
Looks good, build and tests are passing.