Revision 7d915c34

b/trunk/Pithos.Client.WPF/Properties/Settings.Designer.cs
205 205
        
206 206
        [global::System.Configuration.ApplicationScopedSettingAttribute()]
207 207
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
208
        [global::System.Configuration.DefaultSettingValueAttribute("http://pithos.dev.grnet.gr/pithos.html")]
208
        [global::System.Configuration.DefaultSettingValueAttribute("http://pithos.dev.grnet.gr")]
209 209
        public string PithosSite {
210 210
            get {
211 211
                return ((string)(this["PithosSite"]));
b/trunk/Pithos.Client.WPF/Properties/Settings.settings
48 48
      <Value Profile="(Default)">False</Value>
49 49
    </Setting>
50 50
    <Setting Name="PithosSite" Type="System.String" Scope="Application">
51
      <Value Profile="(Default)">http://pithos.dev.grnet.gr/pithos.html</Value>
51
      <Value Profile="(Default)">http://pithos.dev.grnet.gr</Value>
52 52
    </Setting>
53 53
    <Setting Name="Accounts" Type="Pithos.Interfaces.AccountsCollection" Scope="User">
54 54
      <Value Profile="(Default)">
b/trunk/Pithos.Client.WPF/TaskbarViewModel.cs
169 169
            }
170 170
            if (!String.IsNullOrWhiteSpace(Monitor.UserName) &&
171 171
                !String.IsNullOrWhiteSpace(Monitor.ApiKey))
172
                Monitor.Start();
172
                try
173
                {
174
                    Monitor.Start();
175
                }
176
                catch (Exception exc)
177
                {
178
                    MessageBox.Show("An exception occured. Can't start monitoring");
179
                }
173 180
        }
174 181
    }
175 182
}
b/trunk/Pithos.Client.WPF/app.config
71 71
      <setting name="UseManualProxy" serializeAs="String">
72 72
        <value>False</value>
73 73
      </setting>
74
      <setting name="Accounts" serializeAs="Xml">
75
        <value>
76
          <ArrayOfAccountSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
77
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
78
            <AccountSettings>
79
            </AccountSettings>
80
          </ArrayOfAccountSettings>
81
        </value>
82
      </setting>
74 83
    </Pithos.Client.WPF.Properties.Settings>
75 84
  </userSettings>
76 85
  <connectionStrings>
......
88 97
  <applicationSettings>
89 98
    <Pithos.Client.WPF.Properties.Settings>
90 99
      <setting name="PithosSite" serializeAs="String">
91
        <value>http://pithos.dev.grnet.gr/pithos.html</value>
100
        <value>http://pithos.dev.grnet.gr</value>
92 101
      </setting>
93 102
      <setting name="PithosAuthenticationUrl" serializeAs="String">
94 103
        <value>https://pithos.dev.grnet.gr</value>
b/trunk/Pithos.Core/StatusKeeper.cs
24 24
        [System.ComponentModel.Composition.Import]
25 25
        public IPithosSettings Settings { get; set; }
26 26

  
27
        private JobQueue _statusUpdateQueue;
27
        private JobQueue _statusUpdateQueue=new JobQueue();
28 28

  
29 29
        public StatusKeeper()
30 30
        {            
b/trunk/Pithos.Network/PithosClient.cs
7 7
using System.Collections.Specialized;
8 8
using System.Diagnostics;
9 9
using System.Diagnostics.Contracts;
10
using System.IO;
10 11
using System.Net;
11 12
using System.Runtime.Serialization;
13
using System.Threading.Tasks;
12 14

  
13 15
namespace Pithos.Network
14 16
{
......
84 86

  
85 87
        protected override WebResponse GetWebResponse(WebRequest request)
86 88
        {
89
            try
90
            {
91

  
87 92
            var response = (HttpWebResponse)base.GetWebResponse(request);
88 93
            StatusCode = response.StatusCode;
89 94
            StatusDescription = response.StatusDescription;
90 95
            return response;
96
            }
97
            catch (WebException exc)
98
            {
99
                if (exc.Response.ContentLength > 0)
100
                {
101
                    string content;
102
                    content = GetContent(exc.Response);
103
                    Trace.TraceError(content);
104
                }
105
                throw;
106
            }
107
        }
108

  
109
        private static string GetContent(WebResponse webResponse)
110
        {
111
            string content;
112
            using (var stream = webResponse.GetResponseStream())
113
            using (var reader = new StreamReader(stream))
114
            {
115
                content = reader.ReadToEnd();
116
            }
117
            return content;
91 118
        }
92 119

  
93 120
        public string DownloadStringWithRetry(string address,int retries=0)
......
100 127
            var actualRetries = (retries == 0) ? Retries : retries;
101 128
            
102 129

  
103
            var func = Retry(() =>
130
            
131
            var task = Retry(() =>
104 132
            {
105 133
                var uriString = String.Join("/", BaseAddress, actualAddress);
106 134
                var content = base.DownloadString(uriString);
......
111 139

  
112 140
            }, actualRetries);
113 141

  
114
            var result = func();
142
            var result = task.Result;
115 143
            return result;
116 144
        }
117 145

  
......
147 175
            var actualAddress = GetActualAddress(address);
148 176

  
149 177
            var actualRetries = (retries == 0) ? Retries : retries;
150
            var func = Retry(() =>
178
            var task = Retry(() =>
151 179
            {
152 180
                var uriString = String.Join("/",BaseAddress ,actualAddress);
153 181
                var uri = new Uri(uriString);
......
164 192
                return 0;
165 193
            }, actualRetries);
166 194

  
167
            func();
195
            task.Wait();
168 196
        }
169 197

  
170 198
        private string GetActualAddress(string address)
......
191 219
                throw new ArgumentNullException("address");
192 220

  
193 221
            var actualRetries = (retries == 0) ? Retries : retries;            
194
            var func = Retry(() =>
222
            var task = Retry(() =>
195 223
            {
196 224
                var content = base.DownloadString(address);
197 225

  
......
201 229

  
202 230
            }, actualRetries);
203 231

  
204
            var result = func();
232
            var result = task.Result;
205 233
            return result;
206 234
        }
207 235

  
......
243 271
                throw new WebException(String.Format("{0} with code {1} - {2}", message, StatusCode, StatusDescription));
244 272
        }
245 273

  
246
        private Func<T> Retry<T>(Func< T> original, int retryCount)
274
        /*private Func<T> Retry<T>(Func< T> original, int retryCount)
247 275
        {
248 276
            return () =>
249 277
            {
......
305 333
                    }
306 334
                }
307 335
            };
336
        }*/
337
        
338
        private Task<T> Retry<T>(Func< T> original, int retryCount)
339
        {
340
            return Task.Factory.StartNew(() => original()).ContinueWith(_original =>
341
                {
342
                    if(_original.IsFaulted )
343
                    {
344
                        var e = _original.Exception.InnerException;
345
                        if (e is WebException)
346
                        {
347
                            var we = (e as WebException);
348
                            var statusCode = ((HttpWebResponse) we.Response).StatusCode;
349
                            this.StatusCode = statusCode;
350

  
351
                            if (we.Status==WebExceptionStatus.Timeout || 
352
                                (we.Status==WebExceptionStatus.ProtocolError && statusCode==HttpStatusCode.ServiceUnavailable))
353
                            {
354
                                TimedOut = true;
355
                                if (retryCount == 0)
356
                                {
357
                                    Trace.TraceError("[ERROR] Timed out too many times. {0}\n", e);
358
                                    throw new RetryException("Timed out too many times.", e);
359
                                }
360
                                Trace.TraceError(
361
                                    "[RETRY] Timed out after {0} ms. Will retry {1} more times\n{2}", Timeout,
362
                                    retryCount, e);
363
                                return Retry(original, retryCount - 1);
364
                            }
365

  
366
                            if (statusCode==HttpStatusCode.NotFound)
367
                                return new Task<T>(() => default(T));                            
368
                        }
369
                        throw e;
370
                    }
371
                    else                    
372
                        return Task<T>.Factory.StartNew(() => _original.Result);
373
                }).Unwrap();
308 374
        }
309 375

  
310 376
       
b/trunk/Pithos.ShellExtensions/Menus/FileContextMenu.cs
27 27

  
28 28
        private IntPtr _gotoBitmap=IntPtr.Zero;
29 29
        private IntPtr _versionBitmap = IntPtr.Zero;
30
        private IntPtr _propertiesBitmap = IntPtr.Zero;
30 31

  
31 32
        public FileContextMenu()
32 33
        {                        
33 34
            _gotoBitmap = GetBitmapPtr(Resources.MenuGoToPithos);
34 35
            _versionBitmap = GetBitmapPtr(Resources.MenuHistory);
36
            _propertiesBitmap = GetBitmapPtr(Resources.MenuProperties);
35 37

  
36 38

  
37 39
            
......
47 49
                                               DisplayFlags=DisplayFlags.All,
48 50
                                               MenuBitmap = _gotoBitmap
49 51
                                           }},
52
                /*{"showProperties",new MenuItem{
53
                                           MenuText = "&Pithos File Properties",
54
                                            Verb = "showProperties",
55
                                             VerbCanonicalName = "PITHOSProperties",
56
                                              VerbHelpText = "Pithos File Properties",
57
                                               MenuDisplayId = 2,
58
                                               MenuCommand=OnShowProperties,
59
                                               DisplayFlags=DisplayFlags.File,
60
                                               MenuBitmap = _propertiesBitmap
61
                                           }},*/
50 62
                {"prevVersions",new MenuItem{
51 63
                                           MenuText = "&Show Previous Versions",
52 64
                                            Verb = "prevVersions",
53 65
                                             VerbCanonicalName = "PITHOSPrevVersions",
54 66
                                              VerbHelpText = "Go to Pithos and display previous versions",
55
                                               MenuDisplayId = 2,
67
                                               MenuDisplayId = 3,
56 68
                                               MenuCommand=OnVerbDisplayFileName,
57 69
                                               DisplayFlags=DisplayFlags.File,
58 70
                                               MenuBitmap=_versionBitmap
......
77 89
                NativeMethods.DeleteObject(_versionBitmap);
78 90
                _versionBitmap = IntPtr.Zero;
79 91
            }
92
            if (_propertiesBitmap != IntPtr.Zero)
93
            {
94
                NativeMethods.DeleteObject(_propertiesBitmap);
95
                _propertiesBitmap = IntPtr.Zero;
96
            }
80 97

  
81 98
        }
82 99
        private static IntPtr GetBitmapPtr(Bitmap gotoBitmap)
......
86 103
            return hbitmap;
87 104
        }
88 105

  
106
        void OnShowProperties(IntPtr hWnd)
107
        {
108
            
109
        }
89 110

  
90 111
        void OnVerbDisplayFileName(IntPtr hWnd)
91 112
        {
......
102 123

  
103 124
        void OnGotoPithos(IntPtr hWnd)
104 125
        {
105
            Context.Settings.Reload();
106
            Process.Start(Context.Settings.PithosSite);
126
            var settings = Context.Settings;
127
            var activeAccount = settings.Accounts.FirstOrDefault(acc => acc.IsActive);
128
            var address = String.Format("{0}/ui/?token={1}&user={2}",
129
                                        settings.PithosSite,
130
                                        activeAccount.ApiKey,
131
                                        Uri.EscapeUriString(activeAccount.AccountName));
132

  
133
            settings.Reload();
134
            Process.Start(address);
107 135
        }
108 136
        
109 137

  
b/trunk/Pithos.ShellExtensions/Pithos.ShellExtensions.csproj
198 198
      <LastGenOutput>Reference.cs</LastGenOutput>
199 199
    </None>
200 200
  </ItemGroup>
201
  <ItemGroup>
202
    <None Include="Resources\MenuProperties.bmp" />
203
  </ItemGroup>
201 204
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
202 205
  <PropertyGroup>
203 206
    <PreBuildEvent>if  exist "$(TargetPath).locked" del "$(TargetPath).locked"
b/trunk/Pithos.ShellExtensions/PithosHost.cs
24 24
    {
25 25
        public static void EnsureHost()
26 26
        {
27
            return;
27 28
            if (Process.GetProcessesByName("Pithos.Client.WPF").Length == 0 &&
28 29
                Process.GetProcessesByName("Pithos.Client.WPF.vshost").Length == 0)
29 30
            {
b/trunk/Pithos.ShellExtensions/Properties/Resources.Designer.cs
73 73
                return ((System.Drawing.Bitmap)(obj));
74 74
            }
75 75
        }
76
        
77
        internal static System.Drawing.Bitmap MenuProperties {
78
            get {
79
                object obj = ResourceManager.GetObject("MenuProperties", resourceCulture);
80
                return ((System.Drawing.Bitmap)(obj));
81
            }
82
        }
76 83
    }
77 84
}
b/trunk/Pithos.ShellExtensions/Properties/Resources.resx
124 124
  <data name="MenuHistory" type="System.Resources.ResXFileRef, System.Windows.Forms">
125 125
    <value>..\Resources\MenuHistory.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
126 126
  </data>
127
  <data name="MenuProperties" type="System.Resources.ResXFileRef, System.Windows.Forms">
128
    <value>..\Resources\MenuProperties.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
129
  </data>
127 130
</root>

Also available in: Unified diff