r2071 - trunk/src/target/OM-2007/applications/openmoko-dialer/src

thomas at sita.openmoko.org thomas at sita.openmoko.org
Wed May 23 18:00:22 CEST 2007


Author: thomas
Date: 2007-05-23 18:00:21 +0200 (Wed, 23 May 2007)
New Revision: 2071

Modified:
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-outgoing.c
Log:
openmoko-dialer:
 * add a journal entry for incoming calls
 * cancel incoming call window if call is disconnected
 * cancel outgoing window if call is rejected
 * remove some unrequired code from dialer-window-outgoing.c


Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c	2007-05-23 13:56:01 UTC (rev 2070)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-incoming.c	2007-05-23 16:00:21 UTC (rev 2071)
@@ -221,14 +221,41 @@
 
 }
 
+static void
+call_progress_cb (MokoGsmdConnection *connection, int type, MokoDialerData *data)
+{
+  if (type == MOKO_GSMD_PROG_DISCONNECT)
+  {
+    /* call was disconnected before it was answered */
+    gtk_dialog_response (GTK_DIALOG (data->window_incoming), GTK_RESPONSE_CANCEL);
+  }
+}
+
+
 void
 window_incoming_show (MokoDialerData *data)
 {
+  MokoJournalEntry *entry = NULL;
+  MokoJournalVoiceInfo *info = NULL;
+  gulong progress_handler;
+
   if (!data->window_incoming)
   {
     window_incoming_init (data);
   }
 
+  /* create the journal entry for this call and add it to the journal */
+  entry = moko_journal_entry_new (VOICE_JOURNAL_ENTRY);
+  moko_journal_entry_set_direction (entry, DIRECTION_IN);
+  moko_journal_entry_get_voice_info (entry, &info);
+  moko_journal_entry_set_dtstart (entry, moko_time_new_today ());
+  moko_journal_add_entry (data->journal, entry);
+
+  /* connect our handler to track call progress */
+  progress_handler = g_signal_connect (data->connection, "call-progress", 
+                    G_CALLBACK (call_progress_cb), data);
+
+
   if (gtk_dialog_run (GTK_DIALOG (data->window_incoming)) == GTK_RESPONSE_OK)
   {
     moko_gsmd_connection_voice_accept (data->connection);
@@ -236,13 +263,21 @@
     if (!data->window_talking)
       window_talking_init (data);
     gtk_widget_show_all (data->window_talking);
+    moko_journal_voice_info_set_was_missed (info, FALSE);
   }
   else
   {
     moko_gsmd_connection_voice_hangup (data->connection);
+    /* mark the call as misssed
+     * FIXME: this is not strictly true if the call was rejected
+     */
+    moko_journal_voice_info_set_was_missed (info, TRUE);
   }
 
   gtk_widget_hide (data->window_incoming);
+
+  /* disconnect the call progress handler since we no longer need it */
+  g_signal_handler_disconnect (data->connection, progress_handler);
 }
 
 void
@@ -250,4 +285,5 @@
 {
   moko_message_dialog_set_message (MOKO_MESSAGE_DIALOG (data->window_incoming),
                                    "Incoming call from %s", clip);
+  // moko_journal_voice_info_set_distant_number ();
 }

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-outgoing.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-outgoing.c	2007-05-23 13:56:01 UTC (rev 2070)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-outgoing.c	2007-05-23 16:00:21 UTC (rev 2071)
@@ -110,72 +110,6 @@
 }
 
 
-
-static void
-on_window_outgoing_hide (GtkWidget * widget, MokoDialerData * appdata)
-{
-  if (appdata->g_timer_data.ptimer != 0)
-  {
-    g_source_remove (appdata->g_timer_data.ptimer);
-    appdata->g_timer_data.ptimer = 0;
-  }
-  if (appdata->g_state.callstate != STATE_TALKING)
-  {                             //     add_histroy_entry(g_state.historytype,g_state.contactinfo.name,g_state.contactinfo.number,g_state.contactinfo.picpath,g_state.starttime,0);
-/*
-    add_histroy_entry (appdata, appdata->g_state.historytype,
-                       appdata->g_peer_info.name,
-                       appdata->g_peer_info.number,
-                       appdata->g_peer_info.picpath,
-                       appdata->g_state.starttime,
-                       appdata->g_state.startdate, 0);
-*/
-  }
-
-
-}
-
-static void
-window_outgoing_setup_timer (MokoDialerData * appdata)
-{
-  time_t timep;
-  struct tm *p;
-  time (&timep);
-  p = localtime (&timep);
-
-  sprintf (appdata->g_state.starttime, "%02d:%02d:%02d", p->tm_hour,
-           p->tm_min, p->tm_sec);
-  sprintf (appdata->g_state.startdate, "%04d/%02d/%02d", p->tm_year,
-           p->tm_mon, p->tm_mday);
-
-  if (appdata->g_timer_data.ptimer != 0)
-  {
-    g_source_remove (appdata->g_timer_data.ptimer);
-    appdata->g_timer_data.ptimer = 0;
-  }
-
-  memset (&(appdata->g_timer_data), 0, sizeof (appdata->g_timer_data));
-// 1:30 timeout
-  appdata->g_timer_data.stopsec = 90;
-
-  appdata->g_timer_data.ptimer =
-    g_timeout_add (1000, (GSourceFunc) timer_outgoing_time_out, appdata);
-
-
-}
-
-static void
-on_window_outgoing_show (GtkWidget * widget, MokoDialerData * appdata)
-{
-
-  window_outgoing_setup_timer (appdata);
-  appdata->g_state.callstate = STATE_CALLING;
-  /* TODO: MokoGsmdConnection->dial
-   * int retv = gsm_dial (appdata->g_peer_info.number);
-   * DBG_MESSAGE ("GSM_DIAL returns %d", retv);
-   */
-}
-
-
 gint
 window_outgoing_init (MokoDialerData * p_dialer_data)
 {
@@ -242,20 +176,16 @@
   p_dialer_data->window_outgoing = GTK_WIDGET (window);
   p_dialer_data->status_outgoing = MOKO_DIALER_STATUS (status);
 
-  g_signal_connect (G_OBJECT (window), "show",
-                    G_CALLBACK (on_window_outgoing_show), p_dialer_data);
-  g_signal_connect (G_OBJECT (window), "hide",
-                    G_CALLBACK (on_window_outgoing_hide), p_dialer_data);
-
   return 1;
 }
 
-void
+static void
 call_progress_cb (MokoGsmdConnection *connection, int type, MokoDialerData *data)
 {
   if (type == MOKO_GSMD_PROG_REJECT)
   {
     g_debug ("call rejected");
+    gtk_dialog_response (GTK_DIALOG (data->window_outgoing), GTK_RESPONSE_CANCEL);
     return;
   }
 
@@ -268,7 +198,10 @@
 void
 window_outgoing_dial (MokoDialerData *data, gchar *number)
 {
-  g_signal_connect (data->connection, "call-progress", 
+  gulong progress_handler;
+
+  /* connect our handler to track call progress */
+  progress_handler = g_signal_connect (data->connection, "call-progress", 
                     G_CALLBACK (call_progress_cb), data);
   g_object_set_data (G_OBJECT (data->window_outgoing), "current-number", number);
   moko_gsmd_connection_voice_dial (data->connection, number);
@@ -288,4 +221,7 @@
 
   gtk_widget_hide (data->window_outgoing);
   g_object_steal_data (G_OBJECT (data->window_outgoing), "current-number");
+
+  /* disconnect the call progress handler since we no longer need it */
+  g_signal_handler_disconnect (data->connection, progress_handler);
 }





More information about the commitlog mailing list