Temp fixes
[pithos-ms-client] / trunk / Pithos.Client.WPF / Preferences / PreferencesViewModel.cs
index ae41433..2857dc8 100644 (file)
@@ -230,17 +230,20 @@ namespace Pithos.Client.WPF.Preferences
         public void RefreshApiKey()
         {
             //_events.Publish(new Notification { Title = "Authorization failed", Message = "Your API Key has probably expired. You will be directed to a page where you can renew it", Level = TraceLevel.Error });
-
+            if (CurrentAccount == null)
+                return;
             try
             {
 
-                var name = CurrentAccount != null ? CurrentAccount.AccountName : null;
-                var credentials = PithosAccount.RetrieveCredentials(Settings.PithosLoginUrl,name);
+                var name = CurrentAccount.AccountName;
+
+                var loginUri = new Uri(new Uri(CurrentAccount.ServerUrl), "login");
+                var credentials = PithosAccount.RetrieveCredentials(loginUri.ToString(),name);
                 if (credentials==null)
                     return;
                 //The server will return credentials for a different account, not just the current account
                 //We need to find the correct account first
-                var account = Accounts.First(act => act.AccountName == credentials.UserName);
+                var account = Accounts.First(act => act.AccountName == credentials.UserName && act.ServerUrl == ?? );
                 account.ApiKey = credentials.Password;                
                 account.IsExpired = false;
                 Settings.Save();
@@ -376,6 +379,7 @@ namespace Pithos.Client.WPF.Preferences
                        actualRootPath = String.Format("{0} {1}", initialRootPath, attempt++);
                    }
                }
+               ### Check that the account does not already exist
 
                var newAccount = new AccountSettings
                                     {
@@ -397,9 +401,10 @@ namespace Pithos.Client.WPF.Preferences
             
        }
 
+/*
         public void AddPithosAccount()
        {
-            var credentials=PithosAccount.RetrieveCredentials(Settings.PithosLoginUrl);
+            var credentials=PithosAccount.RetrieveCredentials(null);
             if (credentials == null)
                 return;
             var account = Settings.Accounts.FirstOrDefault(act => act.AccountName == credentials.UserName);
@@ -423,6 +428,7 @@ namespace Pithos.Client.WPF.Preferences
             NotifyOfPropertyChange(() => Accounts);
             NotifyOfPropertyChange(()=>Settings);                       
        }
+*/
 
 
         readonly List<AccountSettings> _accountsToRemove = new List<AccountSettings>();
@@ -572,6 +578,7 @@ namespace Pithos.Client.WPF.Preferences
                                                                             SearchOption.AllDirectories))
                         File.Copy(newFilePath, newFilePath.Replace(oldPath, newPath));
 
+                    Log.InfoFormat("Deleting account folder {0}",oldPath);
                     Directory.Delete(oldPath, true);
 
                     //We also need to change the path of the existing file states