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

Proposed by Manuel de la Peña
Status: Merged
Approved by: Manuel de la Peña
Approved revision: 108
Merged at revision: 101
Proposed branch: lp:~mandel/ubuntuone-windows-installer/move_sync_to_service
Merge into: lp:ubuntuone-windows-installer/beta
Prerequisite: lp:~mandel/ubuntuone-windows-installer/add_reg_installation_path
Diff against target: 2146 lines (+1189/-298)
31 files modified
install/UbuntuOne7.wxs (+29/-20)
install/UbuntuOneXP.wxs (+30/-21)
src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj (+6/-0)
src/Canonical.UbuntuOne.Client/Notification/NotificationIconPresenter.cs (+20/-88)
src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj (+7/-0)
src/Canonical.UbuntuOne.Common/Net/IServiceCaller.cs (+50/-0)
src/Canonical.UbuntuOne.Common/Net/ServiceCaller.cs (+105/-0)
src/Canonical.UbuntuOne.Common/OperationContracts/ISyncDaemon.cs (+11/-6)
src/Canonical.UbuntuOne.Common/Utils/ApplicationLocatorException.cs (+58/-0)
src/Canonical.UbuntuOne.Common/Utils/ConfigurationLocator.cs (+305/-0)
src/Canonical.UbuntuOne.Common/Utils/Constants.cs (+36/-0)
src/Canonical.UbuntuOne.Common/Utils/IApplicationLocator.cs (+44/-0)
src/Canonical.UbuntuOne.Common/Utils/UbuntuOneApplicationLocator.cs (+153/-0)
src/Canonical.UbuntuOne.Common/objects.xml (+7/-0)
src/Canonical.UbuntuOne.ProcessDispatcher/App.config (+1/-10)
src/Canonical.UbuntuOne.ProcessDispatcher/Canonical.UbuntuOne.ProcessDispatcher.csproj (+6/-8)
src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.behaviours.config (+1/-1)
src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.services.config (+10/-25)
src/Canonical.UbuntuOne.ProcessDispatcher/Program.cs (+54/-20)
src/Canonical.UbuntuOne.ProcessDispatcher/ProjectInstaller.cs (+0/-49)
src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonService.cs (+92/-5)
src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonWindowsService.cs (+7/-21)
src/Canonical.UbuntuOne.ProcessDispatcher/objects.xml (+14/-6)
src/ServiceTestApp/Program.cs (+0/-3)
src/UbuntuOne.sln (+0/-12)
src/UbuntuOneClient/App.config (+5/-0)
src/UbuntuOneClient/Config/serviceModel.bindings.config (+23/-0)
src/UbuntuOneClient/Config/serviceModel.client.config (+38/-0)
src/UbuntuOneClient/Program.cs (+34/-3)
src/UbuntuOneClient/UbuntuOneClient.csproj (+9/-0)
src/UbuntuOneClient/objects.xml (+34/-0)
To merge this branch: bzr merge lp:~mandel/ubuntuone-windows-installer/move_sync_to_service
Reviewer Review Type Date Requested Status
Rick McBride (community) Approve
Review via email: mp+37957@code.launchpad.net

Description of the change

In this version, the WCF services are hosted in the user space. This is donw by created WCf services hosted in a console application. In order to be able to load the correct configuration, two appdomains are used, one to start the app, the second one to do the WCF hosting. This second appdomain has the users configuration which is build the first time the application is ran.

To post a comment you must log in.
Revision history for this message
Rick McBride (rmcbride) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'install/UbuntuOne7.wxs'
2--- install/UbuntuOne7.wxs 2010-10-08 12:04:40 +0000
3+++ install/UbuntuOne7.wxs 2010-10-08 12:04:40 +0000
4@@ -95,6 +95,16 @@
5 Name="UbuntuOne">
6 <Directory Id="DaemonDir"
7 Name="Daemon">
8+ <Component Id="DaemonAutostart"
9+ Guid="c3308920-d2d1-11df-bd3b-0800200c9a66">
10+ <RegistryValue Id="Daemon.rst"
11+ Root="HKCU"
12+ Key="Software\Microsoft\Windows\CurrentVersion\Run"
13+ Name="Ubuntu One Client Daemon"
14+ Value="[DaemonDir]Canonical.UbuntuOne.ProcessDispatcher.exe"
15+ Type="string"/>
16+ <Condition>UBUNTUONeDAEMON_START_VIA_REGISTRY</Condition>
17+ </Component>
18 <Component Id="DaemonCommonLibComponent"
19 Guid="a609b650-94b5-11df-981c-0800200c9a66">
20 <File Id="Canonical.UbuntuOne.Common.dll"
21@@ -118,22 +128,6 @@
22 DiskId="1"
23 Source="build_results\Daemon\Canonical.UbuntuOne.ProcessDispatcher.exe"
24 KeyPath="yes"/>
25- <!-- Install, start and stop service using the msi -->
26- <ServiceInstall Id="ProcessDispatcher.exe"
27- Name="UbuntuOne"
28- DisplayName="Ubuntu One Sync Daemon"
29- Type="ownProcess"
30- Interactive="no"
31- Start="auto"
32- Vital="yes"
33- ErrorControl="ignore"
34- Description="Provides a central process that manages the Ubuntu One sync daemon." />
35- <ServiceControl Id="ProcessDispatcherControl"
36- Name="UbuntuOne"
37- Start="install"
38- Stop="uninstall"
39- Remove="uninstall"
40- Wait="yes" />
41 </Component>
42 <Component Id="DaemonProgramComponentConfig"
43 Guid="6ac2f100-94bb-11df-981c-0800200c9a66">
44@@ -474,6 +468,22 @@
45 Source="build_results\Client\Config\log4net.config"
46 KeyPath="yes"/>
47 </Component>
48+ <Component Id="ClientConfigServiceModelBindings"
49+ Guid="a76325d0-d200-11df-bd3b-0800200c9a66">
50+ <File Id="serviceModelBindings_client"
51+ Name="serviceModel.bindings.config"
52+ DiskId="1"
53+ Source="build_results\Client\Config\serviceModel.bindings.config"
54+ KeyPath="yes"/>
55+ </Component>
56+ <Component Id="ClientConfigServiceModelClient"
57+ Guid="b2b8c250-d200-11df-bd3b-0800200c9a66">
58+ <File Id="serviceModelClient_client"
59+ Name="serviceModel.client.config"
60+ DiskId="1"
61+ Source="build_results\Client\Config\serviceModel.client.config"
62+ KeyPath="yes"/>
63+ </Component>
64 </Directory>
65 <Directory Id="U1SyncExecutable"
66 Name="U1Sync">
67@@ -987,7 +997,10 @@
68 <ComponentRef Id="UbuntuOneClientConfig" />
69 <ComponentRef Id="UbuntuOneClientPdb" />
70 <ComponentRef Id="ClientConfigLog4Net" />
71+ <ComponentRef Id="ClientConfigServiceModelBindings" />
72+ <ComponentRef Id="ClientConfigServiceModelClient" />
73 <!-- Client auto start -->
74+ <ComponentRef Id="DaemonAutostart" />
75 <ComponentRef Id="UbuntuOneClietnAutostart" />
76 <!-- U1Sync pacakge -->
77 <ComponentRef Id="CTypesComponent" />
78@@ -1050,10 +1063,6 @@
79 <ComponentRef Id="UbuntuSSOViews" />
80 <ComponentRef Id="Newtonsoft.Json" />
81 </Feature>
82-
83- <InstallExecuteSequence>
84- <ScheduleReboot After='InstallFinalize' />
85- </InstallExecuteSequence>
86
87 <UI Id="WixUI_Minimal_No_License">
88 <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
89
90=== modified file 'install/UbuntuOneXP.wxs'
91--- install/UbuntuOneXP.wxs 2010-10-08 12:04:40 +0000
92+++ install/UbuntuOneXP.wxs 2010-10-08 12:04:40 +0000
93@@ -95,6 +95,16 @@
94 Name="UbuntuOne">
95 <Directory Id="DaemonDir"
96 Name="Daemon">
97+ <Component Id="DaemonAutostart"
98+ Guid="c3308920-d2d1-11df-bd3b-0800200c9a66">
99+ <RegistryValue Id="Daemon.rst"
100+ Root="HKCU"
101+ Key="Software\Microsoft\Windows\CurrentVersion\Run"
102+ Name="Ubuntu One Client Daemon"
103+ Value="[DaemonDir]Canonical.UbuntuOne.ProcessDispatcher.exe"
104+ Type="string"/>
105+ <Condition>UBUNTUONeDAEMON_START_VIA_REGISTRY</Condition>
106+ </Component>
107 <Component Id="DaemonCommonLibComponent"
108 Guid="a609b650-94b5-11df-981c-0800200c9a66">
109 <File Id="Canonical.UbuntuOne.Common.dll"
110@@ -118,22 +128,6 @@
111 DiskId="1"
112 Source="build_results\Daemon\Canonical.UbuntuOne.ProcessDispatcher.exe"
113 KeyPath="yes"/>
114- <!-- Install, start and stop service using the msi -->
115- <ServiceInstall Id="ProcessDispatcher.exe"
116- Name="UbuntuOne"
117- DisplayName="Ubuntu One Sync Daemon"
118- Type="ownProcess"
119- Interactive="no"
120- Start="auto"
121- Vital="yes"
122- ErrorControl="ignore"
123- Description="Provides a central process that manages the Ubuntu One sync daemon." />
124- <ServiceControl Id="ProcessDispatcherControl"
125- Name="UbuntuOne"
126- Start="install"
127- Stop="uninstall"
128- Remove="uninstall"
129- Wait="yes" />
130 </Component>
131 <Component Id="DaemonProgramComponentConfig"
132 Guid="6ac2f100-94bb-11df-981c-0800200c9a66">
133@@ -474,6 +468,22 @@
134 Source="build_results\Client\Config\log4net.config"
135 KeyPath="yes"/>
136 </Component>
137+ <Component Id="ClientConfigServiceModelBindings"
138+ Guid="a76325d0-d200-11df-bd3b-0800200c9a66">
139+ <File Id="serviceModelBindings_client"
140+ Name="serviceModel.bindings.config"
141+ DiskId="1"
142+ Source="build_results\Client\Config\serviceModel.bindings.config"
143+ KeyPath="yes"/>
144+ </Component>
145+ <Component Id="ClientConfigServiceModelClient"
146+ Guid="b2b8c250-d200-11df-bd3b-0800200c9a66">
147+ <File Id="serviceModelClient_client"
148+ Name="serviceModel.client.config"
149+ DiskId="1"
150+ Source="build_results\Client\Config\serviceModel.client.config"
151+ KeyPath="yes"/>
152+ </Component>
153 </Directory>
154 <Directory Id="U1SyncExecutable"
155 Name="U1Sync">
156@@ -784,7 +794,10 @@
157 <ComponentRef Id="UbuntuOneClientConfig" />
158 <ComponentRef Id="UbuntuOneClientPdb" />
159 <ComponentRef Id="ClientConfigLog4Net" />
160- <!-- Client auto start -->
161+ <ComponentRef Id="ClientConfigServiceModelBindings" />
162+ <ComponentRef Id="ClientConfigServiceModelClient" />
163+ <!-- auto start -->
164+ <ComponentRef Id="DaemonAutostart" />
165 <ComponentRef Id="UbuntuOneClietnAutostart" />
166 <!-- U1Sync pacakge -->
167 <ComponentRef Id="CTypesComponent" />
168@@ -823,10 +836,6 @@
169 <ComponentRef Id="Newtonsoft.Json" />
170 </Feature>
171
172- <InstallExecuteSequence>
173- <ScheduleReboot After='InstallFinalize' />
174- </InstallExecuteSequence>
175-
176 <UI Id="WixUI_Minimal_No_License">
177 <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
178 <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
179
180=== modified file 'src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj'
181--- src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj 2010-10-06 10:43:02 +0000
182+++ src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj 2010-10-08 12:04:40 +0000
183@@ -102,7 +102,13 @@
184 <RequiredTargetFramework>3.0</RequiredTargetFramework>
185 </Reference>
186 <Reference Include="System" />
187+ <Reference Include="System.Core">
188+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
189+ </Reference>
190 <Reference Include="System.Data" />
191+ <Reference Include="System.ServiceModel">
192+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
193+ </Reference>
194 <Reference Include="System.Web" />
195 <Reference Include="System.Xml" />
196 <Reference Include="WindowsBase">
197
198=== modified file 'src/Canonical.UbuntuOne.Client/Notification/NotificationIconPresenter.cs'
199--- src/Canonical.UbuntuOne.Client/Notification/NotificationIconPresenter.cs 2010-10-08 12:04:40 +0000
200+++ src/Canonical.UbuntuOne.Client/Notification/NotificationIconPresenter.cs 2010-10-08 12:04:40 +0000
201@@ -17,15 +17,15 @@
202 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
203 */
204 using System;
205-using System.Diagnostics;
206 using System.IO;
207+using System.ServiceModel;
208 using Canonical.Ubuntu.SSO;
209 using Canonical.UbuntuOne.Client.Preferences;
210 using Canonical.UbuntuOne.Common;
211 using Canonical.UbuntuOne.Common.Aop;
212+using Canonical.UbuntuOne.Common.Net;
213 using Canonical.UbuntuOne.Common.Utils;
214 using log4net;
215-using Microsoft.Win32;
216
217 namespace Canonical.UbuntuOne.Client.Notification
218 {
219@@ -53,8 +53,6 @@
220 private ISSOCredentialsProvider _ssoProvider;
221 private ILog _logger;
222 private readonly object _loggerLock = new object();
223- private string _u1SyncPath;
224- private readonly object _u1SyncPathLock = new object();
225
226 #endregion
227
228@@ -95,6 +93,7 @@
229 /// Gets and sets the message box used to send messages to the user.
230 /// </summary>
231 public IMessageBox MessageBox { get; set; }
232+
233 /// <summary>
234 /// Gets and sets the provider that will return the credentials used in ubuntu one.
235 /// </summary>
236@@ -130,6 +129,17 @@
237 }
238 }
239
240+ /// <summary>
241+ /// Gets and sets the channel factory that can be used to create communication objects that are used to
242+ /// interact with the sync daemon.
243+ /// </summary>
244+ public ChannelFactory<ISyncDaemon> SyncDaemonChannelFactory { get; set; }
245+
246+ /// <summary>
247+ /// Gets and sets the service caller that is used to do the house keeping when calling a service.
248+ /// </summary>
249+ public IServiceCaller ServiceCaller { get; set; }
250+
251 #endregion
252
253 #region Properties
254@@ -153,36 +163,6 @@
255 set { _logger = value; }
256 }
257
258- private string U1SyncPath
259- {
260- get
261- {
262- if (_u1SyncPath == null)
263- {
264- lock (_u1SyncPathLock)
265- {
266- try
267- {
268- using (var softwareEntry = Registry.LocalMachine.OpenSubKey("SOFTWARE"))
269- using (var canonicalEntry = softwareEntry.OpenSubKey("Canonical"))
270- using (var ubuntuOneEntry = canonicalEntry.OpenSubKey("UbuntuOne"))
271- {
272- _u1SyncPath = (string) ubuntuOneEntry.GetValue("InstallationPath");
273- _u1SyncPath = Path.Combine(_u1SyncPath, "Client");
274- _u1SyncPath = Path.Combine(_u1SyncPath, "U1Sync");
275- }
276- }
277- catch(NullReferenceException)
278- {
279- // thrown when we did not find the key, that is, not correct installation
280- Logger.Error("Registry key HKLM/Software/Canonical/UbuntuOne is not present!!!");
281- }
282- }
283- }
284- return _u1SyncPath;
285- }
286- }
287-
288 #endregion
289
290 #region Constructors
291@@ -256,64 +236,16 @@
292 // check if the credentials are for us
293 if (args.ApplicationName != "UbuntuOne") return;
294 Logger.Info("Got the UbuntuOne credentials!");
295- // get the string used to pass the credentials to the python code.
296- var tokens = string.Format("{0}:{1}:{2}:{3}",
297- args.Credentials["Token"],
298- args.Credentials["TokenSecret"],
299- args.Credentials["ConsumerKey"],
300- args.Credentials["ConsumerSecret"]);
301 var oneDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
302 "UbuntuOne");
303 // ensure that the path can be handled by the python code
304 oneDir = oneDir.Replace("\\", "\\\\");
305- if (!Directory.Exists(oneDir))
306- {
307- Logger.InfoFormat("Creating dir '{0}'", oneDir);
308- Directory.CreateDirectory(oneDir);
309- }
310-
311- if (!Directory.Exists(Path.Combine(oneDir, ".ubuntuone-sync")))
312- {
313- // init the directory
314- var init = new Process
315- {
316- StartInfo =
317- {
318- WorkingDirectory = U1SyncPath,
319- FileName = Path.Combine(U1SyncPath, "main.exe"),
320- Arguments = String.Format(" --init \"{0}\" --oauth {1}", oneDir, tokens),
321- UseShellExecute = false,
322- RedirectStandardOutput = true,
323- RedirectStandardError = true,
324- CreateNoWindow = true,
325- WindowStyle = ProcessWindowStyle.Hidden
326-
327- }
328- };
329- Logger.InfoFormat("Executing u1sync with args: {0}", init.StartInfo.Arguments);
330- init.Start();
331- init.WaitForExit();
332- Logger.InfoFormat("StandarOutput from u1sync is: {0}", init.StandardOutput.ReadToEnd());
333- Logger.ErrorFormat("StandardError from u1sync is: {0}", init.StandardError.ReadToEnd());
334- init.Close();
335-
336- }
337-
338- var proc = new Process
339- {
340- StartInfo =
341- {
342- WorkingDirectory = U1SyncPath,
343- FileName = Path.Combine(U1SyncPath, "main.exe"),
344- Arguments = String.Format("\"{0}\" --oauth {1}", oneDir, tokens),
345- UseShellExecute = false,
346- RedirectStandardOutput = true,
347- RedirectStandardError = true,
348- CreateNoWindow = true,
349- WindowStyle = ProcessWindowStyle.Hidden
350- }
351- };
352- proc.Start();
353+ // call the ISyncService to perform the manual sync
354+
355+ var syncServiceChannel = SyncDaemonChannelFactory.CreateChannel();
356+ ServiceCaller.SaveProxyCall(
357+ () => syncServiceChannel.ManualSync(oneDir, args.Credentials["Token"], args.Credentials["TokenSecret"],args.Credentials["ConsumerKey"], args.Credentials["ConsumerSecret"]),
358+ (ICommunicationObject) syncServiceChannel);
359 }
360
361 [DebugLogged]
362
363=== modified file 'src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj'
364--- src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj 2010-10-08 12:04:40 +0000
365+++ src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj 2010-10-08 12:04:40 +0000
366@@ -79,14 +79,20 @@
367 <Compile Include="Net\HttpWebRequestFactory.cs" />
368 <Compile Include="Net\IHttpWebRequestFactory.cs" />
369 <Compile Include="Net\IHttpWebRequest.cs" />
370+ <Compile Include="Net\IServiceCaller.cs" />
371+ <Compile Include="Net\ServiceCaller.cs" />
372 <Compile Include="OperationContracts\IEventNotifier.cs" />
373 <Compile Include="Security\IAuthentication.cs" />
374 <Compile Include="Threading\IDispatcher.cs" />
375 <Compile Include="Threading\WpfDispatcher.cs" />
376+ <Compile Include="Utils\ApplicationLocatorException.cs" />
377 <Compile Include="Utils\ApplicationWrapper.cs" />
378+ <Compile Include="Utils\ConfigurationLocator.cs" />
379+ <Compile Include="Utils\Constants.cs" />
380 <Compile Include="Utils\Explorer.cs" />
381 <Compile Include="Utils\ExplorerException.cs" />
382 <Compile Include="Utils\IApplication.cs" />
383+ <Compile Include="Utils\IApplicationLocator.cs" />
384 <Compile Include="Utils\IExplorer.cs" />
385 <Compile Include="IMessageBox.cs" />
386 <Compile Include="IProcessManager.cs" />
387@@ -132,6 +138,7 @@
388 </Compile>
389 <Compile Include="Update\SelfUpdateException.cs" />
390 <Compile Include="Update\UpdatingPresenter.cs" />
391+ <Compile Include="Utils\UbuntuOneApplicationLocator.cs" />
392 <Compile Include="Validation\ArgumentValidation.cs" />
393 <Compile Include="Validation\EqualityValidationExtensions.cs" />
394 <Compile Include="Validation\MultiException.cs" />
395
396=== added file 'src/Canonical.UbuntuOne.Common/Net/IServiceCaller.cs'
397--- src/Canonical.UbuntuOne.Common/Net/IServiceCaller.cs 1970-01-01 00:00:00 +0000
398+++ src/Canonical.UbuntuOne.Common/Net/IServiceCaller.cs 2010-10-08 12:04:40 +0000
399@@ -0,0 +1,50 @@
400+/*
401+ * Copyright 2010 Canonical Ltd.
402+ *
403+ * This file is part of UbuntuOne on Windows.
404+ *
405+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
406+ * it under the terms of the GNU Lesser General Public License version
407+ * as published by the Free Software Foundation.
408+ *
409+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
410+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
411+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
412+ * GNU Lesser General Public License for more details.
413+ *
414+ * You should have received a copy of the GNU Lesser General Public License
415+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
416+ *
417+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
418+ */
419+using System;
420+using System.ServiceModel;
421+
422+namespace Canonical.UbuntuOne.Common.Net
423+{
424+ /// <summary>
425+ /// Interface to be implemented by those objects that allow to call WCF service and that will
426+ /// perform all the house keeping required.
427+ /// </summary>
428+ public interface IServiceCaller
429+ {
430+ /// <summary>
431+ /// A method that allows to correctly clean a channel when executing a call to
432+ /// a web service. This method takes an action that should be using the channel
433+ /// and the casted channel so that we can access the ICommunicationObject methods.
434+ /// </summary>
435+ /// <param name="action">The action to be performed that uses the channel.</param>
436+ /// <param name="channel">The casted channel that will be used to clean its state.</param>
437+ void SaveProxyCall(Action action, ICommunicationObject channel);
438+
439+ /// <summary>
440+ /// A method that allows to correctly clean a channel when executing a call to
441+ /// a web service. This method takes an action that should be using the channel
442+ /// and the casted channel so that we can access the ICommunicationObject methods.
443+ /// </summary>
444+ /// <param name="action">An action that has a wcf proxy call.</param>
445+ /// <param name="channel">The casted channel that will be used to clean its state.</param>
446+ /// <returns>The result of the action</returns>
447+ TResult SaveProxyCall<TResult>(Func<TResult> action, ICommunicationObject channel);
448+ }
449+}
450
451=== added file 'src/Canonical.UbuntuOne.Common/Net/ServiceCaller.cs'
452--- src/Canonical.UbuntuOne.Common/Net/ServiceCaller.cs 1970-01-01 00:00:00 +0000
453+++ src/Canonical.UbuntuOne.Common/Net/ServiceCaller.cs 2010-10-08 12:04:40 +0000
454@@ -0,0 +1,105 @@
455+/*
456+ * Copyright 2010 Canonical Ltd.
457+ *
458+ * This file is part of UbuntuOne on Windows.
459+ *
460+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
461+ * it under the terms of the GNU Lesser General Public License version
462+ * as published by the Free Software Foundation.
463+ *
464+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
465+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
466+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
467+ * GNU Lesser General Public License for more details.
468+ *
469+ * You should have received a copy of the GNU Lesser General Public License
470+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
471+ *
472+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
473+ */
474+using System;
475+using System.ServiceModel;
476+
477+namespace Canonical.UbuntuOne.Common.Net
478+{
479+ /// <summary>
480+ /// Implementation of the IServiceCaller interface that performs the required house keeping used when
481+ /// calling a WCF service.
482+ /// </summary>
483+ internal class ServiceCaller : IServiceCaller
484+ {
485+ #region Implementation of IServiceCaller
486+
487+ /// <summary>
488+ /// A method that allows to correctly clean a channel when executing a call to
489+ /// a web service. This method takes an action that should be using the channel
490+ /// and the casted channel so that we can access the ICommunicationObject methods.
491+ /// </summary>
492+ /// <param name="action">The action to be performed that uses the channel.</param>
493+ /// <param name="channel">The casted channel that will be used to clean its state.</param>
494+ public void SaveProxyCall(Action action, ICommunicationObject channel)
495+ {
496+ try
497+ {
498+ action();
499+ channel.Close();
500+ }
501+ catch (FaultException)
502+ {
503+ channel.Close();
504+ }
505+ catch (CommunicationException)
506+ {
507+ channel.Abort();
508+ }
509+ catch (TimeoutException)
510+ {
511+ channel.Abort();
512+ }
513+ catch (Exception)
514+ {
515+ channel.Abort();
516+ throw;
517+ }
518+ }
519+
520+ /// <summary>
521+ /// A method that allows to correctly clean a channel when executing a call to
522+ /// a web service. This method takes an action that should be using the channel
523+ /// and the casted channel so that we can access the ICommunicationObject methods.
524+ /// </summary>
525+ /// <param name="action">An action that has a wcf proxy call.</param>
526+ /// <param name="channel">The casted channel that will be used to clean its state.</param>
527+ /// <returns>The result of the action</returns>
528+ public TResult SaveProxyCall<TResult>(Func<TResult> action, ICommunicationObject channel)
529+ {
530+ try
531+ {
532+ var result = action();
533+ channel.Close();
534+ return result;
535+ }
536+ catch (FaultException)
537+ {
538+ channel.Close();
539+ }
540+ catch (CommunicationException)
541+ {
542+ channel.Abort();
543+ }
544+ catch (TimeoutException)
545+ {
546+ channel.Abort();
547+ }
548+ catch (Exception)
549+ {
550+ channel.Abort();
551+ throw;
552+ }
553+
554+ return default(TResult);
555+ }
556+
557+ #endregion
558+ }
559+}
560
561=== modified file 'src/Canonical.UbuntuOne.Common/OperationContracts/ISyncDaemon.cs'
562--- src/Canonical.UbuntuOne.Common/OperationContracts/ISyncDaemon.cs 2010-08-30 17:30:31 +0000
563+++ src/Canonical.UbuntuOne.Common/OperationContracts/ISyncDaemon.cs 2010-10-08 12:04:40 +0000
564@@ -29,6 +29,17 @@
565 [ServiceContract]
566 public interface ISyncDaemon
567 {
568+ /// <summary>
569+ /// Allows to perform a manual sync of the root Ubuntu One directory in the provided path using the oauth information
570+ /// passed to the service.
571+ /// </summary>
572+ /// <param name="path">The path to which the root of the Ubuntu One folder will be sync.</param>
573+ /// <param name="token">The token from oauth.</param>
574+ /// <param name="tokenSecret">The token secret from oauth.</param>
575+ /// <param name="consumerKey">The consumer key from oauth.</param>
576+ /// <param name="consumerSecret">The consumer secret from oauth.</param>
577+ [OperationContract]
578+ void ManualSync(string path, string token, string tokenSecret, string consumerKey, string consumerSecret);
579
580 /// <summary>
581 /// Allows to start the daemon by a client.
582@@ -57,12 +68,6 @@
583 bool TryStop();
584
585 /// <summary>
586- /// Allows the user to perform a manual sync of his machine with the ubuntu one server.
587- /// </summary>
588- [OperationContract]
589- void ManualSync();
590-
591- /// <summary>
592 /// Returns the port number of the socket that the synd daemo is listening to for communication.
593 /// </summary>
594 /// <returns></returns>
595
596=== added file 'src/Canonical.UbuntuOne.Common/Utils/ApplicationLocatorException.cs'
597--- src/Canonical.UbuntuOne.Common/Utils/ApplicationLocatorException.cs 1970-01-01 00:00:00 +0000
598+++ src/Canonical.UbuntuOne.Common/Utils/ApplicationLocatorException.cs 2010-10-08 12:04:40 +0000
599@@ -0,0 +1,58 @@
600+/*
601+ * Copyright 2010 Canonical Ltd.
602+ *
603+ * This file is part of UbuntuOne on Windows.
604+ *
605+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
606+ * it under the terms of the GNU Lesser General Public License version
607+ * as published by the Free Software Foundation.
608+ *
609+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
610+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
611+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
612+ * GNU Lesser General Public License for more details.
613+ *
614+ * You should have received a copy of the GNU Lesser General Public License
615+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
616+ *
617+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
618+ */
619+using System;
620+
621+namespace Canonical.UbuntuOne.Common.Utils
622+{
623+ /// <summary>
624+ /// Base exception class thrown when there have been issues finding an application in the system.
625+ /// </summary>
626+ public class ApplicationLocatorException : Exception
627+ {
628+ /// <summary>
629+ /// Creates a new instance of the class.
630+ /// </summary>
631+ public ApplicationLocatorException()
632+ {
633+
634+ }
635+
636+ /// <summary>
637+ /// Creates a new instance of the class that will have the given message.
638+ /// </summary>
639+ /// <param name="message">The message to be carried by the exception.</param>
640+ public ApplicationLocatorException(string message)
641+ : base(message)
642+ {
643+
644+ }
645+
646+ /// <summary>
647+ /// Creates a new instance of the class that will have the given message and inner exception.
648+ /// </summary>
649+ /// <param name="message">The message to be carried by the exception.</param>
650+ /// <param name="innerException">The inner exception.</param>
651+ public ApplicationLocatorException(string message, Exception innerException)
652+ : base(message, innerException)
653+ {
654+
655+ }
656+ }
657+}
658
659=== added file 'src/Canonical.UbuntuOne.Common/Utils/ConfigurationLocator.cs'
660--- src/Canonical.UbuntuOne.Common/Utils/ConfigurationLocator.cs 1970-01-01 00:00:00 +0000
661+++ src/Canonical.UbuntuOne.Common/Utils/ConfigurationLocator.cs 2010-10-08 12:04:40 +0000
662@@ -0,0 +1,305 @@
663+/*
664+ * Copyright 2010 Canonical Ltd.
665+ *
666+ * This file is part of UbuntuOne on Windows.
667+ *
668+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
669+ * it under the terms of the GNU Lesser General Public License version
670+ * as published by the Free Software Foundation.
671+ *
672+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
673+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
674+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
675+ * GNU Lesser General Public License for more details.
676+ *
677+ * You should have received a copy of the GNU Lesser General Public License
678+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
679+ *
680+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
681+ */
682+using System;
683+using System.IO;
684+using System.Security.Principal;
685+using Canonical.UbuntuOne.ProcessDispatcher;
686+using log4net;
687+
688+namespace Canonical.UbuntuOne.Common.Utils
689+{
690+ /// <summary>
691+ /// This class allow to find the configuration to be used in the application accodring to the user that started the
692+ /// process. This allows to point to different configurations that will ensure that there are no service collitions
693+ /// by usint the users name space.
694+ /// </summary>
695+ public class ConfigurationLocator
696+ {
697+ #region Variables
698+
699+ private const string UserToken = "$username$";
700+ private const string ConfigFolder = "Config";
701+ private const string DaemonAppConfigName = "Canonical.UbuntuOne.ProcessDispatcher.exe.config";
702+ private const string UserAppConfigName = "UbuntuOneClient.exe.config";
703+ private const string Log4NetConfig = "log4net.config";
704+ private const string BehavioursConfig = "serviceModel.behaviours.config";
705+ private const string BindingsConfig = "serviceModel.bindings.config";
706+ private const string ServicesConfig = "serviceModel.services.config";
707+ private const string ClientConfig = "serviceModel.client.config";
708+ private string _userConfigPath;
709+ private readonly object _userConfigPathLock = new object();
710+ private readonly object _loggerLock = new object();
711+ private ILog _logger;
712+
713+ #endregion
714+
715+ #region Properties
716+
717+ /// <summary>
718+ /// Allows to get and set the logger that will be used.
719+ /// </summary>
720+ internal ILog Logger
721+ {
722+ get
723+ {
724+ if (_logger == null)
725+ {
726+ lock (_loggerLock)
727+ {
728+ _logger = LogManager.GetLogger(typeof(ConfigurationLocator));
729+ }
730+ }
731+ return _logger;
732+ }
733+ set
734+ {
735+ _logger = value;
736+ }
737+ }
738+
739+ /// <summary>
740+ /// Gets the path to be used to store the users configuration.
741+ /// </summary>
742+ private string UserDaemonConfigPath
743+ {
744+ get
745+ {
746+ if (_userConfigPath == null)
747+ {
748+ lock (_userConfigPathLock)
749+ {
750+ _userConfigPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
751+ _userConfigPath = Path.Combine(_userConfigPath, "UbuntuOne");
752+ _userConfigPath = Path.Combine(_userConfigPath, "Daemon");
753+ }
754+ }
755+ return _userConfigPath;
756+ }
757+ }
758+
759+ private string UserClientConfigPath
760+ {
761+ get
762+ {
763+ if (_userConfigPath == null)
764+ {
765+ lock (_userConfigPathLock)
766+ {
767+ _userConfigPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
768+ _userConfigPath = Path.Combine(_userConfigPath, "UbuntuOne");
769+ _userConfigPath = Path.Combine(_userConfigPath, "Client");
770+ }
771+ }
772+ return _userConfigPath;
773+ }
774+ }
775+ /// <summary>
776+ /// Gets and sets the application locator that will be used to find the location of the
777+ /// root configuration.
778+ /// </summary>
779+ public IApplicationLocator ApplicationLocator { get; set; }
780+
781+ #endregion
782+
783+ #region Constructors
784+
785+ /// <summary>
786+ /// Creates a new configuration locator with the default app locator.
787+ /// </summary>
788+ public ConfigurationLocator()
789+ : this(new UbuntuOneApplicationLocator())
790+ {
791+
792+ }
793+
794+ /// <summary>
795+ /// Creates a new configuration locator with a pass app locator.
796+ /// </summary>
797+ /// <param name="applicationLocator">The object that will return the path to known applications.</param>
798+ public ConfigurationLocator(IApplicationLocator applicationLocator)
799+ {
800+ ApplicationLocator = applicationLocator;
801+ }
802+
803+ #endregion
804+
805+ #region Helpers
806+
807+ /// <summary>
808+ /// Returns if the configuration for the current user daemon is present.
809+ /// </summary>
810+ /// <returns>A flag stating if the configuraton is present.</returns>
811+ private bool IsDaemonConfigurationPresent()
812+ {
813+ // the configuration is store per user in his location to
814+ // ensure that he is the only one using it
815+ return Directory.Exists(UserDaemonConfigPath)
816+ && File.Exists(Path.Combine(UserDaemonConfigPath, DaemonAppConfigName))
817+ && Directory.Exists(Path.Combine(UserDaemonConfigPath, ConfigFolder));
818+ }
819+
820+ /// <summary>
821+ /// Returns if the configuration for the current user client is present
822+ /// </summary>
823+ /// <returns>A flag stating if the configuration is present.</returns>
824+ private bool IsClientConfigurationPresent()
825+ {
826+ return Directory.Exists(UserClientConfigPath)
827+ && File.Exists(Path.Combine(UserClientConfigPath, UserAppConfigName))
828+ && Directory.Exists(Path.Combine(UserClientConfigPath, ConfigFolder));
829+ }
830+
831+ /// <summary>
832+ /// Methods that updates all the urls in the services named pipes so that they are ersonalized
833+ /// for the current user.
834+ /// </summary>
835+ private void UpdateDaemonServicesConfiguration()
836+ {
837+ var servicesFullPath = Path.Combine(UserDaemonConfigPath, ConfigFolder);
838+ servicesFullPath = Path.Combine(servicesFullPath, ServicesConfig);
839+ string userConfig;
840+ using (var fileReader = new StreamReader(new FileStream(servicesFullPath, FileMode.Open)))
841+ {
842+ userConfig = fileReader.ReadToEnd();
843+ }
844+ userConfig = userConfig.Replace(UserToken, WindowsIdentity.GetCurrent().Name);
845+ File.Delete(servicesFullPath);
846+ using (var fileWriter = new StreamWriter(new FileStream(servicesFullPath, FileMode.CreateNew)))
847+ {
848+ fileWriter.Write(userConfig);
849+ }
850+ }
851+
852+ /// <summary>
853+ /// Updates the clients configurations so that the clients uses the correct named pipes.
854+ /// </summary>
855+ private void UpdateClientConfiguration()
856+ {
857+ var clientsFullPath = Path.Combine(UserClientConfigPath, ConfigFolder);
858+ clientsFullPath = Path.Combine(clientsFullPath, ClientConfig);
859+ string userConfig;
860+ using(var fileReader = new StreamReader(new FileStream(clientsFullPath, FileMode.Open)))
861+ {
862+ userConfig = fileReader.ReadToEnd();
863+ }
864+ userConfig = userConfig.Replace(UserToken, WindowsIdentity.GetCurrent().Name);
865+ File.Delete(clientsFullPath);
866+ using(var fileWriter = new StreamWriter(new FileStream(clientsFullPath, FileMode.CreateNew)))
867+ {
868+ fileWriter.Write(userConfig);
869+ }
870+ }
871+
872+ /// <summary>
873+ /// Method that copies all the configuration that is deployed by the msi to the users config location.
874+ /// </summary>
875+ private void CopyDaemonRootConfiguration()
876+ {
877+ if (!Directory.Exists(UserDaemonConfigPath))
878+ {
879+ Logger.DebugFormat("Creating dir {0}", UserDaemonConfigPath);
880+ Directory.CreateDirectory(UserDaemonConfigPath);
881+ }
882+ // we need to copy the info from the root path
883+ var daemonPath = ApplicationLocator.GetApplicationPath(Constants.U1DaemonAppName);
884+ File.Copy(Path.Combine(daemonPath, DaemonAppConfigName), Path.Combine(UserDaemonConfigPath, DaemonAppConfigName));
885+ // we copy the config files for log4net and the service model
886+ var userConfigFolderPath = Path.Combine(UserDaemonConfigPath, ConfigFolder);
887+ if (!Directory.Exists(userConfigFolderPath))
888+ {
889+ Logger.DebugFormat("Create dir {0}", userConfigFolderPath);
890+ Directory.CreateDirectory(userConfigFolderPath);
891+ }
892+ var rootConfigFolderPath = Path.Combine(daemonPath, ConfigFolder);
893+ File.Copy(Path.Combine(rootConfigFolderPath, Log4NetConfig), Path.Combine(userConfigFolderPath, Log4NetConfig));
894+ File.Copy(Path.Combine(rootConfigFolderPath, BehavioursConfig), Path.Combine(userConfigFolderPath, BehavioursConfig));
895+ File.Copy(Path.Combine(rootConfigFolderPath, BindingsConfig), Path.Combine(userConfigFolderPath, BindingsConfig));
896+ File.Copy(Path.Combine(rootConfigFolderPath, ServicesConfig), Path.Combine(userConfigFolderPath, ServicesConfig));
897+ }
898+
899+ private void CopyClietnRootConfiguration()
900+ {
901+ if (!Directory.Exists(UserClientConfigPath))
902+ {
903+ Logger.DebugFormat("Creating dir {0}", UserClientConfigPath);
904+ Directory.CreateDirectory(UserClientConfigPath);
905+ }
906+ // we need to copy the info from the root path
907+ var clientPath = ApplicationLocator.GetApplicationPath(Constants.U1ClientAppName);
908+ File.Copy(Path.Combine(clientPath, UserAppConfigName), Path.Combine(UserClientConfigPath, UserAppConfigName));
909+ // we copy the config files for log4net and the service model
910+ var userConfigFolderPath = Path.Combine(UserClientConfigPath, ConfigFolder);
911+ if (!Directory.Exists(userConfigFolderPath))
912+ {
913+ Logger.DebugFormat("Create dir {0}", userConfigFolderPath);
914+ Directory.CreateDirectory(userConfigFolderPath);
915+ }
916+ var rootConfigFolderPath = Path.Combine(clientPath, ConfigFolder);
917+ File.Copy(Path.Combine(rootConfigFolderPath, Log4NetConfig), Path.Combine(userConfigFolderPath, Log4NetConfig));
918+ File.Copy(Path.Combine(rootConfigFolderPath, BindingsConfig), Path.Combine(userConfigFolderPath, BindingsConfig));
919+ File.Copy(Path.Combine(rootConfigFolderPath, ClientConfig), Path.Combine(userConfigFolderPath, ClientConfig));
920+ }
921+
922+ #endregion
923+
924+
925+
926+ ///<summary>
927+ /// Returns the path with the configuration to be used for the dameon for the current user.
928+ ///</summary>
929+ ///<returns>The path to the configuration to be used by the current user when running the daemon.</returns>
930+ public string GetCurrentUserDaemonConfiguration()
931+ {
932+ if (!IsDaemonConfigurationPresent())
933+ {
934+ Logger.Info("The users config does not exist!");
935+ // we copy the root configuration
936+ CopyDaemonRootConfiguration();
937+ // we update the name pipe so that the use the current user name as part of the path
938+ UpdateDaemonServicesConfiguration();
939+ }
940+ var appConfigPath = Path.Combine(UserDaemonConfigPath, DaemonAppConfigName);
941+ Logger.InfoFormat("The config path is {0}", appConfigPath);
942+ return appConfigPath;
943+ }
944+
945+ /// <summary>
946+ /// Returns the path with the configuration to be used for the client for the current user.
947+ /// </summary>
948+ /// <returns>The path to the configuration to use.</returns>
949+ public string GetCurrentUserClientConfiguration()
950+ {
951+ if (!IsClientConfigurationPresent())
952+ {
953+ Logger.Info("The users config does not exist!");
954+ // we copy the root configuration
955+ CopyClietnRootConfiguration();
956+ // we update the name pipe so that the use the current user name as part of the path
957+ UpdateClientConfiguration();
958+ }
959+ var appConfigPath = Path.Combine(UserClientConfigPath, UserAppConfigName);
960+ Logger.InfoFormat("The config path is {0}", appConfigPath);
961+ return appConfigPath;
962+
963+ return null;
964+ }
965+
966+ }
967+}
968
969=== added file 'src/Canonical.UbuntuOne.Common/Utils/Constants.cs'
970--- src/Canonical.UbuntuOne.Common/Utils/Constants.cs 1970-01-01 00:00:00 +0000
971+++ src/Canonical.UbuntuOne.Common/Utils/Constants.cs 2010-10-08 12:04:40 +0000
972@@ -0,0 +1,36 @@
973+/*
974+ * Copyright 2010 Canonical Ltd.
975+ *
976+ * This file is part of UbuntuOne on Windows.
977+ *
978+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
979+ * it under the terms of the GNU Lesser General Public License version
980+ * as published by the Free Software Foundation.
981+ *
982+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
983+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
984+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
985+ * GNU Lesser General Public License for more details.
986+ *
987+ * You should have received a copy of the GNU Lesser General Public License
988+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
989+ *
990+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
991+ */
992+using System;
993+using System.Collections.Generic;
994+using System.Linq;
995+using System.Text;
996+
997+namespace Canonical.UbuntuOne.ProcessDispatcher
998+{
999+ /// <summary>
1000+ /// Contains a set of constants share among different classes.
1001+ /// </summary>
1002+ public static class Constants
1003+ {
1004+ public const string U1SyncAppName = "U1Sync";
1005+ public const string U1DaemonAppName = "U1Daemon";
1006+ public const string U1ClientAppName = "U1Client";
1007+ }
1008+}
1009
1010=== added file 'src/Canonical.UbuntuOne.Common/Utils/IApplicationLocator.cs'
1011--- src/Canonical.UbuntuOne.Common/Utils/IApplicationLocator.cs 1970-01-01 00:00:00 +0000
1012+++ src/Canonical.UbuntuOne.Common/Utils/IApplicationLocator.cs 2010-10-08 12:04:40 +0000
1013@@ -0,0 +1,44 @@
1014+/*
1015+ * Copyright 2010 Canonical Ltd.
1016+ *
1017+ * This file is part of UbuntuOne on Windows.
1018+ *
1019+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
1020+ * it under the terms of the GNU Lesser General Public License version
1021+ * as published by the Free Software Foundation.
1022+ *
1023+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
1024+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1025+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1026+ * GNU Lesser General Public License for more details.
1027+ *
1028+ * You should have received a copy of the GNU Lesser General Public License
1029+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
1030+ *
1031+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1032+ */
1033+using System.Collections.Generic;
1034+
1035+namespace Canonical.UbuntuOne.Common.Utils
1036+{
1037+ /// <summary>
1038+ /// Interface to be implemented by those object that know how to locate an application in the system so that
1039+ /// it can be called in a different process.
1040+ /// </summary>
1041+ public interface IApplicationLocator
1042+ {
1043+ /// <summary>
1044+ /// Returns a collecion with the names of the known application by the object.
1045+ /// </summary>
1046+ /// <returns>A string with all the different applications that the object knows how to locate.</returns>
1047+ ICollection<string> GetKnownApplications();
1048+
1049+ /// <summary>
1050+ /// Returns the full path in the system of the application that mathces the given name.
1051+ /// </summary>
1052+ /// <param name="appName">The name of the application we want to locate.</param>
1053+ /// <returns>The full path of the application with the given name.</returns>
1054+ string GetApplicationPath(string appName);
1055+
1056+ }
1057+}
1058
1059=== added file 'src/Canonical.UbuntuOne.Common/Utils/UbuntuOneApplicationLocator.cs'
1060--- src/Canonical.UbuntuOne.Common/Utils/UbuntuOneApplicationLocator.cs 1970-01-01 00:00:00 +0000
1061+++ src/Canonical.UbuntuOne.Common/Utils/UbuntuOneApplicationLocator.cs 2010-10-08 12:04:40 +0000
1062@@ -0,0 +1,153 @@
1063+/*
1064+ * Copyright 2010 Canonical Ltd.
1065+ *
1066+ * This file is part of UbuntuOne on Windows.
1067+ *
1068+ * UbuntuOne on Windows is free software: you can redistribute it and/or modify
1069+ * it under the terms of the GNU Lesser General Public License version
1070+ * as published by the Free Software Foundation.
1071+ *
1072+ * Ubuntu One on Windows is distributed in the hope that it will be useful,
1073+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1074+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1075+ * GNU Lesser General Public License for more details.
1076+ *
1077+ * You should have received a copy of the GNU Lesser General Public License
1078+ * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
1079+ *
1080+ * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1081+ */
1082+using System;
1083+using System.Collections.Generic;
1084+using System.IO;
1085+using Canonical.UbuntuOne.Common.Win32;
1086+using Canonical.UbuntuOne.ProcessDispatcher;
1087+using log4net;
1088+using Microsoft.Win32;
1089+
1090+namespace Canonical.UbuntuOne.Common.Utils
1091+{
1092+ /// <summary>
1093+ /// Implementation of an IApplicationLocator that does know how to locate the U1 applictions.
1094+ /// </summary>
1095+ public class UbuntuOneApplicationLocator : IApplicationLocator
1096+ {
1097+ #region Variables
1098+
1099+ private readonly IRegistryKey _localMachineKey;
1100+ private string _installationPath;
1101+ private readonly object _installationPathLock = new object();
1102+ private ILog _logger;
1103+ private readonly object _loggerLock = new object();
1104+
1105+ #endregion
1106+
1107+ #region Constructors
1108+
1109+ public UbuntuOneApplicationLocator()
1110+ : this(new RegistryKeyWrapper(Registry.LocalMachine))
1111+ {
1112+
1113+ }
1114+ public UbuntuOneApplicationLocator(IRegistryKey registryKey)
1115+ {
1116+ _localMachineKey = registryKey;
1117+ }
1118+
1119+ #endregion
1120+
1121+ #region Properties
1122+
1123+ /// <summary>
1124+ /// Gets and sets the logger used by the class.
1125+ /// </summary>
1126+ internal ILog Logger
1127+ {
1128+ get
1129+ {
1130+ if (_logger == null)
1131+ {
1132+ lock (_loggerLock)
1133+ {
1134+ _logger = LogManager.GetLogger(typeof(UbuntuOneApplicationLocator));
1135+ }
1136+ }
1137+ return _logger;
1138+ }
1139+ set { _logger = value; }
1140+ }
1141+
1142+ #endregion
1143+
1144+ #region Helpers
1145+
1146+ private string InstallationPath
1147+ {
1148+ get
1149+ {
1150+ if (_installationPath == null)
1151+ {
1152+ lock (_installationPathLock)
1153+ {
1154+ try
1155+ {
1156+ using (var softwareEntry = _localMachineKey.OpenSubKey("SOFTWARE"))
1157+ using (var canonicalEntry = softwareEntry.OpenSubKey("Canonical"))
1158+ using (var ubuntuOneEntry = canonicalEntry.OpenSubKey("UbuntuOne"))
1159+ {
1160+ _installationPath = (string)ubuntuOneEntry.GetValue("InstallationPath");
1161+ }
1162+ }
1163+ catch (NullReferenceException e)
1164+ {
1165+ // thrown when we did not find the key, that is, not correct installation
1166+ Logger.Error("Registry key HKLM/Software/Canonical/UbuntuOne is not present!!!");
1167+ throw new ApplicationLocatorException("Registry key HKLM/Software/Canonical/UbuntuOne is not present!!!", e);
1168+ }
1169+ }
1170+ }
1171+ return _installationPath;
1172+ }
1173+ }
1174+ #endregion
1175+
1176+ #region Implementation of IApplicationLocator
1177+
1178+ /// <summary>
1179+ /// Returns a collecion with the names of the known application by the object.
1180+ /// </summary>
1181+ /// <returns>A string with all the different applications that the object knows how to locate.</returns>
1182+ public ICollection<string> GetKnownApplications()
1183+ {
1184+ return new[] { Constants.U1SyncAppName, Constants.U1DaemonAppName, Constants.U1ClientAppName };
1185+ }
1186+
1187+ /// <summary>
1188+ /// Returns the full path in the system of the application that mathces the given name.
1189+ /// </summary>
1190+ /// <param name="appName">The name of the application we want to locate.</param>
1191+ /// <returns>The full path of the application with the given name.</returns>
1192+ public string GetApplicationPath(string appName)
1193+ {
1194+ if (string.Compare(appName, Constants.U1SyncAppName, true) == 0)
1195+ {
1196+ var u1sync = Path.Combine(InstallationPath, "Client");
1197+ u1sync = Path.Combine(u1sync, "U1Sync");
1198+ return u1sync;
1199+ }
1200+ if (string.Compare(appName, Constants.U1DaemonAppName, true) == 0)
1201+ {
1202+ var u1daemon = Path.Combine(InstallationPath, "Daemon");
1203+ return u1daemon;
1204+ }
1205+ if(string.Compare(appName, Constants.U1ClientAppName, true) == 0)
1206+ {
1207+ var u1client = Path.Combine(InstallationPath, "Client");
1208+ return u1client;
1209+ }
1210+ throw new ApplicationLocatorException(string.Format("Application {0} is not known.", appName));
1211+ }
1212+
1213+ #endregion
1214+ }
1215+}
1216
1217=== modified file 'src/Canonical.UbuntuOne.Common/objects.xml'
1218--- src/Canonical.UbuntuOne.Common/objects.xml 2010-10-05 10:14:44 +0000
1219+++ src/Canonical.UbuntuOne.Common/objects.xml 2010-10-08 12:04:40 +0000
1220@@ -45,6 +45,13 @@
1221 <object id="Application"
1222 type="Canonical.UbuntuOne.Common.Utils.ApplicationWrapper, Canonical.UbuntuOne.Common" />
1223
1224+ <object id="ServiceCaller"
1225+ type="Canonical.UbuntuOne.Common.Net.ServiceCaller, Canonical.UbuntuOne.Common" />
1226+
1227+ <object id="ApplicationLocator"
1228+ type="Canonical.UbuntuOne.Common.Utils.UbuntuOneApplicationLocator, Canonical.UbuntuOne.Common"
1229+ autowire="autodetect"/>
1230+
1231 <!-- ######################################################################################## -->
1232 <!-- Net Objects -->
1233 <!-- ######################################################################################## -->
1234
1235=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/App.config'
1236--- src/Canonical.UbuntuOne.ProcessDispatcher/App.config 2010-08-18 09:49:09 +0000
1237+++ src/Canonical.UbuntuOne.ProcessDispatcher/App.config 2010-10-08 12:04:40 +0000
1238@@ -32,19 +32,10 @@
1239
1240 <!-- Spring configuration -->
1241 <spring>
1242- <parsers>
1243- <parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data" />
1244- </parsers>
1245 <context>
1246 <resource uri="assembly://Canonical.UbuntuOne.ProcessDispatcher/Canonical.UbuntuOne.ProcessDispatcher/objects.xml" />
1247+ <resource uri="assembly://Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common/objects.xml" />
1248 </context>
1249- <objects xmlns="http://www.springframework.net"
1250- xmlns:db="http://www.springframework.net/database">
1251- <!-- most internal objects definition is in the embeded objects.xml file here you will just find the db configuration -->
1252- <db:provider id="DbProvider"
1253- provider="SQLite-1.0.65"
1254- connectionString="Data Source=UbuntuOne.db;Version=3;FailIfMissing=False;Compress=True"/>
1255- </objects>
1256 </spring>
1257
1258 <system.serviceModel>
1259
1260=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/Canonical.UbuntuOne.ProcessDispatcher.csproj'
1261--- src/Canonical.UbuntuOne.ProcessDispatcher/Canonical.UbuntuOne.ProcessDispatcher.csproj 2010-10-06 10:43:02 +0000
1262+++ src/Canonical.UbuntuOne.ProcessDispatcher/Canonical.UbuntuOne.ProcessDispatcher.csproj 2010-10-08 12:04:40 +0000
1263@@ -6,7 +6,7 @@
1264 <ProductVersion>9.0.21022</ProductVersion>
1265 <SchemaVersion>2.0</SchemaVersion>
1266 <ProjectGuid>{8D353509-C095-4E72-A693-3CEE97704C7D}</ProjectGuid>
1267- <OutputType>Exe</OutputType>
1268+ <OutputType>WinExe</OutputType>
1269 <RootNamespace>Canonical.UbuntuOne.ProcessDispatcher</RootNamespace>
1270 <AssemblyName>Canonical.UbuntuOne.ProcessDispatcher</AssemblyName>
1271 <FileUpgradeFlags>
1272@@ -30,6 +30,8 @@
1273 <UseApplicationTrust>false</UseApplicationTrust>
1274 <BootstrapperEnabled>true</BootstrapperEnabled>
1275 <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
1276+ <StartupObject>
1277+ </StartupObject>
1278 </PropertyGroup>
1279 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
1280 <DebugSymbols>true</DebugSymbols>
1281@@ -89,18 +91,14 @@
1282 <Compile Include="..\Version.cs">
1283 <Link>Properties\Version.cs</Link>
1284 </Compile>
1285+ <Compile Include="SyncDaemonWindowsService.cs">
1286+ </Compile>
1287 <Compile Include="CallerContext.cs" />
1288 <Compile Include="EventNotifier.cs" />
1289 <Compile Include="ICallerContext.cs" />
1290 <Compile Include="Program.cs" />
1291- <Compile Include="ProjectInstaller.cs">
1292- <SubType>Component</SubType>
1293- </Compile>
1294 <Compile Include="SyncConfigurationService.cs" />
1295 <Compile Include="SyncDaemonService.cs" />
1296- <Compile Include="SyncDaemonWindowsService.cs">
1297- <SubType>Component</SubType>
1298- </Compile>
1299 <Compile Include="SyncFileManagerService.cs" />
1300 <Compile Include="SyncFoldersService.cs" />
1301 <Compile Include="SyncSharesService.cs" />
1302@@ -128,13 +126,13 @@
1303 <HintPath>..\..\lib\Spring.Net\Spring.Services.dll</HintPath>
1304 </Reference>
1305 <Reference Include="System" />
1306+ <Reference Include="System.configuration" />
1307 <Reference Include="System.Data" />
1308 <Reference Include="System.Data.SQLite, Version=1.0.65.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
1309 <SpecificVersion>False</SpecificVersion>
1310 <HintPath>..\..\lib\SQLite\System.Data.SQLite.DLL</HintPath>
1311 </Reference>
1312 <Reference Include="System.ServiceProcess" />
1313- <Reference Include="System.Configuration.Install" />
1314 <Reference Include="System.ServiceModel">
1315 </Reference>
1316 <Reference Include="System.Core">
1317
1318=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.behaviours.config'
1319--- src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.behaviours.config 2010-07-26 15:57:10 +0000
1320+++ src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.behaviours.config 2010-10-08 12:04:40 +0000
1321@@ -2,7 +2,7 @@
1322 <behaviors>
1323 <serviceBehaviors>
1324 <behavior name="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior">
1325- <serviceMetadata httpGetEnabled="true" />
1326+ <serviceMetadata httpGetEnabled="false" />
1327 <serviceDebug includeExceptionDetailInFaults="true" />
1328 </behavior>
1329 </serviceBehaviors>
1330
1331=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.services.config'
1332--- src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.services.config 2010-07-26 15:57:10 +0000
1333+++ src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.services.config 2010-10-08 12:04:40 +0000
1334@@ -4,10 +4,10 @@
1335 name="SyncConfigurationService">
1336 <host>
1337 <baseAddresses>
1338- <add baseAddress="http://localhost:8000/UbuntuOne/SyncConfigurationService"/>
1339+ <add baseAddress="net.pipe://localhost/UbuntuOne/SyncConfigurationService/$username$"/>
1340 </baseAddresses>
1341 </host>
1342- <endpoint address="net.pipe://localhost/UbuntuOne/SyncConfigurationService"
1343+ <endpoint address="net.pipe://localhost/UbuntuOne/SyncConfigurationService/$username$"
1344 binding="netNamedPipeBinding"
1345 bindingConfiguration="namedPipeBinding"
1346 contract="Canonical.UbuntuOne.Common.ISyncConfiguration">
1347@@ -15,19 +15,16 @@
1348 <dns value="localhost" />
1349 </identity>
1350 </endpoint>
1351- <endpoint address="mex"
1352- binding="mexHttpBinding"
1353- contract="IMetadataExchange" />
1354 </service>
1355
1356 <service behaviorConfiguration="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior"
1357 name="SyncDaemonService">
1358 <host>
1359 <baseAddresses>
1360- <add baseAddress="http://localhost:8000/UbuntuOne/SyncDaemonService"/>
1361+ <add baseAddress="net.pipe://localhost/UbuntuOne/SyncDaemonService/$username$"/>
1362 </baseAddresses>
1363 </host>
1364- <endpoint address="net.pipe://localhost/UbuntuOne/SyncDaemonService"
1365+ <endpoint address="net.pipe://localhost/UbuntuOne/SyncDaemonService/$username$"
1366 binding="netNamedPipeBinding"
1367 bindingConfiguration="namedPipeBinding"
1368 contract="Canonical.UbuntuOne.Common.ISyncDaemon">
1369@@ -35,19 +32,16 @@
1370 <dns value="localhost" />
1371 </identity>
1372 </endpoint>
1373- <endpoint address="mex"
1374- binding="mexHttpBinding"
1375- contract="IMetadataExchange" />
1376 </service>
1377
1378 <service behaviorConfiguration="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior"
1379 name="SyncFileManagerService">
1380 <host>
1381 <baseAddresses>
1382- <add baseAddress="http://localhost:8000/UbuntuOne/SyncFileManagerService"/>
1383+ <add baseAddress="net.pipe://localhost/UbuntuOne/SyncFileManagerService/$username$"/>
1384 </baseAddresses>
1385 </host>
1386- <endpoint address="net.pipe://localhost/UbuntuOne/SyncFileManagerService"
1387+ <endpoint address="net.pipe://localhost/UbuntuOne/SyncFileManagerService/$username$"
1388 binding="netNamedPipeBinding"
1389 bindingConfiguration="namedPipeBinding"
1390 contract="Canonical.UbuntuOne.Common.ISyncFileManager">
1391@@ -55,19 +49,16 @@
1392 <dns value="localhost" />
1393 </identity>
1394 </endpoint>
1395- <endpoint address="mex"
1396- binding="mexHttpBinding"
1397- contract="IMetadataExchange" />
1398 </service>
1399
1400 <service behaviorConfiguration="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior"
1401 name="SyncFoldersService">
1402 <host>
1403 <baseAddresses>
1404- <add baseAddress="http://localhost:8000/UbuntuOne/SyncFoldersService"/>
1405+ <add baseAddress="net.pipe://localhost/UbuntuOne/SyncFoldersService/$username$"/>
1406 </baseAddresses>
1407 </host>
1408- <endpoint address="net.pipe://localhost/UbuntuOne/SyncFoldersService"
1409+ <endpoint address="net.pipe://localhost/UbuntuOne/SyncFoldersService/$username$"
1410 binding="netNamedPipeBinding"
1411 bindingConfiguration="namedPipeBinding"
1412 contract="Canonical.UbuntuOne.Common.ISyncFolders">
1413@@ -75,19 +66,16 @@
1414 <dns value="localhost" />
1415 </identity>
1416 </endpoint>
1417- <endpoint address="mex"
1418- binding="mexHttpBinding"
1419- contract="IMetadataExchange" />
1420 </service>
1421
1422 <service behaviorConfiguration="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior"
1423 name="SyncSharesService">
1424 <host>
1425 <baseAddresses>
1426- <add baseAddress="http://localhost:8000/UbuntuOne/SyncSharesService"/>
1427+ <add baseAddress="net.pipe://localhost/UbuntuOne/SyncSharesService"/>
1428 </baseAddresses>
1429 </host>
1430- <endpoint address="net.pipe://localhost/UbuntuOne/SyncSharesService"
1431+ <endpoint address="net.pipe://localhost/UbuntuOne/SyncSharesService/$username$"
1432 binding="netNamedPipeBinding"
1433 bindingConfiguration="namedPipeBinding"
1434 contract="Canonical.UbuntuOne.Common.ISyncShares">
1435@@ -95,8 +83,5 @@
1436 <dns value="localhost" />
1437 </identity>
1438 </endpoint>
1439- <endpoint address="mex"
1440- binding="mexHttpBinding"
1441- contract="IMetadataExchange" />
1442 </service>
1443 </services>
1444\ No newline at end of file
1445
1446=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/Program.cs'
1447--- src/Canonical.UbuntuOne.ProcessDispatcher/Program.cs 2010-09-08 08:24:05 +0000
1448+++ src/Canonical.UbuntuOne.ProcessDispatcher/Program.cs 2010-10-08 12:04:40 +0000
1449@@ -17,29 +17,63 @@
1450 *
1451 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1452 */
1453-using System.ServiceProcess;
1454+using System;
1455 using Canonical.UbuntuOne.Common.Container;
1456+using Canonical.UbuntuOne.Common.Utils;
1457 using log4net;
1458
1459 namespace Canonical.UbuntuOne.ProcessDispatcher
1460 {
1461- static class Program
1462- {
1463- private static ILog _logger = LogManager.GetLogger(typeof (Program));
1464-
1465- /// <summary>
1466- /// This method starts the service.
1467- /// </summary>
1468- static void Main()
1469- {
1470- _logger.Debug("Starting services.");
1471- // use the IoC to get the implementation of the SyncDaemon service, the IoC will take care of
1472- // setting the object correctly.
1473- ObjectsContainer.Initialize(new SpringContainer());
1474- var syncDaemonWindowsService = ObjectsContainer.GetImplementationOf<SyncDaemonWindowsService>();
1475-
1476- // To run more than one service you have to add them here
1477- ServiceBase.Run(new ServiceBase[] { syncDaemonWindowsService });
1478- }
1479- }
1480+
1481+ static class Program
1482+ {
1483+ private static readonly ILog _logger = LogManager.GetLogger(typeof(Program));
1484+ private static readonly ConfigurationLocator _configLocator = new ConfigurationLocator();
1485+
1486+ /// <summary>
1487+ /// This method starts the service.
1488+ /// </summary>
1489+ static void Main()
1490+ {
1491+ // HACK: This technique is quite interesting although it is a hack. The idea is the following,
1492+ // due to the fact that we want to run a WCF service per user and not per machine, we have to be able
1493+ // to determine at runtime the users pipe names. To do so we would use a config file per user
1494+ // but ofcourse we cannot do that at install time becuase we do not know all the user.
1495+ //
1496+ // Ideally we would not have to do this hack and the ConfiguratonManager would allow to refrest the app
1497+ // condifuration, but it is not the case!! On top of that you cannot do so by using reflection :(
1498+ //
1499+ // The trick is simple, we use the normal app.config to start the program, once the program is started we create
1500+ // a new app domain where we will be doing all the work. Because we are the ones starting the app domain, we can
1501+ // tell him to use a diff configuration, which means that we poit to a new config for this user that points to
1502+ // the correct pipe names :D
1503+ // This is not cheap, now we have a dummy app domain, the one that start this program, and a second app domain that
1504+ // is used to load the spring context plus all the WCT setting. The SeriesAppDomain is the one that really does
1505+ // the job.
1506+ _logger.Debug("Redirecting configuration");
1507+
1508+ // Setup information for the new appdomain.
1509+ var setup = new AppDomainSetup
1510+ {
1511+ ConfigurationFile = _configLocator.GetCurrentUserDaemonConfiguration()
1512+ };
1513+
1514+ // Create the new appdomain with the new config.
1515+ var executionAppDomain = AppDomain.CreateDomain("ServicesAppDomain", AppDomain.CurrentDomain.Evidence, setup);
1516+
1517+ // Call the write config method in that appdomain.
1518+ executionAppDomain.DoCallBack(() =>
1519+ {
1520+ _logger.Debug("Starting services.");
1521+ // use the IoC to get the implementation of the SyncDaemon service, the IoC will take care of
1522+ // setting the object correctly.
1523+ ObjectsContainer.Initialize(new SpringContainer());
1524+ var syncDaemonWindowsService = ObjectsContainer.GetImplementationOf<SyncDaemonWindowsService>();
1525+ // To run more than one service you have to add them here
1526+ syncDaemonWindowsService.Start();
1527+ while (true) ;
1528+ });
1529+
1530+ }
1531+ }
1532 }
1533
1534=== removed file 'src/Canonical.UbuntuOne.ProcessDispatcher/ProjectInstaller.cs'
1535--- src/Canonical.UbuntuOne.ProcessDispatcher/ProjectInstaller.cs 2010-09-08 08:24:05 +0000
1536+++ src/Canonical.UbuntuOne.ProcessDispatcher/ProjectInstaller.cs 1970-01-01 00:00:00 +0000
1537@@ -1,49 +0,0 @@
1538-/*
1539- * Copyright 2010 Canonical Ltd.
1540- *
1541- * This file is part of UbuntuOne on Windows.
1542- *
1543- * UbuntuOne on Windows is free software: you can redistribute it and/or modify
1544- * it under the terms of the GNU Lesser General Public License version
1545- * as published by the Free Software Foundation.
1546- *
1547- * Ubuntu One on Windows is distributed in the hope that it will be useful,
1548- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1549- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1550- * GNU Lesser General Public License for more details.
1551- *
1552- * You should have received a copy of the GNU Lesser General Public License
1553- * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
1554- *
1555- * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1556- */
1557-using System.ComponentModel;
1558-using System.Configuration.Install;
1559-using System.ServiceProcess;
1560-
1561-namespace Canonical.UbuntuOne.ProcessDispatcher
1562-{
1563- /// <summary>
1564- /// Installer that will allows to set up the daemon when using the InnstalUtil application.
1565- /// </summary>
1566- [RunInstaller(true)]
1567- public class ProjectInstaller : Installer
1568- {
1569- private readonly ServiceProcessInstaller _serviceProcessInstaller;
1570- private readonly ServiceInstaller _serviceInstaller;
1571-
1572- /// <summary>
1573- /// Creates a new instance of the installer.
1574- /// </summary>
1575- public ProjectInstaller()
1576- {
1577- _serviceProcessInstaller = new ServiceProcessInstaller();
1578- _serviceInstaller = new ServiceInstaller();
1579- // Here you can set properties on serviceProcessInstaller or register event handlers
1580- _serviceProcessInstaller.Account = ServiceAccount.LocalService;
1581-
1582- _serviceInstaller.ServiceName = SyncDaemonWindowsService.MyServiceName;
1583- Installers.AddRange(new Installer[] { _serviceProcessInstaller, _serviceInstaller });
1584- }
1585- }
1586-}
1587
1588=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonService.cs'
1589--- src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonService.cs 2010-08-30 17:30:31 +0000
1590+++ src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonService.cs 2010-10-08 12:04:40 +0000
1591@@ -19,9 +19,13 @@
1592 */
1593 using System;
1594 using System.Collections.Generic;
1595+using System.Diagnostics;
1596+using System.IO;
1597+using System.ServiceModel;
1598 using Canonical.UbuntuOne.Common;
1599 using Canonical.UbuntuOne.Common.Aop;
1600 using Canonical.UbuntuOne.Common.Security;
1601+using Canonical.UbuntuOne.Common.Utils;
1602 using Canonical.UbuntuOne.Common.Validation;
1603 using log4net;
1604
1605@@ -32,6 +36,7 @@
1606 /// </summary>
1607 internal class SyncDaemonService : ISyncDaemon
1608 {
1609+
1610 #region Variables
1611
1612 // contains a map between user id and pid so that we know if the process is running already.
1613@@ -76,6 +81,12 @@
1614 /// </summary>
1615 internal IAuthentication Authentication { get; set; }
1616
1617+ /// <summary>
1618+ /// Allows to get and set the application locator that can be used to find the required
1619+ /// external applications.
1620+ /// </summary>
1621+ internal IApplicationLocator ApplicationLocator { get; set; }
1622+
1623 #endregion
1624
1625 public SyncDaemonService()
1626@@ -83,12 +94,12 @@
1627 _processesMap = new Dictionary<string, IProcessManager>();
1628 }
1629
1630-
1631 /// <summary>
1632 /// Allows to start the daemon by a client.
1633 /// </summary>
1634 /// <exception cref="SyncDaemonException">Exception thrown when the process could not be started.</exception>
1635 [DebugLogged]
1636+ [OperationBehavior(Impersonation = ImpersonationOption.Allowed)]
1637 public void Start()
1638 {
1639 ValidateArgs.Begin()
1640@@ -135,7 +146,7 @@
1641 Start();
1642 return true;
1643 }
1644- catch(SyncDaemonException)
1645+ catch (SyncDaemonException)
1646 {
1647 return false;
1648 }
1649@@ -155,7 +166,7 @@
1650 if (Authentication.IsAuthenticated)
1651 {
1652 var user = Authentication.Username;
1653- if(_processesMap.ContainsKey(user))
1654+ if (_processesMap.ContainsKey(user))
1655 {
1656 // get the manager, stop the process and remove the info
1657 var manager = _processesMap[user];
1658@@ -164,7 +175,7 @@
1659 manager.Stop();
1660 _processesMap.Remove(user);
1661 }
1662- catch(ProcessManagementException ex)
1663+ catch (ProcessManagementException ex)
1664 {
1665 var message = String.Format("Daemon for {0} could not be stoped: {1}", user, ex.Message);
1666 throw new SyncDaemonException(message, ex);
1667@@ -189,7 +200,7 @@
1668 Stop();
1669 return true;
1670 }
1671- catch(SyncDaemonException)
1672+ catch (SyncDaemonException)
1673 {
1674 return false;
1675 }
1676@@ -204,6 +215,82 @@
1677 }
1678
1679 /// <summary>
1680+ /// Allows to perform a manual sync of the root Ubuntu One directory in the provided path using the oauth information
1681+ /// passed to the service.
1682+ /// </summary>
1683+ /// <param name="path">The path to which the root of the Ubuntu One folder will be sync.</param>
1684+ /// <param name="token">The token from oauth.</param>
1685+ /// <param name="tokenSecret">The token secret from oauth.</param>
1686+ /// <param name="consumerKey">The consumer key from oauth.</param>
1687+ /// <param name="consumerSecret">The consumer secret from oauth.</param>
1688+ public void ManualSync(string path, string token, string tokenSecret, string consumerKey, string consumerSecret)
1689+ {
1690+ ValidateArgs.Begin()
1691+ .IsNotNullOrEmpty(path, "path")
1692+ .IsNotNullOrEmpty(token, "toke")
1693+ .IsNotNullOrEmpty(consumerKey, "consumerKey")
1694+ .IsNotNullOrEmpty(consumerSecret, "consumerSecret")
1695+ .Check();
1696+ // should always be executed befre the impersonation
1697+ var u1SyncPath = ApplicationLocator.GetApplicationPath(Constants.U1SyncAppName);
1698+ var tokens = string.Format("{0}:{1}:{2}:{3}", token, tokenSecret, consumerKey, consumerSecret);
1699+ if (!Directory.Exists(path))
1700+ {
1701+ Directory.CreateDirectory(path);
1702+ }
1703+ if (!Directory.Exists(Path.Combine(path, ".ubuntuone-sync")))
1704+ {
1705+ var initCommand = String.Format("{0} --init \"{1}\" --oauth {2}",
1706+ Path.Combine(u1SyncPath, "main.exe"),
1707+ path, tokens);
1708+ Logger.DebugFormat("Executing {0} as user {1}", initCommand,
1709+ ServiceSecurityContext.Current.WindowsIdentity.Name);
1710+
1711+ //init the directory
1712+ var init = new Process
1713+ {
1714+ StartInfo =
1715+ {
1716+ WorkingDirectory = u1SyncPath,
1717+ FileName = Path.Combine(u1SyncPath, "main.exe"),
1718+ Arguments = String.Format(" --init \"{0}\" --oauth {1}", path, tokens),
1719+ UseShellExecute = false,
1720+ RedirectStandardOutput = true,
1721+ RedirectStandardError = true,
1722+ CreateNoWindow = true,
1723+ WindowStyle = ProcessWindowStyle.Hidden
1724+
1725+ }
1726+ };
1727+ Logger.InfoFormat("Executing u1sync with args: {0}", init.StartInfo.Arguments);
1728+ init.Start();
1729+ init.WaitForExit();
1730+ Logger.InfoFormat("StandarOutput from u1sync is: {0}", init.StandardOutput.ReadToEnd());
1731+ Logger.ErrorFormat("StandardError from u1sync is: {0}", init.StandardError.ReadToEnd());
1732+ init.Close();
1733+
1734+ }
1735+ var syncCommand = String.Format("{0} --oauth {1}", Path.Combine(u1SyncPath, "main.exe"), tokens);
1736+ Logger.DebugFormat("Executing {0} as user {1}", syncCommand,
1737+ ServiceSecurityContext.Current.WindowsIdentity.Name);
1738+ var proc = new Process
1739+ {
1740+ StartInfo =
1741+ {
1742+ WorkingDirectory = u1SyncPath,
1743+ FileName = Path.Combine(u1SyncPath, "main.exe"),
1744+ Arguments = String.Format("\"{0}\" --oauth {1}", path, tokens),
1745+ UseShellExecute = false,
1746+ RedirectStandardOutput = true,
1747+ RedirectStandardError = true,
1748+ CreateNoWindow = true,
1749+ WindowStyle = ProcessWindowStyle.Hidden
1750+ }
1751+ };
1752+ proc.Start();
1753+ }
1754+
1755+ /// <summary>
1756 /// Returns the port number of the socket that the synd daemo is listening to for communication.
1757 /// </summary>
1758 /// <returns></returns>
1759
1760=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonWindowsService.cs'
1761--- src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonWindowsService.cs 2010-09-08 08:24:05 +0000
1762+++ src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonWindowsService.cs 2010-10-08 12:04:40 +0000
1763@@ -18,7 +18,6 @@
1764 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
1765 */
1766 using System.ServiceModel;
1767-using System.ServiceProcess;
1768 using Canonical.UbuntuOne.Common.Aop;
1769 using log4net;
1770
1771@@ -29,7 +28,7 @@
1772 ///
1773 /// This service is used to ensure that the sync daemon run sper user and allows to amange those processes.
1774 /// </summary>
1775- public class SyncDaemonWindowsService : ServiceBase
1776+ public class SyncDaemonWindowsService
1777 {
1778 #region Variables
1779
1780@@ -56,7 +55,7 @@
1781 {
1782 lock (_loggerLock)
1783 {
1784- _logger = LogManager.GetLogger(typeof (SyncDaemonWindowsService));
1785+ _logger = LogManager.GetLogger(typeof(SyncDaemonWindowsService));
1786 }
1787 }
1788 return _logger;
1789@@ -114,36 +113,23 @@
1790 SyncFileManager,
1791 SyncFolders,
1792 SyncShares
1793- };
1794+ };
1795 }
1796
1797 #endregion
1798
1799 /// <summary>
1800- /// Creates a new instance of the sync daemon windows service.
1801- /// </summary>
1802- public SyncDaemonWindowsService()
1803- {
1804- InitializeComponent();
1805- }
1806-
1807- private void InitializeComponent()
1808- {
1809- ServiceName = MyServiceName;
1810- }
1811-
1812- /// <summary>
1813 /// Start this service.
1814 /// </summary>
1815 [DebugLogged]
1816- protected override void OnStart(string[] args)
1817+ public void Start()
1818 {
1819
1820 foreach (var serviceHost in GetHosts())
1821 {
1822 // make sure that it is close and reopen
1823 Logger.InfoFormat("Host {0} state is {1}", serviceHost.BaseAddresses[0], serviceHost.State);
1824- if(serviceHost.State == CommunicationState.Closed)
1825+ if (serviceHost.State == CommunicationState.Closed)
1826 serviceHost.Open();
1827 }
1828 Logger.DebugFormat("{0} started.", MyServiceName);
1829@@ -153,11 +139,11 @@
1830 /// Stop this service.
1831 /// </summary>
1832 [DebugLogged]
1833- protected override void OnStop()
1834+ public void Stop()
1835 {
1836 var hosts = GetHosts();
1837
1838- for (var index = 0; index < hosts.Length; index++ )
1839+ for (var index = 0; index < hosts.Length; index++)
1840 {
1841 if (hosts[index] == null)
1842 {
1843
1844=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/objects.xml'
1845--- src/Canonical.UbuntuOne.ProcessDispatcher/objects.xml 2010-09-28 08:41:33 +0000
1846+++ src/Canonical.UbuntuOne.ProcessDispatcher/objects.xml 2010-10-08 12:04:40 +0000
1847@@ -35,7 +35,7 @@
1848 <property name="attribute"
1849 value="Canonical.UbuntuOne.Common.Aop.DebugLoggedAttribute, Canonical.UbuntuOne.Common" />
1850 </object>
1851-
1852+
1853 <!-- ###################################################################################################### -->
1854 <!-- Wcf services that will allows .Net languages to interact with the SyncDaemon -->
1855 <!-- ###################################################################################################### -->
1856@@ -43,19 +43,27 @@
1857
1858 <!-- services -->
1859 <object id="SyncConfigurationService"
1860- type="Canonical.UbuntuOne.ProcessDispatcher.SyncConfigurationService, Canonical.UbuntuOne.ProcessDispatcher" />
1861+ type="Canonical.UbuntuOne.ProcessDispatcher.SyncConfigurationService, Canonical.UbuntuOne.ProcessDispatcher"
1862+ autowire="autodetect"/>
1863
1864 <object id="SyncDaemonService"
1865- type="Canonical.UbuntuOne.ProcessDispatcher.SyncDaemonService, Canonical.UbuntuOne.ProcessDispatcher" />
1866+ type="Canonical.UbuntuOne.ProcessDispatcher.SyncDaemonService, Canonical.UbuntuOne.ProcessDispatcher"
1867+ autowire="autodetect">
1868+ <property name="ApplicationLocator"
1869+ ref="ApplicationLocator" />
1870+ </object>
1871
1872 <object id="SyncFileManagerService"
1873- type="Canonical.UbuntuOne.ProcessDispatcher.SyncFileManagerService, Canonical.UbuntuOne.ProcessDispatcher" />
1874+ type="Canonical.UbuntuOne.ProcessDispatcher.SyncFileManagerService, Canonical.UbuntuOne.ProcessDispatcher"
1875+ autowire="autodetect"/>
1876
1877 <object id="SyncFoldersService"
1878- type="Canonical.UbuntuOne.ProcessDispatcher.SyncFoldersService, Canonical.UbuntuOne.ProcessDispatcher" />
1879+ type="Canonical.UbuntuOne.ProcessDispatcher.SyncFoldersService, Canonical.UbuntuOne.ProcessDispatcher"
1880+ autowire="autodetect"/>
1881
1882 <object id="SyncSharesService"
1883- type="Canonical.UbuntuOne.ProcessDispatcher.SyncSharesService, Canonical.UbuntuOne.ProcessDispatcher" />
1884+ type="Canonical.UbuntuOne.ProcessDispatcher.SyncSharesService, Canonical.UbuntuOne.ProcessDispatcher"
1885+ autowire="autodetect"/>
1886
1887 <!-- hosts -->
1888
1889
1890=== modified file 'src/ServiceTestApp/Program.cs'
1891--- src/ServiceTestApp/Program.cs 2010-07-26 16:01:09 +0000
1892+++ src/ServiceTestApp/Program.cs 2010-10-08 12:04:40 +0000
1893@@ -1,7 +1,4 @@
1894 using System;
1895-using System.Collections.Generic;
1896-using System.Linq;
1897-using System.Text;
1898 using Canonical.UbuntuOne.Common.Container;
1899 using Canonical.UbuntuOne.ProcessDispatcher;
1900
1901
1902=== modified file 'src/UbuntuOne.sln'
1903--- src/UbuntuOne.sln 2010-10-06 10:43:02 +0000
1904+++ src/UbuntuOne.sln 2010-10-08 12:04:40 +0000
1905@@ -13,8 +13,6 @@
1906 EndProject
1907 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Canonical.UbuntuOne.Client.Views", "Canonical.UbuntuOne.Client.Views\Canonical.UbuntuOne.Client.Views.csproj", "{1B5BA61A-4B34-424A-886E-E2B0CF547D4D}"
1908 EndProject
1909-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceTestApp", "ServiceTestApp\ServiceTestApp.csproj", "{009E6FD4-DE20-410A-B1F3-5F0542CD8745}"
1910-EndProject
1911 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Canonical.UbuntuOne.Client.Test", "Canonical.UbuntuOne.Client.Test\Canonical.UbuntuOne.Client.Test.csproj", "{2947FCA2-D6FC-4509-83F8-64A87447EBD3}"
1912 EndProject
1913 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UbuntuOneClient", "UbuntuOneClient\UbuntuOneClient.csproj", "{E41083CC-B99A-4AEC-93CC-F693F6AA6071}"
1914@@ -104,16 +102,6 @@
1915 {1B5BA61A-4B34-424A-886E-E2B0CF547D4D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
1916 {1B5BA61A-4B34-424A-886E-E2B0CF547D4D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
1917 {1B5BA61A-4B34-424A-886E-E2B0CF547D4D}.Release|x86.ActiveCfg = Release|Any CPU
1918- {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1919- {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Debug|Any CPU.Build.0 = Debug|Any CPU
1920- {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
1921- {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
1922- {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Debug|x86.ActiveCfg = Debug|Any CPU
1923- {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Release|Any CPU.ActiveCfg = Release|Any CPU
1924- {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Release|Any CPU.Build.0 = Release|Any CPU
1925- {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
1926- {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Release|Mixed Platforms.Build.0 = Release|Any CPU
1927- {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Release|x86.ActiveCfg = Release|Any CPU
1928 {2947FCA2-D6FC-4509-83F8-64A87447EBD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1929 {2947FCA2-D6FC-4509-83F8-64A87447EBD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
1930 {2947FCA2-D6FC-4509-83F8-64A87447EBD3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
1931
1932=== modified file 'src/UbuntuOneClient/App.config'
1933--- src/UbuntuOneClient/App.config 2010-10-05 15:20:36 +0000
1934+++ src/UbuntuOneClient/App.config 2010-10-08 12:04:40 +0000
1935@@ -29,6 +29,11 @@
1936 </factoryAdapter>
1937 </logging>
1938 </common>
1939+
1940+ <system.serviceModel>
1941+ <bindings configSource="Config\serviceModel.bindings.config"/>
1942+ <client configSource="Config\serviceModel.client.config"/>
1943+ </system.serviceModel>
1944
1945 <spring>
1946 <context>
1947
1948=== added file 'src/UbuntuOneClient/Config/serviceModel.bindings.config'
1949--- src/UbuntuOneClient/Config/serviceModel.bindings.config 1970-01-01 00:00:00 +0000
1950+++ src/UbuntuOneClient/Config/serviceModel.bindings.config 2010-10-08 12:04:40 +0000
1951@@ -0,0 +1,23 @@
1952+<?xml version="1.0" encoding="utf-8" ?>
1953+<bindings>
1954+ <!-- Named pipe binding provided to allow better performance that the wsHttpBinding -->
1955+ <netNamedPipeBinding>
1956+ <binding name="namedPipeBinding"
1957+ closeTimeout="00:01:00"
1958+ openTimeout="00:01:00"
1959+ receiveTimeout="00:10:00"
1960+ sendTimeout="00:01:00"
1961+ transactionFlow="false"
1962+ transferMode="Buffered"
1963+ transactionProtocol="OleTransactions"
1964+ hostNameComparisonMode="StrongWildcard"
1965+ maxBufferPoolSize="524288"
1966+ maxBufferSize="65536"
1967+ maxConnections="10"
1968+ maxReceivedMessageSize="65536">
1969+ <security mode="Transport">
1970+ <transport protectionLevel="EncryptAndSign" />
1971+ </security>
1972+ </binding>
1973+ </netNamedPipeBinding>
1974+</bindings>
1975\ No newline at end of file
1976
1977=== added file 'src/UbuntuOneClient/Config/serviceModel.client.config'
1978--- src/UbuntuOneClient/Config/serviceModel.client.config 1970-01-01 00:00:00 +0000
1979+++ src/UbuntuOneClient/Config/serviceModel.client.config 2010-10-08 12:04:40 +0000
1980@@ -0,0 +1,38 @@
1981+<?xml version="1.0" encoding="utf-8" ?>
1982+<client>
1983+ <endpoint name="configurationEndpoint"
1984+ address="net.pipe://localhost/UbuntuOne/SyncConfigurationService/$username$"
1985+ binding="netNamedPipeBinding"
1986+ bindingConfiguration="namedPipeBinding"
1987+ contract="Canonical.UbuntuOne.Common.ISyncConfiguration">
1988+ </endpoint>
1989+
1990+ <endpoint name="syncDaemonEndpoint"
1991+ address="net.pipe://localhost/UbuntuOne/SyncDaemonService/$username$"
1992+ binding="netNamedPipeBinding"
1993+ bindingConfiguration="namedPipeBinding"
1994+ contract="Canonical.UbuntuOne.Common.ISyncDaemon">
1995+ </endpoint>
1996+
1997+ <endpoint name="fileManagerEndpoint"
1998+ address="net.pipe://localhost/UbuntuOne/SyncFileManagerService/$username$"
1999+ binding="netNamedPipeBinding"
2000+ bindingConfiguration="namedPipeBinding"
2001+ contract="Canonical.UbuntuOne.Common.ISyncFileManager">
2002+ </endpoint>
2003+
2004+ <endpoint name="syncFoldersEndpoint"
2005+ address="net.pipe://localhost/UbuntuOne/SyncFoldersService/$username$"
2006+ binding="netNamedPipeBinding"
2007+ bindingConfiguration="namedPipeBinding"
2008+ contract="Canonical.UbuntuOne.Common.ISyncFolders">
2009+ </endpoint>
2010+
2011+ <endpoint name="syncSharesEndpoint"
2012+ address="net.pipe://localhost/UbuntuOne/SyncSharesService/$username$"
2013+ binding="netNamedPipeBinding"
2014+ bindingConfiguration="namedPipeBinding"
2015+ contract="Canonical.UbuntuOne.Common.ISyncShares">
2016+ </endpoint>
2017+
2018+</client>
2019\ No newline at end of file
2020
2021=== modified file 'src/UbuntuOneClient/Program.cs'
2022--- src/UbuntuOneClient/Program.cs 2010-09-09 09:11:07 +0000
2023+++ src/UbuntuOneClient/Program.cs 2010-10-08 12:04:40 +0000
2024@@ -39,6 +39,7 @@
2025 private INotificationIconView _notifyIcon;
2026 private readonly object _notifyIconLock = new object();
2027 private Thread _updatesThread;
2028+ private static readonly ConfigurationLocator _configLocator = new ConfigurationLocator();
2029
2030 #region DI Properties for testability
2031
2032@@ -148,10 +149,40 @@
2033 [STAThread]
2034 static void Main()
2035 {
2036+ // HACK: This technique is quite interesting although it is a hack. The idea is the following,
2037+ // due to the fact that we want to run a WCF service per user and not per machine, we have to be able
2038+ // to determine at runtime the users pipe names. To do so we would use a config file per user
2039+ // but ofcourse we cannot do that at install time becuase we do not know all the user.
2040+ //
2041+ // Ideally we would not have to do this hack and the ConfiguratonManager would allow to refrest the app
2042+ // condifuration, but it is not the case!! On top of that you cannot do so by using reflection :(
2043+ //
2044+ // The trick is simple, we use the normal app.config to start the program, once the program is started we create
2045+ // a new app domain where we will be doing all the work. Because we are the ones starting the app domain, we can
2046+ // tell him to use a diff configuration, which means that we poit to a new config for this user that points to
2047+ // the correct pipe names :D
2048+ // This is not cheap, now we have a dummy app domain, the one that start this program, and a second app domain that
2049+ // is used to load the spring context plus all the WCT setting. The SeriesAppDomain is the one that really does
2050+ // the job.
2051+ _logger.Info("Updating config");
2052 // init the objects container
2053- ObjectsContainer.Initialize(new SpringContainer());
2054- var program = ObjectsContainer.GetImplementationOf<Program>();
2055- program.StartApplication();
2056+ // Setup information for the new appdomain.
2057+ var setup = new AppDomainSetup
2058+ {
2059+ ConfigurationFile = _configLocator.GetCurrentUserClientConfiguration()
2060+ };
2061+
2062+ // Create the new appdomain with the new config.
2063+ var executionAppDomain = AppDomain.CreateDomain("ClientAppDomain", AppDomain.CurrentDomain.Evidence, setup);
2064+
2065+ // Call the write config method in that appdomain.
2066+ executionAppDomain.DoCallBack(() =>
2067+ {
2068+ ObjectsContainer.Initialize(new SpringContainer());
2069+ var program = ObjectsContainer.GetImplementationOf<Program>();
2070+ program.StartApplication();
2071+ });
2072+
2073 }
2074 }
2075 }
2076
2077=== modified file 'src/UbuntuOneClient/UbuntuOneClient.csproj'
2078--- src/UbuntuOneClient/UbuntuOneClient.csproj 2010-10-06 08:48:18 +0000
2079+++ src/UbuntuOneClient/UbuntuOneClient.csproj 2010-10-08 12:04:40 +0000
2080@@ -51,6 +51,9 @@
2081 <Reference Include="System.Core">
2082 <RequiredTargetFramework>3.5</RequiredTargetFramework>
2083 </Reference>
2084+ <Reference Include="System.ServiceModel">
2085+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
2086+ </Reference>
2087 <Reference Include="System.Xml.Linq">
2088 <RequiredTargetFramework>3.5</RequiredTargetFramework>
2089 </Reference>
2090@@ -90,6 +93,12 @@
2091 <None Include="Config\log4net.config">
2092 <CopyToOutputDirectory>Always</CopyToOutputDirectory>
2093 </None>
2094+ <None Include="Config\serviceModel.bindings.config">
2095+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
2096+ </None>
2097+ <None Include="Config\serviceModel.client.config">
2098+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
2099+ </None>
2100 <None Include="Properties\Settings.settings">
2101 <Generator>SettingsSingleFileGenerator</Generator>
2102 <LastGenOutput>Settings.Designer.cs</LastGenOutput>
2103
2104=== modified file 'src/UbuntuOneClient/objects.xml'
2105--- src/UbuntuOneClient/objects.xml 2010-09-28 08:41:33 +0000
2106+++ src/UbuntuOneClient/objects.xml 2010-10-08 12:04:40 +0000
2107@@ -56,4 +56,38 @@
2108 <property name="Application"
2109 ref="Application" />
2110 </object>
2111+
2112+ <!-- ############################################################### -->
2113+ <!-- WCF services configuration -->
2114+ <!-- ############################################################### -->
2115+
2116+ <object id="ConfigurationChannelFactory"
2117+ type="System.ServiceModel.ChannelFactory&lt;Canonical.UbuntuOne.Common.ISyncConfiguration>, System.ServiceModel">
2118+ <constructor-arg name="endpointConfigurationName"
2119+ value="configurationEndpoint" />
2120+ </object>
2121+
2122+ <object id="SyncDaemonChannelFactory"
2123+ type="System.ServiceModel.ChannelFactory&lt;Canonical.UbuntuOne.Common.ISyncDaemon>, System.ServiceModel">
2124+ <constructor-arg name="endpointConfigurationName"
2125+ value="syncDaemonEndpoint" />
2126+ </object>
2127+
2128+ <object id="FileManagerChannelFactory"
2129+ type="System.ServiceModel.ChannelFactory&lt;Canonical.UbuntuOne.Common.ISyncFileManager>, System.ServiceModel">
2130+ <constructor-arg name="endpointConfigurationName"
2131+ value="fileManagerEndpoint" />
2132+ </object>
2133+
2134+ <object id="SyncFoldersChannelFactory"
2135+ type="System.ServiceModel.ChannelFactory&lt;Canonical.UbuntuOne.Common.ISyncFolders>, System.ServiceModel">
2136+ <constructor-arg name="endpointConfigurationName"
2137+ value="syncFoldersEndpoint" />
2138+ </object>
2139+
2140+ <object id="SyncSharesChannelFactory"
2141+ type="System.ServiceModel.ChannelFactory&lt;Canonical.UbuntuOne.Common.ISyncShares>, System.ServiceModel">
2142+ <constructor-arg name="endpointConfigurationName"
2143+ value="syncSharesEndpoint" />
2144+ </object>
2145 </objects>
2146\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: