[tomboy] Add skeleton of WebSyncServiceAddin for supporting Snowy sync.



commit 3de83019585fc38578ccfb6646f16cd85ed088b5
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date:   Thu May 14 17:54:19 2009 -0700

    Add skeleton of WebSyncServiceAddin for supporting Snowy sync.
---
 Tomboy.mdp                                         |    7 ++
 Tomboy/Addins/Makefile.am                          |    3 +-
 Tomboy/Addins/WebSyncService/Api/NoteInfo.cs       |   51 +++++++++
 Tomboy/Addins/WebSyncService/Api/UserInfo.cs       |   52 +++++++++
 Tomboy/Addins/WebSyncService/Makefile.am           |   46 ++++++++
 Tomboy/Addins/WebSyncService/WebSyncServer.cs      |  105 ++++++++++++++++++
 .../Addins/WebSyncService/WebSyncService.addin.xml |   21 ++++
 .../Addins/WebSyncService/WebSyncServiceAddin.cs   |  114 ++++++++++++++++++++
 configure.in                                       |    1 +
 9 files changed, 399 insertions(+), 1 deletions(-)

diff --git a/Tomboy.mdp b/Tomboy.mdp
index 5c3c455..0193e55 100644
--- a/Tomboy.mdp
+++ b/Tomboy.mdp
@@ -145,6 +145,12 @@
     <File name="Tomboy/Addins/ExportToHtml/ExportToHtml.xsl" subtype="Code" buildaction="Nothing" />
     <File name="Tomboy/Addins/NoteDirectoryWatcher/NoteDirectoryWatcher.addin.xml" subtype="Code" buildaction="Nothing" />
     <File name="Tomboy/Addins/NoteDirectoryWatcher/NoteDirectoryWatcherApplicationAddin.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/Addins/WebSyncService" subtype="Directory" buildaction="Compile" />
+    <File name="Tomboy/Addins/WebSyncService/WebSyncServiceAddin.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/Addins/WebSyncService/WebSyncServer.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/Addins/WebSyncService/Api" subtype="Directory" buildaction="Compile" />
+    <File name="Tomboy/Addins/WebSyncService/Api/NoteInfo.cs" subtype="Code" buildaction="Compile" />
+    <File name="Tomboy/Addins/WebSyncService/Api/UserInfo.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
@@ -156,6 +162,7 @@
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
     <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Cairo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
+    <ProjectReference type="Gac" localcopy="True" refto="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
   </References>
   <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am" ExecuteTargetName="run">
     <BuildFilesVar />
diff --git a/Tomboy/Addins/Makefile.am b/Tomboy/Addins/Makefile.am
index 9520b67..a6c4d16 100644
--- a/Tomboy/Addins/Makefile.am
+++ b/Tomboy/Addins/Makefile.am
@@ -14,5 +14,6 @@ SUBDIRS =				\
 	StickyNoteImport	\
 	Tasque			\
 	NoteDirectoryWatcher			\
-	WebDavSyncService
+	WebDavSyncService			\
+	WebSyncService
 
diff --git a/Tomboy/Addins/WebSyncService/Api/NoteInfo.cs b/Tomboy/Addins/WebSyncService/Api/NoteInfo.cs
new file mode 100644
index 0000000..6ddf78a
--- /dev/null
+++ b/Tomboy/Addins/WebSyncService/Api/NoteInfo.cs
@@ -0,0 +1,51 @@
+// Permission is hereby granted, free of charge, to any person obtaining 
+// a copy of this software and associated documentation files (the 
+// "Software"), to deal in the Software without restriction, including 
+// without limitation the rights to use, copy, modify, merge, publish, 
+// distribute, sublicense, and/or sell copies of the Software, and to 
+// permit persons to whom the Software is furnished to do so, subject to 
+// the following conditions: 
+//  
+// The above copyright notice and this permission notice shall be 
+// included in all copies or substantial portions of the Software. 
+//  
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+// 
+// Copyright (c) 2008 Novell, Inc. (http://www.novell.com) 
+// 
+// Authors: 
+//      Sandy Armstrong <sanfordarmstrong gmail com>
+// 
+
+using System;
+using System.Collections.Generic;
+
+namespace Tomboy.WebSync.Api
+{
+	public class NoteInfo
+	{
+		public string Guid { get; private set; }
+		
+		public string Uri { get; private set; }
+		
+		public string Title { get; private set; }
+		
+		public string XmlContent { get; private set; }
+		
+		public DateTime LastChangeDate { get; private set; }
+		
+		public DateTime LastMetadataChangeDate { get; private set; }
+		
+		public DateTime CreateDate { get; private set; }
+		
+		public bool OpenOnStartup { get; private set; }
+		
+		public List<string> Tags { get; private set; }
+	}
+}
diff --git a/Tomboy/Addins/WebSyncService/Api/UserInfo.cs b/Tomboy/Addins/WebSyncService/Api/UserInfo.cs
new file mode 100644
index 0000000..ad23a91
--- /dev/null
+++ b/Tomboy/Addins/WebSyncService/Api/UserInfo.cs
@@ -0,0 +1,52 @@
+// Permission is hereby granted, free of charge, to any person obtaining 
+// a copy of this software and associated documentation files (the 
+// "Software"), to deal in the Software without restriction, including 
+// without limitation the rights to use, copy, modify, merge, publish, 
+// distribute, sublicense, and/or sell copies of the Software, and to 
+// permit persons to whom the Software is furnished to do so, subject to 
+// the following conditions: 
+//  
+// The above copyright notice and this permission notice shall be 
+// included in all copies or substantial portions of the Software. 
+//  
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+// 
+// Copyright (c) 2008 Novell, Inc. (http://www.novell.com) 
+// 
+// Authors: 
+//      Sandy Armstrong <sanfordarmstrong gmail com>
+// 
+
+using System;
+using System.Collections.Generic;
+using System.Web.Script.Serialization;
+
+namespace Tomboy.WebSync.Api
+{
+	public class UserInfo
+	{
+		public string FirstName { get; private set; }
+
+		public string LastName { get; private set; }
+
+		public string NotesUri { get; private set; }
+
+		public string FriendsUri { get; private set; }
+
+		public IList<NoteInfo> GetNotes (bool includeContent)
+		{
+			string jsonString = string.Empty;
+
+			// TODO: Do request using NotesUri
+
+			JavaScriptSerializer ser = new JavaScriptSerializer ();
+			return ser.Deserialize <List<NoteInfo>> (jsonString);
+		}
+	}
+}
diff --git a/Tomboy/Addins/WebSyncService/Makefile.am b/Tomboy/Addins/WebSyncService/Makefile.am
new file mode 100644
index 0000000..3b434d7
--- /dev/null
+++ b/Tomboy/Addins/WebSyncService/Makefile.am
@@ -0,0 +1,46 @@
+include $(top_srcdir)/Makefile.include
+
+CSFLAGS = 		\
+	-debug 		\
+	-define:DEBUG 	\
+	-target:library
+
+ASSEMBLIES = 					\
+	$(LINK_TOMBOY_EXE)			\
+	$(GTKSHARP_LIBS) 				\
+	$(LINK_MONO_ADDINS)			\
+	-r:Mono.Posix               \
+	-r:System.Web.Extensions
+
+#
+# Web Sync Service Addin
+#
+
+TARGET = WebSyncServiceAddin.dll
+CSFILES = \
+	$(srcdir)/WebSyncServer.cs		\
+	$(srcdir)/WebSyncServiceAddin.cs	\
+	$(srcdir)/Api/NoteInfo.cs	\
+	$(srcdir)/Api/UserInfo.cs
+RESOURCES = \
+	-resource:$(srcdir)/WebSyncService.addin.xml
+
+$(TARGET).mdb: $(TARGET)
+
+$(TARGET): $(CSFILES) $(top_builddir)/Tomboy/Tomboy.exe
+	$(CSC) -out:$@ $(CSFLAGS) $(ASSEMBLIES) $(CSFILES) $(RESOURCES)
+
+
+addinsdir = $(pkglibdir)/addins
+addins_DATA = 			\
+	$(TARGET)		\
+	$(TARGET).mdb
+
+EXTRA_DIST =            	\
+	$(CSFILES) \
+	$(srcdir)/WebSyncService.addin.xml
+
+CLEANFILES =				\
+	$(TARGET).mdb \
+	$(TARGET)
+
diff --git a/Tomboy/Addins/WebSyncService/WebSyncServer.cs b/Tomboy/Addins/WebSyncService/WebSyncServer.cs
new file mode 100644
index 0000000..5a00e0a
--- /dev/null
+++ b/Tomboy/Addins/WebSyncService/WebSyncServer.cs
@@ -0,0 +1,105 @@
+// Permission is hereby granted, free of charge, to any person obtaining 
+// a copy of this software and associated documentation files (the 
+// "Software"), to deal in the Software without restriction, including 
+// without limitation the rights to use, copy, modify, merge, publish, 
+// distribute, sublicense, and/or sell copies of the Software, and to 
+// permit persons to whom the Software is furnished to do so, subject to 
+// the following conditions: 
+//  
+// The above copyright notice and this permission notice shall be 
+// included in all copies or substantial portions of the Software. 
+//  
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+// 
+// Copyright (c) 2008 Novell, Inc. (http://www.novell.com) 
+// 
+// Authors: 
+//      Sandy Armstrong <sanfordarmstrong gmail com>
+// 
+
+using System;
+using System.Collections.Generic;
+
+using Tomboy.Sync;
+
+namespace Tomboy.WebSync
+{
+	public class WebSyncServer : SyncServer
+	{
+		private string serverUrl;
+		private string userName;
+		
+		public WebSyncServer (string serverUrl, string userName)
+		{
+			this.serverUrl = serverUrl;
+			this.userName = userName;
+		}
+
+		#region SyncServer implementation
+		
+		public bool BeginSyncTransaction ()
+		{
+			// TODO: Check connection and auth
+			return true;
+		}
+		
+		public bool CancelSyncTransaction ()
+		{
+			// TODO: Cancel any pending request
+			return true;
+		}
+		
+		public bool CommitSyncTransaction ()
+		{
+			// TODO: PUT request from info cached during
+			//       UploadNotes and DeleteNotes
+			return true;
+		}
+		
+		public SyncLockInfo CurrentSyncLock {
+			get {
+				return null;
+			}
+		}
+		
+		public void DeleteNotes (IList<string> deletedNoteUUIDs)
+		{
+			// TODO: Build relevant piece of PUT request
+		}
+		
+		public IList<string> GetAllNoteUUIDs ()
+		{
+			throw new System.NotImplementedException();
+		}
+		
+		public IDictionary<string, NoteUpdate> GetNoteUpdatesSince (int revision)
+		{
+			throw new System.NotImplementedException();
+		}
+		
+		public string Id {
+			get {
+				return serverUrl;
+			}
+		}
+		
+		public int LatestRevision {
+			get {
+				throw new System.NotImplementedException();
+			}
+		}
+		
+		public void UploadNotes (IList<Note> notes)
+		{
+			// TODO: Build relevant piece of PUT request
+		}
+		
+		#endregion
+	}
+}
diff --git a/Tomboy/Addins/WebSyncService/WebSyncService.addin.xml b/Tomboy/Addins/WebSyncService/WebSyncService.addin.xml
new file mode 100644
index 0000000..4d8d350
--- /dev/null
+++ b/Tomboy/Addins/WebSyncService/WebSyncService.addin.xml
@@ -0,0 +1,21 @@
+<Addin id="WebSyncServiceAddin"
+	namespace="Tomboy"
+	name="Web Sync Service Add-in"
+	author="Tomboy Project"
+	description="Synchronize Tomboy Notes with Tomboy Online and other compatible web services"
+	category="Synchronization"
+	defaultEnabled="true"
+	version="0.1">
+
+	<Runtime>
+		<Import assembly="WebSyncServiceAddin.dll" />
+	</Runtime>
+
+	<Dependencies>
+		<Addin id="Tomboy" version="0.10" />
+	</Dependencies>
+
+	<Extension path="/Tomboy/SyncServiceAddins">
+		<SyncServiceAddin type="Tomboy.WebSync.WebSyncServiceAddin" />
+	</Extension>
+</Addin>
diff --git a/Tomboy/Addins/WebSyncService/WebSyncServiceAddin.cs b/Tomboy/Addins/WebSyncService/WebSyncServiceAddin.cs
new file mode 100644
index 0000000..ea02b8e
--- /dev/null
+++ b/Tomboy/Addins/WebSyncService/WebSyncServiceAddin.cs
@@ -0,0 +1,114 @@
+// Permission is hereby granted, free of charge, to any person obtaining 
+// a copy of this software and associated documentation files (the 
+// "Software"), to deal in the Software without restriction, including 
+// without limitation the rights to use, copy, modify, merge, publish, 
+// distribute, sublicense, and/or sell copies of the Software, and to 
+// permit persons to whom the Software is furnished to do so, subject to 
+// the following conditions: 
+//  
+// The above copyright notice and this permission notice shall be 
+// included in all copies or substantial portions of the Software. 
+//  
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+// 
+// Copyright (c) 2008 Novell, Inc. (http://www.novell.com) 
+// 
+// Authors: 
+//      Sandy Armstrong <sanfordarmstrong gmail com>
+// 
+
+
+using System;
+
+using Mono.Unix;
+
+using Tomboy.Sync;
+
+namespace Tomboy.WebSync
+{
+	public class WebSyncServiceAddin : SyncServiceAddin
+	{
+		private bool initialized;
+		private string serverUrl;
+		private string userName;
+		
+		public WebSyncServiceAddin ()
+		{
+		}
+
+		#region SyncServiceAddin Overrides
+
+		public override string Id {
+			get { return "tomboyweb"; }
+		}
+
+		public override string Name {
+			get {
+				return Catalog.GetString ("Tomboy Web");
+			}
+		}
+
+		public override bool IsConfigured {
+			get {
+				return true; // TODO: Implement configuration
+			}
+		}
+
+		public override bool IsSupported {
+			get {
+				return true; // TODO: Ever false?
+			}
+		}
+
+		public override Gtk.Widget CreatePreferencesControl ()
+		{
+			return new Gtk.VBox ();
+		}
+
+		public override SyncServer CreateSyncServer ()
+		{
+			// TODO: What exactly do we need for connecting?
+			return new WebSyncServer (serverUrl, userName);
+		}
+
+		public override void PostSyncCleanup ()
+		{
+		}
+
+		public override void ResetConfiguration ()
+		{
+			throw new System.NotImplementedException();
+		}
+
+		public override bool SaveConfiguration ()
+		{
+			// TODO: Implement
+			return true;
+		}
+		
+		#endregion
+
+		#region ApplicationAddin Overrides
+
+		public override void Initialize ()
+		{
+			initialized = true;
+		}
+
+		public override void Shutdown ()
+		{
+		}
+		
+		public override bool Initialized {
+			get { return initialized; }
+		}
+
+		#endregion
+	}
+}
diff --git a/configure.in b/configure.in
index 0a915d5..2c45abb 100644
--- a/configure.in
+++ b/configure.in
@@ -338,6 +338,7 @@ Tomboy/Addins/SshSyncService/Makefile
 Tomboy/Addins/StickyNoteImport/Makefile
 Tomboy/Addins/Tasque/Makefile
 Tomboy/Addins/WebDavSyncService/Makefile
+Tomboy/Addins/WebSyncService/Makefile
 Tomboy/Addins/NoteDirectoryWatcher/Makefile
 test/Makefile
 po/Makefile.in



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