Merge lp:~mandel/ubuntuone-windows-installer/add_update_view into lp:ubuntuone-windows-installer/beta

Proposed by Manuel de la Peña
Status: Merged
Approved by: Rick McBride
Approved revision: 69
Merged at revision: 49
Proposed branch: lp:~mandel/ubuntuone-windows-installer/add_update_view
Merge into: lp:ubuntuone-windows-installer/beta
Prerequisite: lp:~mandel/ubuntuone-windows-installer/systray_integrate_update
Diff against target: 1786 lines (+1258/-108)
30 files modified
build.number (+1/-1)
main.build (+1/-1)
src/Canonical.UbuntuOne.Client.Views/Canonical.UbuntuOne.Client.Views.csproj (+23/-0)
src/Canonical.UbuntuOne.Client.Views/Resources/Resources.Designer.cs (+27/-0)
src/Canonical.UbuntuOne.Client.Views/Resources/Resources.resx (+9/-0)
src/Canonical.UbuntuOne.Client.Views/UbuntuOneMessageBox.cs (+100/-0)
src/Canonical.UbuntuOne.Client.Views/Update/DownloadingView.xaml (+40/-0)
src/Canonical.UbuntuOne.Client.Views/Update/DownloadingView.xaml.cs (+72/-0)
src/Canonical.UbuntuOne.Client.Views/Update/UpdatingView.xaml (+32/-0)
src/Canonical.UbuntuOne.Client.Views/Update/UpdatingView.xaml.cs (+48/-0)
src/Canonical.UbuntuOne.Common.Tests/Canonical.UbuntuOne.Common.Tests.csproj (+6/-0)
src/Canonical.UbuntuOne.Common.Tests/Update/DownloadingPresenterFixture.cs (+141/-0)
src/Canonical.UbuntuOne.Common.Tests/Update/SelfUpdateExceptionFixture.cs (+60/-0)
src/Canonical.UbuntuOne.Common.Tests/Update/UpdaterFixture.cs (+51/-10)
src/Canonical.UbuntuOne.Common.Tests/Update/UpdatingPresenterFixture.cs (+107/-0)
src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj (+10/-1)
src/Canonical.UbuntuOne.Common/IMessageBox.cs (+71/-0)
src/Canonical.UbuntuOne.Common/Update/DownloadingPresenter.cs (+82/-0)
src/Canonical.UbuntuOne.Common/Update/IDownloadingPresenter.cs (+63/-0)
src/Canonical.UbuntuOne.Common/Update/IDownloadingView.cs (+68/-0)
src/Canonical.UbuntuOne.Common/Update/IUpdateView.cs (+0/-78)
src/Canonical.UbuntuOne.Common/Update/IUpdater.cs (+1/-1)
src/Canonical.UbuntuOne.Common/Update/IUpdatingPresenter.cs (+39/-0)
src/Canonical.UbuntuOne.Common/Update/IUpdatingView.cs (+50/-0)
src/Canonical.UbuntuOne.Common/Update/UpdateResources.Designer.cs (+63/-0)
src/Canonical.UbuntuOne.Common/Update/UpdateResources.resx (+21/-0)
src/Canonical.UbuntuOne.Common/Update/Updater.cs (+27/-14)
src/Canonical.UbuntuOne.Common/Update/UpdatingPresenter.cs (+41/-0)
src/UbuntuOneClient.Tests/ProgramFixture.cs (+2/-0)
src/Version.cs (+2/-2)
To merge this branch: bzr merge lp:~mandel/ubuntuone-windows-installer/add_update_view
Reviewer Review Type Date Requested Status
Rick McBride (community) Approve
John Lenton (community) Approve
Review via email: mp+31356@code.launchpad.net

Description of the change

Adds the initial implementation of the views used to show the user that the app is being updated.

To post a comment you must log in.
67. By Manuel de la Peña

Merge with trunk.

68. By Manuel de la Peña

Merge with trunk.

Revision history for this message
Manuel de la Peña (mandel) wrote :

This branch adds a set of view to us in the download dialogue, due to the fact that the views have no code at all besides setting and getting properties.

In order to build and run the tests you have to execute the following command from the root of the branch:

tools\Nant\bin\nant.exe tests

More info about compiling and testing here: https://wiki.ubuntu.com/UbuntuOne/Contribute/WindowsTesting

69. By Manuel de la Peña

Fix criss-cross

Revision history for this message
John Lenton (chipaca) wrote :

The branch looks good. I have only read it through, having no windows vm to test it with right now. So a full review is definitely still needed.

review: Approve
70. By Manuel de la Peña

Ignore test that gives erros due to RhinoMocks bug.

Revision history for this message
Rick McBride (rmcbride) wrote :

Looks good. The remaining issue we saw with the bootstrapper is not related to this branch

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'build.number'
2--- build.number 2010-07-30 09:33:20 +0000
3+++ build.number 2010-08-05 19:26:41 +0000
4@@ -1,1 +1,1 @@
5-1.0.0.0
6\ No newline at end of file
7+1.0.404.5869
8\ No newline at end of file
9
10=== modified file 'main.build'
11--- main.build 2010-08-02 17:57:48 +0000
12+++ main.build 2010-08-05 19:26:41 +0000
13@@ -160,7 +160,7 @@
14 workingdir="src/Canonical.UbuntuOne.ProcessDispatcher.Tests/bin/${enviroment}"
15 program="nunit-console.exe"
16 commandline="Canonical.UbuntuOne.ProcessDispatcher.Tests.dll /xml=../../../../test-results/Canonical.UbuntuOne.ProcessDispatcher.Tests-Result.xml" />
17-
18+
19 <echo>Canonical.UbuntuOne.Client.Test</echo>
20 <exec basedir="tools/NUnit"
21 managed="true"
22
23=== modified file 'src/Canonical.UbuntuOne.Client.Views/Canonical.UbuntuOne.Client.Views.csproj'
24--- src/Canonical.UbuntuOne.Client.Views/Canonical.UbuntuOne.Client.Views.csproj 2010-08-02 17:57:48 +0000
25+++ src/Canonical.UbuntuOne.Client.Views/Canonical.UbuntuOne.Client.Views.csproj 2010-08-05 19:26:41 +0000
26@@ -60,6 +60,10 @@
27 <SpecificVersion>False</SpecificVersion>
28 <HintPath>..\..\lib\WPFContrib\AvalonLibrary.dll</HintPath>
29 </Reference>
30+ <Reference Include="DotUpdater, Version=0.2.0.4, Culture=neutral, processorArchitecture=MSIL">
31+ <SpecificVersion>False</SpecificVersion>
32+ <HintPath>..\..\lib\DotUpdater\DotUpdater.dll</HintPath>
33+ </Reference>
34 <Reference Include="System" />
35 <Reference Include="System.Core">
36 <RequiredTargetFramework>3.5</RequiredTargetFramework>
37@@ -99,6 +103,14 @@
38 <SubType>Designer</SubType>
39 <Generator>MSBuild:Compile</Generator>
40 </Page>
41+ <Page Include="Update\DownloadingView.xaml">
42+ <SubType>Designer</SubType>
43+ <Generator>MSBuild:Compile</Generator>
44+ </Page>
45+ <Page Include="Update\UpdatingView.xaml">
46+ <SubType>Designer</SubType>
47+ <Generator>MSBuild:Compile</Generator>
48+ </Page>
49 <Compile Include="App.xaml.cs">
50 <DependentUpon>App.xaml</DependentUpon>
51 <SubType>Code</SubType>
52@@ -109,6 +121,7 @@
53 </Compile>
54 </ItemGroup>
55 <ItemGroup>
56+ <Compile Include="UbuntuOneMessageBox.cs" />
57 <Compile Include="..\Version.cs">
58 <Link>Properties\Version.cs</Link>
59 </Compile>
60@@ -133,6 +146,12 @@
61 <DesignTime>True</DesignTime>
62 <DependentUpon>Resources.resx</DependentUpon>
63 </Compile>
64+ <Compile Include="Update\DownloadingView.xaml.cs">
65+ <DependentUpon>DownloadingView.xaml</DependentUpon>
66+ </Compile>
67+ <Compile Include="Update\UpdatingView.xaml.cs">
68+ <DependentUpon>UpdatingView.xaml</DependentUpon>
69+ </Compile>
70 <EmbeddedResource Include="Properties\Resources.resx">
71 <Generator>ResXFileCodeGenerator</Generator>
72 <LastGenOutput>Resources.Designer.cs</LastGenOutput>
73@@ -189,6 +208,10 @@
74 <Project>{7467483A-D6D5-4362-8DF4-57A7254EB569}</Project>
75 <Name>Canonical.UbuntuOne.Client</Name>
76 </ProjectReference>
77+ <ProjectReference Include="..\Canonical.UbuntuOne.Common\Canonical.UbuntuOne.Common.csproj">
78+ <Project>{11353FF8-8E5A-488E-9CB1-873DADD232B9}</Project>
79+ <Name>Canonical.UbuntuOne.Common</Name>
80+ </ProjectReference>
81 </ItemGroup>
82 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
83 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
84
85=== modified file 'src/Canonical.UbuntuOne.Client.Views/Resources/Resources.Designer.cs'
86--- src/Canonical.UbuntuOne.Client.Views/Resources/Resources.Designer.cs 2010-07-27 15:35:34 +0000
87+++ src/Canonical.UbuntuOne.Client.Views/Resources/Resources.Designer.cs 2010-08-05 19:26:41 +0000
88@@ -61,6 +61,24 @@
89 }
90
91 /// <summary>
92+ /// Looks up a localized string similar to Ubuntu One.
93+ /// </summary>
94+ public static string ApplicationName {
95+ get {
96+ return ResourceManager.GetString("ApplicationName", resourceCulture);
97+ }
98+ }
99+
100+ /// <summary>
101+ /// Looks up a localized string similar to Downloading updates....
102+ /// </summary>
103+ public static string DownloadingDialogTitle {
104+ get {
105+ return ResourceManager.GetString("DownloadingDialogTitle", resourceCulture);
106+ }
107+ }
108+
109+ /// <summary>
110 /// Looks up a localized string similar to Exit.
111 /// </summary>
112 public static string Exit {
113@@ -122,5 +140,14 @@
114 return ResourceManager.GetString("UbuntuOnePreferences", resourceCulture);
115 }
116 }
117+
118+ /// <summary>
119+ /// Looks up a localized string similar to Updating Ubuntu One....
120+ /// </summary>
121+ public static string UpdatingDialogTitle {
122+ get {
123+ return ResourceManager.GetString("UpdatingDialogTitle", resourceCulture);
124+ }
125+ }
126 }
127 }
128
129=== modified file 'src/Canonical.UbuntuOne.Client.Views/Resources/Resources.resx'
130--- src/Canonical.UbuntuOne.Client.Views/Resources/Resources.resx 2010-07-27 15:35:34 +0000
131+++ src/Canonical.UbuntuOne.Client.Views/Resources/Resources.resx 2010-08-05 19:26:41 +0000
132@@ -117,6 +117,12 @@
133 <resheader name="writer">
134 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
135 </resheader>
136+ <data name="ApplicationName" xml:space="preserve">
137+ <value>Ubuntu One</value>
138+ </data>
139+ <data name="DownloadingDialogTitle" xml:space="preserve">
140+ <value>Downloading updates...</value>
141+ </data>
142 <data name="Exit" xml:space="preserve">
143 <value>Exit</value>
144 </data>
145@@ -138,4 +144,7 @@
146 <data name="UbuntuOnePreferences" xml:space="preserve">
147 <value>Ubuntu One Preferences</value>
148 </data>
149+ <data name="UpdatingDialogTitle" xml:space="preserve">
150+ <value>Updating Ubuntu One...</value>
151+ </data>
152 </root>
153\ No newline at end of file
154
155=== added file 'src/Canonical.UbuntuOne.Client.Views/UbuntuOneMessageBox.cs'
156--- src/Canonical.UbuntuOne.Client.Views/UbuntuOneMessageBox.cs 1970-01-01 00:00:00 +0000
157+++ src/Canonical.UbuntuOne.Client.Views/UbuntuOneMessageBox.cs 2010-08-05 19:26:41 +0000
158@@ -0,0 +1,100 @@
159+/**
160+ * Copyright 2010 Canonical Ltd.
161+ *
162+ * This file is part of UbuntuOne on Windows.
163+ *
164+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
165+ * it under the terms of the GNU Lesser General Public License version
166+ * as published by the Free Software Foundation.
167+ *
168+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
169+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
170+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
171+ * GNU Lesser General Public License for more details.
172+ *
173+ * You should have received a copy of the GNU Lesser General Public License
174+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
175+ *
176+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
177+ */
178+using System.Windows;
179+using Canonical.UbuntuOne.Common;
180+
181+namespace Canonical.UbuntuOne.Client.Views
182+{
183+ /// <summary>
184+ /// Provides a collection of useful method to show information to the user.
185+ /// </summary>
186+ public class UbuntuOneMessageBox : IMessageBox
187+ {
188+ /// <summary>
189+ /// Displays an error dialog with a given message.
190+ /// </summary>
191+ /// <param name="message">The message to be displayed.</param>
192+ public void ShowError(string message)
193+ {
194+ ShowMessage(message, MessageBoxImage.Error);
195+ }
196+
197+ /// <summary>
198+ /// Displays an error dialog with a given message.
199+ /// </summary>
200+ /// <param name="message">The message to be displayed.</param>
201+ public void ShowInformation(string message)
202+ {
203+ ShowMessage(message, MessageBoxImage.Information);
204+ }
205+
206+ /// <summary>
207+ /// Displays an error dialog with a given message.
208+ /// </summary>
209+ /// <param name="message">The message to be displayed.</param>
210+ public void ShowWarning(string message)
211+ {
212+ ShowMessage(message, MessageBoxImage.Warning);
213+ }
214+
215+ /// <summary>
216+ /// Displays an error dialog with a given message and icon.
217+ /// </summary>
218+ /// <param name="message">The message to be displayed.</param>
219+ /// <param name="icon">The icon to be displayed with the message.</param>
220+ public void ShowMessage(string message, MessageBoxImage icon)
221+ {
222+ MessageBox.Show(message, Resources.Resources.ApplicationName, MessageBoxButton.OK, icon);
223+ }
224+
225+ /// <summary>
226+ /// Displays an OK / Cancel dialog and returns the user input.
227+ /// </summary>
228+ /// <param name="message">The message to be displayed.</param>
229+ /// <param name="icon">The icon to be displayed.</param>
230+ /// <returns>User selection.</returns>
231+ public MessageBoxResult ShowOkCancel(string message, MessageBoxImage icon)
232+ {
233+ return MessageBox.Show(message, Resources.Resources.ApplicationName, MessageBoxButton.OKCancel, icon);
234+ }
235+
236+ /// <summary>
237+ /// Displays a Yes/No dialog and returns the user input.
238+ /// </summary>
239+ /// <param name="message">The message to be displayed.</param>
240+ /// <param name="icon">The icon to be displayed.</param>
241+ /// <returns>User selection.</returns>
242+ public MessageBoxResult ShowYesNo(string message, MessageBoxImage icon)
243+ {
244+ return MessageBox.Show(message, Resources.Resources.ApplicationName, MessageBoxButton.YesNo, icon);
245+ }
246+
247+ /// <summary>
248+ /// Displays an Yes / No / Cancel dialog and returns the user input.
249+ /// </summary>
250+ /// <param name="message">The message to be displayed.</param>
251+ /// <param name="icon">The icon to be displayed.</param>
252+ /// <returns>User selection.</returns>
253+ public MessageBoxResult ShowYesNoCancel(string message, MessageBoxImage icon)
254+ {
255+ return MessageBox.Show(message, Resources.Resources.ApplicationName, MessageBoxButton.YesNoCancel, icon);
256+ }
257+ }
258+}
259
260=== added directory 'src/Canonical.UbuntuOne.Client.Views/Update'
261=== added file 'src/Canonical.UbuntuOne.Client.Views/Update/DownloadingView.xaml'
262--- src/Canonical.UbuntuOne.Client.Views/Update/DownloadingView.xaml 1970-01-01 00:00:00 +0000
263+++ src/Canonical.UbuntuOne.Client.Views/Update/DownloadingView.xaml 2010-08-05 19:26:41 +0000
264@@ -0,0 +1,40 @@
265+<!--
266+ * Copyright 2010 Canonical Ltd.
267+ *
268+ * This file is part of UbuntuOne on Windows.
269+ *
270+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
271+ * it under the terms of the GNU Lesser General Public License version
272+ * as published by the Free Software Foundation.
273+ *
274+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
275+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
276+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
277+ * GNU Lesser General Public License for more details.
278+ *
279+ * You should have received a copy of the GNU Lesser General Public License
280+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
281+ *
282+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
283+-->
284+<Window x:Class="Canonical.UbuntuOne.Client.Views.Update.DownloadingView"
285+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
286+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
287+ Height="150" Width="350">
288+ <Grid>
289+ <Grid.RowDefinitions>
290+ <RowDefinition Height="*" />
291+ <RowDefinition Height="28" />
292+ <RowDefinition Height="28" />
293+ </Grid.RowDefinitions>
294+ <Label Name="MessageLabel" Grid.Row="0" Margin="3">Test</Label>
295+ <ProgressBar Name="Progressbar" Grid.Row="1" HorizontalAlignment="Stretch" Margin="3" />
296+ <Grid Grid.Row="2">
297+ <Grid.ColumnDefinitions>
298+ <ColumnDefinition Width="*"/>
299+ <ColumnDefinition Width="85"/>
300+ </Grid.ColumnDefinitions>
301+ <Button Name="CloseButton" Grid.Column="1" Margin="3">Close</Button>
302+ </Grid>
303+ </Grid>
304+</Window>
305
306=== added file 'src/Canonical.UbuntuOne.Client.Views/Update/DownloadingView.xaml.cs'
307--- src/Canonical.UbuntuOne.Client.Views/Update/DownloadingView.xaml.cs 1970-01-01 00:00:00 +0000
308+++ src/Canonical.UbuntuOne.Client.Views/Update/DownloadingView.xaml.cs 2010-08-05 19:26:41 +0000
309@@ -0,0 +1,72 @@
310+/**
311+ * Copyright 2010 Canonical Ltd.
312+ *
313+ * This file is part of UbuntuOne on Windows.
314+ *
315+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
316+ * it under the terms of the GNU Lesser General Public License version
317+ * as published by the Free Software Foundation.
318+ *
319+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
320+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
321+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
322+ * GNU Lesser General Public License for more details.
323+ *
324+ * You should have received a copy of the GNU Lesser General Public License
325+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
326+ *
327+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
328+ */
329+using System;
330+using Canonical.UbuntuOne.Common.Update;
331+using StaticResources = Canonical.UbuntuOne.Client.Views.Resources.Resources;
332+namespace Canonical.UbuntuOne.Client.Views.Update
333+{
334+ /// <summary>
335+ /// Interaction logic for DownloadingView.xaml
336+ /// </summary>
337+ public partial class DownloadingView : IDownloadingView
338+ {
339+ public DownloadingView()
340+ {
341+ InitializeComponent();
342+ Title = StaticResources.DownloadingDialogTitle;
343+ }
344+
345+ public bool CloseButtonIsEnabled
346+ {
347+ get { return CloseButton.IsEnabled; }
348+ set { CloseButton.IsEnabled = value; }
349+ }
350+
351+ public bool IsShown
352+ {
353+ get { return IsVisible; }
354+ }
355+
356+ public string DownloadingMessage
357+ {
358+ get { return (String)MessageLabel.Content; }
359+ set { MessageLabel.Content = value; }
360+ }
361+
362+ public double MinimumValue
363+ {
364+ get { return Progressbar.Minimum; }
365+ set { Progressbar.Minimum = value; }
366+ }
367+
368+ public double MaximumValue
369+ {
370+ get { return Progressbar.Maximum; }
371+ set { Progressbar.Maximum = value; }
372+ }
373+
374+ public double Progress
375+ {
376+ get { return Progressbar.Value; }
377+ set { Progressbar.Value = value; }
378+ }
379+
380+ }
381+}
382
383=== added file 'src/Canonical.UbuntuOne.Client.Views/Update/UpdatingView.xaml'
384--- src/Canonical.UbuntuOne.Client.Views/Update/UpdatingView.xaml 1970-01-01 00:00:00 +0000
385+++ src/Canonical.UbuntuOne.Client.Views/Update/UpdatingView.xaml 2010-08-05 19:26:41 +0000
386@@ -0,0 +1,32 @@
387+<!--
388+ * Copyright 2010 Canonical Ltd.
389+ *
390+ * This file is part of UbuntuOne on Windows.
391+ *
392+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
393+ * it under the terms of the GNU Lesser General Public License version
394+ * as published by the Free Software Foundation.
395+ *
396+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
397+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
398+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
399+ * GNU Lesser General Public License for more details.
400+ *
401+ * You should have received a copy of the GNU Lesser General Public License
402+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
403+ *
404+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
405+-->
406+<Window x:Class="Canonical.UbuntuOne.Client.Views.Update.UpdatingView"
407+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
408+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
409+ Title="UpdatingView" Height="150" Width="350">
410+ <Grid>
411+ <Grid.RowDefinitions>
412+ <RowDefinition Height="*" />
413+ <RowDefinition Height="75" />
414+ </Grid.RowDefinitions>
415+ <Label Name="MessageLabel" Grid.Row="0" Margin="3">Test</Label>
416+ <ProgressBar Name="Progressbar" Grid.Row="1" HorizontalAlignment="Stretch" Margin="3" Height="28"/>
417+ </Grid>
418+</Window>
419
420=== added file 'src/Canonical.UbuntuOne.Client.Views/Update/UpdatingView.xaml.cs'
421--- src/Canonical.UbuntuOne.Client.Views/Update/UpdatingView.xaml.cs 1970-01-01 00:00:00 +0000
422+++ src/Canonical.UbuntuOne.Client.Views/Update/UpdatingView.xaml.cs 2010-08-05 19:26:41 +0000
423@@ -0,0 +1,48 @@
424+/**
425+ * Copyright 2010 Canonical Ltd.
426+ *
427+ * This file is part of UbuntuOne on Windows.
428+ *
429+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
430+ * it under the terms of the GNU Lesser General Public License version
431+ * as published by the Free Software Foundation.
432+ *
433+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
434+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
435+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
436+ * GNU Lesser General Public License for more details.
437+ *
438+ * You should have received a copy of the GNU Lesser General Public License
439+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
440+ *
441+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
442+ */
443+using System;
444+using Canonical.UbuntuOne.Common.Update;
445+
446+namespace Canonical.UbuntuOne.Client.Views.Update
447+{
448+ /// <summary>
449+ /// Interaction logic for UpdatingView.xaml
450+ /// </summary>
451+ public partial class UpdatingView : IUpdatingView
452+ {
453+ public UpdatingView()
454+ {
455+ InitializeComponent();
456+ }
457+
458+ public bool IsShown
459+ {
460+ get { return IsVisible; }
461+ }
462+
463+ public bool IsUpdating { get; set; }
464+
465+ public string UpdatingText
466+ {
467+ get { return (String) MessageLabel.Content; }
468+ set { MessageLabel.Content = value; }
469+ }
470+ }
471+}
472
473=== modified file 'src/Canonical.UbuntuOne.Common.Tests/Canonical.UbuntuOne.Common.Tests.csproj'
474--- src/Canonical.UbuntuOne.Common.Tests/Canonical.UbuntuOne.Common.Tests.csproj 2010-07-30 09:33:20 +0000
475+++ src/Canonical.UbuntuOne.Common.Tests/Canonical.UbuntuOne.Common.Tests.csproj 2010-08-05 19:26:41 +0000
476@@ -42,7 +42,10 @@
477 <Compile Include="ProcessManagementExceptionFixture.cs" />
478 <Compile Include="Properties\AssemblyInfo.cs" />
479 <Compile Include="SyncDaemonExceptionFixture.cs" />
480+ <Compile Include="Update\DownloadingPresenterFixture.cs" />
481+ <Compile Include="Update\SelfUpdateExceptionFixture.cs" />
482 <Compile Include="Update\UpdaterFixture.cs" />
483+ <Compile Include="Update\UpdatingPresenterFixture.cs" />
484 <Compile Include="Validation\ArgumentValidationFixture.cs" />
485 <Compile Include="Validation\EqualityExtensionsValidation.cs" />
486 <Compile Include="Validation\MultiExceptionFixture.cs" />
487@@ -61,6 +64,9 @@
488 <SpecificVersion>False</SpecificVersion>
489 <HintPath>..\..\lib\Nunit\nunit.framework.dll</HintPath>
490 </Reference>
491+ <Reference Include="PresentationFramework">
492+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
493+ </Reference>
494 <Reference Include="Rhino.Mocks, Version=3.6.0.0, Culture=neutral, PublicKeyToken=0b3305902db7183f">
495 <SpecificVersion>False</SpecificVersion>
496 <HintPath>..\..\lib\RhinoMocks\Rhino.Mocks.dll</HintPath>
497
498=== added file 'src/Canonical.UbuntuOne.Common.Tests/Update/DownloadingPresenterFixture.cs'
499--- src/Canonical.UbuntuOne.Common.Tests/Update/DownloadingPresenterFixture.cs 1970-01-01 00:00:00 +0000
500+++ src/Canonical.UbuntuOne.Common.Tests/Update/DownloadingPresenterFixture.cs 2010-08-05 19:26:41 +0000
501@@ -0,0 +1,141 @@
502+/**
503+ * Copyright 2010 Canonical Ltd.
504+ *
505+ * This file is part of UbuntuOne on Windows.
506+ *
507+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
508+ * it under the terms of the GNU Lesser General Public License version
509+ * as published by the Free Software Foundation.
510+ *
511+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
512+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
513+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
514+ * GNU Lesser General Public License for more details.
515+ *
516+ * You should have received a copy of the GNU Lesser General Public License
517+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
518+ *
519+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
520+ */
521+using System;
522+using Canonical.UbuntuOne.Common.Update;
523+using Microsoft.ApplicationBlocks.Updater;
524+using NUnit.Framework;
525+using Rhino.Mocks;
526+namespace Canonical.UbuntuOne.Common.Tests.Update
527+{
528+ [TestFixture]
529+ public class DownloadingPresenterFixture
530+ {
531+ #region Variables
532+
533+ private MockRepository _mocks;
534+ private IDownloadingView _view;
535+ private DownloadingPresenter _presenter;
536+
537+ #endregion
538+
539+ #region SetUp & TearDown
540+
541+ [SetUp]
542+ public void Setup()
543+ {
544+ _mocks = new MockRepository();
545+ _view = _mocks.DynamicMock<IDownloadingView>();
546+ _presenter = new DownloadingPresenter
547+ {
548+ View = _view
549+ };
550+ // If you do not do this the _view will want to play back the settins done inthe
551+ // _presenter set view method.
552+ _mocks.BackToRecord(_view);
553+ }
554+
555+ #endregion
556+
557+ [Test]
558+ public void ViewSetterPropertyNullViewTest()
559+ {
560+ using(_mocks.Record())
561+ {
562+ _view.MaximumValue = DownloadingPresenter.MaximumValue;
563+ _view.MinimumValue = DownloadingPresenter.MinimumValue;
564+ _view.Progress = DownloadingPresenter.MinimumValue;
565+
566+ }
567+ using(_mocks.Playback())
568+ {
569+ _presenter.View = _view;
570+ }
571+ }
572+
573+ [TestCase(34, 45)]
574+ [TestCase(2, 100)]
575+ [TestCase(35, 100)]
576+ public void DownloadProgressHandlerVisibleTest(long progress, long total)
577+ {
578+ using (_mocks.Record())
579+ {
580+ SetupResult.For(_view.IsShown)
581+ .Return(true);
582+ _view.DownloadingMessage = UpdateResources.DownloadInProgress;
583+ _view.Progress = (progress * DownloadingPresenter.MaximumValue) / total;
584+ }
585+ using (_mocks.Playback())
586+ {
587+ _presenter.DownloadProgressHandler(this, new DownloadTaskProgressEventArgs(total, progress, 2, 1, null));
588+ }
589+ }
590+
591+ [TestCase(34, 45)]
592+ [TestCase(2, 100)]
593+ [TestCase(35, 100)]
594+ public void DownloadProgressHandlerNotVisibleTest(long progress, long total)
595+ {
596+ using (_mocks.Record())
597+ {
598+ SetupResult.For(_view.IsShown)
599+ .Return(false);
600+ Expect.Call(() => _view.Show())
601+ .Repeat.Once();
602+ _view.DownloadingMessage = UpdateResources.DownloadInProgress;
603+ _view.Progress = (progress * DownloadingPresenter.MaximumValue) / total;
604+ }
605+ using (_mocks.Playback())
606+ {
607+ _presenter.DownloadProgressHandler(this, new DownloadTaskProgressEventArgs(total, progress, 2, 1, null));
608+ }
609+ }
610+
611+ [Test]
612+ public void DownloadErrorHandlerTest()
613+ {
614+ using (_mocks.Record())
615+ {
616+ _view.DownloadingMessage = UpdateResources.DownloadError;
617+ _view.CloseButtonIsEnabled = true;
618+ _view.Progress = DownloadingPresenter.MinimumValue;
619+ }
620+ using (_mocks.Playback())
621+ {
622+ _presenter.DownloadErrorHandler(this, new DownloadTaskErrorEventArgs(null, new Exception()));
623+ }
624+ }
625+
626+ [Test]
627+ public void DownloadUpdateCompleted()
628+ {
629+ using (_mocks.Record())
630+ {
631+ _view.DownloadingMessage = UpdateResources.DownloadCompleted;
632+ _view.Progress = DownloadingPresenter.MaximumValue;
633+ _view.Close();
634+ }
635+ using (_mocks.Playback())
636+ {
637+ _presenter.DownloadUpdateCompleted(this, new TaskEventArgs(null));
638+ }
639+ }
640+
641+ }
642+}
643
644=== added file 'src/Canonical.UbuntuOne.Common.Tests/Update/SelfUpdateExceptionFixture.cs'
645--- src/Canonical.UbuntuOne.Common.Tests/Update/SelfUpdateExceptionFixture.cs 1970-01-01 00:00:00 +0000
646+++ src/Canonical.UbuntuOne.Common.Tests/Update/SelfUpdateExceptionFixture.cs 2010-08-05 19:26:41 +0000
647@@ -0,0 +1,60 @@
648+/**
649+ * Copyright 2010 Canonical Ltd.
650+ *
651+ * This file is part of UbuntuOne on Windows.
652+ *
653+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
654+ * it under the terms of the GNU Lesser General Public License version
655+ * as published by the Free Software Foundation.
656+ *
657+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
658+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
659+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
660+ * GNU Lesser General Public License for more details.
661+ *
662+ * You should have received a copy of the GNU Lesser General Public License
663+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
664+ *
665+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
666+ */
667+
668+using System;
669+using Canonical.UbuntuOne.Common.Update;
670+using NUnit.Framework;
671+
672+namespace Canonical.UbuntuOne.Common.Tests.Update
673+{
674+ [TestFixture]
675+ public class SelfUpdateExceptionFixture
676+ {
677+
678+ #region Tests
679+
680+ [Test]
681+ public void EmptyConstructor()
682+ {
683+ var ex = new SelfUpdateException();
684+ Assert.IsNotNullOrEmpty(ex.Message);
685+ Assert.IsNull(ex.InnerException);
686+ }
687+
688+ [TestCase("Message")]
689+ [TestCase("mandel")]
690+ public void MessageConstructorTest(string message)
691+ {
692+ var exception = new SelfUpdateException(message);
693+ Assert.AreEqual(message, exception.Message);
694+ }
695+
696+ [TestCase("Message", typeof(InvalidOperationException))]
697+ [TestCase("mandel", typeof(NullReferenceException))]
698+ public void MessageInnerExceptionConstructor(string message, Type exceptionType)
699+ {
700+ var inner = (Exception)Activator.CreateInstance(exceptionType);
701+ var ex = new SelfUpdateException(message, inner);
702+ Assert.AreEqual(message, ex.Message);
703+ Assert.IsInstanceOf(exceptionType, ex.InnerException);
704+ }
705+ #endregion
706+ }
707+}
708
709=== modified file 'src/Canonical.UbuntuOne.Common.Tests/Update/UpdaterFixture.cs'
710--- src/Canonical.UbuntuOne.Common.Tests/Update/UpdaterFixture.cs 2010-07-28 14:35:45 +0000
711+++ src/Canonical.UbuntuOne.Common.Tests/Update/UpdaterFixture.cs 2010-08-05 19:26:41 +0000
712@@ -17,6 +17,7 @@
713 *
714 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
715 */
716+using System.Windows;
717 using Canonical.UbuntuOne.Common.Update;
718 using log4net;
719 using Microsoft.ApplicationBlocks.Updater;
720@@ -33,12 +34,12 @@
721 {
722 #region Setup
723
724- private Logger _dotLogger;
725 private ILog _logger;
726 private MockRepository _mocks;
727 private Updater _updater;
728- private IUpdateView _view;
729+ private IDownloadingPresenter _presenter;
730 private IDotUpdaterWrapper _dotUpdaterWrapper;
731+ private IMessageBox _messageBox;
732
733 [SetUp]
734 public void Setup()
735@@ -46,14 +47,16 @@
736
737 _mocks = new MockRepository();
738 _logger = _mocks.DynamicMock<ILog>();
739- _dotLogger = _mocks.DynamicMock<Logger>();
740+ _mocks.DynamicMock<Logger>();
741 _dotUpdaterWrapper = _mocks.DynamicMock<IDotUpdaterWrapper>();
742- _view = _mocks.DynamicMock<IUpdateView>();
743+ _presenter = _mocks.DynamicMock<IDownloadingPresenter>();
744+ _messageBox = _mocks.StrictMock<IMessageBox>();
745 _updater = new Updater
746 {
747 Logger = _logger,
748- UpdateView = _view,
749- DotUpdater = _dotUpdaterWrapper
750+ DownloadingPresenter = _presenter,
751+ DotUpdater = _dotUpdaterWrapper,
752+ MessageBox = _messageBox
753 };
754 }
755
756@@ -115,7 +118,38 @@
757 [ExpectedException(typeof(SelfUpdateException))]
758 public void PerformUpdateNoCheckDoneTest()
759 {
760- _updater.PerformUpdate();
761+ using(_mocks.Record())
762+ {
763+ Expect.Call(_messageBox.ShowYesNo(UpdateResources.DownloadUpdatesQuestion, MessageBoxImage.Question))
764+ .Return(MessageBoxResult.Yes);
765+ }
766+ using (_mocks.Playback())
767+ {
768+ _updater.PerformUpdate();
769+ }
770+ }
771+
772+ [Test]
773+ public void PerformUpdateUserSaysNoTest()
774+ {
775+ var task = _mocks.DynamicMock<UpdaterTask>("", "wewe", new string[0], "code", new string[0]);
776+ using (_mocks.Record())
777+ {
778+ Expect.Call(_messageBox.ShowYesNo(UpdateResources.DownloadUpdatesQuestion, MessageBoxImage.Question))
779+ .Return(MessageBoxResult.No);
780+ Expect.Call(_dotUpdaterWrapper.CheckForUpdates())
781+ .Return(task)
782+ .Repeat.Once();
783+ Expect.Call(() => _dotUpdaterWrapper.BeginDownload(task))
784+ .Repeat.Never();
785+ }
786+ using (_mocks.Playback())
787+ {
788+ if (_updater.UpdatesArePresent())
789+ {
790+ _updater.PerformUpdate();
791+ }
792+ }
793 }
794
795 [Test]
796@@ -124,6 +158,8 @@
797 {
798 using (_mocks.Record())
799 {
800+ Expect.Call(_messageBox.ShowYesNo(UpdateResources.DownloadUpdatesQuestion, MessageBoxImage.Question))
801+ .Return(MessageBoxResult.Yes);
802 Expect.Call(_dotUpdaterWrapper.CheckForUpdates())
803 .Return(null)
804 .Repeat.Once();
805@@ -142,6 +178,9 @@
806 var task = _mocks.DynamicMock<UpdaterTask>("", "wewe", new string[0], "code", new string[0]);
807 using(_mocks.Record())
808 {
809+ Expect.Call(_messageBox.ShowYesNo(UpdateResources.DownloadUpdatesQuestion, MessageBoxImage.Question))
810+ .Return(MessageBoxResult.Yes);
811+
812 Expect.Call(_dotUpdaterWrapper.CheckForUpdates())
813 .Return(task)
814 .Repeat.Once();
815@@ -150,13 +189,13 @@
816 .Repeat.Once();
817
818 // ensure the handlers have been registered
819- _dotUpdaterWrapper.OnDownloadProgress += _view.DownloadProgressHandler;
820+ _dotUpdaterWrapper.OnDownloadProgress += _presenter.DownloadProgressHandler;
821
822- _dotUpdaterWrapper.OnDownloadCompleted += _view.DownloadUpdateCompleted;
823+ _dotUpdaterWrapper.OnDownloadCompleted += _presenter.DownloadUpdateCompleted;
824 _dotUpdaterWrapper.OnDownloadCompleted += null;
825 LastCall.IgnoreArguments();
826
827- _dotUpdaterWrapper.OnDownloadError += _view.DownloadErrorHandler;
828+ _dotUpdaterWrapper.OnDownloadError += _presenter.DownloadErrorHandler;
829 _dotUpdaterWrapper.OnDownloadError += null;
830 LastCall.IgnoreArguments();
831
832@@ -177,6 +216,8 @@
833 var task = _mocks.DynamicMock<UpdaterTask>("", "wewe", new string[0], "code", new string[0]);
834 using (_mocks.Record())
835 {
836+ Expect.Call(_messageBox.ShowYesNo(UpdateResources.DownloadUpdatesQuestion, MessageBoxImage.Question))
837+ .Return(MessageBoxResult.Yes);
838 Expect.Call(_dotUpdaterWrapper.CheckForUpdates())
839 .Return(task)
840 .Repeat.Once();
841
842=== added file 'src/Canonical.UbuntuOne.Common.Tests/Update/UpdatingPresenterFixture.cs'
843--- src/Canonical.UbuntuOne.Common.Tests/Update/UpdatingPresenterFixture.cs 1970-01-01 00:00:00 +0000
844+++ src/Canonical.UbuntuOne.Common.Tests/Update/UpdatingPresenterFixture.cs 2010-08-05 19:26:41 +0000
845@@ -0,0 +1,107 @@
846+/**
847+ * Copyright 2010 Canonical Ltd.
848+ *
849+ * This file is part of UbuntuOne on Windows.
850+ *
851+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
852+ * it under the terms of the GNU Lesser General Public License version
853+ * as published by the Free Software Foundation.
854+ *
855+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
856+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
857+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
858+ * GNU Lesser General Public License for more details.
859+ *
860+ * You should have received a copy of the GNU Lesser General Public License
861+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
862+ *
863+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
864+ */
865+
866+using Canonical.UbuntuOne.Common.Update;
867+using NUnit.Framework;
868+using Rhino.Mocks;
869+
870+namespace Canonical.UbuntuOne.Common.Tests.Update
871+{
872+ [TestFixture]
873+ public class UpdatingPresenterFixture
874+ {
875+ #region Variables
876+
877+ private MockRepository _mocks;
878+ private IUpdatingView _view;
879+ private UpdatingPresenter _presenter;
880+
881+ #endregion
882+
883+ #region Setup & TearDown
884+
885+ [SetUp]
886+ public void Setup()
887+ {
888+ _mocks = new MockRepository();
889+ _view = _mocks.StrictMock<IUpdatingView>();
890+ _presenter = new UpdatingPresenter
891+ {
892+ View = _view
893+ };
894+ }
895+
896+ #endregion
897+
898+ #region Tests
899+
900+ [Test]
901+ public void UpdatingStartedShownTest()
902+ {
903+ using(_mocks.Record())
904+ {
905+ SetupResult.For(_view.IsShown)
906+ .Return(true);
907+ _view.UpdatingText = UpdateResources.UpdateStarted;
908+ _view.IsUpdating = true;
909+ }
910+ using(_mocks.Playback())
911+ {
912+ _presenter.UpdatingStarted();
913+ }
914+ }
915+
916+ [Test]
917+ public void UpdatingStartedNotShownTest()
918+ {
919+ using (_mocks.Record())
920+ {
921+ SetupResult.For(_view.IsShown)
922+ .Return(false);
923+ Expect.Call(() => _view.Show())
924+ .Repeat.Once();
925+
926+ _view.UpdatingText = UpdateResources.UpdateStarted;
927+ _view.IsUpdating = true;
928+ }
929+ using (_mocks.Playback())
930+ {
931+ _presenter.UpdatingStarted();
932+ }
933+ }
934+
935+ [Test]
936+ public void UpdatingFinishedTest()
937+ {
938+ using (_mocks.Record())
939+ {
940+ _view.UpdatingText = UpdateResources.UpdateFinished;
941+ _view.IsUpdating = false;
942+ }
943+ using (_mocks.Playback())
944+ {
945+ _presenter.UpdatingFinished();
946+ }
947+ }
948+
949+ #endregion
950+
951+ }
952+}
953
954=== modified file 'src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj'
955--- src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj 2010-07-30 09:33:20 +0000
956+++ src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj 2010-08-05 19:26:41 +0000
957@@ -57,6 +57,7 @@
958 <Compile Include="Container\SpringContainer.cs" />
959 <Compile Include="Container\UnsatisfiedDependencyException.cs" />
960 <Compile Include="IAuthentication.cs" />
961+ <Compile Include="IMessageBox.cs" />
962 <Compile Include="IProcessManager.cs" />
963 <Compile Include="IProcessManagerFactory.cs" />
964 <Compile Include="ProcessManagementException.cs" />
965@@ -83,10 +84,14 @@
966 <Compile Include="Properties\AssemblyInfo.cs" />
967 <Compile Include="Update\DotLogger.cs" />
968 <Compile Include="Update\DotUpdaterWrapper.cs" />
969+ <Compile Include="Update\DownloadingPresenter.cs" />
970 <Compile Include="Update\Enumerators.cs" />
971 <Compile Include="Update\IDotUpdaterWrapper.cs" />
972- <Compile Include="Update\IUpdateView.cs" />
973+ <Compile Include="Update\IDownloadingPresenter.cs" />
974+ <Compile Include="Update\IDownloadingView.cs" />
975 <Compile Include="Update\IUpdater.cs" />
976+ <Compile Include="Update\IUpdatingPresenter.cs" />
977+ <Compile Include="Update\IUpdatingView.cs" />
978 <Compile Include="Update\Updater.cs" />
979 <Compile Include="Update\UpdateResources.Designer.cs">
980 <AutoGen>True</AutoGen>
981@@ -94,6 +99,7 @@
982 <DependentUpon>UpdateResources.resx</DependentUpon>
983 </Compile>
984 <Compile Include="Update\SelfUpdateException.cs" />
985+ <Compile Include="Update\UpdatingPresenter.cs" />
986 <Compile Include="Validation\ArgumentValidation.cs" />
987 <Compile Include="Validation\EqualityValidationExtensions.cs" />
988 <Compile Include="Validation\MultiException.cs" />
989@@ -114,6 +120,9 @@
990 <SpecificVersion>False</SpecificVersion>
991 <HintPath>..\..\lib\log4net\log4net.dll</HintPath>
992 </Reference>
993+ <Reference Include="PresentationFramework">
994+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
995+ </Reference>
996 <Reference Include="Spring.Aop, Version=1.3.0.20214, Culture=neutral, PublicKeyToken=65e474d141e25e07, processorArchitecture=MSIL">
997 <SpecificVersion>False</SpecificVersion>
998 <HintPath>..\..\lib\Spring.Net\Spring.Aop.dll</HintPath>
999
1000=== added file 'src/Canonical.UbuntuOne.Common/IMessageBox.cs'
1001--- src/Canonical.UbuntuOne.Common/IMessageBox.cs 1970-01-01 00:00:00 +0000
1002+++ src/Canonical.UbuntuOne.Common/IMessageBox.cs 2010-08-05 19:26:41 +0000
1003@@ -0,0 +1,71 @@
1004+/**
1005+ * Copyright 2010 Canonical Ltd.
1006+ *
1007+ * This file is part of UbuntuOne on Windows.
1008+ *
1009+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
1010+ * it under the terms of the GNU Lesser General Public License version
1011+ * as published by the Free Software Foundation.
1012+ *
1013+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
1014+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1015+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1016+ * GNU Lesser General Public License for more details.
1017+ *
1018+ * You should have received a copy of the GNU Lesser General Public License
1019+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
1020+ *
1021+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1022+ */
1023+using System.Windows;
1024+
1025+namespace Canonical.UbuntuOne.Common
1026+{
1027+ /// <summary>
1028+ /// Interface to be implemented by a class that allows to show general useful informatio to the user.
1029+ /// </summary>
1030+ public interface IMessageBox
1031+ {
1032+ /// <summary>
1033+ /// Displays an error dialog with a given message.
1034+ /// </summary>
1035+ /// <param name="message">The message to be displayed.</param>
1036+ void ShowError(string message);
1037+
1038+ /// <summary>
1039+ /// Displays an error dialog with a given message.
1040+ /// </summary>
1041+ /// <param name="message">The message to be displayed.</param>
1042+ void ShowInformation(string message);
1043+
1044+ /// <summary>
1045+ /// Displays an error dialog with a given message.
1046+ /// </summary>
1047+ /// <param name="message">The message to be displayed.</param>
1048+ void ShowWarning(string message);
1049+
1050+ /// <summary>
1051+ /// Displays an OK / Cancel dialog and returns the user input.
1052+ /// </summary>
1053+ /// <param name="message">The message to be displayed.</param>
1054+ /// <param name="icon">The icon to be displayed.</param>
1055+ /// <returns>User selection.</returns>
1056+ MessageBoxResult ShowOkCancel(string message, MessageBoxImage icon);
1057+
1058+ /// <summary>
1059+ /// Displays a Yes/No dialog and returns the user input.
1060+ /// </summary>
1061+ /// <param name="message">The message to be displayed.</param>
1062+ /// <param name="icon">The icon to be displayed.</param>
1063+ /// <returns>User selection.</returns>
1064+ MessageBoxResult ShowYesNo(string message, MessageBoxImage icon);
1065+
1066+ /// <summary>
1067+ /// Displays an Yes / No / Cancel dialog and returns the user input.
1068+ /// </summary>
1069+ /// <param name="message">The message to be displayed.</param>
1070+ /// <param name="icon">The icon to be displayed.</param>
1071+ /// <returns>User selection.</returns>
1072+ MessageBoxResult ShowYesNoCancel(string message, MessageBoxImage icon);
1073+ }
1074+}
1075
1076=== added file 'src/Canonical.UbuntuOne.Common/Update/DownloadingPresenter.cs'
1077--- src/Canonical.UbuntuOne.Common/Update/DownloadingPresenter.cs 1970-01-01 00:00:00 +0000
1078+++ src/Canonical.UbuntuOne.Common/Update/DownloadingPresenter.cs 2010-08-05 19:26:41 +0000
1079@@ -0,0 +1,82 @@
1080+/**
1081+ * Copyright 2010 Canonical Ltd.
1082+ *
1083+ * This file is part of UbuntuOne on Windows.
1084+ *
1085+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
1086+ * it under the terms of the GNU Lesser General Public License version
1087+ * as published by the Free Software Foundation.
1088+ *
1089+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
1090+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1091+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1092+ * GNU Lesser General Public License for more details.
1093+ *
1094+ * You should have received a copy of the GNU Lesser General Public License
1095+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
1096+ *
1097+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1098+ */
1099+using System.Threading;
1100+using Microsoft.ApplicationBlocks.Updater;
1101+
1102+namespace Canonical.UbuntuOne.Common.Update
1103+{
1104+ /// <summary>
1105+ /// Presenter that manages Downloading views.
1106+ /// </summary>
1107+ public class DownloadingPresenter : IDownloadingPresenter
1108+ {
1109+ #region Variables
1110+
1111+ private IDownloadingView _view;
1112+ public const double MaximumValue = 100;
1113+ public const double MinimumValue = 0;
1114+
1115+ #endregion
1116+
1117+ public IDownloadingView View
1118+ {
1119+ get { return _view; }
1120+ set
1121+ {
1122+ if (value != null)
1123+ {
1124+ var progress = (_view != null) ? _view.Progress : 0;
1125+ _view = value;
1126+ _view.MaximumValue = MaximumValue;
1127+ _view.MinimumValue = MinimumValue;
1128+ _view.Progress = progress;
1129+ }
1130+ else
1131+ {
1132+ _view = null;
1133+ }
1134+ }
1135+ }
1136+
1137+ public void DownloadProgressHandler(object sender, DownloadTaskProgressEventArgs args)
1138+ {
1139+ if(!View.IsShown)
1140+ View.Show();
1141+ View.DownloadingMessage = UpdateResources.DownloadInProgress;
1142+ View.Progress = (args.BytesTransferred * MaximumValue) / args.BytesTotal;
1143+ }
1144+
1145+ public void DownloadErrorHandler(object sender, DownloadTaskErrorEventArgs args)
1146+ {
1147+ View.DownloadingMessage = UpdateResources.DownloadError;
1148+ View.Progress = MinimumValue;
1149+ View.CloseButtonIsEnabled = true;
1150+ }
1151+
1152+ public void DownloadUpdateCompleted(object sender, TaskEventArgs e)
1153+ {
1154+ View.DownloadingMessage = UpdateResources.DownloadCompleted;
1155+ View.Progress = MaximumValue;
1156+ // let the user know
1157+ Thread.Sleep(100);
1158+ View.Close();
1159+ }
1160+ }
1161+}
1162
1163=== added file 'src/Canonical.UbuntuOne.Common/Update/IDownloadingPresenter.cs'
1164--- src/Canonical.UbuntuOne.Common/Update/IDownloadingPresenter.cs 1970-01-01 00:00:00 +0000
1165+++ src/Canonical.UbuntuOne.Common/Update/IDownloadingPresenter.cs 2010-08-05 19:26:41 +0000
1166@@ -0,0 +1,63 @@
1167+/**
1168+ * Copyright 2010 Canonical Ltd.
1169+ *
1170+ * This file is part of UbuntuOne on Windows.
1171+ *
1172+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
1173+ * it under the terms of the GNU Lesser General Public License version
1174+ * as published by the Free Software Foundation.
1175+ *
1176+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
1177+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1178+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1179+ * GNU Lesser General Public License for more details.
1180+ *
1181+ * You should have received a copy of the GNU Lesser General Public License
1182+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
1183+ *
1184+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1185+ */
1186+using Microsoft.ApplicationBlocks.Updater;
1187+
1188+namespace Canonical.UbuntuOne.Common.Update
1189+{
1190+ /// <summary>
1191+ /// Interface that represents the view that will ask for a confirmation to the user
1192+ /// regarding the update procedure.
1193+ /// </summary>
1194+ public interface IDownloadingPresenter
1195+ {
1196+ /// <summary>
1197+ /// Gets and sets the view used by the presenter.
1198+ /// </summary>
1199+ IDownloadingView View { get; set; }
1200+
1201+ /// <summary>
1202+ /// Handler that will be used when there is an update in the progress of the download.
1203+ /// This handler can be used to allow the user know the progress of the download.
1204+ /// </summary>
1205+ /// <param name="sender">The object that sent the arguments.</param>
1206+ /// <param name="args">The event arguments that provide the information to be
1207+ /// shown to the user.</param>
1208+ void DownloadProgressHandler(object sender, DownloadTaskProgressEventArgs args);
1209+
1210+ /// <summary>
1211+ /// Handler that will be used when there was an error in the update. This will allow
1212+ /// the view to communicate the user that there was an error but should not try to do anything about
1213+ /// it since this object is just a view.
1214+ /// </summary>
1215+ /// <param name="sender">The object that sent the event.</param>
1216+ /// <param name="args">The event arguments that provide the information to be
1217+ /// shown to the user.</param>
1218+ void DownloadErrorHandler(object sender, DownloadTaskErrorEventArgs args);
1219+
1220+ /// <summary>
1221+ /// Handler that will be used when the download of the updates finished. This will allows th view
1222+ /// to let the user know that we finished and that the updating will be in progress.
1223+ /// </summary>
1224+ /// <param name="sender">The object that sent the event.</param>
1225+ /// <param name="e">The event arguments that provide the information to be
1226+ /// shown to the user.</param>
1227+ void DownloadUpdateCompleted(object sender, TaskEventArgs e);
1228+ }
1229+}
1230
1231=== added file 'src/Canonical.UbuntuOne.Common/Update/IDownloadingView.cs'
1232--- src/Canonical.UbuntuOne.Common/Update/IDownloadingView.cs 1970-01-01 00:00:00 +0000
1233+++ src/Canonical.UbuntuOne.Common/Update/IDownloadingView.cs 2010-08-05 19:26:41 +0000
1234@@ -0,0 +1,68 @@
1235+/**
1236+ * Copyright 2010 Canonical Ltd.
1237+ *
1238+ * This file is part of UbuntuOne on Windows.
1239+ *
1240+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
1241+ * it under the terms of the GNU Lesser General Public License version
1242+ * as published by the Free Software Foundation.
1243+ *
1244+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
1245+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1246+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1247+ * GNU Lesser General Public License for more details.
1248+ *
1249+ * You should have received a copy of the GNU Lesser General Public License
1250+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
1251+ *
1252+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1253+ */
1254+namespace Canonical.UbuntuOne.Common.Update
1255+{
1256+ /// <summary>
1257+ /// Interface to be implemented by those views that are used to display the download process.
1258+ /// </summary>
1259+ public interface IDownloadingView
1260+ {
1261+ /// <summary>
1262+ /// Gets and sets if the close button is enabled.
1263+ /// </summary>
1264+ bool CloseButtonIsEnabled { get; set; }
1265+
1266+ /// <summary>
1267+ /// Gets if the view is visible.
1268+ /// </summary>
1269+ bool IsShown { get; }
1270+
1271+ /// <summary>
1272+ /// Gets and sets the downloading message to be displayed.
1273+ /// </summary>
1274+ string DownloadingMessage { get; set; }
1275+
1276+ /// <summary>
1277+ /// Gets and sets the min value of the progress.
1278+ /// </summary>
1279+ double MinimumValue { get; set; }
1280+
1281+ /// <summary>
1282+ /// Get and sets the max value of the progress.
1283+ /// </summary>
1284+ double MaximumValue { get; set; }
1285+
1286+ /// <summary>
1287+ /// Gets and sets the current progress.
1288+ /// </summary>
1289+ double Progress { get; set; }
1290+
1291+ /// <summary>
1292+ /// Shows the view to the user.
1293+ /// </summary>
1294+ void Show();
1295+
1296+ /// <summary>
1297+ /// Closes the view.
1298+ /// </summary>
1299+ void Close();
1300+
1301+ }
1302+}
1303
1304=== removed file 'src/Canonical.UbuntuOne.Common/Update/IUpdateView.cs'
1305--- src/Canonical.UbuntuOne.Common/Update/IUpdateView.cs 2010-07-28 10:41:14 +0000
1306+++ src/Canonical.UbuntuOne.Common/Update/IUpdateView.cs 1970-01-01 00:00:00 +0000
1307@@ -1,78 +0,0 @@
1308-/**
1309- * Copyright 2010 Canonical Ltd.
1310- *
1311- * This file is part of UbuntuOne on Windows.
1312- *
1313- * UbuntuOne on Windows is free software: you can redistribute it and/or modify
1314- * it under the terms of the GNU Lesser General Public License version
1315- * as published by the Free Software Foundation.
1316- *
1317- * Ubuntu One on Windows is distributed in the hope that it will be useful,
1318- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1319- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1320- * GNU Lesser General Public License for more details.
1321- *
1322- * You should have received a copy of the GNU Lesser General Public License
1323- * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
1324- *
1325- * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1326- */
1327-using Microsoft.ApplicationBlocks.Updater;
1328-
1329-namespace Canonical.UbuntuOne.Common.Update
1330-{
1331- /// <summary>
1332- /// Interface that represents the view that will ask for a confirmation to the user
1333- /// regarding the update procedure.
1334- /// </summary>
1335- public interface IUpdateView
1336- {
1337- /// <summary>
1338- /// This method should prompt some kind of confirmation message to the user
1339- /// and return if he decided to update the application or not.
1340- /// </summary>
1341- /// <returns>The answer that the user provided.</returns>
1342- UpdateConfirmation AskForDownloadAndUpdateConfirmation();
1343-
1344- /// <summary>
1345- /// This method should prompt some kind of confirmation to the user to close and install the update
1346- /// of the application.
1347- /// </summary>
1348- /// <returns>The answer that the suer provided.</returns>
1349- UpdateConfirmation AskForCloseAnInstallConfirmation();
1350-
1351- /// <summary>
1352- /// This method wil be called when the update finished. The view should show the appropiate
1353- /// data to the user when this occurs.
1354- /// </summary>
1355- void Updatefinished();
1356-
1357- /// <summary>
1358- /// Handler that will be used when there is an update in the progress of the download.
1359- /// This handler can be used to allow the user know the progress of the download.
1360- /// </summary>
1361- /// <param name="sender">The object that sent the arguments.</param>
1362- /// <param name="args">The event arguments that provide the information to be
1363- /// shown to the user.</param>
1364- void DownloadProgressHandler(object sender, DownloadTaskProgressEventArgs args);
1365-
1366- /// <summary>
1367- /// Handler that will be used when there was an error in the update. This will allow
1368- /// the view to communicate the user that there was an error but should not try to do anything about
1369- /// it since this object is just a view.
1370- /// </summary>
1371- /// <param name="sender">The object that sent the event.</param>
1372- /// <param name="args">The event arguments that provide the information to be
1373- /// shown to the user.</param>
1374- void DownloadErrorHandler(object sender, DownloadTaskErrorEventArgs args);
1375-
1376- /// <summary>
1377- /// Handler that will be used when the download of the updates finished. This will allows th view
1378- /// to let the user know that we finished and that the updating will be in progress.
1379- /// </summary>
1380- /// <param name="sender">The object that sent the event.</param>
1381- /// <param name="e">The event arguments that provide the information to be
1382- /// shown to the user.</param>
1383- void DownloadUpdateCompleted(object sender, TaskEventArgs e);
1384- }
1385-}
1386
1387=== modified file 'src/Canonical.UbuntuOne.Common/Update/IUpdater.cs'
1388--- src/Canonical.UbuntuOne.Common/Update/IUpdater.cs 2010-07-14 13:50:36 +0000
1389+++ src/Canonical.UbuntuOne.Common/Update/IUpdater.cs 2010-08-05 19:26:41 +0000
1390@@ -37,7 +37,7 @@
1391 /// <summary>
1392 /// Gets and sets the view that will be used to ask for confirmation when an update exists.
1393 /// </summary>
1394- IUpdateView UpdateView { get; set; }
1395+ IDownloadingPresenter DownloadingPresenter { get; set; }
1396
1397 /// <summary>
1398 /// Returns if the are updates present for the application.
1399
1400=== added file 'src/Canonical.UbuntuOne.Common/Update/IUpdatingPresenter.cs'
1401--- src/Canonical.UbuntuOne.Common/Update/IUpdatingPresenter.cs 1970-01-01 00:00:00 +0000
1402+++ src/Canonical.UbuntuOne.Common/Update/IUpdatingPresenter.cs 2010-08-05 19:26:41 +0000
1403@@ -0,0 +1,39 @@
1404+/**
1405+ * Copyright 2010 Canonical Ltd.
1406+ *
1407+ * This file is part of UbuntuOne on Windows.
1408+ *
1409+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
1410+ * it under the terms of the GNU Lesser General Public License version
1411+ * as published by the Free Software Foundation.
1412+ *
1413+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
1414+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1415+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1416+ * GNU Lesser General Public License for more details.
1417+ *
1418+ * You should have received a copy of the GNU Lesser General Public License
1419+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
1420+ *
1421+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1422+ */
1423+namespace Canonical.UbuntuOne.Common.Update
1424+{
1425+ public interface IUpdatingPresenter
1426+ {
1427+ /// <summary>
1428+ /// Gets and sets the view used by the presenter.
1429+ /// </summary>
1430+ IUpdatingView View { get; set; }
1431+
1432+ /// <summary>
1433+ /// Method used to notify the user that the updating started.
1434+ /// </summary>
1435+ void UpdatingStarted();
1436+
1437+ /// <summary>
1438+ /// Method used to notify the user that the updating finished.
1439+ /// </summary>
1440+ void UpdatingFinished();
1441+ }
1442+}
1443
1444=== added file 'src/Canonical.UbuntuOne.Common/Update/IUpdatingView.cs'
1445--- src/Canonical.UbuntuOne.Common/Update/IUpdatingView.cs 1970-01-01 00:00:00 +0000
1446+++ src/Canonical.UbuntuOne.Common/Update/IUpdatingView.cs 2010-08-05 19:26:41 +0000
1447@@ -0,0 +1,50 @@
1448+/**
1449+ * Copyright 2010 Canonical Ltd.
1450+ *
1451+ * This file is part of UbuntuOne on Windows.
1452+ *
1453+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
1454+ * it under the terms of the GNU Lesser General Public License version
1455+ * as published by the Free Software Foundation.
1456+ *
1457+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
1458+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1459+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1460+ * GNU Lesser General Public License for more details.
1461+ *
1462+ * You should have received a copy of the GNU Lesser General Public License
1463+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
1464+ *
1465+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1466+ */
1467+
1468+namespace Canonical.UbuntuOne.Common.Update
1469+{
1470+ public interface IUpdatingView
1471+ {
1472+ /// <summary>
1473+ /// Gets and sets if the view is visible
1474+ /// </summary>
1475+ bool IsShown { get; }
1476+
1477+ /// <summary>
1478+ /// Gets and sets if the application is being updated.
1479+ /// </summary>
1480+ bool IsUpdating { get; set; }
1481+
1482+ /// <summary>
1483+ /// Gets and sets the text tht tell the user the app is being updated.
1484+ /// </summary>
1485+ string UpdatingText { get; set; }
1486+
1487+ /// <summary>
1488+ /// Displays the view to the user.
1489+ /// </summary>
1490+ void Show();
1491+
1492+ /// <summary>
1493+ /// Closes the view.
1494+ /// </summary>
1495+ void Close();
1496+ }
1497+}
1498
1499=== modified file 'src/Canonical.UbuntuOne.Common/Update/UpdateResources.Designer.cs'
1500--- src/Canonical.UbuntuOne.Common/Update/UpdateResources.Designer.cs 2010-07-21 10:07:22 +0000
1501+++ src/Canonical.UbuntuOne.Common/Update/UpdateResources.Designer.cs 2010-08-05 19:26:41 +0000
1502@@ -97,6 +97,24 @@
1503 }
1504
1505 /// <summary>
1506+ /// Looks up a localized string similar to Downloading....
1507+ /// </summary>
1508+ internal static string DownloadInProgress {
1509+ get {
1510+ return ResourceManager.GetString("DownloadInProgress", resourceCulture);
1511+ }
1512+ }
1513+
1514+ /// <summary>
1515+ /// Looks up a localized string similar to There are updates avialable. Do you want to download them?.
1516+ /// </summary>
1517+ internal static string DownloadUpdatesQuestion {
1518+ get {
1519+ return ResourceManager.GetString("DownloadUpdatesQuestion", resourceCulture);
1520+ }
1521+ }
1522+
1523+ /// <summary>
1524 /// Looks up a localized string similar to Updater RSS feed is null or empty..
1525 /// </summary>
1526 internal static string NoRSSFeedPresent {
1527@@ -113,5 +131,50 @@
1528 return ResourceManager.GetString("NoUpdatesAvailable", resourceCulture);
1529 }
1530 }
1531+
1532+ /// <summary>
1533+ /// Looks up a localized string similar to The updates have been correctly downloaded. Do you want to update Ubuntu One?.
1534+ /// </summary>
1535+ internal static string PerformUpdateQuestion {
1536+ get {
1537+ return ResourceManager.GetString("PerformUpdateQuestion", resourceCulture);
1538+ }
1539+ }
1540+
1541+ /// <summary>
1542+ /// Looks up a localized string similar to The update process has finished..
1543+ /// </summary>
1544+ internal static string UpdateFinished {
1545+ get {
1546+ return ResourceManager.GetString("UpdateFinished", resourceCulture);
1547+ }
1548+ }
1549+
1550+ /// <summary>
1551+ /// Looks up a localized string similar to The update process could not be completed..
1552+ /// </summary>
1553+ internal static string UpdatesError {
1554+ get {
1555+ return ResourceManager.GetString("UpdatesError", resourceCulture);
1556+ }
1557+ }
1558+
1559+ /// <summary>
1560+ /// Looks up a localized string similar to The application was correctly updated..
1561+ /// </summary>
1562+ internal static string UpdatesSucceded {
1563+ get {
1564+ return ResourceManager.GetString("UpdatesSucceded", resourceCulture);
1565+ }
1566+ }
1567+
1568+ /// <summary>
1569+ /// Looks up a localized string similar to The update process has started..
1570+ /// </summary>
1571+ internal static string UpdateStarted {
1572+ get {
1573+ return ResourceManager.GetString("UpdateStarted", resourceCulture);
1574+ }
1575+ }
1576 }
1577 }
1578
1579=== modified file 'src/Canonical.UbuntuOne.Common/Update/UpdateResources.resx'
1580--- src/Canonical.UbuntuOne.Common/Update/UpdateResources.resx 2010-07-21 10:07:22 +0000
1581+++ src/Canonical.UbuntuOne.Common/Update/UpdateResources.resx 2010-08-05 19:26:41 +0000
1582@@ -129,10 +129,31 @@
1583 <data name="DownloadError" xml:space="preserve">
1584 <value>The download could not me completed.</value>
1585 </data>
1586+ <data name="DownloadUpdatesQuestion" xml:space="preserve">
1587+ <value>There are updates avialable. Do you want to download them?</value>
1588+ </data>
1589 <data name="NoRSSFeedPresent" xml:space="preserve">
1590 <value>Updater RSS feed is null or empty.</value>
1591 </data>
1592 <data name="NoUpdatesAvailable" xml:space="preserve">
1593 <value>There are no updates available.</value>
1594 </data>
1595+ <data name="PerformUpdateQuestion" xml:space="preserve">
1596+ <value>The updates have been correctly downloaded. Do you want to update Ubuntu One?</value>
1597+ </data>
1598+ <data name="UpdateFinished" xml:space="preserve">
1599+ <value>The update process has finished.</value>
1600+ </data>
1601+ <data name="UpdatesError" xml:space="preserve">
1602+ <value>The update process could not be completed.</value>
1603+ </data>
1604+ <data name="UpdatesSucceded" xml:space="preserve">
1605+ <value>The application was correctly updated.</value>
1606+ </data>
1607+ <data name="UpdateStarted" xml:space="preserve">
1608+ <value>The update process has started.</value>
1609+ </data>
1610+ <data name="DownloadInProgress" xml:space="preserve">
1611+ <value>Downloading...</value>
1612+ </data>
1613 </root>
1614\ No newline at end of file
1615
1616=== modified file 'src/Canonical.UbuntuOne.Common/Update/Updater.cs'
1617--- src/Canonical.UbuntuOne.Common/Update/Updater.cs 2010-07-28 14:35:45 +0000
1618+++ src/Canonical.UbuntuOne.Common/Update/Updater.cs 2010-08-05 19:26:41 +0000
1619@@ -18,6 +18,7 @@
1620 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1621 */
1622 using System;
1623+using System.Windows;
1624 using System.Windows.Threading;
1625 using DotUpdater;
1626 using log4net;
1627@@ -45,7 +46,7 @@
1628
1629 #endregion
1630
1631- #region Delegats
1632+ #region Delegates
1633
1634 delegate void UpdaterDelegate(UpdaterTask task);
1635
1636@@ -54,8 +55,9 @@
1637 #region DI properties
1638
1639 public string RSSFeed { get; set; }
1640-
1641- public IUpdateView UpdateView { get; set; }
1642+ public IMessageBox MessageBox { get; set; }
1643+ public IDownloadingPresenter DownloadingPresenter { get; set; }
1644+ public IUpdatingPresenter UpdatingPresenter { get; set; }
1645
1646 #endregion
1647
1648@@ -145,15 +147,26 @@
1649 /// <param name="task">The updater tasks that was being performed.</param>
1650 private void UpdateDownloadedMainThread(UpdaterTask task)
1651 {
1652- if (UpdateView.AskForCloseAnInstallConfirmation() != UpdateConfirmation.YES)
1653+ if (MessageBox.ShowOkCancel(UpdateResources.PerformUpdateQuestion, MessageBoxImage.Question) == MessageBoxResult.Cancel )
1654 return;
1655
1656- // perform the update
1657- DotUpdater.Install(_task);
1658- // clean the resoruces
1659- _task = null;
1660- _updateChecked = false;
1661- _downloadingUpdate = false;
1662+ try
1663+ {
1664+ UpdatingPresenter.UpdatingStarted();
1665+ // perform the update
1666+ DotUpdater.Install(_task);
1667+ // clean the resoruces
1668+ _task = null;
1669+ _updateChecked = false;
1670+ _downloadingUpdate = false;
1671+ UpdatingPresenter.UpdatingFinished();
1672+ MessageBox.ShowInformation(UpdateResources.UpdatesSucceded);
1673+ }
1674+ catch(UpdaterException)
1675+ {
1676+ MessageBox.ShowError(UpdateResources.UpdatesError);
1677+ }
1678+
1679 }
1680
1681 #endregion
1682@@ -185,7 +198,7 @@
1683 lock (_updateLock)
1684 {
1685 // ask the user if he wants to perform the update
1686- if (UpdateView.AskForDownloadAndUpdateConfirmation() == UpdateConfirmation.NO) return;
1687+ if (MessageBox.ShowYesNo(UpdateResources.DownloadUpdatesQuestion, MessageBoxImage.Question) == MessageBoxResult.No) return;
1688 if (!_updateChecked)
1689 {
1690 Logger.Error(UpdateResources.CheckNotDone);
1691@@ -205,14 +218,14 @@
1692 DotUpdater.BeginDownload(_task);
1693 // provide the handler for the progress of the download as well as the
1694 // error and finish
1695- DotUpdater.OnDownloadProgress += UpdateView.DownloadProgressHandler;
1696+ DotUpdater.OnDownloadProgress += DownloadingPresenter.DownloadProgressHandler;
1697 // we provide two handlers one for the view to let the user know we completed
1698 // the download and a second one for the updater that will do the actual work
1699- DotUpdater.OnDownloadCompleted += UpdateView.DownloadUpdateCompleted;
1700+ DotUpdater.OnDownloadCompleted += DownloadingPresenter.DownloadUpdateCompleted;
1701 DotUpdater.OnDownloadCompleted += DownloadUpdateCompleted;
1702 // register to handlers, one for the view that will show the error and an other
1703 // one for the updater that will handle the error.
1704- DotUpdater.OnDownloadError += UpdateView.DownloadErrorHandler;
1705+ DotUpdater.OnDownloadError += DownloadingPresenter.DownloadErrorHandler;
1706 DotUpdater.OnDownloadError += DownloadErrorHandler;
1707 }
1708 catch (UpdaterException e)
1709
1710=== added file 'src/Canonical.UbuntuOne.Common/Update/UpdatingPresenter.cs'
1711--- src/Canonical.UbuntuOne.Common/Update/UpdatingPresenter.cs 1970-01-01 00:00:00 +0000
1712+++ src/Canonical.UbuntuOne.Common/Update/UpdatingPresenter.cs 2010-08-05 19:26:41 +0000
1713@@ -0,0 +1,41 @@
1714+/**
1715+ * Copyright 2010 Canonical Ltd.
1716+ *
1717+ * This file is part of UbuntuOne on Windows.
1718+ *
1719+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
1720+ * it under the terms of the GNU Lesser General Public License version
1721+ * as published by the Free Software Foundation.
1722+ *
1723+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
1724+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1725+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1726+ * GNU Lesser General Public License for more details.
1727+ *
1728+ * You should have received a copy of the GNU Lesser General Public License
1729+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
1730+ *
1731+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1732+ */
1733+
1734+namespace Canonical.UbuntuOne.Common.Update
1735+{
1736+ public class UpdatingPresenter : IUpdatingPresenter
1737+ {
1738+ public IUpdatingView View { get; set; }
1739+
1740+ public void UpdatingStarted()
1741+ {
1742+ if(!View.IsShown)
1743+ View.Show();
1744+ View.UpdatingText = UpdateResources.UpdateStarted;
1745+ View.IsUpdating = true;
1746+ }
1747+
1748+ public void UpdatingFinished()
1749+ {
1750+ View.UpdatingText = UpdateResources.UpdateFinished;
1751+ View.IsUpdating = false;
1752+ }
1753+ }
1754+}
1755
1756=== modified file 'src/UbuntuOneClient.Tests/ProgramFixture.cs'
1757--- src/UbuntuOneClient.Tests/ProgramFixture.cs 2010-07-28 14:35:45 +0000
1758+++ src/UbuntuOneClient.Tests/ProgramFixture.cs 2010-08-05 19:26:41 +0000
1759@@ -64,6 +64,7 @@
1760 // ensure that the updater thread joins the application, if not we will have an issue
1761 // with the tests since the thread will not be collected
1762 _program.StopUpdaterThread();
1763+ _mocks.BackToRecordAll();
1764 }
1765
1766 #endregion
1767@@ -94,6 +95,7 @@
1768 [Test]
1769 public void StartApplicationWithUpdates()
1770 {
1771+ Assert.Ignore("RhinoMocks does not support multithreaded tests and therefore this test will not be reliable");
1772 using (_mocks.Record())
1773 {
1774 _app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
1775
1776=== modified file 'src/Version.cs'
1777--- src/Version.cs 2010-07-30 09:33:20 +0000
1778+++ src/Version.cs 2010-08-05 19:26:41 +0000
1779@@ -10,6 +10,6 @@
1780 // </auto-generated>
1781 //------------------------------------------------------------------------------
1782
1783-[assembly: AssemblyVersionAttribute("1.0.0.0")]
1784-[assembly: AssemblyFileVersionAttribute("1.0.0.0")]
1785+[assembly: AssemblyVersionAttribute("1.0.404.5869")]
1786+[assembly: AssemblyFileVersionAttribute("1.0.404.5869")]
1787

Subscribers

People subscribed via source and target branches

to all changes: