Exemple #1
0
		public ManifestTracker (Engine engine, string path) {
			this.path = path;

			if (!File.Exists (path)) {
				Manifest = new SyncManifest ();
				using (var output = new FileStream (path, FileMode.Create)) {
					SyncManifest.Write (Manifest, output);
				}
				foreach (Note note in engine.GetNotes ().Values) {
					Manifest.NoteRevisions [note.Guid] = Manifest.LastSyncRevision + 1;
				}
				Flush ();
			}

			using (var input = new FileStream (path, FileMode.Open)) {
				this.Manifest = SyncManifest.Read (input);
                		input.Close();
			}
			engine.NoteAdded += (Note note) => {
				Console.WriteLine ("Note added");
				Manifest.NoteRevisions [note.Guid] = Manifest.LastSyncRevision + 1;
			};

			engine.NoteUpdated += (Note note) => {
				Console.WriteLine ("Note updated");
				Manifest.NoteRevisions [note.Guid] = Manifest.LastSyncRevision + 1;
			};

			engine.NoteRemoved += (Note note) => {
				Console.WriteLine ("Note removed: " + note.Guid);
				Manifest.NoteDeletions.Add (note.Guid, note.Title);
			};
		}
Exemple #2
0
        public AppDelegate()
        {
            // TODO, set it in a generic way
            Tomboy.DiskStorage.Instance.SetPath ("/Users/jeremie/projects/MacBoy/test-notes");
            NoteEngine = new Engine (Tomboy.DiskStorage.Instance);
            Notes = NoteEngine.GetNotes ();

            // Create our cache directory
            if (!Directory.Exists (BaseUrlPath))
                Directory.CreateDirectory (BaseUrlPath);
        }
        private static void ProcessDirectory(string targetDirectory, Engine appEngine)
        {
            DiskStorage noteStorage = new DiskStorage (targetDirectory);
            Engine noteEngine = new Engine (noteStorage);
            Dictionary<string,Note> notes = new Dictionary<string,Note>();

            try {
                notes = noteEngine.GetNotes ();
            } catch (ArgumentException) {
                Console.WriteLine ("Found an exception with {0}",targetDirectory);
            }

            foreach (Note note in notes.Values) {

                Note newNote = appEngine.NewNote ();
                newNote.ChangeDate = note.ChangeDate;
                newNote.CreateDate = note.CreateDate;
                newNote.CursorPosition = note.CursorPosition;
                newNote.Height = note.Height;
                newNote.MetadataChangeDate = note.MetadataChangeDate;
                newNote.Notebook = note.Notebook;
                newNote.OpenOnStartup = note.OpenOnStartup;
                newNote.SelectionBoundPosition = note.SelectionBoundPosition;
                newNote.Tags = note.Tags;
                newNote.Text = note.Text;
                newNote.Title = note.Title;
                newNote.Width = note.Width;
                newNote.X = note.X;
                newNote.Y = note.Y;
                appEngine.SaveNote (newNote, false);

                Console.WriteLine ("Imported the Note {0}",newNote.Title);
            }

            string [] subdirectoryEntries = System.IO.Directory.GetDirectories(targetDirectory);
            foreach(string subdirectory in subdirectoryEntries)
                ProcessDirectory(subdirectory, appEngine);
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="Tomboy.AppDelegate"/> class.
		/// </summary>
		public AppDelegate () {
			var storage_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Library", "Application Support", "Tomboy");
            		// TODO, set it in a generic way
            		noteStorage = new DiskStorage (storage_path);
            		noteStorage.SetBackupPath(backupPathUri);

            		if (!Directory.Exists(backupPathUri))
                		noteStorage.Backup(); //FIXME: Need to better handle status messages.

			Logger.Debug ("Backup Path set to {0}", backupPathUri);

			NoteEngine = new Engine (noteStorage);

			// keep track of note for syncing
			// TODO move this into an Add-in one day
			var manifest_path = Path.Combine (storage_path, "manifest.xml");
			manifestTracker = new ManifestTracker (NoteEngine, manifest_path);

			// Create our cache directory
			if (!Directory.Exists (BaseUrlPath))
				Directory.CreateDirectory (BaseUrlPath);

			// Currently lazy load because otherwise the Dock Menu throws an error about there being no notes.
			if (Notes == null)
				Notes = NoteEngine.GetNotes ();
			
			NoteEngine.NoteAdded += HandleNoteAdded;
			NoteEngine.NoteRemoved += HandleNoteRemoved;
			NoteEngine.NoteUpdated += HandleNoteUpdated;

			settings = SettingsSync.Read();

            		Notebooks = new List<string>();
            		currentNotebook = "All Notebooks";
            		PopulateNotebookList();
		}