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

njp at sita.openmoko.org njp at sita.openmoko.org
Fri Aug 3 12:40:00 CEST 2007


Author: njp
Date: 2007-08-03 12:39:58 +0200 (Fri, 03 Aug 2007)
New Revision: 2614

Modified:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-contacts.c
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-talking.c
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-talking.h
Log:
2007-08-03  Neil J. Patel  <njp at o-hand.com>

	* src/moko-contacts.c: (moko_contacts_get_photo),
	(moko_contacts_lookup), (moko_contacts_add_contact),
	(moko_contacts_init):
	When searching for a contact, it it doesn't have a photo, look for it.
	
	* src/moko-dialer.c: (on_incoming_call), (on_incoming_clip),
	(register_network_cb):
	Set the incoming clip on the 'talking' widget.

	* src/moko-talking.c: (moko_talking_set_clip),
	(moko_talking_outgoing_call), (moko_talking_accepted_call):
	* src/moko-talking.h:
	Add a method to update the UI with an incomig clip.

2007-08-02  Neil J. Patel  <njp at o-hand.com>

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-08-03 08:48:20 UTC (rev 2613)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-08-03 10:39:58 UTC (rev 2614)
@@ -1,3 +1,19 @@
+2007-08-03  Neil J. Patel  <njp at o-hand.com>
+
+	* src/moko-contacts.c: (moko_contacts_get_photo),
+	(moko_contacts_lookup), (moko_contacts_add_contact),
+	(moko_contacts_init):
+	When searching for a contact, it it doesn't have a photo, look for it.
+	
+	* src/moko-dialer.c: (on_incoming_call), (on_incoming_clip),
+	(register_network_cb):
+	Set the incoming clip on the 'talking' widget.
+
+	* src/moko-talking.c: (moko_talking_set_clip),
+	(moko_talking_outgoing_call), (moko_talking_accepted_call):
+	* src/moko-talking.h:
+	Add a method to update the UI with an incomig clip.
+
 2007-08-02  Neil J. Patel  <njp at o-hand.com>
 
 	* src/moko-dialer.c: (on_incoming_call), (on_pin_requested),

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-08-03 08:48:20 UTC (rev 2613)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-contacts.c	2007-08-03 10:39:58 UTC (rev 2614)
@@ -35,21 +35,64 @@
 
 struct _MokoContactsPrivate
 {
+  EBook      *book;
+
   GList      *contacts;
   GList      *entries;
   GHashTable *prefixes;
 };
 
+static void
+moko_contacts_get_photo (MokoContacts *contacts, MokoContact *m_contact)
+{
+  MokoContactsPrivate *priv;
+  EContact *e_contact;
+  EContactPhoto *photo;
+  GError *err = NULL;
+  GdkPixbufLoader *loader;
+  
+  g_return_if_fail (MOKO_IS_CONTACTS (contacts));
+  priv = contacts->priv;
+  
+  if (!e_book_get_contact (priv->book, m_contact->uid, &e_contact, &err))
+  {
+    g_warning ("%s\n", err->message);
+    m_contact->photo = gdk_pixbuf_new_from_file (PKGDATADIR"/person.png", NULL);
+    g_object_ref (m_contact->photo);
+    return;
+  }
 
+  photo = e_contact_get (e_contact, E_CONTACT_PHOTO);
+
+  loader = gdk_pixbuf_loader_new ();
+  gdk_pixbuf_loader_write (loader, 
+                           photo->data.inlined.data,
+                           photo->data.inlined.length,
+                           NULL);
+  gdk_pixbuf_loader_close (loader, NULL);
+
+  m_contact->photo = gdk_pixbuf_loader_get_pixbuf (loader);
+  if (GDK_IS_PIXBUF (m_contact->photo))
+    g_object_ref (m_contact->photo);
+
+  g_object_unref (loader);
+}
+
 MokoContactEntry*
 moko_contacts_lookup (MokoContacts *contacts, const gchar *number)
 {
   MokoContactsPrivate *priv;
+  MokoContactEntry *entry;
 
   g_return_val_if_fail (MOKO_IS_CONTACTS (contacts), NULL);
   priv = contacts->priv;
   
-  return g_hash_table_lookup (priv->prefixes, number);
+  entry =  g_hash_table_lookup (priv->prefixes, number);
+
+  if (!GDK_IS_PIXBUF (entry->contact->photo))
+    moko_contacts_get_photo (contacts, entry->contact);
+
+  return entry;
 }
 
 GList*
@@ -100,7 +143,7 @@
 
   name = e_contact_get_const (e_contact, E_CONTACT_NAME_OR_ORG);
   if (!name || (g_utf8_strlen (name, -1) <= 0))
-    name = "Unnamed";
+    name = "Unknown";
     
   /* Create the contact & append to the list */
   m_contact = g_new0 (MokoContact, 1);
@@ -197,7 +240,7 @@
   EBook *book;
   EBookView *view;
   EBookQuery *query;
-  GList *contact, *c, *e;
+  GList *contact, *c;
 
   priv = contacts->priv = MOKO_CONTACTS_GET_PRIVATE (contacts);
 
@@ -208,7 +251,7 @@
   query = e_book_query_any_field_contains ("");
 
   /* Open the system book and check that it is valid */
-  book = e_book_new_system_addressbook (NULL);
+  book = priv->book = e_book_new_system_addressbook (NULL);
   if (!book)
   {
     g_warning ("Failed to create system book\n");

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c	2007-08-03 08:48:20 UTC (rev 2613)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c	2007-08-03 10:39:58 UTC (rev 2614)
@@ -353,7 +353,7 @@
   /* We sometimes get the signals multiple times */
   if (priv->status == DIALER_STATUS_INCOMING)
   {
-    g_print ("We are already showing the incoming page");
+    g_print ("We are already showing the incoming page\n");
     return;
   }
   g_print ("Status = %d\n", priv->status);
@@ -381,7 +381,16 @@
                   const gchar        *number,
                   MokoDialer         *dialer)
 {
-  g_print ("Number = %s\n", number);
+  MokoDialerPrivate *priv;
+  MokoContactEntry *entry;
+
+  g_return_if_fail (MOKO_IS_DIALER (dialer));
+  priv = dialer->priv;
+  
+  entry = moko_contacts_lookup (priv->contacts, number);
+  moko_talking_set_clip (MOKO_TALKING (priv->talking), number, entry);
+
+  g_print ("Incoming Number = %s\n", number);
 }
 
 static void
@@ -458,7 +467,7 @@
   {
     /* We have yet to request registration, so lets do it */
     /* FIXME: do the pin stuff */
-    g_print ("Requesting registration");
+    g_print ("Requesting registration\n");
     moko_gsmd_connection_network_register (priv->connection);
   }
   else 
@@ -468,12 +477,12 @@
      */
     if (priv->registered)
     {
-      g_print ("Netwok Registered");
+      g_print ("Netwok Registered\n");
       return FALSE;
     }
     else
     {
-      g_print ("Requesting registration");
+      g_print ("Requesting registration\n");
       moko_gsmd_connection_network_register (priv->connection);
     }
   }

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-talking.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-talking.c	2007-08-03 08:48:20 UTC (rev 2613)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-talking.c	2007-08-03 10:39:58 UTC (rev 2614)
@@ -62,6 +62,34 @@
 
 static guint talking_signals[LAST_SIGNAL] = {0, };
 
+
+void
+moko_talking_set_clip (MokoTalking      *talking, 
+                       const gchar      *number,
+                       MokoContactEntry *entry)
+{
+  MokoTalkingPrivate *priv;
+  gchar *markup;
+  
+  g_return_if_fail (MOKO_IS_TALKING (talking));
+  priv = talking->priv;
+
+  if (entry)
+    markup = g_strdup_printf ("<b>%s</b>\n%s", entry->contact->name, number);
+  else
+    markup = g_strdup (number);
+
+  gtk_label_set_markup (GTK_LABEL (priv->status), markup);
+  
+  if (entry && GDK_IS_PIXBUF (entry->contact->photo))
+    gtk_image_set_from_pixbuf (GTK_IMAGE (priv->person), entry->contact->photo);
+  else
+    gtk_image_set_from_file (GTK_IMAGE (priv->person),
+                             PKGDATADIR"/unkown.png");
+
+  g_free (markup);
+}
+
 static gboolean
 incoming_timeout (MokoTalking *talking)
 {
@@ -148,8 +176,12 @@
   gtk_label_set_text (GTK_LABEL (priv->title), "Outgoing Call");
 
   gtk_label_set_markup (GTK_LABEL (priv->status), markup);
-  gtk_image_set_from_file (GTK_IMAGE (priv->person),
-                           PKGDATADIR"/unkown.png");
+  
+  if (entry && GDK_IS_PIXBUF (entry->contact->photo))
+    gtk_image_set_from_pixbuf (GTK_IMAGE (priv->person), entry->contact->photo);
+  else
+    gtk_image_set_from_file (GTK_IMAGE (priv->person),
+                             PKGDATADIR"/unkown.png");
 
   g_source_remove (priv->timeout);
   priv->timeout = g_timeout_add (1000, 
@@ -201,10 +233,9 @@
   gtk_image_set_from_file (GTK_IMAGE (priv->icon), 
                            PKGDATADIR"/talking_3.png");
 
-  gtk_label_set_text (GTK_LABEL (priv->status), number);
-  gtk_image_set_from_file (GTK_IMAGE (priv->person),
-                           PKGDATADIR"/unkown.png");
-  
+  /* We don't change the status or person widgets, as incoming call has already
+   * set them for us.
+   */
   g_source_remove (priv->timeout);
   priv->timeout = g_timeout_add (1000, 
                                  (GSourceFunc)talking_timeout,

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-talking.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-talking.h	2007-08-03 08:48:20 UTC (rev 2613)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-talking.h	2007-08-03 10:39:58 UTC (rev 2614)
@@ -1,6 +1,5 @@
 /*
- *  moko-talking; a GObject wrapper for the talking which exports method and
- *  signals over dbus
+ *  moko-talking; a GObject wrapper for the talking/incoming/outgoing page
  *
  *  Authored by OpenedHand Ltd <info at openedhand.com>
  *
@@ -89,6 +88,11 @@
                             const gchar      *number,
                             MokoContactEntry *entry);
 
+void
+moko_talking_set_clip (MokoTalking      *talking, 
+                       const gchar      *number,
+                       MokoContactEntry *entry);
+
 G_END_DECLS
 
 #endif /* _HAVE_MOKO_TALKING_H */





More information about the commitlog mailing list