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
=== modified file 'install/UbuntuOne7.wxs'
--- install/UbuntuOne7.wxs 2010-10-08 12:04:40 +0000
+++ install/UbuntuOne7.wxs 2010-10-08 12:04:40 +0000
@@ -95,6 +95,16 @@
95 Name="UbuntuOne">95 Name="UbuntuOne">
96 <Directory Id="DaemonDir"96 <Directory Id="DaemonDir"
97 Name="Daemon">97 Name="Daemon">
98 <Component Id="DaemonAutostart"
99 Guid="c3308920-d2d1-11df-bd3b-0800200c9a66">
100 <RegistryValue Id="Daemon.rst"
101 Root="HKCU"
102 Key="Software\Microsoft\Windows\CurrentVersion\Run"
103 Name="Ubuntu One Client Daemon"
104 Value="[DaemonDir]Canonical.UbuntuOne.ProcessDispatcher.exe"
105 Type="string"/>
106 <Condition>UBUNTUONeDAEMON_START_VIA_REGISTRY</Condition>
107 </Component>
98 <Component Id="DaemonCommonLibComponent" 108 <Component Id="DaemonCommonLibComponent"
99 Guid="a609b650-94b5-11df-981c-0800200c9a66">109 Guid="a609b650-94b5-11df-981c-0800200c9a66">
100 <File Id="Canonical.UbuntuOne.Common.dll" 110 <File Id="Canonical.UbuntuOne.Common.dll"
@@ -118,22 +128,6 @@
118 DiskId="1" 128 DiskId="1"
119 Source="build_results\Daemon\Canonical.UbuntuOne.ProcessDispatcher.exe" 129 Source="build_results\Daemon\Canonical.UbuntuOne.ProcessDispatcher.exe"
120 KeyPath="yes"/>130 KeyPath="yes"/>
121 <!-- Install, start and stop service using the msi -->
122 <ServiceInstall Id="ProcessDispatcher.exe"
123 Name="UbuntuOne"
124 DisplayName="Ubuntu One Sync Daemon"
125 Type="ownProcess"
126 Interactive="no"
127 Start="auto"
128 Vital="yes"
129 ErrorControl="ignore"
130 Description="Provides a central process that manages the Ubuntu One sync daemon." />
131 <ServiceControl Id="ProcessDispatcherControl"
132 Name="UbuntuOne"
133 Start="install"
134 Stop="uninstall"
135 Remove="uninstall"
136 Wait="yes" />
137 </Component>131 </Component>
138 <Component Id="DaemonProgramComponentConfig" 132 <Component Id="DaemonProgramComponentConfig"
139 Guid="6ac2f100-94bb-11df-981c-0800200c9a66">133 Guid="6ac2f100-94bb-11df-981c-0800200c9a66">
@@ -474,6 +468,22 @@
474 Source="build_results\Client\Config\log4net.config" 468 Source="build_results\Client\Config\log4net.config"
475 KeyPath="yes"/>469 KeyPath="yes"/>
476 </Component>470 </Component>
471 <Component Id="ClientConfigServiceModelBindings"
472 Guid="a76325d0-d200-11df-bd3b-0800200c9a66">
473 <File Id="serviceModelBindings_client"
474 Name="serviceModel.bindings.config"
475 DiskId="1"
476 Source="build_results\Client\Config\serviceModel.bindings.config"
477 KeyPath="yes"/>
478 </Component>
479 <Component Id="ClientConfigServiceModelClient"
480 Guid="b2b8c250-d200-11df-bd3b-0800200c9a66">
481 <File Id="serviceModelClient_client"
482 Name="serviceModel.client.config"
483 DiskId="1"
484 Source="build_results\Client\Config\serviceModel.client.config"
485 KeyPath="yes"/>
486 </Component>
477 </Directory>487 </Directory>
478 <Directory Id="U1SyncExecutable"488 <Directory Id="U1SyncExecutable"
479 Name="U1Sync">489 Name="U1Sync">
@@ -987,7 +997,10 @@
987 <ComponentRef Id="UbuntuOneClientConfig" />997 <ComponentRef Id="UbuntuOneClientConfig" />
988 <ComponentRef Id="UbuntuOneClientPdb" />998 <ComponentRef Id="UbuntuOneClientPdb" />
989 <ComponentRef Id="ClientConfigLog4Net" />999 <ComponentRef Id="ClientConfigLog4Net" />
1000 <ComponentRef Id="ClientConfigServiceModelBindings" />
1001 <ComponentRef Id="ClientConfigServiceModelClient" />
990 <!-- Client auto start -->1002 <!-- Client auto start -->
1003 <ComponentRef Id="DaemonAutostart" />
991 <ComponentRef Id="UbuntuOneClietnAutostart" />1004 <ComponentRef Id="UbuntuOneClietnAutostart" />
992 <!-- U1Sync pacakge -->1005 <!-- U1Sync pacakge -->
993 <ComponentRef Id="CTypesComponent" />1006 <ComponentRef Id="CTypesComponent" />
@@ -1050,10 +1063,6 @@
1050 <ComponentRef Id="UbuntuSSOViews" />1063 <ComponentRef Id="UbuntuSSOViews" />
1051 <ComponentRef Id="Newtonsoft.Json" />1064 <ComponentRef Id="Newtonsoft.Json" />
1052 </Feature>1065 </Feature>
1053
1054 <InstallExecuteSequence>
1055 <ScheduleReboot After='InstallFinalize' />
1056 </InstallExecuteSequence>
10571066
1058 <UI Id="WixUI_Minimal_No_License">1067 <UI Id="WixUI_Minimal_No_License">
1059 <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />1068 <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
10601069
=== modified file 'install/UbuntuOneXP.wxs'
--- install/UbuntuOneXP.wxs 2010-10-08 12:04:40 +0000
+++ install/UbuntuOneXP.wxs 2010-10-08 12:04:40 +0000
@@ -95,6 +95,16 @@
95 Name="UbuntuOne">95 Name="UbuntuOne">
96 <Directory Id="DaemonDir"96 <Directory Id="DaemonDir"
97 Name="Daemon">97 Name="Daemon">
98 <Component Id="DaemonAutostart"
99 Guid="c3308920-d2d1-11df-bd3b-0800200c9a66">
100 <RegistryValue Id="Daemon.rst"
101 Root="HKCU"
102 Key="Software\Microsoft\Windows\CurrentVersion\Run"
103 Name="Ubuntu One Client Daemon"
104 Value="[DaemonDir]Canonical.UbuntuOne.ProcessDispatcher.exe"
105 Type="string"/>
106 <Condition>UBUNTUONeDAEMON_START_VIA_REGISTRY</Condition>
107 </Component>
98 <Component Id="DaemonCommonLibComponent" 108 <Component Id="DaemonCommonLibComponent"
99 Guid="a609b650-94b5-11df-981c-0800200c9a66">109 Guid="a609b650-94b5-11df-981c-0800200c9a66">
100 <File Id="Canonical.UbuntuOne.Common.dll" 110 <File Id="Canonical.UbuntuOne.Common.dll"
@@ -118,22 +128,6 @@
118 DiskId="1" 128 DiskId="1"
119 Source="build_results\Daemon\Canonical.UbuntuOne.ProcessDispatcher.exe" 129 Source="build_results\Daemon\Canonical.UbuntuOne.ProcessDispatcher.exe"
120 KeyPath="yes"/>130 KeyPath="yes"/>
121 <!-- Install, start and stop service using the msi -->
122 <ServiceInstall Id="ProcessDispatcher.exe"
123 Name="UbuntuOne"
124 DisplayName="Ubuntu One Sync Daemon"
125 Type="ownProcess"
126 Interactive="no"
127 Start="auto"
128 Vital="yes"
129 ErrorControl="ignore"
130 Description="Provides a central process that manages the Ubuntu One sync daemon." />
131 <ServiceControl Id="ProcessDispatcherControl"
132 Name="UbuntuOne"
133 Start="install"
134 Stop="uninstall"
135 Remove="uninstall"
136 Wait="yes" />
137 </Component>131 </Component>
138 <Component Id="DaemonProgramComponentConfig" 132 <Component Id="DaemonProgramComponentConfig"
139 Guid="6ac2f100-94bb-11df-981c-0800200c9a66">133 Guid="6ac2f100-94bb-11df-981c-0800200c9a66">
@@ -474,6 +468,22 @@
474 Source="build_results\Client\Config\log4net.config" 468 Source="build_results\Client\Config\log4net.config"
475 KeyPath="yes"/>469 KeyPath="yes"/>
476 </Component>470 </Component>
471 <Component Id="ClientConfigServiceModelBindings"
472 Guid="a76325d0-d200-11df-bd3b-0800200c9a66">
473 <File Id="serviceModelBindings_client"
474 Name="serviceModel.bindings.config"
475 DiskId="1"
476 Source="build_results\Client\Config\serviceModel.bindings.config"
477 KeyPath="yes"/>
478 </Component>
479 <Component Id="ClientConfigServiceModelClient"
480 Guid="b2b8c250-d200-11df-bd3b-0800200c9a66">
481 <File Id="serviceModelClient_client"
482 Name="serviceModel.client.config"
483 DiskId="1"
484 Source="build_results\Client\Config\serviceModel.client.config"
485 KeyPath="yes"/>
486 </Component>
477 </Directory>487 </Directory>
478 <Directory Id="U1SyncExecutable"488 <Directory Id="U1SyncExecutable"
479 Name="U1Sync">489 Name="U1Sync">
@@ -784,7 +794,10 @@
784 <ComponentRef Id="UbuntuOneClientConfig" />794 <ComponentRef Id="UbuntuOneClientConfig" />
785 <ComponentRef Id="UbuntuOneClientPdb" />795 <ComponentRef Id="UbuntuOneClientPdb" />
786 <ComponentRef Id="ClientConfigLog4Net" />796 <ComponentRef Id="ClientConfigLog4Net" />
787 <!-- Client auto start -->797 <ComponentRef Id="ClientConfigServiceModelBindings" />
798 <ComponentRef Id="ClientConfigServiceModelClient" />
799 <!-- auto start -->
800 <ComponentRef Id="DaemonAutostart" />
788 <ComponentRef Id="UbuntuOneClietnAutostart" />801 <ComponentRef Id="UbuntuOneClietnAutostart" />
789 <!-- U1Sync pacakge -->802 <!-- U1Sync pacakge -->
790 <ComponentRef Id="CTypesComponent" />803 <ComponentRef Id="CTypesComponent" />
@@ -823,10 +836,6 @@
823 <ComponentRef Id="Newtonsoft.Json" />836 <ComponentRef Id="Newtonsoft.Json" />
824 </Feature>837 </Feature>
825 838
826 <InstallExecuteSequence>
827 <ScheduleReboot After='InstallFinalize' />
828 </InstallExecuteSequence>
829
830 <UI Id="WixUI_Minimal_No_License">839 <UI Id="WixUI_Minimal_No_License">
831 <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />840 <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
832 <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />841 <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
833842
=== modified file 'src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj'
--- src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj 2010-10-06 10:43:02 +0000
+++ src/Canonical.UbuntuOne.Client/Canonical.UbuntuOne.Client.csproj 2010-10-08 12:04:40 +0000
@@ -102,7 +102,13 @@
102 <RequiredTargetFramework>3.0</RequiredTargetFramework>102 <RequiredTargetFramework>3.0</RequiredTargetFramework>
103 </Reference>103 </Reference>
104 <Reference Include="System" />104 <Reference Include="System" />
105 <Reference Include="System.Core">
106 <RequiredTargetFramework>3.5</RequiredTargetFramework>
107 </Reference>
105 <Reference Include="System.Data" />108 <Reference Include="System.Data" />
109 <Reference Include="System.ServiceModel">
110 <RequiredTargetFramework>3.0</RequiredTargetFramework>
111 </Reference>
106 <Reference Include="System.Web" />112 <Reference Include="System.Web" />
107 <Reference Include="System.Xml" />113 <Reference Include="System.Xml" />
108 <Reference Include="WindowsBase">114 <Reference Include="WindowsBase">
109115
=== modified file 'src/Canonical.UbuntuOne.Client/Notification/NotificationIconPresenter.cs'
--- src/Canonical.UbuntuOne.Client/Notification/NotificationIconPresenter.cs 2010-10-08 12:04:40 +0000
+++ src/Canonical.UbuntuOne.Client/Notification/NotificationIconPresenter.cs 2010-10-08 12:04:40 +0000
@@ -17,15 +17,15 @@
17 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>17 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
18 */18 */
19using System;19using System;
20using System.Diagnostics;
21using System.IO;20using System.IO;
21using System.ServiceModel;
22using Canonical.Ubuntu.SSO;22using Canonical.Ubuntu.SSO;
23using Canonical.UbuntuOne.Client.Preferences;23using Canonical.UbuntuOne.Client.Preferences;
24using Canonical.UbuntuOne.Common;24using Canonical.UbuntuOne.Common;
25using Canonical.UbuntuOne.Common.Aop;25using Canonical.UbuntuOne.Common.Aop;
26using Canonical.UbuntuOne.Common.Net;
26using Canonical.UbuntuOne.Common.Utils;27using Canonical.UbuntuOne.Common.Utils;
27using log4net;28using log4net;
28using Microsoft.Win32;
2929
30namespace Canonical.UbuntuOne.Client.Notification30namespace Canonical.UbuntuOne.Client.Notification
31{31{
@@ -53,8 +53,6 @@
53 private ISSOCredentialsProvider _ssoProvider;53 private ISSOCredentialsProvider _ssoProvider;
54 private ILog _logger;54 private ILog _logger;
55 private readonly object _loggerLock = new object();55 private readonly object _loggerLock = new object();
56 private string _u1SyncPath;
57 private readonly object _u1SyncPathLock = new object();
5856
59 #endregion57 #endregion
6058
@@ -95,6 +93,7 @@
95 /// Gets and sets the message box used to send messages to the user.93 /// Gets and sets the message box used to send messages to the user.
96 /// </summary>94 /// </summary>
97 public IMessageBox MessageBox { get; set; }95 public IMessageBox MessageBox { get; set; }
96
98 /// <summary>97 /// <summary>
99 /// Gets and sets the provider that will return the credentials used in ubuntu one.98 /// Gets and sets the provider that will return the credentials used in ubuntu one.
100 /// </summary>99 /// </summary>
@@ -130,6 +129,17 @@
130 }129 }
131 }130 }
132131
132 /// <summary>
133 /// Gets and sets the channel factory that can be used to create communication objects that are used to
134 /// interact with the sync daemon.
135 /// </summary>
136 public ChannelFactory<ISyncDaemon> SyncDaemonChannelFactory { get; set; }
137
138 /// <summary>
139 /// Gets and sets the service caller that is used to do the house keeping when calling a service.
140 /// </summary>
141 public IServiceCaller ServiceCaller { get; set; }
142
133 #endregion143 #endregion
134144
135 #region Properties145 #region Properties
@@ -153,36 +163,6 @@
153 set { _logger = value; }163 set { _logger = value; }
154 }164 }
155165
156 private string U1SyncPath
157 {
158 get
159 {
160 if (_u1SyncPath == null)
161 {
162 lock (_u1SyncPathLock)
163 {
164 try
165 {
166 using (var softwareEntry = Registry.LocalMachine.OpenSubKey("SOFTWARE"))
167 using (var canonicalEntry = softwareEntry.OpenSubKey("Canonical"))
168 using (var ubuntuOneEntry = canonicalEntry.OpenSubKey("UbuntuOne"))
169 {
170 _u1SyncPath = (string) ubuntuOneEntry.GetValue("InstallationPath");
171 _u1SyncPath = Path.Combine(_u1SyncPath, "Client");
172 _u1SyncPath = Path.Combine(_u1SyncPath, "U1Sync");
173 }
174 }
175 catch(NullReferenceException)
176 {
177 // thrown when we did not find the key, that is, not correct installation
178 Logger.Error("Registry key HKLM/Software/Canonical/UbuntuOne is not present!!!");
179 }
180 }
181 }
182 return _u1SyncPath;
183 }
184 }
185
186 #endregion166 #endregion
187167
188 #region Constructors168 #region Constructors
@@ -256,64 +236,16 @@
256 // check if the credentials are for us236 // check if the credentials are for us
257 if (args.ApplicationName != "UbuntuOne") return;237 if (args.ApplicationName != "UbuntuOne") return;
258 Logger.Info("Got the UbuntuOne credentials!");238 Logger.Info("Got the UbuntuOne credentials!");
259 // get the string used to pass the credentials to the python code.
260 var tokens = string.Format("{0}:{1}:{2}:{3}",
261 args.Credentials["Token"],
262 args.Credentials["TokenSecret"],
263 args.Credentials["ConsumerKey"],
264 args.Credentials["ConsumerSecret"]);
265 var oneDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),239 var oneDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
266 "UbuntuOne");240 "UbuntuOne");
267 // ensure that the path can be handled by the python code241 // ensure that the path can be handled by the python code
268 oneDir = oneDir.Replace("\\", "\\\\");242 oneDir = oneDir.Replace("\\", "\\\\");
269 if (!Directory.Exists(oneDir))243 // call the ISyncService to perform the manual sync
270 {244
271 Logger.InfoFormat("Creating dir '{0}'", oneDir);245 var syncServiceChannel = SyncDaemonChannelFactory.CreateChannel();
272 Directory.CreateDirectory(oneDir);246 ServiceCaller.SaveProxyCall(
273 }247 () => syncServiceChannel.ManualSync(oneDir, args.Credentials["Token"], args.Credentials["TokenSecret"],args.Credentials["ConsumerKey"], args.Credentials["ConsumerSecret"]),
274248 (ICommunicationObject) syncServiceChannel);
275 if (!Directory.Exists(Path.Combine(oneDir, ".ubuntuone-sync")))
276 {
277 // init the directory
278 var init = new Process
279 {
280 StartInfo =
281 {
282 WorkingDirectory = U1SyncPath,
283 FileName = Path.Combine(U1SyncPath, "main.exe"),
284 Arguments = String.Format(" --init \"{0}\" --oauth {1}", oneDir, tokens),
285 UseShellExecute = false,
286 RedirectStandardOutput = true,
287 RedirectStandardError = true,
288 CreateNoWindow = true,
289 WindowStyle = ProcessWindowStyle.Hidden
290
291 }
292 };
293 Logger.InfoFormat("Executing u1sync with args: {0}", init.StartInfo.Arguments);
294 init.Start();
295 init.WaitForExit();
296 Logger.InfoFormat("StandarOutput from u1sync is: {0}", init.StandardOutput.ReadToEnd());
297 Logger.ErrorFormat("StandardError from u1sync is: {0}", init.StandardError.ReadToEnd());
298 init.Close();
299
300 }
301
302 var proc = new Process
303 {
304 StartInfo =
305 {
306 WorkingDirectory = U1SyncPath,
307 FileName = Path.Combine(U1SyncPath, "main.exe"),
308 Arguments = String.Format("\"{0}\" --oauth {1}", oneDir, tokens),
309 UseShellExecute = false,
310 RedirectStandardOutput = true,
311 RedirectStandardError = true,
312 CreateNoWindow = true,
313 WindowStyle = ProcessWindowStyle.Hidden
314 }
315 };
316 proc.Start();
317 }249 }
318250
319 [DebugLogged]251 [DebugLogged]
320252
=== modified file 'src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj'
--- src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj 2010-10-08 12:04:40 +0000
+++ src/Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common.csproj 2010-10-08 12:04:40 +0000
@@ -79,14 +79,20 @@
79 <Compile Include="Net\HttpWebRequestFactory.cs" />79 <Compile Include="Net\HttpWebRequestFactory.cs" />
80 <Compile Include="Net\IHttpWebRequestFactory.cs" />80 <Compile Include="Net\IHttpWebRequestFactory.cs" />
81 <Compile Include="Net\IHttpWebRequest.cs" />81 <Compile Include="Net\IHttpWebRequest.cs" />
82 <Compile Include="Net\IServiceCaller.cs" />
83 <Compile Include="Net\ServiceCaller.cs" />
82 <Compile Include="OperationContracts\IEventNotifier.cs" />84 <Compile Include="OperationContracts\IEventNotifier.cs" />
83 <Compile Include="Security\IAuthentication.cs" />85 <Compile Include="Security\IAuthentication.cs" />
84 <Compile Include="Threading\IDispatcher.cs" />86 <Compile Include="Threading\IDispatcher.cs" />
85 <Compile Include="Threading\WpfDispatcher.cs" />87 <Compile Include="Threading\WpfDispatcher.cs" />
88 <Compile Include="Utils\ApplicationLocatorException.cs" />
86 <Compile Include="Utils\ApplicationWrapper.cs" />89 <Compile Include="Utils\ApplicationWrapper.cs" />
90 <Compile Include="Utils\ConfigurationLocator.cs" />
91 <Compile Include="Utils\Constants.cs" />
87 <Compile Include="Utils\Explorer.cs" />92 <Compile Include="Utils\Explorer.cs" />
88 <Compile Include="Utils\ExplorerException.cs" />93 <Compile Include="Utils\ExplorerException.cs" />
89 <Compile Include="Utils\IApplication.cs" />94 <Compile Include="Utils\IApplication.cs" />
95 <Compile Include="Utils\IApplicationLocator.cs" />
90 <Compile Include="Utils\IExplorer.cs" />96 <Compile Include="Utils\IExplorer.cs" />
91 <Compile Include="IMessageBox.cs" />97 <Compile Include="IMessageBox.cs" />
92 <Compile Include="IProcessManager.cs" />98 <Compile Include="IProcessManager.cs" />
@@ -132,6 +138,7 @@
132 </Compile>138 </Compile>
133 <Compile Include="Update\SelfUpdateException.cs" />139 <Compile Include="Update\SelfUpdateException.cs" />
134 <Compile Include="Update\UpdatingPresenter.cs" />140 <Compile Include="Update\UpdatingPresenter.cs" />
141 <Compile Include="Utils\UbuntuOneApplicationLocator.cs" />
135 <Compile Include="Validation\ArgumentValidation.cs" />142 <Compile Include="Validation\ArgumentValidation.cs" />
136 <Compile Include="Validation\EqualityValidationExtensions.cs" />143 <Compile Include="Validation\EqualityValidationExtensions.cs" />
137 <Compile Include="Validation\MultiException.cs" />144 <Compile Include="Validation\MultiException.cs" />
138145
=== added file 'src/Canonical.UbuntuOne.Common/Net/IServiceCaller.cs'
--- src/Canonical.UbuntuOne.Common/Net/IServiceCaller.cs 1970-01-01 00:00:00 +0000
+++ src/Canonical.UbuntuOne.Common/Net/IServiceCaller.cs 2010-10-08 12:04:40 +0000
@@ -0,0 +1,50 @@
1/*
2 * Copyright 2010 Canonical Ltd.
3 *
4 * This file is part of UbuntuOne on Windows.
5 *
6 * UbuntuOne on Windows is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version
8 * as published by the Free Software Foundation.
9 *
10 * Ubuntu One on Windows is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
19 */
20using System;
21using System.ServiceModel;
22
23namespace Canonical.UbuntuOne.Common.Net
24{
25 /// <summary>
26 /// Interface to be implemented by those objects that allow to call WCF service and that will
27 /// perform all the house keeping required.
28 /// </summary>
29 public interface IServiceCaller
30 {
31 /// <summary>
32 /// A method that allows to correctly clean a channel when executing a call to
33 /// a web service. This method takes an action that should be using the channel
34 /// and the casted channel so that we can access the ICommunicationObject methods.
35 /// </summary>
36 /// <param name="action">The action to be performed that uses the channel.</param>
37 /// <param name="channel">The casted channel that will be used to clean its state.</param>
38 void SaveProxyCall(Action action, ICommunicationObject channel);
39
40 /// <summary>
41 /// A method that allows to correctly clean a channel when executing a call to
42 /// a web service. This method takes an action that should be using the channel
43 /// and the casted channel so that we can access the ICommunicationObject methods.
44 /// </summary>
45 /// <param name="action">An action that has a wcf proxy call.</param>
46 /// <param name="channel">The casted channel that will be used to clean its state.</param>
47 /// <returns>The result of the action</returns>
48 TResult SaveProxyCall<TResult>(Func<TResult> action, ICommunicationObject channel);
49 }
50}
051
=== added file 'src/Canonical.UbuntuOne.Common/Net/ServiceCaller.cs'
--- src/Canonical.UbuntuOne.Common/Net/ServiceCaller.cs 1970-01-01 00:00:00 +0000
+++ src/Canonical.UbuntuOne.Common/Net/ServiceCaller.cs 2010-10-08 12:04:40 +0000
@@ -0,0 +1,105 @@
1/*
2 * Copyright 2010 Canonical Ltd.
3 *
4 * This file is part of UbuntuOne on Windows.
5 *
6 * UbuntuOne on Windows is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version
8 * as published by the Free Software Foundation.
9 *
10 * Ubuntu One on Windows is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
19 */
20using System;
21using System.ServiceModel;
22
23namespace Canonical.UbuntuOne.Common.Net
24{
25 /// <summary>
26 /// Implementation of the IServiceCaller interface that performs the required house keeping used when
27 /// calling a WCF service.
28 /// </summary>
29 internal class ServiceCaller : IServiceCaller
30 {
31 #region Implementation of IServiceCaller
32
33 /// <summary>
34 /// A method that allows to correctly clean a channel when executing a call to
35 /// a web service. This method takes an action that should be using the channel
36 /// and the casted channel so that we can access the ICommunicationObject methods.
37 /// </summary>
38 /// <param name="action">The action to be performed that uses the channel.</param>
39 /// <param name="channel">The casted channel that will be used to clean its state.</param>
40 public void SaveProxyCall(Action action, ICommunicationObject channel)
41 {
42 try
43 {
44 action();
45 channel.Close();
46 }
47 catch (FaultException)
48 {
49 channel.Close();
50 }
51 catch (CommunicationException)
52 {
53 channel.Abort();
54 }
55 catch (TimeoutException)
56 {
57 channel.Abort();
58 }
59 catch (Exception)
60 {
61 channel.Abort();
62 throw;
63 }
64 }
65
66 /// <summary>
67 /// A method that allows to correctly clean a channel when executing a call to
68 /// a web service. This method takes an action that should be using the channel
69 /// and the casted channel so that we can access the ICommunicationObject methods.
70 /// </summary>
71 /// <param name="action">An action that has a wcf proxy call.</param>
72 /// <param name="channel">The casted channel that will be used to clean its state.</param>
73 /// <returns>The result of the action</returns>
74 public TResult SaveProxyCall<TResult>(Func<TResult> action, ICommunicationObject channel)
75 {
76 try
77 {
78 var result = action();
79 channel.Close();
80 return result;
81 }
82 catch (FaultException)
83 {
84 channel.Close();
85 }
86 catch (CommunicationException)
87 {
88 channel.Abort();
89 }
90 catch (TimeoutException)
91 {
92 channel.Abort();
93 }
94 catch (Exception)
95 {
96 channel.Abort();
97 throw;
98 }
99
100 return default(TResult);
101 }
102
103 #endregion
104 }
105}
0106
=== modified file 'src/Canonical.UbuntuOne.Common/OperationContracts/ISyncDaemon.cs'
--- src/Canonical.UbuntuOne.Common/OperationContracts/ISyncDaemon.cs 2010-08-30 17:30:31 +0000
+++ src/Canonical.UbuntuOne.Common/OperationContracts/ISyncDaemon.cs 2010-10-08 12:04:40 +0000
@@ -29,6 +29,17 @@
29 [ServiceContract]29 [ServiceContract]
30 public interface ISyncDaemon30 public interface ISyncDaemon
31 {31 {
32 /// <summary>
33 /// Allows to perform a manual sync of the root Ubuntu One directory in the provided path using the oauth information
34 /// passed to the service.
35 /// </summary>
36 /// <param name="path">The path to which the root of the Ubuntu One folder will be sync.</param>
37 /// <param name="token">The token from oauth.</param>
38 /// <param name="tokenSecret">The token secret from oauth.</param>
39 /// <param name="consumerKey">The consumer key from oauth.</param>
40 /// <param name="consumerSecret">The consumer secret from oauth.</param>
41 [OperationContract]
42 void ManualSync(string path, string token, string tokenSecret, string consumerKey, string consumerSecret);
3243
33 /// <summary>44 /// <summary>
34 /// Allows to start the daemon by a client.45 /// Allows to start the daemon by a client.
@@ -57,12 +68,6 @@
57 bool TryStop();68 bool TryStop();
5869
59 /// <summary>70 /// <summary>
60 /// Allows the user to perform a manual sync of his machine with the ubuntu one server.
61 /// </summary>
62 [OperationContract]
63 void ManualSync();
64
65 /// <summary>
66 /// Returns the port number of the socket that the synd daemo is listening to for communication.71 /// Returns the port number of the socket that the synd daemo is listening to for communication.
67 /// </summary>72 /// </summary>
68 /// <returns></returns>73 /// <returns></returns>
6974
=== added file 'src/Canonical.UbuntuOne.Common/Utils/ApplicationLocatorException.cs'
--- src/Canonical.UbuntuOne.Common/Utils/ApplicationLocatorException.cs 1970-01-01 00:00:00 +0000
+++ src/Canonical.UbuntuOne.Common/Utils/ApplicationLocatorException.cs 2010-10-08 12:04:40 +0000
@@ -0,0 +1,58 @@
1/*
2 * Copyright 2010 Canonical Ltd.
3 *
4 * This file is part of UbuntuOne on Windows.
5 *
6 * UbuntuOne on Windows is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version
8 * as published by the Free Software Foundation.
9 *
10 * Ubuntu One on Windows is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
19 */
20using System;
21
22namespace Canonical.UbuntuOne.Common.Utils
23{
24 /// <summary>
25 /// Base exception class thrown when there have been issues finding an application in the system.
26 /// </summary>
27 public class ApplicationLocatorException : Exception
28 {
29 /// <summary>
30 /// Creates a new instance of the class.
31 /// </summary>
32 public ApplicationLocatorException()
33 {
34
35 }
36
37 /// <summary>
38 /// Creates a new instance of the class that will have the given message.
39 /// </summary>
40 /// <param name="message">The message to be carried by the exception.</param>
41 public ApplicationLocatorException(string message)
42 : base(message)
43 {
44
45 }
46
47 /// <summary>
48 /// Creates a new instance of the class that will have the given message and inner exception.
49 /// </summary>
50 /// <param name="message">The message to be carried by the exception.</param>
51 /// <param name="innerException">The inner exception.</param>
52 public ApplicationLocatorException(string message, Exception innerException)
53 : base(message, innerException)
54 {
55
56 }
57 }
58}
059
=== added file 'src/Canonical.UbuntuOne.Common/Utils/ConfigurationLocator.cs'
--- src/Canonical.UbuntuOne.Common/Utils/ConfigurationLocator.cs 1970-01-01 00:00:00 +0000
+++ src/Canonical.UbuntuOne.Common/Utils/ConfigurationLocator.cs 2010-10-08 12:04:40 +0000
@@ -0,0 +1,305 @@
1/*
2 * Copyright 2010 Canonical Ltd.
3 *
4 * This file is part of UbuntuOne on Windows.
5 *
6 * UbuntuOne on Windows is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version
8 * as published by the Free Software Foundation.
9 *
10 * Ubuntu One on Windows is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
19 */
20using System;
21using System.IO;
22using System.Security.Principal;
23using Canonical.UbuntuOne.ProcessDispatcher;
24using log4net;
25
26namespace Canonical.UbuntuOne.Common.Utils
27{
28 /// <summary>
29 /// This class allow to find the configuration to be used in the application accodring to the user that started the
30 /// process. This allows to point to different configurations that will ensure that there are no service collitions
31 /// by usint the users name space.
32 /// </summary>
33 public class ConfigurationLocator
34 {
35 #region Variables
36
37 private const string UserToken = "$username$";
38 private const string ConfigFolder = "Config";
39 private const string DaemonAppConfigName = "Canonical.UbuntuOne.ProcessDispatcher.exe.config";
40 private const string UserAppConfigName = "UbuntuOneClient.exe.config";
41 private const string Log4NetConfig = "log4net.config";
42 private const string BehavioursConfig = "serviceModel.behaviours.config";
43 private const string BindingsConfig = "serviceModel.bindings.config";
44 private const string ServicesConfig = "serviceModel.services.config";
45 private const string ClientConfig = "serviceModel.client.config";
46 private string _userConfigPath;
47 private readonly object _userConfigPathLock = new object();
48 private readonly object _loggerLock = new object();
49 private ILog _logger;
50
51 #endregion
52
53 #region Properties
54
55 /// <summary>
56 /// Allows to get and set the logger that will be used.
57 /// </summary>
58 internal ILog Logger
59 {
60 get
61 {
62 if (_logger == null)
63 {
64 lock (_loggerLock)
65 {
66 _logger = LogManager.GetLogger(typeof(ConfigurationLocator));
67 }
68 }
69 return _logger;
70 }
71 set
72 {
73 _logger = value;
74 }
75 }
76
77 /// <summary>
78 /// Gets the path to be used to store the users configuration.
79 /// </summary>
80 private string UserDaemonConfigPath
81 {
82 get
83 {
84 if (_userConfigPath == null)
85 {
86 lock (_userConfigPathLock)
87 {
88 _userConfigPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
89 _userConfigPath = Path.Combine(_userConfigPath, "UbuntuOne");
90 _userConfigPath = Path.Combine(_userConfigPath, "Daemon");
91 }
92 }
93 return _userConfigPath;
94 }
95 }
96
97 private string UserClientConfigPath
98 {
99 get
100 {
101 if (_userConfigPath == null)
102 {
103 lock (_userConfigPathLock)
104 {
105 _userConfigPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
106 _userConfigPath = Path.Combine(_userConfigPath, "UbuntuOne");
107 _userConfigPath = Path.Combine(_userConfigPath, "Client");
108 }
109 }
110 return _userConfigPath;
111 }
112 }
113 /// <summary>
114 /// Gets and sets the application locator that will be used to find the location of the
115 /// root configuration.
116 /// </summary>
117 public IApplicationLocator ApplicationLocator { get; set; }
118
119 #endregion
120
121 #region Constructors
122
123 /// <summary>
124 /// Creates a new configuration locator with the default app locator.
125 /// </summary>
126 public ConfigurationLocator()
127 : this(new UbuntuOneApplicationLocator())
128 {
129
130 }
131
132 /// <summary>
133 /// Creates a new configuration locator with a pass app locator.
134 /// </summary>
135 /// <param name="applicationLocator">The object that will return the path to known applications.</param>
136 public ConfigurationLocator(IApplicationLocator applicationLocator)
137 {
138 ApplicationLocator = applicationLocator;
139 }
140
141 #endregion
142
143 #region Helpers
144
145 /// <summary>
146 /// Returns if the configuration for the current user daemon is present.
147 /// </summary>
148 /// <returns>A flag stating if the configuraton is present.</returns>
149 private bool IsDaemonConfigurationPresent()
150 {
151 // the configuration is store per user in his location to
152 // ensure that he is the only one using it
153 return Directory.Exists(UserDaemonConfigPath)
154 && File.Exists(Path.Combine(UserDaemonConfigPath, DaemonAppConfigName))
155 && Directory.Exists(Path.Combine(UserDaemonConfigPath, ConfigFolder));
156 }
157
158 /// <summary>
159 /// Returns if the configuration for the current user client is present
160 /// </summary>
161 /// <returns>A flag stating if the configuration is present.</returns>
162 private bool IsClientConfigurationPresent()
163 {
164 return Directory.Exists(UserClientConfigPath)
165 && File.Exists(Path.Combine(UserClientConfigPath, UserAppConfigName))
166 && Directory.Exists(Path.Combine(UserClientConfigPath, ConfigFolder));
167 }
168
169 /// <summary>
170 /// Methods that updates all the urls in the services named pipes so that they are ersonalized
171 /// for the current user.
172 /// </summary>
173 private void UpdateDaemonServicesConfiguration()
174 {
175 var servicesFullPath = Path.Combine(UserDaemonConfigPath, ConfigFolder);
176 servicesFullPath = Path.Combine(servicesFullPath, ServicesConfig);
177 string userConfig;
178 using (var fileReader = new StreamReader(new FileStream(servicesFullPath, FileMode.Open)))
179 {
180 userConfig = fileReader.ReadToEnd();
181 }
182 userConfig = userConfig.Replace(UserToken, WindowsIdentity.GetCurrent().Name);
183 File.Delete(servicesFullPath);
184 using (var fileWriter = new StreamWriter(new FileStream(servicesFullPath, FileMode.CreateNew)))
185 {
186 fileWriter.Write(userConfig);
187 }
188 }
189
190 /// <summary>
191 /// Updates the clients configurations so that the clients uses the correct named pipes.
192 /// </summary>
193 private void UpdateClientConfiguration()
194 {
195 var clientsFullPath = Path.Combine(UserClientConfigPath, ConfigFolder);
196 clientsFullPath = Path.Combine(clientsFullPath, ClientConfig);
197 string userConfig;
198 using(var fileReader = new StreamReader(new FileStream(clientsFullPath, FileMode.Open)))
199 {
200 userConfig = fileReader.ReadToEnd();
201 }
202 userConfig = userConfig.Replace(UserToken, WindowsIdentity.GetCurrent().Name);
203 File.Delete(clientsFullPath);
204 using(var fileWriter = new StreamWriter(new FileStream(clientsFullPath, FileMode.CreateNew)))
205 {
206 fileWriter.Write(userConfig);
207 }
208 }
209
210 /// <summary>
211 /// Method that copies all the configuration that is deployed by the msi to the users config location.
212 /// </summary>
213 private void CopyDaemonRootConfiguration()
214 {
215 if (!Directory.Exists(UserDaemonConfigPath))
216 {
217 Logger.DebugFormat("Creating dir {0}", UserDaemonConfigPath);
218 Directory.CreateDirectory(UserDaemonConfigPath);
219 }
220 // we need to copy the info from the root path
221 var daemonPath = ApplicationLocator.GetApplicationPath(Constants.U1DaemonAppName);
222 File.Copy(Path.Combine(daemonPath, DaemonAppConfigName), Path.Combine(UserDaemonConfigPath, DaemonAppConfigName));
223 // we copy the config files for log4net and the service model
224 var userConfigFolderPath = Path.Combine(UserDaemonConfigPath, ConfigFolder);
225 if (!Directory.Exists(userConfigFolderPath))
226 {
227 Logger.DebugFormat("Create dir {0}", userConfigFolderPath);
228 Directory.CreateDirectory(userConfigFolderPath);
229 }
230 var rootConfigFolderPath = Path.Combine(daemonPath, ConfigFolder);
231 File.Copy(Path.Combine(rootConfigFolderPath, Log4NetConfig), Path.Combine(userConfigFolderPath, Log4NetConfig));
232 File.Copy(Path.Combine(rootConfigFolderPath, BehavioursConfig), Path.Combine(userConfigFolderPath, BehavioursConfig));
233 File.Copy(Path.Combine(rootConfigFolderPath, BindingsConfig), Path.Combine(userConfigFolderPath, BindingsConfig));
234 File.Copy(Path.Combine(rootConfigFolderPath, ServicesConfig), Path.Combine(userConfigFolderPath, ServicesConfig));
235 }
236
237 private void CopyClietnRootConfiguration()
238 {
239 if (!Directory.Exists(UserClientConfigPath))
240 {
241 Logger.DebugFormat("Creating dir {0}", UserClientConfigPath);
242 Directory.CreateDirectory(UserClientConfigPath);
243 }
244 // we need to copy the info from the root path
245 var clientPath = ApplicationLocator.GetApplicationPath(Constants.U1ClientAppName);
246 File.Copy(Path.Combine(clientPath, UserAppConfigName), Path.Combine(UserClientConfigPath, UserAppConfigName));
247 // we copy the config files for log4net and the service model
248 var userConfigFolderPath = Path.Combine(UserClientConfigPath, ConfigFolder);
249 if (!Directory.Exists(userConfigFolderPath))
250 {
251 Logger.DebugFormat("Create dir {0}", userConfigFolderPath);
252 Directory.CreateDirectory(userConfigFolderPath);
253 }
254 var rootConfigFolderPath = Path.Combine(clientPath, ConfigFolder);
255 File.Copy(Path.Combine(rootConfigFolderPath, Log4NetConfig), Path.Combine(userConfigFolderPath, Log4NetConfig));
256 File.Copy(Path.Combine(rootConfigFolderPath, BindingsConfig), Path.Combine(userConfigFolderPath, BindingsConfig));
257 File.Copy(Path.Combine(rootConfigFolderPath, ClientConfig), Path.Combine(userConfigFolderPath, ClientConfig));
258 }
259
260 #endregion
261
262
263
264 ///<summary>
265 /// Returns the path with the configuration to be used for the dameon for the current user.
266 ///</summary>
267 ///<returns>The path to the configuration to be used by the current user when running the daemon.</returns>
268 public string GetCurrentUserDaemonConfiguration()
269 {
270 if (!IsDaemonConfigurationPresent())
271 {
272 Logger.Info("The users config does not exist!");
273 // we copy the root configuration
274 CopyDaemonRootConfiguration();
275 // we update the name pipe so that the use the current user name as part of the path
276 UpdateDaemonServicesConfiguration();
277 }
278 var appConfigPath = Path.Combine(UserDaemonConfigPath, DaemonAppConfigName);
279 Logger.InfoFormat("The config path is {0}", appConfigPath);
280 return appConfigPath;
281 }
282
283 /// <summary>
284 /// Returns the path with the configuration to be used for the client for the current user.
285 /// </summary>
286 /// <returns>The path to the configuration to use.</returns>
287 public string GetCurrentUserClientConfiguration()
288 {
289 if (!IsClientConfigurationPresent())
290 {
291 Logger.Info("The users config does not exist!");
292 // we copy the root configuration
293 CopyClietnRootConfiguration();
294 // we update the name pipe so that the use the current user name as part of the path
295 UpdateClientConfiguration();
296 }
297 var appConfigPath = Path.Combine(UserClientConfigPath, UserAppConfigName);
298 Logger.InfoFormat("The config path is {0}", appConfigPath);
299 return appConfigPath;
300
301 return null;
302 }
303
304 }
305}
0306
=== added file 'src/Canonical.UbuntuOne.Common/Utils/Constants.cs'
--- src/Canonical.UbuntuOne.Common/Utils/Constants.cs 1970-01-01 00:00:00 +0000
+++ src/Canonical.UbuntuOne.Common/Utils/Constants.cs 2010-10-08 12:04:40 +0000
@@ -0,0 +1,36 @@
1/*
2 * Copyright 2010 Canonical Ltd.
3 *
4 * This file is part of UbuntuOne on Windows.
5 *
6 * UbuntuOne on Windows is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version
8 * as published by the Free Software Foundation.
9 *
10 * Ubuntu One on Windows is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
19 */
20using System;
21using System.Collections.Generic;
22using System.Linq;
23using System.Text;
24
25namespace Canonical.UbuntuOne.ProcessDispatcher
26{
27 /// <summary>
28 /// Contains a set of constants share among different classes.
29 /// </summary>
30 public static class Constants
31 {
32 public const string U1SyncAppName = "U1Sync";
33 public const string U1DaemonAppName = "U1Daemon";
34 public const string U1ClientAppName = "U1Client";
35 }
36}
037
=== added file 'src/Canonical.UbuntuOne.Common/Utils/IApplicationLocator.cs'
--- src/Canonical.UbuntuOne.Common/Utils/IApplicationLocator.cs 1970-01-01 00:00:00 +0000
+++ src/Canonical.UbuntuOne.Common/Utils/IApplicationLocator.cs 2010-10-08 12:04:40 +0000
@@ -0,0 +1,44 @@
1/*
2 * Copyright 2010 Canonical Ltd.
3 *
4 * This file is part of UbuntuOne on Windows.
5 *
6 * UbuntuOne on Windows is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version
8 * as published by the Free Software Foundation.
9 *
10 * Ubuntu One on Windows is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
19 */
20using System.Collections.Generic;
21
22namespace Canonical.UbuntuOne.Common.Utils
23{
24 /// <summary>
25 /// Interface to be implemented by those object that know how to locate an application in the system so that
26 /// it can be called in a different process.
27 /// </summary>
28 public interface IApplicationLocator
29 {
30 /// <summary>
31 /// Returns a collecion with the names of the known application by the object.
32 /// </summary>
33 /// <returns>A string with all the different applications that the object knows how to locate.</returns>
34 ICollection<string> GetKnownApplications();
35
36 /// <summary>
37 /// Returns the full path in the system of the application that mathces the given name.
38 /// </summary>
39 /// <param name="appName">The name of the application we want to locate.</param>
40 /// <returns>The full path of the application with the given name.</returns>
41 string GetApplicationPath(string appName);
42
43 }
44}
045
=== added file 'src/Canonical.UbuntuOne.Common/Utils/UbuntuOneApplicationLocator.cs'
--- src/Canonical.UbuntuOne.Common/Utils/UbuntuOneApplicationLocator.cs 1970-01-01 00:00:00 +0000
+++ src/Canonical.UbuntuOne.Common/Utils/UbuntuOneApplicationLocator.cs 2010-10-08 12:04:40 +0000
@@ -0,0 +1,153 @@
1/*
2 * Copyright 2010 Canonical Ltd.
3 *
4 * This file is part of UbuntuOne on Windows.
5 *
6 * UbuntuOne on Windows is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version
8 * as published by the Free Software Foundation.
9 *
10 * Ubuntu One on Windows is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
19 */
20using System;
21using System.Collections.Generic;
22using System.IO;
23using Canonical.UbuntuOne.Common.Win32;
24using Canonical.UbuntuOne.ProcessDispatcher;
25using log4net;
26using Microsoft.Win32;
27
28namespace Canonical.UbuntuOne.Common.Utils
29{
30 /// <summary>
31 /// Implementation of an IApplicationLocator that does know how to locate the U1 applictions.
32 /// </summary>
33 public class UbuntuOneApplicationLocator : IApplicationLocator
34 {
35 #region Variables
36
37 private readonly IRegistryKey _localMachineKey;
38 private string _installationPath;
39 private readonly object _installationPathLock = new object();
40 private ILog _logger;
41 private readonly object _loggerLock = new object();
42
43 #endregion
44
45 #region Constructors
46
47 public UbuntuOneApplicationLocator()
48 : this(new RegistryKeyWrapper(Registry.LocalMachine))
49 {
50
51 }
52 public UbuntuOneApplicationLocator(IRegistryKey registryKey)
53 {
54 _localMachineKey = registryKey;
55 }
56
57 #endregion
58
59 #region Properties
60
61 /// <summary>
62 /// Gets and sets the logger used by the class.
63 /// </summary>
64 internal ILog Logger
65 {
66 get
67 {
68 if (_logger == null)
69 {
70 lock (_loggerLock)
71 {
72 _logger = LogManager.GetLogger(typeof(UbuntuOneApplicationLocator));
73 }
74 }
75 return _logger;
76 }
77 set { _logger = value; }
78 }
79
80 #endregion
81
82 #region Helpers
83
84 private string InstallationPath
85 {
86 get
87 {
88 if (_installationPath == null)
89 {
90 lock (_installationPathLock)
91 {
92 try
93 {
94 using (var softwareEntry = _localMachineKey.OpenSubKey("SOFTWARE"))
95 using (var canonicalEntry = softwareEntry.OpenSubKey("Canonical"))
96 using (var ubuntuOneEntry = canonicalEntry.OpenSubKey("UbuntuOne"))
97 {
98 _installationPath = (string)ubuntuOneEntry.GetValue("InstallationPath");
99 }
100 }
101 catch (NullReferenceException e)
102 {
103 // thrown when we did not find the key, that is, not correct installation
104 Logger.Error("Registry key HKLM/Software/Canonical/UbuntuOne is not present!!!");
105 throw new ApplicationLocatorException("Registry key HKLM/Software/Canonical/UbuntuOne is not present!!!", e);
106 }
107 }
108 }
109 return _installationPath;
110 }
111 }
112 #endregion
113
114 #region Implementation of IApplicationLocator
115
116 /// <summary>
117 /// Returns a collecion with the names of the known application by the object.
118 /// </summary>
119 /// <returns>A string with all the different applications that the object knows how to locate.</returns>
120 public ICollection<string> GetKnownApplications()
121 {
122 return new[] { Constants.U1SyncAppName, Constants.U1DaemonAppName, Constants.U1ClientAppName };
123 }
124
125 /// <summary>
126 /// Returns the full path in the system of the application that mathces the given name.
127 /// </summary>
128 /// <param name="appName">The name of the application we want to locate.</param>
129 /// <returns>The full path of the application with the given name.</returns>
130 public string GetApplicationPath(string appName)
131 {
132 if (string.Compare(appName, Constants.U1SyncAppName, true) == 0)
133 {
134 var u1sync = Path.Combine(InstallationPath, "Client");
135 u1sync = Path.Combine(u1sync, "U1Sync");
136 return u1sync;
137 }
138 if (string.Compare(appName, Constants.U1DaemonAppName, true) == 0)
139 {
140 var u1daemon = Path.Combine(InstallationPath, "Daemon");
141 return u1daemon;
142 }
143 if(string.Compare(appName, Constants.U1ClientAppName, true) == 0)
144 {
145 var u1client = Path.Combine(InstallationPath, "Client");
146 return u1client;
147 }
148 throw new ApplicationLocatorException(string.Format("Application {0} is not known.", appName));
149 }
150
151 #endregion
152 }
153}
0154
=== modified file 'src/Canonical.UbuntuOne.Common/objects.xml'
--- src/Canonical.UbuntuOne.Common/objects.xml 2010-10-05 10:14:44 +0000
+++ src/Canonical.UbuntuOne.Common/objects.xml 2010-10-08 12:04:40 +0000
@@ -45,6 +45,13 @@
45 <object id="Application"45 <object id="Application"
46 type="Canonical.UbuntuOne.Common.Utils.ApplicationWrapper, Canonical.UbuntuOne.Common" />46 type="Canonical.UbuntuOne.Common.Utils.ApplicationWrapper, Canonical.UbuntuOne.Common" />
4747
48 <object id="ServiceCaller"
49 type="Canonical.UbuntuOne.Common.Net.ServiceCaller, Canonical.UbuntuOne.Common" />
50
51 <object id="ApplicationLocator"
52 type="Canonical.UbuntuOne.Common.Utils.UbuntuOneApplicationLocator, Canonical.UbuntuOne.Common"
53 autowire="autodetect"/>
54
48 <!-- ######################################################################################## -->55 <!-- ######################################################################################## -->
49 <!-- Net Objects -->56 <!-- Net Objects -->
50 <!-- ######################################################################################## -->57 <!-- ######################################################################################## -->
5158
=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/App.config'
--- src/Canonical.UbuntuOne.ProcessDispatcher/App.config 2010-08-18 09:49:09 +0000
+++ src/Canonical.UbuntuOne.ProcessDispatcher/App.config 2010-10-08 12:04:40 +0000
@@ -32,19 +32,10 @@
32 32
33 <!-- Spring configuration -->33 <!-- Spring configuration -->
34 <spring>34 <spring>
35 <parsers>
36 <parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data" />
37 </parsers>
38 <context>35 <context>
39 <resource uri="assembly://Canonical.UbuntuOne.ProcessDispatcher/Canonical.UbuntuOne.ProcessDispatcher/objects.xml" />36 <resource uri="assembly://Canonical.UbuntuOne.ProcessDispatcher/Canonical.UbuntuOne.ProcessDispatcher/objects.xml" />
37 <resource uri="assembly://Canonical.UbuntuOne.Common/Canonical.UbuntuOne.Common/objects.xml" />
40 </context>38 </context>
41 <objects xmlns="http://www.springframework.net"
42 xmlns:db="http://www.springframework.net/database">
43 <!-- most internal objects definition is in the embeded objects.xml file here you will just find the db configuration -->
44 <db:provider id="DbProvider"
45 provider="SQLite-1.0.65"
46 connectionString="Data Source=UbuntuOne.db;Version=3;FailIfMissing=False;Compress=True"/>
47 </objects>
48 </spring>39 </spring>
4940
50 <system.serviceModel>41 <system.serviceModel>
5142
=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/Canonical.UbuntuOne.ProcessDispatcher.csproj'
--- src/Canonical.UbuntuOne.ProcessDispatcher/Canonical.UbuntuOne.ProcessDispatcher.csproj 2010-10-06 10:43:02 +0000
+++ src/Canonical.UbuntuOne.ProcessDispatcher/Canonical.UbuntuOne.ProcessDispatcher.csproj 2010-10-08 12:04:40 +0000
@@ -6,7 +6,7 @@
6 <ProductVersion>9.0.21022</ProductVersion>6 <ProductVersion>9.0.21022</ProductVersion>
7 <SchemaVersion>2.0</SchemaVersion>7 <SchemaVersion>2.0</SchemaVersion>
8 <ProjectGuid>{8D353509-C095-4E72-A693-3CEE97704C7D}</ProjectGuid>8 <ProjectGuid>{8D353509-C095-4E72-A693-3CEE97704C7D}</ProjectGuid>
9 <OutputType>Exe</OutputType>9 <OutputType>WinExe</OutputType>
10 <RootNamespace>Canonical.UbuntuOne.ProcessDispatcher</RootNamespace>10 <RootNamespace>Canonical.UbuntuOne.ProcessDispatcher</RootNamespace>
11 <AssemblyName>Canonical.UbuntuOne.ProcessDispatcher</AssemblyName>11 <AssemblyName>Canonical.UbuntuOne.ProcessDispatcher</AssemblyName>
12 <FileUpgradeFlags>12 <FileUpgradeFlags>
@@ -30,6 +30,8 @@
30 <UseApplicationTrust>false</UseApplicationTrust>30 <UseApplicationTrust>false</UseApplicationTrust>
31 <BootstrapperEnabled>true</BootstrapperEnabled>31 <BootstrapperEnabled>true</BootstrapperEnabled>
32 <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>32 <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
33 <StartupObject>
34 </StartupObject>
33 </PropertyGroup>35 </PropertyGroup>
34 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">36 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
35 <DebugSymbols>true</DebugSymbols>37 <DebugSymbols>true</DebugSymbols>
@@ -89,18 +91,14 @@
89 <Compile Include="..\Version.cs">91 <Compile Include="..\Version.cs">
90 <Link>Properties\Version.cs</Link>92 <Link>Properties\Version.cs</Link>
91 </Compile>93 </Compile>
94 <Compile Include="SyncDaemonWindowsService.cs">
95 </Compile>
92 <Compile Include="CallerContext.cs" />96 <Compile Include="CallerContext.cs" />
93 <Compile Include="EventNotifier.cs" />97 <Compile Include="EventNotifier.cs" />
94 <Compile Include="ICallerContext.cs" />98 <Compile Include="ICallerContext.cs" />
95 <Compile Include="Program.cs" />99 <Compile Include="Program.cs" />
96 <Compile Include="ProjectInstaller.cs">
97 <SubType>Component</SubType>
98 </Compile>
99 <Compile Include="SyncConfigurationService.cs" />100 <Compile Include="SyncConfigurationService.cs" />
100 <Compile Include="SyncDaemonService.cs" />101 <Compile Include="SyncDaemonService.cs" />
101 <Compile Include="SyncDaemonWindowsService.cs">
102 <SubType>Component</SubType>
103 </Compile>
104 <Compile Include="SyncFileManagerService.cs" />102 <Compile Include="SyncFileManagerService.cs" />
105 <Compile Include="SyncFoldersService.cs" />103 <Compile Include="SyncFoldersService.cs" />
106 <Compile Include="SyncSharesService.cs" />104 <Compile Include="SyncSharesService.cs" />
@@ -128,13 +126,13 @@
128 <HintPath>..\..\lib\Spring.Net\Spring.Services.dll</HintPath>126 <HintPath>..\..\lib\Spring.Net\Spring.Services.dll</HintPath>
129 </Reference>127 </Reference>
130 <Reference Include="System" />128 <Reference Include="System" />
129 <Reference Include="System.configuration" />
131 <Reference Include="System.Data" />130 <Reference Include="System.Data" />
132 <Reference Include="System.Data.SQLite, Version=1.0.65.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">131 <Reference Include="System.Data.SQLite, Version=1.0.65.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
133 <SpecificVersion>False</SpecificVersion>132 <SpecificVersion>False</SpecificVersion>
134 <HintPath>..\..\lib\SQLite\System.Data.SQLite.DLL</HintPath>133 <HintPath>..\..\lib\SQLite\System.Data.SQLite.DLL</HintPath>
135 </Reference>134 </Reference>
136 <Reference Include="System.ServiceProcess" />135 <Reference Include="System.ServiceProcess" />
137 <Reference Include="System.Configuration.Install" />
138 <Reference Include="System.ServiceModel">136 <Reference Include="System.ServiceModel">
139 </Reference>137 </Reference>
140 <Reference Include="System.Core">138 <Reference Include="System.Core">
141139
=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.behaviours.config'
--- src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.behaviours.config 2010-07-26 15:57:10 +0000
+++ src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.behaviours.config 2010-10-08 12:04:40 +0000
@@ -2,7 +2,7 @@
2<behaviors>2<behaviors>
3 <serviceBehaviors>3 <serviceBehaviors>
4 <behavior name="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior">4 <behavior name="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior">
5 <serviceMetadata httpGetEnabled="true" />5 <serviceMetadata httpGetEnabled="false" />
6 <serviceDebug includeExceptionDetailInFaults="true" />6 <serviceDebug includeExceptionDetailInFaults="true" />
7 </behavior>7 </behavior>
8 </serviceBehaviors>8 </serviceBehaviors>
99
=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.services.config'
--- src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.services.config 2010-07-26 15:57:10 +0000
+++ src/Canonical.UbuntuOne.ProcessDispatcher/Config/serviceModel.services.config 2010-10-08 12:04:40 +0000
@@ -4,10 +4,10 @@
4 name="SyncConfigurationService">4 name="SyncConfigurationService">
5 <host>5 <host>
6 <baseAddresses>6 <baseAddresses>
7 <add baseAddress="http://localhost:8000/UbuntuOne/SyncConfigurationService"/>7 <add baseAddress="net.pipe://localhost/UbuntuOne/SyncConfigurationService/$username$"/>
8 </baseAddresses>8 </baseAddresses>
9 </host>9 </host>
10 <endpoint address="net.pipe://localhost/UbuntuOne/SyncConfigurationService"10 <endpoint address="net.pipe://localhost/UbuntuOne/SyncConfigurationService/$username$"
11 binding="netNamedPipeBinding"11 binding="netNamedPipeBinding"
12 bindingConfiguration="namedPipeBinding"12 bindingConfiguration="namedPipeBinding"
13 contract="Canonical.UbuntuOne.Common.ISyncConfiguration">13 contract="Canonical.UbuntuOne.Common.ISyncConfiguration">
@@ -15,19 +15,16 @@
15 <dns value="localhost" />15 <dns value="localhost" />
16 </identity>16 </identity>
17 </endpoint>17 </endpoint>
18 <endpoint address="mex"
19 binding="mexHttpBinding"
20 contract="IMetadataExchange" />
21 </service>18 </service>
2219
23 <service behaviorConfiguration="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior"20 <service behaviorConfiguration="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior"
24 name="SyncDaemonService">21 name="SyncDaemonService">
25 <host>22 <host>
26 <baseAddresses>23 <baseAddresses>
27 <add baseAddress="http://localhost:8000/UbuntuOne/SyncDaemonService"/>24 <add baseAddress="net.pipe://localhost/UbuntuOne/SyncDaemonService/$username$"/>
28 </baseAddresses>25 </baseAddresses>
29 </host>26 </host>
30 <endpoint address="net.pipe://localhost/UbuntuOne/SyncDaemonService"27 <endpoint address="net.pipe://localhost/UbuntuOne/SyncDaemonService/$username$"
31 binding="netNamedPipeBinding"28 binding="netNamedPipeBinding"
32 bindingConfiguration="namedPipeBinding"29 bindingConfiguration="namedPipeBinding"
33 contract="Canonical.UbuntuOne.Common.ISyncDaemon">30 contract="Canonical.UbuntuOne.Common.ISyncDaemon">
@@ -35,19 +32,16 @@
35 <dns value="localhost" />32 <dns value="localhost" />
36 </identity>33 </identity>
37 </endpoint>34 </endpoint>
38 <endpoint address="mex"
39 binding="mexHttpBinding"
40 contract="IMetadataExchange" />
41 </service>35 </service>
4236
43 <service behaviorConfiguration="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior"37 <service behaviorConfiguration="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior"
44 name="SyncFileManagerService">38 name="SyncFileManagerService">
45 <host>39 <host>
46 <baseAddresses>40 <baseAddresses>
47 <add baseAddress="http://localhost:8000/UbuntuOne/SyncFileManagerService"/>41 <add baseAddress="net.pipe://localhost/UbuntuOne/SyncFileManagerService/$username$"/>
48 </baseAddresses>42 </baseAddresses>
49 </host>43 </host>
50 <endpoint address="net.pipe://localhost/UbuntuOne/SyncFileManagerService"44 <endpoint address="net.pipe://localhost/UbuntuOne/SyncFileManagerService/$username$"
51 binding="netNamedPipeBinding"45 binding="netNamedPipeBinding"
52 bindingConfiguration="namedPipeBinding"46 bindingConfiguration="namedPipeBinding"
53 contract="Canonical.UbuntuOne.Common.ISyncFileManager">47 contract="Canonical.UbuntuOne.Common.ISyncFileManager">
@@ -55,19 +49,16 @@
55 <dns value="localhost" />49 <dns value="localhost" />
56 </identity>50 </identity>
57 </endpoint>51 </endpoint>
58 <endpoint address="mex"
59 binding="mexHttpBinding"
60 contract="IMetadataExchange" />
61 </service>52 </service>
6253
63 <service behaviorConfiguration="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior"54 <service behaviorConfiguration="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior"
64 name="SyncFoldersService">55 name="SyncFoldersService">
65 <host>56 <host>
66 <baseAddresses>57 <baseAddresses>
67 <add baseAddress="http://localhost:8000/UbuntuOne/SyncFoldersService"/>58 <add baseAddress="net.pipe://localhost/UbuntuOne/SyncFoldersService/$username$"/>
68 </baseAddresses>59 </baseAddresses>
69 </host>60 </host>
70 <endpoint address="net.pipe://localhost/UbuntuOne/SyncFoldersService"61 <endpoint address="net.pipe://localhost/UbuntuOne/SyncFoldersService/$username$"
71 binding="netNamedPipeBinding"62 binding="netNamedPipeBinding"
72 bindingConfiguration="namedPipeBinding"63 bindingConfiguration="namedPipeBinding"
73 contract="Canonical.UbuntuOne.Common.ISyncFolders">64 contract="Canonical.UbuntuOne.Common.ISyncFolders">
@@ -75,19 +66,16 @@
75 <dns value="localhost" />66 <dns value="localhost" />
76 </identity>67 </identity>
77 </endpoint>68 </endpoint>
78 <endpoint address="mex"
79 binding="mexHttpBinding"
80 contract="IMetadataExchange" />
81 </service>69 </service>
8270
83 <service behaviorConfiguration="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior"71 <service behaviorConfiguration="Canonical.UbuntuOne.ProcessDispatcher.DefaultBehavior"
84 name="SyncSharesService">72 name="SyncSharesService">
85 <host>73 <host>
86 <baseAddresses>74 <baseAddresses>
87 <add baseAddress="http://localhost:8000/UbuntuOne/SyncSharesService"/>75 <add baseAddress="net.pipe://localhost/UbuntuOne/SyncSharesService"/>
88 </baseAddresses>76 </baseAddresses>
89 </host>77 </host>
90 <endpoint address="net.pipe://localhost/UbuntuOne/SyncSharesService"78 <endpoint address="net.pipe://localhost/UbuntuOne/SyncSharesService/$username$"
91 binding="netNamedPipeBinding"79 binding="netNamedPipeBinding"
92 bindingConfiguration="namedPipeBinding"80 bindingConfiguration="namedPipeBinding"
93 contract="Canonical.UbuntuOne.Common.ISyncShares">81 contract="Canonical.UbuntuOne.Common.ISyncShares">
@@ -95,8 +83,5 @@
95 <dns value="localhost" />83 <dns value="localhost" />
96 </identity>84 </identity>
97 </endpoint>85 </endpoint>
98 <endpoint address="mex"
99 binding="mexHttpBinding"
100 contract="IMetadataExchange" />
101 </service>86 </service>
102</services>87</services>
103\ No newline at end of file88\ No newline at end of file
10489
=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/Program.cs'
--- src/Canonical.UbuntuOne.ProcessDispatcher/Program.cs 2010-09-08 08:24:05 +0000
+++ src/Canonical.UbuntuOne.ProcessDispatcher/Program.cs 2010-10-08 12:04:40 +0000
@@ -17,29 +17,63 @@
17 * 17 *
18 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>18 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
19 */19 */
20using System.ServiceProcess;20using System;
21using Canonical.UbuntuOne.Common.Container;21using Canonical.UbuntuOne.Common.Container;
22using Canonical.UbuntuOne.Common.Utils;
22using log4net;23using log4net;
2324
24namespace Canonical.UbuntuOne.ProcessDispatcher25namespace Canonical.UbuntuOne.ProcessDispatcher
25{26{
26 static class Program27
27 {28 static class Program
28 private static ILog _logger = LogManager.GetLogger(typeof (Program));29 {
2930 private static readonly ILog _logger = LogManager.GetLogger(typeof(Program));
30 /// <summary>31 private static readonly ConfigurationLocator _configLocator = new ConfigurationLocator();
31 /// This method starts the service.32
32 /// </summary>33 /// <summary>
33 static void Main()34 /// This method starts the service.
34 {35 /// </summary>
35 _logger.Debug("Starting services.");36 static void Main()
36 // use the IoC to get the implementation of the SyncDaemon service, the IoC will take care of 37 {
37 // setting the object correctly.38 // HACK: This technique is quite interesting although it is a hack. The idea is the following,
38 ObjectsContainer.Initialize(new SpringContainer());39 // due to the fact that we want to run a WCF service per user and not per machine, we have to be able
39 var syncDaemonWindowsService = ObjectsContainer.GetImplementationOf<SyncDaemonWindowsService>();40 // to determine at runtime the users pipe names. To do so we would use a config file per user
40 41 // but ofcourse we cannot do that at install time becuase we do not know all the user.
41 // To run more than one service you have to add them here42 //
42 ServiceBase.Run(new ServiceBase[] { syncDaemonWindowsService });43 // Ideally we would not have to do this hack and the ConfiguratonManager would allow to refrest the app
43 }44 // condifuration, but it is not the case!! On top of that you cannot do so by using reflection :(
44 }45 //
46 // The trick is simple, we use the normal app.config to start the program, once the program is started we create
47 // a new app domain where we will be doing all the work. Because we are the ones starting the app domain, we can
48 // tell him to use a diff configuration, which means that we poit to a new config for this user that points to
49 // the correct pipe names :D
50 // This is not cheap, now we have a dummy app domain, the one that start this program, and a second app domain that
51 // is used to load the spring context plus all the WCT setting. The SeriesAppDomain is the one that really does
52 // the job.
53 _logger.Debug("Redirecting configuration");
54
55 // Setup information for the new appdomain.
56 var setup = new AppDomainSetup
57 {
58 ConfigurationFile = _configLocator.GetCurrentUserDaemonConfiguration()
59 };
60
61 // Create the new appdomain with the new config.
62 var executionAppDomain = AppDomain.CreateDomain("ServicesAppDomain", AppDomain.CurrentDomain.Evidence, setup);
63
64 // Call the write config method in that appdomain.
65 executionAppDomain.DoCallBack(() =>
66 {
67 _logger.Debug("Starting services.");
68 // use the IoC to get the implementation of the SyncDaemon service, the IoC will take care of
69 // setting the object correctly.
70 ObjectsContainer.Initialize(new SpringContainer());
71 var syncDaemonWindowsService = ObjectsContainer.GetImplementationOf<SyncDaemonWindowsService>();
72 // To run more than one service you have to add them here
73 syncDaemonWindowsService.Start();
74 while (true) ;
75 });
76
77 }
78 }
45}79}
4680
=== removed file 'src/Canonical.UbuntuOne.ProcessDispatcher/ProjectInstaller.cs'
--- src/Canonical.UbuntuOne.ProcessDispatcher/ProjectInstaller.cs 2010-09-08 08:24:05 +0000
+++ src/Canonical.UbuntuOne.ProcessDispatcher/ProjectInstaller.cs 1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
1/*
2 * Copyright 2010 Canonical Ltd.
3 *
4 * This file is part of UbuntuOne on Windows.
5 *
6 * UbuntuOne on Windows is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version
8 * as published by the Free Software Foundation.
9 *
10 * Ubuntu One on Windows is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with UbuntuOne for Windows. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
19 */
20using System.ComponentModel;
21using System.Configuration.Install;
22using System.ServiceProcess;
23
24namespace Canonical.UbuntuOne.ProcessDispatcher
25{
26 /// <summary>
27 /// Installer that will allows to set up the daemon when using the InnstalUtil application.
28 /// </summary>
29 [RunInstaller(true)]
30 public class ProjectInstaller : Installer
31 {
32 private readonly ServiceProcessInstaller _serviceProcessInstaller;
33 private readonly ServiceInstaller _serviceInstaller;
34
35 /// <summary>
36 /// Creates a new instance of the installer.
37 /// </summary>
38 public ProjectInstaller()
39 {
40 _serviceProcessInstaller = new ServiceProcessInstaller();
41 _serviceInstaller = new ServiceInstaller();
42 // Here you can set properties on serviceProcessInstaller or register event handlers
43 _serviceProcessInstaller.Account = ServiceAccount.LocalService;
44
45 _serviceInstaller.ServiceName = SyncDaemonWindowsService.MyServiceName;
46 Installers.AddRange(new Installer[] { _serviceProcessInstaller, _serviceInstaller });
47 }
48 }
49}
500
=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonService.cs'
--- src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonService.cs 2010-08-30 17:30:31 +0000
+++ src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonService.cs 2010-10-08 12:04:40 +0000
@@ -19,9 +19,13 @@
19 */19 */
20using System;20using System;
21using System.Collections.Generic;21using System.Collections.Generic;
22using System.Diagnostics;
23using System.IO;
24using System.ServiceModel;
22using Canonical.UbuntuOne.Common;25using Canonical.UbuntuOne.Common;
23using Canonical.UbuntuOne.Common.Aop;26using Canonical.UbuntuOne.Common.Aop;
24using Canonical.UbuntuOne.Common.Security;27using Canonical.UbuntuOne.Common.Security;
28using Canonical.UbuntuOne.Common.Utils;
25using Canonical.UbuntuOne.Common.Validation;29using Canonical.UbuntuOne.Common.Validation;
26using log4net;30using log4net;
2731
@@ -32,6 +36,7 @@
32 /// </summary>36 /// </summary>
33 internal class SyncDaemonService : ISyncDaemon37 internal class SyncDaemonService : ISyncDaemon
34 {38 {
39
35 #region Variables40 #region Variables
3641
37 // contains a map between user id and pid so that we know if the process is running already.42 // contains a map between user id and pid so that we know if the process is running already.
@@ -76,6 +81,12 @@
76 /// </summary>81 /// </summary>
77 internal IAuthentication Authentication { get; set; }82 internal IAuthentication Authentication { get; set; }
7883
84 /// <summary>
85 /// Allows to get and set the application locator that can be used to find the required
86 /// external applications.
87 /// </summary>
88 internal IApplicationLocator ApplicationLocator { get; set; }
89
79 #endregion90 #endregion
8091
81 public SyncDaemonService()92 public SyncDaemonService()
@@ -83,12 +94,12 @@
83 _processesMap = new Dictionary<string, IProcessManager>();94 _processesMap = new Dictionary<string, IProcessManager>();
84 }95 }
8596
86
87 /// <summary>97 /// <summary>
88 /// Allows to start the daemon by a client.98 /// Allows to start the daemon by a client.
89 /// </summary>99 /// </summary>
90 /// <exception cref="SyncDaemonException">Exception thrown when the process could not be started.</exception>100 /// <exception cref="SyncDaemonException">Exception thrown when the process could not be started.</exception>
91 [DebugLogged]101 [DebugLogged]
102 [OperationBehavior(Impersonation = ImpersonationOption.Allowed)]
92 public void Start()103 public void Start()
93 {104 {
94 ValidateArgs.Begin()105 ValidateArgs.Begin()
@@ -135,7 +146,7 @@
135 Start();146 Start();
136 return true;147 return true;
137 }148 }
138 catch(SyncDaemonException)149 catch (SyncDaemonException)
139 {150 {
140 return false;151 return false;
141 }152 }
@@ -155,7 +166,7 @@
155 if (Authentication.IsAuthenticated)166 if (Authentication.IsAuthenticated)
156 {167 {
157 var user = Authentication.Username;168 var user = Authentication.Username;
158 if(_processesMap.ContainsKey(user))169 if (_processesMap.ContainsKey(user))
159 {170 {
160 // get the manager, stop the process and remove the info171 // get the manager, stop the process and remove the info
161 var manager = _processesMap[user];172 var manager = _processesMap[user];
@@ -164,7 +175,7 @@
164 manager.Stop();175 manager.Stop();
165 _processesMap.Remove(user);176 _processesMap.Remove(user);
166 }177 }
167 catch(ProcessManagementException ex)178 catch (ProcessManagementException ex)
168 {179 {
169 var message = String.Format("Daemon for {0} could not be stoped: {1}", user, ex.Message);180 var message = String.Format("Daemon for {0} could not be stoped: {1}", user, ex.Message);
170 throw new SyncDaemonException(message, ex);181 throw new SyncDaemonException(message, ex);
@@ -189,7 +200,7 @@
189 Stop();200 Stop();
190 return true;201 return true;
191 }202 }
192 catch(SyncDaemonException)203 catch (SyncDaemonException)
193 {204 {
194 return false;205 return false;
195 }206 }
@@ -204,6 +215,82 @@
204 }215 }
205216
206 /// <summary>217 /// <summary>
218 /// Allows to perform a manual sync of the root Ubuntu One directory in the provided path using the oauth information
219 /// passed to the service.
220 /// </summary>
221 /// <param name="path">The path to which the root of the Ubuntu One folder will be sync.</param>
222 /// <param name="token">The token from oauth.</param>
223 /// <param name="tokenSecret">The token secret from oauth.</param>
224 /// <param name="consumerKey">The consumer key from oauth.</param>
225 /// <param name="consumerSecret">The consumer secret from oauth.</param>
226 public void ManualSync(string path, string token, string tokenSecret, string consumerKey, string consumerSecret)
227 {
228 ValidateArgs.Begin()
229 .IsNotNullOrEmpty(path, "path")
230 .IsNotNullOrEmpty(token, "toke")
231 .IsNotNullOrEmpty(consumerKey, "consumerKey")
232 .IsNotNullOrEmpty(consumerSecret, "consumerSecret")
233 .Check();
234 // should always be executed befre the impersonation
235 var u1SyncPath = ApplicationLocator.GetApplicationPath(Constants.U1SyncAppName);
236 var tokens = string.Format("{0}:{1}:{2}:{3}", token, tokenSecret, consumerKey, consumerSecret);
237 if (!Directory.Exists(path))
238 {
239 Directory.CreateDirectory(path);
240 }
241 if (!Directory.Exists(Path.Combine(path, ".ubuntuone-sync")))
242 {
243 var initCommand = String.Format("{0} --init \"{1}\" --oauth {2}",
244 Path.Combine(u1SyncPath, "main.exe"),
245 path, tokens);
246 Logger.DebugFormat("Executing {0} as user {1}", initCommand,
247 ServiceSecurityContext.Current.WindowsIdentity.Name);
248
249 //init the directory
250 var init = new Process
251 {
252 StartInfo =
253 {
254 WorkingDirectory = u1SyncPath,
255 FileName = Path.Combine(u1SyncPath, "main.exe"),
256 Arguments = String.Format(" --init \"{0}\" --oauth {1}", path, tokens),
257 UseShellExecute = false,
258 RedirectStandardOutput = true,
259 RedirectStandardError = true,
260 CreateNoWindow = true,
261 WindowStyle = ProcessWindowStyle.Hidden
262
263 }
264 };
265 Logger.InfoFormat("Executing u1sync with args: {0}", init.StartInfo.Arguments);
266 init.Start();
267 init.WaitForExit();
268 Logger.InfoFormat("StandarOutput from u1sync is: {0}", init.StandardOutput.ReadToEnd());
269 Logger.ErrorFormat("StandardError from u1sync is: {0}", init.StandardError.ReadToEnd());
270 init.Close();
271
272 }
273 var syncCommand = String.Format("{0} --oauth {1}", Path.Combine(u1SyncPath, "main.exe"), tokens);
274 Logger.DebugFormat("Executing {0} as user {1}", syncCommand,
275 ServiceSecurityContext.Current.WindowsIdentity.Name);
276 var proc = new Process
277 {
278 StartInfo =
279 {
280 WorkingDirectory = u1SyncPath,
281 FileName = Path.Combine(u1SyncPath, "main.exe"),
282 Arguments = String.Format("\"{0}\" --oauth {1}", path, tokens),
283 UseShellExecute = false,
284 RedirectStandardOutput = true,
285 RedirectStandardError = true,
286 CreateNoWindow = true,
287 WindowStyle = ProcessWindowStyle.Hidden
288 }
289 };
290 proc.Start();
291 }
292
293 /// <summary>
207 /// Returns the port number of the socket that the synd daemo is listening to for communication.294 /// Returns the port number of the socket that the synd daemo is listening to for communication.
208 /// </summary>295 /// </summary>
209 /// <returns></returns>296 /// <returns></returns>
210297
=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonWindowsService.cs'
--- src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonWindowsService.cs 2010-09-08 08:24:05 +0000
+++ src/Canonical.UbuntuOne.ProcessDispatcher/SyncDaemonWindowsService.cs 2010-10-08 12:04:40 +0000
@@ -18,7 +18,6 @@
18 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>18 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
19 */19 */
20using System.ServiceModel;20using System.ServiceModel;
21using System.ServiceProcess;
22using Canonical.UbuntuOne.Common.Aop;21using Canonical.UbuntuOne.Common.Aop;
23using log4net;22using log4net;
2423
@@ -29,7 +28,7 @@
29 /// 28 ///
30 /// This service is used to ensure that the sync daemon run sper user and allows to amange those processes.29 /// This service is used to ensure that the sync daemon run sper user and allows to amange those processes.
31 /// </summary>30 /// </summary>
32 public class SyncDaemonWindowsService : ServiceBase31 public class SyncDaemonWindowsService
33 {32 {
34 #region Variables33 #region Variables
3534
@@ -56,7 +55,7 @@
56 {55 {
57 lock (_loggerLock)56 lock (_loggerLock)
58 {57 {
59 _logger = LogManager.GetLogger(typeof (SyncDaemonWindowsService));58 _logger = LogManager.GetLogger(typeof(SyncDaemonWindowsService));
60 }59 }
61 }60 }
62 return _logger;61 return _logger;
@@ -114,36 +113,23 @@
114 SyncFileManager,113 SyncFileManager,
115 SyncFolders,114 SyncFolders,
116 SyncShares115 SyncShares
117 }; 116 };
118 }117 }
119118
120 #endregion119 #endregion
121120
122 /// <summary>121 /// <summary>
123 /// Creates a new instance of the sync daemon windows service.
124 /// </summary>
125 public SyncDaemonWindowsService()
126 {
127 InitializeComponent();
128 }
129
130 private void InitializeComponent()
131 {
132 ServiceName = MyServiceName;
133 }
134
135 /// <summary>
136 /// Start this service.122 /// Start this service.
137 /// </summary>123 /// </summary>
138 [DebugLogged]124 [DebugLogged]
139 protected override void OnStart(string[] args)125 public void Start()
140 {126 {
141127
142 foreach (var serviceHost in GetHosts())128 foreach (var serviceHost in GetHosts())
143 {129 {
144 // make sure that it is close and reopen130 // make sure that it is close and reopen
145 Logger.InfoFormat("Host {0} state is {1}", serviceHost.BaseAddresses[0], serviceHost.State);131 Logger.InfoFormat("Host {0} state is {1}", serviceHost.BaseAddresses[0], serviceHost.State);
146 if(serviceHost.State == CommunicationState.Closed)132 if (serviceHost.State == CommunicationState.Closed)
147 serviceHost.Open();133 serviceHost.Open();
148 }134 }
149 Logger.DebugFormat("{0} started.", MyServiceName);135 Logger.DebugFormat("{0} started.", MyServiceName);
@@ -153,11 +139,11 @@
153 /// Stop this service.139 /// Stop this service.
154 /// </summary>140 /// </summary>
155 [DebugLogged]141 [DebugLogged]
156 protected override void OnStop()142 public void Stop()
157 {143 {
158 var hosts = GetHosts();144 var hosts = GetHosts();
159145
160 for (var index = 0; index < hosts.Length; index++ )146 for (var index = 0; index < hosts.Length; index++)
161 {147 {
162 if (hosts[index] == null)148 if (hosts[index] == null)
163 {149 {
164150
=== modified file 'src/Canonical.UbuntuOne.ProcessDispatcher/objects.xml'
--- src/Canonical.UbuntuOne.ProcessDispatcher/objects.xml 2010-09-28 08:41:33 +0000
+++ src/Canonical.UbuntuOne.ProcessDispatcher/objects.xml 2010-10-08 12:04:40 +0000
@@ -35,7 +35,7 @@
35 <property name="attribute"35 <property name="attribute"
36 value="Canonical.UbuntuOne.Common.Aop.DebugLoggedAttribute, Canonical.UbuntuOne.Common" />36 value="Canonical.UbuntuOne.Common.Aop.DebugLoggedAttribute, Canonical.UbuntuOne.Common" />
37 </object>37 </object>
3838
39 <!-- ###################################################################################################### -->39 <!-- ###################################################################################################### -->
40 <!-- Wcf services that will allows .Net languages to interact with the SyncDaemon -->40 <!-- Wcf services that will allows .Net languages to interact with the SyncDaemon -->
41 <!-- ###################################################################################################### -->41 <!-- ###################################################################################################### -->
@@ -43,19 +43,27 @@
4343
44 <!-- services -->44 <!-- services -->
45 <object id="SyncConfigurationService"45 <object id="SyncConfigurationService"
46 type="Canonical.UbuntuOne.ProcessDispatcher.SyncConfigurationService, Canonical.UbuntuOne.ProcessDispatcher" />46 type="Canonical.UbuntuOne.ProcessDispatcher.SyncConfigurationService, Canonical.UbuntuOne.ProcessDispatcher"
47 autowire="autodetect"/>
4748
48 <object id="SyncDaemonService"49 <object id="SyncDaemonService"
49 type="Canonical.UbuntuOne.ProcessDispatcher.SyncDaemonService, Canonical.UbuntuOne.ProcessDispatcher" />50 type="Canonical.UbuntuOne.ProcessDispatcher.SyncDaemonService, Canonical.UbuntuOne.ProcessDispatcher"
51 autowire="autodetect">
52 <property name="ApplicationLocator"
53 ref="ApplicationLocator" />
54 </object>
5055
51 <object id="SyncFileManagerService"56 <object id="SyncFileManagerService"
52 type="Canonical.UbuntuOne.ProcessDispatcher.SyncFileManagerService, Canonical.UbuntuOne.ProcessDispatcher" />57 type="Canonical.UbuntuOne.ProcessDispatcher.SyncFileManagerService, Canonical.UbuntuOne.ProcessDispatcher"
58 autowire="autodetect"/>
5359
54 <object id="SyncFoldersService"60 <object id="SyncFoldersService"
55 type="Canonical.UbuntuOne.ProcessDispatcher.SyncFoldersService, Canonical.UbuntuOne.ProcessDispatcher" />61 type="Canonical.UbuntuOne.ProcessDispatcher.SyncFoldersService, Canonical.UbuntuOne.ProcessDispatcher"
62 autowire="autodetect"/>
5663
57 <object id="SyncSharesService"64 <object id="SyncSharesService"
58 type="Canonical.UbuntuOne.ProcessDispatcher.SyncSharesService, Canonical.UbuntuOne.ProcessDispatcher" />65 type="Canonical.UbuntuOne.ProcessDispatcher.SyncSharesService, Canonical.UbuntuOne.ProcessDispatcher"
66 autowire="autodetect"/>
59 67
60 <!-- hosts -->68 <!-- hosts -->
6169
6270
=== modified file 'src/ServiceTestApp/Program.cs'
--- src/ServiceTestApp/Program.cs 2010-07-26 16:01:09 +0000
+++ src/ServiceTestApp/Program.cs 2010-10-08 12:04:40 +0000
@@ -1,7 +1,4 @@
1using System;1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Canonical.UbuntuOne.Common.Container;2using Canonical.UbuntuOne.Common.Container;
6using Canonical.UbuntuOne.ProcessDispatcher;3using Canonical.UbuntuOne.ProcessDispatcher;
74
85
=== modified file 'src/UbuntuOne.sln'
--- src/UbuntuOne.sln 2010-10-06 10:43:02 +0000
+++ src/UbuntuOne.sln 2010-10-08 12:04:40 +0000
@@ -13,8 +13,6 @@
13EndProject13EndProject
14Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Canonical.UbuntuOne.Client.Views", "Canonical.UbuntuOne.Client.Views\Canonical.UbuntuOne.Client.Views.csproj", "{1B5BA61A-4B34-424A-886E-E2B0CF547D4D}"14Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Canonical.UbuntuOne.Client.Views", "Canonical.UbuntuOne.Client.Views\Canonical.UbuntuOne.Client.Views.csproj", "{1B5BA61A-4B34-424A-886E-E2B0CF547D4D}"
15EndProject15EndProject
16Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceTestApp", "ServiceTestApp\ServiceTestApp.csproj", "{009E6FD4-DE20-410A-B1F3-5F0542CD8745}"
17EndProject
18Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Canonical.UbuntuOne.Client.Test", "Canonical.UbuntuOne.Client.Test\Canonical.UbuntuOne.Client.Test.csproj", "{2947FCA2-D6FC-4509-83F8-64A87447EBD3}"16Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Canonical.UbuntuOne.Client.Test", "Canonical.UbuntuOne.Client.Test\Canonical.UbuntuOne.Client.Test.csproj", "{2947FCA2-D6FC-4509-83F8-64A87447EBD3}"
19EndProject17EndProject
20Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UbuntuOneClient", "UbuntuOneClient\UbuntuOneClient.csproj", "{E41083CC-B99A-4AEC-93CC-F693F6AA6071}"18Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UbuntuOneClient", "UbuntuOneClient\UbuntuOneClient.csproj", "{E41083CC-B99A-4AEC-93CC-F693F6AA6071}"
@@ -104,16 +102,6 @@
104 {1B5BA61A-4B34-424A-886E-E2B0CF547D4D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU102 {1B5BA61A-4B34-424A-886E-E2B0CF547D4D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
105 {1B5BA61A-4B34-424A-886E-E2B0CF547D4D}.Release|Mixed Platforms.Build.0 = Release|Any CPU103 {1B5BA61A-4B34-424A-886E-E2B0CF547D4D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
106 {1B5BA61A-4B34-424A-886E-E2B0CF547D4D}.Release|x86.ActiveCfg = Release|Any CPU104 {1B5BA61A-4B34-424A-886E-E2B0CF547D4D}.Release|x86.ActiveCfg = Release|Any CPU
107 {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
108 {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Debug|Any CPU.Build.0 = Debug|Any CPU
109 {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
110 {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
111 {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Debug|x86.ActiveCfg = Debug|Any CPU
112 {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Release|Any CPU.ActiveCfg = Release|Any CPU
113 {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Release|Any CPU.Build.0 = Release|Any CPU
114 {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
115 {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Release|Mixed Platforms.Build.0 = Release|Any CPU
116 {009E6FD4-DE20-410A-B1F3-5F0542CD8745}.Release|x86.ActiveCfg = Release|Any CPU
117 {2947FCA2-D6FC-4509-83F8-64A87447EBD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU105 {2947FCA2-D6FC-4509-83F8-64A87447EBD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
118 {2947FCA2-D6FC-4509-83F8-64A87447EBD3}.Debug|Any CPU.Build.0 = Debug|Any CPU106 {2947FCA2-D6FC-4509-83F8-64A87447EBD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
119 {2947FCA2-D6FC-4509-83F8-64A87447EBD3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU107 {2947FCA2-D6FC-4509-83F8-64A87447EBD3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
120108
=== modified file 'src/UbuntuOneClient/App.config'
--- src/UbuntuOneClient/App.config 2010-10-05 15:20:36 +0000
+++ src/UbuntuOneClient/App.config 2010-10-08 12:04:40 +0000
@@ -29,6 +29,11 @@
29 </factoryAdapter>29 </factoryAdapter>
30 </logging>30 </logging>
31 </common>31 </common>
32
33 <system.serviceModel>
34 <bindings configSource="Config\serviceModel.bindings.config"/>
35 <client configSource="Config\serviceModel.client.config"/>
36 </system.serviceModel>
32 37
33 <spring>38 <spring>
34 <context>39 <context>
3540
=== added file 'src/UbuntuOneClient/Config/serviceModel.bindings.config'
--- src/UbuntuOneClient/Config/serviceModel.bindings.config 1970-01-01 00:00:00 +0000
+++ src/UbuntuOneClient/Config/serviceModel.bindings.config 2010-10-08 12:04:40 +0000
@@ -0,0 +1,23 @@
1<?xml version="1.0" encoding="utf-8" ?>
2<bindings>
3 <!-- Named pipe binding provided to allow better performance that the wsHttpBinding -->
4 <netNamedPipeBinding>
5 <binding name="namedPipeBinding"
6 closeTimeout="00:01:00"
7 openTimeout="00:01:00"
8 receiveTimeout="00:10:00"
9 sendTimeout="00:01:00"
10 transactionFlow="false"
11 transferMode="Buffered"
12 transactionProtocol="OleTransactions"
13 hostNameComparisonMode="StrongWildcard"
14 maxBufferPoolSize="524288"
15 maxBufferSize="65536"
16 maxConnections="10"
17 maxReceivedMessageSize="65536">
18 <security mode="Transport">
19 <transport protectionLevel="EncryptAndSign" />
20 </security>
21 </binding>
22 </netNamedPipeBinding>
23</bindings>
0\ No newline at end of file24\ No newline at end of file
125
=== added file 'src/UbuntuOneClient/Config/serviceModel.client.config'
--- src/UbuntuOneClient/Config/serviceModel.client.config 1970-01-01 00:00:00 +0000
+++ src/UbuntuOneClient/Config/serviceModel.client.config 2010-10-08 12:04:40 +0000
@@ -0,0 +1,38 @@
1<?xml version="1.0" encoding="utf-8" ?>
2<client>
3 <endpoint name="configurationEndpoint"
4 address="net.pipe://localhost/UbuntuOne/SyncConfigurationService/$username$"
5 binding="netNamedPipeBinding"
6 bindingConfiguration="namedPipeBinding"
7 contract="Canonical.UbuntuOne.Common.ISyncConfiguration">
8 </endpoint>
9
10 <endpoint name="syncDaemonEndpoint"
11 address="net.pipe://localhost/UbuntuOne/SyncDaemonService/$username$"
12 binding="netNamedPipeBinding"
13 bindingConfiguration="namedPipeBinding"
14 contract="Canonical.UbuntuOne.Common.ISyncDaemon">
15 </endpoint>
16
17 <endpoint name="fileManagerEndpoint"
18 address="net.pipe://localhost/UbuntuOne/SyncFileManagerService/$username$"
19 binding="netNamedPipeBinding"
20 bindingConfiguration="namedPipeBinding"
21 contract="Canonical.UbuntuOne.Common.ISyncFileManager">
22 </endpoint>
23
24 <endpoint name="syncFoldersEndpoint"
25 address="net.pipe://localhost/UbuntuOne/SyncFoldersService/$username$"
26 binding="netNamedPipeBinding"
27 bindingConfiguration="namedPipeBinding"
28 contract="Canonical.UbuntuOne.Common.ISyncFolders">
29 </endpoint>
30
31 <endpoint name="syncSharesEndpoint"
32 address="net.pipe://localhost/UbuntuOne/SyncSharesService/$username$"
33 binding="netNamedPipeBinding"
34 bindingConfiguration="namedPipeBinding"
35 contract="Canonical.UbuntuOne.Common.ISyncShares">
36 </endpoint>
37
38</client>
0\ No newline at end of file39\ No newline at end of file
140
=== modified file 'src/UbuntuOneClient/Program.cs'
--- src/UbuntuOneClient/Program.cs 2010-09-09 09:11:07 +0000
+++ src/UbuntuOneClient/Program.cs 2010-10-08 12:04:40 +0000
@@ -39,6 +39,7 @@
39 private INotificationIconView _notifyIcon;39 private INotificationIconView _notifyIcon;
40 private readonly object _notifyIconLock = new object();40 private readonly object _notifyIconLock = new object();
41 private Thread _updatesThread;41 private Thread _updatesThread;
42 private static readonly ConfigurationLocator _configLocator = new ConfigurationLocator();
4243
43 #region DI Properties for testability44 #region DI Properties for testability
4445
@@ -148,10 +149,40 @@
148 [STAThread]149 [STAThread]
149 static void Main()150 static void Main()
150 {151 {
152 // HACK: This technique is quite interesting although it is a hack. The idea is the following,
153 // due to the fact that we want to run a WCF service per user and not per machine, we have to be able
154 // to determine at runtime the users pipe names. To do so we would use a config file per user
155 // but ofcourse we cannot do that at install time becuase we do not know all the user.
156 //
157 // Ideally we would not have to do this hack and the ConfiguratonManager would allow to refrest the app
158 // condifuration, but it is not the case!! On top of that you cannot do so by using reflection :(
159 //
160 // The trick is simple, we use the normal app.config to start the program, once the program is started we create
161 // a new app domain where we will be doing all the work. Because we are the ones starting the app domain, we can
162 // tell him to use a diff configuration, which means that we poit to a new config for this user that points to
163 // the correct pipe names :D
164 // This is not cheap, now we have a dummy app domain, the one that start this program, and a second app domain that
165 // is used to load the spring context plus all the WCT setting. The SeriesAppDomain is the one that really does
166 // the job.
167 _logger.Info("Updating config");
151 // init the objects container168 // init the objects container
152 ObjectsContainer.Initialize(new SpringContainer());169 // Setup information for the new appdomain.
153 var program = ObjectsContainer.GetImplementationOf<Program>();170 var setup = new AppDomainSetup
154 program.StartApplication();171 {
172 ConfigurationFile = _configLocator.GetCurrentUserClientConfiguration()
173 };
174
175 // Create the new appdomain with the new config.
176 var executionAppDomain = AppDomain.CreateDomain("ClientAppDomain", AppDomain.CurrentDomain.Evidence, setup);
177
178 // Call the write config method in that appdomain.
179 executionAppDomain.DoCallBack(() =>
180 {
181 ObjectsContainer.Initialize(new SpringContainer());
182 var program = ObjectsContainer.GetImplementationOf<Program>();
183 program.StartApplication();
184 });
185
155 }186 }
156 }187 }
157}188}
158189
=== modified file 'src/UbuntuOneClient/UbuntuOneClient.csproj'
--- src/UbuntuOneClient/UbuntuOneClient.csproj 2010-10-06 08:48:18 +0000
+++ src/UbuntuOneClient/UbuntuOneClient.csproj 2010-10-08 12:04:40 +0000
@@ -51,6 +51,9 @@
51 <Reference Include="System.Core">51 <Reference Include="System.Core">
52 <RequiredTargetFramework>3.5</RequiredTargetFramework>52 <RequiredTargetFramework>3.5</RequiredTargetFramework>
53 </Reference>53 </Reference>
54 <Reference Include="System.ServiceModel">
55 <RequiredTargetFramework>3.0</RequiredTargetFramework>
56 </Reference>
54 <Reference Include="System.Xml.Linq">57 <Reference Include="System.Xml.Linq">
55 <RequiredTargetFramework>3.5</RequiredTargetFramework>58 <RequiredTargetFramework>3.5</RequiredTargetFramework>
56 </Reference>59 </Reference>
@@ -90,6 +93,12 @@
90 <None Include="Config\log4net.config">93 <None Include="Config\log4net.config">
91 <CopyToOutputDirectory>Always</CopyToOutputDirectory>94 <CopyToOutputDirectory>Always</CopyToOutputDirectory>
92 </None>95 </None>
96 <None Include="Config\serviceModel.bindings.config">
97 <CopyToOutputDirectory>Always</CopyToOutputDirectory>
98 </None>
99 <None Include="Config\serviceModel.client.config">
100 <CopyToOutputDirectory>Always</CopyToOutputDirectory>
101 </None>
93 <None Include="Properties\Settings.settings">102 <None Include="Properties\Settings.settings">
94 <Generator>SettingsSingleFileGenerator</Generator>103 <Generator>SettingsSingleFileGenerator</Generator>
95 <LastGenOutput>Settings.Designer.cs</LastGenOutput>104 <LastGenOutput>Settings.Designer.cs</LastGenOutput>
96105
=== modified file 'src/UbuntuOneClient/objects.xml'
--- src/UbuntuOneClient/objects.xml 2010-09-28 08:41:33 +0000
+++ src/UbuntuOneClient/objects.xml 2010-10-08 12:04:40 +0000
@@ -56,4 +56,38 @@
56 <property name="Application"56 <property name="Application"
57 ref="Application" />57 ref="Application" />
58 </object>58 </object>
59
60 <!-- ############################################################### -->
61 <!-- WCF services configuration -->
62 <!-- ############################################################### -->
63
64 <object id="ConfigurationChannelFactory"
65 type="System.ServiceModel.ChannelFactory&lt;Canonical.UbuntuOne.Common.ISyncConfiguration>, System.ServiceModel">
66 <constructor-arg name="endpointConfigurationName"
67 value="configurationEndpoint" />
68 </object>
69
70 <object id="SyncDaemonChannelFactory"
71 type="System.ServiceModel.ChannelFactory&lt;Canonical.UbuntuOne.Common.ISyncDaemon>, System.ServiceModel">
72 <constructor-arg name="endpointConfigurationName"
73 value="syncDaemonEndpoint" />
74 </object>
75
76 <object id="FileManagerChannelFactory"
77 type="System.ServiceModel.ChannelFactory&lt;Canonical.UbuntuOne.Common.ISyncFileManager>, System.ServiceModel">
78 <constructor-arg name="endpointConfigurationName"
79 value="fileManagerEndpoint" />
80 </object>
81
82 <object id="SyncFoldersChannelFactory"
83 type="System.ServiceModel.ChannelFactory&lt;Canonical.UbuntuOne.Common.ISyncFolders>, System.ServiceModel">
84 <constructor-arg name="endpointConfigurationName"
85 value="syncFoldersEndpoint" />
86 </object>
87
88 <object id="SyncSharesChannelFactory"
89 type="System.ServiceModel.ChannelFactory&lt;Canonical.UbuntuOne.Common.ISyncShares>, System.ServiceModel">
90 <constructor-arg name="endpointConfigurationName"
91 value="syncSharesEndpoint" />
92 </object>
59</objects>93</objects>
60\ No newline at end of file94\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: