public Task<bool> ShareFolder (string path, List<Identity> users)
		{
			return Task.Run (() => {

				LocalBox box = DataLayer.Instance.GetSelectedOrDefaultBox ();
				var explorer = new RemoteExplorer (box);

				var messages = AddKeys (path, users, users.Select (e => e).ToList ());
				foreach (var message in messages) {
					var r = explorer.AddAesKey (path, message);
				}
				return explorer.ShareFolder (path, users);
			});
		}
		public Task<bool> UpdateSettingsSharedFolder (Share share, List<Identity> usersToShareWith)
		{
			return Task.Run (() => {
				LocalBox box = DataLayer.Instance.GetSelectedOrDefaultBox ();
				var explorer = new RemoteExplorer (box);

				List<Identity> inBoth = (from local in share.Identities
				                          join remote in usersToShareWith
                on local.Id equals remote.Id
				                          select local).ToList ();

				var toAdd = usersToShareWith.Where (e => inBoth.All (f => f.Id != e.Id)).ToList ();
				var toRemove = share.Identities.Where (e => inBoth.All (f => f.Id != e.Id)).ToList ();

				var messages = AddKeys (share.Item.Path, usersToShareWith, toAdd);
				RemoveKeys (share.Item.Path, toRemove);
					

				var result = explorer.UpdateSettingsSharedFolder (share.Id, usersToShareWith);

				foreach (var message in messages) {
					var r = explorer.AddAesKey (share.Item.Path, message);
				}

				return result;
			});
		}
Example #3
0
        public Task<bool> CreateFolder(string path, bool encrypt = true) {
            return Task.Run(() =>
            {
                var explorer = new RemoteExplorer();
                var result = explorer.CreateFolder(path);

                // kijken of het een map op rootniveau is
                if(encrypt && path.Count(e => e == '/') == 1) {
                    AESKeyAndIVGenerator gen = new AESKeyAndIVGenerator();
                    var box = GetSelectedOrDefaultBox();
                    var post = new AesKeyPost() {
                        User = null,
                        Key = Convert.ToBase64String(CryptoHelper.EncryptPgp(gen.aesKey, box.PublicKey)),
                        IV = Convert.ToBase64String(CryptoHelper.EncryptPgp(gen.aesIV, box.PublicKey))
                    };

                    var keyResult = explorer.AddAesKey(path, post);
                }
                return result;
            });
        }