Exemplo n.º 1
0
        /// <summary>
        /// called during the ctor of the base-class, here we fetch the data from the server to have the same
        /// </summary>
        internal override void SetupWorkDirectory(object initParam)
        {
            Logger.Debug("basic stuff");
            base.SetupWorkDirectory(initParam);

            // because we only sync to the server and just copy the stuff everytime we
            // sync, we only need to use a temp-directory
            serverPath = cachePath;

            // refresh these variables because they would be wrong else
            lockPath     = System.IO.Path.Combine(serverPath, "lock");
            manifestPath = System.IO.Path.Combine(serverPath, "manifest.xml");


            Logger.Debug("getting webdav interface");
            // this must be the webdav interface (not very nice way to do it, but did't know any other way)
            webdavserver = initParam as WebDAVInterface;

            Logger.Debug("deleting local files");
            // make our local sync dir empty
            Util.DelelteFilesInDirectory(serverPath);

            Logger.Debug("checking for remote lockfile");
            // fetch data from server
            if (webdavserver.CheckForLockFile())
            {
                Logger.Debug("downloading lockfile");
                webdavserver.DownloadLockFile(lockPath);
            }
            Logger.Debug("downloading notes");
            webdavserver.DownloadNotes(serverPath);
            Logger.Debug("workdir setup done");
        }
        /// <summary>
        /// called during the ctor of the base-class, here we fetch the data from the server to have the same 
        /// </summary>
        internal override void SetupWorkDirectory(object initParam)
        {
            Logger.Debug("basic stuff");
            base.SetupWorkDirectory(initParam);

            // because we only sync to the server and just copy the stuff everytime we
            // sync, we only need to use a temp-directory
            serverPath = cachePath;

            // refresh these variables because they would be wrong else
            lockPath = System.IO.Path.Combine(serverPath, "lock");
            manifestPath = System.IO.Path.Combine(serverPath, "manifest.xml");

            Logger.Debug("getting webdav interface");
            // this must be the webdav interface (not very nice way to do it, but did't know any other way)
            webdavserver = initParam as WebDAVInterface;

            Logger.Debug("deleting local files");
            // make our local sync dir empty
            Util.DelelteFilesInDirectory(serverPath);

            Logger.Debug("checking for remote lockfile");
            // fetch data from server
            if (webdavserver.CheckForLockFile())
            {
                Logger.Debug("downloading lockfile");
                webdavserver.DownloadLockFile(lockPath);
            }
            Logger.Debug("downloading notes");
            webdavserver.DownloadNotes(serverPath);
            Logger.Debug("workdir setup done");
        }
 public EncryptedWebdavSyncServer(String _tempDir, byte[] _key, WebDAVInterface _webDav)
     : base(_tempDir, _key, _webDav)
 {
 }
Exemplo n.º 4
0
 public EncryptedWebdavSyncServer(String _tempDir, byte[] _key, WebDAVInterface _webDav)
     : base(_tempDir, _key, _webDav)
 {
 }
Exemplo n.º 5
0
		private WebDAVInterface getClient()
		{
			WebDAVInterface wdc = new WebDAVInterface(TESTSERVER, TESTPATH, TESTUSER, TESTPASSWORD, false);
			return wdc;
		}
        /// <summary>
        /// Get config settings
        /// </summary>
        private bool GetConfigSettings(out string _password, out WebDAVInterface _webdav)
        {
            _password = null;
            _webdav = null;

            object ask = Preferences.Get(AddinPreferences.SYNC_PRIVATENOTES_ASKEVERYTIME);

            if (ask == null)
                return false;

            if (((bool)ask == false))
            {
            #if WIN32 && DPAPI
                object pw = DPAPIUtil.getPassword();
            #else
                object pw = Preferences.Get(AddinPreferences.SYNC_PRIVATENOTES_PASSWORD);
            #endif
                if (pw != null)
                {
                    _password = Convert.ToString(pw); // quick fix -> a num-only pw is returned as an int o.O
                }
            }

            if (_password == null)
            {
                // ask for password
                var entryWindow = new PrivateNotes.PasswordEntry();

                _password = entryWindow.getPassword();
            }

            #if USE_LOCAL_TEST
             _webdav = new WebDAVInterface("http://localhost", "/webdav/notes", "wampp", "xampp", false);
            #else
            Uri serverUri = new Uri(Convert.ToString(Preferences.Get(AddinPreferences.SYNC_PRIVATENOTES_SERVERPATH)));

            String serverHost = serverUri.GetLeftPart(UriPartial.Authority);
            String serverBasePath = serverUri.AbsolutePath;

            bool checkSslCertificates = true;
            object checksslobj = Preferences.Get(AddinPreferences.SYNC_PRIVATENOTES_SERVERCHECKSSLCERT);
            if (checksslobj != null && (checksslobj.Equals(false) || checksslobj.Equals("false")))
                checkSslCertificates = false;

            string serverUser = (string)Preferences.Get(AddinPreferences.SYNC_PRIVATENOTES_SERVERUSER);
            string serverPass = (string)Preferences.Get(AddinPreferences.SYNC_PRIVATENOTES_SERVERPASS);

            Logger.Debug("will user server: " + serverHost + " path: " + serverBasePath);
            //Logger.Debug("creating server with user " + serverUser + " pass: " + serverPass);

            _webdav = new WebDAVInterface(serverHost, serverBasePath,
                serverUser,
                serverPass,
                checkSslCertificates);
            #endif

            if (_webdav != null && _password != null)
                return true;

            return false;
        }