[evolution-etesync/Add-notes-feature] I#1 - Add support for notes
- From: Nour E-Din El-Nhass <nourmat src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-etesync/Add-notes-feature] I#1 - Add support for notes
- Date: Tue, 27 Apr 2021 23:39:50 +0000 (UTC)
commit 0994f87449063c7cb8a9e8f561fb88c733b037a4
Author: Nour E-Din El-Nhass <nouredinosama gmail com>
Date: Wed Mar 31 22:40:58 2021 +0200
I#1 - Add support for notes
src/addressbook/e-book-backend-etesync.c | 17 +-
src/calendar/e-cal-backend-etesync-factory.c | 35 +++-
src/calendar/e-cal-backend-etesync.c | 50 +++---
src/common/e-etesync-connection.c | 256 +++++++++++++++++++++++----
src/common/e-etesync-connection.h | 3 +
src/common/e-etesync-defines.h | 1 +
src/common/e-etesync-utils.c | 7 +-
src/common/e-etesync-utils.h | 10 +-
src/evolution/e-cal-config-etesync.c | 6 +
src/evolution/e-etesync-config-lookup.c | 2 +-
src/registry/e-etesync-backend.c | 67 ++++---
11 files changed, 356 insertions(+), 98 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-etesync.c b/src/addressbook/e-book-backend-etesync.c
index 5fa2a4a..ee39054 100644
--- a/src/addressbook/e-book-backend-etesync.c
+++ b/src/addressbook/e-book-backend-etesync.c
@@ -279,10 +279,10 @@ ebb_etesync_save_contact_sync (EBookMetaBackend *meta_backend,
if (overwrite_existing) {
success = e_etesync_connection_item_upload_sync (connection, E_BACKEND (meta_backend),
bbetesync->priv->col_obj,
- E_ETESYNC_ITEM_ACTION_MODIFY, content, uid, extra, out_new_extra,
cancellable, error);
+ E_ETESYNC_ITEM_ACTION_MODIFY, content, uid, extra, NULL, out_new_extra,
cancellable, error);
} else {
success = e_etesync_connection_item_upload_sync (connection, E_BACKEND (meta_backend),
bbetesync->priv->col_obj,
- E_ETESYNC_ITEM_ACTION_CREATE, content, uid, NULL, out_new_extra, cancellable,
error);
+ E_ETESYNC_ITEM_ACTION_CREATE, content, uid, NULL, NULL, out_new_extra,
cancellable, error);
}
g_free (content);
@@ -314,7 +314,7 @@ ebb_etesync_remove_contact_sync (EBookMetaBackend *meta_backend,
g_rec_mutex_lock (&bbetesync->priv->etesync_lock);
success = e_etesync_connection_item_upload_sync (connection, E_BACKEND (meta_backend),
bbetesync->priv->col_obj,
- E_ETESYNC_ITEM_ACTION_DELETE, NULL, uid, extra, NULL, cancellable, error);
+ E_ETESYNC_ITEM_ACTION_DELETE, NULL, uid, extra, NULL, NULL, cancellable,
error);
g_rec_mutex_unlock (&bbetesync->priv->etesync_lock);
@@ -347,14 +347,12 @@ ebb_etesync_create_modify_contacts_sync (EBookBackendSync *backend,
while (length > 0 && success) {
GSList *batch_contacts = NULL; /* EContact */
GSList *batch_info = NULL; /* EBookMetaBackendInfo */
- gchar **content;
+ gchar *content[E_ETESYNC_ITEM_PUSH_LIMIT];
guint ii;
batch_length = length > E_ETESYNC_ITEM_PUSH_LIMIT ? E_ETESYNC_ITEM_PUSH_LIMIT : length;
length -= batch_length;
- content = g_slice_alloc0 (batch_length * sizeof (gchar *));
-
for (ii = 0; ii < batch_length; ii++) {
EContact *contact;
@@ -394,6 +392,7 @@ ebb_etesync_create_modify_contacts_sync (EBookBackendSync *backend,
bbetesync->priv->col_obj,
E_ETESYNC_ADDRESSBOOK,
(const gchar *const*)
content,
+ NULL,
batch_length, /* length of
content */
E_CACHE (book_cache), /*
uses book_cache if type is addressbook */
&batch_info,
@@ -417,7 +416,6 @@ ebb_etesync_create_modify_contacts_sync (EBookBackendSync *backend,
for (ii = 0; ii < batch_length; ii++)
g_free (content[ii]);
- g_slice_free1 (batch_length * sizeof (gchar *), content);
batch_number++;
}
@@ -518,13 +516,12 @@ ebb_etesync_remove_contacts_sync (EBookBackendSync *backend,
while (length > 0 && success) {
GSList *batch_contacts_id = NULL; /* gchar */
GSList *batch_info = NULL; /* EBookMetaBackendInfo */
- gchar **content;
+ gchar *content[E_ETESYNC_ITEM_PUSH_LIMIT];
guint ii;
batch_length = length > E_ETESYNC_ITEM_PUSH_LIMIT ? E_ETESYNC_ITEM_PUSH_LIMIT : length;
length -= batch_length;
*out_removed_uids = NULL;
- content = g_slice_alloc0 (batch_length * sizeof (gchar *));
for (ii = 0; ii < batch_length; ii++) {
const gchar *id;
@@ -545,6 +542,7 @@ ebb_etesync_remove_contacts_sync (EBookBackendSync *backend,
bbetesync->priv->col_obj,
E_ETESYNC_ADDRESSBOOK,
(const gchar *const*) content,
+ NULL,
batch_length, /* length of content */
E_CACHE (book_cache), /* uses book_cache if
type is addressbook */
&batch_info,
@@ -561,7 +559,6 @@ ebb_etesync_remove_contacts_sync (EBookBackendSync *backend,
for (ii = 0; ii < batch_length; ii++)
g_free (content[ii]);
- g_slice_free1 (batch_length * sizeof (gchar *), content);
batch_number++;
}
diff --git a/src/calendar/e-cal-backend-etesync-factory.c b/src/calendar/e-cal-backend-etesync-factory.c
index 940c503..28810db 100644
--- a/src/calendar/e-cal-backend-etesync-factory.c
+++ b/src/calendar/e-cal-backend-etesync-factory.c
@@ -20,6 +20,9 @@ typedef ECalBackendFactoryClass ECalBackendEteSyncEventsFactoryClass;
typedef ECalBackendFactory ECalBackendEteSyncTodosFactory;
typedef ECalBackendFactoryClass ECalBackendEteSyncTodosFactoryClass;
+typedef ECalBackendFactory ECalBackendEteSyncJournalFactory;
+typedef ECalBackendFactoryClass ECalBackendEteSyncJournalFactoryClass;
+
static EModule *e_module;
/* Module Entry Points */
@@ -29,7 +32,7 @@ void e_module_unload (GTypeModule *type_module);
/* Forward Declarations */
GType e_cal_backend_etesync_events_factory_get_type (void);
GType e_cal_backend_etesync_todos_factory_get_type (void);
-
+GType e_cal_backend_etesync_journal_factory_get_type (void);
G_DEFINE_DYNAMIC_TYPE (
ECalBackendEteSyncEventsFactory,
@@ -41,6 +44,11 @@ G_DEFINE_DYNAMIC_TYPE (
e_cal_backend_etesync_todos_factory,
E_TYPE_CAL_BACKEND_FACTORY)
+G_DEFINE_DYNAMIC_TYPE (
+ ECalBackendEteSyncJournalFactory,
+ e_cal_backend_etesync_journal_factory,
+ E_TYPE_CAL_BACKEND_FACTORY)
+
static void
e_cal_backend_etesync_events_factory_class_init (ECalBackendFactoryClass *class)
{
@@ -89,6 +97,30 @@ e_cal_backend_etesync_todos_factory_init (ECalBackendFactory *factory)
{
}
+static void
+e_cal_backend_etesync_journal_factory_class_init (ECalBackendFactoryClass *class)
+{
+ EBackendFactoryClass *backend_factory_class;
+
+ backend_factory_class = E_BACKEND_FACTORY_CLASS (class);
+ backend_factory_class->e_module = e_module;
+ backend_factory_class->share_subprocess = TRUE;
+
+ class->factory_name = FACTORY_NAME;
+ class->component_kind = I_CAL_VJOURNAL_COMPONENT;
+ class->backend_type = E_TYPE_CAL_BACKEND_ETESYNC;
+}
+
+static void
+e_cal_backend_etesync_journal_factory_class_finalize (ECalBackendFactoryClass *class)
+{
+}
+
+static void
+e_cal_backend_etesync_journal_factory_init (ECalBackendFactory *factory)
+{
+}
+
G_MODULE_EXPORT void
e_module_load (GTypeModule *type_module)
{
@@ -101,6 +133,7 @@ e_module_load (GTypeModule *type_module)
e_cal_backend_etesync_events_factory_register_type (type_module);
e_cal_backend_etesync_todos_factory_register_type (type_module);
+ e_cal_backend_etesync_journal_factory_register_type (type_module);
}
G_MODULE_EXPORT void
diff --git a/src/calendar/e-cal-backend-etesync.c b/src/calendar/e-cal-backend-etesync.c
index 4742672..7e6271c 100644
--- a/src/calendar/e-cal-backend-etesync.c
+++ b/src/calendar/e-cal-backend-etesync.c
@@ -291,10 +291,10 @@ ecb_etesync_save_component_sync (ECalMetaBackend *meta_backend,
if (overwrite_existing) {
success = e_etesync_connection_item_upload_sync (connection, E_BACKEND (meta_backend),
cbetesync->priv->col_obj,
- E_ETESYNC_ITEM_ACTION_MODIFY, content, uid, extra, out_new_extra, cancellable, error);
+ E_ETESYNC_ITEM_ACTION_MODIFY, content, uid, extra, NULL, out_new_extra, cancellable,
error);
} else {
success = e_etesync_connection_item_upload_sync (connection, E_BACKEND (meta_backend),
cbetesync->priv->col_obj,
- E_ETESYNC_ITEM_ACTION_CREATE, content, uid, NULL, out_new_extra, cancellable, error);
+ E_ETESYNC_ITEM_ACTION_CREATE, content, uid, NULL, out_new_uid, out_new_extra,
cancellable, error);
}
g_free (content);
@@ -327,7 +327,7 @@ ecb_etesync_remove_component_sync (ECalMetaBackend *meta_backend,
g_rec_mutex_lock (&cbetesync->priv->etesync_lock);
success = e_etesync_connection_item_upload_sync (connection, E_BACKEND (meta_backend),
cbetesync->priv->col_obj,
- E_ETESYNC_ITEM_ACTION_DELETE, NULL, uid, extra, NULL, cancellable, error);
+ E_ETESYNC_ITEM_ACTION_DELETE, NULL, uid, extra, NULL, NULL, cancellable,
error);
g_rec_mutex_unlock (&cbetesync->priv->etesync_lock);
@@ -368,14 +368,12 @@ ecb_etesync_create_objects_sync (ECalBackendSync *backend,
/* extract the components and mass-add them to the server "batch by batch" */
while (l && success) {
- gchar **content;
+ gchar *content[E_ETESYNC_ITEM_PUSH_LIMIT];
GSList *batch_uids = NULL; /* gchar* */
GSList *batch_components= NULL; /* ECalComponent* */
GSList *batch_info = NULL; /* ECalMetaBackendInfo* */
guint ii, batch_length = 0;
- content = g_slice_alloc0 (E_ETESYNC_ITEM_PUSH_LIMIT * sizeof (gchar *));
-
/* Data Preproccessing */
for (ii = 0 ; ii < E_ETESYNC_ITEM_PUSH_LIMIT && l; l = l->next, ii++) {
ICalComponent *icomp, *vcal;
@@ -430,7 +428,7 @@ ecb_etesync_create_objects_sync (ECalBackendSync *backend,
if (success) {
success = e_etesync_connection_batch_create_sync (connection,
- E_BACKEND (E_CAL_META_BACKEND
(cbetesync)),
+ E_BACKEND (cbetesync),
cbetesync->priv->col_obj,
E_ETESYNC_CALENDAR,
(const gchar *const*) content,
@@ -453,7 +451,6 @@ ecb_etesync_create_objects_sync (ECalBackendSync *backend,
for (ii = 0; ii < batch_length; ii++)
g_free (content[ii]);
- g_slice_free1 (E_ETESYNC_ITEM_PUSH_LIMIT * sizeof (gchar *), content);
}
if (success) {
@@ -511,20 +508,18 @@ ecb_etesync_modify_objects_sync (ECalBackendSync *backend,
/* extract the components and mass-add them to the server "batch by batch" */
while (l && success) {
- gchar **content;
+ gchar *data_uids[E_ETESYNC_ITEM_PUSH_LIMIT];
+ gchar *content[E_ETESYNC_ITEM_PUSH_LIMIT];
GSList *batch_out_old_components = NULL; /* ECalComponent* */
GSList *batch_out_new_components= NULL; /* ECalComponent* */
GSList *batch_info = NULL; /* ECalMetaBackendInfo* */
guint ii, batch_length = 0;
- content = g_slice_alloc0 (E_ETESYNC_ITEM_PUSH_LIMIT * sizeof (gchar *));
-
/* Data Preproccessing */
for (ii = 0 ; ii < E_ETESYNC_ITEM_PUSH_LIMIT && l; l = l->next, ii++) {
ICalComponent *icomp, *vcal;
ECalComponent *comp;
ICalTime *current;
- const gchar *comp_uid;
GSList *instances;
/* Parse the icalendar text */
@@ -549,10 +544,10 @@ ecb_etesync_modify_objects_sync (ECalBackendSync *backend,
} else
content[ii] = i_cal_component_as_ical_string (icomp);
- comp_uid = i_cal_component_get_uid (icomp);
+ data_uids[ii] = g_strdup (i_cal_component_get_uid (icomp));
batch_out_new_components = g_slist_prepend (batch_out_new_components,
e_cal_component_clone (comp));
- if (e_cal_cache_get_components_by_uid (cal_cache, comp_uid, &instances, NULL, NULL))
+ if (e_cal_cache_get_components_by_uid (cal_cache, data_uids[ii], &instances, NULL,
NULL))
batch_out_old_components = g_slist_concat (batch_out_old_components,
instances);
g_object_unref (comp);
@@ -562,11 +557,12 @@ ecb_etesync_modify_objects_sync (ECalBackendSync *backend,
if (success) {
success = e_etesync_connection_batch_modify_sync (connection,
- E_BACKEND (E_CAL_META_BACKEND
(cbetesync)),
+ E_BACKEND (cbetesync),
cbetesync->priv->col_obj,
E_ETESYNC_CALENDAR,
(const gchar *const*) content,
- batch_length, /* length of content
*/
+ (const gchar *const*) data_uids,
+ batch_length, /* length of batch */
E_CACHE (cal_cache), /* uses
cal_cache if type is calendar */
&batch_info,
cancellable,
@@ -583,9 +579,10 @@ ecb_etesync_modify_objects_sync (ECalBackendSync *backend,
}
}
- for (ii = 0; ii < batch_length; ii++)
+ for (ii = 0; ii < batch_length; ii++) {
g_free (content[ii]);
- g_slice_free1 (E_ETESYNC_ITEM_PUSH_LIMIT * sizeof (gchar *), content);
+ g_free (data_uids[ii]);
+ }
}
if (success) {
@@ -644,13 +641,12 @@ ecb_etesync_remove_objects_sync (ECalBackendSync *backend,
/* extract the components and mass-add them to the server "batch by batch" */
while (l && success) {
- gchar **content;
+ gchar *data_uids[E_ETESYNC_ITEM_PUSH_LIMIT];
+ gchar *content[E_ETESYNC_ITEM_PUSH_LIMIT];
GSList *batch_out_old_components = NULL; /* ECalComponent* */
GSList *batch_info = NULL; /* ECalMetaBackendInfo* */
guint ii, batch_length = 0;
- content = g_slice_alloc0 (E_ETESYNC_ITEM_PUSH_LIMIT * sizeof (gchar *));
-
/* Data Preproccessing */
for (ii = 0; ii < E_ETESYNC_ITEM_PUSH_LIMIT && l; l = l->next, ii++) {
ICalComponent *vcal;
@@ -659,6 +655,7 @@ ecb_etesync_remove_objects_sync (ECalBackendSync *backend,
if (e_cal_cache_get_components_by_uid (cal_cache, e_cal_component_id_get_uid
(l->data), &instances, cancellable, NULL)) {
vcal = e_cal_meta_backend_merge_instances (E_CAL_META_BACKEND (cbetesync),
instances, TRUE);
content[ii] = i_cal_component_as_ical_string (vcal);
+ data_uids[ii] = g_strdup (e_cal_component_id_get_uid (l->data));
g_object_unref (vcal);
} else {
success = FALSE;
@@ -673,11 +670,12 @@ ecb_etesync_remove_objects_sync (ECalBackendSync *backend,
if (success) {
success = e_etesync_connection_batch_delete_sync (connection,
- E_BACKEND (E_CAL_META_BACKEND
(cbetesync)),
+ E_BACKEND (cbetesync),
cbetesync->priv->col_obj,
E_ETESYNC_CALENDAR,
(const gchar *const*) content,
- batch_length, /* length of content
*/
+ (const gchar *const*) data_uids,
+ batch_length, /* length of batch */
E_CACHE (cal_cache), /* uses
cal_cache if type is calendar */
&batch_info,
cancellable,
@@ -692,9 +690,10 @@ ecb_etesync_remove_objects_sync (ECalBackendSync *backend,
}
}
- for (ii = 0; ii < batch_length; ii++)
+ for (ii = 0; ii < batch_length; ii++) {
g_free (content[ii]);
- g_slice_free1 (E_ETESYNC_ITEM_PUSH_LIMIT * sizeof (gchar *), content);
+ g_free (data_uids[ii]);
+ }
}
if (success) {
@@ -733,6 +732,7 @@ ecb_etesync_get_backend_property (ECalBackend *cal_backend,
E_CAL_STATIC_CAPABILITY_TASK_CAN_RECUR,
E_CAL_STATIC_CAPABILITY_COMPONENT_COLOR,
E_CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS,
+ E_CAL_STATIC_CAPABILITY_SIMPLE_MEMO,
e_cal_meta_backend_get_capabilities (E_CAL_META_BACKEND (cbetesync)),
NULL);
} else if (g_str_equal (prop_name, E_CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS)) {
diff --git a/src/common/e-etesync-connection.c b/src/common/e-etesync-connection.c
index 338bafd..72c432a 100644
--- a/src/common/e-etesync-connection.c
+++ b/src/common/e-etesync-connection.c
@@ -272,9 +272,9 @@ e_etesync_connection_is_connected (EEteSyncConnection *connection)
g_rec_mutex_lock (&connection->priv->connection_lock);
- success = (connection->priv->etebase_client
- && connection->priv->etebase_account
- && connection->priv->col_mgr) ? TRUE : FALSE;
+ success = (connection->priv->etebase_client &&
+ connection->priv->etebase_account &&
+ connection->priv->col_mgr) ? TRUE : FALSE;
g_rec_mutex_unlock (&connection->priv->connection_lock);
@@ -457,9 +457,9 @@ e_etesync_connection_collection_create_upload_sync (EEteSyncConnection *connecti
col_obj = etebase_collection_manager_create (connection->priv->col_mgr, col_type, item_metadata, "",
0);
success = !etebase_collection_manager_upload (connection->priv->col_mgr, col_obj, NULL);
- if (!success
- && etebase_error_get_code () == ETEBASE_ERROR_CODE_UNAUTHORIZED
- && e_etesync_connection_maybe_reconnect_sync (connection, backend, cancellable, error)) {
+ if (!success &&
+ etebase_error_get_code () == ETEBASE_ERROR_CODE_UNAUTHORIZED &&
+ e_etesync_connection_maybe_reconnect_sync (connection, backend, cancellable, error)) {
success = !etebase_collection_manager_upload (connection->priv->col_mgr, col_obj, NULL);
}
@@ -508,9 +508,9 @@ e_etesync_connection_collection_modify_upload_sync (EEteSyncConnection *connecti
etebase_collection_set_meta (col_obj, item_metadata);
success = !etebase_collection_manager_upload (connection->priv->col_mgr, col_obj, NULL);
- if (!success
- && etebase_error_get_code () == ETEBASE_ERROR_CODE_UNAUTHORIZED
- && e_etesync_connection_reconnect_sync (connection, NULL, NULL, &local_error)) {
+ if (!success &&
+ etebase_error_get_code () == ETEBASE_ERROR_CODE_UNAUTHORIZED &&
+ e_etesync_connection_reconnect_sync (connection, NULL, NULL, &local_error)) {
success = !etebase_collection_manager_upload (connection->priv->col_mgr, col_obj, NULL);
}
@@ -555,9 +555,9 @@ e_etesync_connection_collection_delete_upload_sync (EEteSyncConnection *connecti
etebase_collection_delete (col_obj);
success = !etebase_collection_manager_upload (connection->priv->col_mgr, col_obj, NULL);
- if (!success
- && etebase_error_get_code () == ETEBASE_ERROR_CODE_UNAUTHORIZED
- && e_etesync_connection_maybe_reconnect_sync (connection, backend, cancellable, error)) {
+ if (!success &&
+ etebase_error_get_code () == ETEBASE_ERROR_CODE_UNAUTHORIZED &&
+ e_etesync_connection_maybe_reconnect_sync (connection, backend, cancellable, error)) {
success = !etebase_collection_manager_upload (connection->priv->col_mgr, col_obj, NULL);
}
@@ -573,6 +573,68 @@ e_etesync_connection_collection_delete_upload_sync (EEteSyncConnection *connecti
}
/* ------------------- Book and calendar common function ------------------- */
+static gboolean
+e_etesync_connection_backend_is_for_memos (EBackend *backend)
+{
+ return E_IS_CAL_BACKEND (backend) && e_cal_backend_get_kind (E_CAL_BACKEND (backend)) ==
I_CAL_VJOURNAL_COMPONENT;
+}
+
+static gchar *
+e_etesync_connection_notes_new_ical_string (time_t creation_date,
+ time_t last_modified,
+ const gchar *uid,
+ const gchar *revision,
+ const gchar *summary,
+ const gchar *description)
+{
+ ICalComponent *icomp;
+ ICalTime *itt;
+ time_t tt;
+ gchar *ical_str;
+
+ icomp = i_cal_component_new_vjournal ();
+
+ if (creation_date > 0)
+ tt = creation_date;
+ else if (last_modified > 0)
+ tt = last_modified;
+ else
+ tt = time (NULL);
+
+ itt = i_cal_time_new_from_timet_with_zone (tt, FALSE, i_cal_timezone_get_utc_timezone ());
+ i_cal_component_take_property (icomp, i_cal_property_new_created (itt));
+ g_object_unref (itt);
+
+ if (last_modified > 0)
+ tt = last_modified;
+ else
+ tt = time (NULL);
+
+ itt = i_cal_time_new_from_timet_with_zone (tt, FALSE, i_cal_timezone_get_utc_timezone ());
+ i_cal_component_take_property (icomp, i_cal_property_new_lastmodified (itt));
+ g_object_unref (itt);
+
+ i_cal_component_set_uid (icomp, uid);
+
+ if (summary && g_str_has_suffix (summary, ".txt")) {
+ gchar *tmp;
+
+ tmp = g_strndup (summary, strlen (summary) - 4);
+ i_cal_component_set_summary (icomp, tmp);
+ g_free (tmp);
+ } else if (summary && *summary) {
+ i_cal_component_set_summary (icomp, summary);
+ }
+
+ if (description && *description)
+ i_cal_component_set_description (icomp, description);
+
+ ical_str = i_cal_component_as_ical_string (icomp);
+
+ g_object_unref (icomp);
+
+ return ical_str;
+}
static gboolean
e_etesync_connection_chunk_itemlist_fetch_sync (EtebaseItemManager *item_mgr,
@@ -619,6 +681,7 @@ e_etesync_connection_list_existing_sync (EEteSyncConnection *connection,
gchar *stoken = NULL;
gboolean done = FALSE;
gboolean success = TRUE;
+ gboolean is_memo;
*out_existing_objects = NULL;
*out_new_sync_tag = NULL;
@@ -630,6 +693,7 @@ e_etesync_connection_list_existing_sync (EEteSyncConnection *connection,
return FALSE;
}
+ is_memo = e_etesync_connection_backend_is_for_memos (backend);
item_mgr = etebase_collection_manager_get_item_manager (connection->priv->col_mgr, col_obj);
while (!done) {
@@ -677,9 +741,29 @@ e_etesync_connection_list_existing_sync (EEteSyncConnection *connection,
} else if (type == E_ETESYNC_CALENDAR) {
ECalMetaBackendInfo *nfo;
- /* create ECalMetaBackendInfo * to be stored in
GSList, data_uid is component uid */
- e_etesync_utils_get_component_uid_revision (content ?
content : buf, &data_uid, &revision);
- nfo = e_cal_meta_backend_info_new (data_uid,
revision, content ? content : buf, item_cache_b64);
+ if (is_memo) {
+ EtebaseItemMetadata *item_meta;
+ const gchar *summary;
+ gchar *ical_str;
+ glong now;
+
+ item_meta = etebase_item_get_meta (item);
+ summary = etebase_item_metadata_get_name
(item_meta);
+ data_uid = g_strdup (etebase_item_get_uid
(item));
+ e_etesync_utils_get_time_now (&now);
+
+ /* change plain text to a icomp vjournal
object */
+ ical_str =
e_etesync_connection_notes_new_ical_string ((time_t) now, (time_t) now, data_uid, NULL, summary, content ?
content : buf);
+ nfo = e_cal_meta_backend_info_new (data_uid,
NULL, ical_str, item_cache_b64);
+
+ g_free (ical_str);
+ etebase_item_metadata_destroy (item_meta);
+ } else {
+ /* create ECalMetaBackendInfo * to be stored
in GSList, data_uid is component uid */
+ e_etesync_utils_get_component_uid_revision
(content ? content : buf, &data_uid, &revision);
+ nfo = e_cal_meta_backend_info_new (data_uid,
revision, content ? content : buf, item_cache_b64);
+ }
+
*out_existing_objects = g_slist_prepend
(*out_existing_objects, nfo);
}
@@ -733,6 +817,7 @@ e_etesync_connection_get_changes_sync (EEteSyncConnection *connection,
gchar *stoken;
gboolean done = FALSE;
gboolean success = TRUE;
+ gboolean is_memo;
stoken = g_strdup (last_sync_tag);
@@ -743,6 +828,7 @@ e_etesync_connection_get_changes_sync (EEteSyncConnection *connection,
return FALSE;
}
+ is_memo = e_etesync_connection_backend_is_for_memos (backend);
item_mgr = etebase_collection_manager_get_item_manager (connection->priv->col_mgr, col_obj);
while (!done) {
@@ -802,10 +888,29 @@ e_etesync_connection_get_changes_sync (EEteSyncConnection *connection,
} else if (type == E_ETESYNC_CALENDAR) {
ECalMetaBackendInfo *nfo;
- /* create ECalMetaBackendInfo * to be stored in GSList, data
uid is compounent uid */
- e_etesync_utils_get_component_uid_revision (content ? content
: buf, &data_uid, &revision);
+ if (is_memo) {
+ EtebaseItemMetadata *item_meta;
+ const gchar *summary;
+ gchar *ical_str;
+ glong now;
+
+ item_meta = etebase_item_get_meta (item);
+ summary = etebase_item_metadata_get_name (item_meta);
+ data_uid = g_strdup (etebase_item_get_uid (item));
+ e_etesync_utils_get_time_now (&now);
+
+ /* change plain text to a icomp vjournal object */
+ ical_str = e_etesync_connection_notes_new_ical_string
((time_t) now, (time_t) now, data_uid, NULL, summary, content ? content : buf);
+ nfo = e_cal_meta_backend_info_new (data_uid, NULL,
ical_str, item_cache_b64);
+
+ g_free (ical_str);
+ etebase_item_metadata_destroy (item_meta);
+ } else {
+ /* create ECalMetaBackendInfo * to be stored in
GSList, data uid is compounent uid */
+ e_etesync_utils_get_component_uid_revision (content ?
content : buf, &data_uid, &revision);
+ nfo = e_cal_meta_backend_info_new (data_uid,
revision, content ? content : buf, item_cache_b64);
+ }
- nfo = e_cal_meta_backend_info_new (data_uid, revision,
content ? content : buf, item_cache_b64);
is_exist = e_cache_contains (cache, data_uid,
E_CACHE_EXCLUDE_DELETED);
/* data with uid exist, then it is modified or deleted, else
it is new data */
@@ -863,12 +968,14 @@ e_etesync_connection_item_upload_sync (EEteSyncConnection *connection,
const gchar *content,
const gchar *uid,
const gchar *extra, /* item_cache_b64 */
+ gchar **out_new_uid,
gchar **out_new_extra,
GCancellable *cancellable,
GError **error)
{
EtebaseItemManager *item_mgr;
gboolean success = TRUE;
+ gboolean is_memo;
const gchar *item_cache_b64 = extra;
g_return_val_if_fail (connection != NULL, FALSE);
@@ -879,22 +986,38 @@ e_etesync_connection_item_upload_sync (EEteSyncConnection *connection,
g_rec_mutex_lock (&connection->priv->connection_lock);
+ is_memo = e_etesync_connection_backend_is_for_memos (backend);
item_mgr = etebase_collection_manager_get_item_manager (connection->priv->col_mgr, col_obj);
if (item_mgr) {
EtebaseItemMetadata *item_metadata = NULL;
EtebaseItem *item;
time_t now;
+ gchar *item_name, *item_content; /* Added to support EteSync notes type */
e_etesync_utils_get_time_now (&now);
+ /* If it is etesync note item, then set the EteSyncitem metadata name (uid) to summary in
VJOURNAL
+ and set the EteSyncItem content to the description in VJOURNAL */
+ if (action != E_ETESYNC_ITEM_ACTION_DELETE && is_memo) {
+ ICalComponent *icomp = i_cal_component_new_from_string (content);
+
+ item_name = g_strdup (i_cal_component_get_summary (icomp)); /* set data_uid to
summary */
+ item_content = g_strdup (i_cal_component_get_description (icomp)); /* set content to
description */
+
+ g_object_unref (icomp);
+ } else {
+ item_name = g_strdup (uid);
+ item_content = g_strdup (content);
+ }
+
if (action == E_ETESYNC_ITEM_ACTION_CREATE) {
item_metadata = etebase_item_metadata_new ();
- etebase_item_metadata_set_name (item_metadata, uid);
+ etebase_item_metadata_set_name (item_metadata, item_name);
etebase_item_metadata_set_mtime (item_metadata, &now);
- item = etebase_item_manager_create (item_mgr, item_metadata, content, strlen
(content));
+ item = etebase_item_manager_create (item_mgr, item_metadata, item_content ?
item_content : "" , item_content ? strlen (item_content) : 0);
} else {
item = e_etesync_utils_etebase_item_from_base64 (item_cache_b64, item_mgr);
if (!item) {
@@ -904,11 +1027,12 @@ e_etesync_connection_item_upload_sync (EEteSyncConnection *connection,
} else {
item_metadata = etebase_item_get_meta (item);
+ etebase_item_metadata_set_name (item_metadata, item_name);
etebase_item_metadata_set_mtime (item_metadata, &now);
etebase_item_set_meta(item, item_metadata);
if (action == E_ETESYNC_ITEM_ACTION_MODIFY)
- etebase_item_set_content (item, content, strlen (content));
+ etebase_item_set_content (item, item_content ? item_content : "" ,
item_content ? strlen (item_content) : 0);
else if (action == E_ETESYNC_ITEM_ACTION_DELETE)
etebase_item_delete (item);
}
@@ -921,8 +1045,8 @@ e_etesync_connection_item_upload_sync (EEteSyncConnection *connection,
if (!success) {
EtebaseErrorCode etebase_error = etebase_error_get_code ();
/* This is used to check if the error was due to expired token, if so try to
get a new token, then try again */
- if (etebase_error == ETEBASE_ERROR_CODE_UNAUTHORIZED
- && e_etesync_connection_maybe_reconnect_sync (connection, backend,
cancellable, error)) {
+ if (etebase_error == ETEBASE_ERROR_CODE_UNAUTHORIZED &&
+ e_etesync_connection_maybe_reconnect_sync (connection, backend,
cancellable, error)) {
success = !etebase_item_manager_batch (item_mgr, (const EtebaseItem
**) &item, 1, NULL);
}
@@ -934,11 +1058,20 @@ e_etesync_connection_item_upload_sync (EEteSyncConnection *connection,
if (out_new_extra)
*out_new_extra = success ? e_etesync_utils_etebase_item_to_base64 (item,
item_mgr) : NULL;
+ /* Set the new uid for notes from the EteSyncitem uid, as EteSync notes item doesn't
contain
+ uid in its content as other etesync types (calendar, tasks, contacts) */
+ if (action == E_ETESYNC_ITEM_ACTION_CREATE &&
+ out_new_uid &&
+ is_memo)
+ *out_new_uid = g_strdup (etebase_item_get_uid (item));
+
if (item_metadata)
etebase_item_metadata_destroy (item_metadata);
etebase_item_destroy (item);
}
+ g_free (item_name);
+ g_free (item_content);
etebase_item_manager_destroy (item_mgr);
}
@@ -954,6 +1087,7 @@ e_etesync_connection_batch_modify_delete_sync (EEteSyncConnection *connection,
const EteSyncAction action,
const EteSyncType type,
const gchar *const *content,
+ const gchar *const *data_uids,
guint content_len,
ECache *cache,
GSList **out_batch_info,
@@ -962,6 +1096,7 @@ e_etesync_connection_batch_modify_delete_sync (EEteSyncConnection *connection,
{
EtebaseItemManager *item_mgr;
gboolean success = TRUE;
+ gboolean is_memo;
g_return_val_if_fail (connection != NULL, FALSE);
g_return_val_if_fail (col_obj != NULL, FALSE);
@@ -971,6 +1106,7 @@ e_etesync_connection_batch_modify_delete_sync (EEteSyncConnection *connection,
g_rec_mutex_lock (&connection->priv->connection_lock);
+ is_memo = e_etesync_connection_backend_is_for_memos (backend);
item_mgr = etebase_collection_manager_get_item_manager (connection->priv->col_mgr, col_obj);
if (item_mgr) {
@@ -990,7 +1126,12 @@ e_etesync_connection_batch_modify_delete_sync (EEteSyncConnection *connection,
e_etesync_utils_get_contact_uid_revision (content[ii], &data_uid, &revision);
e_book_cache_get_contact_extra (E_BOOK_CACHE (cache), data_uid,
&item_cache_b64, NULL, NULL);
} else if (type == E_ETESYNC_CALENDAR) {/* Calendar */
- e_etesync_utils_get_component_uid_revision (content[ii], &data_uid,
&revision);
+
+ if (is_memo)
+ data_uid = g_strdup (data_uids[ii]);
+ else
+ e_etesync_utils_get_component_uid_revision (content[ii], &data_uid,
&revision);
+
e_cal_cache_get_component_extra (E_CAL_CACHE (cache), data_uid, NULL,
&item_cache_b64, NULL, NULL);
}
@@ -1006,9 +1147,25 @@ e_etesync_connection_batch_modify_delete_sync (EEteSyncConnection *connection,
etebase_item_metadata_set_mtime (item_metadata, &now);
etebase_item_set_meta(items[ii], item_metadata);
- if (action == E_ETESYNC_ITEM_ACTION_MODIFY) /* Modify */
- etebase_item_set_content (items[ii], content[ii], strlen
(content[ii]));
- else if (action == E_ETESYNC_ITEM_ACTION_DELETE) /* Delete */
+ if (action == E_ETESYNC_ITEM_ACTION_MODIFY) {/* Modify */
+
+ if (is_memo) { /* notes */
+ ICalComponent *icomp;
+ const gchar *notes_item_content; /* notes_item_content is add
to support EteSync notes */
+
+ icomp = i_cal_component_new_from_string (content[ii]);
+ notes_item_content = i_cal_component_get_description (icomp);
+
+ etebase_item_metadata_set_name (item_metadata,
i_cal_component_get_summary (icomp));
+ etebase_item_set_meta (items[ii], item_metadata);
+
+ etebase_item_set_content (items[ii], notes_item_content ?
notes_item_content : "", notes_item_content ? strlen (notes_item_content) : 0);
+
+ g_object_unref (icomp);
+ } else { /* Events and Tasks */
+ etebase_item_set_content (items[ii], content[ii], strlen
(content[ii]));
+ }
+ } else if (action == E_ETESYNC_ITEM_ACTION_DELETE) /* Delete */
etebase_item_delete (items[ii]);
g_free (item_cache_b64);
@@ -1041,8 +1198,8 @@ e_etesync_connection_batch_modify_delete_sync (EEteSyncConnection *connection,
EtebaseErrorCode etebase_error = etebase_error_get_code ();
/* This is used to check if the error was due to expired token, if so try to
get a new token, then try again */
- if (etebase_error == ETEBASE_ERROR_CODE_UNAUTHORIZED
- && e_etesync_connection_maybe_reconnect_sync (connection, backend,
cancellable, error)) {
+ if (etebase_error == ETEBASE_ERROR_CODE_UNAUTHORIZED &&
+ e_etesync_connection_maybe_reconnect_sync (connection, backend,
cancellable, error)) {
success = !etebase_item_manager_batch (item_mgr, (const EtebaseItem
**) items, ETEBASE_UTILS_C_ARRAY_LEN (items), NULL);
}
@@ -1074,6 +1231,7 @@ e_etesync_connection_batch_create_sync (EEteSyncConnection *connection,
{
EtebaseItemManager *item_mgr;
gboolean success = TRUE;
+ gboolean is_memo;
g_return_val_if_fail (connection != NULL, FALSE);
g_return_val_if_fail (col_obj != NULL, FALSE);
@@ -1083,6 +1241,7 @@ e_etesync_connection_batch_create_sync (EEteSyncConnection *connection,
g_rec_mutex_lock (&connection->priv->connection_lock);
+ is_memo = e_etesync_connection_backend_is_for_memos (backend);
item_mgr = etebase_collection_manager_get_item_manager (connection->priv->col_mgr, col_obj);
if (item_mgr) {
@@ -1094,20 +1253,36 @@ e_etesync_connection_batch_create_sync (EEteSyncConnection *connection,
for (ii = 0; ii < content_len; ii++) {
EtebaseItemMetadata *item_metadata = NULL;
- gchar *data_uid = NULL, *revision = NULL;
+ gchar *data_uid = NULL, *revision = NULL, *notes_item_content = NULL; /*
notes_item_content is add to support EteSync notes */
gchar *item_cache_b64;
if (type == E_ETESYNC_ADDRESSBOOK) /* Contact */
e_etesync_utils_get_contact_uid_revision (content[ii], &data_uid, &revision);
- else if (type == E_ETESYNC_CALENDAR) /* Calendar */
- e_etesync_utils_get_component_uid_revision (content[ii], &data_uid,
&revision);
+ else if (type == E_ETESYNC_CALENDAR) { /* Calendar */
+ if (is_memo) { /* Notes */
+ ICalComponent *icomp = i_cal_component_new_from_string (content[ii]);
+
+ data_uid = g_strdup (i_cal_component_get_summary (icomp));
+ notes_item_content = g_strdup (i_cal_component_get_description
(icomp));
+
+ g_object_unref (icomp);
+ } else { /* Events and Tasks */
+ e_etesync_utils_get_component_uid_revision (content[ii], &data_uid,
&revision);
+ }
+ }
item_metadata = etebase_item_metadata_new ();
etebase_item_metadata_set_name (item_metadata, data_uid);
etebase_item_metadata_set_mtime (item_metadata, &now);
- items[ii] = etebase_item_manager_create (item_mgr, item_metadata, content[ii], strlen
(content[ii]));
+ if (is_memo) { /* Notes */
+ items[ii] = etebase_item_manager_create (item_mgr, item_metadata,
notes_item_content ? notes_item_content : "", notes_item_content ? strlen (notes_item_content) : 0);
+ g_free (notes_item_content);
+ } else { /* Addressbook, Calendar, Task */
+ items[ii] = etebase_item_manager_create (item_mgr, item_metadata,
content[ii], strlen (content[ii]));
+ }
+
item_cache_b64 = e_etesync_utils_etebase_item_to_base64 (items[ii], item_mgr);
if (type == E_ETESYNC_ADDRESSBOOK) { /* Contact */
@@ -1118,6 +1293,11 @@ e_etesync_connection_batch_create_sync (EEteSyncConnection *connection,
} else if (type == E_ETESYNC_CALENDAR) { /* Calendar */
ECalMetaBackendInfo *nfo;
+ if (is_memo) { /* Notes */
+ g_free (data_uid);
+ data_uid = g_strdup (etebase_item_get_uid (items[ii]));
+ }
+
nfo = e_cal_meta_backend_info_new (data_uid, revision, content[ii],
item_cache_b64);
*out_batch_info = g_slist_prepend (*out_batch_info, nfo);
}
@@ -1133,8 +1313,8 @@ e_etesync_connection_batch_create_sync (EEteSyncConnection *connection,
EtebaseErrorCode etebase_error = etebase_error_get_code ();
/* This is used to check if the error was due to expired token, if so try to get a
new token, then try again */
- if (etebase_error == ETEBASE_ERROR_CODE_UNAUTHORIZED
- && e_etesync_connection_maybe_reconnect_sync (connection, backend,
cancellable, error)) {
+ if (etebase_error == ETEBASE_ERROR_CODE_UNAUTHORIZED &&
+ e_etesync_connection_maybe_reconnect_sync (connection, backend, cancellable,
error)) {
success = !etebase_item_manager_batch (item_mgr, (const EtebaseItem **)
items, ETEBASE_UTILS_C_ARRAY_LEN (items), NULL);
}
@@ -1159,13 +1339,14 @@ e_etesync_connection_batch_modify_sync (EEteSyncConnection *connection,
const EtebaseCollection *col_obj,
const EteSyncType type,
const gchar *const *content,
+ const gchar *const *data_uids,
guint content_len,
ECache *cache,
GSList **out_batch_info,
GCancellable *cancellable,
GError **error)
{
- return e_etesync_connection_batch_modify_delete_sync (connection, backend, col_obj,
E_ETESYNC_ITEM_ACTION_MODIFY, type, content, content_len, cache, out_batch_info, cancellable, error);
+ return e_etesync_connection_batch_modify_delete_sync (connection, backend, col_obj,
E_ETESYNC_ITEM_ACTION_MODIFY, type, content, data_uids, content_len, cache, out_batch_info, cancellable,
error);
}
gboolean
@@ -1174,13 +1355,14 @@ e_etesync_connection_batch_delete_sync (EEteSyncConnection *connection,
const EtebaseCollection *col_obj,
const EteSyncType type,
const gchar *const *content,
+ const gchar *const *data_uids,
guint content_len,
ECache *cache,
GSList **out_batch_info,
GCancellable *cancellable,
GError **error)
{
- return e_etesync_connection_batch_modify_delete_sync (connection, backend, col_obj,
E_ETESYNC_ITEM_ACTION_DELETE, type, content, content_len, cache, out_batch_info, cancellable, error);
+ return e_etesync_connection_batch_modify_delete_sync (connection, backend, col_obj,
E_ETESYNC_ITEM_ACTION_DELETE, type, content, data_uids, content_len, cache, out_batch_info, cancellable,
error);
}
/*----------------------------GObject functions----------------------*/
diff --git a/src/common/e-etesync-connection.h b/src/common/e-etesync-connection.h
index ea2291d..5b5c9bd 100644
--- a/src/common/e-etesync-connection.h
+++ b/src/common/e-etesync-connection.h
@@ -129,6 +129,7 @@ gboolean e_etesync_connection_item_upload_sync
const gchar *content,
const gchar *uid,
const gchar *extra,
+ gchar **out_new_uid,
gchar **out_new_extra,
GCancellable *cancellable,
GError **error);
@@ -148,6 +149,7 @@ gboolean e_etesync_connection_batch_modify_sync
const EtebaseCollection *col_obj,
const EteSyncType type,
const gchar *const *content,
+ const gchar *const *data_uids,
guint content_len,
ECache *cache,
GSList **out_batch_info,
@@ -159,6 +161,7 @@ gboolean e_etesync_connection_batch_delete_sync
const EtebaseCollection *col_obj,
const EteSyncType type,
const gchar *const *content,
+ const gchar *const *data_uids,
guint content_len,
ECache *cache,
GSList **out_batch_info,
diff --git a/src/common/e-etesync-defines.h b/src/common/e-etesync-defines.h
index 1a48db8..9630cf4 100644
--- a/src/common/e-etesync-defines.h
+++ b/src/common/e-etesync-defines.h
@@ -24,6 +24,7 @@ typedef enum {
#define E_ETESYNC_COLLECTION_TYPE_CALENDAR "etebase.vevent"
#define E_ETESYNC_COLLECTION_TYPE_ADDRESS_BOOK "etebase.vcard"
#define E_ETESYNC_COLLECTION_TYPE_TASKS "etebase.vtodo"
+#define E_ETESYNC_COLLECTION_TYPE_NOTES "etebase.md.note"
#define E_ETESYNC_COLLECTION_DEFAULT_COLOR "#8BC34A"
diff --git a/src/common/e-etesync-utils.c b/src/common/e-etesync-utils.c
index 6752c07..fa1f62e 100644
--- a/src/common/e-etesync-utils.c
+++ b/src/common/e-etesync-utils.c
@@ -15,11 +15,13 @@
static const gchar *const collection_supported_types[] = {
E_ETESYNC_COLLECTION_TYPE_ADDRESS_BOOK,
E_ETESYNC_COLLECTION_TYPE_CALENDAR,
- E_ETESYNC_COLLECTION_TYPE_TASKS };
+ E_ETESYNC_COLLECTION_TYPE_TASKS,
+ E_ETESYNC_COLLECTION_TYPE_NOTES};
static const gchar *const collection_supported_types_default_names[] = {
"My Contacts",
"My Calendar",
- "My Tasks" };
+ "My Tasks",
+ "My Notes"};
void
e_etesync_utils_get_time_now (time_t *now)
@@ -47,6 +49,7 @@ e_etesync_utils_get_component_uid_revision (const gchar *content,
ICalComponentKind kind = i_cal_component_isa (subcomp);
if (kind == I_CAL_VEVENT_COMPONENT ||
+ kind == I_CAL_VJOURNAL_COMPONENT ||
kind == I_CAL_VTODO_COMPONENT) {
if (!*out_component_uid){
*out_component_uid = g_strdup (i_cal_component_get_uid (subcomp));
diff --git a/src/common/e-etesync-utils.h b/src/common/e-etesync-utils.h
index 11e35bb..6b5311f 100644
--- a/src/common/e-etesync-utils.h
+++ b/src/common/e-etesync-utils.h
@@ -11,7 +11,15 @@
#include <libedataserver/libedataserver.h>
#include <etebase.h>
-#define EETESYNC_UTILS_SUPPORTED_TYPES_SIZE 3
+#define EETESYNC_UTILS_SUPPORTED_TYPES_SIZE 4
+
+/* Collection indexs in 'collection_supported_types' */
+enum {
+ COLLECTION_INDEX_TYPE_ADDRESSBOOK,
+ COLLECTION_INDEX_TYPE_CALENDAR,
+ COLLECTION_INDEX_TYPE_TASKS,
+ COLLECTION_INDEX_TYPE_NOTES
+};
G_BEGIN_DECLS
diff --git a/src/evolution/e-cal-config-etesync.c b/src/evolution/e-cal-config-etesync.c
index f29952f..bb07fd5 100644
--- a/src/evolution/e-cal-config-etesync.c
+++ b/src/evolution/e-cal-config-etesync.c
@@ -35,6 +35,7 @@ cal_config_etesync_allow_creation (ESourceConfigBackend *backend)
switch (source_type) {
case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
allow_creation = TRUE;
break;
@@ -90,6 +91,11 @@ cal_config_etesync_commit_changes (ESourceConfigBackend *backend,
col_type = E_ETESYNC_COLLECTION_TYPE_TASKS;
}
+ if (e_source_has_extension (scratch_source, E_SOURCE_EXTENSION_MEMO_LIST)) {
+ extension_name = E_SOURCE_EXTENSION_MEMO_LIST;
+ col_type = E_ETESYNC_COLLECTION_TYPE_NOTES;
+ }
+
if (col_type) {
ESourceBackend *source_backend;
ESourceEteSync *etesync_extension;
diff --git a/src/evolution/e-etesync-config-lookup.c b/src/evolution/e-etesync-config-lookup.c
index e09215e..dc8e161 100644
--- a/src/evolution/e-etesync-config-lookup.c
+++ b/src/evolution/e-etesync-config-lookup.c
@@ -76,7 +76,7 @@ etesync_config_lookup_worker_result (EConfigLookupWorker *lookup_worker,
E_CONFIG_LOOKUP_RESULT_PRIORITY_POP3,
TRUE, "etesync",
_("EteSync account"),
- _("EteSync end-to-end encrypts your contacts, calendars and tasks."),
+ _("EteSync end-to-end encrypts your contacts, calendars, memos and tasks."),
params && e_named_parameters_exists (params, E_CONFIG_LOOKUP_PARAM_PASSWORD) &&
e_named_parameters_exists (params, E_CONFIG_LOOKUP_PARAM_REMEMBER_PASSWORD) ?
e_named_parameters_get (params, E_CONFIG_LOOKUP_PARAM_PASSWORD) : NULL);
diff --git a/src/registry/e-etesync-backend.c b/src/registry/e-etesync-backend.c
index d2d4423..868e526 100644
--- a/src/registry/e-etesync-backend.c
+++ b/src/registry/e-etesync-backend.c
@@ -60,10 +60,11 @@ etesync_backend_update_enabled (ESource *data_source,
if (e_source_has_extension (data_source, E_SOURCE_EXTENSION_CALENDAR) ||
e_source_has_extension (data_source, E_SOURCE_EXTENSION_TASK_LIST) ||
+ e_source_has_extension (data_source, E_SOURCE_EXTENSION_MEMO_LIST) ||
e_source_has_extension (data_source, E_SOURCE_EXTENSION_ADDRESS_BOOK)) {
- part_enabled = !collection_extension
- || e_source_collection_get_calendar_enabled (collection_extension)
- || e_source_collection_get_contacts_enabled (collection_extension);
+ part_enabled = !collection_extension ||
+ e_source_collection_get_calendar_enabled (collection_extension) ||
+ e_source_collection_get_contacts_enabled (collection_extension);
}
e_source_set_enabled (data_source, part_enabled);
@@ -152,6 +153,8 @@ etesync_backend_new_child (EEteSyncBackend *backend,
extension_name = E_SOURCE_EXTENSION_TASK_LIST;
} else if (g_str_equal (type, E_ETESYNC_COLLECTION_TYPE_ADDRESS_BOOK)) {
extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+ } else if (g_str_equal (type, E_ETESYNC_COLLECTION_TYPE_NOTES)) {
+ extension_name = E_SOURCE_EXTENSION_MEMO_LIST;
} else {
g_object_unref (source);
return NULL;
@@ -251,8 +254,10 @@ etesync_check_create_modify (EEteSyncBackend *backend,
extension_name = E_SOURCE_EXTENSION_CALENDAR;
if (e_source_has_extension (source, E_SOURCE_EXTENSION_TASK_LIST))
extension_name = E_SOURCE_EXTENSION_TASK_LIST;
+ if (e_source_has_extension (source, E_SOURCE_EXTENSION_MEMO_LIST))
+ extension_name = E_SOURCE_EXTENSION_MEMO_LIST;
- /* If extention_name has be set then this is a calendar or task which both have colors
+ /* If extention_name has be set then this is a calendar or task or a memo which the three
have colors
address-book doesn't have color */
if (extension_name) {
source_backend = e_source_get_extension (source, extension_name);
@@ -499,28 +504,49 @@ etesync_backend_sync_folders_sync (EEteSyncBackend *backend,
if (is_first_time) {
EtebaseCollectionListResponse *col_list;
EtebaseFetchOptions *fetch_options;
+ const gchar *const *collection_supported_types;
+ const gchar *const *collection_supported_types_default_names;
+ gint ii;
fetch_options = etebase_fetch_options_new();
etebase_fetch_options_set_prefetch(fetch_options, ETEBASE_PREFETCH_OPTION_MEDIUM);
etebase_fetch_options_set_stoken (fetch_options, NULL);
etebase_fetch_options_set_limit (fetch_options, 1);
+ collection_supported_types = e_etesync_util_get_collection_supported_types ();
+ collection_supported_types_default_names =
e_etesync_util_get_collection_supported_types_default_names ();
+
+ /* Check default type (contacts, calendar and tasks)
+ First three types in `collection_supported_types` are contacts, calendar and tasks */
col_list = etebase_collection_manager_list_multi
(e_etesync_connection_get_collection_manager (connection),
-
e_etesync_util_get_collection_supported_types (),
- EETESYNC_UTILS_SUPPORTED_TYPES_SIZE,
+ collection_supported_types,
+ 3,
fetch_options);
if (etebase_collection_list_response_get_data_length (col_list) == 0) {
- gint ii = 0;
const gchar *temp_stoken;
- const gchar *const *collection_supported_types;
- const gchar *const *collection_supported_types_default_names;
- collection_supported_types = e_etesync_util_get_collection_supported_types ();
- collection_supported_types_default_names =
e_etesync_util_get_collection_supported_types_default_names ();
+ for (ii = COLLECTION_INDEX_TYPE_ADDRESSBOOK; ii <= COLLECTION_INDEX_TYPE_TASKS; ii++)
+ temp_stoken = etesync_backend_create_and_add_collection_sync (backend,
server, collection_supported_types[ii],
+
collection_supported_types_default_names[ii], cancellable);
+
+ if (temp_stoken) {
+ g_free (stoken);
+ stoken = g_strdup (temp_stoken);
+ }
+ }
+
+ /* Check (Notes) type */
+ etebase_collection_list_response_destroy (col_list);
+ col_list = etebase_collection_manager_list (e_etesync_connection_get_collection_manager
(connection),
+ E_ETESYNC_COLLECTION_TYPE_NOTES,
+ fetch_options);
+
+ if (etebase_collection_list_response_get_data_length (col_list) == 0) {
+ const gchar *temp_stoken;
- for (ii = 0; ii < EETESYNC_UTILS_SUPPORTED_TYPES_SIZE; ii++)
- temp_stoken = etesync_backend_create_and_add_collection_sync (backend,
server, collection_supported_types[ii], collection_supported_types_default_names[ii], cancellable);
+ temp_stoken = etesync_backend_create_and_add_collection_sync (backend, server,
collection_supported_types[COLLECTION_INDEX_TYPE_NOTES],
+
collection_supported_types_default_names[COLLECTION_INDEX_TYPE_NOTES], cancellable);
if (temp_stoken) {
g_free (stoken);
@@ -580,16 +606,15 @@ etesync_backend_create_resource_sync (ECollectionBackend *backend,
if (e_source_has_extension (source, E_SOURCE_EXTENSION_ADDRESS_BOOK)) {
extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
col_type = E_ETESYNC_COLLECTION_TYPE_ADDRESS_BOOK;
- }
-
- if (e_source_has_extension (source, E_SOURCE_EXTENSION_CALENDAR)) {
+ } else if (e_source_has_extension (source, E_SOURCE_EXTENSION_CALENDAR)) {
extension_name = E_SOURCE_EXTENSION_CALENDAR;
col_type = E_ETESYNC_COLLECTION_TYPE_CALENDAR;
- }
-
- if (e_source_has_extension (source, E_SOURCE_EXTENSION_TASK_LIST)) {
+ } else if (e_source_has_extension (source, E_SOURCE_EXTENSION_TASK_LIST)) {
extension_name = E_SOURCE_EXTENSION_TASK_LIST;
col_type = E_ETESYNC_COLLECTION_TYPE_TASKS;
+ } else if (e_source_has_extension (source, E_SOURCE_EXTENSION_MEMO_LIST)) {
+ extension_name = E_SOURCE_EXTENSION_MEMO_LIST;
+ col_type = E_ETESYNC_COLLECTION_TYPE_NOTES;
}
if (col_type == NULL) {
@@ -756,8 +781,8 @@ etesync_backend_source_removed_cb (ESourceRegistryServer *server,
connection = e_etesync_connection_new (source);
/* Get credentials and set connection object, then use the connection object to logout */
- if (e_etesync_service_lookup_credentials_sync (collection_uid, &credentials, NULL, NULL)
- && e_etesync_connection_set_connection_from_sources (connection, credentials)) {
+ if (e_etesync_service_lookup_credentials_sync (collection_uid, &credentials, NULL, NULL) &&
+ e_etesync_connection_set_connection_from_sources (connection, credentials)) {
etebase_account_logout (e_etesync_connection_get_etebase_account (connection));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]