[evolution-data-server/libgdata-port] Eliminated the redundant EGoItem and cleaned up the code a little



commit bd900fc4d604581ad5ab9a47b84004eb88ead0e0
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Apr 25 18:03:01 2009 +0100

    Eliminated the redundant EGoItem and cleaned up the code a little
    
    EGoItem was confusing the communication between e-cal-backend-google.c and
    e-cal-backend-google-utils.c and served little purpose. The code has been
    cleaned up a little apart from this, and a few small improvements have been
    made to read-only mode.
---
 .../backends/google/e-cal-backend-google-utils.c   |  143 +++++++-------------
 .../backends/google/e-cal-backend-google-utils.h   |   10 +-
 calendar/backends/google/e-cal-backend-google.c    |  129 ++++++------------
 calendar/backends/google/e-cal-backend-google.h    |   14 +--
 4 files changed, 97 insertions(+), 199 deletions(-)

diff --git a/calendar/backends/google/e-cal-backend-google-utils.c b/calendar/backends/google/e-cal-backend-google-utils.c
index 5c9e074..fb826e8 100644
--- a/calendar/backends/google/e-cal-backend-google-utils.c
+++ b/calendar/backends/google/e-cal-backend-google-utils.c
@@ -60,19 +60,20 @@
 
 /****************************************************** Google Connection Helper Functions ***********************************************/
 
-static gboolean gd_timeval_to_ical (EGoItem *item, GTimeVal *timeval, struct icaltimetype *itt, ECalComponentDateTime *dt, icaltimezone *default_zone);
+static gboolean gd_timeval_to_ical (GDataEntry *entry, GTimeVal *timeval, struct icaltimetype *itt, ECalComponentDateTime *dt,
+				    icaltimezone *default_zone);
 static void get_timeval (ECalComponentDateTime dt, GTimeVal *timeval);
 static gint utils_compare_ids (gconstpointer cache_id, gconstpointer modified_cache_id);
 static gchar * utils_form_query (const gchar *query);
 static gboolean get_deltas_timeout (gpointer cbgo);
-static void utils_update_insertion (ECalBackendGoogle *cbgo, ECalBackendCache *cache, EGoItem *item, GSList *cache_keys);
+static void utils_update_insertion (ECalBackendGoogle *cbgo, ECalBackendCache *cache, GDataFeed *feed, GSList *cache_keys);
 static void utils_update_deletion (ECalBackendGoogle *cbgo, ECalBackendCache *cache, GSList *cache_keys);
 
 /**
  *
  * e_cal_backend_google_utils_populate_cache:
  * @cbgo ECalBackendGoogle Object
- * Populates the cache with intial values
+ * Populates the cache with initial values
  *
  **/
 static void
@@ -80,7 +81,7 @@ e_cal_backend_google_utils_populate_cache (ECalBackendGoogle *cbgo)
 {
 	ECalComponent *comp=NULL;
 	ECalBackendCache *cache;
-	EGoItem *item;
+	GDataFeed *feed;
 	ECalBackendGooglePrivate *priv;
 	icalcomponent_kind kind;
 	icaltimetype temp;
@@ -90,13 +91,12 @@ e_cal_backend_google_utils_populate_cache (ECalBackendGoogle *cbgo)
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND(cbgo));
 	temp = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
 
- 	item = e_cal_backend_google_get_item (cbgo);
-	entries = gdata_feed_get_entries (item->feed);
+	feed = e_cal_backend_google_get_feed (cbgo);
+	entries = gdata_feed_get_entries (feed);
 	priv = cbgo->priv;
 
 	for (list = entries; list != NULL; list = list->next) {
-		item->entry = GDATA_ENTRY(list->data);
-		comp = e_go_item_to_cal_component (item, cbgo);
+		comp = e_gdata_entry_to_cal_component (GDATA_ENTRY(list->data), cbgo);
 		if (comp && E_IS_CAL_COMPONENT(comp)) {
 			gchar *comp_str;
 			e_cal_component_commit_sequence (comp);
@@ -169,7 +169,7 @@ e_cal_backend_google_utils_update (gpointer handle)
 {
 	ECalBackendGoogle *cbgo;
 	ECalBackendGooglePrivate *priv;
-	EGoItem *item;
+	GDataFeed *feed;
 	GError *error = NULL;
 
 	ECalBackendCache *cache;
@@ -194,20 +194,20 @@ e_cal_backend_google_utils_update (gpointer handle)
 	priv = cbgo->priv;
 
 	cache = e_cal_backend_google_get_cache (cbgo);
-	item =  e_cal_backend_google_get_item (cbgo);
 	service = GDATA_SERVICE (e_cal_backend_google_get_service (cbgo));
 	uri = e_cal_backend_google_get_uri (cbgo);
 
-	item->feed = gdata_service_query (GDATA_SERVICE(service), uri, NULL, GDATA_TYPE_CALENDAR_EVENT, NULL, NULL, NULL, &error);
+	feed = gdata_service_query (GDATA_SERVICE(service), uri, NULL, GDATA_TYPE_CALENDAR_EVENT, NULL, NULL, NULL, &error);
 
-	if (item->feed == NULL) {
+	if (feed == NULL) {
 		g_warning ("Error querying Google Calendar %s: %s", uri, error->message);
 		g_error_free (error);
 		g_static_mutex_unlock (&updating);
 		return NULL;
 	}
 
-	entries_list = gdata_feed_get_entries (item->feed);
+	e_cal_backend_google_set_feed (cbgo, feed);
+	entries_list = gdata_feed_get_entries (feed);
 	cache_keys = e_cal_backend_cache_get_keys (cache);
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgo));
 
@@ -241,7 +241,7 @@ e_cal_backend_google_utils_update (gpointer handle)
 
 	/* Update the inserted entries */
 	if (needs_to_insert) {
-		utils_update_insertion (cbgo, cache, item, uid_list);
+		utils_update_insertion (cbgo, cache, feed, uid_list);
 		needs_to_insert = FALSE;
 	}
 
@@ -271,7 +271,6 @@ ECalBackendSyncStatus
 e_cal_backend_google_utils_connect (ECalBackendGoogle *cbgo)
 {
 	ECalBackendCache *cache;
-	EGoItem *item;
 	ESource *source;
 	GDataFeed *feed;
 	GDataCalendarService *service;
@@ -291,12 +290,14 @@ e_cal_backend_google_utils_connect (ECalBackendGoogle *cbgo)
 	service = gdata_calendar_service_new ("evolution-client-0.0.2");
 	e_cal_backend_google_set_service (cbgo, service);
 
+	/* Get the query URI */
+	/* TODO: Would be better as a GDataCalendarQuery */
 	suri = e_source_get_uri (source);
 	uri = utils_form_query (suri);
 	e_cal_backend_google_set_uri (cbgo, uri);
-
 	g_free (suri);
 
+	/* Authenticate with the service */
 	username = e_cal_backend_google_get_username (cbgo);
 	password = e_cal_backend_google_get_password (cbgo);
 	if (!gdata_service_authenticate (GDATA_SERVICE(service), username, password, NULL, NULL)) {
@@ -306,16 +307,13 @@ e_cal_backend_google_utils_connect (ECalBackendGoogle *cbgo)
 		return GNOME_Evolution_Calendar_AuthenticationRequired;
 	}
 
+	/* Query for calendar events */
 	feed = gdata_service_query (GDATA_SERVICE(service), uri, NULL, GDATA_TYPE_CALENDAR_EVENT, NULL, NULL, NULL, NULL);
 
-	item = g_new0 (EGoItem, 1);
-	item->entry = e_cal_backend_google_get_entry (cbgo);
-	item->feed = feed;
-
 	cache = e_cal_backend_google_get_cache (cbgo);
 	service = e_cal_backend_google_get_service (cbgo);
 
-	e_cal_backend_google_set_item (cbgo, item);
+	e_cal_backend_google_set_feed (cbgo, feed);
 
 	/* For event sync */
 	if (cache && service) {
@@ -383,18 +381,18 @@ e_cal_backend_google_utils_connect (ECalBackendGoogle *cbgo)
 
 }
 
-/*************************************************** EGoItem Functions*********************************************/
+/*************************************************** GDataEntry Functions*********************************************/
 
 /**
- * e_go_item_to_cal_component:
- * @item: an #EGoItem
+ * e_gdata_entry_to_cal_component:
+ * @entry: a #GDataEntry
  * @cbgo: an #ECalBackendGoogle
  *
- * Creates an #EGoItem from an #ECalComponent
+ * Creates an #ECalComponent from a #GDataEntry
  **/
 
 ECalComponent *
-e_go_item_to_cal_component (EGoItem *item, ECalBackendGoogle *cbgo)
+e_gdata_entry_to_cal_component (GDataEntry *entry, ECalBackendGoogle *cbgo)
 {
 	ECalComponent *comp;
 	ECalComponentText text;
@@ -417,7 +415,7 @@ e_go_item_to_cal_component (EGoItem *item, ECalBackendGoogle *cbgo)
 	e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
 
 	/* Description*/
-	description = gdata_entry_get_content (item->entry);
+	description = gdata_entry_get_content (entry);
 	if (description) {
 		GSList l;
 		text.value = description;
@@ -428,37 +426,37 @@ e_go_item_to_cal_component (EGoItem *item, ECalBackendGoogle *cbgo)
 	}
 
 	/* Creation/Last update */
-	gdata_entry_get_published (item->entry, &timeval);
-	if (gd_timeval_to_ical (item, &timeval, &itt, &dt, default_zone))
+	gdata_entry_get_published (entry, &timeval);
+	if (gd_timeval_to_ical (entry, &timeval, &itt, &dt, default_zone))
 		e_cal_component_set_created (comp, &itt);
 
-	gdata_entry_get_updated (item->entry, &timeval);
-	if (gd_timeval_to_ical (item, &timeval, &itt, &dt, default_zone))
+	gdata_entry_get_updated (entry, &timeval);
+	if (gd_timeval_to_ical (entry, &timeval, &itt, &dt, default_zone))
 		e_cal_component_set_dtstamp (comp, &itt);
 
 	/* Start/End times */
 	/* TODO: deal with multiple time periods */
-	gdata_calendar_event_get_primary_time (GDATA_CALENDAR_EVENT(item->entry), &timeval, &timeval2, NULL);
-	if (gd_timeval_to_ical (item, &timeval, &itt, &dt, default_zone))
+	gdata_calendar_event_get_primary_time (GDATA_CALENDAR_EVENT(entry), &timeval, &timeval2, NULL);
+	if (gd_timeval_to_ical (entry, &timeval, &itt, &dt, default_zone))
 		e_cal_component_set_dtstart (comp, &dt);
-	if (gd_timeval_to_ical (item, &timeval2, &itt, &dt, default_zone))
+	if (gd_timeval_to_ical (entry, &timeval2, &itt, &dt, default_zone))
 		e_cal_component_set_dtend (comp, &dt);
 
 	/* Summary of the Entry */
-	text.value = gdata_entry_get_title (item->entry);
+	text.value = gdata_entry_get_title (entry);
 	text.altrep = NULL;
 	if (text.value != NULL)
 		e_cal_component_set_summary (comp, &text);
 
 	/* Categories or Kinds */
 	category_ids = NULL;
-	category_ids = gdata_entry_get_categories (item->entry);
+	category_ids = gdata_entry_get_categories (entry);
 
-	uid = gdata_entry_get_id (item->entry);
+	uid = gdata_entry_get_id (entry);
 
 	/* Classification or Visibility */
 	temp = NULL;
-	temp = gdata_calendar_event_get_visibility (GDATA_CALENDAR_EVENT(item->entry));
+	temp = gdata_calendar_event_get_visibility (GDATA_CALENDAR_EVENT(entry));
 
 	if (strcmp (temp, "public") == 0)
 		e_cal_component_set_classification (comp, E_CAL_COMPONENT_CLASS_PUBLIC);
@@ -469,7 +467,7 @@ e_go_item_to_cal_component (EGoItem *item, ECalBackendGoogle *cbgo)
 	temp = NULL;
 
 	/* Transparency */
-	temp = gdata_calendar_event_get_transparency (GDATA_CALENDAR_EVENT(item->entry));
+	temp = gdata_calendar_event_get_transparency (GDATA_CALENDAR_EVENT(entry));
 	if (strcmp (temp, "http://schemas.google.com/g/2005#event.opaque";) == 0)
 		e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_OPAQUE);
 	else if (strcmp (temp, "http://schemas.google.com/g/2005#event.transparent";) == 0)
@@ -478,7 +476,7 @@ e_go_item_to_cal_component (EGoItem *item, ECalBackendGoogle *cbgo)
 		e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_UNKNOWN);
 
 	/* Attendees */
-	go_attendee_list = gdata_calendar_event_get_people (GDATA_CALENDAR_EVENT(item->entry));
+	go_attendee_list = gdata_calendar_event_get_people (GDATA_CALENDAR_EVENT(entry));
 
 	for (l = go_attendee_list; l != NULL; l = l->next) {
 		GDataGDWho *go_attendee;
@@ -520,7 +518,7 @@ e_go_item_to_cal_component (EGoItem *item, ECalBackendGoogle *cbgo)
 		e_cal_component_set_organizer (comp, org);
 
 	/* Location */
-	go_location_list = gdata_calendar_event_get_places (GDATA_CALENDAR_EVENT(item->entry));
+	go_location_list = gdata_calendar_event_get_places (GDATA_CALENDAR_EVENT(entry));
 
 	for (l = go_location_list; l != NULL; l = l->next) {
 		GDataGDWhere *go_location;
@@ -542,7 +540,7 @@ e_go_item_to_cal_component (EGoItem *item, ECalBackendGoogle *cbgo)
 	e_cal_component_set_dtend (comp, &dt);
 #endif
 
-	uid = gdata_entry_get_id (item->entry);
+	uid = gdata_entry_get_id (entry);
 	e_cal_component_set_uid (comp, (const char *)uid);
 	e_cal_component_commit_sequence (comp);
 
@@ -552,17 +550,16 @@ e_go_item_to_cal_component (EGoItem *item, ECalBackendGoogle *cbgo)
 
 /**
  *
- * e_go_item_from_cal_component:
+ * e_gdata_entry_from_cal_component:
  * @cbgo a ECalBackendGoogle
  * @comp a ECalComponent object
- * Creates a ECalComponent from EGoItem
+ * Creates a #GDataEntry from an #ECalComponent
  *
  **/
-EGoItem *
-e_go_item_from_cal_component (ECalBackendGoogle *cbgo, ECalComponent *comp)
+GDataEntry *
+e_gdata_entry_from_cal_component (ECalBackendGoogle *cbgo, ECalComponent *comp)
 {
 	ECalBackendGooglePrivate *priv;
-	EGoItem *item;
 	ECalComponentText text;
 	ECalComponentDateTime dt;
 	gchar *term = NULL;
@@ -582,7 +579,6 @@ e_go_item_from_cal_component (ECalBackendGoogle *cbgo, ECalComponent *comp)
 
 	e_cal_component_get_uid (comp, &uid);
 
-	item = g_new0 (EGoItem, 1);
 	entry = gdata_calendar_event_new (uid);
 
 	/* Summary */
@@ -663,41 +659,8 @@ e_go_item_from_cal_component (ECalBackendGoogle *cbgo, ECalComponent *comp)
 	}
 
 	/* FIXME For transparency and status */
-	item->entry = GDATA_ENTRY (entry);
-	return item;
-}
-
-/**
- *
- * e_go_item_get_entry:
- * @item a EGoItem
- * Returns the GDataEntry object
- *
- **/
-
-GDataEntry *
-e_go_item_get_entry (EGoItem *item)
-{
-	g_return_val_if_fail (item != NULL, NULL);
-	return item->entry;
-}
-
-
-/**
- *
- * e_go_item_set_entry:
- * @item  a EGoItem
- * @entry a GDataEntry
- * Sets the GDataEntry of EGoItem to entry
- *
- **/
-void
-e_go_item_set_entry (EGoItem *item, GDataEntry *entry)
-{
-	g_return_if_fail (item != NULL);
-	g_return_if_fail (entry != NULL);
 
-	item->entry = entry;
+	return GDATA_ENTRY (entry);
 }
 
 
@@ -719,22 +682,18 @@ utils_form_query (const gchar *query)
 }
 
 static void
-utils_update_insertion (ECalBackendGoogle *cbgo, ECalBackendCache *cache, EGoItem *item, GSList *uid_list)
+utils_update_insertion (ECalBackendGoogle *cbgo, ECalBackendCache *cache, GDataFeed *feed, GSList *uid_list)
 {
-	EGoItem *item_t;
 	ECalComponent *comp;
 	GSList *list = NULL;
 	GDataEntry *entry;
 	gchar *temp;
 
 	comp = e_cal_component_new ();
-	item_t = g_new0 (EGoItem, 1);
-	item_t->feed = item->feed;
 
 	for (list = uid_list; list != NULL; list = list->next) {
-		entry = gdata_feed_look_up_entry (item->feed, list->data);
-		item_t->entry = entry;
-		comp = e_go_item_to_cal_component (item_t, cbgo);
+		entry = gdata_feed_look_up_entry (feed, list->data);
+		comp = e_gdata_entry_to_cal_component (entry, cbgo);
 
 		if (comp) {
 			e_cal_component_commit_sequence (comp);
@@ -749,7 +708,6 @@ utils_update_insertion (ECalBackendGoogle *cbgo, ECalBackendCache *cache, EGoIte
 		}
 	}
 
-	g_free (item_t);
 	if (list)
 		g_slist_free (list);
 }
@@ -821,7 +779,7 @@ get_deltas_timeout (gpointer cbgo)
  *
  * gd_timeval_to_ical:
  * Helper Function to convert a gdata format date to ical date
- * @item item from which the time comes. It's used to get to the feed's timezone
+ * @entry entry from which the time comes. It's used to get to the entry's timezone
  * @timeval date as a #GTimeVal
  * @iit Resulting icaltimetype.
  * @dt Resulting ECalComponentDateTime.
@@ -830,8 +788,9 @@ get_deltas_timeout (gpointer cbgo)
  * @note Do not free itt or dt values, those come from buildin structures held by libical
  **/
 static gboolean
-gd_timeval_to_ical (EGoItem *item, GTimeVal *timeval, struct icaltimetype *itt, ECalComponentDateTime *dt, icaltimezone *default_zone)
+gd_timeval_to_ical (GDataEntry *entry, GTimeVal *timeval, struct icaltimetype *itt, ECalComponentDateTime *dt, icaltimezone *default_zone)
 {
+	/* TODO: Entry's timezone? */
 	g_return_val_if_fail (itt != NULL, FALSE);
 	g_return_val_if_fail (dt != NULL, FALSE);
 
diff --git a/calendar/backends/google/e-cal-backend-google-utils.h b/calendar/backends/google/e-cal-backend-google-utils.h
index 612cd55..ac1f54d 100644
--- a/calendar/backends/google/e-cal-backend-google-utils.h
+++ b/calendar/backends/google/e-cal-backend-google-utils.h
@@ -29,16 +29,10 @@
 #include <gdata/gdata-entry.h>
 
 ECalComponent *
-e_go_item_to_cal_component (EGoItem *item, ECalBackendGoogle *cbgo);
-
-void
-e_go_item_set_entry (EGoItem *item, GDataEntry *entry);
+e_gdata_entry_to_cal_component (GDataEntry *entry, ECalBackendGoogle *cbgo);
 
 GDataEntry *
-e_go_item_get_entry (EGoItem *item);
-
-EGoItem *
-e_go_item_from_cal_component (ECalBackendGoogle *cbgo, ECalComponent *comp);
+e_gdata_entry_from_cal_component (ECalBackendGoogle *cbgo, ECalComponent *comp);
 
 gpointer
 e_cal_backend_google_utils_update (gpointer handle);
diff --git a/calendar/backends/google/e-cal-backend-google.c b/calendar/backends/google/e-cal-backend-google.c
index 278300a..025369c 100644
--- a/calendar/backends/google/e-cal-backend-google.c
+++ b/calendar/backends/google/e-cal-backend-google.c
@@ -63,18 +63,15 @@ struct _ECalBackendGooglePrivate {
 	ESource *source;
 
 	GDataCalendarService *service;
+	GDataFeed *feed;
 	GMutex *mutex;
-	GDataEntry *entry;
-	GSList *entries;
 	icaltimezone *default_zone;
 	CalMode	mode;
-	EGoItem *item;
 
 	guint timeout_id;
 	gchar *username;
 	gchar *password;
 	gchar *uri;
-	gchar *feed;
 	gchar *local_attachments_store;	
 
 	gboolean read_only;
@@ -417,7 +414,7 @@ e_cal_backend_google_set_mode (ECalBackend *backend, CalMode mode)
 	cbgo = E_CAL_BACKEND_GOOGLE (backend);
 	priv = cbgo->priv;
 
-	if (!priv->mode && priv->mode == mode) {
+	if (priv->mode == mode) {
 		e_cal_backend_notify_mode (backend, GNOME_Evolution_Calendar_CalListener_MODE_SET,
 				  	   cal_mode_to_corba (mode));
 		return;
@@ -529,7 +526,6 @@ ECalBackendSyncStatus
 static receive_object (ECalBackendGoogle *cbgo, EDataCal *cal, icalcomponent *icalcomp)
 {
 	ECalBackendGooglePrivate *priv;
-	EGoItem *item = NULL;
 	GDataEntry *entry = NULL, *updated_entry = NULL;
 	ECalComponent *comp, *modif_comp;
 	GSList *comps = NULL, *l = NULL;
@@ -563,8 +559,7 @@ static receive_object (ECalBackendGoogle *cbgo, EDataCal *cal, icalcomponent *ic
 		fetch_attachments (cbgo, comp);
 
 	/* Sent to Server */
-	item = e_go_item_from_cal_component (cbgo, comp);	
-	entry =	e_go_item_get_entry (item);
+	entry =	e_gdata_entry_from_cal_component (cbgo, comp);
 
 	if (!GDATA_IS_ENTRY(entry))
 		return GNOME_Evolution_Calendar_InvalidObject;	
@@ -577,7 +572,6 @@ static receive_object (ECalBackendGoogle *cbgo, EDataCal *cal, icalcomponent *ic
 	}
 
 	/* Update the Cache */
-
 	modif_comp = g_object_ref (comp);
 	if (instances) {
 		const char *uid;
@@ -841,13 +835,10 @@ e_cal_backend_google_get_changes (ECalBackendSync *backend, EDataCal *cal, const
 static ECalBackendSyncStatus
 e_cal_backend_google_is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
 {
-	/* FIXME */
-	*read_only = FALSE;
-
+	*read_only = E_CAL_BACKEND_GOOGLE (backend)->priv->read_only;
 	return GNOME_Evolution_Calendar_Success;
 }
 
-
 /* Returns the email address of the person who opened the calendar */
 static ECalBackendSyncStatus
 e_cal_backend_google_get_cal_address (ECalBackendSync *backend, EDataCal *cal, char **address)
@@ -880,7 +871,6 @@ e_cal_backend_google_modify_object (ECalBackendSync *backend, EDataCal *cal, con
 	ECalBackendGooglePrivate *priv;
 	icalcomponent *icalcomp;
 	ECalComponent *comp = NULL, *cache_comp = NULL;
-	EGoItem *item;
 	const char *uid = NULL, *rid = NULL;
 	GDataEntry *entry, *entry_from_server = NULL, *updated_entry = NULL;
 
@@ -916,18 +906,19 @@ e_cal_backend_google_modify_object (ECalBackendSync *backend, EDataCal *cal, con
 				return GNOME_Evolution_Calendar_ObjectNotFound;
 			}
 
-			item = e_go_item_from_cal_component (cbgo, comp);
-			item->feed = gdata_service_query (GDATA_SERVICE(priv->service), priv->uri, NULL, GDATA_TYPE_CALENDAR_EVENT,
+			if (priv->feed)
+				g_object_unref (priv->feed);
+			priv->feed = gdata_service_query (GDATA_SERVICE(priv->service), priv->uri, NULL, GDATA_TYPE_CALENDAR_EVENT,
 							  NULL, NULL, NULL, NULL);
-			entry = item->entry;
 
-			if (!item->feed) {
-				g_message ("CRITICAL: Could not find feed in EGoItem %s", G_STRLOC);
+			if (!priv->feed) {
+				g_message ("CRITICAL: Could not find feed %s", G_STRLOC);
 				g_object_unref (comp);
 				return GNOME_Evolution_Calendar_OtherError;
 			}
 
-			entry_from_server = gdata_feed_look_up_entry (item->feed, uid);
+			entry = e_gdata_entry_from_cal_component (cbgo, comp);
+			entry_from_server = gdata_feed_look_up_entry (priv->feed, uid);
 
 			if (!GDATA_IS_ENTRY(entry_from_server)) {
 				g_object_unref (comp);
@@ -970,15 +961,11 @@ e_cal_backend_google_remove_object (ECalBackendSync *backend, EDataCal *cal,
 	ECalBackendGooglePrivate *priv;
 	ECalComponent *comp = NULL;
 	char *calobj = NULL;
-	EGoItem *item;
 
 	cbgo = E_CAL_BACKEND_GOOGLE (backend);
 	priv = cbgo->priv;
-	item = priv->item;
 
 	*old_object = *object = NULL;
-	/* FIXME */
-	item->feed = gdata_service_query (GDATA_SERVICE(priv->service), priv->uri, NULL, GDATA_TYPE_CALENDAR_EVENT, NULL, NULL, NULL, NULL);
 
 	if (priv->mode == CAL_MODE_REMOTE) {
 		ECalBackendSyncStatus status;
@@ -1008,7 +995,11 @@ e_cal_backend_google_remove_object (ECalBackendSync *backend, EDataCal *cal,
 		e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgo), id, comp_str, NULL);
 		g_free (comp_str);
 
-		entry = gdata_feed_look_up_entry (item->feed, uid);
+		/* FIXME */
+		if (priv->feed)
+			g_object_unref (priv->feed);
+		priv->feed = gdata_service_query (GDATA_SERVICE(priv->service), priv->uri, NULL, GDATA_TYPE_CALENDAR_EVENT, NULL, NULL, NULL, NULL);
+		entry = gdata_feed_look_up_entry (priv->feed, uid);
 
 		if (!entry) {
 			g_free (calobj);
@@ -1033,7 +1024,6 @@ e_cal_backend_google_create_object (ECalBackendSync *backend, EDataCal *cal, cha
 	ECalBackendGooglePrivate *priv;
 	icalcomponent *icalcomp;
 	ECalComponent *comp;
-	EGoItem *item;
 	GDataEntry *entry;
 
 	cbgo = E_CAL_BACKEND_GOOGLE (backend);
@@ -1068,8 +1058,7 @@ e_cal_backend_google_create_object (ECalBackendSync *backend, EDataCal *cal, cha
 			GDataEntry *updated_entry;
 			const gchar *id;
 
-			item = e_go_item_from_cal_component (cbgo, comp);
-			entry = e_go_item_get_entry (item);
+			entry = e_gdata_entry_from_cal_component (cbgo, comp);
 
 			updated_entry = gdata_service_insert_entry (GDATA_SERVICE(priv->service), priv->uri, entry, NULL, NULL);
 
@@ -1218,6 +1207,10 @@ e_cal_backend_google_dispose (GObject *object)
 	cbgo = E_CAL_BACKEND_GOOGLE (object);
 	priv = cbgo->priv;
 
+	if (priv->feed)
+		g_object_unref (priv->feed);
+	priv->feed = NULL;
+
 	if (G_OBJECT_CLASS (parent_class)->dispose)
 		(* G_OBJECT_CLASS (parent_class)->dispose) (object);
 }
@@ -1311,9 +1304,9 @@ e_cal_backend_google_init (ECalBackendGoogle *cbgo, ECalBackendGoogleClass *clas
 	priv = g_new0 (ECalBackendGooglePrivate, 1);
 
 	priv->mutex = g_mutex_new ();
+	priv->read_only = FALSE;
 	priv->username = NULL;
 	priv->password = NULL;
-	priv->entry = NULL;
 	priv->service = NULL;
 	priv->timeout_id = 0;
 	cbgo->priv = priv;
@@ -1432,28 +1425,28 @@ e_cal_backend_google_set_cache (ECalBackendGoogle *cbgo, ECalBackendCache *cache
 }
 
 /**
- * e_cal_backend_google_set_item:
+ * e_cal_backend_google_set_feed:
  * @cbgo a #ECalBackendGoogle object
- * @cache a #EGoItem *item
+ * @feed a #GDataFeed
  *
  **/
 void
-e_cal_backend_google_set_item (ECalBackendGoogle *cbgo, EGoItem *item)
+e_cal_backend_google_set_feed (ECalBackendGoogle *cbgo, GDataFeed *feed)
 {
-	ECalBackendGooglePrivate *priv;
-
 	g_return_if_fail (cbgo != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo));
+	g_return_if_fail (GDATA_IS_FEED (feed));
 
-	priv = cbgo->priv;
-	priv->item = item;
+	if (cbgo->priv->feed)
+		g_object_unref (cbgo->priv->feed);
+	cbgo->priv->feed = g_object_ref (feed);
 }
 
 /**
- * e_cal_backend_google_set_item:
+ * e_cal_backend_google_set_service:
  * @cbgo a #ECalBackendGoogle object
- * @cache a #EGoItem *item
- * Sets the #EGoItem item on object
+ * @service a #GDataCalendarService
+ * Sets the #GDataCalendarService service on object
  *
  **/
 void
@@ -1496,25 +1489,6 @@ e_cal_backend_google_set_uri (ECalBackendGoogle *cbgo, gchar *uri)
 }
 
 /**
- * e_cal_backend_google_set_entry:
- * @cbgo a #ECalBackendGoogle object
- * @entry a #GDataEntry entry
- * Sets the entry on object
- *
- **/
-void
-e_cal_backend_google_set_entry (ECalBackendGoogle *cbgo, GDataEntry *entry)
-{
-	ECalBackendGooglePrivate *priv;
-
-	g_return_if_fail (cbgo != NULL);
-	g_return_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo));
-
-	priv = cbgo->priv;
-	priv->entry = entry;
-}
-
-/**
  * e_cal_backend_google_set_timeout_id:
  * @cbgo a #ECalBackendGoogle object
  * @timeout_id a time out id
@@ -1555,13 +1529,13 @@ e_cal_backend_google_set_username (ECalBackendGoogle *cbgo,gchar *username)
 /**
  * e_cal_backend_google_set_password:
  * @cbgo a #ECalBackendGoogle object
- * @cache a #EGoItem *item
- * Sets the #EGoItem item on object
+ * @password a password
+ * Sets the password on object
  *
  **/
 
 void
-e_cal_backend_google_set_password (ECalBackendGoogle *cbgo,gchar *password)
+e_cal_backend_google_set_password (ECalBackendGoogle *cbgo, gchar *password)
 {
 	ECalBackendGooglePrivate *priv;
 	priv = cbgo->priv;
@@ -1591,20 +1565,17 @@ e_cal_backend_google_get_cache (ECalBackendGoogle *cbgo)
 }
 
 /**
- * e_cal_backend_google_get_item:
+ * e_cal_backend_google_get_feed:
  * @cbgo a #ECalBackendGoogle object
- * Gets the #EGoItem . from cbgo
+ * Gets the #GDataFeed from cbgo
  **/
-EGoItem *
-e_cal_backend_google_get_item (ECalBackendGoogle *cbgo)
+GDataFeed *
+e_cal_backend_google_get_feed (ECalBackendGoogle *cbgo)
 {
-	ECalBackendGooglePrivate *priv;
-
 	g_return_val_if_fail (cbgo != NULL, NULL);
 	g_return_val_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo), NULL);
 
-	priv = cbgo->priv;
-	return priv->item;
+	return cbgo->priv->feed;
 }
 
 /**
@@ -1626,7 +1597,7 @@ e_cal_backend_google_get_service (ECalBackendGoogle *cbgo)
 }
 
 /**
- * e_cal_backend_google_set_item:
+ * e_cal_backend_google_get_uri:
  * @cbgo a #ECalBackendGoogle object
  * Gets the uri
  **/
@@ -1643,24 +1614,6 @@ e_cal_backend_google_get_uri (ECalBackendGoogle *cbgo)
 }
 
 /**
- * e_cal_backend_google_get_entry:
- * @cbgo a #ECalBackendGoogle object
- * Gets the #GDataEntry object.
- *
- **/
-GDataEntry *
-e_cal_backend_google_get_entry (ECalBackendGoogle *cbgo)
-{
-	ECalBackendGooglePrivate *priv;
-
-	g_return_val_if_fail (cbgo != NULL, NULL);
-	g_return_val_if_fail (E_IS_CAL_BACKEND_GOOGLE(cbgo), NULL);
-
-	priv = cbgo->priv;
-	return priv->entry;
-}
-
-/**
  * e_cal_backend_google_get_timeout_id:
  * @cbgo a #ECalBackendGoogle object
  * Gets the timeout id.
diff --git a/calendar/backends/google/e-cal-backend-google.h b/calendar/backends/google/e-cal-backend-google.h
index 0c217f7..3da5a3e 100644
--- a/calendar/backends/google/e-cal-backend-google.h
+++ b/calendar/backends/google/e-cal-backend-google.h
@@ -56,15 +56,8 @@ struct _ECalBackendGoogleClass {
 	ECalBackendSyncClass parent_class;
 };
 
-struct _EGoItem {
-	GDataEntry *entry;
-	GDataFeed *feed;
-};
-typedef struct _EGoItem EGoItem;
-
 GType e_cal_backend_google_get_type (void);
-EGoItem * e_cal_backend_google_get_item (ECalBackendGoogle *cbgo);
-GDataEntry * e_cal_backend_google_get_entry (ECalBackendGoogle *cbgo);
+GDataFeed * e_cal_backend_google_get_feed (ECalBackendGoogle *cbgo);
 ECalBackendCache * e_cal_backend_google_get_cache (ECalBackendGoogle *cbgo);
 GDataCalendarService * e_cal_backend_google_get_service (ECalBackendGoogle *cbgo);
 gchar * e_cal_backend_google_get_uri (ECalBackendGoogle *cbgo);
@@ -75,12 +68,11 @@ gchar * e_cal_backend_google_get_password (ECalBackendGoogle *cbgo);
 gchar * e_cal_backend_google_get_local_attachments_store (ECalBackendGoogle *cbgo);
 guint e_cal_backend_google_get_timeout_id (ECalBackendGoogle *cbgo);
 
-void e_cal_backend_google_set_entry (ECalBackendGoogle *cbgo, GDataEntry *entry);
 void e_cal_backend_google_set_cache (ECalBackendGoogle *cbgo, ECalBackendCache *cache);
-void e_cal_backend_google_set_item (ECalBackendGoogle *cbgo, EGoItem *item);
+void e_cal_backend_google_set_feed (ECalBackendGoogle *cbgo, GDataFeed *feed);
 void e_cal_backend_google_set_service (ECalBackendGoogle *cbgo, GDataCalendarService *service);
 void e_cal_backend_google_set_uri (ECalBackendGoogle *cbgo, gchar *uri);
-void e_cal_backend_google_set_item (ECalBackendGoogle *cbgo, EGoItem *item);
+void e_cal_backend_google_set_feed (ECalBackendGoogle *cbgo, GDataFeed *feed);
 void e_cal_backend_google_set_mode_changed (ECalBackendGoogle *cbgo, gboolean mode_changed);
 void e_cal_backend_google_set_username (ECalBackendGoogle *cbgo, gchar *username);
 void e_cal_backend_google_set_password (ECalBackendGoogle *cbgo, gchar *password);



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