Revision 5bcf6d70 trunk/Pithos.Core/PithosMonitor.cs
b/trunk/Pithos.Core/PithosMonitor.cs | ||
---|---|---|
8 | 8 |
using System.Linq; |
9 | 9 |
using System.Net.NetworkInformation; |
10 | 10 |
using System.Security.Cryptography; |
11 |
using System.ServiceModel.Description; |
|
11 | 12 |
using System.Text; |
12 | 13 |
using System.Threading; |
13 | 14 |
using System.Threading.Tasks; |
... | ... | |
45 | 46 |
set |
46 | 47 |
{ |
47 | 48 |
if (_watcher!=null) |
48 |
_watcher.EnableRaisingEvents = !value; |
|
49 |
_watcher.EnableRaisingEvents = !value; |
|
50 |
if (value) |
|
51 |
{ |
|
52 |
StatusKeeper.SetPithosStatus(PithosStatus.SyncPaused); |
|
53 |
} |
|
54 |
else |
|
55 |
{ |
|
56 |
StatusKeeper.SetPithosStatus(PithosStatus.InSynch); |
|
57 |
} |
|
49 | 58 |
} |
50 | 59 |
} |
51 | 60 |
|
... | ... | |
68 | 77 |
_cancellationSource = new CancellationTokenSource(); |
69 | 78 |
|
70 | 79 |
string path = Settings.PithosPath; |
80 |
var proxyUri = ProxyFromSettings(); |
|
81 |
CloudClient.Proxy = proxyUri; |
|
71 | 82 |
StartMonitoringFiles(path); |
72 | 83 |
|
73 | 84 |
StartStatusService(); |
... | ... | |
75 | 86 |
StartNetwork(); |
76 | 87 |
} |
77 | 88 |
|
89 |
private Uri ProxyFromSettings() |
|
90 |
{ |
|
91 |
if (Settings.UseManualProxy) |
|
92 |
{ |
|
93 |
var proxyUri = new UriBuilder |
|
94 |
{ |
|
95 |
Host = Settings.ProxyServer, |
|
96 |
Port = Settings.ProxyPort |
|
97 |
}; |
|
98 |
if (Settings.ProxyAuthentication) |
|
99 |
{ |
|
100 |
proxyUri.UserName = Settings.ProxyUsername; |
|
101 |
proxyUri.Password = Settings.ProxyPassword; |
|
102 |
} |
|
103 |
return proxyUri.Uri; |
|
104 |
} |
|
105 |
return null; |
|
106 |
} |
|
107 |
|
|
78 | 108 |
private void StartStatusService() |
79 | 109 |
{ |
80 |
Uri baseAddress = new Uri("http://localhost:30000/pithos/statuscache"); |
|
81 |
string address = "net.pipe://localhost/pithos/statuscache"; |
|
82 |
|
|
83 | 110 |
// Create a ServiceHost for the CalculatorService type and provide the base address. |
84 |
_statusService= new ServiceHost(typeof(StatusService), baseAddress); |
|
111 |
var baseAddress = new Uri("net.pipe://localhost/pithos"); |
|
112 |
_statusService = new ServiceHost(typeof(StatusService), baseAddress); |
|
85 | 113 |
|
86 |
NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); |
|
87 |
_statusService.AddServiceEndpoint(typeof(IStatusService), binding, address); |
|
114 |
var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); |
|
115 |
|
|
116 |
_statusService.AddServiceEndpoint(typeof(IStatusService), binding, "net.pipe://localhost/pithos/statuscache"); |
|
117 |
_statusService.AddServiceEndpoint(typeof (ISettingsService), binding, "net.pipe://localhost/pithos/settings"); |
|
118 |
|
|
119 |
|
|
120 |
//// Add a mex endpoint |
|
121 |
var smb = new ServiceMetadataBehavior |
|
122 |
{ |
|
123 |
HttpGetEnabled = true, |
|
124 |
HttpGetUrl = new Uri("http://localhost:30000/pithos/mex") |
|
125 |
}; |
|
126 |
_statusService.Description.Behaviors.Add(smb); |
|
127 |
|
|
128 |
|
|
88 | 129 |
_statusService.Open(); |
89 | 130 |
} |
90 | 131 |
|
... | ... | |
115 | 156 |
|
116 | 157 |
try |
117 | 158 |
{ |
159 |
|
|
118 | 160 |
CloudClient.Authenticate(Settings.UserName, Settings.ApiKey); |
119 | 161 |
|
120 | 162 |
StartListening(); |
Also available in: Unified diff