[bijiben] ownCloud : Initial support
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] ownCloud : Initial support
- Date: Sat, 15 Jun 2013 19:55:17 +0000 (UTC)
commit 20a907fd422b5e37fe05efe3b4c74f92d85a8cc9
Author: Pierre-Yves Luyten <py luyten fr>
Date: Sat Jun 15 15:15:47 2013 +0200
ownCloud : Initial support
Already allow to see ownCloud notes
But no new note, no UI to setup anything and wrong startup
configure.ac | 1 +
src/bjb-bijiben.c | 103 +++-
src/bjb-controller.c | 12 +-
src/bjb-editor-toolbar.c | 266 ++++----
src/bjb-main-toolbar.c | 93 ++--
src/bjb-main-view.c | 2 +
src/bjb-main-view.h | 2 +
src/bjb-note-tag-dialog.c | 10 +-
src/bjb-selection-toolbar.c | 23 +-
src/bjb-share.c | 6 +-
src/libbiji/Makefile.am | 12 +-
src/libbiji/biji-collection.c | 39 +-
src/libbiji/biji-collection.h | 2 +-
src/libbiji/biji-info-set.c | 44 ++
src/libbiji/biji-info-set.h | 64 ++
src/libbiji/biji-item.c | 87 +++-
src/libbiji/biji-item.h | 14 +
src/libbiji/biji-local-note.c | 212 ++++++
src/libbiji/biji-local-note.h | 59 ++
src/libbiji/biji-note-book.c | 244 ++++++--
src/libbiji/biji-note-book.h | 57 ++-
src/libbiji/biji-note-id.c | 214 ++++---
src/libbiji/biji-note-id.h | 46 +-
src/libbiji/biji-note-obj.c | 342 ++++------
src/libbiji/biji-note-obj.h | 144 +++--
src/libbiji/biji-tracker.c | 467 +++++++++++--
src/libbiji/biji-tracker.h | 44 +-
src/libbiji/deserializer/biji-lazy-deserializer.c | 35 +-
src/libbiji/editor/biji-webkit-editor.c | 7 +-
src/libbiji/libbiji.h | 1 +
src/libbiji/provider/Makefile.am | 1 +
src/libbiji/provider/biji-own-cloud-note.c | 288 ++++++++
src/libbiji/provider/biji-own-cloud-note.h | 61 ++
src/libbiji/provider/biji-own-cloud-provider.c | 745 +++++++++++++++++++++
src/libbiji/provider/biji-own-cloud-provider.h | 61 ++
src/libbiji/provider/biji-provider.c | 74 ++
src/libbiji/provider/biji-provider.h | 59 ++
src/libbiji/serializer/biji-lazy-serializer.c | 33 +-
38 files changed, 3244 insertions(+), 730 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b224aa4..9bd0379 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,7 @@ PKG_CHECK_MODULES(BIJIBEN,
egg-list-box
gio-unix-2.0
glib-2.0 >= $GLIB_REQUIRED_VERSION
+ goa-1.0
gtk+-3.0 >= $GTK_REQUIRED_VERSION
libxml-2.0
tracker-sparql-0.16
diff --git a/src/bjb-bijiben.c b/src/bjb-bijiben.c
index dd11644..1b9f2c1 100644
--- a/src/bjb-bijiben.c
+++ b/src/bjb-bijiben.c
@@ -46,25 +46,29 @@ bijiben_new_window_internal (GApplication *app,
GFile *file,
BijiNoteObj *note_obj)
{
- GtkWindow *win;
- BijiNoteObj* note;
+ BjbWindowBase *window;
+ BijiNoteObj* note = NULL;
+ Bijiben *self;
+
+ g_return_if_fail (BIJIBEN_IS_APPLICATION (app));
+ self = BIJIBEN_APPLICATION (app);
+ window = BJB_WINDOW_BASE (bjb_window_base_new ());
- win = bjb_window_base_new ();
- note = NULL;
if (file != NULL)
- note = biji_note_get_new_from_file (g_file_get_path(file));
+ note = biji_note_get_new_from_file (self->priv->book,
+ g_file_get_path(file));
else if (note_obj != NULL)
note = note_obj;
if (note != NULL)
- bjb_window_base_switch_to_note (BJB_WINDOW_BASE (win), note);
+ bjb_window_base_switch_to_note (window, note);
else
- bjb_window_base_switch_to (BJB_WINDOW_BASE (win), BJB_WINDOW_BASE_MAIN_VIEW);
+ bjb_window_base_switch_to (window, BJB_WINDOW_BASE_MAIN_VIEW);
- gtk_widget_show_all (GTK_WIDGET (win));
+ gtk_widget_show_all (GTK_WIDGET (window));
}
void
@@ -121,6 +125,11 @@ copy_note (GFileInfo *info, GFile *container)
BijiNoteObj *retval = NULL;
const gchar *name;
gchar *path;
+ Bijiben *self;
+ BijiNoteBook *book;
+
+ self = BIJIBEN_APPLICATION (g_application_get_default ());
+ book = self->priv->book;
/* First make sure it's a note */
name = g_file_info_get_name (info);
@@ -129,7 +138,7 @@ copy_note (GFileInfo *info, GFile *container)
/* Deserialize it */
path = g_build_filename (g_file_get_path (container), name, NULL);
- retval = biji_note_get_new_from_file (path);
+ retval = biji_note_get_new_from_file (book, path);
g_free (path);
g_return_val_if_fail (BIJI_IS_NOTE_OBJ (retval), NULL);
@@ -257,15 +266,71 @@ bijiben_import_notes (Bijiben *self, gchar *location)
g_object_unref (to_import);
}
+
+/* Just filter on ownCloud accounts
+ * TODO : settings to force activate & inactivate
+ * but, up to libbiji to survey GoaObject
+ */
+static void
+on_client_got (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ Bijiben *self;
+ GoaClient *client;
+ GError *error;
+ GList *accounts, *l;
+ GoaObject *object;
+ GoaAccount *account;
+ const gchar *type;
+
+ self = BIJIBEN_APPLICATION (user_data);
+ error = NULL;
+ client = goa_client_new_finish (res, &error);
+
+ if (error)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ accounts = goa_client_get_accounts (client);
+
+ for (l=accounts; l!=NULL; l=l->next)
+ {
+ object = GOA_OBJECT (l->data);
+ account = goa_object_get_account (object);
+
+ if (GOA_IS_ACCOUNT (account))
+ {
+ type = goa_account_get_provider_type (account);
+
+ if (g_strcmp0 (type, "owncloud") ==0)
+ biji_note_book_add_goa_object (self->priv->book, object);
+
+ else
+ g_object_unref (object);
+ }
+ }
+
+ g_list_free (accounts);
+}
+
static void
bijiben_startup (GApplication *application)
{
- Bijiben *self = BIJIBEN_APPLICATION (application);
- gchar *storage_path;
- GFile *storage;
- GError *error = NULL;
+ Bijiben *self;
+ gchar *storage_path, *default_color;
+ GFile *storage;
+ GError *error;
+ GdkRGBA color = {0,0,0,0};
+
G_APPLICATION_CLASS (bijiben_parent_class)->startup (application);
+ self = BIJIBEN_APPLICATION (application);
+ error = NULL;
+
if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
{
@@ -301,12 +366,20 @@ bijiben_startup (GApplication *application)
self->priv->first_run = TRUE;
}
- self->priv->book = biji_note_book_new (storage);
+
+ g_object_get (self->priv->settings, "color", &default_color, NULL);
+ gdk_rgba_parse (&color, default_color);
+ g_warning ("bijiben wants color %s", default_color);
+ self->priv->book = biji_note_book_new (storage, &color);
+ g_free (default_color);
g_free (storage_path);
g_object_unref (storage);
- // create the first window
+ /* Goa */
+ goa_client_new (NULL, on_client_got, self); // cancellable
+
+ /* Create the first window */
bijiben_new_window_internal (application, NULL, NULL);
}
diff --git a/src/bjb-controller.c b/src/bjb-controller.c
index cc59013..746ea38 100644
--- a/src/bjb-controller.c
+++ b/src/bjb-controller.c
@@ -53,6 +53,7 @@ struct _BjbControllerPrivate
GList *items_to_show;
gint n_items_to_show;
gboolean remaining_items;
+ GMutex mutex;
gboolean connected;
gulong book_change;
@@ -306,7 +307,7 @@ bjb_controller_add_item_if_needed (BjbController *self,
GtkTreeIter *sibling)
{
gboolean need_to_add_item = FALSE;
- gchar *content;
+ const gchar *content;
const gchar *title;
BjbControllerPrivate *priv = self->priv;
@@ -336,7 +337,7 @@ bjb_controller_add_item_if_needed (BjbController *self,
/* matching content */
else if (BIJI_IS_NOTE_OBJ (item))
{
- content = biji_note_get_raw_text (BIJI_NOTE_OBJ (item));
+ content = biji_note_obj_get_raw_text (BIJI_NOTE_OBJ (item));
if (g_strrstr (content, priv->needle) != NULL)
need_to_add_item = TRUE;
}
@@ -406,13 +407,9 @@ sort_items (GList **to_show)
static void
notify_displayed_items_changed (BjbController *self)
{
- /*gboolean shown;
-
- shown = (self->priv->items_to_show != NULL);*/
g_signal_emit (G_OBJECT (self),
bjb_controller_signals[DISPLAY_NOTES_CHANGED],
0,
- //shown,
(self->priv->items_to_show != NULL),
self->priv->remaining_items);
}
@@ -556,6 +553,8 @@ on_book_changed (BijiNoteBook *book,
GtkTreeIter iter;
GtkTreeIter *p_iter = &iter;
+ g_mutex_lock (&priv->mutex);
+
switch (flag)
{
/* If this is a *new* item, per def prepend */
@@ -616,6 +615,7 @@ on_book_changed (BijiNoteBook *book,
/* FIXME we refresh the whole completion model each time */
refresh_completion(self);
+ g_mutex_unlock (&priv->mutex);
}
static void
diff --git a/src/bjb-editor-toolbar.c b/src/bjb-editor-toolbar.c
index 94e2378..dc168b4 100644
--- a/src/bjb-editor-toolbar.c
+++ b/src/bjb-editor-toolbar.c
@@ -106,131 +106,12 @@ bjb_editor_toolbar_fade_out (BjbEditorToolbar *self)
static void
bjb_editor_toolbar_init (BjbEditorToolbar *self)
{
- BjbEditorToolbarPrivate *priv;
- GtkWidget *bin;
- GtkWidget *image;
- GdkPixbuf *pixbuf;
- GtkStyleContext *context;
- GdkRGBA transparent = {0.0, 0.0, 0.0, 0.0};
- GdkRGBA black = {0.0, 0.0, 0.0, 0.6};
- gchar *icons_path, *full_path;
- GError *error = NULL;
-
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BJB_TYPE_EDITOR_TOOLBAR, BjbEditorToolbarPrivate);
- priv = self->priv;
-
- priv->accel = gtk_accel_group_new ();
-
- priv->widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
- context = gtk_widget_get_style_context (priv->widget);
- gtk_style_context_add_class (context, "osd");
- gtk_style_context_add_class (context, "toolbar");
-
- priv->actor = gtk_clutter_actor_new_with_contents (priv->widget);
- clutter_actor_set_opacity (priv->actor, 0);
- g_object_set (priv->actor, "show-on-set-parent", FALSE, NULL);
-
- clutter_actor_set_easing_mode (priv->actor, CLUTTER_EASE_IN_QUAD);
- clutter_actor_set_easing_duration (priv->actor, 300.0);
-
- bin = gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (priv->actor));
- gtk_widget_override_background_color (bin,
- GTK_STATE_FLAG_NORMAL,
- &transparent);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+ self,
+ BJB_TYPE_EDITOR_TOOLBAR,
+ BjbEditorToolbarPrivate);
- priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- priv->group = gtk_tool_item_new ();
- gtk_container_add (GTK_CONTAINER (priv->group), priv->box);
- gtk_container_add (GTK_CONTAINER (priv->widget), GTK_WIDGET(priv->group));
- gtk_widget_show_all (GTK_WIDGET (priv->group));
-
- /* Cut */
- priv->toolbar_cut = gtk_button_new_with_label (_("Cut"));
- gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_cut);
- gtk_widget_override_background_color (priv->toolbar_cut,
- GTK_STATE_FLAG_NORMAL,
- &black);
-
- /* Copy */
- priv->toolbar_copy = gtk_button_new_with_label (_("Copy"));
- gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_copy);
- gtk_widget_override_background_color (priv->toolbar_copy,
- GTK_STATE_FLAG_NORMAL,
- &black);
-
- /* 'n paste */
- priv->toolbar_paste = gtk_button_new_with_label (_("Paste"));
- gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_paste);
- gtk_widget_override_background_color (priv->toolbar_paste,
- GTK_STATE_FLAG_NORMAL,
- &black);
-
- /* GtkWidget *toolbar_bold */
- priv->toolbar_bold = gtk_button_new ();
- image = gtk_image_new_from_icon_name ("format-text-bold-symbolic", GTK_ICON_SIZE_INVALID);
- gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
- gtk_container_add (GTK_CONTAINER (priv->toolbar_bold), image);
- gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_bold), _("Bold"));
- gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_bold);
- gtk_widget_override_background_color (priv->toolbar_bold,
- GTK_STATE_FLAG_NORMAL,
- &black);
-
- /* GtkWidget *toolbar_italic; */
- priv->toolbar_italic = gtk_button_new ();
- image = gtk_image_new_from_icon_name ("format-text-italic-symbolic", GTK_ICON_SIZE_INVALID);
- gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
- gtk_container_add (GTK_CONTAINER (priv->toolbar_italic), image);
- gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_italic), _("Italic"));
- gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_italic);
- gtk_widget_override_background_color (priv->toolbar_italic,
- GTK_STATE_FLAG_NORMAL,
- &black);
-
- /* GtkWidget *toolbar_strike; */
- priv->toolbar_strike = gtk_button_new ();
- image = gtk_image_new_from_icon_name ("format-text-strikethrough-symbolic", GTK_ICON_SIZE_INVALID);
- gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
- gtk_container_add (GTK_CONTAINER (priv->toolbar_strike), image);
- gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_strike), _("Strike"));
- gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_strike);
- gtk_widget_override_background_color (priv->toolbar_strike,
- GTK_STATE_FLAG_NORMAL,
- &black);
-
- /* GtkWidget *toolbar_link; */
- priv->toolbar_link = gtk_button_new ();
-
- icons_path = (gchar*) bijiben_get_bijiben_dir ();
- full_path = g_build_filename (icons_path,
- "bijiben",
- "icons",
- "hicolor",
- "scalable",
- "actions",
- "link.svg",
- NULL);
-
- pixbuf = gdk_pixbuf_new_from_file (full_path, &error);
- g_free (full_path);
-
- if (error)
- g_warning ("error loading link icon : %s",error->message);
-
- image = gtk_image_new_from_pixbuf (pixbuf);
- gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
-
- gtk_container_add (GTK_CONTAINER (priv->toolbar_link), image);
- gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_link),
- _("Copy selection to a new note"));
- gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_link);
- gtk_widget_override_background_color (priv->toolbar_link,
- GTK_STATE_FLAG_NORMAL,
- &black);
-
- priv->glued = FALSE;
- gtk_widget_show_all (GTK_WIDGET(priv->group));
- clutter_actor_show (priv->actor);
+ self->priv->accel = gtk_accel_group_new ();
}
static void
@@ -435,16 +316,143 @@ link_callback (GtkWidget *button, BjbEditorToolbar *self)
static void
bjb_editor_toolbar_constructed (GObject *obj)
{
- BjbEditorToolbar *self = BJB_EDITOR_TOOLBAR(obj);
- BjbEditorToolbarPrivate *priv = self->priv ;
- GtkWidget *view;
- GtkWidget *window;
+ BjbEditorToolbar *self;
+ BjbEditorToolbarPrivate *priv;
+ GtkWidget *view;
+ GtkWidget *window;
+ GtkWidget *bin;
+ GtkWidget *image;
+ GdkPixbuf *pixbuf;
+ GtkStyleContext *context;
+ GdkRGBA transparent = {0.0, 0.0, 0.0, 0.0};
+ GdkRGBA black = {0.0, 0.0, 0.0, 0.6};
+ gchar *icons_path, *full_path;
+ GError *error = NULL;
G_OBJECT_CLASS (bjb_editor_toolbar_parent_class)->constructed (obj);
- window = bjb_note_view_get_base_window (priv->view);
+ self = BJB_EDITOR_TOOLBAR (obj);
+ priv = self->priv;
+ window = bjb_note_view_get_base_window (priv->view);
gtk_window_add_accel_group (GTK_WINDOW (window), priv->accel);
+ priv->widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
+ context = gtk_widget_get_style_context (priv->widget);
+ gtk_style_context_add_class (context, "osd");
+ gtk_style_context_add_class (context, "toolbar");
+
+ priv->actor = gtk_clutter_actor_new_with_contents (priv->widget);
+ clutter_actor_set_opacity (priv->actor, 0);
+ g_object_set (priv->actor, "show-on-set-parent", FALSE, NULL);
+
+ clutter_actor_set_easing_mode (priv->actor, CLUTTER_EASE_IN_QUAD);
+ clutter_actor_set_easing_duration (priv->actor, 300.0);
+
+ bin = gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (priv->actor));
+ gtk_widget_override_background_color (bin,
+ GTK_STATE_FLAG_NORMAL,
+ &transparent);
+
+ priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ priv->group = gtk_tool_item_new ();
+ gtk_container_add (GTK_CONTAINER (priv->group), priv->box);
+ gtk_container_add (GTK_CONTAINER (priv->widget), GTK_WIDGET(priv->group));
+ gtk_widget_show_all (GTK_WIDGET (priv->group));
+
+ /* Cut */
+ priv->toolbar_cut = gtk_button_new_with_label (_("Cut"));
+ gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_cut);
+ gtk_widget_override_background_color (priv->toolbar_cut,
+ GTK_STATE_FLAG_NORMAL,
+ &black);
+
+ /* Copy */
+ priv->toolbar_copy = gtk_button_new_with_label (_("Copy"));
+ gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_copy);
+ gtk_widget_override_background_color (priv->toolbar_copy,
+ GTK_STATE_FLAG_NORMAL,
+ &black);
+
+ /* 'n paste */
+ priv->toolbar_paste = gtk_button_new_with_label (_("Paste"));
+ gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_paste);
+ gtk_widget_override_background_color (priv->toolbar_paste,
+ GTK_STATE_FLAG_NORMAL,
+ &black);
+
+
+ if (biji_note_obj_can_format (priv->note))
+ {
+
+ /* GtkWidget *toolbar_bold */
+ priv->toolbar_bold = gtk_button_new ();
+ image = gtk_image_new_from_icon_name ("format-text-bold-symbolic", GTK_ICON_SIZE_INVALID);
+ gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
+ gtk_container_add (GTK_CONTAINER (priv->toolbar_bold), image);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_bold), _("Bold"));
+ gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_bold);
+ gtk_widget_override_background_color (priv->toolbar_bold,
+ GTK_STATE_FLAG_NORMAL,
+ &black);
+
+ /* GtkWidget *toolbar_italic; */
+ priv->toolbar_italic = gtk_button_new ();
+ image = gtk_image_new_from_icon_name ("format-text-italic-symbolic", GTK_ICON_SIZE_INVALID);
+ gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
+ gtk_container_add (GTK_CONTAINER (priv->toolbar_italic), image);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_italic), _("Italic"));
+ gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_italic);
+ gtk_widget_override_background_color (priv->toolbar_italic,
+ GTK_STATE_FLAG_NORMAL,
+ &black);
+
+ /* GtkWidget *toolbar_strike; */
+ priv->toolbar_strike = gtk_button_new ();
+ image = gtk_image_new_from_icon_name ("format-text-strikethrough-symbolic", GTK_ICON_SIZE_INVALID);
+ gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
+ gtk_container_add (GTK_CONTAINER (priv->toolbar_strike), image);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_strike), _("Strike"));
+ gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_strike);
+ gtk_widget_override_background_color (priv->toolbar_strike,
+ GTK_STATE_FLAG_NORMAL,
+ &black);
+
+ }
+
+ /* GtkWidget *toolbar_link; */
+ priv->toolbar_link = gtk_button_new ();
+
+ icons_path = (gchar*) bijiben_get_bijiben_dir ();
+ full_path = g_build_filename (icons_path,
+ "bijiben",
+ "icons",
+ "hicolor",
+ "scalable",
+ "actions",
+ "link.svg",
+ NULL);
+
+ pixbuf = gdk_pixbuf_new_from_file (full_path, &error);
+ g_free (full_path);
+
+ if (error)
+ g_warning ("error loading link icon : %s",error->message);
+
+ image = gtk_image_new_from_pixbuf (pixbuf);
+ gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
+
+ gtk_container_add (GTK_CONTAINER (priv->toolbar_link), image);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (priv->toolbar_link),
+ _("Copy selection to a new note"));
+ gtk_container_add (GTK_CONTAINER (priv->box), priv->toolbar_link);
+ gtk_widget_override_background_color (priv->toolbar_link,
+ GTK_STATE_FLAG_NORMAL,
+ &black);
+
+ priv->glued = FALSE;
+ gtk_widget_show_all (GTK_WIDGET(priv->group));
+ clutter_actor_show (priv->actor);
+
/* text selected --> fade in , and not selected --> fade out */
view = biji_note_obj_get_editor (priv->note);
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index 62378ca..981cffc 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -502,11 +502,11 @@ on_note_color_changed (BijiNoteObj *note, GtkColorButton *button)
static void
on_note_content_changed (BjbMainToolbar *self)
{
- gchar *str = NULL;
+ const gchar *str = NULL;
gboolean sensitive = TRUE;
if (self->priv->note)
- str = biji_note_get_raw_text (self->priv->note);
+ str = biji_note_obj_get_raw_text (self->priv->note);
if (!str || g_strcmp0 (str, "") == 0 || g_strcmp0 (str, "\n") == 0)
sensitive = FALSE;
@@ -603,24 +603,30 @@ bjb_note_menu_new (BjbMainToolbar *self)
gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
gtk_widget_show (item);
- /* Bullets, ordered list, separator */
- /* Bullets : unordered list format */
- item = gtk_menu_item_new_with_label (_("Bullets"));
- gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
- g_signal_connect_swapped (item, "activate",
- G_CALLBACK (bjb_toggle_bullets), editor);
- gtk_widget_show (item);
+ if (biji_note_obj_can_format (priv->note))
+ {
- /* Ordered list as 1.mouse 2.cats 3.dogs */
- item = gtk_menu_item_new_with_label (_("Numbered List"));
- gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
- g_signal_connect_swapped (item, "activate",
- G_CALLBACK (bjb_toggle_list), editor);
- gtk_widget_show(item);
+ /* Bullets, ordered list, separator */
+ /* Bullets : unordered list format */
+ item = gtk_menu_item_new_with_label (_("Bullets"));
+ gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
+ g_signal_connect_swapped (item, "activate",
+ G_CALLBACK (bjb_toggle_bullets), editor);
+ gtk_widget_show (item);
- item = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
- gtk_widget_show (item);
+
+ /* Ordered list as 1.mouse 2.cats 3.dogs */
+ item = gtk_menu_item_new_with_label (_("Numbered List"));
+ gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
+ g_signal_connect_swapped (item, "activate",
+ G_CALLBACK (bjb_toggle_list), editor);
+ gtk_widget_show(item);
+
+ item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
+ gtk_widget_show (item);
+
+ }
/* Rename, view tags, separtor */
item = gtk_menu_item_new_with_label(_("Rename"));
@@ -629,11 +635,15 @@ bjb_note_menu_new (BjbMainToolbar *self)
G_CALLBACK(action_rename_note_callback),self);
gtk_widget_show(item);
- item = gtk_menu_item_new_with_label(_("Collections"));
- gtk_menu_shell_append(GTK_MENU_SHELL(result),item);
- g_signal_connect(item,"activate",
- G_CALLBACK(action_view_tags_callback),self);
- gtk_widget_show(item);
+
+ if (biji_item_is_collectable (BIJI_ITEM (priv->note)))
+ {
+ item = gtk_menu_item_new_with_label(_("Collections"));
+ gtk_menu_shell_append(GTK_MENU_SHELL(result),item);
+ g_signal_connect(item,"activate",
+ G_CALLBACK(action_view_tags_callback),self);
+ gtk_widget_show(item);
+ }
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
@@ -694,28 +704,31 @@ populate_bar_for_note_view (BjbMainToolbar *self)
/* Note Color */
- if (!biji_note_obj_get_rgba (priv->note, &color))
+ if (biji_item_has_color (BIJI_ITEM (priv->note)))
{
- gchar *default_color;
+ if (!biji_note_obj_get_rgba (priv->note, &color))
+ {
+ gchar *default_color;
- g_object_get (G_OBJECT(settings),"color", &default_color, NULL);
- gdk_rgba_parse (&color, default_color);
- g_free (default_color);
- }
+ g_object_get (G_OBJECT(settings),"color", &default_color, NULL);
+ gdk_rgba_parse (&color, default_color);
+ g_free (default_color);
+ }
- button = bjb_color_button_new ();
- gtk_widget_set_tooltip_text (button, _("Note color"));
- gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), &color);
+ button = bjb_color_button_new ();
+ gtk_widget_set_tooltip_text (button, _("Note color"));
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), &color);
- gd_main_toolbar_add_widget (bar, button, FALSE);
- gtk_widget_set_size_request (gtk_bin_get_child (GTK_BIN (button)),
- COLOR_SIZE, COLOR_SIZE);
- gtk_widget_show (button);
+ gd_main_toolbar_add_widget (bar, button, FALSE);
+ gtk_widget_set_size_request (gtk_bin_get_child (GTK_BIN (button)),
+ COLOR_SIZE, COLOR_SIZE);
+ gtk_widget_show (button);
- g_signal_connect (button, "color-set",
- G_CALLBACK (on_color_button_clicked), self);
- priv->note_color_changed = g_signal_connect (priv->note, "color-changed",
- G_CALLBACK (on_note_color_changed), button);
+ g_signal_connect (button, "color-set",
+ G_CALLBACK (on_color_button_clicked), self);
+ priv->note_color_changed = g_signal_connect (priv->note, "color-changed",
+ G_CALLBACK (on_note_color_changed), button);
+ }
/* Sharing */
priv->share = gd_main_toolbar_add_button (bar, "send-to-symbolic",
diff --git a/src/bjb-main-view.c b/src/bjb-main-view.c
index d3ee396..77894d6 100644
--- a/src/bjb-main-view.c
+++ b/src/bjb-main-view.c
@@ -274,6 +274,8 @@ bjb_main_view_get_selected_items (BjbMainView *view)
}
+
+
static void
on_selection_mode_changed_cb (BjbMainView *self)
{
diff --git a/src/bjb-main-view.h b/src/bjb-main-view.h
index c0cb36f..5e9e689 100644
--- a/src/bjb-main-view.h
+++ b/src/bjb-main-view.h
@@ -61,6 +61,7 @@ GtkWidget *bjb_main_view_get_window(BjbMainView *view);
void action_new_window_callback(GtkAction *action, gpointer bjb_main_view);
+
GList *bjb_main_view_get_selected_items (BjbMainView *view);
@@ -88,6 +89,7 @@ GdMainViewType bjb_main_view_get_view_type (BjbMainView *view);
void bjb_main_view_set_view_type (BjbMainView *view, GdMainViewType type);
+
G_END_DECLS
#endif /* _MAIN_VIEW_H_ */
diff --git a/src/bjb-note-tag-dialog.c b/src/bjb-note-tag-dialog.c
index ebc191a..524c371 100644
--- a/src/bjb-note-tag-dialog.c
+++ b/src/bjb-note-tag-dialog.c
@@ -76,7 +76,7 @@ struct _BjbNoteTagDialogPrivate
G_DEFINE_TYPE (BjbNoteTagDialog, bjb_note_tag_dialog, GTK_TYPE_DIALOG);
static void
-append_collection (BijiTrackerInfoSet *set, BjbNoteTagDialog *self)
+append_collection (BijiInfoSet *set, BjbNoteTagDialog *self)
{
BjbNoteTagDialogPrivate *priv = self->priv;
@@ -99,7 +99,7 @@ append_collection (BijiTrackerInfoSet *set, BjbNoteTagDialog *self)
gtk_list_store_set (priv->store, &iter,
COL_SELECTION, item_has_tag,
- COL_URN, set->urn,
+ COL_URN, set->tracker_urn,
COL_TAG_NAME , set->title, -1);
}
@@ -108,10 +108,10 @@ bjb_compare_collection (gconstpointer a, gconstpointer b)
{
gchar *up_a, *up_b;
- BijiTrackerInfoSet *set_a, *set_b;
+ BijiInfoSet *set_a, *set_b;
gint retval;
- set_a = (BijiTrackerInfoSet *) a;
- set_b = (BijiTrackerInfoSet *) b;
+ set_a = (BijiInfoSet *) a;
+ set_b = (BijiInfoSet *) b;
up_a = g_utf8_strup (set_a->title, -1);
up_b = g_utf8_strup (set_b->title, -1);
diff --git a/src/bjb-selection-toolbar.c b/src/bjb-selection-toolbar.c
index 44fce13..411a972 100644
--- a/src/bjb-selection-toolbar.c
+++ b/src/bjb-selection-toolbar.c
@@ -137,17 +137,28 @@ bjb_selection_toolbar_set_item_visibility (BjbSelectionToolbar *self)
priv = self->priv;
selection = bjb_main_view_get_selected_items (priv->view);
- /* Trash, always,
- * Color, awlays */
+ /* Trash, always */
gtk_widget_set_visible (priv->toolbar_trash, TRUE);
+
+ /* Color */
+ gtk_widget_set_visible (priv->toolbar_color, FALSE);
+
+
for (l=selection; l !=NULL; l=l->next)
{
- if (BIJI_IS_NOTE_OBJ (l->data))
+ if (!biji_item_has_color (l->data))
+ {
+ gtk_widget_set_visible (priv->toolbar_color, FALSE);
+ break;
+ }
+
+ else if (BIJI_IS_NOTE_OBJ (l->data))
{
if (biji_note_obj_get_rgba (BIJI_NOTE_OBJ (l->data), &color))
{
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->toolbar_color), &color);
+ gtk_widget_set_visible (priv->toolbar_color, TRUE);
break;
}
}
@@ -155,13 +166,13 @@ bjb_selection_toolbar_set_item_visibility (BjbSelectionToolbar *self)
/* Organize */
- gtk_widget_set_visible (priv->toolbar_tag, 1);
+ gtk_widget_set_visible (priv->toolbar_tag, TRUE);
for (l=selection; l!=NULL; l=l->next)
{
- if (BIJI_IS_COLLECTION (l->data))
+ if (!biji_item_is_collectable (l->data))
{
- gtk_widget_set_visible (priv->toolbar_tag, 0);
+ gtk_widget_set_visible (priv->toolbar_tag, FALSE);
break;
}
}
diff --git a/src/bjb-share.c b/src/bjb-share.c
index c64f878..b01e26d 100644
--- a/src/bjb-share.c
+++ b/src/bjb-share.c
@@ -18,12 +18,12 @@
#include "bjb-share.h"
static gchar *
-mail_str (gchar * string )
+mail_str (const gchar * string )
{
if (!string)
return g_strdup ("''");
- return g_strdup (g_strdelimit (string, "\n", ' '));
+ return g_strdelimit (g_strdup (string), "\n", ' ');
}
/* TODO find EOL for xdg-email */
@@ -35,7 +35,7 @@ on_email_note_callback(GtkWidget *widget, BijiNoteObj *note)
gchar *title_mail, *text_mail;
title_mail = mail_str ((gchar*) biji_item_get_title (BIJI_ITEM (note)));
- text_mail = mail_str (biji_note_get_raw_text (note));
+ text_mail = mail_str (biji_note_obj_get_raw_text (note));
gchar *execute[7] = { "xdg-email",
"--utf8",
diff --git a/src/libbiji/Makefile.am b/src/libbiji/Makefile.am
index 94e2216..ee718ea 100644
--- a/src/libbiji/Makefile.am
+++ b/src/libbiji/Makefile.am
@@ -13,8 +13,12 @@ libbiji_la_SOURCES = \
biji-collection.h \
biji-date-time.c \
biji-date-time.h \
- biji-item.h \
+ biji-info-set.c \
+ biji-info-set.h \
biji-item.c \
+ biji-item.h \
+ biji-local-note.c \
+ biji-local-note.h \
biji-note-id.c \
biji-note-id.h \
biji-note-obj.c \
@@ -37,6 +41,12 @@ libbiji_la_SOURCES = \
editor/biji-editor-utils.h \
editor/biji-webkit-editor.c \
editor/biji-webkit-editor.h \
+ provider/biji-own-cloud-note.c \
+ provider/biji-own-cloud-note.h \
+ provider/biji-own-cloud-provider.c \
+ provider/biji-own-cloud-provider.h \
+ provider/biji-provider.c \
+ provider/biji-provider.h \
serializer/biji-lazy-serializer.c \
serializer/biji-lazy-serializer.h
diff --git a/src/libbiji/biji-collection.c b/src/libbiji/biji-collection.c
index c06d0a4..65d7128 100644
--- a/src/libbiji/biji-collection.c
+++ b/src/libbiji/biji-collection.c
@@ -18,6 +18,13 @@
*/
/*
+ * in current implementation, one cannot add a collection
+ * to a collection
+ * but tracker would be fine with this
+ * given we prevent self-containment.
+ */
+
+/*
* biji_create_collection_icon
* is adapted from Photos (photos_utils_create_collection_icon),
* which is ported from Documents
@@ -38,7 +45,7 @@ struct BijiCollectionPrivate_
gchar *urn;
gchar *name;
- gchar *mtime;
+ gint64 mtime;
GdkPixbuf *icon;
GdkPixbuf *emblem;
@@ -236,23 +243,19 @@ biji_collection_get_emblem (BijiItem *coll)
}
-/* Not the same as the prop, which is a string */
+
static gint64
biji_collection_get_mtime (BijiItem *coll)
{
- GTimeVal tv;
- gint64 timestamp = 0;
BijiCollection *self;
g_return_val_if_fail (BIJI_IS_COLLECTION (coll), 0);
self = BIJI_COLLECTION (coll);
- if (g_time_val_from_iso8601 (self->priv->mtime, &tv))
- timestamp = tv.tv_sec;
-
- return timestamp;
+ return self->priv->mtime;
}
+
static gboolean
biji_collection_trash (BijiItem *item)
{
@@ -262,7 +265,7 @@ biji_collection_trash (BijiItem *item)
self = BIJI_COLLECTION (item);
g_signal_emit (G_OBJECT (item), biji_collections_signals[COLLECTION_DELETED], 0);
- biji_remove_collection_from_tracker (self->priv->urn);
+ biji_remove_collection_from_tracker (biji_item_get_book (item), self->priv->urn);
g_object_unref (self);
return TRUE;
@@ -314,7 +317,7 @@ biji_collection_set_property (GObject *object,
self->priv->name = g_strdup (g_value_get_string (value));
break;
case PROP_MTIME:
- self->priv->mtime = g_strdup (g_value_get_string (value));
+ self->priv->mtime = g_value_get_int64 (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -343,7 +346,7 @@ biji_collection_get_property (GObject *object,
g_value_set_string (value, self->priv->name);
break;
case PROP_MTIME:
- g_value_set_string (value, self->priv->mtime);
+ g_value_set_int64 (value, self->priv->mtime);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -417,6 +420,12 @@ biji_collection_constructed (GObject *obj)
self);
}
+static gboolean
+say_no (BijiItem *item)
+{
+ return FALSE;
+}
+
static void
biji_collection_class_init (BijiCollectionClass *klass)
@@ -458,10 +467,10 @@ biji_collection_class_init (BijiCollectionClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
properties[PROP_MTIME] =
- g_param_spec_string ("mtime",
+ g_param_spec_int64 ("mtime",
"Modification time",
"Last modified time",
- NULL,
+ G_MININT64, G_MAXINT64, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (g_object_class, BIJI_COLL_PROPERTIES, properties);
@@ -495,7 +504,9 @@ biji_collection_class_init (BijiCollectionClass *klass)
item_class->get_emblem = biji_collection_get_emblem;
item_class->get_pristine = biji_collection_get_emblem;
item_class->get_mtime = biji_collection_get_mtime;
+ item_class->has_color = say_no;
item_class->trash = biji_collection_trash;
+ item_class->is_collectable = say_no;
item_class->has_collection = biji_collection_has_collection;
item_class->add_collection = biji_collection_add_collection;
item_class->remove_collection = biji_collection_remove_collection;
@@ -531,7 +542,7 @@ biji_collection_init (BijiCollection *self)
BijiCollection *
-biji_collection_new (GObject *book, gchar *urn, gchar *name, gchar *mtime)
+biji_collection_new (GObject *book, gchar *urn, gchar *name, gint64 mtime)
{
return g_object_new (BIJI_TYPE_COLLECTION,
"book", book,
diff --git a/src/libbiji/biji-collection.h b/src/libbiji/biji-collection.h
index 88cf9bb..073c51a 100644
--- a/src/libbiji/biji-collection.h
+++ b/src/libbiji/biji-collection.h
@@ -55,7 +55,7 @@ GType biji_collection_get_type (void);
/* Exiting coll in tracker : provide urn & iso8601 date
* To create a brand new collection in tracker rather gobjectize existing one,
* see biji_create_new_collection_async */
-BijiCollection * biji_collection_new (GObject *book, gchar *urn, gchar *name, gchar *mtime);
+BijiCollection * biji_collection_new (GObject *book, gchar *urn, gchar *name, gint64 mtime);
/* Watching for tracker would be best. Right now manually called. */
diff --git a/src/libbiji/biji-info-set.c b/src/libbiji/biji-info-set.c
new file mode 100644
index 0000000..71f2ef2
--- /dev/null
+++ b/src/libbiji/biji-info-set.c
@@ -0,0 +1,44 @@
+/* biji-info-set.h
+ * Copyright (C) Pierre-Yves LUYTEN 2013 <py luyten fr>
+ *
+ * libbiji is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * bijiben is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "biji-info-set.h"
+
+
+
+
+BijiInfoSet *
+biji_info_set_new ()
+{
+ BijiInfoSet *retval;
+
+ retval = g_slice_new0 (BijiInfoSet);
+ retval->url = NULL;
+ retval->title = NULL;
+ retval->content = NULL;
+ retval->datasource_urn = NULL;
+ retval->tracker_urn = NULL;
+ retval->user_data = NULL;
+
+ return retval;
+}
+
+
+void
+biji_info_set_free (BijiInfoSet *info)
+{
+ g_slice_free (BijiInfoSet, info);
+}
diff --git a/src/libbiji/biji-info-set.h b/src/libbiji/biji-info-set.h
new file mode 100644
index 0000000..0bb423b
--- /dev/null
+++ b/src/libbiji/biji-info-set.h
@@ -0,0 +1,64 @@
+/* biji-info-set.h
+ * Copyright (C) Pierre-Yves LUYTEN 2013 <py luyten fr>
+ *
+ * libbiji is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * bijiben is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/*
+ * All fields come from tracker.
+ * These fields are enough to create an object.
+ * Ideally, this would store _all_ the serialized data
+ * for local notes : bz #701828
+ *
+ * Ideally, this is also the cache system
+ */
+
+
+#ifndef _BIJI_INFO_SET_H_
+#define _BIJI_INFO_SET_H_ 1
+
+
+#include <glib-object.h>
+
+
+typedef struct
+{
+ /* core (ie, cache). All but content are coomon to bijiIem. */
+ gchar *url;
+ gchar *title;
+ gint64 mtime;
+ gchar *content;
+ gint64 created;
+
+
+ /* only when ensuring ressource */
+ gchar *datasource_urn;
+
+
+ /* only infoset H callback when retrieving urn */
+ gchar *tracker_urn;
+
+
+ /* deprecated */
+ gpointer user_data;
+
+} BijiInfoSet;
+
+
+BijiInfoSet * biji_info_set_new ();
+
+void biji_info_set_free (BijiInfoSet *info);
+
+#endif /* _BIJI_NOTE_ID_H_ */
diff --git a/src/libbiji/biji-item.c b/src/libbiji/biji-item.c
index e1bac66..59e6a63 100644
--- a/src/libbiji/biji-item.c
+++ b/src/libbiji/biji-item.c
@@ -18,10 +18,22 @@
*/
#include "biji-item.h"
+#include "biji-note-book.h"
+
+/* Properties */
+enum {
+ PROP_0,
+ PROP_BOOK,
+ BIJI_ITEM_PROP
+};
+
+
+static GParamSpec *properties[BIJI_ITEM_PROP] = { NULL, };
+
struct BijiItemPrivate_
{
- gpointer dummy;
+ BijiNoteBook *book;
};
static void biji_item_finalize (GObject *object);
@@ -30,14 +42,65 @@ G_DEFINE_TYPE (BijiItem, biji_item, G_TYPE_OBJECT)
static void
+biji_item_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ BijiItem *self = BIJI_ITEM (object);
+
+
+ switch (property_id)
+ {
+ case PROP_BOOK:
+ self->priv->book = g_value_dup_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+static void
+biji_item_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ BijiItem *self = BIJI_ITEM (object);
+
+ switch (property_id)
+ {
+ case PROP_BOOK:
+ g_value_set_object (value, self->priv->book);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
biji_item_class_init (BijiItemClass *klass)
{
GObjectClass *g_object_class;
g_object_class = G_OBJECT_CLASS (klass);
+ g_object_class->get_property = biji_item_get_property;
+ g_object_class->set_property = biji_item_set_property;
g_object_class->finalize = biji_item_finalize;
+ properties[PROP_BOOK] =
+ g_param_spec_object("note-book",
+ "Note Book",
+ "The Note Book controlling this item",
+ BIJI_TYPE_NOTE_BOOK,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+ g_object_class_install_properties (g_object_class, BIJI_ITEM_PROP, properties);
+
g_type_class_add_private ((gpointer)klass, sizeof (BijiItemPrivate));
}
@@ -55,6 +118,7 @@ static void
biji_item_init (BijiItem *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BIJI_TYPE_ITEM, BijiItemPrivate);
+ self->priv->book = NULL;
}
const gchar *
@@ -69,6 +133,14 @@ biji_item_get_uuid (BijiItem *item)
return BIJI_ITEM_GET_CLASS (item)->get_uuid (item);
}
+
+gpointer
+biji_item_get_book (BijiItem *item)
+{
+ return item->priv->book;
+}
+
+
GdkPixbuf *
biji_item_get_icon (BijiItem *item)
{
@@ -95,6 +167,13 @@ biji_item_get_mtime (BijiItem *item)
return BIJI_ITEM_GET_CLASS (item)->get_mtime (item);
}
+
+gboolean
+biji_item_has_color (BijiItem *item)
+{
+ return BIJI_ITEM_GET_CLASS (item)->has_color (item);
+}
+
gboolean
biji_item_trash (BijiItem *item)
{
@@ -102,6 +181,12 @@ biji_item_trash (BijiItem *item)
}
gboolean
+biji_item_is_collectable (BijiItem *item)
+{
+ return BIJI_ITEM_GET_CLASS (item)->is_collectable (item);
+}
+
+gboolean
biji_item_has_collection (BijiItem *item, gchar *coll)
{
return BIJI_ITEM_GET_CLASS (item)->has_collection (item, coll);
diff --git a/src/libbiji/biji-item.h b/src/libbiji/biji-item.h
index 29d7820..8ae068b 100644
--- a/src/libbiji/biji-item.h
+++ b/src/libbiji/biji-item.h
@@ -63,7 +63,12 @@ struct BijiItemClass_
GdkPixbuf * (*get_emblem) (BijiItem *item);
GdkPixbuf * (*get_pristine) (BijiItem *item);
gint64 (*get_mtime) (BijiItem *item);
+ gboolean (*has_color) (BijiItem *item);
+
gboolean (*trash) (BijiItem *item);
+
+
+ gboolean (*is_collectable) (BijiItem *item);
gboolean (*has_collection) (BijiItem *item, gchar *coll);
gboolean (*add_collection) (BijiItem *item, BijiItem *coll, gchar *title);
gboolean (*remove_collection) (BijiItem *item, BijiItem *coll);
@@ -85,6 +90,12 @@ const gchar * biji_item_get_title (BijiItem *item);
const gchar * biji_item_get_uuid (BijiItem *item);
+gpointer biji_item_get_book (BijiItem *item);
+
+
+gboolean biji_item_has_color (BijiItem *item);
+
+
GdkPixbuf * biji_item_get_icon (BijiItem *item);
@@ -100,6 +111,9 @@ gint64 biji_item_get_mtime (BijiItem *item);
gboolean biji_item_trash (BijiItem *item);
+gboolean biji_item_is_collectable (BijiItem *item);
+
+
gboolean biji_item_has_collection (BijiItem *item, gchar *collection);
diff --git a/src/libbiji/biji-local-note.c b/src/libbiji/biji-local-note.c
new file mode 100644
index 0000000..899f9ab
--- /dev/null
+++ b/src/libbiji/biji-local-note.c
@@ -0,0 +1,212 @@
+/* bjb-local-note.c
+ * Copyright (C) Pierre-Yves LUYTEN 2013 <py luyten fr>
+ *
+ * bijiben is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * bijiben is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "biji-local-note.h"
+#include "serializer/biji-lazy-serializer.h"
+
+
+struct BijiLocalNotePrivate_
+{
+ GFile *location;
+ gchar *basename;
+ gchar *html;
+};
+
+
+G_DEFINE_TYPE (BijiLocalNote, biji_local_note, BIJI_TYPE_NOTE_OBJ)
+
+/* Iface */
+
+gchar *
+local_note_get_html (BijiNoteObj *note)
+{
+ if (BIJI_IS_LOCAL_NOTE (note))
+ return BIJI_LOCAL_NOTE (note)->priv->html;
+
+ else
+ return NULL;
+}
+
+
+void
+local_note_set_html (BijiNoteObj *note,
+ gchar *html)
+{
+ if (BIJI_LOCAL_NOTE (note)->priv->html)
+ g_free (BIJI_LOCAL_NOTE (note)->priv->html);
+
+ if (html)
+ BIJI_LOCAL_NOTE (note)->priv->html = g_strdup (html);
+}
+
+
+void
+local_note_save (BijiNoteObj *note)
+{
+ g_return_if_fail (BIJI_IS_LOCAL_NOTE (note));
+
+ biji_lazy_serialize (note);
+ bijiben_push_note_to_tracker (note);
+}
+
+
+/* GObj */
+
+static void
+biji_local_note_finalize (GObject *object)
+{
+ BijiLocalNote *self;
+
+ g_return_if_fail (BIJI_IS_LOCAL_NOTE (object));
+
+ self = BIJI_LOCAL_NOTE (object);
+
+ if (self->priv->html)
+ g_free (self->priv->html);
+
+ G_OBJECT_CLASS (biji_local_note_parent_class)->finalize (object);
+}
+
+
+static void
+biji_local_note_init (BijiLocalNote *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BIJI_TYPE_LOCAL_NOTE, BijiLocalNotePrivate);
+ self->priv->html = NULL;
+}
+
+
+static gboolean
+item_yes (BijiItem * item)
+{
+ return TRUE;
+}
+
+
+static gboolean
+note_yes (BijiNoteObj *item)
+{
+ return TRUE;
+}
+
+
+static gboolean
+local_note_archive (BijiNoteObj *note)
+{
+ BijiLocalNote *self;
+ GFile *parent, *trash, *archive;
+ gchar *parent_path, *trash_path, *backup_path;
+ GError *error = NULL;
+ gboolean result = FALSE;
+
+ g_warning ("local note archive");
+ self = BIJI_LOCAL_NOTE (note);
+
+ /* Create the trash directory
+ * No matter if already exists */
+ parent = g_file_get_parent (self->priv->location);
+ parent_path = g_file_get_path (parent);
+ trash_path = g_build_filename (parent_path, ".Trash", NULL);
+ trash = g_file_new_for_path (trash_path);
+ g_file_make_directory (trash, NULL, NULL);
+
+ /* Move the note to trash */
+
+ backup_path = g_build_filename (trash_path, self->priv->basename, NULL);
+ archive = g_file_new_for_path (backup_path);
+
+ result = g_file_move (self->priv->location,
+ archive,
+ G_FILE_COPY_OVERWRITE,
+ NULL, // cancellable
+ NULL, // progress callback
+ NULL, // progress_callback_data,
+ &error);
+
+ if (error)
+ {
+ g_message ("%s", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+
+
+ g_free (parent_path);
+ g_object_unref (parent);
+ g_free (trash_path);
+ g_object_unref (trash);
+ g_free (backup_path);
+ g_object_unref (archive);
+
+ return result;
+}
+
+
+static gchar*
+local_note_get_basename (BijiNoteObj *note)
+{
+ return BIJI_LOCAL_NOTE (note)->priv->basename;
+}
+
+
+static void
+biji_local_note_class_init (BijiLocalNoteClass *klass)
+{
+ GObjectClass *g_object_class;
+ BijiItemClass *item_class;
+ BijiNoteObjClass *note_class;
+
+ g_object_class = G_OBJECT_CLASS (klass);
+ item_class = BIJI_ITEM_CLASS (klass);
+ note_class = BIJI_NOTE_OBJ_CLASS (klass);
+
+ g_object_class->finalize = biji_local_note_finalize;
+
+ item_class->is_collectable = item_yes;
+ item_class->has_color = item_yes;
+
+ note_class->get_basename = local_note_get_basename;
+ note_class->get_html = local_note_get_html;
+ note_class->set_html = local_note_set_html;
+ note_class->save_note = local_note_save;
+ note_class->can_format = note_yes;
+ note_class->archive = local_note_archive;
+
+ g_type_class_add_private ((gpointer)klass, sizeof (BijiLocalNotePrivate));
+}
+
+
+BijiNoteObj *
+biji_local_note_new_from_info (BijiNoteBook *book, BijiInfoSet *set)
+{
+ BijiNoteID *id;
+ BijiNoteObj *obj;
+ BijiLocalNote *local;
+
+ id = biji_note_id_new_from_info (set);
+
+ obj = g_object_new (BIJI_TYPE_LOCAL_NOTE,
+ "note-book", book,
+ "id", id,
+ NULL);
+
+ local = BIJI_LOCAL_NOTE (obj);
+ local->priv->location = g_file_new_for_commandline_arg (set->url);
+ local->priv->basename = g_file_get_basename (local->priv->location);
+
+ return obj;
+}
diff --git a/src/libbiji/biji-local-note.h b/src/libbiji/biji-local-note.h
new file mode 100644
index 0000000..1eb60a7
--- /dev/null
+++ b/src/libbiji/biji-local-note.h
@@ -0,0 +1,59 @@
+/* bjb-local-note.h
+ * Copyright (C) Pierre-Yves LUYTEN 2013 <py luyten fr>
+ *
+ * bijiben is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * bijiben is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef BIJI_LOCAL_NOTE_H_
+#define BIJI_LOCAL_NOTE_H_ 1
+
+#include "biji-note-id.h"
+#include "biji-note-obj.h"
+
+G_BEGIN_DECLS
+
+
+#define BIJI_TYPE_LOCAL_NOTE (biji_local_note_get_type ())
+#define BIJI_LOCAL_NOTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIJI_TYPE_LOCAL_NOTE,
BijiLocalNote))
+#define BIJI_LOCAL_NOTE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIJI_TYPE_LOCAL_NOTE,
BijiLocalNoteClass))
+#define BIJI_IS_LOCAL_NOTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIJI_TYPE_LOCAL_NOTE))
+#define BIJI_IS_LOCAL_NOTE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIJI_TYPE_LOCAL_NOTE))
+#define BIJI_LOCAL_NOTE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIJI_TYPE_LOCAL_NOTE,
BijiLocalNoteClass))
+
+typedef struct BijiLocalNote_ BijiLocalNote;
+typedef struct BijiLocalNoteClass_ BijiLocalNoteClass;
+typedef struct BijiLocalNotePrivate_ BijiLocalNotePrivate;
+
+struct BijiLocalNote_
+{
+ BijiNoteObj parent;
+ BijiLocalNotePrivate *priv;
+};
+
+struct BijiLocalNoteClass_
+{
+ BijiNoteObjClass parent_class;
+};
+
+
+GType biji_local_note_get_type (void);
+
+
+BijiNoteObj *biji_local_note_new_from_info (BijiNoteBook *book,
+ BijiInfoSet *set);
+
+G_END_DECLS
+
+#endif /* BIJI_LOCAL_NOTE_H_ */
diff --git a/src/libbiji/biji-note-book.c b/src/libbiji/biji-note-book.c
index 7d84cbc..52f030c 100644
--- a/src/libbiji/biji-note-book.c
+++ b/src/libbiji/biji-note-book.c
@@ -20,17 +20,22 @@
#include "libbiji.h"
#include "biji-collection.h"
+#include "biji-local-note.h"
+#include "provider/biji-own-cloud-provider.h"
struct _BijiNoteBookPrivate
{
/* Notes & Collections */
GHashTable *items;
+ GHashTable *providers;
/* Signals */
gulong note_renamed ;
GFile *location;
+ TrackerSparqlConnection *connection;
+ GdkRGBA color;
GCancellable *load_cancellable;
};
@@ -38,6 +43,7 @@ struct _BijiNoteBookPrivate
enum {
PROP_0,
PROP_LOCATION,
+ PROP_COLOR,
BIJI_BOOK_PROPERTIES
};
@@ -50,23 +56,51 @@ enum {
static guint biji_book_signals[BIJI_BOOK_SIGNALS] = { 0 };
static GParamSpec *properties[BIJI_BOOK_PROPERTIES] = { NULL, };
+
+
#define BIJI_NOTE_BOOK_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BIJI_TYPE_NOTE_BOOK,
BijiNoteBookPrivate))
G_DEFINE_TYPE (BijiNoteBook, biji_note_book, G_TYPE_OBJECT);
+
+
+
+
+
static void
biji_note_book_init (BijiNoteBook *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BIJI_TYPE_NOTE_BOOK,
- BijiNoteBookPrivate);
+ BijiNoteBookPrivate *priv;
+ GError *error;
+
+
+ priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BIJI_TYPE_NOTE_BOOK,
+ BijiNoteBookPrivate);
/* Item path is key for table */
- self->priv->items = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- NULL,
- g_object_unref);
+ priv->items = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ NULL,
+ g_object_unref);
+
+ error = NULL;
+ priv->connection = tracker_sparql_connection_get (NULL, &error);
+
+ if (error)
+ {
+ g_warning ("Tracker db connection failed : %s", error->message);
+ g_error_free (error);
+ }
+}
+
+
+TrackerSparqlConnection *
+biji_note_book_get_tracker_connection (BijiNoteBook *book)
+{
+ return book->priv->connection;
}
+
static void
biji_note_book_finalize (GObject *object)
{
@@ -82,6 +116,9 @@ biji_note_book_finalize (GObject *object)
G_OBJECT_CLASS (biji_note_book_parent_class)->finalize (object);
}
+
+
+
static void
biji_note_book_set_property (GObject *object,
guint property_id,
@@ -89,13 +126,23 @@ biji_note_book_set_property (GObject *object,
GParamSpec *pspec)
{
BijiNoteBook *self = BIJI_NOTE_BOOK (object);
-
+ GdkRGBA *color;
switch (property_id)
{
case PROP_LOCATION:
self->priv->location = g_value_dup_object (value);
break;
+
+ case PROP_COLOR:
+ color = g_value_get_pointer (value);
+ self->priv->color.red = color->red;
+ self->priv->color.blue = color->blue;
+ self->priv->color.green = color->green;
+ self->priv->color.alpha = color->alpha;
+ g_warning ("book color is not done :%s", gdk_rgba_to_string (&self->priv->color));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -175,6 +222,10 @@ biji_note_book_notify_changed (BijiNoteBook *book,
BijiNoteBookChangeFlag flag,
BijiItem *item)
{
+ g_warning ("biji_note_book_notify_changed, flag %i has_item=%i",
+ flag, (item != NULL));
+
+
g_signal_emit (G_OBJECT (book), biji_book_signals[BOOK_AMENDED], 0, flag, item);
return FALSE;
}
@@ -200,21 +251,25 @@ book_on_item_icon_changed_cb (BijiNoteObj *note, BijiNoteBook *book)
}
static void
-_biji_note_book_add_one_note (BijiNoteBook *book, BijiNoteObj *note)
+_biji_note_book_add_one_item (BijiNoteBook *book, BijiItem *item)
{
- g_return_if_fail (BIJI_IS_NOTE_OBJ (note));
+ BijiNoteObj *note;
+
+ g_return_if_fail (BIJI_IS_ITEM (item));
+ note = BIJI_IS_NOTE_OBJ (item) ? BIJI_NOTE_OBJ (item) : NULL;
- _biji_note_obj_set_book (note, (gpointer) book);
/* Add it to the list */
g_hash_table_insert (book->priv->items,
- (gpointer) biji_item_get_uuid (BIJI_ITEM (note)),
- note);
+ (gpointer) biji_item_get_uuid (item), item);
/* Notify */
- g_signal_connect (note, "changed", G_CALLBACK (book_on_note_changed_cb), book);
- g_signal_connect (note, "renamed", G_CALLBACK (book_on_note_changed_cb), book);
- g_signal_connect (note, "color-changed", G_CALLBACK (book_on_item_icon_changed_cb), book);
+ if (note)
+ {
+ g_signal_connect (note, "changed", G_CALLBACK (book_on_note_changed_cb), book);
+ g_signal_connect (note, "renamed", G_CALLBACK (book_on_note_changed_cb), book);
+ g_signal_connect (note, "color-changed", G_CALLBACK (book_on_item_icon_changed_cb), book);
+ }
}
#define ATTRIBUTES_FOR_NOTEBOOK "standard::content-type,standard::name"
@@ -245,7 +300,7 @@ create_collection_if_needed (gpointer key,
gpointer user_data)
{
BijiNoteBook *book = BIJI_NOTE_BOOK (user_data);
- BijiTrackerInfoSet *set = value;
+ BijiInfoSet *set = value;
BijiCollection *collection;
collection = g_hash_table_lookup (book->priv->items, key);
@@ -306,23 +361,29 @@ enumerate_next_files_ready_cb (GObject *source,
// now load the notes
for (l = files; l != NULL; l = l->next)
{
- GFileInfo *info;
+ GFileInfo *file;
const gchar *name;
- gchar *path;
BijiNoteObj *note;
+ BijiInfoSet info;
- info = l->data;
- name = g_file_info_get_name (info);
+ file = l->data;
+ name = g_file_info_get_name (file);
if (!g_str_has_suffix (name, ".note"))
continue;
- path = g_build_filename (base_path, name, NULL);
- note = biji_note_get_new_from_file (path);
+ info.url = g_build_filename (base_path, name, NULL);
+ info.title = "";
+ info.content = "";
+ info.mtime = 0;
+
- _biji_note_book_add_one_note (self, note);
+ note = biji_local_note_new_from_info (self, &info);
+ biji_lazy_deserialize (note);
- g_free (path);
+ _biji_note_book_add_one_item (self, BIJI_ITEM (note));
+
+ g_free (info.url);
}
g_free (base_path);
@@ -362,6 +423,10 @@ enumerate_children_ready_cb (GObject *source,
self);
}
+
+
+
+
static void
note_book_load_from_location (BijiNoteBook *self)
{
@@ -374,6 +439,64 @@ note_book_load_from_location (BijiNoteBook *self)
self);
}
+
+static void
+on_provider_loaded_cb (BijiProvider *provider,
+ GList *items,
+ BijiNoteBook *book)
+{
+ BijiItem *item = NULL;
+ BijiNoteBookChangeFlag flag = BIJI_BOOK_CHANGE_FLAG;
+ GList *l;
+ gint i = 0;
+
+
+ for (l=items; l!=NULL; l=l->next)
+ {
+ if (BIJI_IS_ITEM (l->data))
+ {
+ _biji_note_book_add_one_item (book, l->data);
+ i++;
+ }
+ }
+
+ if (i==1)
+ flag = BIJI_BOOK_ITEM_ADDED;
+
+ else if (i>1)
+ flag = BIJI_BOOK_MASS_CHANGE;
+
+
+ if (flag > BIJI_BOOK_CHANGE_FLAG)
+ biji_note_book_notify_changed (book, flag, item);
+}
+
+
+void
+biji_note_book_add_goa_object (BijiNoteBook *self,
+ GoaObject *object)
+{
+ BijiProvider *provider;
+ GoaAccount *account;
+ const gchar *type;
+
+ provider = NULL;
+ account = goa_object_get_account (object);
+
+ if (GOA_IS_ACCOUNT (account))
+ {
+ type = goa_account_get_provider_type (account);
+
+ if (g_strcmp0 (type, "owncloud") ==0)
+ provider = biji_own_cloud_provider_new (self, object);
+ }
+
+ if (provider)
+ g_signal_connect (provider, "loaded",
+ G_CALLBACK (on_provider_loaded_cb), self);
+}
+
+
static void
biji_note_book_constructed (GObject *object)
{
@@ -412,16 +535,37 @@ biji_note_book_class_init (BijiNoteBookClass *klass)
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_POINTER);
properties[PROP_LOCATION] =
- g_param_spec_object("location",
- "The book location",
- "The location where the notes are loaded and saved",
- G_TYPE_FILE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+ g_param_spec_object ("location",
+ "The book location",
+ "The location where the notes are loaded and saved",
+ G_TYPE_FILE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+
+ properties[PROP_COLOR] =
+ g_param_spec_pointer ("color",
+ "Default color",
+ "Note book default color for notes",
+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
+
g_object_class_install_properties (object_class, BIJI_BOOK_PROPERTIES, properties);
g_type_class_add_private (klass, sizeof (BijiNoteBookPrivate));
}
+
+void
+biji_note_book_get_default_color (BijiNoteBook *book, GdkRGBA *color)
+{
+ g_return_if_fail (BIJI_IS_NOTE_BOOK (book));
+
+ color->red = book->priv->color.red;
+ color->blue = book->priv->color.blue;
+ color->green = book->priv->color.green;
+ color->alpha = book->priv->color.alpha;
+}
+
+
gboolean
biji_note_book_remove_item (BijiNoteBook *book, BijiItem *item)
{
@@ -440,11 +584,12 @@ biji_note_book_remove_item (BijiNoteBook *book, BijiItem *item)
/* Signal before doing anything here. So the note is still
* fully available for signal receiver. */
biji_note_book_notify_changed (book, BIJI_BOOK_ITEM_TRASHED, to_delete);
-
- /* Ref note first, hash_table won't finalize it & we can delete it*/
- g_object_ref (to_delete);
- g_hash_table_remove (book->priv->items, path);
biji_item_trash (item);
+ g_hash_table_remove (book->priv->items, path);
+ /* Ref note first, hash_table won't finalize it & we can delete it*/
+ //g_object_ref (to_delete);
+ //g_hash_table_remove (book->priv->items, path);
+ //biji_item_trash (item);
retval = TRUE;
}
@@ -467,7 +612,7 @@ biji_note_book_add_item (BijiNoteBook *book, BijiItem *item, gboolean notify)
retval = FALSE;
else if (BIJI_IS_NOTE_OBJ (item))
- _biji_note_book_add_one_note (book, BIJI_NOTE_OBJ (item));
+ _biji_note_book_add_one_item (book, item);
else if (BIJI_IS_COLLECTION (item))
{
@@ -498,19 +643,26 @@ biji_note_book_get_item_at_path (BijiNoteBook *book, const gchar *path)
}
BijiNoteBook *
-biji_note_book_new (GFile *location)
+biji_note_book_new (GFile *location, GdkRGBA *color)
{
return g_object_new(BIJI_TYPE_NOTE_BOOK,
"location", location,
+ "color", color,
NULL);
}
BijiNoteObj *
-biji_note_get_new_from_file (const gchar* path)
+biji_note_get_new_from_file (BijiNoteBook *book, const gchar* path)
{
- BijiNoteObj* ret = biji_note_obj_new_from_path (path);
+ BijiInfoSet set;
+ BijiNoteObj *ret;
+
+ set.url = (gchar*) path;
+ set.mtime = 0;
+ set.title = NULL;
+ set.content = NULL;
- /* The deserializer will handle note type */
+ ret = biji_local_note_new_from_info (book, &set);
biji_lazy_deserialize (ret);
return ret ;
@@ -533,7 +685,11 @@ get_note_skeleton (BijiNoteBook *book)
{
BijiNoteObj *ret = NULL;
gchar * folder, *name, *path;
+ BijiInfoSet set;
+ set.title = NULL;
+ set.content = NULL;
+ set.mtime = 0;
folder = g_file_get_path (book->priv->location);
while (!ret)
@@ -541,9 +697,10 @@ get_note_skeleton (BijiNoteBook *book)
name = biji_note_book_get_uuid ();
path = g_build_filename (folder, name, NULL);
g_free (name);
+ set.url = path;
if (!g_hash_table_lookup (book->priv->items, path))
- ret = biji_note_obj_new_from_path (path);
+ ret = biji_local_note_new_from_info (book, &set);
g_free (path);
}
@@ -553,11 +710,6 @@ get_note_skeleton (BijiNoteBook *book)
return ret;
}
-static char*
-wrap_note_content (char *content)
-{
- return g_strdup_printf("<html xmlns=\"http://www.w3.org/1999/xhtml\"><body>%s</body></html>", content);
-}
BijiNoteObj *
biji_note_book_note_new (BijiNoteBook *book, gchar *str)
@@ -569,11 +721,11 @@ biji_note_book_note_new (BijiNoteBook *book, gchar *str)
gchar *unique, *html;
unique = biji_note_book_get_unique_title (book, str);
- html = wrap_note_content (str);
+ html = html_from_plain_text (str);
biji_note_obj_set_title (ret, unique);
biji_note_obj_set_raw_text (ret, str);
- biji_note_obj_set_html_content (ret, html);
+ biji_note_obj_set_html (ret, html);
g_free (unique);
g_free (html);
diff --git a/src/libbiji/biji-note-book.h b/src/libbiji/biji-note-book.h
index 60fac8e..7b0ce9c 100644
--- a/src/libbiji/biji-note-book.h
+++ b/src/libbiji/biji-note-book.h
@@ -2,9 +2,13 @@
#define _BIJI_NOTE_BOOK_H_
#include <glib-object.h>
+#include <tracker-sparql.h>
#include "biji-note-obj.h"
+#define GOA_API_IS_SUBJECT_TO_CHANGE
+#include <goa/goa.h>
+
G_BEGIN_DECLS
/* The flag tells if view should reload the whole model or not */
@@ -43,27 +47,58 @@ struct _BijiNoteBook
GType biji_note_book_get_type (void) G_GNUC_CONST;
-BijiNoteBook * biji_note_book_new (GFile *location);
-gchar * biji_note_book_get_unique_title (BijiNoteBook *book, const gchar *title);
-gboolean biji_note_book_add_item (BijiNoteBook *book, BijiItem *item, gboolean notify);
+BijiNoteBook *biji_note_book_new (GFile *location,
+ GdkRGBA *color);
+
+
+void biji_note_book_add_goa_object (BijiNoteBook *book,
+ GoaObject *object);
+
+
+TrackerSparqlConnection
+ *biji_note_book_get_tracker_connection (BijiNoteBook *book);
+
+
+void biji_note_book_get_default_color (BijiNoteBook *book,
+ GdkRGBA *color);
+
+
+gchar *biji_note_book_get_unique_title (BijiNoteBook *book,
+ const gchar *title);
-gboolean biji_note_book_notify_changed (BijiNoteBook *book,
- BijiNoteBookChangeFlag flag,
- BijiItem *item);
-gboolean biji_note_book_remove_item (BijiNoteBook *book, BijiItem *item);
+gboolean biji_note_book_add_item (BijiNoteBook *book,
+ BijiItem *item,
+ gboolean notify);
+
+
+gboolean biji_note_book_notify_changed (BijiNoteBook *book,
+ BijiNoteBookChangeFlag flag,
+ BijiItem *item);
+
+
+gboolean biji_note_book_remove_item (BijiNoteBook *book,
+ BijiItem *item);
+
+
+BijiItem *biji_note_book_get_item_at_path (BijiNoteBook *book,
+ const gchar *path);
-BijiItem * biji_note_book_get_item_at_path (BijiNoteBook *book, const gchar *path);
/* Get all items, either notes or collections
* Free the GList, not its content */
-GList * biji_note_book_get_items (BijiNoteBook *book);
+GList *biji_note_book_get_items (BijiNoteBook *book);
+
+
+BijiNoteObj *biji_note_get_new_from_file (BijiNoteBook *book,
+ const gchar* tomboy_format_note_path);
-BijiNoteObj* biji_note_get_new_from_file (const gchar* tomboy_format_note_path);
-BijiNoteObj * biji_note_book_note_new (BijiNoteBook *book, gchar *str);
+/* todo: add optional parameter : LOCAL or GOA */
+BijiNoteObj *biji_note_book_note_new (BijiNoteBook *book,
+ gchar *str);
G_END_DECLS
diff --git a/src/libbiji/biji-note-id.c b/src/libbiji/biji-note-id.c
index cd2784a..cc7e39f 100644
--- a/src/libbiji/biji-note-id.c
+++ b/src/libbiji/biji-note-id.c
@@ -21,35 +21,47 @@
enum {
PROP_0,
PROP_PATH,
+ PROP_TITLE,
+ PROP_MTIME,
+ PROP_CONTENT,
BIJI_ID_PROPERTIES
};
static GParamSpec *properties[BIJI_ID_PROPERTIES] = { NULL, };
+
struct _BijiNoteIDPrivate
{
- GFile * location;
- gchar * title ;
- gchar * basename;
- const gchar * path;
-
- GTimeVal last_change_date;
- GTimeVal last_metadata_change_date;
- GTimeVal create_date ;
+ /* InfoSet */
+
+ const gchar *path;
+ gchar *title;
+ gchar *content;
+ gint64 mtime;
+ gint64 create_date ;
+
+
+ /* Not sure anymore */
+
+ gchar *basename;
+ gint64 last_metadata_change_date;
+
};
#define NOTE_OBJ_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NOTE_TYPE_OBJ, NoteObjPrivate))
+
G_DEFINE_TYPE (BijiNoteID, biji_note_id, G_TYPE_OBJECT);
+
static void
biji_note_id_init (BijiNoteID *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, biji_note_id_get_type(),
BijiNoteIDPrivate);
- self->priv->location = NULL;
self->priv->title = NULL;
+ self->priv->content = NULL;
}
static void
@@ -58,7 +70,6 @@ biji_note_id_finalize (GObject *object)
BijiNoteID *id = BIJI_NOTE_ID (object);
BijiNoteIDPrivate *priv = id->priv;
- g_object_unref (priv->location);
g_free (priv->title);
G_OBJECT_CLASS (biji_note_id_parent_class)->finalize (object);
@@ -69,13 +80,12 @@ biji_note_id_set_path (BijiNoteID *self, const gchar *path)
{
g_return_if_fail (BIJI_IS_NOTE_ID (self));
- self->priv->location = g_file_new_for_path (path);
- self->priv->basename = g_file_get_basename (self->priv->location);
- self->priv->path = g_file_get_path (self->priv->location);
+ self->priv->path = g_strdup (path);
}
+
static void
-biji_note_id_set_property (GObject *object,
+biji_note_id_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
@@ -86,7 +96,17 @@ biji_note_id_set_property (GObject *object,
switch (property_id)
{
case PROP_PATH:
- biji_note_id_set_path (self,g_value_get_string (value));
+ biji_note_id_set_path (self, g_value_get_string (value));
+ break;
+ case PROP_TITLE:
+ biji_note_id_set_title (self, (gchar*) g_value_get_string (value));
+ break;
+ case PROP_MTIME:
+ self->priv->mtime = g_value_get_int64 (value);
+ break;
+ case PROP_CONTENT:
+ self->priv->content = g_strdup (g_value_get_string (value));
+ g_object_notify_by_pspec (object, properties[PROP_CONTENT]);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -105,7 +125,16 @@ biji_note_id_get_property (GObject *object,
switch (property_id)
{
case PROP_PATH:
- g_value_set_object (value, g_file_get_basename (self->priv->location));
+ g_value_set_object (value, self->priv->basename);
+ break;
+ case PROP_TITLE:
+ g_value_set_string (value, self->priv->title);
+ break;
+ case PROP_MTIME:
+ g_value_set_int64 (value, self->priv->mtime);
+ break;
+ case PROP_CONTENT:
+ g_value_set_string (value, self->priv->content);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -127,7 +156,29 @@ biji_note_id_class_init (BijiNoteIDClass *klass)
"The note file",
"The location where the note is stored and saved",
NULL,
- G_PARAM_READWRITE);
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
+
+ properties[PROP_TITLE] =
+ g_param_spec_string("title",
+ "The note title",
+ "Note current title",
+ NULL,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
+
+ properties[PROP_MTIME] =
+ g_param_spec_int64 ("mtime",
+ "Msec since epoch",
+ "The note last modification time",
+ G_MININT64, G_MAXINT64, 0,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
+
+
+ properties[PROP_CONTENT] =
+ g_param_spec_string("content",
+ "The note content",
+ "Plain text note content",
+ NULL,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
g_object_class_install_properties (object_class, BIJI_ID_PROPERTIES, properties);
@@ -137,7 +188,11 @@ biji_note_id_class_init (BijiNoteIDClass *klass)
gboolean
biji_note_id_equal (BijiNoteID *a, BijiNoteID *b)
{
- return g_file_equal (a->priv->location, b->priv->location);
+ if (g_strcmp0 (a->priv->path, b->priv->path) &&
+ g_strcmp0 (a->priv->content ,b->priv->content) ==0)
+ return TRUE;
+
+ return FALSE;
}
const gchar *
@@ -148,19 +203,6 @@ biji_note_id_get_path (BijiNoteID* n)
return n->priv->path;
}
-const gchar *
-biji_note_id_get_uuid (BijiNoteID *n)
-{
- g_return_val_if_fail (BIJI_IS_NOTE_ID (n), NULL);
-
- return n->priv->basename;
-}
-
-GFile *
-biji_note_id_get_file (BijiNoteID *note)
-{
- return note->priv->location;
-}
void
biji_note_id_set_title (BijiNoteID *n, gchar* title)
@@ -171,98 +213,116 @@ biji_note_id_set_title (BijiNoteID *n, gchar* title)
n->priv->title = g_strdup (title);
}
+
const gchar *
biji_note_id_get_title (BijiNoteID* n)
{
return n->priv->title ;
}
-static gboolean
-set_date_from_string (gchar *iso8601, GTimeVal *date)
+
+gboolean
+biji_note_id_set_content (BijiNoteID *id, gchar *content)
{
- g_return_val_if_fail (iso8601, FALSE);
- g_return_val_if_fail (date, FALSE);
+ g_return_val_if_fail (BIJI_IS_NOTE_ID (id), FALSE);
+ g_return_val_if_fail ((content != NULL), FALSE);
+
+ if (id->priv->content != NULL &&
+ g_strcmp0 (id->priv->content, content) !=0)
+ g_clear_pointer (&id->priv->content, g_free);
- if (!g_time_val_from_iso8601 (iso8601, date))
+
+ if (id->priv->content == NULL)
{
- g_get_current_time (date);
- return FALSE;
+ id->priv->content = g_strdup (content);
+ return TRUE;
}
- return TRUE;
+ return FALSE;
}
-gchar *
-biji_note_id_get_last_change_date (BijiNoteID* n)
-{
- g_return_val_if_fail (BIJI_IS_NOTE_ID (n), NULL);
-
- return g_time_val_to_iso8601 (&(n->priv->last_change_date));
-}
-void
-biji_note_id_set_last_change_date_now (BijiNoteID *n)
+const gchar *
+biji_note_id_get_content (BijiNoteID *id)
{
- g_get_current_time(&(n->priv->last_change_date));
-}
+ g_return_val_if_fail (BIJI_IS_NOTE_ID (id), NULL);
-glong
-biji_note_id_get_last_change_date_sec (BijiNoteID *n)
-{
- g_return_val_if_fail (BIJI_IS_NOTE_ID (n), 0);
-
- return n->priv->last_change_date.tv_sec ;
+ return id->priv->content;
}
+
gint64
biji_note_id_get_mtime (BijiNoteID *n)
{
- return n->priv->last_change_date.tv_sec;
+ return n->priv->mtime;
}
+
gboolean
-biji_note_id_set_last_change_date (BijiNoteID* n,gchar* date)
+biji_note_id_set_mtime (BijiNoteID *n, gint64 time)
{
- return set_date_from_string(date,&(n->priv->last_change_date));
+ if (n->priv->mtime != time)
+ {
+ n->priv->mtime = time;
+ return TRUE;
+ }
+
+ return FALSE;
}
-gchar *
-biji_note_id_get_last_metadata_change_date(BijiNoteID* n)
+
+gint64
+biji_note_id_get_last_metadata_change_date (BijiNoteID* n)
{
g_return_val_if_fail (BIJI_IS_NOTE_ID (n), NULL);
- return g_time_val_to_iso8601 (&n->priv->last_metadata_change_date);
+ return n->priv->last_metadata_change_date;
}
+
gboolean
-biji_note_id_set_last_metadata_change_date (BijiNoteID* n,gchar* date)
+biji_note_id_set_last_metadata_change_date (BijiNoteID* n, gint64 time)
{
- return set_date_from_string(date,&(n->priv->last_metadata_change_date));
-}
+ if (n->priv->last_metadata_change_date != time)
+ {
+ n->priv->last_metadata_change_date = time;
+ return TRUE;
+ }
-void
-biji_note_id_set_last_metadata_change_date_now (BijiNoteID *n)
-{
- g_get_current_time(&(n->priv->last_metadata_change_date));
+ return FALSE;
}
-gchar *
-biji_note_id_get_create_date(BijiNoteID* n)
+
+gint64
+biji_note_id_get_create_date (BijiNoteID* n)
{
g_return_val_if_fail (BIJI_IS_NOTE_ID (n), NULL);
- return g_time_val_to_iso8601 (&n->priv->create_date);
+ return n->priv->create_date;
}
+
gboolean
-biji_note_id_set_create_date (BijiNoteID* n,gchar* date)
+biji_note_id_set_create_date (BijiNoteID* n, gint64 time)
{
- return set_date_from_string (date, &(n->priv->create_date));
+ if (n->priv->create_date != time)
+ {
+ n->priv->create_date = time;
+ return TRUE;
+ }
+
+ return FALSE;
}
-void
-biji_note_id_set_create_date_now (BijiNoteID* n)
+
+BijiNoteID *
+biji_note_id_new_from_info (BijiInfoSet *info)
{
- g_get_current_time (&(n->priv->create_date));
+ return g_object_new (BIJI_TYPE_NOTE_ID,
+ "path", info->url,
+ "title", info->title,
+ "mtime", info->mtime,
+ "content", info->content,
+ NULL);
}
diff --git a/src/libbiji/biji-note-id.h b/src/libbiji/biji-note-id.h
index d20a557..9d911f7 100644
--- a/src/libbiji/biji-note-id.h
+++ b/src/libbiji/biji-note-id.h
@@ -22,6 +22,8 @@
#include <glib-object.h>
#include <gtk/gtk.h>
+#include "biji-tracker.h"
+
G_BEGIN_DECLS
#define BIJI_TYPE_NOTE_ID (biji_note_id_get_type ())
@@ -31,6 +33,8 @@ G_BEGIN_DECLS
#define BIJI_IS_NOTE_ID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIJI_TYPE_NOTE_ID))
#define BIJI_NOTE_ID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIJI_TYPE_NOTE_ID, BijiNoteIDClass))
+
+
typedef struct _BijiNoteIDClass BijiNoteIDClass;
typedef struct _BijiNoteID BijiNoteID;
@@ -47,41 +51,47 @@ struct _BijiNoteID
BijiNoteIDPrivate* priv;
};
-GType biji_note_id_get_type (void) G_GNUC_CONST;
+GType biji_note_id_get_type (void) G_GNUC_CONST;
+
+
+gboolean biji_note_id_equal (BijiNoteID *a, BijiNoteID *b);
+
+
+const gchar *biji_note_id_get_path (BijiNoteID *note);
+
+
+void biji_note_id_set_title (BijiNoteID* n, gchar* title);
+
+
+const gchar *biji_note_id_get_title (BijiNoteID* n);
+
+
+gboolean biji_note_id_set_content (BijiNoteID *id, gchar *content);
-gboolean biji_note_id_equal (BijiNoteID *a, BijiNoteID *b);
-const gchar * biji_note_id_get_path (BijiNoteID *note);
+const gchar *biji_note_id_get_content (BijiNoteID *id);
-const gchar * biji_note_id_get_uuid (BijiNoteID *note);
-GFile * biji_note_id_get_file (BijiNoteID *note);
+gint64 biji_note_id_get_mtime (BijiNoteID *n);
-void biji_note_id_set_title (BijiNoteID* n,gchar* title);
-const gchar* biji_note_id_get_title (BijiNoteID* n);
+gboolean biji_note_id_set_mtime (BijiNoteID* n, gint64 mtime);
-gchar * biji_note_id_get_last_change_date (BijiNoteID* n);
-glong biji_note_id_get_last_change_date_sec (BijiNoteID *n);
+gint64 biji_note_id_get_last_metadata_change_date (BijiNoteID* n);
-gint64 biji_note_id_get_mtime (BijiNoteID *n);
-gboolean biji_note_id_set_last_change_date (BijiNoteID* n,gchar* date);
+gboolean biji_note_id_set_last_metadata_change_date (BijiNoteID* n, gint64 mtime);
-void biji_note_id_set_last_change_date_now (BijiNoteID *n);
-gchar * biji_note_id_get_last_metadata_change_date (BijiNoteID* n);
+gint64 biji_note_id_get_create_date (BijiNoteID* n);
-gboolean biji_note_id_set_last_metadata_change_date (BijiNoteID* n,gchar* date);
-void biji_note_id_set_last_metadata_change_date_now (BijiNoteID *n);
+gboolean biji_note_id_set_create_date (BijiNoteID* n, gint64 mtime);
-gchar * biji_note_id_get_create_date (BijiNoteID* n);
-gboolean biji_note_id_set_create_date (BijiNoteID* n,gchar* date);
+BijiNoteID *biji_note_id_new_from_info (BijiInfoSet *info);
-void biji_note_id_set_create_date_now (BijiNoteID* n);
G_END_DECLS
diff --git a/src/libbiji/biji-note-obj.c b/src/libbiji/biji-note-obj.c
index 31de332..8566077 100644
--- a/src/libbiji/biji-note-obj.c
+++ b/src/libbiji/biji-note-obj.c
@@ -23,22 +23,18 @@
#include "biji-tracker.h"
#include "biji-zeitgeist.h"
#include "editor/biji-webkit-editor.h"
-#include "serializer/biji-lazy-serializer.h"
+
#include <libgd/gd.h>
struct _BijiNoteObjPrivate
{
- /* Notebook might be null. */
- BijiNoteBook *book;
-
/* Metadata */
BijiNoteID *id;
- GdkRGBA *color;
+ GdkRGBA *color; // Not yet in Tracker
- /* Data */
- gchar *html;
- gchar *raw_text;
+ /* Editing use the same widget
+ * for all notes provider. */
BijiWebkitEditor *editor;
/* Save */
@@ -62,11 +58,10 @@ struct _BijiNoteObjPrivate
gulong save;
};
-/* Properties
- * Actually path is just sent to note id */
+/* Properties */
enum {
PROP_0,
- PROP_PATH,
+ PROP_ID,
BIJI_OBJ_PROPERTIES
};
@@ -81,13 +76,20 @@ on_save_timeout (BijiNoteObj *self)
{
BijiNoteObjPrivate *priv = self->priv;
+ /* g_mutex_lock (priv->mutex); */
+
if (!priv->needs_save)
return;
g_object_ref (self);
- biji_lazy_serialize (self);
- bijiben_push_note_to_tracker(self);
+
+
+ /* Each note type serializes its own way
+ * FIXME: common tracker would make sense */
+
+
+ BIJI_NOTE_OBJ_GET_CLASS (self)->save_note (self);
priv->needs_save = FALSE;
g_object_unref (self);
@@ -101,15 +103,14 @@ biji_note_obj_init (BijiNoteObj *self)
priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BIJI_TYPE_NOTE_OBJ, BijiNoteObjPrivate);
self->priv = priv ;
-
- priv->id = g_object_new (BIJI_TYPE_NOTE_ID, NULL);
+ priv->id = NULL;
priv->needs_save = FALSE;
priv->timeout = biji_timeout_new ();
priv->save = g_signal_connect_swapped (priv->timeout, "timeout",
G_CALLBACK (on_save_timeout), self);
- priv->book = NULL ;
+
priv->is_template = FALSE ;
/* Existing note keep their title.
@@ -118,7 +119,6 @@ biji_note_obj_init (BijiNoteObj *self)
/* The editor is NULL so we know it's not opened
* neither fully deserialized */
- priv->html = NULL;
priv->editor = NULL;
/* Icon is only computed when necessary */
@@ -146,12 +146,6 @@ biji_note_obj_finalize (GObject *object)
g_clear_object (&priv->id);
- if (priv->html)
- g_free (priv->html);
-
- if (priv->raw_text);
- g_free (priv->raw_text);
-
g_hash_table_destroy (priv->labels);
if (priv->icon)
@@ -197,8 +191,8 @@ biji_note_obj_set_property (GObject *object,
switch (property_id)
{
- case PROP_PATH:
- g_object_set_property (G_OBJECT (self->priv->id), "path", value);
+ case PROP_ID:
+ self->priv->id = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -216,8 +210,8 @@ biji_note_obj_get_property (GObject *object,
switch (property_id)
{
- case PROP_PATH:
- g_value_set_object (value, (gpointer) biji_note_id_get_path (self->priv->id));
+ case PROP_ID:
+ g_value_set_object (value, self->priv->id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -226,46 +220,10 @@ biji_note_obj_get_property (GObject *object,
}
-BijiNoteObj *
-biji_note_obj_new_from_path (const gchar *path)
-{
- return g_object_new (BIJI_TYPE_NOTE_OBJ,
- "path", path,
- NULL);
-}
-
-void
-_biji_note_obj_set_book(BijiNoteObj *note, gpointer biji_note_book)
-{
- if ( BIJI_IS_NOTE_BOOK(biji_note_book) )
- {
- note->priv->book = biji_note_book ;
- }
- else
- {
- g_message("criticical : BIJI NOTE OBJ SET BOOK received wrong parameter");
- }
-}
-
-gpointer
-biji_note_obj_get_note_book(BijiNoteObj *note)
-{
- if ( note->priv->book != NULL )
- {
- return note->priv->book ;
- }
- g_message("biji note obj _ biji note obj get note book returns NULL");
- return NULL ;
-}
-
gboolean
biji_note_obj_are_same (BijiNoteObj *a, BijiNoteObj* b)
{
- if (biji_note_id_equal (a->priv->id,b->priv->id)
- && g_strcmp0 (a->priv->raw_text ,b->priv->raw_text) == 0)
- return TRUE;
-
- return FALSE;
+ return biji_note_id_equal (a->priv->id, b->priv->id);
}
/* First cancel timeout
@@ -275,9 +233,8 @@ biji_note_obj_trash (BijiItem *item)
{
BijiNoteObj *note_to_kill;
BijiNoteObjPrivate *priv;
- GFile *to_trash, *parent, *trash, *backup_file, *icon;
- gchar *note_name, *parent_path, *trash_path, *backup_path, *icon_path;
- GError *error = NULL;
+ GFile *icon;
+ gchar *icon_path;
gboolean result = FALSE;
note_to_kill = BIJI_NOTE_OBJ (item);
@@ -285,65 +242,29 @@ biji_note_obj_trash (BijiItem *item)
priv->needs_save = FALSE;
biji_timeout_cancel (priv->timeout);
+ biji_note_delete_from_tracker (note_to_kill);
- to_trash = biji_note_id_get_file (note_to_kill->priv->id);
-
- /* Don't try to backup a file which does not exist */
- if (to_trash)
- {
- note_name = g_file_get_basename (to_trash);
- parent = g_file_get_parent (to_trash);
-
- /* Create the trash directory
- * No matter if already exists */
- parent_path = g_file_get_path (parent);
- trash_path = g_build_filename (parent_path, ".Trash", NULL);
- g_free (parent_path);
- g_object_unref (parent);
- trash = g_file_new_for_path (trash_path);
- g_file_make_directory (trash, NULL, NULL);
-
- /* Move the note to trash */
- backup_path = g_build_filename (trash_path, note_name, NULL);
- g_free (trash_path);
- backup_file = g_file_new_for_path (backup_path);
- g_free (note_name);
- g_free (backup_path);
- result = g_file_move (to_trash,
- backup_file,
- G_FILE_COPY_OVERWRITE,
- NULL, // cancellable
- NULL, // progress callback
- NULL, // progress_callback_data,
- &error);
-
- if (error)
- {
- g_message ("%s", error->message);
- g_error_free (error);
- error = NULL;
- }
-
- /* Say goodbye however */
- g_object_unref (trash);
- g_object_unref (backup_file);
- }
+ result = BIJI_NOTE_OBJ_GET_CLASS (note_to_kill)->archive (note_to_kill);
/* Delete icon file */
icon_path = biji_note_obj_get_icon_file (note_to_kill);
icon = g_file_new_for_path (icon_path);
- g_free (icon_path);
g_file_delete (icon, NULL, NULL);
- g_object_unref (icon);
- /* Tracker, NoteBook, Memory. TODO : zeitgeist */
- biji_note_delete_from_tracker (note_to_kill);
+ /* TODO : zeitgeist */
g_signal_emit (G_OBJECT (note_to_kill), biji_obj_signals[NOTE_DELETED], 0);
- g_clear_object (¬e_to_kill);
+ //g_clear_object (¬e_to_kill);
+
+ if (icon_path != NULL)
+ g_free (icon_path);
+
+ if (icon != NULL)
+ g_object_unref (icon);
return result;
}
+
static const gchar *
biji_note_obj_get_path (BijiItem *item)
{
@@ -354,11 +275,14 @@ biji_note_obj_get_path (BijiItem *item)
return biji_note_id_get_path (note->priv->id);
}
-BijiNoteID* note_get_id(BijiNoteObj* n)
+
+BijiNoteID *
+note_get_id(BijiNoteObj* n)
{
return n->priv->id;
}
+
static const gchar *
biji_note_obj_get_title (BijiItem *note)
{
@@ -369,7 +293,7 @@ biji_note_obj_get_title (BijiItem *note)
/* If already a title, then note is renamed */
gboolean
-biji_note_obj_set_title (BijiNoteObj *note, gchar *proposed_title)
+biji_note_obj_set_title (BijiNoteObj *note, const gchar *proposed_title)
{
gboolean initial = FALSE;
note->priv->does_title_survive = TRUE;
@@ -384,8 +308,9 @@ biji_note_obj_set_title (BijiNoteObj *note, gchar *proposed_title)
/* If the note is really renamed, check the new title */
if (!initial)
{
- title = biji_note_book_get_unique_title (note->priv->book, proposed_title);
- biji_note_id_set_last_metadata_change_date_now (note->priv->id);
+ title = biji_note_book_get_unique_title (
+ biji_item_get_book (BIJI_ITEM (note)), proposed_title);
+ biji_note_id_set_last_metadata_change_date (note->priv->id, g_get_real_time ());
}
/* Otherwise it's up to the caller to sanitize its title */
@@ -401,12 +326,14 @@ biji_note_obj_set_title (BijiNoteObj *note, gchar *proposed_title)
return TRUE;
}
+
gboolean
biji_note_obj_title_survives (BijiNoteObj *note)
{
return note->priv->does_title_survive;
}
+
void
biji_note_obj_set_title_survives (BijiNoteObj *obj, gboolean value)
{
@@ -415,11 +342,13 @@ biji_note_obj_set_title_survives (BijiNoteObj *obj, gboolean value)
obj->priv->does_title_survive = value;
}
+
gboolean
-biji_note_obj_set_last_change_date (BijiNoteObj* n,gchar* date)
+biji_note_obj_set_mtime (BijiNoteObj* n, gint64 mtime)
{
- g_return_val_if_fail (BIJI_IS_NOTE_OBJ(n), FALSE);
- return biji_note_id_set_last_change_date (n->priv->id,date);
+ g_return_if_fail (BIJI_IS_NOTE_OBJ (n));
+
+ return biji_note_id_set_mtime (n->priv->id, mtime);
}
@@ -435,10 +364,11 @@ gchar *
biji_note_obj_get_last_change_date_string (BijiNoteObj *self)
{
return biji_get_time_diff_with_time (
- biji_note_id_get_last_change_date_sec(note_get_id(self)));
+ biji_note_id_get_mtime (self->priv->id));
}
-gchar *
+
+gint64
biji_note_obj_get_last_metadata_change_date (BijiNoteObj *note)
{
g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), NULL);
@@ -446,20 +376,21 @@ biji_note_obj_get_last_metadata_change_date (BijiNoteObj *note)
return biji_note_id_get_last_metadata_change_date (note->priv->id);
}
+
gboolean
-biji_note_obj_set_last_metadata_change_date (BijiNoteObj* n,gchar* date)
+biji_note_obj_set_last_metadata_change_date (BijiNoteObj* n, gint64 time)
{
g_return_val_if_fail (BIJI_IS_NOTE_OBJ(n), FALSE);
- return biji_note_id_set_last_metadata_change_date (n->priv->id,date);
+ return biji_note_id_set_last_metadata_change_date (n->priv->id, time);
}
gboolean
-biji_note_obj_set_note_create_date (BijiNoteObj* n,gchar *date)
+biji_note_obj_set_note_create_date (BijiNoteObj* n, gint64 time)
{
g_return_val_if_fail (BIJI_IS_NOTE_OBJ(n), FALSE);
- return biji_note_id_set_create_date (n->priv->id, date);
+ return biji_note_id_set_create_date (n->priv->id, time);
}
static void
@@ -490,7 +421,7 @@ biji_note_obj_set_rgba (BijiNoteObj *n, GdkRGBA *rgba)
biji_note_obj_clear_icons (n);
biji_note_obj_set_rgba_internal (n, rgba);
- biji_note_id_set_last_metadata_change_date_now (n->priv->id);
+ biji_note_id_set_last_metadata_change_date (n->priv->id, g_get_real_time ());
biji_note_obj_save_note (n);
}
}
@@ -511,14 +442,20 @@ biji_note_obj_get_rgba(BijiNoteObj *n,
}
-void biji_note_obj_set_raw_text (BijiNoteObj *note, gchar *plain_text)
+const gchar *
+biji_note_obj_get_raw_text (BijiNoteObj *note)
{
- if (note->priv->raw_text)
- g_free (note->priv->raw_text);
+ return biji_note_id_get_content (note->priv->id);
+}
- note->priv->raw_text = g_strdup (plain_text);
- biji_note_obj_clear_icons (note);
- g_signal_emit (note, biji_obj_signals[NOTE_CHANGED],0);
+void
+biji_note_obj_set_raw_text (BijiNoteObj *note, gchar *plain_text)
+{
+ if (biji_note_id_set_content (note->priv->id, plain_text))
+ {
+ biji_note_obj_clear_icons (note);
+ g_signal_emit (note, biji_obj_signals[NOTE_CHANGED],0);
+ }
}
GList *
@@ -575,7 +512,7 @@ biji_note_obj_add_collection (BijiItem *item,
{
biji_push_existing_collection_to_note (
note, label, _biji_collection_refresh, collection); // Tracker
- biji_note_id_set_last_metadata_change_date_now (note->priv->id);
+ biji_note_id_set_last_metadata_change_date (note->priv->id, g_get_real_time ());
biji_note_obj_save_note (note);
}
@@ -595,7 +532,7 @@ biji_note_obj_remove_collection (BijiItem *item, BijiItem *collection)
{
biji_remove_collection_from_note (
note, collection, _biji_collection_refresh, collection); // tracker.
- biji_note_id_set_last_metadata_change_date_now (note->priv->id);
+ biji_note_id_set_last_metadata_change_date (note->priv->id, g_get_real_time ());
biji_note_obj_save_note (note);
return TRUE;
}
@@ -652,7 +589,7 @@ biji_note_obj_get_icon_file (BijiNoteObj *note)
const gchar *uuid;
gchar *basename, *filename;
- uuid = biji_note_id_get_uuid (note->priv->id);
+ uuid = BIJI_NOTE_OBJ_GET_CLASS (note)->get_basename (note);
basename = biji_str_mass_replace (uuid, ".note", ".png", NULL);
filename = g_build_filename (g_get_user_cache_dir (),
@@ -661,7 +598,6 @@ biji_note_obj_get_icon_file (BijiNoteObj *note)
NULL);
g_free (basename);
-
return filename;
}
@@ -681,7 +617,7 @@ static GdkPixbuf *
biji_note_obj_get_icon (BijiItem *item)
{
GdkRGBA note_color;
- gchar *text;
+ const gchar *text;
cairo_t *cr;
PangoLayout *layout;
PangoFontDescription *desc;
@@ -708,7 +644,7 @@ biji_note_obj_get_icon (BijiItem *item)
cairo_fill (cr);
/* Text */
- text = biji_note_get_raw_text (note);
+ text = biji_note_id_get_content (note->priv->id);
if (text != NULL)
{
cairo_translate (cr, 10, 10);
@@ -824,93 +760,80 @@ biji_note_obj_get_emblem (BijiItem *item)
/* Single Note */
-gchar *
-biji_note_get_raw_text(BijiNoteObj *note)
+void
+biji_note_obj_set_all_dates_now (BijiNoteObj *note)
{
- if (note->priv->raw_text)
- return note->priv->raw_text;
+ gint64 time;
+ BijiNoteID *id;
+
+ g_return_if_fail (BIJI_IS_NOTE_OBJ (note));
- return "";
+ id = note->priv->id;
+ time = g_get_real_time ();
+ biji_note_id_set_create_date (id, time);
+ biji_note_id_set_last_metadata_change_date (id, time);
+ biji_note_id_set_mtime (id, time);
}
+
gboolean
biji_note_obj_is_template(BijiNoteObj *note)
{
return note_obj_is_template(note);
}
-gchar *
-biji_note_obj_get_last_change_date(BijiNoteObj *note)
-{
- g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), NULL);
-
- return biji_note_id_get_last_change_date (note->priv->id);
-}
-gchar *
-biji_note_obj_get_create_date(BijiNoteObj *note)
+gint64
+biji_note_obj_get_create_date (BijiNoteObj *note)
{
g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), NULL);
return biji_note_id_get_create_date (note->priv->id);
}
+
gboolean
-biji_note_obj_set_create_date (BijiNoteObj *note, gchar *date)
+biji_note_obj_set_create_date (BijiNoteObj *note, gint64 time)
{
g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), FALSE);
- return biji_note_id_set_create_date (note->priv->id, date);
+ return biji_note_id_set_create_date (note->priv->id, time);
}
-void
-biji_note_obj_set_create_date_now (BijiNoteObj *note)
-{
- g_return_if_fail (BIJI_IS_NOTE_OBJ (note));
- biji_note_id_set_create_date_now (note->priv->id);
-}
+/* Webkit */
-void
-biji_note_obj_set_last_change_date_now (BijiNoteObj *note)
+gchar *
+html_from_plain_text (gchar *content)
{
- g_return_if_fail (BIJI_IS_NOTE_OBJ (note));
+ gchar *escaped, *retval;
- biji_note_id_set_last_change_date_now (note->priv->id);
-}
+ escaped = biji_str_mass_replace (content,
+ "&", "&",
+ "<", "<",
+ ">", ">",
+ "\n", "<br/>",
+ NULL);
-void
-biji_note_obj_set_all_dates_now (BijiNoteObj *note)
-{
- g_return_if_fail (BIJI_IS_NOTE_OBJ (note));
- BijiNoteID *id = note->priv->id;
+ retval = g_strconcat ("<html xmlns=\"http://www.w3.org/1999/xhtml\">",
+ "<body>", escaped, "</body></html>", NULL);
- biji_note_id_set_create_date_now (id);
- biji_note_id_set_last_change_date_now (id);
- biji_note_id_set_last_metadata_change_date_now (id);
+ g_free (escaped);
+ return retval;
}
-/* Webkit */
gchar *
biji_note_obj_get_html (BijiNoteObj *note)
{
- if (BIJI_IS_NOTE_OBJ (note))
- return note->priv->html;
-
- else
- return NULL;
+ return BIJI_NOTE_OBJ_GET_CLASS (note)->get_html (note);
}
void
-biji_note_obj_set_html_content (BijiNoteObj *note,
- gchar *html)
+biji_note_obj_set_html (BijiNoteObj *note,
+ gchar *html)
{
- if (html)
- {
- g_free (note->priv->html);
- note->priv->html = g_strdup (html);
- }
+ BIJI_NOTE_OBJ_GET_CLASS (note)->set_html (note, html);
}
gboolean
@@ -922,22 +845,30 @@ biji_note_obj_is_opened (BijiNoteObj *note)
static void
_biji_note_obj_close (BijiNoteObj *note)
{
- BijiNoteObjPrivate *priv = note->priv;
+ BijiNoteObjPrivate *priv;
+ BijiItem *item;
+ BijiNoteBook *book;
+
+ priv = note->priv;
+ item = BIJI_ITEM (note);
+ book = biji_item_get_book (BIJI_ITEM (note));
priv->editor = NULL;
/* Delete if note is totaly blank
* Actually we just need to remove it from book
* since no change could trigger save */
- if (!priv->raw_text)
+ if (biji_note_id_get_content (priv->id) == NULL)
{
- biji_note_book_remove_item (priv->book, BIJI_ITEM (note));
+ biji_note_book_remove_item (book, item);
}
/* If the note only has one row. put some title */
else if (!biji_note_obj_title_survives (note))
{
- gchar *title = biji_note_book_get_unique_title (biji_note_obj_get_note_book (note),
- priv->raw_text);
+ gchar *title;
+
+ title = biji_note_book_get_unique_title (book,
+ biji_note_id_get_content (priv->id));
biji_note_obj_set_title (note, title);
g_free (title);
}
@@ -947,7 +878,7 @@ _biji_note_obj_close (BijiNoteObj *note)
else if (!biji_note_id_get_title (priv->id) ||
g_strcmp0 (biji_note_id_get_title (priv->id),"")==0)
{
- biji_note_obj_set_title (note, priv->raw_text);
+ biji_note_obj_set_title (note, biji_note_id_get_content (priv->id));
}
}
@@ -974,6 +905,14 @@ biji_note_obj_get_editor (BijiNoteObj *note)
return GTK_WIDGET (note->priv->editor);
}
+
+gboolean
+biji_note_obj_can_format (BijiNoteObj *note)
+{
+ return BIJI_NOTE_OBJ_GET_CLASS (note)->can_format (note);
+}
+
+
void
biji_note_obj_editor_apply_format (BijiNoteObj *note, gint format)
{
@@ -1028,12 +967,12 @@ biji_note_obj_class_init (BijiNoteObjClass *klass)
object_class->get_property = biji_note_obj_get_property;
object_class->set_property = biji_note_obj_set_property;
- properties[PROP_PATH] =
- g_param_spec_string("path",
- "The note file",
- "The location where the note is stored and saved",
- NULL,
- G_PARAM_READWRITE);
+ properties[PROP_ID] =
+ g_param_spec_object("id",
+ "The note id",
+ "The basic information about the note",
+ BIJI_TYPE_NOTE_ID,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
g_object_class_install_properties (object_class, BIJI_OBJ_PROPERTIES, properties);
@@ -1083,7 +1022,8 @@ biji_note_obj_class_init (BijiNoteObjClass *klass)
g_type_class_add_private (klass, sizeof (BijiNoteObjPrivate));
- /* Interface */
+ /* Interface
+ * is_collectable is implemented at higher level, eg local_note */
item_class->get_title = biji_note_obj_get_title;
item_class->get_uuid = biji_note_obj_get_path;
item_class->get_icon = biji_note_obj_get_icon;
diff --git a/src/libbiji/biji-note-obj.h b/src/libbiji/biji-note-obj.h
index 577794a..53642d1 100644
--- a/src/libbiji/biji-note-obj.h
+++ b/src/libbiji/biji-note-obj.h
@@ -46,6 +46,7 @@ typedef enum
#define BIJI_IS_NOTE_OBJ_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIJI_TYPE_NOTE_OBJ))
#define BIJI_NOTE_OBJ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIJI_TYPE_NOTE_OBJ,
BijiNoteObjClass))
+
typedef struct _BijiNoteObjClass BijiNoteObjClass;
typedef struct _BijiNoteObj BijiNoteObj;
@@ -54,6 +55,13 @@ typedef struct _BijiNoteObjPrivate BijiNoteObjPrivate;
struct _BijiNoteObjClass
{
BijiItemClass parent_class;
+
+ gchar* (*get_basename) (BijiNoteObj *note);
+ gchar* (*get_html) (BijiNoteObj *note);
+ void (*set_html) (BijiNoteObj *note, gchar *html);
+ void (*save_note) (BijiNoteObj *note);
+ gboolean (*archive) (BijiNoteObj *note);
+ gboolean (*can_format) (BijiNoteObj *note);
};
struct _BijiNoteObj
@@ -62,100 +70,136 @@ struct _BijiNoteObj
BijiNoteObjPrivate* priv ;
};
-GType biji_note_obj_get_type (void) G_GNUC_CONST;
-
-BijiNoteObj * biji_note_obj_new_from_path (const gchar *path);
-void biji_note_obj_fix_path (BijiNoteObj *note, gchar *path);
-/////////////////////////////////////////////////// Relationships other notes
-gpointer biji_note_obj_get_note_book(BijiNoteObj *note);
+GType biji_note_obj_get_type (void) G_GNUC_CONST;
-void _biji_note_obj_set_book(BijiNoteObj *note, gpointer biji_note_book);
-gboolean biji_note_obj_are_same(BijiNoteObj *a, BijiNoteObj* b);
+gboolean biji_note_obj_are_same (BijiNoteObj *a,
+ BijiNoteObj* b);
-///////////////////////////////////////////////////////////////////// Metadata
/* will enter hit make title renamed? */
-gboolean biji_note_obj_title_survives (BijiNoteObj *note);
-void biji_note_obj_set_title_survives (BijiNoteObj *obj, gboolean value);
+gboolean biji_note_obj_title_survives (BijiNoteObj *note);
+
+
+void biji_note_obj_set_title_survives (BijiNoteObj *obj,
+ gboolean value);
+
+
+gboolean biji_note_obj_set_mtime (BijiNoteObj* n,
+ gint64 time);
+
+
+gchar *biji_note_obj_get_last_change_date_string (BijiNoteObj *self);
+
+
+gint64 biji_note_obj_get_last_metadata_change_date (BijiNoteObj *note);
+
+
+gboolean biji_note_obj_set_last_metadata_change_date (BijiNoteObj* n,
+ gint64 time);
+
+
+gint64 biji_note_obj_get_create_date (BijiNoteObj *note);
+
+
+gboolean biji_note_obj_set_create_date (BijiNoteObj* n ,
+ gint64 time);
+
+
+void biji_note_obj_set_all_dates_now (BijiNoteObj *note);
+
+
+int get_note_status (BijiNoteObj* n);
+
+
+void set_note_status (BijiNoteObj* n,
+ int status) ;
+
+
+gboolean biji_note_obj_get_rgba (BijiNoteObj *n,
+ GdkRGBA *rgba) ;
+
+
+void biji_note_obj_set_rgba (BijiNoteObj *n, GdkRGBA *rgba) ;
+
+
+GList *biji_note_obj_get_collections (BijiNoteObj *n);
+
+
+gboolean note_obj_is_template (BijiNoteObj *n) ;
+
+
+void note_obj_set_is_template (BijiNoteObj *n,
+ gboolean is_template);
+
+
+void biji_note_obj_save_note (BijiNoteObj *self);
+
+
+void biji_note_obj_set_icon (BijiNoteObj *note,
+ GdkPixbuf *pix);
+
-gboolean biji_note_obj_set_last_change_date (BijiNoteObj* n,gchar* date);
+gchar *biji_note_obj_get_icon_file (BijiNoteObj *note);
-void biji_note_obj_set_last_change_date_now (BijiNoteObj* n) ;
-gchar * biji_note_obj_get_last_change_date_string (BijiNoteObj *self);
+const gchar *biji_note_obj_get_raw_text (BijiNoteObj *note);
-gchar * biji_note_obj_get_last_metadata_change_date (BijiNoteObj *note);
-gboolean biji_note_obj_set_last_metadata_change_date (BijiNoteObj* n,gchar* date) ;
+void biji_note_obj_set_raw_text (BijiNoteObj *note,
+ gchar *plain_text);
-gboolean biji_note_obj_set_create_date (BijiNoteObj* n ,gchar* date);
-void biji_note_obj_set_create_date_now (BijiNoteObj *note);
+gboolean biji_note_obj_set_title (BijiNoteObj* note_obj_ptr,
+ const gchar* title);
-void biji_note_obj_set_all_dates_now (BijiNoteObj *note);
-int get_note_status(BijiNoteObj* n);
+gboolean biji_note_obj_is_template (BijiNoteObj *note);
-void set_note_status(BijiNoteObj* n, int status) ;
-gboolean biji_note_obj_get_rgba(BijiNoteObj *n, GdkRGBA *rgba) ;
+GtkWidget *biji_note_obj_open (BijiNoteObj *note);
-void biji_note_obj_set_rgba(BijiNoteObj *n, GdkRGBA *rgba) ;
-/* Tracker Tags. Free the GList.
- * Remove label always due to user action. Add label has to precise */
+gboolean biji_note_obj_is_opened (BijiNoteObj *note);
-GList * biji_note_obj_get_collections (BijiNoteObj *n);
-gboolean note_obj_is_template(BijiNoteObj *n) ;
+GtkWidget *biji_note_obj_get_editor (BijiNoteObj *note);
-void note_obj_set_is_template(BijiNoteObj *n,gboolean is_template);
-void biji_note_obj_save_note (BijiNoteObj *self);
+gboolean biji_note_obj_can_format (BijiNoteObj *note);
-void biji_note_obj_set_icon (BijiNoteObj *note, GdkPixbuf *pix);
-gchar *biji_note_obj_get_icon_file (BijiNoteObj *note);
+gchar *html_from_plain_text (gchar *content);
-gchar *biji_note_get_raw_text(BijiNoteObj *note);
-void biji_note_obj_set_raw_text (BijiNoteObj *note, gchar *plain_text);
+void biji_note_obj_set_html (BijiNoteObj *note,
+ gchar *html);
-gboolean biji_note_obj_set_title (BijiNoteObj* note_obj_ptr,gchar* title);
-gboolean biji_note_obj_is_template(BijiNoteObj *note);
+gchar *biji_note_obj_get_html (BijiNoteObj *note);
-gchar *biji_note_obj_get_last_change_date(BijiNoteObj *note);
-gchar *biji_note_obj_get_create_date(BijiNoteObj *note);
+void biji_note_obj_editor_apply_format (BijiNoteObj *note,
+ gint format);
-/* Webkit : note edition */
-GtkWidget * biji_note_obj_open (BijiNoteObj *note);
+gboolean biji_note_obj_editor_has_selection (BijiNoteObj *note);
-gboolean biji_note_obj_is_opened (BijiNoteObj *note);
-GtkWidget * biji_note_obj_get_editor (BijiNoteObj *note);
+gchar *biji_note_obj_editor_get_selection (BijiNoteObj *note);
-void biji_note_obj_set_html_content (BijiNoteObj *note, gchar *html);
-gchar * biji_note_obj_get_html (BijiNoteObj *note);
+void biji_note_obj_editor_cut (BijiNoteObj *note);
-void biji_note_obj_editor_apply_format (BijiNoteObj *note,
- gint format);
-gboolean biji_note_obj_editor_has_selection (BijiNoteObj *note);
+void biji_note_obj_editor_copy (BijiNoteObj *note);
-gchar * biji_note_obj_editor_get_selection (BijiNoteObj *note);
-void biji_note_obj_editor_cut (BijiNoteObj *note);
+void biji_note_obj_editor_paste (BijiNoteObj *note);
-void biji_note_obj_editor_copy (BijiNoteObj *note);
-void biji_note_obj_editor_paste (BijiNoteObj *note);
G_END_DECLS
diff --git a/src/libbiji/biji-tracker.c b/src/libbiji/biji-tracker.c
index 6361fa4..a4a6990 100644
--- a/src/libbiji/biji-tracker.c
+++ b/src/libbiji/biji-tracker.c
@@ -25,7 +25,10 @@ typedef enum
BIJI_URN_COL,
BIJI_TITLE_COL,
BIJI_MTIME_COL,
+ BIJI_CONTENT_COL,
+ BIJI_CREATED_COL,
BIJI_NO_COL
+
} BijiTrackerColumns;
@@ -39,10 +42,12 @@ typedef struct {
/* usually a query */
gchar *str;
+ BijiInfoSet *info;
/* after the query, _one of_ the callbacks */
BijiBoolCallback bool_cb;
+ BijiInfoCallback info_cb;
BijiItemCallback item_cb;
BijiItemsListCallback list_cb;
BijiInfoSetsHCallback hash_cb;
@@ -60,7 +65,9 @@ typedef struct {
static BijiTrackerFinisher *
biji_tracker_finisher_new (BijiNoteBook *book,
gchar *str,
+ BijiInfoSet *info,
BijiBoolCallback bool_cb,
+ BijiInfoCallback info_cb,
BijiItemCallback item_cb,
BijiItemsListCallback list_cb,
BijiInfoSetsHCallback hash_cb,
@@ -70,7 +77,9 @@ biji_tracker_finisher_new (BijiNoteBook *book,
retval->book = book;
retval->str = str;
+ retval->info = info;
retval->bool_cb = bool_cb;
+ retval->info_cb = info_cb;
retval->item_cb = item_cb;
retval->list_cb = list_cb;
retval->hash_cb = hash_cb;
@@ -90,42 +99,10 @@ biji_tracker_finisher_free (BijiTrackerFinisher *f)
}
-static BijiTrackerInfoSet *
-biji_tracker_info_set_new ()
-{
- return g_slice_new (BijiTrackerInfoSet);
-}
-
-
-static void
-biji_tracker_info_set_free (BijiTrackerInfoSet *set)
+static TrackerSparqlConnection*
+get_connection (BijiNoteBook *book)
{
- g_free (set->urn);
- g_free (set->title);
- g_free (set->mtime);
-
- g_slice_free (BijiTrackerInfoSet, (gpointer) set);
-}
-
-
-TrackerSparqlConnection *bjb_connection ;
-
-
-static TrackerSparqlConnection *
-get_connection_singleton(void)
-{
- if ( bjb_connection == NULL )
- {
- GError *error = NULL ;
-
- g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"Getting tracker connection.");
- bjb_connection = tracker_sparql_connection_get (NULL,&error);
-
- if ( error )
- g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"Connection errror. Tracker out.");
- }
-
- return bjb_connection ;
+ return biji_note_book_get_tracker_connection (book);
}
@@ -141,6 +118,7 @@ biji_finish_update (GObject *source_object,
GError *error;
gchar *query;
+ g_warning ("biji finish update");
self = TRACKER_SPARQL_CONNECTION (source_object);
finisher = user_data;
error = NULL;
@@ -159,17 +137,21 @@ biji_finish_update (GObject *source_object,
finisher->bool_cb (TRUE, finisher->user_data);
biji_tracker_finisher_free (finisher);
+ g_warning ("biji finish update = done");
}
static void
-biji_perform_update_async_and_free (gchar *query, BijiBoolCallback f, gpointer user_data)
+biji_perform_update_async_and_free (TrackerSparqlConnection *connection,
+ gchar *query,
+ BijiBoolCallback f,
+ gpointer user_data)
{
BijiTrackerFinisher *finisher;
- finisher = biji_tracker_finisher_new
- (NULL, query, f, NULL, NULL, NULL, user_data);
- tracker_sparql_connection_update_async (get_connection_singleton(),
+ finisher = biji_tracker_finisher_new
+ (NULL, query, NULL, f, NULL, NULL, NULL, NULL, user_data);
+ tracker_sparql_connection_update_async (connection,
query,
0, // priority
NULL,
@@ -182,7 +164,9 @@ biji_perform_update_async_and_free (gchar *query, BijiBoolCallback f, gpointer u
static gchar *
tracker_str (const gchar * string )
{
- return biji_str_mass_replace (string, "\n", " ", "'", " ", NULL);
+ g_return_val_if_fail (string != NULL, g_strdup (""));
+
+ return biji_str_mass_replace (string, "\n", "b<br/>", "'", " ", NULL);
}
@@ -218,7 +202,7 @@ biji_query_info_hash_finish (GObject *source_object,
finisher = (BijiTrackerFinisher*) user_data;
error = NULL;
result = g_hash_table_new_full (
- g_str_hash, g_str_equal, NULL, (GDestroyNotify) biji_tracker_info_set_free);
+ g_str_hash, g_str_equal, NULL, (GDestroyNotify) biji_info_set_free);
cursor = tracker_sparql_connection_query_finish (self,
res,
@@ -235,13 +219,19 @@ biji_query_info_hash_finish (GObject *source_object,
while (tracker_sparql_cursor_next (cursor, NULL, NULL))
{
- BijiTrackerInfoSet *set = biji_tracker_info_set_new ();
+ BijiInfoSet *set = biji_info_set_new ();
+ GTimeVal time = {0,0};
- set->urn = g_strdup (tracker_sparql_cursor_get_string (cursor, BIJI_URN_COL, NULL));
+ set->tracker_urn = g_strdup (tracker_sparql_cursor_get_string (cursor, BIJI_URN_COL, NULL));
set->title = g_strdup (tracker_sparql_cursor_get_string (cursor, BIJI_TITLE_COL, NULL));
- set->mtime = g_strdup (tracker_sparql_cursor_get_string (cursor, BIJI_MTIME_COL, NULL));
+
+ if (g_time_val_from_iso8601 (tracker_sparql_cursor_get_string (cursor, BIJI_MTIME_COL, NULL), &time))
+ set->mtime = time.tv_sec;
- g_hash_table_replace (result, set->urn, set);
+ else
+ set->mtime = 0;
+
+ g_hash_table_replace (result, set->tracker_urn, set);
}
g_object_unref (cursor);
@@ -330,7 +320,7 @@ bjb_query_async (BijiNoteBook *book,
BijiTrackerFinisher *finisher;
GAsyncReadyCallback callback = NULL;
- finisher = biji_tracker_finisher_new (book, NULL, NULL, NULL, list_cb, hash_cb, user_data);
+ finisher = biji_tracker_finisher_new (book, NULL, NULL, NULL, NULL, NULL, list_cb, hash_cb, user_data);
if (hash_cb != NULL)
callback = biji_query_info_hash_finish;
@@ -340,7 +330,7 @@ bjb_query_async (BijiNoteBook *book,
if (callback)
tracker_sparql_connection_query_async (
- get_connection_singleton (), query, NULL, callback, finisher);
+ get_connection (book), query, NULL, callback, finisher);
}
@@ -461,20 +451,11 @@ on_new_collection_query_executed (GObject *source_object, GAsyncResult *res, gpo
/* Update the note book */
if (urn)
{
- gint64 timestamp;
- GTimeVal tv;
- gchar *time;
-
- timestamp = g_get_real_time () / G_USEC_PER_SEC;
- tv.tv_sec = timestamp;
- tv.tv_usec = 0;
- time = g_time_val_to_iso8601 (&tv);
-
collection = biji_collection_new (
G_OBJECT (finisher->book),
urn,
finisher->str,
- time);
+ g_get_real_time () / G_USEC_PER_SEC);
biji_note_book_add_item (finisher->book, BIJI_ITEM (collection), TRUE);
}
@@ -520,8 +501,8 @@ biji_create_new_collection_async (BijiNoteBook *book,
/* The finisher has all the pointers we want.
* And the callback will free it */
- finisher = biji_tracker_finisher_new (book, g_strdup (name), NULL, item_cb, NULL, NULL, user_data);
- tracker_sparql_connection_update_blank_async (get_connection_singleton (),
+ finisher = biji_tracker_finisher_new (book, g_strdup (name), NULL, NULL, NULL, item_cb, NULL, NULL,
user_data);
+ tracker_sparql_connection_update_blank_async (get_connection (book),
query,
G_PRIORITY_DEFAULT,
NULL,
@@ -533,12 +514,12 @@ biji_create_new_collection_async (BijiNoteBook *book,
/* removes the tag EVEN if files associated. */
void
-biji_remove_collection_from_tracker (const gchar *urn)
+biji_remove_collection_from_tracker (BijiNoteBook *book, const gchar *urn)
{
gchar *query;
query = g_strdup_printf ("DELETE {'%s' a nfo:DataContainer}", urn);
- biji_perform_update_async_and_free (query, NULL, NULL);
+ biji_perform_update_async_and_free (get_connection (book), query, NULL, NULL);
}
@@ -554,7 +535,8 @@ biji_push_existing_collection_to_note (BijiNoteObj *note,
query = g_strdup_printf ("INSERT {?urn nie:isPartOf '%s'} WHERE {?urn a nfo:DataContainer; nie:title '%s';
nie:generator 'Bijiben'}",
url, title);
- biji_perform_update_async_and_free (query, afterward, user_data);
+ biji_perform_update_async_and_free (
+ get_connection (biji_item_get_book (BIJI_ITEM (note))), query, afterward, user_data);
g_free (url);
}
@@ -575,7 +557,7 @@ biji_remove_collection_from_note (BijiNoteObj *note,
biji_item_get_uuid (coll), url);
- biji_perform_update_async_and_free (query, afterward, user_data);
+ biji_perform_update_async_and_free (get_connection (biji_item_get_book (coll)), query, afterward,
user_data);
g_free (url);
}
@@ -583,36 +565,46 @@ biji_remove_collection_from_note (BijiNoteObj *note,
void
biji_note_delete_from_tracker (BijiNoteObj *note)
{
+ BijiItem *item;
gchar *query;
+ const gchar *uuid;
+ BijiNoteBook *book;
- query = g_strdup_printf ("DELETE { <%s> a rdfs:Resource }",
- biji_item_get_uuid (BIJI_ITEM (note)));
-
- biji_perform_update_async_and_free (query, NULL, NULL);
+ item = BIJI_ITEM (note);
+ book = biji_item_get_book (item);
+ uuid = biji_item_get_uuid (item);
+ query = g_strdup_printf ("DELETE { <%s> a rdfs:Resource }", uuid);
+ biji_perform_update_async_and_free (get_connection (book), query, NULL, NULL);
}
void
bijiben_push_note_to_tracker (BijiNoteObj *note)
{
- gchar *title,*content,*file,*date, *create_date,*last_change_date;
+ gchar *title,*content,*file, *date, *create_date,*last_change_date;
const gchar *path;
+ GTimeVal time = {0, 0};
+ BijiItem *item;
g_return_if_fail (BIJI_IS_NOTE_OBJ (note));
- path = biji_item_get_uuid (BIJI_ITEM (note));
- title = tracker_str (biji_item_get_title (BIJI_ITEM (note)));
+ item = BIJI_ITEM (note);
+ path = biji_item_get_uuid (item);
+ title = tracker_str (biji_item_get_title (item));
file = get_note_url (note);
- date = biji_note_obj_get_create_date (note);
+ time.tv_sec = biji_note_obj_get_create_date (note) / G_USEC_PER_SEC;
+ date = g_time_val_to_iso8601 (&time);
create_date = to_8601_date (date);
g_free (date);
- date = biji_note_obj_get_last_change_date (note);
+
+ time.tv_sec = biji_note_obj_get_create_date (note) / G_USEC_PER_SEC;
+ date = g_time_val_to_iso8601 (&time);
last_change_date = to_8601_date (date);
g_free (date);
- content = tracker_str (biji_note_get_raw_text (note));
+ content = tracker_str (biji_note_obj_get_raw_text (note));
/* TODO : nie:mimeType Note ;
* All these properties are unique and thus can be "updated"
@@ -632,7 +624,7 @@ bijiben_push_note_to_tracker (BijiNoteObj *note)
title,
content) ;
- biji_perform_update_async_and_free (query, NULL, NULL);
+ biji_perform_update_async_and_free (get_connection (biji_item_get_book (item)), query, NULL, NULL);
g_free(title);
g_free(file);
@@ -641,3 +633,330 @@ bijiben_push_note_to_tracker (BijiNoteObj *note)
g_free(last_change_date);
}
+
+void
+biji_tracker_trash_ressource (BijiNoteBook *book,
+ gchar *tracker_urn)
+{
+ gchar *query;
+
+ query = g_strdup_printf ("DELETE { <%s> a rdfs:Resource }", tracker_urn);
+ biji_perform_update_async_and_free (get_connection (book), query, NULL, NULL);
+}
+
+
+static void
+update_ressource (BijiTrackerFinisher *finisher, gchar *tracker_urn_uuid )
+{
+ BijiNoteBook *book;
+ BijiInfoSet *info;
+ gchar *query, *created, *mtime, *content;
+ GTimeVal t;
+
+ book = finisher->book;
+ info = finisher->info;
+
+ t.tv_usec = 0;
+ t.tv_sec = info->mtime;
+ mtime = g_time_val_to_iso8601 (&t);
+ t.tv_sec = info->created;
+ created = g_time_val_to_iso8601 (&t);
+ content = tracker_str (info->content);
+
+ g_warning ("ENSURE RESSOURCE: *UPDATING* ressource:%s:%s", info->title, tracker_urn_uuid);
+
+ query = g_strdup_printf (
+ "INSERT OR REPLACE { <%s> a nfo:Note , nie:DataObject ; "
+ "nie:url '%s' ; "
+ "nie:contentLastModified '%s' ; "
+ "nie:contentCreated '%s' ; "
+ "nie:title '%s' ; "
+ "nie:plainTextContent '%s' ; "
+ "nie:dataSource '%s' ;"
+ "nie:generator 'Bijiben' . }",
+ tracker_urn_uuid,
+ info->url,
+ mtime,
+ created,
+ info->title,
+ content,
+ info->datasource_urn);
+
+ biji_perform_update_async_and_free (get_connection (book), query, NULL, NULL);
+
+ g_free (tracker_urn_uuid);
+ g_free (mtime);
+ g_free (created);
+ g_free (content);
+ biji_tracker_finisher_free (finisher);
+}
+
+
+static void
+push_new_note (BijiTrackerFinisher *finisher)
+{
+ BijiNoteBook *book;
+ BijiInfoSet *info;
+ gchar *query, *content, *created_time, *modified_time;
+ GTimeVal t;
+
+ book = finisher->book;
+ info = finisher->info;
+ g_warning ("ENSURE RESSOURCE: pushing *NEW* ressource...");
+
+ content = tracker_str (info->content);
+ t.tv_usec = 0;
+ t.tv_sec = info->mtime;
+ modified_time = g_time_val_to_iso8601 (&t);
+ t.tv_sec = info->created;
+ created_time = g_time_val_to_iso8601 (&t);
+
+
+ query = g_strconcat (
+ "INSERT { _:res a nfo:Note ; ",
+ " a nie:DataObject ; ",
+ " nie:contentLastModified '", modified_time, "' ;",
+ " nie:contentCreated '", created_time, "' ;",
+ " nie:title '", info->title, "' ;",
+ " nie:url '", info->url, "' ;",
+ " nie:plainTextContent '", content, "' ;",
+ " nie:dataSource '", info->datasource_urn, "' ;",
+ " nie:generator 'Bijiben' }",
+ NULL);
+
+
+ tracker_sparql_connection_update_blank_async (get_connection (book),
+ query,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ NULL, // callback,
+ NULL); // user_data);
+
+
+ g_free (query);
+ g_free (content);
+ g_clear_pointer (&modified_time, g_free);
+ g_clear_pointer (&created_time, g_free);
+ biji_tracker_finisher_free (finisher);
+}
+
+
+static void
+ensure_ressource_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ TrackerSparqlConnection *connection;
+ TrackerSparqlCursor *cursor;
+ BijiTrackerFinisher *finisher;
+ GError *error;
+ gchar *urn_found;
+
+
+ connection = TRACKER_SPARQL_CONNECTION (source_object);
+ finisher = user_data;
+ error = NULL;
+ urn_found = NULL;
+ cursor = tracker_sparql_connection_query_finish (connection, res, &error);
+
+ if (error)
+ {
+ g_warning ("ENSURE RESSOURCE : error %s", error->message);
+ g_error_free (error);
+ biji_tracker_finisher_free (finisher);
+ return;
+ }
+
+ /* Queried ressource found into tracker */
+
+ if (cursor)
+ {
+
+ if (tracker_sparql_cursor_next (cursor, NULL, NULL))
+ urn_found = g_strdup (tracker_sparql_cursor_get_string (cursor, 0, NULL));
+
+ g_object_unref (cursor);
+ }
+
+
+ if (urn_found != NULL)
+ update_ressource (finisher, urn_found);
+
+ else
+ push_new_note (finisher);
+}
+
+
+
+void
+biji_tracker_ensure_ressource_from_info (BijiNoteBook *book,
+ BijiInfoSet *info)
+{
+ gchar *query;
+ BijiTrackerFinisher *finisher;
+
+
+ query = g_strconcat (
+ "SELECT ?urn ?time WHERE { ?urn a nfo:Note ;",
+ " nie:title ?title ;",
+ " nie:contentLastModified ?time ;",
+ " nie:url '", info->url, "' }",
+ NULL);
+
+
+ /* No matter user callback or not,
+ * we'll need our own to push if needed */
+
+ finisher = biji_tracker_finisher_new (
+ book,
+ NULL,
+ info,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL); // user_data);
+
+ tracker_sparql_connection_query_async (
+ get_connection (book), query, NULL, ensure_ressource_callback, finisher);
+}
+
+
+
+
+
+void
+biji_tracker_ensure_datasource (BijiNoteBook *book,
+ gchar *datasource,
+ gchar *identifier,
+ BijiBoolCallback cb,
+ gpointer user_data)
+{
+ gchar *query;
+
+
+ query = g_strdup_printf (
+ "INSERT OR REPLACE INTO <%s> {"
+ " <%s> a nie:DataSource ; nao:identifier \"%s\" }",
+ datasource,
+ datasource,
+ identifier);
+
+ biji_perform_update_async_and_free (
+ get_connection (book), query, cb, user_data);
+}
+
+
+
+static void
+on_info_queried (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ TrackerSparqlConnection *connection;
+ TrackerSparqlCursor *cursor;
+ BijiTrackerFinisher *finisher;
+ GError *error;
+ BijiInfoSet *retval;
+ GTimeVal t;
+
+
+ connection = TRACKER_SPARQL_CONNECTION (source_object);
+ finisher = user_data;
+ error = NULL;
+ retval = NULL;
+ cursor = tracker_sparql_connection_query_finish (connection, res, &error);
+
+ if (error)
+ {
+ g_warning ("Check for Info : error %s", error->message);
+ g_error_free (error);
+ biji_tracker_finisher_free (finisher);
+ return;
+ }
+
+ /* Queried ressource found into tracker */
+ if (cursor)
+ {
+ if (tracker_sparql_cursor_next (cursor, NULL, NULL))
+ {
+ retval = biji_info_set_new ();
+
+ retval->url = g_strdup (tracker_sparql_cursor_get_string (cursor, 0, NULL));
+ retval->title = g_strdup (tracker_sparql_cursor_get_string (cursor, 1, NULL));
+
+ if (g_time_val_from_iso8601 (tracker_sparql_cursor_get_string (cursor, 2, NULL), &t))
+ retval->mtime = t.tv_sec;
+
+ retval->content = biji_str_replace (
+ tracker_sparql_cursor_get_string (cursor, 3, NULL), "b<br/>", "\n");
+
+ if (g_time_val_from_iso8601 (tracker_sparql_cursor_get_string (cursor, 4, NULL), &t))
+ retval->created = t.tv_sec;
+
+
+ /* Check if the ressource is up to date */
+
+ if (finisher->info->mtime != retval->mtime)
+ g_clear_pointer (&retval, biji_info_set_free);
+ }
+
+ g_object_unref (cursor);
+ }
+
+
+ /* No matter retval or not, we are supposed to callback
+ * (REMEMBER CALLER IS RESPONSIBLE FOR FREEING INFO SET) */
+ if (finisher->info_cb != NULL)
+ finisher->info_cb (retval, finisher->user_data);
+
+
+ biji_tracker_finisher_free (finisher);
+}
+
+
+void
+biji_tracker_check_for_info (BijiNoteBook *book,
+ gchar *url,
+ gint64 mtime,
+ BijiInfoCallback callback,
+ gpointer user_data)
+{
+ BijiInfoSet *info;
+ BijiTrackerFinisher *finisher;
+ gchar *query;
+
+ query = g_strconcat (
+ " SELECT ?urn ?title ?time ?content ?created",
+ " WHERE { ?urn a nfo:Note ;",
+ " nie:title ?title ;",
+ " nie:contentLastModified ?time ;",
+ " nie:plainTextContent ?content ;",
+ " nie:contentCreated ?created ;",
+ " nie:url '", url, "' }",
+ NULL);
+
+ /* No matter user callback or not,
+ * we'll need our own to push if needed */
+ info = biji_info_set_new ();
+ info->url = url;
+ info->mtime = mtime;
+
+ finisher = biji_tracker_finisher_new (
+ book,
+ NULL,
+ info,
+ NULL,
+ callback,
+ NULL,
+ NULL,
+ NULL,
+ user_data);
+
+ tracker_sparql_connection_query_async (
+ get_connection (book), query, NULL, on_info_queried, finisher);
+
+
+ g_free (query);
+}
diff --git a/src/libbiji/biji-tracker.h b/src/libbiji/biji-tracker.h
index 179cefa..2037a63 100644
--- a/src/libbiji/biji-tracker.h
+++ b/src/libbiji/biji-tracker.h
@@ -23,20 +23,11 @@
#include <tracker-sparql.h>
#include "libbiji.h"
-
-
-
-typedef struct
-{
- gchar *urn;
- gchar *title;
- gchar *mtime;
-
-} BijiTrackerInfoSet;
+#include "biji-info-set.h"
/* All possible query return
- * Free the containers for list & hash */
+ * Free the containers for list & hash<BijiInfoSets> */
typedef void (*BijiBoolCallback) (gboolean result, gpointer user_data);
@@ -51,6 +42,11 @@ typedef void (*BijiItemsListCallback) (GList *items, gpointer user_dat
typedef void (*BijiInfoSetsHCallback) (GHashTable *info_sets, gpointer user_data);
+/* CALLER IS RESPONSIBLE FOR FREEING INFO SET */
+
+typedef void (*BijiInfoCallback) (BijiInfoSet *info, gpointer user_data);
+
+
void biji_get_items_with_collection_async (BijiNoteBook *book,
const gchar *needle,
@@ -78,7 +74,8 @@ void biji_create_new_collection_async (BijiNoteBook *book,
-void biji_remove_collection_from_tracker (const gchar *urn);
+void biji_remove_collection_from_tracker (BijiNoteBook *book,
+ const gchar *urn);
@@ -96,14 +93,31 @@ void biji_remove_collection_from_note (BijiNoteObj *note,
gpointer user_data);
- /* Either insert or update */
-
void bijiben_push_note_to_tracker (BijiNoteObj *note);
-
void biji_note_delete_from_tracker (BijiNoteObj *note);
+void biji_tracker_trash_ressource (BijiNoteBook *book,
+ gchar *tracker_urn);
+
+
+void biji_tracker_ensure_ressource_from_info (BijiNoteBook *book,
+ BijiInfoSet *info);
+
+
+void biji_tracker_ensure_datasource (BijiNoteBook *book,
+ gchar *datasource_id,
+ gchar *identifier,
+ BijiBoolCallback cb,
+ gpointer user_data);
+
+
+void biji_tracker_check_for_info (BijiNoteBook *book,
+ gchar *url,
+ gint64 mtime,
+ BijiInfoCallback callback,
+ gpointer user_data);
#endif /*_BIJI_TRACKER_H*/
diff --git a/src/libbiji/deserializer/biji-lazy-deserializer.c
b/src/libbiji/deserializer/biji-lazy-deserializer.c
index 09dbd9f..71eb36c 100644
--- a/src/libbiji/deserializer/biji-lazy-deserializer.c
+++ b/src/libbiji/deserializer/biji-lazy-deserializer.c
@@ -161,6 +161,17 @@ biji_lazy_deserializer_class_init (BijiLazyDeserializerClass *klass)
typedef void BijiReaderFunc (BijiNoteObj *note, gchar *string);
+
+static gint64
+str_to_gint64 (xmlChar *str)
+{
+ GTimeVal time = {0,0};
+
+ g_time_val_from_iso8601 ((gchar*) str, &time);
+ return (gint64) time.tv_sec;
+}
+
+
static void
biji_process_string (xmlTextReaderPtr reader,
BijiReaderFunc process_xml,
@@ -171,6 +182,8 @@ biji_process_string (xmlTextReaderPtr reader,
free (result);
}
+
+
/* Tomboy Inner XML */
static void
@@ -306,7 +319,7 @@ process_tomboy_xml_content (BijiLazyDeserializer *self)
biji_note_obj_set_raw_text (priv->note, priv->raw_text->str);
revamped_html = biji_str_replace (priv->html->str, "\n", "<br/>");
- biji_note_obj_set_html_content (priv->note, revamped_html);
+ biji_note_obj_set_html (priv->note, revamped_html);
g_free (revamped_html);
}
@@ -420,7 +433,7 @@ process_bijiben_html_content (BijiLazyDeserializer *self,
}
biji_note_obj_set_raw_text (priv->note, priv->raw_text->str);
- biji_note_obj_set_html_content (priv->note, sane_html);
+ biji_note_obj_set_html (priv->note, sane_html);
xmlFree (BAD_CAST sane_html);
}
@@ -458,13 +471,25 @@ processNode (BijiLazyDeserializer *self)
}
if (g_strcmp0 ((gchar*) name, "last-change-date") == 0)
- biji_process_string (r, (BijiReaderFunc*) biji_note_obj_set_last_change_date, n);
+ {
+ xmlChar *result = xmlTextReaderReadString (r);
+ biji_note_obj_set_mtime (n, str_to_gint64 (result));
+ free (result);
+ }
if (g_strcmp0 ((gchar*) name, "last-metadata-change-date") == 0)
- biji_process_string (r, (BijiReaderFunc*) biji_note_obj_set_last_metadata_change_date, n);
+ {
+ xmlChar *result = xmlTextReaderReadString (r);
+ biji_note_obj_set_last_metadata_change_date (n, str_to_gint64 (result));
+ free (result);
+ }
if (g_strcmp0 ((gchar*) name, "create-date") == 0)
- biji_process_string (r, (BijiReaderFunc*) biji_note_obj_set_create_date, n);
+ {
+ xmlChar *result = xmlTextReaderReadString (r);
+ biji_note_obj_set_create_date (n, str_to_gint64 (result));
+ free (result);
+ }
if (g_strcmp0 ((gchar*) name, "color") == 0 )
{
diff --git a/src/libbiji/editor/biji-webkit-editor.c b/src/libbiji/editor/biji-webkit-editor.c
index d1eb731..efc7045 100644
--- a/src/libbiji/editor/biji-webkit-editor.c
+++ b/src/libbiji/editor/biji-webkit-editor.c
@@ -253,7 +253,7 @@ on_content_changed (WebKitWebView *view)
html = webkit_dom_html_element_get_outer_html (elem);
text = webkit_dom_html_element_get_inner_text (elem);
- biji_note_obj_set_html_content (note, html);
+ biji_note_obj_set_html (note, html);
biji_note_obj_set_raw_text (note, text);
/* Now tries to update title if new note
@@ -272,7 +272,7 @@ on_content_changed (WebKitWebView *view)
char *unique_title;
title = rows[0];
- unique_title = biji_note_book_get_unique_title (biji_note_obj_get_note_book (note),
+ unique_title = biji_note_book_get_unique_title (biji_item_get_book (BIJI_ITEM (note)),
title);
biji_note_obj_set_title (note, unique_title);
@@ -285,7 +285,7 @@ on_content_changed (WebKitWebView *view)
g_free (html);
g_free (text);
- biji_note_obj_set_last_change_date_now (note);
+ biji_note_obj_set_mtime (note, g_get_real_time () / G_USEC_PER_SEC);
biji_note_obj_save_note (note);
}
@@ -312,6 +312,7 @@ biji_webkit_editor_constructed (GObject *obj)
priv = self->priv;
body = biji_note_obj_get_html (priv->note);
+
if (!body)
body = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><body></body></html>";
diff --git a/src/libbiji/libbiji.h b/src/libbiji/libbiji.h
index 1401508..3f04784 100644
--- a/src/libbiji/libbiji.h
+++ b/src/libbiji/libbiji.h
@@ -20,6 +20,7 @@
#define _LIBBIJI_INSIDE_H
+
#include "biji-collection.h"
#include "biji-date-time.h"
#include "biji-item.h"
diff --git a/src/libbiji/provider/Makefile.am b/src/libbiji/provider/Makefile.am
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/src/libbiji/provider/Makefile.am
@@ -0,0 +1 @@
+
diff --git a/src/libbiji/provider/biji-own-cloud-note.c b/src/libbiji/provider/biji-own-cloud-note.c
new file mode 100644
index 0000000..997350b
--- /dev/null
+++ b/src/libbiji/provider/biji-own-cloud-note.c
@@ -0,0 +1,288 @@
+/* bjb-own-cloud-note.c
+ * Copyright (C) Pierre-Yves LUYTEN 2013 <py luyten fr>
+ *
+ * bijiben is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * bijiben is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "biji-info-set.h"
+#include "biji-item.h"
+#include "biji-own-cloud-note.h"
+#include "biji-own-cloud-provider.h"
+
+
+
+struct BijiOwnCloudNotePrivate_
+{
+ BijiOwnCloudProvider *prov;
+ BijiNoteID *id;
+
+ gchar *html;
+ GFile *location;
+ gchar *basename;
+ GCancellable *cancellable; //TODO cancel write to file
+};
+
+
+
+G_DEFINE_TYPE (BijiOwnCloudNote, biji_own_cloud_note, BIJI_TYPE_NOTE_OBJ)
+
+
+static gchar *
+ocloud_note_get_html (BijiNoteObj *note)
+{
+ g_return_val_if_fail (BIJI_IS_OWN_CLOUD_NOTE (note), NULL);
+
+ return BIJI_OWN_CLOUD_NOTE (note)->priv->html;
+}
+
+
+static void
+ocloud_note_set_html (BijiNoteObj *note,
+ gchar *html)
+{
+ BIJI_OWN_CLOUD_NOTE (note)->priv->html = g_strdup (html);
+}
+
+
+/* we definitely need to be sure we push to tracker
+ * the exact same mtime as reported by GFile
+ * the real fix is to set mtime when save happens.. */
+
+static void
+ocloud_note_ensure_ressource (BijiNoteObj *note)
+{
+ BijiInfoSet *info;
+ BijiItem *item;
+ BijiOwnCloudNote *ocnote;
+ GFile *file;
+ GFileInfo *file_info;
+
+ g_return_if_fail (BIJI_IS_OWN_CLOUD_NOTE (note));
+ item = BIJI_ITEM (note);
+ ocnote = BIJI_OWN_CLOUD_NOTE (note);
+ file = ocnote->priv->location;
+ file_info = g_file_query_info (file, "time::modified", G_FILE_QUERY_INFO_NONE, NULL, NULL);
+
+ info = biji_info_set_new ();
+ info->url = (gchar*) biji_item_get_uuid (item);
+ info->title = (gchar*) biji_item_get_title (item);
+ info->content = (gchar*) biji_note_obj_get_raw_text (note);
+ //info->mtime = biji_item_get_mtime (item);
+ info->mtime = g_file_info_get_attribute_uint64 (file_info, "time::modified");
+ info->created = biji_note_obj_get_create_date (note);
+ info->datasource_urn = g_strdup (
+ BIJI_PROVIDER_GET_CLASS (ocnote->priv->prov)->get_datasource (BIJI_PROVIDER (ocnote->priv->prov)));
+
+ biji_tracker_ensure_ressource_from_info (biji_item_get_book (item),
+ info);
+}
+
+
+/* Notes creation as soon as files content retrieved */
+static void
+on_content_change (gpointer user_data)
+{
+ BijiNoteObj *note;
+ gchar *html;
+
+ g_return_if_fail (BIJI_IS_OWN_CLOUD_NOTE (user_data));
+ note = user_data;
+
+ html = html_from_plain_text ((gchar*) biji_note_obj_get_raw_text (user_data));
+
+ ocloud_note_set_html (note, html);
+ g_free (html);
+}
+
+
+/* TODO: propagate error if any
+ * through generic provider -> book */
+void
+on_content_replaced (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error = NULL;
+
+ if (!g_file_replace_contents_finish (G_FILE (source_object),
+ res,
+ NULL, //etag
+ &error))
+ {
+ if (error)
+ {
+ g_warning ("ownCloud note not saved. %s", error->message);
+ g_error_free (error);
+ }
+ }
+
+
+ else
+ {
+ ocloud_note_ensure_ressource (user_data);
+ }
+}
+
+
+
+void
+ocloud_note_save (BijiNoteObj *note)
+{
+ BijiOwnCloudNote *self;
+ GString *str;
+
+ g_return_if_fail (BIJI_IS_OWN_CLOUD_NOTE (note));
+ self = BIJI_OWN_CLOUD_NOTE (note);
+ str = g_string_new (biji_note_obj_get_raw_text (note));
+
+ /* backup would fail for some reason.
+ * gfilemove for workaround? */
+ g_file_replace_contents_async (
+ self->priv->location,
+ str->str,
+ str->len,
+ NULL, // etag
+ FALSE, //backup
+ G_FILE_CREATE_REPLACE_DESTINATION,
+ self->priv->cancellable,
+ on_content_replaced,
+ self);
+
+
+ g_string_free (str, FALSE);
+}
+
+
+
+static void
+biji_own_cloud_note_finalize (GObject *object)
+{
+ BijiOwnCloudNote *self;
+
+ g_return_if_fail (BIJI_IS_OWN_CLOUD_NOTE (object));
+
+ self = BIJI_OWN_CLOUD_NOTE (object);
+ g_free (self->priv->html);
+ g_object_unref (self->priv->cancellable);
+ G_OBJECT_CLASS (biji_own_cloud_note_parent_class)->finalize (object);
+}
+
+
+static void
+biji_own_cloud_note_constructed (GObject *object)
+{
+ g_return_if_fail (BIJI_IS_OWN_CLOUD_NOTE (object));
+
+ G_OBJECT_CLASS (biji_own_cloud_note_parent_class)->constructed (object);
+
+ on_content_change ((gpointer) object);
+}
+
+
+static void
+biji_own_cloud_note_init (BijiOwnCloudNote *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BIJI_TYPE_OWN_CLOUD_NOTE, BijiOwnCloudNotePrivate);
+ self->priv->cancellable = g_cancellable_new ();
+ self->priv->id = NULL;
+}
+
+
+static gboolean
+item_no (BijiItem * item)
+{
+ return FALSE;
+}
+
+
+static gboolean
+note_no (BijiNoteObj *item)
+{
+ return FALSE;
+}
+
+
+static gboolean
+ocloud_note_delete (BijiNoteObj *note)
+{
+ BijiOwnCloudNote *ocl;
+
+ ocl = BIJI_OWN_CLOUD_NOTE (note);
+ return g_file_delete (ocl->priv->location, NULL, NULL);
+}
+
+static gchar *
+ocloud_note_get_basename (BijiNoteObj *note)
+{
+ return BIJI_OWN_CLOUD_NOTE (note)->priv->basename;
+}
+
+
+static void
+biji_own_cloud_note_class_init (BijiOwnCloudNoteClass *klass)
+{
+ GObjectClass *g_object_class;
+ BijiItemClass *item_class;
+ BijiNoteObjClass *note_class;
+
+ g_object_class = G_OBJECT_CLASS (klass);
+ item_class = BIJI_ITEM_CLASS (klass);
+ note_class = BIJI_NOTE_OBJ_CLASS (klass);
+
+ g_object_class->finalize = biji_own_cloud_note_finalize;
+ g_object_class->constructed = biji_own_cloud_note_constructed;
+
+ item_class->is_collectable = item_no;
+ item_class->has_color = item_no;
+
+ note_class->get_basename = ocloud_note_get_basename;
+ note_class->get_html = ocloud_note_get_html;
+ note_class->set_html = ocloud_note_set_html;
+ note_class->save_note = ocloud_note_save;
+ note_class->can_format = note_no;
+ note_class->archive = ocloud_note_delete;
+
+ g_type_class_add_private ((gpointer)klass, sizeof (BijiOwnCloudNotePrivate));
+}
+
+
+BijiNoteObj *biji_own_cloud_note_new_from_info (BijiOwnCloudProvider *prov,
+ BijiNoteBook *book,
+ BijiInfoSet *info)
+{
+ BijiNoteID *id;
+ BijiNoteObj *retval;
+ BijiOwnCloudNote *ocloud;
+
+ id = biji_note_id_new_from_info (info);
+
+ retval = g_object_new (BIJI_TYPE_OWN_CLOUD_NOTE,
+ "note-book", book,
+ "id", id,
+ NULL);
+
+ ocloud = BIJI_OWN_CLOUD_NOTE (retval);
+ ocloud->priv->id = id;
+ ocloud->priv->prov = prov;
+ biji_note_obj_set_create_date (retval, info->created);
+ g_signal_connect_swapped (id, "notify::content",
+ G_CALLBACK (on_content_change), retval);
+
+
+ ocloud->priv->location = g_file_new_for_commandline_arg (info->url);
+ ocloud->priv->basename = g_file_get_basename (ocloud->priv->location);
+
+ return retval;
+}
diff --git a/src/libbiji/provider/biji-own-cloud-note.h b/src/libbiji/provider/biji-own-cloud-note.h
new file mode 100644
index 0000000..ccad0de
--- /dev/null
+++ b/src/libbiji/provider/biji-own-cloud-note.h
@@ -0,0 +1,61 @@
+/* bjb-own-cloud-note.c
+ * Copyright (C) Pierre-Yves LUYTEN 2013 <py luyten fr>
+ *
+ * bijiben is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * bijiben is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BIJI_OWN_CLOUD_NOTE_H_
+#define BIJI_OWN_CLOUD_NOTE_H_ 1
+
+#include "../biji-note-obj.h"
+#include "../biji-note-id.h"
+
+#include "biji-own-cloud-provider.h"
+
+G_BEGIN_DECLS
+
+
+#define BIJI_TYPE_OWN_CLOUD_NOTE (biji_own_cloud_note_get_type ())
+#define BIJI_OWN_CLOUD_NOTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIJI_TYPE_OWN_CLOUD_NOTE,
BijiOwnCloudNote))
+#define BIJI_OWN_CLOUD_NOTE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIJI_TYPE_OWN_CLOUD_NOTE,
BijiOwnCloudNoteClass))
+#define BIJI_IS_OWN_CLOUD_NOTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIJI_TYPE_OWN_CLOUD_NOTE))
+#define BIJI_IS_OWN_CLOUD_NOTE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIJI_TYPE_OWN_CLOUD_NOTE))
+#define BIJI_OWN_CLOUD_NOTE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIJI_TYPE_OWN_CLOUD_NOTE,
BijiOwnCloudNoteClass))
+
+typedef struct BijiOwnCloudNote_ BijiOwnCloudNote;
+typedef struct BijiOwnCloudNoteClass_ BijiOwnCloudNoteClass;
+typedef struct BijiOwnCloudNotePrivate_ BijiOwnCloudNotePrivate;
+
+struct BijiOwnCloudNote_
+{
+ BijiNoteObj parent;
+ BijiOwnCloudNotePrivate *priv;
+};
+
+struct BijiOwnCloudNoteClass_
+{
+ BijiNoteObjClass parent_class;
+};
+
+
+GType biji_own_cloud_note_get_type (void);
+
+
+BijiNoteObj *biji_own_cloud_note_new_from_info (BijiOwnCloudProvider *prov,
+ BijiNoteBook *book,
+ BijiInfoSet *info);
+
+G_END_DECLS
+
+#endif /* BIJI_OWN_CLOUD_NOTE_H_ */
diff --git a/src/libbiji/provider/biji-own-cloud-provider.c b/src/libbiji/provider/biji-own-cloud-provider.c
new file mode 100644
index 0000000..b21da99
--- /dev/null
+++ b/src/libbiji/provider/biji-own-cloud-provider.c
@@ -0,0 +1,745 @@
+/* biji-own-cloud-provider.c
+ * Copyright (C) Pierre-Yves LUYTEN 2013 <py luyten fr>
+ *
+ * bijiben is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * bijiben is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/*
+ * ownCloud does not have collections
+ * neither colors
+ * nor formating (but markdown could be used or even translated upstream
+ * on web app
+ */
+
+
+#include "biji-own-cloud-note.h"
+#include "biji-own-cloud-provider.h"
+
+
+#define MINER_ID "gn:ownc:miner:96df9bc8-f542-427f-aa19-77b5a2c9a5f0"
+
+
+
+static void get_mount (BijiOwnCloudProvider *self);
+
+/* Properties */
+enum {
+ PROP_0,
+ PROP_BOOK,
+ PROP_GOA_OBJECT,
+ OCLOUD_PROV_PROP
+};
+
+
+/* Signals */
+enum {
+ OCLOUD_PROV_LOADED,
+ OCLOUD_PROV_SIGNALS
+};
+
+
+static guint biji_ocloud_provider_signals[OCLOUD_PROV_SIGNALS] = { 0 };
+static GParamSpec *properties[OCLOUD_PROV_PROP] = { NULL, };
+
+
+struct BijiOwnCloudProviderPrivate_
+{
+ BijiNoteBook *book;
+ GoaObject *object;
+ GoaAccount *account;
+ gchar *identifier;
+
+ GHashTable *notes;
+ GHashTable *tracker;
+ GQueue *queue;
+
+ GVolume *volume;
+ GMount *mount;
+ GFile *folder;
+
+ GFileMonitor *monitor;
+ GCancellable *cancel_monitor;
+};
+
+
+G_DEFINE_TYPE (BijiOwnCloudProvider, biji_own_cloud_provider, BIJI_TYPE_PROVIDER)
+
+typedef struct
+{
+ GFile *file;
+ BijiOwnCloudProvider *self;
+
+ BijiInfoSet set;
+} BijiOCloudItem;
+
+
+static BijiOCloudItem *
+o_cloud_item_new (BijiOwnCloudProvider *self)
+{
+ BijiOCloudItem *item;
+
+ item = g_slice_new (BijiOCloudItem);
+ item->file = NULL;
+ item->self = self;
+ item->set.content = NULL;
+ item->set.mtime = 0;
+ item->set.created= 0;
+ item->set.title = NULL;
+ item->set.url = NULL;
+
+ return item;
+}
+
+
+static void
+o_cloud_item_free (BijiOCloudItem *item)
+{
+ g_object_unref (item->file);
+ g_free (item->set.content);
+ g_free (item->set.url);
+ g_free (item->set.title);
+
+ g_slice_free (BijiOCloudItem, item);
+}
+
+
+
+
+static void
+biji_own_cloud_provider_finalize (GObject *object)
+{
+ BijiOwnCloudProvider *self;
+
+ g_return_if_fail (BIJI_IS_OWN_CLOUD_PROVIDER (object));
+ self = BIJI_OWN_CLOUD_PROVIDER (object);
+
+ g_free (self->priv->identifier);
+ g_object_unref (self->priv->account);
+ g_object_unref (self->priv->object);
+
+ G_OBJECT_CLASS (biji_own_cloud_provider_parent_class)->finalize (object);
+}
+
+
+
+static void
+release_enum_cb (GObject *source, GAsyncResult *res, gpointer user_data)
+{
+ g_file_enumerator_close_finish (G_FILE_ENUMERATOR (source),
+ res,
+ NULL);
+ g_object_unref (source);
+}
+
+
+static void handle_next_item (BijiOwnCloudProvider *self);
+
+
+/* No color, hence we use default color */
+
+static void
+create_note_from_item (BijiOCloudItem *item)
+{
+ BijiNoteObj *note;
+ GdkRGBA color;
+
+ note = biji_own_cloud_note_new_from_info (item->self,
+ item->self->priv->book,
+ &item->set);
+ biji_note_book_get_default_color (item->self->priv->book, &color);
+ biji_note_obj_set_rgba (note, &color);
+ g_hash_table_replace (item->self->priv->notes,
+ item->set.url,
+ note);
+}
+
+
+static void
+on_content (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ BijiOCloudItem *item;
+ BijiOwnCloudProvider *self;
+ GFile *file;
+ GError *error;
+ gboolean ok;
+ gchar *contents;
+ gsize length;
+
+ file = G_FILE (source);
+ item = user_data;
+ self = item->self;
+ error = NULL;
+ length = 0;
+
+ ok = g_file_load_contents_finish (file,
+ res,
+ &contents,
+ &length,
+ NULL,
+ &error);
+
+ if (!ok)
+ {
+ if (error)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ o_cloud_item_free (item);
+ }
+
+ /*
+ * File has been read, both create the note
+ * then update db
+ */
+
+ else
+ {
+ item->set.content = contents;
+ create_note_from_item (item);
+ biji_tracker_ensure_ressource_from_info (self->priv->book, &item->set);
+
+ // TODO --> ensure_ressource callback.... o_cloud_item_free (item);
+ }
+
+ handle_next_item (self);
+}
+
+
+
+/*
+ * If the tracker db is up to date it provides the Info.
+ * Otherwise the file is more recent than tracker :
+ * do it the hard way
+ *
+ * but ownCloud mtime are not reliable so this does not work well.
+ * editing file changes mtime. Not editing from Notes...
+ *
+ */
+
+static void
+check_info_maybe_read_file (BijiInfoSet *info,
+ gpointer user_data)
+{
+ BijiOCloudItem *item;
+ BijiOwnCloudProvider *self;
+
+ item = user_data;
+ self = item->self;
+
+
+ /* Create the note from cache (tracker store)
+ * My escape char for plainTextContent are buggy */
+
+ if (info != NULL)
+ {
+ item->set.content = g_strdup (info->content);
+ item->set.created = info->created;
+ create_note_from_item (item);
+ o_cloud_item_free (item);
+ biji_info_set_free (info);
+ handle_next_item (self);
+ }
+
+
+ /* Store not up to date. We need to read the file */
+
+ else
+ {
+ g_file_load_contents_async (item->file, NULL, on_content, item);
+ }
+
+}
+
+
+static void
+trash (gpointer urn_uuid, gpointer self)
+{
+ biji_tracker_trash_ressource (
+ BIJI_OWN_CLOUD_PROVIDER (self)->priv->book, (gchar*) urn_uuid);
+}
+
+
+
+static void
+handle_next_item (BijiOwnCloudProvider *self)
+{
+ BijiOCloudItem *item;
+ GList *list;
+
+ item = g_queue_pop_head (self->priv->queue);
+
+ if (item != NULL)
+ {
+ g_hash_table_remove (self->priv->tracker, item->set.url);
+
+ biji_tracker_check_for_info (self->priv->book,
+ item->set.url,
+ item->set.mtime,
+ check_info_maybe_read_file,
+ item);
+ }
+
+
+ else
+ {
+ /* Post load tracker db clean-up */
+ list = g_hash_table_get_values (self->priv->tracker);
+ g_list_foreach (list, trash, self);
+ g_list_free (list);
+
+
+ /* Now simply provide data to controller */
+ list = g_hash_table_get_values (self->priv->notes);
+ g_warning ("emiting");
+ g_signal_emit (G_OBJECT (self),
+ biji_ocloud_provider_signals[OCLOUD_PROV_LOADED],
+ 0,
+ list);
+
+ g_list_free (list);
+ }
+}
+
+
+static void
+enumerate_next_files_ready_cb (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GFileEnumerator *enumerator;
+ GError *error;
+ BijiOwnCloudProvider *self;
+ GList *files, *l;
+
+ g_return_if_fail (BIJI_IS_OWN_CLOUD_PROVIDER (user_data));
+
+ enumerator = G_FILE_ENUMERATOR (source);
+ error = NULL;
+ self = BIJI_OWN_CLOUD_PROVIDER (user_data);
+
+ files = g_file_enumerator_next_files_finish (enumerator, res, &error);
+ g_file_enumerator_close_async (enumerator, G_PRIORITY_DEFAULT, NULL,
+ release_enum_cb, NULL);
+
+ if (error != NULL)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ /* Open the file, have a dedicated deserializer */
+ for (l = files; l != NULL; l = l->next)
+ {
+ GFileInfo *info;
+ GTimeVal time = {0,0};
+ BijiOCloudItem *item;
+
+ info = l->data;
+ item = o_cloud_item_new (self);
+ item->set.title = g_strdup (g_file_info_get_name (info));
+ item->set.url = g_strconcat
+ (g_file_get_parse_name (self->priv->folder),
+ "/", item->set.title, NULL);
+
+ g_file_info_get_modification_time (info, &time);
+ item->set.mtime = time.tv_sec;
+ item->set.created = g_file_info_get_attribute_uint64 (info, "time:created");
+ item->set.datasource_urn = g_strdup (self->priv->identifier);
+ item->file = g_file_new_for_uri (item->set.url);
+ g_queue_push_head (self->priv->queue, item);
+ }
+
+ // TODO - create the dir monitor
+ handle_next_item (self);
+ g_list_free_full (files, g_object_unref);
+}
+
+
+
+
+
+static void
+enumerate_children_ready_cb (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GFile *location;
+ GFileEnumerator *enumerator;
+ GError *error;
+ BijiOwnCloudProvider *self;
+
+ g_return_if_fail (BIJI_IS_OWN_CLOUD_PROVIDER (user_data));
+
+ error = NULL;
+ location = G_FILE (source);
+ self = BIJI_OWN_CLOUD_PROVIDER (user_data);
+ enumerator = g_file_enumerate_children_finish (location, res, &error);
+
+ if (error != NULL)
+ {
+ g_warning ("could not enumerate... %s", error->message);
+ g_error_free (error);
+
+ /* TODO : nice place to reset everything
+ * and start again with fresh air ?
+ * but we don't want to umount for the user */
+ return;
+ }
+
+ g_file_enumerator_next_files_async (enumerator, G_MAXINT,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ enumerate_next_files_ready_cb,
+ self);
+}
+
+
+/* Stock all existing urn-uuid. Then parse files */
+static void
+on_notes_mined (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ BijiOwnCloudProvider *self;
+ TrackerSparqlConnection *connect;
+ TrackerSparqlCursor *cursor;
+ GError *error;
+
+ self = user_data;
+ connect = TRACKER_SPARQL_CONNECTION (source_object);
+ error = NULL;
+ cursor = tracker_sparql_connection_query_finish (connect, res, &error);
+
+ if (error)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ if (cursor)
+ {
+ while (tracker_sparql_cursor_next (cursor, NULL, NULL))
+ {
+ g_hash_table_insert (self->priv->tracker,
+ g_strdup (tracker_sparql_cursor_get_string (cursor, 0, NULL)),
+ g_strdup (tracker_sparql_cursor_get_string (cursor, 1, NULL)));
+
+ }
+ }
+
+ g_file_enumerate_children_async (self->priv->folder,
+ "standard::name,time::modified,time::created", 0,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ enumerate_children_ready_cb,
+ self);
+}
+
+
+/* TODO use datasource so func is somewhat std:: */
+static void
+mine_notes (gboolean result, gpointer user_data)
+{
+ BijiOwnCloudProvider *self;
+ const gchar *root;
+ gchar *query;
+
+
+ self = user_data;
+ root = goa_files_get_uri (goa_object_peek_files (self->priv->object));
+
+ /*
+ * We could as well use nie:url to lookup existing db
+ * but rather use dataSource since this might go to generic bProvider
+ *
+ * query = g_strdup_printf ("SELECT ?urn ?url WHERE {?urn a nfo:Note ; "
+ "nie:url ?url . FILTER ("
+ "fn:contains (?url,'%s'))}",
+ root);
+ *
+ */
+
+ query = g_strdup_printf ("SELECT ?url ?urn WHERE {?urn a nfo:Note; "
+ " nie:dataSource '%s' ; nie:url ?url}",
+ BIJI_PROVIDER_GET_CLASS (self)->get_datasource (BIJI_PROVIDER (self)));
+
+ tracker_sparql_connection_query_async (
+ biji_note_book_get_tracker_connection (self->priv->book),
+ query,
+ NULL,
+ on_notes_mined,
+ self);
+
+ g_free (query);
+}
+
+
+
+static void
+handle_mount (BijiOwnCloudProvider *self)
+{
+ GFile *root;
+
+ root = NULL;
+ if (G_IS_MOUNT (self->priv->mount))
+ root = g_mount_get_root (self->priv->mount);
+
+
+ if (G_IS_FILE (root))
+ {
+ /* OwnCloud Notes folder is not localized.
+ * https://github.com/owncloud/notes/issues/7 */
+
+ self->priv->folder = g_file_get_child (root, "Notes");
+ self->priv->monitor = g_file_monitor_directory
+ (self->priv->folder, G_FILE_MONITOR_NONE, NULL, NULL); // cancel, error
+
+
+ g_object_unref (root);
+ biji_tracker_ensure_datasource (self->priv->book,
+ self->priv->identifier,
+ MINER_ID,
+ mine_notes,
+ self);
+ }
+}
+
+
+
+static void
+on_owncloud_volume_mounted (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ BijiOwnCloudProvider *self;
+ GError *error;
+
+ self = BIJI_OWN_CLOUD_PROVIDER (user_data);
+
+ /* bug #701021 makes this fail */
+
+ if (!g_volume_mount_finish (self->priv->volume, res, &error))
+ {
+ if (error != NULL)
+ {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+ return;
+ }
+
+ self->priv->mount = g_volume_get_mount (self->priv->volume);
+
+ if (!G_IS_MOUNT (self->priv->mount))
+ {
+ g_warning ("finish but not really finish...");
+ get_mount (self);
+ }
+
+ else
+ handle_mount (self);
+}
+
+
+static void
+get_mount (BijiOwnCloudProvider *self)
+{
+ GVolumeMonitor *monitor;
+ GoaFiles *files;
+ const gchar *uri;
+
+ monitor = g_volume_monitor_get ();
+
+ if (!GOA_IS_OBJECT (self->priv->object))
+ return;
+
+ files = goa_object_peek_files (self->priv->object);
+
+ if (GOA_IS_FILES (files))
+ {
+ uri = goa_files_get_uri (files);
+ self->priv->volume = g_volume_monitor_get_volume_for_uuid (monitor, uri);
+ self->priv->mount = g_volume_get_mount (self->priv->volume);
+
+
+ if (self->priv->mount != NULL &&
+ G_IS_MOUNT (self->priv->mount))
+ {
+ handle_mount (self);
+ }
+
+
+ /* not already mounted. no matter, we mount. in theory. */
+ //else if (self->priv->mount == NULL)
+ else
+ {
+ g_volume_mount (self->priv->volume,
+ G_MOUNT_MOUNT_NONE,
+ NULL,
+ NULL,
+ on_owncloud_volume_mounted,
+ self);
+ }
+ }
+
+ g_object_unref (monitor);
+}
+
+
+static void
+biji_own_cloud_provider_constructed (GObject *obj)
+{
+ BijiOwnCloudProvider *self;
+
+ G_OBJECT_CLASS (biji_own_cloud_provider_parent_class)->constructed (obj);
+
+ self = BIJI_OWN_CLOUD_PROVIDER (obj);
+
+ if (!GOA_IS_OBJECT (self->priv->object))
+ return;
+
+ self->priv->account = goa_object_get_account (self->priv->object);
+
+ if (self->priv->account != NULL)
+ {
+ self->priv->identifier = g_strdup_printf ("gn:goa-account:%s",
+ goa_account_get_id (self->priv->account));
+ get_mount (self);
+ }
+}
+
+
+
+static void
+biji_own_cloud_provider_init (BijiOwnCloudProvider *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BIJI_TYPE_OWN_CLOUD_PROVIDER, BijiOwnCloudProviderPrivate);
+
+ self->priv->notes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ self->priv->tracker = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ self->priv->queue = g_queue_new ();
+}
+
+
+static void
+biji_own_cloud_provider_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ BijiOwnCloudProvider *self = BIJI_OWN_CLOUD_PROVIDER (object);
+
+
+ switch (property_id)
+ {
+ case PROP_BOOK:
+ self->priv->book = g_value_dup_object (value);
+ case PROP_GOA_OBJECT:
+ self->priv->object = g_value_dup_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+biji_own_cloud_provider_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ BijiOwnCloudProvider *self = BIJI_OWN_CLOUD_PROVIDER (object);
+
+ switch (property_id)
+ {
+ case PROP_GOA_OBJECT:
+ g_value_set_object (value, self->priv->object);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+static const gchar *
+own_cloud_get_datasource (BijiProvider *provider)
+{
+ BijiOwnCloudProvider *self;
+
+ self = BIJI_OWN_CLOUD_PROVIDER (provider);
+ return (const gchar *) self->priv->identifier;
+}
+
+
+static void
+biji_own_cloud_provider_class_init (BijiOwnCloudProviderClass *klass)
+{
+ GObjectClass *g_object_class;
+ BijiProviderClass *provider_class;
+
+ g_object_class = G_OBJECT_CLASS (klass);
+ provider_class = BIJI_PROVIDER_CLASS (klass);
+
+ g_object_class->finalize = biji_own_cloud_provider_finalize;
+ g_object_class->get_property = biji_own_cloud_provider_get_property;
+ g_object_class->set_property = biji_own_cloud_provider_set_property;
+ g_object_class->constructed = biji_own_cloud_provider_constructed;
+ provider_class->get_datasource = own_cloud_get_datasource;
+
+
+ biji_ocloud_provider_signals[OCLOUD_PROV_LOADED] =
+ g_signal_new ("loaded",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+
+
+ properties[PROP_BOOK] =
+ g_param_spec_object("book",
+ "Note Book",
+ "The Note Book",
+ BIJI_TYPE_NOTE_BOOK,
+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
+
+
+ properties[PROP_GOA_OBJECT] =
+ g_param_spec_object("goa",
+ "The Goa Object",
+ "The Goa Object providing notes",
+ GOA_TYPE_OBJECT,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+ g_object_class_install_properties (g_object_class, OCLOUD_PROV_PROP, properties);
+
+ g_type_class_add_private ((gpointer)klass, sizeof (BijiOwnCloudProviderPrivate));
+}
+
+
+BijiProvider *
+biji_own_cloud_provider_new (BijiNoteBook *book, GoaObject *object)
+{
+ return g_object_new (BIJI_TYPE_OWN_CLOUD_PROVIDER, "book", book, "goa", object, NULL);
+}
diff --git a/src/libbiji/provider/biji-own-cloud-provider.h b/src/libbiji/provider/biji-own-cloud-provider.h
new file mode 100644
index 0000000..5a50831
--- /dev/null
+++ b/src/libbiji/provider/biji-own-cloud-provider.h
@@ -0,0 +1,61 @@
+/* bjb-own-cloud-provider.h
+ * Copyright (C) Pierre-Yves LUYTEN 2013 <py luyten fr>
+ *
+ * bijiben is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * bijiben is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef BIJI_OWN_CLOUD_PROVIDER_H_
+#define BIJI_OWN_CLOUD_PROVIDER_H_ 1
+
+#include "biji-provider.h"
+
+G_BEGIN_DECLS
+
+
+#define BIJI_TYPE_OWN_CLOUD_PROVIDER (biji_own_cloud_provider_get_type ())
+#define BIJI_OWN_CLOUD_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
BIJI_TYPE_OWN_CLOUD_PROVIDER, BijiOwnCloudProvider))
+#define BIJI_OWN_CLOUD_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
BIJI_TYPE_OWN_CLOUD_PROVIDER, BijiOwnCloudProviderClass))
+#define BIJI_IS_OWN_CLOUD_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
BIJI_TYPE_OWN_CLOUD_PROVIDER))
+#define BIJI_IS_OWN_CLOUD_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
BIJI_TYPE_OWN_CLOUD_PROVIDER))
+#define BIJI_OWN_CLOUD_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
BIJI_TYPE_OWN_CLOUD_PROVIDER, BijiOwnCloudProviderClass))
+
+typedef struct BijiOwnCloudProvider_ BijiOwnCloudProvider;
+typedef struct BijiOwnCloudProviderClass_ BijiOwnCloudProviderClass;
+typedef struct BijiOwnCloudProviderPrivate_ BijiOwnCloudProviderPrivate;
+
+struct BijiOwnCloudProvider_
+{
+ BijiProvider parent;
+ BijiOwnCloudProviderPrivate *priv;
+};
+
+
+struct BijiOwnCloudProviderClass_
+{
+ BijiProviderClass parent_class;
+};
+
+
+GType biji_own_cloud_provider_get_type (void);
+
+
+
+BijiProvider *biji_own_cloud_provider_new (BijiNoteBook *book,
+ GoaObject *object);
+
+
+G_END_DECLS
+
+#endif /* BIJI_OWN_CLOUD_PROVIDER_H_ */
diff --git a/src/libbiji/provider/biji-provider.c b/src/libbiji/provider/biji-provider.c
new file mode 100644
index 0000000..012813a
--- /dev/null
+++ b/src/libbiji/provider/biji-provider.c
@@ -0,0 +1,74 @@
+/* bjb-provider.c
+ * Copyright (C) Pierre-Yves LUYTEN 2013 <py luyten fr>
+ *
+ * bijiben is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * bijiben is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/*
+ * TODO: the generic provider should at least
+ * be the one emiting the signals
+ *
+ * So 1. for each provider, the book connects to the same
+ * & provider does not reinvent anything
+ * 2. it might be a right place for running the approriate
+ * threads - or even processes.
+ *
+ */
+
+#include "biji-provider.h"
+
+
+struct BijiProviderPrivate_
+{
+ gpointer delete_me;
+};
+
+G_DEFINE_TYPE (BijiProvider, biji_provider, G_TYPE_OBJECT)
+
+
+
+
+
+static void
+biji_provider_finalize (GObject *object)
+{
+ //BijiProvider *self;
+
+ //g_return_if_fail (BIJI_IS_PROVIDER (object));
+
+ //self = BIJI_PROVIDER (object);
+
+ G_OBJECT_CLASS (biji_provider_parent_class)->finalize (object);
+}
+
+
+static void
+biji_provider_init (BijiProvider *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, BIJI_TYPE_PROVIDER, BijiProviderPrivate);
+}
+
+
+static void
+biji_provider_class_init (BijiProviderClass *klass)
+{
+ GObjectClass *g_object_class;
+
+ g_object_class = G_OBJECT_CLASS (klass);
+
+ g_object_class->finalize = biji_provider_finalize;
+
+ g_type_class_add_private ((gpointer)klass, sizeof (BijiProviderPrivate));
+}
diff --git a/src/libbiji/provider/biji-provider.h b/src/libbiji/provider/biji-provider.h
new file mode 100644
index 0000000..eb2847e
--- /dev/null
+++ b/src/libbiji/provider/biji-provider.h
@@ -0,0 +1,59 @@
+/* bjb-provider.h
+ * Copyright (C) Pierre-Yves LUYTEN 2013 <py luyten fr>
+ *
+ * bijiben is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * bijiben is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BIJI_PROVIDER_H_
+#define BIJI_PROVIDER_H_ 1
+
+#include <glib-object.h>
+
+#include "../biji-note-book.h"
+
+G_BEGIN_DECLS
+
+
+#define BIJI_TYPE_PROVIDER (biji_provider_get_type ())
+#define BIJI_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIJI_TYPE_PROVIDER, BijiProvider))
+#define BIJI_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIJI_TYPE_PROVIDER,
BijiProviderClass))
+#define BIJI_IS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIJI_TYPE_PROVIDER))
+#define BIJI_IS_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIJI_TYPE_PROVIDER))
+#define BIJI_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIJI_TYPE_PROVIDER,
BijiProviderClass))
+
+typedef struct BijiProvider_ BijiProvider;
+typedef struct BijiProviderClass_ BijiProviderClass;
+typedef struct BijiProviderPrivate_ BijiProviderPrivate;
+
+struct BijiProvider_
+{
+ GObject parent;
+ BijiProviderPrivate *priv;
+};
+
+
+struct BijiProviderClass_
+{
+ GObjectClass parent_class;
+
+ const gchar* (*get_datasource) (BijiProvider *provider);
+};
+
+
+GType biji_provider_get_type (void);
+
+
+G_END_DECLS
+
+#endif /* BIJI_PROVIDER_H_ */
diff --git a/src/libbiji/serializer/biji-lazy-serializer.c b/src/libbiji/serializer/biji-lazy-serializer.c
index e40a800..226563a 100644
--- a/src/libbiji/serializer/biji-lazy-serializer.c
+++ b/src/libbiji/serializer/biji-lazy-serializer.c
@@ -171,6 +171,7 @@ biji_lazy_serialize_internal (BijiLazySerializer *self)
gchar *date, *color_str;
gboolean retval;
const gchar *path;
+ GTimeVal time = {0, 0};
priv->writer = xmlNewTextWriterMemory(priv->buf, 0);
@@ -205,17 +206,31 @@ biji_lazy_serialize_internal (BijiLazySerializer *self)
xmlTextWriterEndElement(priv->writer);
// <last-change-date>
- date = biji_note_obj_get_last_change_date (priv->note);
- serialize_node (priv->writer, "last-change-date", date);
- g_free (date);
+ time.tv_sec = biji_item_get_mtime (BIJI_ITEM (priv->note));
+ date = g_time_val_to_iso8601 (&time);
+ if (date)
+ {
+ serialize_node (priv->writer, "last-change-date", date);
+ g_free (date);
+ }
+
+
+ time.tv_sec = biji_note_obj_get_last_metadata_change_date (priv->note);
+ date = g_time_val_to_iso8601 (&time);
+ if (date)
+ {
+ serialize_node (priv->writer, "last-metadata-change-date", date);
+ g_free (date);
+ }
- date = biji_note_obj_get_last_metadata_change_date (priv->note);
- serialize_node (priv->writer, "last-metadata-change-date", date);
- g_free (date);
- date = biji_note_obj_get_create_date (priv->note);
- serialize_node (priv->writer, "create-date", date);
- g_free (date);
+ time.tv_sec = biji_note_obj_get_create_date (priv->note);
+ date = g_time_val_to_iso8601 (&time);
+ if (date)
+ {
+ serialize_node (priv->writer, "create-date", date);
+ g_free (date);
+ }
serialize_node (priv->writer, "cursor-position", "0");
serialize_node (priv->writer, "selection-bound-position", "0");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]