public override void DidFinishLaunching(NSNotification notification)
        {
            LocalExtensionManager = new ExtensionManager("com.userfilesystem.vfs.app", "ITHitFS6");

            NSMenu menu = new NSMenu();

            NSMenuItem installMenuItem   = new NSMenuItem("Install FS Extension", (a, b) => { LocalExtensionManager.InstallExtension(); });
            NSMenuItem uninstallMenuItem = new NSMenuItem("Uninstall FS Extension", (a, b) => { LocalExtensionManager.UninstallExtension(); });
            NSMenuItem exitMenuItem      = new NSMenuItem("Quit", (a, b) => { NSApplication.SharedApplication.Terminate(this); });

            menu.AddItem(installMenuItem);
            menu.AddItem(uninstallMenuItem);
            menu.AddItem(exitMenuItem);

            StatusItem               = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
            StatusItem.Menu          = menu;
            StatusItem.Image         = NSImage.ImageNamed("TrayIcon.png");
            StatusItem.HighlightMode = true;

            NSDictionary userData = AppGroupSettings.SaveSharedSettings("appsettings.json");

            if (!Directory.Exists(userData[AppGroupSettings.LocalPathId] as NSString))
            {
                NSAlert alert = NSAlert.WithMessage("Path is not found", null, null, null, "");
                alert.RunModal();

                NSApplication.SharedApplication.Terminate(this);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Returns a user file system path that corresponds to the remote storage URI.
        /// </summary>
        /// <param name="remoteStorageUri">Remote storage URI.</param>
        /// <returns>Path in the user file system that corresponds to the <paramref name="remoteStorageUri"/>.</returns>
        public static string ReverseMapPath(string remoteStorageUri)
        {
            // Get path relative to the virtual root.
            string relativePath = remoteStorageUri.TrimEnd(Path.DirectorySeparatorChar).Substring(
                AppGroupSettings.GetRemoteRootPath().TrimEnd(Path.DirectorySeparatorChar).Length);

            return($"{AppGroupSettings.GetUserRootPath().TrimEnd(Path.DirectorySeparatorChar)}{relativePath}");
        }
Beispiel #3
0
        /// <summary>
        /// Returns a remote storage URI that corresponds to the user file system path.
        /// </summary>
        /// <param name="userFileSystemPath">Full path in the user file system.</param>
        /// <returns>Remote storage URI that corresponds to the <paramref name="userFileSystemPath"/>.</returns>
        public static string MapPath(string userFileSystemPath)
        {
            // Get path relative to the virtual root.
            string relativePath = userFileSystemPath.TrimEnd(Path.DirectorySeparatorChar).Substring(
                AppGroupSettings.GetUserRootPath().TrimEnd(Path.DirectorySeparatorChar).Length);

            return($"{AppGroupSettings.GetRemoteRootPath().TrimEnd(Path.DirectorySeparatorChar)}{relativePath}");
        }
        public VfsEngine(NSFileProviderDomain domain)
            : base(domain)
        {
            License = AppGroupSettings.GetLicense();
            logger  = new ConsoleLogger(GetType().Name);

            remoteStorageMonitor = new RemoteStorageMonitor(AppGroupSettings.GetRemoteRootPath(), NSFileProviderManager.FromDomain(domain));
            remoteStorageMonitor.Start();
        }
Beispiel #5
0
        public FileProviderExtension()
        {
            ServerSettings serverSettings = AppGroupSettings.GetServerSettings();

            this.Session        = SessionFactory.Create(serverSettings);
            this.LocalStorage   = new LocalStorage();
            this.LocationMapper = new LocationMapper(serverSettings.ServerUri, this.LocalStorage.StorageRootPath);
            this.StorageManager = new StorageManager(this.LocationMapper, this.Session, this.LocalStorage);
        }
        async partial void Login_Clicked(UIButton sender)
        {
            string serverUri = this.Server.Text;
            string userName  = this.Username.Text;
            string passWord  = this.Password.Text;

            if (string.IsNullOrEmpty(serverUri) || string.IsNullOrWhiteSpace(serverUri))
            {
                this.ShowAlert(InvalidUriTitle, EmptyUriMessage);
                return;
            }


            try
            {
                this.LoginActivityIndicator.Hidden = false;
                this.LoginActivityIndicator.StartAnimating();
                sender.Enabled = false;
                var serverSettings = new ServerSettings(serverUri, userName, passWord);
                await SessionFactory.CheckConnectionAsync(serverSettings);

                var localStorage = new LocalStorage();
                localStorage.Clean();
                AppGroupSettings.SaveServerSettings(serverSettings);
                this.ShowAlert(LoginSuccessfulTitle, LoginSuccessfulMessage);
            }
            catch (System.Net.WebException ex)
            {
                if (ex.Status == System.Net.WebExceptionStatus.NameResolutionFailure)
                {
                    this.ShowAlert(InvalidUriTitle, IncorrectServerNameMessage);
                }
                else
                {
                    this.ShowAlert(ErrorTitle, ex.Message);
                }
            }
            catch (Exception ex)
            {
                this.ShowAlert(ErrorTitle, ex.Message);
            }
            finally
            {
                sender.Enabled = true;
            }

            this.Editing = false;
            this.Server.ResignFirstResponder();
            this.Username.ResignFirstResponder();
            this.Password.ResignFirstResponder();
        }
Beispiel #7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ServerSettings serverSettings = AppGroupSettings.GetServerSettings();

            if (serverSettings != null)
            {
                this.Server.Text   = serverSettings.ServerUri.ToString();
                this.Username.Text = serverSettings.UserName ?? string.Empty;
                this.Password.Text = serverSettings.Password ?? string.Empty;
            }

#if DEBUG
            this.Server.Text = "http://webdavserver.net/User7bb0de4/";
#endif
        }
 public VfsEngine(NSFileProviderDomain domain)
     : base(domain)
 {
     License = AppGroupSettings.GetLicense();
 }