private ObservableCollection<ObjectInfo> _checks;\r
//private readonly PithosMonitor _monitor;\r
private bool _isBusy=true;\r
- private string _apiKey;\r
+ private readonly string _apiKey;\r
\r
public ObservableCollection<ObjectInfo> Checks\r
{\r
//_monitor = monitor;\r
_events = events;\r
_apiKey = apiKey;\r
+ IsEnabled = account.SelectiveSyncEnabled;\r
TaskEx.Run(LoadRootNode);\r
}\r
\r
var client = new CloudFilesClient(AccountName,_apiKey){AuthenticationUrl=Account.ServerUrl,UsePithos=true};\r
client.Authenticate();\r
\r
+ //NEED to get the local folders here as well,\r
+ // and combine them with the cloud folders\r
+\r
\r
var dirs = from container in client.ListContainers(AccountName) \r
where container.Name != "trash"\r
};\r
var ownFolders = dirs.ToList();\r
\r
+\r
+\r
var accountNodes=from account in client.ListSharingAccounts()\r
select new DirectoryRecord\r
{\r
\r
var othersNode = new DirectoryRecord\r
{\r
- DisplayName = "Shared to me",\r
+ DisplayName = "Shared with me",\r
Directories=accountNodes.ToList()\r
};\r
\r
Directories = ownFolders.ToList()\r
};\r
\r
+ // Add Local Folders\r
+ ///var localFolders = SelectiveExtensions.LocalFolders(AccountName, Account.RootPath,client.StorageUrl.AbsoluteUri);\r
+\r
+ ///AppendToTree(localFolders, rootItem);\r
+ \r
+ //For each local folder that doesn't exist in the server nodes \r
+ //find the best matching parent and add the folder below it.\r
+\r
Execute.OnUIThread(() =>\r
{\r
RootNodes.Add(rootItem);\r
IsBusy = false;\r
}\r
\r
+ private static void AppendToTree(IEnumerable<DirectoryRecord> localFolders, DirectoryRecord rootItem)\r
+ {\r
+ foreach (var folder in localFolders)\r
+ {\r
+ var items = from root in rootItem\r
+ from child in root\r
+ select child;\r
+ //If this folder is not included in the server folders\r
+ if (items.Any(dir => dir.Uri == folder.Uri)) \r
+ continue;\r
+\r
+ //we need to add it\r
+ //Find the best parent\r
+\r
+ //One way to do this, is to break the the Uri to its parts\r
+ //and try to find a parent using progressively fewer parts\r
+ var parts = folder.Uri.AbsoluteUri.Split('/');\r
+ for (var i = parts.Length - 1; i > 2; i--)\r
+ {\r
+ var parentUrl = String.Join("/", parts.Splice(0, i));\r
+ var parentUri = new Uri(parentUrl);\r
+\r
+ var parent = items.FirstOrDefault(dir => dir.Uri == parentUri);\r
+ if (parent != null)\r
+ {\r
+ parent.Directories.Add(folder);\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
public bool IsBusy\r
{\r
get {\r
where record.Removed && record.Uri != null\r
select record.Uri).ToArray();\r
//TODO: Include Uris for the containers as well\r
- _events.Publish(new SelectiveSynchChanges{Account=Account,Uris=uris,Added=added,Removed=removed});\r
+ _events.Publish(new SelectiveSynchChanges{Enabled=IsEnabled, Account=Account,Uris=uris,Added=added,Removed=removed});\r
\r
\r
\r
TryClose(true);\r
}\r
\r
- \r
+ private bool _isEnabled;\r
+ public bool IsEnabled\r
+ {\r
+ get { return _isEnabled; }\r
+ set\r
+ {\r
+ _isEnabled = value;\r
+ NotifyOfPropertyChange(()=>IsEnabled);\r
+ }\r
+ }\r
+\r
private void SaveSettings(IEnumerable<Uri> uris)\r
{\r
var selections = uris.Select(uri => uri.ToString()).ToArray();\r
-\r
+ Account.SelectiveSyncEnabled = IsEnabled;\r
Account.SelectiveFolders.Clear();\r
Account.SelectiveFolders.AddRange(selections);\r
Settings.Default.Save(); \r