[tomboy] [sync] Add ISyncServer.UpatesAvailableSince method
- From: Sanford Armstrong <sharm src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tomboy] [sync] Add ISyncServer.UpatesAvailableSince method
- Date: Mon, 8 Feb 2010 20:06:14 +0000 (UTC)
commit 82e91fb566b793b570d5c45c9048e13063323abc
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date: Mon Feb 8 11:38:42 2010 -0800
[sync] Add ISyncServer.UpatesAvailableSince method
Tomboy/Addins/WebSyncService/WebSyncServer.cs | 13 ++++++++++---
Tomboy/Synchronization/FileSystemSyncServer.cs | 5 +++++
Tomboy/Synchronization/SyncManager.cs | 3 ++-
3 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/Tomboy/Addins/WebSyncService/WebSyncServer.cs b/Tomboy/Addins/WebSyncService/WebSyncServer.cs
index 6884ec5..285c16a 100644
--- a/Tomboy/Addins/WebSyncService/WebSyncServer.cs
+++ b/Tomboy/Addins/WebSyncService/WebSyncServer.cs
@@ -34,7 +34,7 @@ namespace Tomboy.WebSync
{
public class WebSyncServer : SyncServer
{
- private string serverUrl;
+ private string rootUri;
private IWebConnection connection;
private RootInfo root;
@@ -43,8 +43,8 @@ namespace Tomboy.WebSync
public WebSyncServer (string serverUrl, IWebConnection connection)
{
- this.serverUrl = serverUrl;
this.connection = connection;
+ rootUri = serverUrl + "/api/1.0/"; // TODO: Trim trailing / from serverUrl if necessary
}
#region SyncServer implementation
@@ -52,7 +52,6 @@ namespace Tomboy.WebSync
public bool BeginSyncTransaction ()
{
// TODO: Check connection and auth (is getting root/user resources a sufficient check?)
- string rootUri = serverUrl + "/api/1.0/";
root = RootInfo.GetRoot (rootUri, connection);
user = UserInfo.GetUser (root.User.ApiRef, connection);
if (user.LatestSyncRevision.HasValue)
@@ -141,6 +140,14 @@ namespace Tomboy.WebSync
foreach (Note note in notes)
pendingCommits.Add (NoteConvert.ToNoteInfo (note));
}
+
+ public bool UpdatesAvailableSince (int revision)
+ {
+ root = RootInfo.GetRoot (rootUri, connection);
+ user = UserInfo.GetUser (root.User.ApiRef, connection);
+ return user.LatestSyncRevision.HasValue &&
+ user.LatestSyncRevision.Value > revision;
+ }
#endregion
diff --git a/Tomboy/Synchronization/FileSystemSyncServer.cs b/Tomboy/Synchronization/FileSystemSyncServer.cs
index 5cd5315..9aa29cb 100644
--- a/Tomboy/Synchronization/FileSystemSyncServer.cs
+++ b/Tomboy/Synchronization/FileSystemSyncServer.cs
@@ -96,6 +96,11 @@ namespace Tomboy.Sync
return noteUUIDs;
}
+ public bool UpdatesAvailableSince (int revision)
+ {
+ return LatestRevision > revision; // TODO: Mounting, etc?
+ }
+
public virtual IDictionary<string, NoteUpdate> GetNoteUpdatesSince (int revision)
{
Dictionary<string, NoteUpdate> noteUpdates = new Dictionary<string, NoteUpdate> ();
diff --git a/Tomboy/Synchronization/SyncManager.cs b/Tomboy/Synchronization/SyncManager.cs
index 0b1551a..00f5577 100644
--- a/Tomboy/Synchronization/SyncManager.cs
+++ b/Tomboy/Synchronization/SyncManager.cs
@@ -851,9 +851,10 @@ namespace Tomboy.Sync
IDictionary<string, NoteUpdate> GetNoteUpdatesSince (int revision);
void DeleteNotes (IList<string> deletedNoteUUIDs);
void UploadNotes (IList<Note> notes);
- int LatestRevision { get; }
+ int LatestRevision { get; } // NOTE: Only reliable during a transaction
SyncLockInfo CurrentSyncLock { get; }
string Id { get; }
+ bool UpdatesAvailableSince (int revision);
}
public interface SyncClient
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]