[evolution-kolab/ek-wip-porting] ECalBackendKolab: added backend property getter implementation



commit fdde08ac8c26ec830d44c2c73d01e824ef5cf5ec
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Fri Mar 16 10:52:40 2012 +0100

    ECalBackendKolab: added backend property getter implementation
    
    * implemented the getter for backend properties
      which are not covered by the parent class
    * the implementation is a modified dupe of the
      respective evolution-mapi function
    * may need tuning wrt. the capabilities reported

 src/calendar/e-cal-backend-kolab.c |   85 ++++++++++++++++++++++++++++++------
 1 files changed, 71 insertions(+), 14 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-kolab.c b/src/calendar/e-cal-backend-kolab.c
index bf194c9..5b8f7f6 100644
--- a/src/calendar/e-cal-backend-kolab.c
+++ b/src/calendar/e-cal-backend-kolab.c
@@ -106,18 +106,18 @@ e_cal_backend_kolab_open (ECalBackendSync *backend,
 	ECalBackendKolab *self = NULL;
 	ECalBackendKolabPrivate *priv = NULL;
 	ESource *esource = NULL;
-        CamelURL *c_url = NULL;
-        KolabSettingsHandler *ksettings = NULL;
-        KolabMailAccess *tmp_koma = NULL;
-        KolabSyncStrategyID sync_value = KOLAB_SYNC_STRATEGY_DEFAULT;
-        KolabMailAccessOpmodeID tmp_mode = KOLAB_MAIL_ACCESS_OPMODE_INVAL;
-        icalcomponent_kind icalkind = ICAL_VEVENT_COMPONENT;
-        gchar *sourcename = NULL;
-        gchar *servername = NULL;
-        gchar *username = NULL;
-        gchar *user_at_server = NULL;
-        gchar *tmp_key = NULL;
-        const gchar *prop_str = NULL;
+	CamelURL *c_url = NULL;
+	KolabSettingsHandler *ksettings = NULL;
+	KolabMailAccess *tmp_koma = NULL;
+	KolabSyncStrategyID sync_value = KOLAB_SYNC_STRATEGY_DEFAULT;
+	KolabMailAccessOpmodeID tmp_mode = KOLAB_MAIL_ACCESS_OPMODE_INVAL;
+	icalcomponent_kind icalkind = ICAL_VEVENT_COMPONENT;
+	gchar *sourcename = NULL;
+	gchar *servername = NULL;
+	gchar *username = NULL;
+	gchar *user_at_server = NULL;
+	gchar *tmp_key = NULL;
+	const gchar *prop_str = NULL;
 	GError *tmp_err = NULL;
 	gboolean ok = FALSE;
 
@@ -301,6 +301,12 @@ e_cal_backend_kolab_open (ECalBackendSync *backend,
 		return;
 	}
 
+	/* TODO this is sort of hackish, we cannot be sure that
+	 *      'user server' is truly the Kolab email address
+	 *      of the Kolab user
+	 */
+	priv->user_email = g_strdup (user_at_server);
+
  notifications:
 	priv->already_opened = TRUE;
 #if 0 /* FIXME */
@@ -376,6 +382,9 @@ e_cal_backend_kolab_get_backend_property (ECalBackendSync *backend,
 {
 	ECalBackendKolab *self = NULL;
 	ECalBackendKolabPrivate *priv = NULL;
+	gboolean processed = TRUE;
+
+	/* this is a modified dupe of the respective mapi function */
 
 	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 	e_return_data_cal_error_val_if_fail (E_IS_CAL_BACKEND_KOLAB (backend), InvalidArg);
@@ -387,9 +396,57 @@ e_cal_backend_kolab_get_backend_property (ECalBackendSync *backend,
 	self = E_CAL_BACKEND_KOLAB (backend);
 	priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
 
-	g_error ("%s: FIXME implement me", __func__);
+	if (g_str_equal (prop_name, CLIENT_BACKEND_PROPERTY_CAPABILITIES)) {
+		*prop_value = g_strdup (CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT ","
+		                        CAL_STATIC_CAPABILITY_NO_AUDIO_ALARMS ","
+		                        CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS ","
+		                        CAL_STATIC_CAPABILITY_NO_PROCEDURE_ALARMS ","
+		                        CAL_STATIC_CAPABILITY_ONE_ALARM_ONLY ","
+		                        CAL_STATIC_CAPABILITY_REMOVE_ALARMS ","
+		                        CAL_STATIC_CAPABILITY_NO_THISANDFUTURE ","
+		                        CAL_STATIC_CAPABILITY_NO_THISANDPRIOR ","
+		                        CAL_STATIC_CAPABILITY_CREATE_MESSAGES ","
+		                        CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK ","
+		                        CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR ","
+		                        CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING ","
+		                        CAL_STATIC_CAPABILITY_REFRESH_SUPPORTED
+		                        );
+	} else if (g_str_equal (prop_name, CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS)) {
+		/* see the comment for user_email in e_cal_backend_kolab_open() ! */
+		*prop_value = g_strdup (priv->user_email);
+	} else if (g_str_equal (prop_name, CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS)) {
+		/* We don't support email alarms. This should not have been called. */
+		*prop_value = NULL;
+	} else if (g_str_equal (prop_name, CAL_BACKEND_PROPERTY_DEFAULT_OBJECT)) {
+		ECalComponent *comp;
+		GError *tmp_err = NULL;
+
+		comp = e_cal_component_new ();
+
+		switch (e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
+		case ICAL_VEVENT_COMPONENT:
+			e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
+			break;
+		case ICAL_VTODO_COMPONENT:
+			e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO);
+			break;
+		case ICAL_VJOURNAL_COMPONENT:
+			e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_JOURNAL);
+			break;
+		default:
+			g_object_unref (comp);
+			tmp_err = e_data_cal_create_error (ObjectNotFound, NULL);
+			g_propagate_error (error, tmp_err);
+			return TRUE;
+		}
 
-	return FALSE;
+		*prop_value = e_cal_component_get_as_string (comp);
+		g_object_unref (comp);
+	} else {
+		processed = FALSE; /* means chaining up the call to parent */
+	}
+
+	return processed;
 }
 
 static gboolean



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]