[tomboy] Add notebook-related methods to remote control (bug #576329)



commit 11836f8fe4ec6617b958ba12ee4b943ea5b97193
Author: Clemens N. Buss <cebuzz gmail com>
Date:   Sun Nov 15 22:39:21 2009 -0800

    Add notebook-related methods to remote control (bug #576329)

 Tomboy.mdp                     |    2 +
 Tomboy/IRemoteControl.cs       |    8 +++++-
 Tomboy/RemoteControl.cs        |   45 ++++++++++++++++++++++++++++++++++++++++
 Tomboy/RemoteControlWrapper.cs |   22 ++++++++++++++++++-
 4 files changed, 74 insertions(+), 3 deletions(-)
---
diff --git a/Tomboy.mdp b/Tomboy.mdp
index d7a1bba..8ab265b 100644
--- a/Tomboy.mdp
+++ b/Tomboy.mdp
@@ -14,6 +14,8 @@
     </Configuration>
   </Configurations>
   <Contents>
+    <File subtype="Code" buildaction="Compile" name="Tomboy/IRemoteControl.cs" />
+    <File subtype="Code" buildaction="Compile" name="Tomboy/RemoteControlWrapper.cs" />
     <File name="Tomboy/ActionManager.cs" subtype="Code" buildaction="Compile" />
     <File name="Tomboy/Applet.cs" subtype="Code" buildaction="Compile" />
     <File name="Tomboy/Logger.cs" subtype="Code" buildaction="Compile" />
diff --git a/Tomboy/IRemoteControl.cs b/Tomboy/IRemoteControl.cs
index adf4de1..6004ca5 100644
--- a/Tomboy/IRemoteControl.cs
+++ b/Tomboy/IRemoteControl.cs
@@ -1,9 +1,11 @@
-using System;
+using System;
 
 namespace Tomboy
 {
 	public interface IRemoteControl
 	{
+		bool AddNotebook (string notebook_name);
+		bool AddNoteToNotebook (string uri, string notebook_name);
 		bool AddTagToNote (string uri, string tag_name);
 		string CreateNamedNote (string linked_title);
 		string CreateNamedNoteWithUri (string linked_title, string uri);
@@ -15,7 +17,9 @@ namespace Tomboy
 		void DisplaySearchWithText (string search_text);
 		string FindNote (string linked_title);
 		string FindStartHereNote ();
-		string [] GetAllNotesWithTag (string tag_name);
+		string [] GetAllNotesInNotebook (string notebook_name);
+ 		string [] GetAllNotesWithTag (string tag_name);
+		string GetNotebookForNote (string uri);
 		long GetNoteChangeDate (string uri);
 		string GetNoteCompleteXml (string uri);
 		string GetNoteContents (string uri);
diff --git a/Tomboy/RemoteControl.cs b/Tomboy/RemoteControl.cs
index f135a58..d5e60cd 100644
--- a/Tomboy/RemoteControl.cs
+++ b/Tomboy/RemoteControl.cs
@@ -6,6 +6,8 @@ using NDesk.DBus;
 using org.freedesktop.DBus;
 #endif
 
+using Tomboy.Notebooks;
+
 namespace Tomboy
 {
 	public delegate void RemoteDeletedHandler (string uri, string title);
@@ -328,6 +330,49 @@ namespace Tomboy
 			return tagged_note_uris;
 		}
 
+		public string GetNotebookForNote (string uri)
+		{
+			Note note = note_manager.FindByUri (uri);
+			if (note == null)
+				return string.Empty;
+			Notebook notebook = NotebookManager.GetNotebookFromNote (note);
+			if (notebook == null)
+				return string.Empty;
+			return notebook.Name;
+		}
+
+		public bool AddNoteToNotebook (string uri, string notebook_name)
+		{
+			Note note = note_manager.FindByUri (uri);
+			if (note == null)
+				return false;
+			Notebook notebook = NotebookManager.GetNotebook (notebook_name);
+			if (notebook == null)
+				return false;
+			return NotebookManager.MoveNoteToNotebook (note, notebook);
+		}
+
+		public string [] GetAllNotesInNotebook (string notebook_name)
+		{
+			Tag tag = TagManager.GetTag (Tag.SYSTEM_TAG_PREFIX + Notebook.NotebookTagPrefix + notebook_name);
+			if (tag == null)
+				return new string [0];
+			string [] tagged_note_uris = new string [tag.Notes.Count];
+			for (int i = 0; i < tagged_note_uris.Length; i++)
+				tagged_note_uris [i] = tag.Notes [i].Uri;
+			return tagged_note_uris;
+		}
+
+		public bool AddNotebook (string notebook_name)
+		{
+			if (NotebookManager.GetNotebook (notebook_name) != null)
+				return false;
+			Notebook notebook = NotebookManager.GetOrCreateNotebook (notebook_name);
+			if (notebook == null)
+				return false;
+			return true;
+		}
+
 		private void OnNoteDeleted (object sender, Note note)
 		{
 			if (NoteDeleted != null)
diff --git a/Tomboy/RemoteControlWrapper.cs b/Tomboy/RemoteControlWrapper.cs
index b92cc1f..9fa1ad3 100644
--- a/Tomboy/RemoteControlWrapper.cs
+++ b/Tomboy/RemoteControlWrapper.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
 
 namespace Tomboy
 {
@@ -185,6 +185,26 @@ namespace Tomboy
 			return remote.Version ();
 		}
 
+		public string GetNotebookForNote (string uri)
+		{
+			return remote.GetNotebookForNote (uri);
+		}
+
+		public bool AddNoteToNotebook (string uri, string notebook_name)
+		{
+			return remote.AddNoteToNotebook (uri, notebook_name);
+		}
+
+		public string [] GetAllNotesInNotebook (string notebook_name)
+		{
+			return remote.GetAllNotesInNotebook (notebook_name);
+		}
+
+		public bool AddNotebook (string notebook_name)
+		{
+			return remote.AddNotebook (notebook_name);
+		}
+
 		#endregion
 	}
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]