r3073 - in trunk/src/target/OM-2007.2/applications/openmoko-dialer2: . src

thomas at sita.openmoko.org thomas at sita.openmoko.org
Tue Oct 2 17:01:28 CEST 2007


Author: thomas
Date: 2007-10-02 17:01:27 +0200 (Tue, 02 Oct 2007)
New Revision: 3073

Modified:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-contacts.c
Log:
Patch by: Roman Moravcik <roman.moravcik at gmail.com>

* src/moko-contacts.c: (moko_contacts_add_contact): Read phone number from
VCARD.


Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-10-02 10:58:14 UTC (rev 3072)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-10-02 15:01:27 UTC (rev 3073)
@@ -2,6 +2,13 @@
 
 	Patch by: Roman Moravcik <roman.moravcik at gmail.com>
 
+	* src/moko-contacts.c: (moko_contacts_add_contact): Read phone number from
+	VCARD.
+
+2007-10-02  Thomas Wood  <thomas at openedhand.com>
+
+	Patch by: Roman Moravcik <roman.moravcik at gmail.com>
+
 	* src/moko-history.c: (moko_history_load_entries): History list wasn't
 	corectly filled with moko journal entries,
 	(on_delete_clicked), (history_add_entry): Function

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-contacts.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-contacts.c	2007-10-02 10:58:14 UTC (rev 3072)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-contacts.c	2007-10-02 15:01:27 UTC (rev 3073)
@@ -248,7 +248,7 @@
   MokoContactsPrivate *priv;
   MokoContact *m_contact = NULL;
   const gchar *name;
-  gint         i;
+  GList *attributes, *params, *numbers;
 
   g_return_if_fail (MOKO_IS_CONTACTS (contacts));
   g_return_if_fail (E_IS_CONTACT (e_contact));
@@ -267,24 +267,37 @@
   priv->contacts = g_list_append (priv->contacts, m_contact);
    
   /* Now go through the numbers,creating MokoNumber for them */
-  for (i = E_CONTACT_FIRST_PHONE_ID; i < E_CONTACT_LAST_PHONE_ID; i++)
+  for (attributes = e_vcard_get_attributes (E_VCARD(e_contact)); attributes; attributes = attributes->next)
   {
     MokoContactEntry  *entry;
     const gchar *phone;
+    const char *attr;
 
-    phone = e_contact_get_const (e_contact, i);
-    if (phone)
+    attr = e_vcard_attribute_get_name (attributes->data);
+    if (!strcmp (attr, EVC_TEL))
     {
-      entry = g_new0 (MokoContactEntry, 1);
-      entry->desc = g_strdup (e_contact_field_name (i));
-      entry->number = normalize (phone);
-      entry->contact = m_contact;
+      for (numbers = e_vcard_attribute_get_values (attributes->data); numbers; numbers = numbers->next)
+      {
+        phone = g_strdup (numbers->data);
+	 if (phone)
+        {
+          entry = g_new0 (MokoContactEntry, 1);
 
-      priv->entries = g_list_append (priv->entries, (gpointer)entry);
-      g_hash_table_insert (priv->prefixes, 
-                           g_strdup (entry->number), 
-                           (gpointer)entry);
-      add_number (&priv->start, entry);
+          params = e_vcard_attribute_get_param (attributes->data, "TYPE");
+          if (params)
+            entry->desc = g_strdup (params->data);
+
+          entry->desc = g_strdup (params->data);
+          entry->number = normalize (phone);
+          entry->contact = m_contact;
+
+          priv->entries = g_list_append (priv->entries, (gpointer)entry);
+          g_hash_table_insert (priv->prefixes, 
+                               g_strdup (entry->number), 
+                               (gpointer)entry);
+          add_number (&priv->start, entry);
+        }
+      }
     }
   }
 }





More information about the commitlog mailing list