[bijiben] ownCloud: better handle note creation with a primary path
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] ownCloud: better handle note creation with a primary path
- Date: Sat, 14 Sep 2013 23:38:26 +0000 (UTC)
commit e0bdc42f2e5e683b6cce96a183c693af08f60540
Author: Pierre-Yves Luyten <py luyten fr>
Date: Sun Sep 15 01:09:55 2013 +0200
ownCloud: better handle note creation with a primary path
generate a unique path at startup that will anyway be changed soon
src/libbiji/biji-note-book.c | 15 +++++++++++-
src/libbiji/provider/biji-own-cloud-note.c | 33 ++++++++++++++++-----------
2 files changed, 32 insertions(+), 16 deletions(-)
---
diff --git a/src/libbiji/biji-note-book.c b/src/libbiji/biji-note-book.c
index 8e72613..dd3c89f 100644
--- a/src/libbiji/biji-note-book.c
+++ b/src/libbiji/biji-note-book.c
@@ -215,6 +215,9 @@ title_is_unique (BijiNoteBook *book, gchar *title)
for ( l=items ; l != NULL ; l = l->next)
{
+ if (BIJI_IS_ITEM (l->data) == FALSE)
+ break;
+
iter = BIJI_ITEM (l->data);
if (g_strcmp0 (biji_item_get_title (iter), title) == 0)
@@ -529,7 +532,8 @@ biji_note_book_add_item (BijiNoteBook *book, BijiItem *item, gboolean notify)
uid = biji_item_get_uuid (item);
- if (g_hash_table_lookup (book->priv->items, uid))
+ if (uid != NULL &&
+ g_hash_table_lookup (book->priv->items, uid))
retval = FALSE;
else if (BIJI_IS_NOTE_OBJ (item))
@@ -679,6 +683,7 @@ biji_note_book_note_new (BijiNoteBook *book,
gchar *provider_id)
{
BijiProvider *provider;
+ BijiNoteObj *retval;
// If we move local_note_new to create_note for local provider
// we won't need this stupid switch.
@@ -691,6 +696,12 @@ biji_note_book_note_new (BijiNoteBook *book,
provider = g_hash_table_lookup (book->priv->providers,
provider_id);
- return BIJI_PROVIDER_GET_CLASS (provider)->create_note (provider, str);
+
+ retval = BIJI_PROVIDER_GET_CLASS (provider)->create_note (provider, str);
+ // do not save. up to the provider implementation to save it or not
+ // at creation.
+ biji_note_book_add_item (book, BIJI_ITEM (retval), TRUE);
+
+ return retval;
}
diff --git a/src/libbiji/provider/biji-own-cloud-note.c b/src/libbiji/provider/biji-own-cloud-note.c
index 46e64be..39bdf18 100644
--- a/src/libbiji/provider/biji-own-cloud-note.c
+++ b/src/libbiji/provider/biji-own-cloud-note.c
@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <uuid/uuid.h>
#include "biji-info-set.h"
#include "biji-item.h"
@@ -336,6 +337,22 @@ BijiNoteObj *biji_own_cloud_note_new_from_info (BijiOwnCloudPro
g_free (info->title);
info->title = sane_title;
+
+ /* Hmm, even if the note starts blank we want some path...*/
+
+ if (info->url == NULL)
+ {
+ uuid_t unique;
+ char out[40];
+
+ uuid_generate (unique);
+ uuid_unparse_lower (unique, out);
+
+ info->url = g_strdup_printf ("%s/%s.txt",
+ biji_own_cloud_provider_get_readable_path (prov),
+ out);
+ }
+
/* Now actually create the stuff */
id = biji_note_id_new_from_info (info);
@@ -354,21 +371,9 @@ BijiNoteObj *biji_own_cloud_note_new_from_info (BijiOwnCloudPro
g_signal_connect_swapped (id, "notify::title",
G_CALLBACK (on_title_change), retval);
- /* That's not a blank note. That's an existing file. */
-
- if (info->url != NULL)
- {
- ocloud->priv->location = g_file_new_for_commandline_arg (info->url);
- ocloud->priv->basename = g_file_get_basename (ocloud->priv->location);
- }
-
- /* Really new note */
- else
- {
- ocloud->priv->location = NULL;
- ocloud->priv->basename = NULL;
- }
+ ocloud->priv->location = g_file_new_for_commandline_arg (info->url);
+ ocloud->priv->basename = g_file_get_basename (ocloud->priv->location);
return retval;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]