public void SetUp()
        {
            var current_dir = Directory.GetCurrentDirectory ();
            serverStorageDir = Path.Combine (current_dir, "../../syncserver/");

            serverStorage = new DiskStorage (serverStorageDir);

            serverEngine = new Engine (serverStorage);

            manifest = new SyncManifest ();
            syncServer = new FilesystemSyncServer (serverEngine, manifest);

            CreateSomeSampleNotes ();
        }
Пример #2
0
		/// <summary>
		/// Syncs the notes.
		/// </summary>
		/// <param name="sender">Sender.</param>
		partial void SyncNotes(NSObject sender) {
			var dest_manifest_path = Path.Combine (settings.syncURL, "manifest.xml");
			SyncManifest dest_manifest;
			if (!File.Exists (dest_manifest_path)) {
				using (var output = new FileStream (dest_manifest_path, FileMode.Create)) {
					SyncManifest.Write (new SyncManifest (), output);
				}
			}
			using (var input = new FileStream (dest_manifest_path, FileMode.Open)) {
				dest_manifest = SyncManifest.Read (input);
			}
			var dest_storage = new DiskStorage (settings.syncURL);
			var dest_engine = new Engine (dest_storage);

			var client = new FilesystemSyncClient (NoteEngine, manifestTracker.Manifest);
			var server = new FilesystemSyncServer (dest_engine, dest_manifest);
			var sync_manager = new SyncManager(client, server);
			sync_manager.DoSync ();
			RefreshNotesWindowController();
			// write back the dest manifest
		        using (var output = new FileStream (dest_manifest_path, FileMode.Create)) {
				SyncManifest.Write (dest_manifest, output);
			}

        	}
 private void InitServer()
 {
     serverStorage = new DiskStorage ();
     serverStorage.SetPath (serverStorageDir);
     serverEngine = new Engine (serverStorage);
     serverManifest = new SyncManifest ();
     syncServer = new FilesystemSyncServer (serverEngine, serverManifest);
 }
Пример #4
0
		/// <summary>
		/// Syncs the notes.
		/// </summary>
		/// <param name="sender">Sender.</param>
		partial void SyncNotes(NSObject sender) {

			bool success = false;

			if (!String.IsNullOrEmpty (settings.syncURL) || !String.IsNullOrWhiteSpace (settings.syncURL)) {

				var dest_manifest_path = Path.Combine (settings.syncURL, "manifest.xml");
				SyncManifest dest_manifest;
				if (!File.Exists (dest_manifest_path)) {
					using (var output = new FileStream (dest_manifest_path, FileMode.Create)) {
						SyncManifest.Write (new SyncManifest (), output);
					}
				}
				using (var input = new FileStream (dest_manifest_path, FileMode.Open)) {
					dest_manifest = SyncManifest.Read (input);
				}
				var dest_storage = new DiskStorage (settings.syncURL);
				var dest_engine = new Engine (dest_storage);

				var client = new FilesystemSyncClient (NoteEngine, manifestTracker.Manifest);
				var server = new FilesystemSyncServer (dest_engine, dest_manifest);
				new SyncManager(client, server).DoSync ();

				// write back the dest manifest
		        	using (var output = new FileStream (dest_manifest_path, FileMode.Create)) {
					SyncManifest.Write (dest_manifest, output);
				}

				PopulateNotebookList (false);
				RefreshNotesWindowController ();

				success = true;
			}

			else if (!String.IsNullOrEmpty (settings.webSyncURL) ||!String.IsNullOrWhiteSpace (settings.webSyncURL)) {

				ServicePointManager.CertificatePolicy = new DummyCertificateManager();

				OAuthToken reused_token = new OAuthToken { Token = settings.token, Secret = settings.secret };


				ISyncClient client = new FilesystemSyncClient (NoteEngine, manifestTracker.Manifest);
				ISyncServer server = new WebSyncServer (settings.webSyncURL, reused_token);

				new SyncManager (client, server).DoSync ();

				PopulateNotebookList (false);
				RefreshNotesWindowController ();

				success = true;
			}

			if (success) {
				NSAlert alert = new NSAlert () {
					MessageText = "Sync Successful",
					InformativeText = "The sync was successful",
					AlertStyle = NSAlertStyle.Warning
				};
				alert.AddButton ("OK");
				alert.BeginSheet (null);
				alert.Window.Title = "Sync Successful";
			} else {
				NSAlert alert = new NSAlert () {
					MessageText = "Sync Failed",
					InformativeText = "The sync was not successful. Please check the Sync Settings.",
					AlertStyle = NSAlertStyle.Warning
				};
				alert.AddButton ("OK");
				alert.BeginSheet (null);
				alert.Window.Title = "Sync Failed";
			}
        	}
 protected override void ClearServer(bool reset = false)
 {
     if (reset) {
         serverManifest = new SyncManifest ();
         CleanupServerDirectory ();
     }
     serverStorage = new DiskStorage ();
     serverStorage.SetPath (serverStorageDir);
     serverEngine = new Engine (serverStorage);
     syncServer = new FilesystemSyncServer (serverEngine, serverManifest);
 }