| 1 | --- addressbook/backends/google/e-book-backend-google.c.orig 2013-05-09 15:13:08.000000000 -0700 |
| 2 | +++ addressbook/backends/google/e-book-backend-google.c 2013-05-09 15:20:35.000000000 -0700 |
| 3 | @@ -511,7 +511,11 @@ |
| 4 | GTimeVal updated; |
| 5 | |
| 6 | g_assert (g_time_val_from_iso8601 (last_updated, &updated) == TRUE); |
| 7 | - gdata_query_set_updated_min (query, &updated); |
| 8 | + #ifdef HAVE_GDATA_07 |
| 9 | + gdata_query_set_updated_min (query, updated.tv_sec); |
| 10 | + #else |
| 11 | + gdata_query_set_updated_min (query, &updated); |
| 12 | + #endif |
| 13 | gdata_contacts_query_set_show_deleted (GDATA_CONTACTS_QUERY (query), TRUE); |
| 14 | } |
| 15 | |
| 16 | @@ -788,11 +792,18 @@ |
| 17 | g_free (xml); |
| 18 | |
| 19 | /* Update the contact on the server */ |
| 20 | - new_entry = GDATA_ENTRY ( |
| 21 | - gdata_contacts_service_update_contact ( |
| 22 | - GDATA_CONTACTS_SERVICE (priv->service), |
| 23 | - GDATA_CONTACTS_CONTACT (entry), |
| 24 | - NULL, &error)); |
| 25 | + #ifdef HAVE_GDATA_07 |
| 26 | + new_entry = gdata_service_update_entry ( |
| 27 | + GDATA_SERVICE (priv->service), |
| 28 | + entry, |
| 29 | + NULL, &error); |
| 30 | + #else |
| 31 | + new_entry = GDATA_ENTRY ( |
| 32 | + gdata_contacts_service_update_contact ( |
| 33 | + GDATA_CONTACTS_SERVICE (priv->service), |
| 34 | + GDATA_CONTACTS_CONTACT (entry), |
| 35 | + NULL, &error)); |
| 36 | + #endif |
| 37 | g_object_unref (entry); |
| 38 | |
| 39 | if (!new_entry) { |
| 40 | @@ -1189,6 +1200,12 @@ |
| 41 | E_CONTACT_ORG_UNIT, |
| 42 | E_CONTACT_TITLE, |
| 43 | E_CONTACT_ROLE, |
| 44 | + #ifdef HAVE_GDATA_07 |
| 45 | + E_CONTACT_HOMEPAGE_URL, |
| 46 | + E_CONTACT_BLOG_URL, |
| 47 | + E_CONTACT_BIRTH_DATE, |
| 48 | + E_CONTACT_ANNIVERSARY, |
| 49 | + #endif |
| 50 | E_CONTACT_NOTE |
| 51 | }; |
| 52 | |
| 53 | --- addressbook/backends/google/util.c.orig 2013-05-09 15:25:00.000000000 -0700 |
| 54 | +++ addressbook/backends/google/util.c 2013-05-09 15:33:18.000000000 -0700 |
| 55 | @@ -58,6 +58,57 @@ |
| 56 | return NULL; |
| 57 | } |
| 58 | |
| 59 | +#ifdef HAVE_GDATA_07 |
| 60 | +static void |
| 61 | +remove_anniversary (GDataContactsContact *contact) |
| 62 | +{ |
| 63 | + GList *events, *itr; |
| 64 | + |
| 65 | + events = gdata_contacts_contact_get_events (contact); |
| 66 | + if (!events) |
| 67 | + return; |
| 68 | + |
| 69 | + events = g_list_copy (events); |
| 70 | + g_list_foreach (events, (GFunc) g_object_ref, NULL); |
| 71 | + |
| 72 | + gdata_contacts_contact_remove_all_events (contact); |
| 73 | + for (itr = events; itr; itr = itr->next) { |
| 74 | + GDataGContactEvent *event = itr->data; |
| 75 | + |
| 76 | + if (g_strcmp0 (gdata_gcontact_event_get_relation_type (event), GDATA_GCONTACT_EVENT_ANNIVERSARY) != 0) |
| 77 | + gdata_contacts_contact_add_event (contact, event); |
| 78 | + } |
| 79 | + |
| 80 | + g_list_foreach (events, (GFunc) g_object_unref, NULL); |
| 81 | + g_list_free (events); |
| 82 | +} |
| 83 | + |
| 84 | +static void |
| 85 | +remove_websites (GDataContactsContact *contact) |
| 86 | +{ |
| 87 | + GList *websites, *itr; |
| 88 | + |
| 89 | + websites = gdata_contacts_contact_get_websites (contact); |
| 90 | + if (!websites) |
| 91 | + return; |
| 92 | + |
| 93 | + websites = g_list_copy (websites); |
| 94 | + g_list_foreach (websites, (GFunc) g_object_ref, NULL); |
| 95 | + |
| 96 | + gdata_contacts_contact_remove_all_websites (contact); |
| 97 | + for (itr = websites; itr; itr = itr->next) { |
| 98 | + GDataGContactWebsite *website = itr->data; |
| 99 | + |
| 100 | + if (g_strcmp0 (gdata_gcontact_website_get_relation_type (website), GDATA_GCONTACT_WEBSITE_HOME_PAGE) != 0 && |
| 101 | + g_strcmp0 (gdata_gcontact_website_get_relation_type (website), GDATA_GCONTACT_WEBSITE_BLOG) != 0) |
| 102 | + gdata_contacts_contact_add_website (contact, website); |
| 103 | + } |
| 104 | + |
| 105 | + g_list_foreach (websites, (GFunc) g_object_unref, NULL); |
| 106 | + g_list_free (websites); |
| 107 | +} |
| 108 | +#endif |
| 109 | + |
| 110 | gboolean |
| 111 | _gdata_entry_update_from_e_contact (GDataEntry *entry, EContact *contact) |
| 112 | { |
| 113 | @@ -69,6 +120,10 @@ |
| 114 | gboolean have_postal_primary = FALSE; |
| 115 | gboolean have_org_primary = FALSE; |
| 116 | const gchar *title, *role, *note; |
| 117 | + #ifdef HAVE_GDATA_07 |
| 118 | + EContactDate *bdate; |
| 119 | + const gchar *url; |
| 120 | + #endif |
| 121 | |
| 122 | attributes = e_vcard_get_attributes (E_VCARD (contact)); |
| 123 | |
| 124 | @@ -214,6 +269,58 @@ |
| 125 | gdata_gd_organization_set_job_description (org, role); |
| 126 | } |
| 127 | |
| 128 | + #ifdef HAVE_GDATA_07 |
| 129 | + remove_websites (GDATA_CONTACTS_CONTACT (entry)); |
| 130 | + |
| 131 | + url = e_contact_get_const (contact, E_CONTACT_HOMEPAGE_URL); |
| 132 | + if (url && *url) { |
| 133 | + GDataGContactWebsite *website = gdata_gcontact_website_new (url, GDATA_GCONTACT_WEBSITE_HOME_PAGE, NULL, FALSE); |
| 134 | + if (website) { |
| 135 | + gdata_contacts_contact_add_website (GDATA_CONTACTS_CONTACT (entry), website); |
| 136 | + g_object_unref (website); |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + url = e_contact_get_const (contact, E_CONTACT_BLOG_URL); |
| 141 | + if (url && *url) { |
| 142 | + GDataGContactWebsite *website = gdata_gcontact_website_new (url, GDATA_GCONTACT_WEBSITE_BLOG, NULL, FALSE); |
| 143 | + if (website) { |
| 144 | + gdata_contacts_contact_add_website (GDATA_CONTACTS_CONTACT (entry), website); |
| 145 | + g_object_unref (website); |
| 146 | + } |
| 147 | + } |
| 148 | + |
| 149 | + gdata_contacts_contact_set_birthday (GDATA_CONTACTS_CONTACT (entry), NULL, TRUE); |
| 150 | + bdate = e_contact_get (contact, E_CONTACT_BIRTH_DATE); |
| 151 | + if (bdate) { |
| 152 | + GDate *gdate = g_date_new_dmy (bdate->day, bdate->month, bdate->year); |
| 153 | + |
| 154 | + if (gdate) { |
| 155 | + gdata_contacts_contact_set_birthday (GDATA_CONTACTS_CONTACT (entry), gdate, TRUE); |
| 156 | + g_date_free (gdate); |
| 157 | + } |
| 158 | + e_contact_date_free (bdate); |
| 159 | + } |
| 160 | + |
| 161 | + remove_anniversary (GDATA_CONTACTS_CONTACT (entry)); |
| 162 | + bdate = e_contact_get (contact, E_CONTACT_ANNIVERSARY); |
| 163 | + if (bdate) { |
| 164 | + GDate *gdate = g_date_new_dmy (bdate->day, bdate->month, bdate->year); |
| 165 | + |
| 166 | + if (gdate) { |
| 167 | + GDataGContactEvent *anni = gdata_gcontact_event_new (gdate, GDATA_GCONTACT_EVENT_ANNIVERSARY, NULL); |
| 168 | + |
| 169 | + if (anni) { |
| 170 | + gdata_contacts_contact_add_event (GDATA_CONTACTS_CONTACT (entry), anni); |
| 171 | + g_object_unref (anni); |
| 172 | + } |
| 173 | + |
| 174 | + g_date_free (gdate); |
| 175 | + } |
| 176 | + e_contact_date_free (bdate); |
| 177 | + } |
| 178 | + #endif |
| 179 | + |
| 180 | return TRUE; |
| 181 | } |
| 182 | |
| 183 | @@ -241,6 +348,11 @@ |
| 184 | GDataGDPostalAddress *postal_address; |
| 185 | GDataGDOrganization *org; |
| 186 | GHashTable *extended_props; |
| 187 | + #ifdef HAVE_GDATA_07 |
| 188 | + GList *websites, *events; |
| 189 | + GDate bdate; |
| 190 | + gboolean bdate_has_year; |
| 191 | + #endif |
| 192 | |
| 193 | uid = gdata_entry_get_id (entry); |
| 194 | if (NULL == uid) |
| 195 | @@ -352,6 +464,84 @@ |
| 196 | extended_props = gdata_contacts_contact_get_extended_properties (GDATA_CONTACTS_CONTACT (entry)); |
| 197 | g_hash_table_foreach (extended_props, (GHFunc) foreach_extended_props_cb, vcard); |
| 198 | |
| 199 | + #ifdef HAVE_GDATA_07 |
| 200 | + websites = gdata_contacts_contact_get_websites (GDATA_CONTACTS_CONTACT (entry)); |
| 201 | + for (itr = websites; itr != NULL; itr = itr->next) { |
| 202 | + GDataGContactWebsite *website = itr->data; |
| 203 | + const gchar *uri, *reltype; |
| 204 | + |
| 205 | + if (!website) |
| 206 | + continue; |
| 207 | + |
| 208 | + uri = gdata_gcontact_website_get_uri (website); |
| 209 | + reltype = gdata_gcontact_website_get_relation_type (website); |
| 210 | + |
| 211 | + if (!uri || !*uri || !reltype) |
| 212 | + continue; |
| 213 | + |
| 214 | + if (g_str_equal (reltype, GDATA_GCONTACT_WEBSITE_HOME_PAGE)) |
| 215 | + e_contact_set (E_CONTACT (vcard), E_CONTACT_HOMEPAGE_URL, uri); |
| 216 | + else if (g_str_equal (reltype, GDATA_GCONTACT_WEBSITE_BLOG)) |
| 217 | + e_contact_set (E_CONTACT (vcard), E_CONTACT_BLOG_URL, uri); |
| 218 | + } |
| 219 | + |
| 220 | + g_date_clear (&bdate, 1); |
| 221 | + bdate_has_year = gdata_contacts_contact_get_birthday (GDATA_CONTACTS_CONTACT (entry), &bdate); |
| 222 | + if (!bdate_has_year) { |
| 223 | + GTimeVal curr_time = { 0 }; |
| 224 | + GDate tmp_date; |
| 225 | + |
| 226 | + g_get_current_time (&curr_time); |
| 227 | + g_date_clear (&tmp_date, 1); |
| 228 | + g_date_set_time_val (&tmp_date, &curr_time); |
| 229 | + |
| 230 | + g_date_set_year (&bdate, g_date_get_year (&tmp_date)); |
| 231 | + } |
| 232 | + |
| 233 | + if (g_date_valid (&bdate)) { |
| 234 | + EContactDate *date = e_contact_date_new (); |
| 235 | + |
| 236 | + if (date) { |
| 237 | + date->day = g_date_get_day (&bdate); |
| 238 | + date->month = g_date_get_month (&bdate); |
| 239 | + date->year = g_date_get_year (&bdate); |
| 240 | + |
| 241 | + e_contact_set (E_CONTACT (vcard), E_CONTACT_BIRTH_DATE, date); |
| 242 | + e_contact_date_free (date); |
| 243 | + } |
| 244 | + } |
| 245 | + |
| 246 | + events = gdata_contacts_contact_get_events (GDATA_CONTACTS_CONTACT (entry)); |
| 247 | + for (itr = events; itr; itr = itr->next) { |
| 248 | + GDataGContactEvent *event = itr->data; |
| 249 | + |
| 250 | + if (!event) |
| 251 | + continue; |
| 252 | + |
| 253 | + if (!gdata_gcontact_event_get_relation_type (event) || |
| 254 | + !g_str_equal (gdata_gcontact_event_get_relation_type (event), GDATA_GCONTACT_EVENT_ANNIVERSARY)) |
| 255 | + continue; |
| 256 | + |
| 257 | + g_date_clear (&bdate, 1); |
| 258 | + gdata_gcontact_event_get_date (event, &bdate); |
| 259 | + |
| 260 | + if (g_date_valid (&bdate)) { |
| 261 | + EContactDate *date = e_contact_date_new (); |
| 262 | + |
| 263 | + if (date) { |
| 264 | + date->day = g_date_get_day (&bdate); |
| 265 | + date->month = g_date_get_month (&bdate); |
| 266 | + date->year = g_date_get_year (&bdate); |
| 267 | + |
| 268 | + e_contact_set (E_CONTACT (vcard), E_CONTACT_ANNIVERSARY, date); |
| 269 | + e_contact_date_free (date); |
| 270 | + } |
| 271 | + } |
| 272 | + |
| 273 | + break; |
| 274 | + } |
| 275 | + #endif |
| 276 | + |
| 277 | return E_CONTACT (vcard); |
| 278 | } |
| 279 | |