[evolution-couchdb] Use e_contact_get for dates, since e_contact_get_const just works for strings,



commit 6204a04e16870addb3d64d3ef26d2b383e67735c
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Wed Nov 11 18:36:29 2009 +0100

    Use e_contact_get for dates, since e_contact_get_const just works for strings,
    and make sure we never set empty dates on contact records

 addressbook/e-book-backend-couchdb.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/addressbook/e-book-backend-couchdb.c b/addressbook/e-book-backend-couchdb.c
index 3d46aa1..17d49f7 100644
--- a/addressbook/e-book-backend-couchdb.c
+++ b/addressbook/e-book-backend-couchdb.c
@@ -787,21 +787,25 @@ couch_document_from_contact (EBookBackendCouchDB *couchdb_backend, EContact *con
 	}
 
 	/* birth date */
-	dt = (EContactDate *) e_contact_get_const (contact, E_CONTACT_BIRTH_DATE);
+	dt = (EContactDate *) e_contact_get (contact, E_CONTACT_BIRTH_DATE);
 	if (dt) {
 		char *dt_str = e_contact_date_to_string (dt);
-		couchdb_document_contact_set_birth_date (document, (const char *) dt_str);
+		if (dt_str != NULL) {
+			couchdb_document_contact_set_birth_date (document, (const char *) dt_str);
 
-		g_free (dt_str);
+			g_free (dt_str);
+		}
 	}
 
 	/* wedding date */
-	dt = (EContactDate *) e_contact_get_const (contact, E_CONTACT_ANNIVERSARY);
+	dt = (EContactDate *) e_contact_get (contact, E_CONTACT_ANNIVERSARY);
 	if (dt) {
 		char *dt_str = e_contact_date_to_string (dt);
-		couchdb_document_contact_set_wedding_date (document, (const char *) dt_str);
+		if (dt_str != NULL) {
+			couchdb_document_contact_set_wedding_date (document, (const char *) dt_str);
 
-		g_free (dt_str);
+			g_free (dt_str);
+		}
 	}
 
 	/* application annotations */



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