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

thomas at sita.openmoko.org thomas at sita.openmoko.org
Thu Oct 18 12:28:57 CEST 2007


Author: thomas
Date: 2007-10-18 12:28:56 +0200 (Thu, 18 Oct 2007)
New Revision: 3218

Modified:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
   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
Log:
Patch by: Roman Moravcik <roman.moravcik at gmail.com>

* src/moko-dialer.c: (on_keypad_dial_clicked),
  (on_talking_accepted_call), (on_talking_reject_call),
  (on_incoming_call), (on_call_progress_changed):
  Set value of MokoJournal properties dtstart and dtend
  to indicate begin and end of call. When call was rejected
  or missed dtstart will has the same value as dtend.

* src/moko-talking.c: (moko_talking_incoming_call),
 (moko_talking_outgoing_call), (talking_timeout),
 (moko_talking_accepted_call), (on_cancel_clicked),
 (moko_init_tlking): Implemented displaying of call
 duration.

Closes bug 936 - Dialer doesn't display duration of call during call


Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-10-18 10:17:51 UTC (rev 3217)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-10-18 10:28:56 UTC (rev 3218)
@@ -1,3 +1,22 @@
+2007-10-18  Thomas Wood  <thomas at openedhand.com>
+
+	Patch by: Roman Moravcik <roman.moravcik at gmail.com>
+
+	* src/moko-dialer.c: (on_keypad_dial_clicked),
+	  (on_talking_accepted_call), (on_talking_reject_call),
+	  (on_incoming_call), (on_call_progress_changed):
+	  Set value of MokoJournal properties dtstart and dtend
+	  to indicate begin and end of call. When call was rejected
+	  or missed dtstart will has the same value as dtend.
+
+	* src/moko-talking.c: (moko_talking_incoming_call),
+	 (moko_talking_outgoing_call), (talking_timeout),
+	 (moko_talking_accepted_call), (on_cancel_clicked),
+	 (moko_init_tlking): Implemented displaying of call
+	 duration.
+
+	Closes bug 936 - Dialer doesn't display duration of call during call
+
 2007-10-16  Daniel Willmann <alphaone at openmoko.org>
 
         * src/moko-sound.{c,h}: Add GSM speaker out sound profile
@@ -1026,3 +1045,4 @@
 	* src/moko-dialer.h:
 	Intial Import
 
+/* vi: set noexpandtab sw=8 sts=8 ts=8: */

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-10-18 10:17:51 UTC (rev 3217)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-dialer.c	2007-10-18 10:28:56 UTC (rev 3218)
@@ -293,9 +293,7 @@
   if (priv->journal)
   {
     priv->entry = moko_journal_entry_new (VOICE_JOURNAL_ENTRY);
-    priv->time = moko_time_new_today ();
     moko_journal_entry_set_direction (priv->entry, DIRECTION_OUT);
-    moko_journal_entry_set_dtstart (priv->entry, priv->time);
     moko_journal_entry_set_source (priv->entry, "Openmoko Dialer");
     moko_journal_entry_set_gsm_location (priv->entry, &priv->gsm_location);
     moko_journal_voice_info_set_distant_number (priv->entry, number);
@@ -365,15 +363,6 @@
   /* Stop the notification */
   moko_notify_stop (priv->notify);  
   
-  /* Finalise and add the journal entry */
-  if (priv->journal && priv->entry)
-  {
-    moko_journal_add_entry (priv->journal, priv->entry);
-    moko_journal_write_to_storage (priv->journal);
-    priv->entry = NULL;
-    priv->time = NULL;
-  }  
-  
   g_signal_emit (G_OBJECT (dialer), dialer_signals[TALKING], 0);
 }
 
@@ -392,8 +381,11 @@
   gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), 0);
  
   /* Finalise and add the journal entry */
-  if (priv->entry)
+  if (priv->journal && priv->entry)
   {
+    priv->time = moko_time_new_today ();
+    moko_journal_entry_set_dtstart (priv->entry, priv->time);
+    moko_journal_entry_set_dtend (priv->entry, priv->time);
     moko_journal_voice_info_set_was_missed (priv->entry, TRUE);
     moko_journal_add_entry (priv->journal, priv->entry);
     moko_journal_write_to_storage (priv->journal);
@@ -541,9 +533,7 @@
   if (priv->journal)
   {
     priv->entry = moko_journal_entry_new (VOICE_JOURNAL_ENTRY);
-    priv->time = moko_time_new_today ();
     moko_journal_entry_set_direction (priv->entry, DIRECTION_IN);
-    moko_journal_entry_set_dtstart (priv->entry, priv->time);
     moko_journal_entry_set_source (priv->entry, "Openmoko Dialer");
     moko_journal_entry_set_gsm_location (priv->entry, &priv->gsm_location);
   }
@@ -620,7 +610,6 @@
                           MokoDialer *dialer)
 {
   MokoDialerPrivate *priv;
-  MessageDirection dir;
 
   g_return_if_fail (MOKO_IS_DIALER (dialer));
   priv = dialer->priv;
@@ -629,13 +618,17 @@
   {
     case MOKO_GSMD_PROG_DISCONNECT:
     case MOKO_GSMD_PROG_RELEASE:
-      moko_dialer_hung_up (dialer);
-      moko_keypad_set_talking (MOKO_KEYPAD (priv->keypad), FALSE);
+      /* Finalise and add the journal entry */
       if (priv->journal && priv->entry)
       {
-        moko_journal_entry_get_direction (priv->entry, &dir);
-        if (dir == DIRECTION_IN)
+        priv->time = moko_time_new_today ();
+        moko_journal_entry_set_dtend (priv->entry, priv->time);
+
+        if (priv->status == DIALER_STATUS_INCOMING)
+        {
+          moko_journal_entry_set_dtstart (priv->entry, priv->time);
           moko_journal_voice_info_set_was_missed (priv->entry, TRUE);
+        }
 
         moko_journal_add_entry (priv->journal, priv->entry);
         moko_journal_write_to_storage (priv->journal);
@@ -643,6 +636,9 @@
         priv->time = NULL;
       }
 
+      moko_dialer_hung_up (dialer);
+      moko_keypad_set_talking (MOKO_KEYPAD (priv->keypad), FALSE);
+
       if (priv->incoming_clip)
         g_free (priv->incoming_clip);
       priv->incoming_clip = NULL;
@@ -662,6 +658,13 @@
         moko_dialer_talking (dialer);
       moko_talking_accepted_call (MOKO_TALKING (priv->talking), NULL, NULL);
       moko_keypad_set_talking (MOKO_KEYPAD (priv->keypad), TRUE);
+
+      /* Update a journal entry */
+      if (priv->journal && priv->entry)
+      {
+        priv->time = moko_time_new_today ();
+        moko_journal_entry_set_dtstart (priv->entry, priv->time);
+      }
       g_debug ("mokogsmd connected");
       break;
     case MOKO_GSMD_PROG_SETUP:

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-10-18 10:17:51 UTC (rev 3217)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-talking.c	2007-10-18 10:28:56 UTC (rev 3218)
@@ -39,6 +39,7 @@
   GtkWidget          *main_bar;
 
   GtkWidget          *title;
+  GtkWidget          *duration;
   GtkWidget          *icon;
 
   GtkWidget          *person;
@@ -48,6 +49,7 @@
   GdkPixbuf          *incoming[4];
   GdkPixbuf          *outgoing[4];
 
+  GTimer             *dtimer;
   guint               timeout;
 };
 
@@ -128,6 +130,7 @@
   gtk_widget_show (priv->incoming_bar);
 
   gtk_label_set_text (GTK_LABEL (priv->title), "Incoming Call");
+  gtk_label_set_text (GTK_LABEL (priv->duration), "");
   gtk_image_set_from_file (GTK_IMAGE (priv->icon), 
                            PKGDATADIR"/incoming_3.png");
 
@@ -181,6 +184,7 @@
     markup = g_strdup (number);
 
   gtk_label_set_text (GTK_LABEL (priv->title), "Outgoing Call");
+  gtk_label_set_text (GTK_LABEL (priv->duration), "");
 
   gtk_label_set_markup (GTK_LABEL (priv->status), markup);
   
@@ -202,11 +206,26 @@
 talking_timeout (MokoTalking *talking)
 {
   MokoTalkingPrivate *priv;
+  gdouble elapsed;
+  gint hour, min, sec;
+  gchar *markup = NULL;
   static gint i = 0;
 
   g_return_val_if_fail (MOKO_IS_TALKING (talking), FALSE);
   priv = talking->priv;
 
+  if (priv->dtimer)
+  {
+    elapsed = g_timer_elapsed(priv->dtimer, NULL);
+
+    hour = (gint) (elapsed / 3600);
+    min = (gint) ((elapsed - 3600 * hour) / 60);
+    sec = (gint) (elapsed - 3600 * hour - 60 * min);
+
+    markup = g_strdup_printf ("%02d:%02d:%02d", hour, min, sec);
+    gtk_label_set_markup (GTK_LABEL (priv->duration), markup);
+  }
+
   gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon), 
                              priv->talking[i]);
   
@@ -214,6 +233,7 @@
   if (i == 5)
     i = 0;
   
+  g_free(markup);
   return TRUE;
 }
   
@@ -239,9 +259,15 @@
     markup = g_strdup (number);
 
   gtk_label_set_text (GTK_LABEL (priv->title), "Talking");
+  gtk_label_set_text (GTK_LABEL (priv->duration), "00:00:00");
   gtk_image_set_from_file (GTK_IMAGE (priv->icon), 
                            PKGDATADIR"/talking_3.png");
 
+  /* start call duration timer */
+  if (priv->dtimer)
+    g_timer_destroy(priv->dtimer);
+  priv->dtimer = g_timer_new();
+
   /* We don't change the status or person widgets, as incoming call has already
    * set them for us.
    */
@@ -278,6 +304,10 @@
 static void
 on_cancel_clicked (GtkToolButton *button, MokoTalking *talking)
 {
+  /* stop call duration timer */
+  if (talking->priv->dtimer)
+    g_timer_destroy(talking->priv->dtimer);
+
   g_source_remove (talking->priv->timeout);
   moko_sound_profile_set(SOUND_PROFILE_STEREO_OUT);
   g_signal_emit (G_OBJECT (talking), talking_signals[CANCEL_CALL], 0);
@@ -364,6 +394,7 @@
 {
   MokoTalkingPrivate *priv;
   GtkWidget *toolbar, *image, *vbox, *hbox, *label, *align, *frame;
+  GtkWidget *duration;
   GtkToolItem *item;
   GdkPixbuf *icon;
   gint i;
@@ -448,6 +479,10 @@
   priv->icon = image = gtk_image_new ();
   gtk_container_add (GTK_CONTAINER (align), image);
 
+  priv->duration = duration = gtk_label_new ("00:00:00");
+  gtk_misc_set_alignment (GTK_MISC (duration), 0.5, 0.5);
+  gtk_box_pack_start (GTK_BOX (vbox), duration, FALSE, FALSE, 0);
+
   /* The status area */
   align = gtk_alignment_new (0.5, 0.5, 1, 0 );
   gtk_box_pack_start (GTK_BOX (talking), align, TRUE, TRUE, 0);





More information about the commitlog mailing list