[evolution-kolab/ek-wip-porting] kolab-util-{contact, backend}: moved util functions
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting] kolab-util-{contact, backend}: moved util functions
- Date: Fri, 16 Mar 2012 19:14:23 +0000 (UTC)
commit e600cf3c76887c1d23c60ea7b2d6fa5308ad1ac7
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Fri Mar 16 20:08:03 2012 +0100
kolab-util-{contact,backend}: moved util functions
* moved the KolamMailAccess operational mode switcher
util functions from the addressbook to libekolab
* these functions will be used by the calendar backend
as well
src/addressbook/kolab-util-contact.c | 61 -----------------------
src/addressbook/kolab-util-contact.h | 9 +---
src/libekolab/kolab-util-backend.c | 91 +++++++++++++++++++++++++++++++++-
src/libekolab/kolab-util-backend.h | 23 +++++++-
4 files changed, 112 insertions(+), 72 deletions(-)
---
diff --git a/src/addressbook/kolab-util-contact.c b/src/addressbook/kolab-util-contact.c
index b83b369..d86884c 100644
--- a/src/addressbook/kolab-util-contact.c
+++ b/src/addressbook/kolab-util-contact.c
@@ -68,67 +68,6 @@ kolab_util_contact_gen_uid_if_none (EContact **contact)
}
-KolabMailAccessOpmodeID
-kolab_util_contact_deploy_mode_by_koma (KolabMailAccess *koma,
- KolabMailAccessOpmodeID koma_mode,
- GCancellable *cancellable,
- GError **error)
-{
- KolabMailAccessOpmodeID tmp_mode;
- GError *tmp_error = NULL;
- gboolean ok;
-
- g_debug ("%s()[%u] called.", __func__, __LINE__);
-
- if (koma == NULL) {
- g_debug ("%s()[%u] error: KolabMailAccess object not existent.",
- __func__, __LINE__);
- /* FIXME set GError */
- return KOLAB_MAIL_ACCESS_OPMODE_INVAL;
- }
- tmp_mode = kolab_mail_access_get_opmode (koma,
- &tmp_error);
- if (error != NULL) {
- g_propagate_error (error, tmp_error);
- return KOLAB_MAIL_ACCESS_OPMODE_INVAL;
- }
- if (tmp_mode < KOLAB_MAIL_ACCESS_OPMODE_OFFLINE) {
- g_debug ("%s()[%u] KolabMailAccess object not ready, deferring.",
- __func__, __LINE__);
- return tmp_mode;
- }
- ok = kolab_mail_access_set_opmode (koma,
- koma_mode,
- cancellable,
- &tmp_error);
- if (! ok) {
- g_propagate_error (error, tmp_error);
- return KOLAB_MAIL_ACCESS_OPMODE_INVAL;
- }
- return koma_mode;
-} /* kolab_util_contacts_deploy_by_koma_mode () */
-
-#if 0
-gboolean
-kolab_util_contact_deploy_mode_by_backend (KolabMailAccess *koma,
- GNOME_Evolution_Addressbook_BookMode backend_mode)
-{
- KolabMailAccessOpmodeID koma_mode;
- KolabMailAccessOpmodeID tmp_mode;
-
- switch (backend_mode) {
- case GNOME_Evolution_Addressbook_MODE_LOCAL:
- koma_mode = KOLAB_MAIL_ACCESS_OPMODE_OFFLINE;
- break;
- default:
- koma_mode = KOLAB_MAIL_ACCESS_OPMODE_ONLINE;
- }
- tmp_mode = kolab_util_contact_deploy_mode_by_koma (koma, koma_mode);
-
- return tmp_mode == koma_mode;
-}
-#endif
-
gboolean
kolab_util_contact_store (EContact *econtact,
KolabMailAccess *koma,
diff --git a/src/addressbook/kolab-util-contact.h b/src/addressbook/kolab-util-contact.h
index 33d68fa..1e37ced 100644
--- a/src/addressbook/kolab-util-contact.h
+++ b/src/addressbook/kolab-util-contact.h
@@ -40,6 +40,8 @@
#include <libekolab/kolab-mail-access.h>
+#include "e-book-backend-kolab.h"
+
/*----------------------------------------------------------------------------*/
G_BEGIN_DECLS
@@ -50,12 +52,6 @@ kolab_util_contact_has_id (EContact *contact);
void
kolab_util_contact_gen_uid_if_none (EContact **contact);
-KolabMailAccessOpmodeID
-kolab_util_contact_deploy_mode_by_koma (KolabMailAccess *koma,
- KolabMailAccessOpmodeID koma_mode,
- GCancellable *cancellable,
- GError **error);
-
gboolean
kolab_util_contact_store (EContact *econtact,
KolabMailAccess *koma,
@@ -64,7 +60,6 @@ kolab_util_contact_store (EContact *econtact,
GError **error);
#if 0
-gboolean kolab_util_contact_deploy_mode_by_backend (KolabMailAccess *koma, GNOME_Evolution_Addressbook_BookMode backend_mode);
EBookBackendSyncStatus kolab_util_contact_map_error (GError *error);
#endif
diff --git a/src/libekolab/kolab-util-backend.c b/src/libekolab/kolab-util-backend.c
index 91a5a81..b354a90 100644
--- a/src/libekolab/kolab-util-backend.c
+++ b/src/libekolab/kolab-util-backend.c
@@ -38,7 +38,6 @@
#include <libekolabutil/camel-system-headers.h>
#include <libekolabutil/kolab-util-camel.h>
-#include "kolab-types.h"
#include "kolab-mail-access.h"
#include "kolab-util-backend.h"
@@ -585,3 +584,93 @@ kolab_util_backend_account_uid_new_from_settings (KolabSettingsHandler *ksetting
return account_uid;
}
+
+KolabMailAccessOpmodeID
+kolab_util_backend_deploy_mode_by_koma (KolabMailAccess *koma,
+ KolabMailAccessOpmodeID koma_mode,
+ GCancellable *cancellable,
+ GError **error)
+{
+ KolabMailAccessOpmodeID tmp_mode = KOLAB_MAIL_ACCESS_OPMODE_INVAL;
+ GError *tmp_err = NULL;
+ gboolean ok = FALSE;
+
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
+
+ if (koma != NULL) g_assert (KOLAB_IS_MAIL_ACCESS (koma));
+ g_assert (koma_mode < KOLAB_MAIL_ACCESS_LAST_OPMODE);
+ /* cancellable may be NULL */
+ g_return_val_if_fail (error == NULL || *error == NULL, KOLAB_MAIL_ACCESS_OPMODE_INVAL);
+
+ if (koma == NULL) {
+ g_debug ("%s()[%u] error: KolabMailAccess object not existent.",
+ __func__, __LINE__);
+ /* FIXME set GError */
+ return KOLAB_MAIL_ACCESS_OPMODE_INVAL;
+ }
+
+ /* get current KolabMailAccess operational mode */
+ tmp_mode = kolab_mail_access_get_opmode (koma, &tmp_err);
+ if (tmp_err != NULL) {
+ g_propagate_error (error, tmp_err);
+ return KOLAB_MAIL_ACCESS_OPMODE_INVAL;
+ }
+ if (tmp_mode < KOLAB_MAIL_ACCESS_OPMODE_OFFLINE) {
+ g_debug ("%s()[%u] KolabMailAccess object not ready, deferring.",
+ __func__, __LINE__);
+ return tmp_mode;
+ }
+
+ /* set new KolabMailAccess operational mode */
+ ok = kolab_mail_access_set_opmode (koma,
+ koma_mode,
+ cancellable,
+ &tmp_err);
+ if (! ok) {
+ g_propagate_error (error, tmp_err);
+ return KOLAB_MAIL_ACCESS_OPMODE_INVAL;
+ }
+
+ return koma_mode;
+}
+
+gboolean
+kolab_util_backend_deploy_mode_by_backend (KolabMailAccess *koma,
+ gboolean online,
+ GCancellable *cancellable,
+ GError **error)
+{
+ KolabMailAccessOpmodeID koma_mode = KOLAB_MAIL_ACCESS_OPMODE_INVAL;
+ KolabMailAccessOpmodeID tmp_mode = KOLAB_MAIL_ACCESS_OPMODE_INVAL;
+ GError *tmp_err = NULL;
+
+ g_debug ("%s()[%u] called.", __func__, __LINE__);
+
+ if (koma != NULL) g_assert (KOLAB_IS_MAIL_ACCESS (koma));
+ g_assert (koma_mode < KOLAB_MAIL_ACCESS_LAST_OPMODE);
+ /* cancellable may be NULL */
+ g_return_val_if_fail (error == NULL || *error == NULL, KOLAB_MAIL_ACCESS_OPMODE_INVAL);
+
+ if (koma == NULL) {
+ g_debug ("%s()[%u] error: KolabMailAccess object not existent.",
+ __func__, __LINE__);
+ /* FIXME set GError */
+ return KOLAB_MAIL_ACCESS_OPMODE_INVAL;
+ }
+
+ switch (online) {
+ case FALSE:
+ koma_mode = KOLAB_MAIL_ACCESS_OPMODE_OFFLINE;
+ break;
+ default:
+ koma_mode = KOLAB_MAIL_ACCESS_OPMODE_ONLINE;
+ }
+ tmp_mode = kolab_util_backend_deploy_mode_by_koma (koma,
+ koma_mode,
+ cancellable,
+ &tmp_err);
+ if (tmp_err != NULL)
+ g_propagate_error (error, tmp_err);
+
+ return tmp_mode == koma_mode;
+}
diff --git a/src/libekolab/kolab-util-backend.h b/src/libekolab/kolab-util-backend.h
index 71f1805..a1be082 100644
--- a/src/libekolab/kolab-util-backend.h
+++ b/src/libekolab/kolab-util-backend.h
@@ -31,9 +31,7 @@
/*----------------------------------------------------------------------------*/
#include <glib.h>
-
-#include "kolab-settings-handler.h"
-#include "kolab-types.h"
+#include <gio/gio.h>
#include <libebook/e-contact.h>
#include <libecal/e-cal-component.h>
@@ -42,6 +40,13 @@
#include <libekolabutil/camel-system-headers.h>
#include <libekolabutil/kolab-util-sqlite.h>
+#include "kolab-settings-handler.h"
+#include "kolab-types.h"
+#include "kolab-backend-types.h"
+
+/*----------------------------------------------------------------------------*/
+
+struct _KolabMailAccess;
/*----------------------------------------------------------------------------*/
/* GError for libekolabbackend */
@@ -91,6 +96,18 @@ const gchar* kolab_util_backend_get_tls_variant_desc (KolabTLSVariantID id);
CamelURL* kolab_util_backend_camel_url_new_from_settings (KolabSettingsHandler *ksettings, GError **err);
gchar* kolab_util_backend_account_uid_new_from_settings (KolabSettingsHandler *ksettings, GError **err);
+KolabMailAccessOpmodeID
+kolab_util_backend_deploy_mode_by_koma (struct _KolabMailAccess *koma,
+ KolabMailAccessOpmodeID koma_mode,
+ GCancellable *cancellable,
+ GError **error);
+
+gboolean
+kolab_util_backend_deploy_mode_by_backend (struct _KolabMailAccess *koma,
+ gboolean online,
+ GCancellable *cancellable,
+ GError **error);
+
/*----------------------------------------------------------------------------*/
#endif /* _KOLAB_UTIL_BACKEND_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]