Esempio n. 1
0
        /// <summary>
        /// Update repository settings.
        /// </summary>
        public virtual void UpdateSettings(string password, int pollInterval)
        {
            //Get configuration
            Config config = ConfigManager.CurrentConfig;

            CmisSync.Lib.Config.SyncConfig.Folder syncConfig = config.getFolder(this.Name);

            //Pause sync
            this.remote_timer.Stop();
            if (Status == SyncStatus.Idle)
            {
                Suspend();
            }

            //Update password...
            if (!String.IsNullOrEmpty(password))
            {
                this.RepoInfo.Password        = new CmisSync.Auth.CmisPassword(password.TrimEnd());
                syncConfig.ObfuscatedPassword = RepoInfo.Password.ObfuscatedPassword;
                Logger.Debug("Updated \"" + this.Name + "\" password");
            }

            //Update poll interval
            this.RepoInfo.PollInterval = pollInterval;
            this.remote_timer.Interval = pollInterval;
            syncConfig.PollInterval    = pollInterval;
            Logger.Debug("Updated \"" + this.Name + "\" poll interval: " + pollInterval);

            //Save configuration
            config.Save();

            //Always resume sync...
            Resume();
            this.remote_timer.Start();
        }
Esempio n. 2
0
        /// <summary>
        /// Called when sync completes.
        /// </summary>
        public void OnSyncComplete(bool syncFull)
        {
            if (syncFull)
            {
                remote_timer.Start();
                last_sync = DateTime.Now;
            }
            else
            {
                last_partial_sync = DateTime.Now;
            }

            if (Watcher.GetChangeCount() > 0)
            {
                //Watcher was stopped (due to error) so clear and restart sync
                Watcher.Clear();
            }

            Watcher.EnableRaisingEvents = true;
            Watcher.EnableEvent         = true;
            Logger.Info((syncFull ? "Full" : "Partial") + " Sync Complete: " + LocalPath);

            // Save last sync
            RepoInfo.LastSuccessedSync = DateTime.Now;

            //Get configuration
            Config config = ConfigManager.CurrentConfig;

            CmisSync.Lib.Config.SyncConfig.Folder syncConfig = config.getFolder(this.Name);
            syncConfig.LastSuccessedSync = RepoInfo.LastSuccessedSync;
            config.Save();
        }
Esempio n. 3
0
        /// <summary>
        /// Stop syncing momentarily.
        /// </summary>
        public void Disable()
        {
            Enabled = false;
            RepoInfo.IsSuspended = true;

            //Get configuration
            Config config = ConfigManager.CurrentConfig;

            CmisSync.Lib.Config.SyncConfig.Folder syncConfig = config.GetFolder(this.Name);
            syncConfig.IsSuspended = true;
            config.Save();
        }
Esempio n. 4
0
        /// <summary>
        /// Restart syncing.
        /// </summary>
        public virtual void Resume()
        {
            Status = SyncStatus.Idle;
            RepoInfo.IsSuspended = false;

            //Get configuration
            Config config = ConfigManager.CurrentConfig;

            CmisSync.Lib.Config.SyncConfig.Folder syncConfig = config.GetFolder(this.Name);
            syncConfig.IsSuspended = false;
            config.Save();
        }
Esempio n. 5
0
        /// <summary>
        /// Stop syncing momentarily.
        /// </summary>
        public void Suspend()
        {
            Status = SyncStatus.Suspend;
            RepoInfo.IsSuspended = true;

            //Get configuration
            Config config = ConfigManager.CurrentConfig;

            CmisSync.Lib.Config.SyncConfig.Folder syncConfig = config.GetFolder(this.Name);
            syncConfig.IsSuspended = true;
            config.Save();
        }
Esempio n. 6
0
 /// <summary>
 /// With the default web browser, open the remote folder of a CmisSync synchronized folder.
 /// </summary>
 public void SettingsClicked(string reponame)
 {
     CmisSync.Lib.Config.SyncConfig.Folder repository = ConfigManager.CurrentConfig.getFolder(reponame);
     Program.UI.Setup.Controller.saved_repository = reponame;
     if (repository != null)
     {
         Program.UI.Setup.Controller.saved_user          = repository.UserName;
         Program.UI.Setup.Controller.saved_remote_path   = repository.RemotePath;
         Program.UI.Setup.Controller.saved_address       = repository.RemoteUrl;
         Program.UI.Setup.Controller.saved_sync_interval = (int)repository.PollInterval;
     }
     Program.Controller.ShowSetupWindow(PageType.Settings);
 }
Esempio n. 7
0
        /// <summary>
        /// Load folder configuration.
        /// </summary>
        private void AddSynchronizedFolder(string folderName)
        {
            Config config = ConfigManager.CurrentConfig;

            CmisSync.Lib.Config.SyncConfig.Folder folder = config.GetFolder(folderName);
            if (folder == null)
            {
                System.Console.WriteLine("No folder found with this name: " + folderName);
                return;
            }
            RepoInfo repoInfo = folder.GetRepoInfo();

            repos.Add(repoInfo);
        }
Esempio n. 8
0
        /// <summary>
        /// Load folder configuration.
        /// </summary>
        private void AddSynchronizedFolder(string folderName, bool enableWatcher)
        {
            Config config = ConfigManager.CurrentConfig;

            CmisSync.Lib.Config.SyncConfig.Folder folder = config.GetFolder(folderName);
            if (folder == null)
            {
                System.Console.WriteLine("No folder found with this name: " + folderName);
                return;
            }
            RepoInfo repoInfo = folder.GetRepoInfo();
            CmisRepo cmisRepo = new CmisRepo(repoInfo, controller, enableWatcher, perpetual);

            repos.Add(cmisRepo);
        }
Esempio n. 9
0
        /// <summary>
        /// Load folder configuration.
        /// </summary>
        private void Init(string folderName)
        {
            Config config = ConfigManager.CurrentConfig;

            CmisSync.Lib.Config.SyncConfig.Folder folder = config.getFolder(folderName);
            if (folder == null)
            {
                System.Console.WriteLine("No folder found with this name: " + folderName);
                return;
            }
            RepoInfo repoInfo = folder.GetRepoInfo();

            ConsoleController controller = new ConsoleController();

            cmisRepo = new CmisRepo(repoInfo, controller);
        }
Esempio n. 10
0
        private static bool IsAlfresco42OrLater(CmisSync.Lib.Config.SyncConfig.Folder folder, string newUrl)
        {
            try
            {
                CmisUtils.GetSubfolders(
                    folder.RepositoryId,
                    folder.RemotePath,
                    newUrl,
                    folder.UserName,
                    Crypto.Deobfuscate(folder.ObfuscatedPassword));

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Update repository settings.
        /// </summary>
        public virtual void UpdateSettings(string password, int pollInterval, bool syncAtStartup)
        {
            //Get configuration
            Config config = ConfigManager.CurrentConfig;

            CmisSync.Lib.Config.SyncConfig.Folder syncConfig = config.GetFolder(this.Name);

            //Pause sync
            this.remote_timer.Stop();
            if (Enabled)
            {
                Disable();
            }

            //Update password...
            if (!String.IsNullOrEmpty(password))
            {
                this.RepoInfo.Password        = new Password(password.TrimEnd());
                syncConfig.ObfuscatedPassword = RepoInfo.Password.ObfuscatedPassword;
                Logger.Debug("Updated \"" + this.Name + "\" password");
            }

            // Sync at startup
            syncConfig.SyncAtStartup = syncAtStartup;

            //Update poll interval
            this.RepoInfo.PollInterval = pollInterval;
            this.remote_timer.Interval = pollInterval;
            syncConfig.PollInterval    = pollInterval;
            Logger.Debug("Updated \"" + this.Name + "\" poll interval: " + pollInterval);

            //Save configuration
            config.Save();

            //Always resume sync...
            Enable();
            this.remote_timer.Start();
        }