[evolution-couchdb] Set phone numbers when creating contact
- From: Rodrigo Moya <rodrigo src gnome org>
- To: svn-commits-list gnome org
- Subject: [evolution-couchdb] Set phone numbers when creating contact
- Date: Wed, 24 Jun 2009 15:26:18 +0000 (UTC)
commit 96f5290f037aca5128137f8def055c4cd8e67262
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Wed Jun 24 16:30:57 2009 +0200
Set phone numbers when creating contact
addressbook/e-book-backend-couchdb.c | 49 ++++++++++++++++++++++++++++-----
1 files changed, 41 insertions(+), 8 deletions(-)
---
diff --git a/addressbook/e-book-backend-couchdb.c b/addressbook/e-book-backend-couchdb.c
index 390ea59..8178562 100644
--- a/addressbook/e-book-backend-couchdb.c
+++ b/addressbook/e-book-backend-couchdb.c
@@ -22,6 +22,7 @@
*/
#include "e-book-backend-couchdb.h"
+#include <libedata-book/e-data-book.h>
G_DEFINE_TYPE (EBookBackendCouchDB, e_book_backend_couchdb, E_TYPE_BOOK_BACKEND);
@@ -231,6 +232,7 @@ e_book_backend_couchdb_create_contact (EBookBackend *backend,
GError *error = NULL;
GSList *list;
gint i;
+ const char *str;
EBookBackendCouchDB *couchdb_backend = E_BOOK_BACKEND_COUCHDB (backend);
static guint uid_count = 0;
@@ -243,22 +245,20 @@ e_book_backend_couchdb_create_contact (EBookBackend *backend,
/* create the CouchDBDocument to put on the database */
document = couchdb_document_new (couchdb_backend->couchdb);
- couchdb_document_contact_set_first_name (document, (const char *) e_contact_get (contact, E_CONTACT_GIVEN_NAME));
- couchdb_document_contact_set_last_name (document, (const char *) e_contact_get (contact, E_CONTACT_FAMILY_NAME));
+ couchdb_document_contact_set_first_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_GIVEN_NAME));
+ couchdb_document_contact_set_last_name (document, (const char *) e_contact_get_const (contact, E_CONTACT_FAMILY_NAME));
/* email addresses */
list = NULL;
for (i = E_CONTACT_FIRST_EMAIL_ID; i <= E_CONTACT_LAST_EMAIL_ID; i++) {
- gchar *email;
+ const gchar *email;
- email = e_contact_get (contact, i);
+ email = e_contact_get_const (contact, i);
if (email) {
CouchDBStructField *sf;
sf = couchdb_document_contact_email_new (email, /* FIXME */ NULL);
list = g_slist_append (list, sf);
-
- g_free (email);
}
}
@@ -269,10 +269,43 @@ e_book_backend_couchdb_create_contact (EBookBackend *backend,
g_slist_free (list);
}
- /* FIXME: phone numbers */
+ /* phone numbers */
+ list = NULL;
+ str = e_contact_get_const (contact, E_CONTACT_PHONE_HOME);
+ if (str) {
+ CouchDBStructField *sf;
+
+ sf = couchdb_document_contact_phone_new (str, "home", /* FIXME */ 0);
+ list = g_slist_append (list, sf);
+ }
+
+ str = e_contact_get_const (contact, E_CONTACT_PHONE_BUSINESS);
+ if (str) {
+ CouchDBStructField *sf;
+
+ sf = couchdb_document_contact_phone_new (str, "work", /* FIXME */ 0);
+ list = g_slist_append (list, sf);
+ }
+
+ str = e_contact_get_const (contact, E_CONTACT_PHONE_OTHER);
+ if (str) {
+ CouchDBStructField *sf;
+
+ sf = couchdb_document_contact_phone_new (str, "other", /* FIXME */ 0);
+ list = g_slist_append (list, sf);
+ }
+
+ if (list) {
+ couchdb_document_contact_set_phone_numbers (document, list);
+
+ g_slist_foreach (list, (GFunc) couchdb_struct_field_unref, NULL);
+ g_slist_free (list);
+ }
+
/* FIXME: addresses */
- dt = (EContactDate *) e_contact_get (contact, E_CONTACT_BIRTH_DATE);
+ /* birth date */
+ dt = (EContactDate *) e_contact_get_const (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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]