[evolution-data-server/libgdata-port: 2/5] Converted Google addressbook backend to use the external libgdata



commit 682fb324b4ed4a76721d3df46cc88e1fd7159a03
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Apr 19 21:45:42 2009 +0100

    Converted Google addressbook backend to use the external libgdata
    
    A straight find-and-replace which has been made to build, there are several
    places where the code can be rewritten to better use libgdata's features.
---
 addressbook/backends/google/Makefile.am   |   12 +-
 addressbook/backends/google/google-book.c |   59 +++++---
 addressbook/backends/google/util.c        |  221 ++++++++++++++---------------
 addressbook/backends/google/util.h        |    3 +-
 calendar/backends/google/Makefile.am      |    2 +-
 5 files changed, 151 insertions(+), 146 deletions(-)

diff --git a/addressbook/backends/google/Makefile.am b/addressbook/backends/google/Makefile.am
index 19f3932..1520d59 100644
--- a/addressbook/backends/google/Makefile.am
+++ b/addressbook/backends/google/Makefile.am
@@ -4,12 +4,9 @@ INCLUDES = \
 	-I$(top_builddir) \
 	-I$(top_srcdir)/addressbook \
 	-I$(top_builddir)/addressbook \
-	-I$(top_srcdir)/servers/google/libgdata \
-	-I$(top_builddir)/servers/google/libgdata \
-	-I$(top_srcdir)/servers/google/libgdata-google \
-	-I$(top_builddir)/servers/google/libgdata-google \
 	$(SOUP_CFLAGS) \
-	$(EVOLUTION_ADDRESSBOOK_CFLAGS)
+	$(EVOLUTION_ADDRESSBOOK_CFLAGS) \
+	$(GDATA_CFLAGS)
 
 extension_LTLIBRARIES = libebookbackendgoogle.la
 
@@ -27,11 +24,10 @@ libebookbackendgoogle_la_LIBADD = \
 	$(top_builddir)/addressbook/libebook/libebook-1.2.la \
 	$(top_builddir)/addressbook/libedata-book/libedata-book-1.2.la \
 	$(top_builddir)/libedataserver/libedataserver-1.2.la \
-	$(top_builddir)/servers/google/libgdata/libgdata-1.2.la \
-	$(top_builddir)/servers/google/libgdata-google/libgdata-google-1.2.la \
 	$(top_builddir)/libebackend/libebackend-1.2.la \
 	$(SOUP_LIBS) \
-	$(EVOLUTION_ADDRESSBOOK_LIBS)
+	$(EVOLUTION_ADDRESSBOOK_LIBS) \
+	$(GDATA_LIBS)
 
 libebookbackendgoogle_la_LDFLAGS = \
 	-module -avoid-version $(NO_UNDEFINED)
diff --git a/addressbook/backends/google/google-book.c b/addressbook/backends/google/google-book.c
index 6d0902c..6cc6812 100644
--- a/addressbook/backends/google/google-book.c
+++ b/addressbook/backends/google/google-book.c
@@ -1,6 +1,7 @@
 /* goggle-book.c - Google contact list abstraction with caching.
  *
  * Copyright (C) 2008 Joergen Scheibengruber
+ * Copyright (C) 2009 Philip Withnall
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by the
@@ -16,14 +17,16 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
- * Author: Joergen Scheibengruber <joergen.scheibengruber AT googlemail.com>
+ * Author: Joergen Scheibengruber <joergen.scheibengruber AT googlemail.com>,
+ * Philip Withnall <philip tecnocode co uk>
  */
 
 #include <string.h>
 #include <libedata-book/e-book-backend-cache.h>
 #include <libedataserver/e-proxy.h>
-#include <gdata-service-iface.h>
-#include <gdata-google-service.h>
+#include <gdata/gdata-service.h>
+#include <gdata/services/contacts/gdata-contacts-service.h>
+#include <gdata/services/contacts/gdata-contacts-contact.h>
 
 #include "util.h"
 #include "google-book.h"
@@ -181,7 +184,7 @@ google_book_cache_get_contact (GoogleBook *book, const char *uid, GDataEntry **e
             if (entry) {
                 const char *entry_xml;
                 entry_xml = _e_contact_get_gdata_entry_xml (contact);
-                *entry = gdata_entry_new_from_xml (entry_xml);
+                *entry = GDATA_ENTRY (gdata_contacts_contact_new_from_xml (entry_xml, -1, NULL));
             }
             _e_contact_remove_gdata_entry_xml (contact);
         }
@@ -762,23 +765,22 @@ google_book_connect_to_google (GoogleBook *book, const char *password, GError **
     priv = GET_PRIVATE (book);
 
     if (priv->service) {
-        g_warning ("Connection to google already established.");
+        g_warning ("Connection to Google already established.");
         return TRUE;
     }
 
-    service = (GDataService*)gdata_google_service_new ("cp", "evolution-client-0.0.1");
+    service = GDATA_SERVICE (gdata_contacts_service_new ("evolution-client-0.0.1"));
     priv->proxy = e_proxy_new ();
     e_proxy_setup_proxy (priv->proxy);
     priv->service = service;
     proxy_settings_changed (priv->proxy, priv);
     priv->service = NULL;
 
-    gdata_service_set_credentials (GDATA_SERVICE (service), priv->username, password);
-    gdata_google_service_authenticate (GDATA_GOOGLE_SERVICE (service), &soup_error);
+    gdata_service_authenticate (service, priv->username, password, NULL, &soup_error);
 
     if (soup_error) {
         google_book_error_from_soup_error (soup_error, error,
-                                           "Connecting to google failed");
+                                           "Connecting to Google failed");
         priv->service = NULL;
 	g_object_unref (service);
 	g_object_unref (priv->proxy);
@@ -830,6 +832,7 @@ google_book_add_contact (GoogleBook *book,
 {
     GoogleBookPrivate *priv;
     GDataEntry *entry, *new_entry;
+    gchar *xml;
     GError *soup_error = NULL;
 
     *out_contact = NULL;
@@ -842,9 +845,12 @@ google_book_add_contact (GoogleBook *book,
     g_return_val_if_fail (priv->service, FALSE);
 
     entry = _gdata_entry_new_from_e_contact (contact);
-    __debug__ ("new entry with xml: %s", gdata_entry_generate_xml (entry));
+    xml = gdata_entry_get_xml (entry);
+    __debug__ ("new entry with xml: %s", xml);
+    g_free (xml);
+
     new_entry = gdata_service_insert_entry (GDATA_SERVICE (priv->service),
-                                            priv->add_base_uri, entry, &soup_error);
+                                            priv->add_base_uri, entry, NULL, &soup_error);
     g_object_unref (entry);
     if (soup_error) {
         google_book_error_from_soup_error (soup_error, error,
@@ -869,6 +875,7 @@ google_book_update_contact (GoogleBook *book,
     GDataEntry *entry, *new_entry;
     GError *soup_error = NULL;
     EContact *cached_contact;
+    gchar *xml;
     const char *uid;
 
     *out_contact = NULL;
@@ -894,8 +901,11 @@ google_book_update_contact (GoogleBook *book,
     g_object_unref (cached_contact);
     _gdata_entry_update_from_e_contact (entry, contact);
 
-    __debug__ ("Before:\n%s", gdata_entry_generate_xml (entry));
-    new_entry = gdata_service_update_entry (GDATA_SERVICE (priv->service), entry, &soup_error);
+    xml = gdata_entry_get_xml (entry);
+    __debug__ ("Before:\n%s", xml);
+    g_free (xml);
+
+    new_entry = gdata_service_update_entry (GDATA_SERVICE (priv->service), entry, NULL, &soup_error);
     g_object_unref (entry);
 
     if (soup_error) {
@@ -903,7 +913,12 @@ google_book_update_contact (GoogleBook *book,
                                            "Updating entry failed");
         return FALSE;
     }
-    __debug__ ("After:\n%s", new_entry ? gdata_entry_generate_xml (new_entry) : NULL);
+
+    xml = NULL;
+    if (new_entry)
+        xml = gdata_entry_get_xml (new_entry);
+    __debug__ ("After:\n%s", xml);
+    g_free (xml);
 
     *out_contact = google_book_cache_add_contact (book, new_entry);
 
@@ -937,7 +952,7 @@ google_book_remove_contact (GoogleBook *book, const char *uid, GError **error)
     }
 
     google_book_cache_remove_contact (book, uid);
-    gdata_service_delete_entry (GDATA_SERVICE (priv->service), entry, &soup_error);
+    gdata_service_delete_entry (GDATA_SERVICE (priv->service), entry, NULL, &soup_error);
     g_object_unref (entry);
     g_object_unref (cached_contact);
 
@@ -964,7 +979,7 @@ process_subsequent_entry (gpointer list_data, gpointer user_data)
     priv = GET_PRIVATE (book);
     entry = GDATA_ENTRY (list_data);
     uid = gdata_entry_get_id (entry);
-    is_deleted = gdata_entry_is_deleted (entry);
+    is_deleted = gdata_contacts_contact_is_deleted (GDATA_CONTACTS_CONTACT (entry));
 
     cached_contact = google_book_cache_get_contact (book, uid, NULL);
     if (is_deleted) {
@@ -1032,11 +1047,12 @@ google_book_get_new_contacts_in_chunks (GoogleBook *book,
 
     while (start_index > 0) {
         GDataFeed *feed;
-        GSList *entries;
+        GList *entries;
         GString *uri;
         int results;
         GError *soup_error = NULL;
 
+        /* TODO: Convert to GDataQuery */
         uri = g_string_new (priv->base_uri);
         g_string_append_printf (uri, "?max-results=%d&start-index=%d",
                                 chunk_size, start_index);
@@ -1046,7 +1062,7 @@ google_book_get_new_contacts_in_chunks (GoogleBook *book,
         }
 
         __debug__ ("URI is '%s'", uri->str);
-        feed = gdata_service_get_feed (priv->service, uri->str, &soup_error);
+        feed = gdata_service_query (priv->service, uri->str, NULL, GDATA_TYPE_CONTACTS_CONTACT, NULL, NULL, NULL, &soup_error);
         g_string_free (uri, TRUE);
 
         if (soup_error) {
@@ -1060,13 +1076,13 @@ google_book_get_new_contacts_in_chunks (GoogleBook *book,
         }
 
         entries = gdata_feed_get_entries (feed);
-        results = entries ? g_slist_length (entries) : 0;
+        results = entries ? g_list_length (entries) : 0;
         __debug__ ("Feed has %d entries", results);
 
         if (last_updated) {
-            g_slist_foreach (entries, process_subsequent_entry, book);
+            g_list_foreach (entries, process_subsequent_entry, book);
         } else {
-            g_slist_foreach (entries, process_initial_entry, book);
+            g_list_foreach (entries, process_initial_entry, book);
         }
 
         if (results == chunk_size) {
@@ -1222,6 +1238,7 @@ google_book_error_from_soup_error (GError     *soup_error,
 
     g_assert (soup_error);
 
+    /* TODO: Convert this to deal with libgdata codes */
     if (soup_error->code < 100) {
         code = GOOGLE_BOOK_ERROR_NETWORK_ERROR;
     } else
diff --git a/addressbook/backends/google/util.c b/addressbook/backends/google/util.c
index 8b74ff5..8ddd089 100644
--- a/addressbook/backends/google/util.c
+++ b/addressbook/backends/google/util.c
@@ -1,6 +1,7 @@
 /* util.c - Google contact backend utility functions.
  *
  * Copyright (C) 2008 Joergen Scheibengruber
+ * Copyright (C) 2009 Philip Withnall
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by the
@@ -21,6 +22,8 @@
 
 #include <string.h>
 #include <libsoup/soup.h>
+#include <gdata/gdata-gdata.h>
+#include <gdata/services/contacts/gdata-contacts-contact.h>
 #include "util.h"
 
 /*#define GOOGLE_PRIMARY_PARAM "X-GOOGLE-PRIMARY"*/
@@ -28,31 +31,31 @@
 #define GOOGLE_LABEL_PARAM "X-GOOGLE-LABEL"
 
 static EVCardAttribute*
-attribute_from_gdata_entry_email_address  (GDataEntryEmailAddress  *email);
+attribute_from_gdata_gd_email_address  (GDataGDEmailAddress  *email);
 
 static EVCardAttribute*
-attribute_from_gdata_entry_im_address     (GDataEntryIMAddress     *im);
+attribute_from_gdata_gd_im_address     (GDataGDIMAddress     *im);
 
 static EVCardAttribute*
-attribute_from_gdata_entry_phone_number   (GDataEntryPhoneNumber   *number);
+attribute_from_gdata_gd_phone_number   (GDataGDPhoneNumber   *number);
 
 static EVCardAttribute*
-attribute_from_gdata_entry_postal_address (GDataEntryPostalAddress *address);
+attribute_from_gdata_gd_postal_address (GDataGDPostalAddress *address);
 
-static GDataEntryEmailAddress*
-gdata_entry_email_address_from_attribute  (EVCardAttribute         *attr,
+static GDataGDEmailAddress*
+gdata_gd_email_address_from_attribute  (EVCardAttribute         *attr,
                                            gboolean                *primary);
 
-static GDataEntryIMAddress*
-gdata_entry_im_address_from_attribute     (EVCardAttribute         *attr,
+static GDataGDIMAddress*
+gdata_gd_im_address_from_attribute     (EVCardAttribute         *attr,
                                            gboolean                *primary);
 
-static GDataEntryPhoneNumber*
-gdata_entry_phone_number_from_attribute   (EVCardAttribute         *attr,
+static GDataGDPhoneNumber*
+gdata_gd_phone_number_from_attribute   (EVCardAttribute         *attr,
                                            gboolean                *primary);
 
-static GDataEntryPostalAddress*
-gdata_entry_postal_address_from_attribute (EVCardAttribute         *attr,
+static GDataGDPostalAddress*
+gdata_gd_postal_address_from_attribute (EVCardAttribute         *attr,
                                            gboolean                *primary);
 
 static gboolean
@@ -62,14 +65,12 @@ GDataEntry*
 _gdata_entry_new_from_e_contact (EContact *contact)
 {
     GDataEntry *entry;
-    GDataEntryCategory *category;
+    GDataCategory *category;
 
-    entry = gdata_entry_new ();
+    entry = gdata_entry_new (NULL);
 
-    category = g_new0 (GDataEntryCategory, 1);
-    category->scheme = g_strdup ("http://schemas.google.com/g/2005#kind";);
-    category->term = g_strdup ("http://schemas.google.com/contact/2008#contact";);
-    gdata_entry_set_categories (entry, g_slist_append (NULL, category));
+    category = gdata_category_new ("http://schemas.google.com/contact/2008#contact";, "http://schemas.google.com/g/2005#kind";, NULL);
+    gdata_entry_add_category (entry, category);
 
     if (_gdata_entry_update_from_e_contact (entry, contact))
         return entry;
@@ -85,10 +86,6 @@ _gdata_entry_update_from_e_contact (GDataEntry *entry,
 {
     GList *attributes, *iter;
     char *fullname = NULL;
-    GSList *email_addresses = NULL;
-    GSList *im_addresses = NULL;
-    GSList *phone_numbers = NULL;
-    GSList *postal_addresses = NULL;
     gboolean have_email_primary = FALSE;
     gboolean have_im_primary = FALSE;
     gboolean have_phone_primary = FALSE;
@@ -124,51 +121,43 @@ _gdata_entry_update_from_e_contact (GDataEntry *entry,
             0 == g_ascii_strcasecmp (name, EVC_X_FILE_AS)) {
         } else
         if (0 == g_ascii_strcasecmp (name, EVC_EMAIL)) {
-            GDataEntryEmailAddress *email;
+            GDataGDEmailAddress *email;
 
-            email = gdata_entry_email_address_from_attribute
+            email = gdata_gd_email_address_from_attribute
                         (attr, &have_email_primary);
-            if (email) {
-                email_addresses = g_slist_append (email_addresses,
-                                                  email);
-            }
+            if (email)
+                gdata_contacts_contact_add_email_address (GDATA_CONTACTS_CONTACT (entry), email);
         } else
 
         /* TEL */
         if (0 == g_ascii_strcasecmp (name, EVC_TEL)) {
-            GDataEntryPhoneNumber *number;
+            GDataGDPhoneNumber *number;
 
-            number = gdata_entry_phone_number_from_attribute
+            number = gdata_gd_phone_number_from_attribute
                         (attr, &have_phone_primary);
-            if (number) {
-                phone_numbers = g_slist_append (phone_numbers,
-                                                number);
-            }
+            if (number)
+                gdata_contacts_contact_add_phone_number (GDATA_CONTACTS_CONTACT (entry), number);
         } else
         
         /* LABEL */
         if (0 == g_ascii_strcasecmp (name, EVC_LABEL)) {
-            GDataEntryPostalAddress *address;
+            GDataGDPostalAddress *address;
 
-            address = gdata_entry_postal_address_from_attribute
+            address = gdata_gd_postal_address_from_attribute
                         (attr, &have_postal_primary);
-            if (address) {
-                postal_addresses = g_slist_append (postal_addresses,
-                                                   address);
-            }
+            if (address)
+                gdata_contacts_contact_add_postal_address (GDATA_CONTACTS_CONTACT (entry), address);
         } else
     
         /* X-IM */
         if (0 == g_ascii_strncasecmp (name, "X-", 2) &&
             is_known_google_im_protocol (name + 2)) {
-            GDataEntryIMAddress *im;
+            GDataGDIMAddress *im;
 
-            im = gdata_entry_im_address_from_attribute
+            im = gdata_gd_im_address_from_attribute
                         (attr, &have_im_primary);
-            if (im) {
-                im_addresses = g_slist_append (im_addresses,
-                                               im);
-            }
+            if (im)
+                gdata_contacts_contact_add_im_address (GDATA_CONTACTS_CONTACT (entry), im);
         } else {
             GList *values;
 
@@ -180,10 +169,6 @@ _gdata_entry_update_from_e_contact (GDataEntry *entry,
     }
     gdata_entry_set_title (entry, fullname);
     g_free (fullname);
-    gdata_entry_set_email_addresses (entry, email_addresses);
-    gdata_entry_set_im_addresses (entry, im_addresses);
-    gdata_entry_set_phone_numbers (entry, phone_numbers);
-    gdata_entry_set_postal_addresses (entry, postal_addresses);
 
     return TRUE;
 }
@@ -193,14 +178,14 @@ _e_contact_new_from_gdata_entry (GDataEntry *entry)
 {
     EVCard *vcard;
     EVCardAttribute *attr;
-    GSList *email_addresses, *im_addresses, *phone_numbers, *postal_addresses;
+    GList *email_addresses, *im_addresses, *phone_numbers, *postal_addresses;
     const char *name;
     const char *uid;
-    GSList *itr;
-    GDataEntryEmailAddress *email;
-    GDataEntryIMAddress *im;
-    GDataEntryPhoneNumber *phone_number;
-    GDataEntryPostalAddress *postal_address;
+    GList *itr;
+    GDataGDEmailAddress *email;
+    GDataGDIMAddress *im;
+    GDataGDPhoneNumber *phone_number;
+    GDataGDPostalAddress *postal_address;
 
     uid = gdata_entry_get_id (entry);
     if (NULL == uid) {
@@ -220,69 +205,69 @@ _e_contact_new_from_gdata_entry (GDataEntry *entry)
     }
 
     /* EMAIL - primary first */
-    email = gdata_entry_get_primary_email_address (entry);
-    attr = attribute_from_gdata_entry_email_address (email);
+    email = gdata_contacts_contact_get_primary_email_address (GDATA_CONTACTS_CONTACT (entry));
+    attr = attribute_from_gdata_gd_email_address (email);
     if (attr) {
         e_vcard_add_attribute (vcard, attr);
     }
 
-    email_addresses = gdata_entry_get_email_addresses (entry);
+    email_addresses = gdata_contacts_contact_get_email_addresses (GDATA_CONTACTS_CONTACT (entry));
     for (itr = email_addresses; itr; itr = itr->next) {
         email = itr->data;
         if (TRUE == email->primary)
             continue;
-        attr = attribute_from_gdata_entry_email_address (email);
+        attr = attribute_from_gdata_gd_email_address (email);
         if (attr) {
             e_vcard_add_attribute (vcard, attr);
         }
     }
 
     /* X-IM - primary first */
-    im = gdata_entry_get_primary_im_address (entry);
-    attr = attribute_from_gdata_entry_im_address (im);
+    im = gdata_contacts_contact_get_primary_im_address (GDATA_CONTACTS_CONTACT (entry));
+    attr = attribute_from_gdata_gd_im_address (im);
     if (attr) {
         e_vcard_add_attribute (vcard, attr);
     }
-    im_addresses = gdata_entry_get_im_addresses (entry);
+    im_addresses = gdata_contacts_contact_get_im_addresses (GDATA_CONTACTS_CONTACT (entry));
     for (itr = im_addresses; itr; itr = itr->next) {
         im = itr->data;
         if (TRUE == im->primary)
             continue;
-        attr = attribute_from_gdata_entry_im_address (im);
+        attr = attribute_from_gdata_gd_im_address (im);
         if (attr) {
             e_vcard_add_attribute (vcard, attr);
         }
     }
 
     /* TEL - primary first */
-    phone_number = gdata_entry_get_primary_phone_number (entry);
-    attr = attribute_from_gdata_entry_phone_number (phone_number);
+    phone_number = gdata_contacts_contact_get_primary_phone_number (GDATA_CONTACTS_CONTACT (entry));
+    attr = attribute_from_gdata_gd_phone_number (phone_number);
     if (attr) {
         e_vcard_add_attribute (vcard, attr);
     }
-    phone_numbers = gdata_entry_get_phone_numbers (entry);
+    phone_numbers = gdata_contacts_contact_get_phone_numbers (GDATA_CONTACTS_CONTACT (entry));
     for (itr = phone_numbers; itr; itr = itr->next) {
         phone_number = itr->data;
         if (TRUE == phone_number->primary)
             continue;
-        attr = attribute_from_gdata_entry_phone_number (phone_number);
+        attr = attribute_from_gdata_gd_phone_number (phone_number);
         if (attr) {
             e_vcard_add_attribute (vcard, attr);
         }
     }
 
     /* LABEL - primary first TODO: ADR */
-    postal_address = gdata_entry_get_primary_postal_address (entry);
-    attr = attribute_from_gdata_entry_postal_address (postal_address);
+    postal_address = gdata_contacts_contact_get_primary_postal_address (GDATA_CONTACTS_CONTACT (entry));
+    attr = attribute_from_gdata_gd_postal_address (postal_address);
     if (attr) {
         e_vcard_add_attribute (vcard, attr);
     }
-    postal_addresses = gdata_entry_get_postal_addresses (entry);
+    postal_addresses = gdata_contacts_contact_get_postal_addresses (GDATA_CONTACTS_CONTACT (entry));
     for (itr = postal_addresses; itr; itr = itr->next) {
         postal_address = itr->data;
         if (TRUE == postal_address->primary)
             continue;
-        attr = attribute_from_gdata_entry_postal_address (postal_address);
+        attr = attribute_from_gdata_gd_postal_address (postal_address);
         if (attr) {
             e_vcard_add_attribute (vcard, attr);
         }
@@ -297,13 +282,16 @@ void
 _e_contact_add_gdata_entry_xml (EContact *contact, GDataEntry *entry)
 {
     EVCardAttribute *attr;
-    const char* entry_xml;
+    char *entry_xml;
 
-    entry_xml = gdata_entry_generate_xml (entry);
+    /* TODO: Why is this necessary? */
+    entry_xml = gdata_entry_get_xml (entry);
 
     attr = e_vcard_attribute_new ("", GDATA_ENTRY_XML_ATTR);
     e_vcard_attribute_add_value (attr, entry_xml);
     e_vcard_add_attribute (E_VCARD (contact), attr);
+
+    g_free (entry_xml);
 }
 
 void
@@ -405,6 +393,7 @@ add_label_param (EVCardAttribute *attr, const char *label)
     }
 }
 
+/* TODO: Can this be made const? */
 static char*
 _google_rel_from_types (GList *types,
                         const struct RelTypeMap rel_type_map[],
@@ -482,6 +471,7 @@ field_name_from_google_im_protocol (const char* google_protocol)
     return g_strdup_printf ("X-%s", protocol + 1);
 }
 
+/* TODO: Can this be made const? */
 static char*
 google_im_protocol_from_field_name (const char* field_name)
 {
@@ -548,13 +538,13 @@ get_google_primary_type_label (EVCardAttribute *attr,
 
 
 static EVCardAttribute*
-attribute_from_gdata_entry_email_address (GDataEntryEmailAddress *email)
+attribute_from_gdata_gd_email_address (GDataGDEmailAddress *email)
 {
     EVCardAttribute *attr;
     gboolean has_type;
 
     if (NULL == email || NULL == email->address)
-        return NULL;;
+        return NULL;
 
     attr = e_vcard_attribute_new (NULL, EVC_EMAIL);
     has_type = add_type_param_from_google_rel (attr, email->rel);
@@ -567,14 +557,14 @@ attribute_from_gdata_entry_email_address (GDataEntryEmailAddress *email)
 }
 
 static EVCardAttribute*
-attribute_from_gdata_entry_im_address (GDataEntryIMAddress *im)
+attribute_from_gdata_gd_im_address (GDataGDIMAddress *im)
 {
     EVCardAttribute *attr;
     gboolean has_type;
     char *field_name;
 
     if (NULL == im || NULL == im->address)
-        return NULL;;
+        return NULL;
 
     field_name = field_name_from_google_im_protocol (im->protocol);
     if (NULL == field_name)
@@ -591,13 +581,13 @@ attribute_from_gdata_entry_im_address (GDataEntryIMAddress *im)
 }
 
 static EVCardAttribute*
-attribute_from_gdata_entry_phone_number (GDataEntryPhoneNumber *number)
+attribute_from_gdata_gd_phone_number (GDataGDPhoneNumber *number)
 {
     EVCardAttribute *attr;
     gboolean has_type;
 
     if (NULL == number || NULL == number->number)
-        return NULL;;
+        return NULL;
 
     attr = e_vcard_attribute_new (NULL, EVC_TEL);
     has_type = add_type_param_from_google_rel_phone (attr, number->rel);
@@ -610,13 +600,13 @@ attribute_from_gdata_entry_phone_number (GDataEntryPhoneNumber *number)
 }
 
 static EVCardAttribute*
-attribute_from_gdata_entry_postal_address (GDataEntryPostalAddress *address)
+attribute_from_gdata_gd_postal_address (GDataGDPostalAddress *address)
 {
     EVCardAttribute *attr;
     gboolean has_type;
 
     if (NULL == address || NULL == address->address)
-        return NULL;;
+        return NULL;
 
     attr = e_vcard_attribute_new (NULL, EVC_LABEL);
     has_type = add_type_param_from_google_rel (attr, address->rel);
@@ -628,15 +618,16 @@ attribute_from_gdata_entry_postal_address (GDataEntryPostalAddress *address)
     return attr;
 }
 
-static GDataEntryEmailAddress*
-gdata_entry_email_address_from_attribute (EVCardAttribute *attr, gboolean *have_primary)
+static GDataGDEmailAddress*
+gdata_gd_email_address_from_attribute (EVCardAttribute *attr, gboolean *have_primary)
 {
-    GDataEntryEmailAddress *email = NULL;
+    GDataGDEmailAddress *email = NULL;
     GList *values;
 
     values = e_vcard_attribute_get_values (attr);
     if (values) {
         GList *types;
+        char *rel;
         const char *label;
         gboolean primary;
 
@@ -647,11 +638,10 @@ gdata_entry_email_address_from_attribute (EVCardAttribute *attr, gboolean *have_
             primary = FALSE;
         }
 
-        email = g_new0 (GDataEntryEmailAddress, 1);
-        email->address = g_strdup (values->data);
-        email->rel = google_rel_from_types (types);
-        email->label = g_strdup (label);
-        email->primary = primary;
+        rel = google_rel_from_types (types);
+        email = gdata_gd_email_address_new (values->data, rel, label, primary);
+        g_free (rel);
+
         __debug__ ("New %semail entry %s (%s/%s)",
                     email->primary ? "primary " : "",
                     email->address,
@@ -662,10 +652,10 @@ gdata_entry_email_address_from_attribute (EVCardAttribute *attr, gboolean *have_
     return email;
 }
 
-static GDataEntryIMAddress*
-gdata_entry_im_address_from_attribute (EVCardAttribute *attr, gboolean *have_primary)
+static GDataGDIMAddress*
+gdata_gd_im_address_from_attribute (EVCardAttribute *attr, gboolean *have_primary)
 {
-    GDataEntryIMAddress *im = NULL;
+    GDataGDIMAddress *im = NULL;
     GList *values;
     const char *name;
 
@@ -674,6 +664,7 @@ gdata_entry_im_address_from_attribute (EVCardAttribute *attr, gboolean *have_pri
     values = e_vcard_attribute_get_values (attr);
     if (values) {
         GList *types;
+        char *protocol, *rel;
         const char *label;
         gboolean primary;
 
@@ -684,12 +675,12 @@ gdata_entry_im_address_from_attribute (EVCardAttribute *attr, gboolean *have_pri
             primary = FALSE;
         }
 
-        im = g_new0 (GDataEntryIMAddress, 1);
-        im->address = g_strdup (values->data);
-        im->rel = google_rel_from_types (types);
-        im->label = g_strdup (label);
-        im->primary = primary;
-        im->protocol = google_im_protocol_from_field_name (name);
+        rel = google_rel_from_types (types);
+        protocol = google_im_protocol_from_field_name (name);
+        im = gdata_gd_im_address_new (values->data, protocol, rel, label, primary);
+        g_free (rel);
+        g_free (protocol);
+
         __debug__ ("New %s%s entry %s (%s/%s)",
                     im->primary ? "primary " : "",
                     im->protocol,
@@ -701,16 +692,17 @@ gdata_entry_im_address_from_attribute (EVCardAttribute *attr, gboolean *have_pri
     return im;
 }
 
-static GDataEntryPhoneNumber*
-gdata_entry_phone_number_from_attribute (EVCardAttribute *attr, gboolean *have_primary)
+static GDataGDPhoneNumber*
+gdata_gd_phone_number_from_attribute (EVCardAttribute *attr, gboolean *have_primary)
 {
-    GDataEntryPhoneNumber *number = NULL;
+    GDataGDPhoneNumber *number = NULL;
     GList *values;
 
     values = e_vcard_attribute_get_values (attr);
     if (values) {
         GList *types;
         gboolean primary;
+        char *rel;
         const char *label;
 
         types = get_google_primary_type_label (attr, &primary, &label);
@@ -720,11 +712,10 @@ gdata_entry_phone_number_from_attribute (EVCardAttribute *attr, gboolean *have_p
             primary = FALSE;
         }
 
-        number = g_new0 (GDataEntryPhoneNumber, 1);
-        number->number = g_strdup (values->data);
-        number->rel = google_rel_from_types_phone (types);
-        number->label = g_strdup (label);
-        number->primary = primary;
+        rel = google_rel_from_types_phone (types);
+        number = gdata_gd_phone_number_new (values->data, rel, label, NULL, primary);
+        g_free (rel);
+
         __debug__ ("New %sphone-number entry %s (%s/%s)",
                     number->primary ? "primary " : "",
                     number->number,
@@ -735,15 +726,16 @@ gdata_entry_phone_number_from_attribute (EVCardAttribute *attr, gboolean *have_p
     return number;
 }
 
-static GDataEntryPostalAddress*
-gdata_entry_postal_address_from_attribute (EVCardAttribute *attr, gboolean *have_primary)
+static GDataGDPostalAddress*
+gdata_gd_postal_address_from_attribute (EVCardAttribute *attr, gboolean *have_primary)
 {
-    GDataEntryPostalAddress *address = NULL;
+    GDataGDPostalAddress *address = NULL;
     GList *values;
 
     values = e_vcard_attribute_get_values (attr);
     if (values) {
         GList *types;
+        char *rel;
         const char *label;
         gboolean primary;
 
@@ -754,11 +746,10 @@ gdata_entry_postal_address_from_attribute (EVCardAttribute *attr, gboolean *have
             primary = FALSE;
         }
 
-        address = g_new0 (GDataEntryPostalAddress, 1);
-        address->address = g_strdup (values->data);
-        address->rel = google_rel_from_types (types);
-        address->label = g_strdup (label);
-        address->primary = primary;
+        rel = google_rel_from_types (types);
+        address = gdata_gd_postal_address_new (values->data, rel, label, primary);
+        g_free (rel);
+
         __debug__ ("New %spostal address entry %s (%s/%s)",
                     address->primary ? "primary " : "",
                     address->address,
diff --git a/addressbook/backends/google/util.h b/addressbook/backends/google/util.h
index 483e2b1..c952196 100644
--- a/addressbook/backends/google/util.h
+++ b/addressbook/backends/google/util.h
@@ -1,6 +1,7 @@
 /* util.h - Google contact backend utility functions.
  *
  * Copyright (C) 2008 Joergen Scheibengruber
+ * Copyright (C) 2009 Philip Withnall
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by the
@@ -23,7 +24,7 @@
 
 #include <libebook/e-vcard.h>
 #include <libebook/e-contact.h>
-#include <servers/google/libgdata/gdata-entry.h>
+#include <gdata/gdata-entry.h>
 
 extern gboolean __e_book_backend_google_debug__;
 
diff --git a/calendar/backends/google/Makefile.am b/calendar/backends/google/Makefile.am
index bfaefe8..f67e323 100644
--- a/calendar/backends/google/Makefile.am
+++ b/calendar/backends/google/Makefile.am
@@ -7,7 +7,7 @@ INCLUDES =						\
 	$(EVOLUTION_CALENDAR_CFLAGS)			\
 	$(SOUP_CFLAGS)					\
 	$(DEBUG_CFLAGS)					\
-	$(GDATA_CFLAGS)				
+	$(GDATA_CFLAGS)
 
 extension_LTLIBRARIES = libecalbackendgoogle.la
 



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