tomboy r1876 - in trunk: . Tomboy Tomboy/Addins/NoteOfTheDay Tomboy/Addins/StickyNoteImport Tomboy/Notebooks Tomboy/Synchronization
- From: sharm svn gnome org
- To: svn-commits-list gnome org
- Subject: tomboy r1876 - in trunk: . Tomboy Tomboy/Addins/NoteOfTheDay Tomboy/Addins/StickyNoteImport Tomboy/Notebooks Tomboy/Synchronization
- Date: Fri, 22 Feb 2008 19:16:23 +0000 (GMT)
Author: sharm
Date: Fri Feb 22 19:16:22 2008
New Revision: 1876
URL: http://svn.gnome.org/viewvc/tomboy?rev=1876&view=rev
Log:
* Tomboy/Synchronization/SyncManager.cs,
Tomboy/Addins/StickyNoteImport/StickyNoteImportNoteAddin.cs,
Tomboy/Addins/NoteOfTheDay/NoteOfTheDayPreferences.cs,
Tomboy/Notebooks/Notebook.cs, Tomboy/NoteManager.cs,
Tomboy/Note.cs, Tomboy/RemoteControl.cs: Added MetadataChangeDate
property to Note and NoteData classes, serialized in XML as
last-metadata-change-date. Indicates when any note data has
changed, including tags (notebooks), etc, whereas the ChangeDate
property only reflects changes to a note's title and other content.
Our UI generally sorts by ChangeDate, while sync and dbus clients
care about MetadataChangeDate. Fixes bug #508798.
Modified:
trunk/ChangeLog
trunk/Tomboy/Addins/NoteOfTheDay/NoteOfTheDayPreferences.cs
trunk/Tomboy/Addins/StickyNoteImport/StickyNoteImportNoteAddin.cs
trunk/Tomboy/Note.cs
trunk/Tomboy/NoteManager.cs
trunk/Tomboy/Notebooks/Notebook.cs
trunk/Tomboy/RemoteControl.cs
trunk/Tomboy/Synchronization/SyncManager.cs
Modified: trunk/Tomboy/Addins/NoteOfTheDay/NoteOfTheDayPreferences.cs
==============================================================================
--- trunk/Tomboy/Addins/NoteOfTheDay/NoteOfTheDayPreferences.cs (original)
+++ trunk/Tomboy/Addins/NoteOfTheDay/NoteOfTheDayPreferences.cs Fri Feb 22 19:16:22 2008
@@ -42,7 +42,7 @@
NoteOfTheDay.TemplateTitle,
NoteOfTheDay.GetTemplateContent (
NoteOfTheDay.TemplateTitle));
- template_note.QueueSave (true);
+ template_note.QueueSave (ChangeType.ContentChanged);
} catch (Exception e) {
Logger.Warn ("Error creating Note of the Day Template note: {0}\n{1}",
e.Message, e.StackTrace);
Modified: trunk/Tomboy/Addins/StickyNoteImport/StickyNoteImportNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/StickyNoteImport/StickyNoteImportNoteAddin.cs (original)
+++ trunk/Tomboy/Addins/StickyNoteImport/StickyNoteImportNoteAddin.cs Fri Feb 22 19:16:22 2008
@@ -193,7 +193,7 @@
try {
Note newNote = Manager.Create (title, noteXml);
- newNote.QueueSave (false);
+ newNote.QueueSave (ChangeType.NoChange);
newNote.Save ();
return true;
} catch (Exception e) {
Modified: trunk/Tomboy/Note.cs
==============================================================================
--- trunk/Tomboy/Note.cs (original)
+++ trunk/Tomboy/Note.cs Fri Feb 22 19:16:22 2008
@@ -15,6 +15,13 @@
public delegate void TagRemovingHandler (Note note, Tag tag);
public delegate void TagRemovedHandler (Note note, string tag_name);
+ public enum ChangeType
+ {
+ NoChange,
+ ContentChanged,
+ OtherDataChanged
+ }
+
// Contains all pure note data, like the note title and note text.
public class NoteData
{
@@ -23,6 +30,7 @@
string text;
DateTime create_date;
DateTime change_date;
+ DateTime metadata_change_date;
int cursor_pos;
int width, height;
@@ -44,6 +52,7 @@
create_date = DateTime.MinValue;
change_date = DateTime.MinValue;
+ metadata_change_date = DateTime.MinValue;
}
public string Uri
@@ -83,6 +92,10 @@
}
}
+ /// <summary>
+ /// Indicates the last time note content data changed.
+ /// Does not include tag/notebook changes (see MetadataChangeDate).
+ /// </summary>
public DateTime ChangeDate
{
get {
@@ -90,8 +103,24 @@
}
set {
change_date = value;
+ metadata_change_date = value;
+ }
+ }
+
+ /// <summary>
+ /// Indicates the last time non-content note data changed.
+ /// This currently only applies to tags/notebooks.
+ /// </summary>
+ public DateTime MetadataChangeDate
+ {
+ get {
+ return metadata_change_date;
+ }
+ set {
+ metadata_change_date = value;
}
}
+
// FIXME: the next five attributes don't belong here (the data
// model), but belong into the view; for now they are kept here
@@ -451,14 +480,14 @@
void BufferChanged (object sender, EventArgs args)
{
DebugSave ("BufferChanged queueing save");
- QueueSave (true);
+ QueueSave (ChangeType.ContentChanged);
}
void BufferTagApplied (object sender, Gtk.TagAppliedArgs args)
{
if (NoteTagTable.TagIsSerializable (args.Tag)) {
DebugSave ("BufferTagApplied queueing save: {0}", args.Tag.Name);
- QueueSave (true);
+ QueueSave (ChangeType.ContentChanged);
}
}
@@ -466,7 +495,7 @@
{
if (NoteTagTable.TagIsSerializable (args.Tag)) {
DebugSave ("BufferTagRemoved queueing save: {0}", args.Tag.Name);
- QueueSave (true);
+ QueueSave (ChangeType.ContentChanged);
}
}
@@ -478,7 +507,7 @@
data.Data.CursorPosition = args.Location.Offset;
DebugSave ("BufferInsertSetMark queueing save");
- QueueSave (false);
+ QueueSave (ChangeType.NoChange);
}
//
@@ -508,7 +537,7 @@
data.Data.SetPositionExtent (cur_x, cur_y, cur_width, cur_height);
DebugSave ("WindowConfigureEvent queueing save");
- QueueSave (false);
+ QueueSave (ChangeType.NoChange);
}
[GLib.ConnectBefore]
@@ -516,7 +545,7 @@
{
window = null;
}
-
+
/// <summary>
/// Set a 4 second timeout to execute the save. Possibly
/// invalidate the text, which causes a re-serialize when the
@@ -524,7 +553,7 @@
/// </summary>
/// <param name="content_changed">Indicates whether or not
/// to update the note's last change date</param>
- public void QueueSave (bool content_changed)
+ public void QueueSave (ChangeType changeType)
{
DebugSave ("Got QueueSave");
@@ -532,9 +561,22 @@
// before saving...
save_timeout.Reset (4000);
save_needed = true;
-
- if (content_changed) {
+
+ switch (changeType)
+ {
+ case ChangeType.ContentChanged:
+ // NOTE: Updating ChangeDate automatically updates MetdataChangeDate to match.
data.Data.ChangeDate = DateTime.Now;
+ break;
+ case ChangeType.OtherDataChanged:
+ // Only update MetadataChangeDate. Used by sync/etc
+ // to know when non-content note data has changed,
+ // but order of notes in menu and search UI is
+ // unaffected.
+ data.Data.MetadataChangeDate = DateTime.Now;
+ break;
+ default:
+ break;
}
}
@@ -565,7 +607,7 @@
TagAdded (this, tag);
DebugSave ("Tag added, queueing save");
- QueueSave (true);
+ QueueSave (ChangeType.OtherDataChanged);
}
}
@@ -587,7 +629,7 @@
TagRemoved (this, tag.NormalizedName);
DebugSave ("Tag removed, queueing save");
- QueueSave (true);
+ QueueSave (ChangeType.OtherDataChanged);
}
public bool ContainsTag (Tag tag)
@@ -664,7 +706,7 @@
if (Renamed != null)
Renamed (this, old_title);
- QueueSave (true); // TODO: Right place for this?
+ QueueSave (ChangeType.ContentChanged); // TODO: Right place for this?
}
}
}
@@ -681,7 +723,7 @@
if (Renamed != null)
Renamed (this, newTitle);
- QueueSave (true); // TODO: Right place for this?
+ QueueSave (ChangeType.ContentChanged); // TODO: Right place for this?
}
}
@@ -765,6 +807,10 @@
data.Data.ChangeDate =
XmlConvert.ToDateTime (xml.ReadString (), NoteArchiver.DATE_TIME_FORMAT);
break;
+ case "last-metadata-change-date":
+ data.Data.MetadataChangeDate =
+ XmlConvert.ToDateTime (xml.ReadString (), NoteArchiver.DATE_TIME_FORMAT);
+ break;
case "create-date":
data.Data.CreateDate =
XmlConvert.ToDateTime (xml.ReadString (), NoteArchiver.DATE_TIME_FORMAT);
@@ -836,12 +882,27 @@
}
}
+ /// <summary>
+ /// Indicates the last time note content data changed.
+ /// Does not include tag/notebook changes (see MetadataChangeDate).
+ /// </summary>
public DateTime ChangeDate
{
get {
return data.Data.ChangeDate;
}
}
+
+ /// <summary>
+ /// Indicates the last time non-content note data changed.
+ /// This currently only applies to tags/notebooks.
+ /// </summary>
+ public DateTime MetadataChangeDate
+ {
+ get {
+ return data.Data.MetadataChangeDate;
+ }
+ }
public NoteManager Manager
{
@@ -1030,7 +1091,7 @@
// since this class is only seldomly used
public class NoteArchiver
{
- public const string CURRENT_VERSION = "0.2";
+ public const string CURRENT_VERSION = "0.3";
public const string DATE_TIME_FORMAT = "yyyy-MM-ddTHH:mm:ss.fffffffzzz";
@@ -1094,6 +1155,10 @@
note.ChangeDate =
XmlConvert.ToDateTime (xml.ReadString (), DATE_TIME_FORMAT);
break;
+ case "last-metadata-change-date":
+ note.MetadataChangeDate =
+ XmlConvert.ToDateTime (xml.ReadString (), DATE_TIME_FORMAT);
+ break;
case "create-date":
note.CreateDate =
XmlConvert.ToDateTime (xml.ReadString (), DATE_TIME_FORMAT);
@@ -1219,6 +1284,11 @@
XmlConvert.ToString (note.ChangeDate, DATE_TIME_FORMAT));
xml.WriteEndElement ();
+ xml.WriteStartElement (null, "last-metadata-change-date", null);
+ xml.WriteString (
+ XmlConvert.ToString (note.MetadataChangeDate, DATE_TIME_FORMAT));
+ xml.WriteEndElement ();
+
if (note.CreateDate != DateTime.MinValue) {
xml.WriteStartElement (null, "create-date", null);
xml.WriteString (
Modified: trunk/Tomboy/NoteManager.cs
==============================================================================
--- trunk/Tomboy/NoteManager.cs (original)
+++ trunk/Tomboy/NoteManager.cs Fri Feb 22 19:16:22 2008
@@ -168,12 +168,12 @@
try {
Note start_note = Create (Catalog.GetString ("Start Here"),
start_note_content);
- start_note.QueueSave (true);
+ start_note.QueueSave (ChangeType.ContentChanged);
Preferences.Set (Preferences.START_NOTE_URI, start_note.Uri);
Note links_note = Create (Catalog.GetString ("Using Links in Tomboy"),
links_note_content);
- links_note.QueueSave (true);
+ links_note.QueueSave (ChangeType.ContentChanged);
start_note.Window.Show ();
} catch (Exception e) {
@@ -220,7 +220,7 @@
note.Window.Show ();
note.IsOpenOnStartup = false;
- note.QueueSave (false);
+ note.QueueSave (ChangeType.NoChange);
}
}
@@ -451,7 +451,7 @@
Tag tag = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSystemTag);
template_note.AddTag (tag);
- template_note.QueueSave (true);
+ template_note.QueueSave (ChangeType.ContentChanged);
}
return template_note;
Modified: trunk/Tomboy/Notebooks/Notebook.cs
==============================================================================
--- trunk/Tomboy/Notebooks/Notebook.cs (original)
+++ trunk/Tomboy/Notebooks/Notebook.cs Fri Feb 22 19:16:22 2008
@@ -131,7 +131,7 @@
tag = TagManager.GetOrCreateSystemTag (NotebookTagPrefix + Name);
note.AddTag (tag);
- note.QueueSave (true);
+ note.QueueSave (ChangeType.ContentChanged);
}
return note;
Modified: trunk/Tomboy/RemoteControl.cs
==============================================================================
--- trunk/Tomboy/RemoteControl.cs (original)
+++ trunk/Tomboy/RemoteControl.cs Fri Feb 22 19:16:22 2008
@@ -195,7 +195,7 @@
note = note_manager.FindByUri (uri);
if (note == null)
return -1;
- return UnixDateTime (note.ChangeDate);
+ return UnixDateTime (note.MetadataChangeDate);
}
public string GetNoteContentsXml (string uri)
Modified: trunk/Tomboy/Synchronization/SyncManager.cs
==============================================================================
--- trunk/Tomboy/Synchronization/SyncManager.cs (original)
+++ trunk/Tomboy/Synchronization/SyncManager.cs Fri Feb 22 19:16:22 2008
@@ -318,7 +318,7 @@
if (existingNote == null) {
CreateNoteInMainThread (noteUpdate);
- } else if (existingNote.ChangeDate.CompareTo (client.LastSyncDate) <= 0) {
+ } else if (existingNote.MetadataChangeDate.CompareTo (client.LastSyncDate) <= 0) {
// Existing note hasn't been modified since last sync; simply update it from server
UpdateNoteInMainThread (existingNote, noteUpdate);
} else {
@@ -395,7 +395,7 @@
if (NoteSynchronized != null)
NoteSynchronized (note.Title, NoteSyncType.UploadNew);
} else if (client.GetRevision (note) <= client.LastSynchronizedRevision &&
- note.ChangeDate > client.LastSyncDate) {
+ note.MetadataChangeDate > client.LastSyncDate) {
note.Save ();
newOrModifiedNotes.Add (note);
if (NoteSynchronized != null)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]