r3466 - in trunk/src/target/OM-2007.2/applications/openmoko-dialer2: . src/phone-kit

thomas at sita.openmoko.org thomas at sita.openmoko.org
Wed Nov 21 17:05:16 CET 2007


Author: thomas
Date: 2007-11-21 17:05:13 +0100 (Wed, 21 Nov 2007)
New Revision: 3466

Added:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-pin.c
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-pin.h
Modified:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/Makefile.am
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-dialer.c
Log:
* src/phone-kit/Makefile.am:
* src/phone-kit/moko-dialer.c: (on_incoming_call),
(on_pin_requested), (moko_dialer_init):
* src/phone-kit/moko-pin.c:
* src/phone-kit/moko-pin.h:

Add new code to request PIN from user


Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-11-21 16:00:08 UTC (rev 3465)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-11-21 16:05:13 UTC (rev 3466)
@@ -1,3 +1,13 @@
+2007-11-21  Thomas Wood  <thomas at openedhand.com>
+
+	* src/phone-kit/Makefile.am:
+	* src/phone-kit/moko-dialer.c: (on_incoming_call),
+	(on_pin_requested), (moko_dialer_init):
+	* src/phone-kit/moko-pin.c:
+	* src/phone-kit/moko-pin.h:
+
+	Add new code to request PIN from user
+
 2007-11-21  Chris Lord  <chris at openedhand.com>
 
 	* src/phone-kit/moko-dialer-sms.c: (moko_dialer_sms_finalize),

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/Makefile.am
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/Makefile.am	2007-11-21 16:00:08 UTC (rev 3465)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/Makefile.am	2007-11-21 16:05:13 UTC (rev 3466)
@@ -11,7 +11,9 @@
 	moko-notify.c moko-notify.h \
 	moko-sound.c moko-sound.h \
 	moko-talking.c moko-talking.h \
-	moko-dialer-sms.c moko-dialer-sms.h
+	moko-dialer-sms.c moko-dialer-sms.h \
+	moko-pin.c \
+	moko-pin.h
 
 phone_kit_LDADD = @DIALER_LIBS@ @JANA_LIBS@ $(top_srcdir)/src/common/libdialer-common.a
 

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-dialer.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-dialer.c	2007-11-21 16:00:08 UTC (rev 3465)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-dialer.c	2007-11-21 16:05:13 UTC (rev 3466)
@@ -34,6 +34,7 @@
 #include "moko-notify.h"
 #include "moko-talking.h"
 #include "moko-sound.h"
+#include "moko-pin.h"
 
 G_DEFINE_TYPE (MokoDialer, moko_dialer, G_TYPE_OBJECT)
 
@@ -434,7 +435,7 @@
   if (priv->status == DIALER_STATUS_INCOMING  
         || priv->status == DIALER_STATUS_TALKING)
   {
-    /*g_debug ("We are already showing the incoming page");*/
+    g_debug ("We are already showing the incoming page");
     return;
   }
   priv->status = DIALER_STATUS_INCOMING;
@@ -497,11 +498,17 @@
 on_pin_requested (MokoGsmdConnection *conn, int type, MokoDialer *dialer)
 {
   MokoDialerPrivate *priv;
+  gchar *pin;
 
   g_return_if_fail (MOKO_IS_DIALER (dialer));
+  g_debug ("Pin Requested");
   priv = dialer->priv;
   
-  g_debug ("Pin Requested");
+  pin = get_pin_from_user ();
+  if (!pin)
+    return;
+  moko_gsmd_connection_send_pin (priv->connection, pin);
+  g_free (pin);
 }
 
 static void
@@ -771,7 +778,6 @@
   g_signal_connect (G_OBJECT (priv->talking), "speaker_toggle",
                     G_CALLBACK (on_talking_speaker_toggle), (gpointer)dialer);
 
-
 }
 
 MokoDialer*

Added: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-pin.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-pin.c	2007-11-21 16:00:08 UTC (rev 3465)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-pin.c	2007-11-21 16:05:13 UTC (rev 3466)
@@ -0,0 +1,106 @@
+/*
+ *  Authored by OpenedHand Ltd <info at openedhand.com>
+ *
+ *  Copyright (C) 2007 OpenMoko Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Lesser Public License for more details.
+ */
+
+#include <gtk/gtk.h>
+
+#include "moko-dialer-textview.h"
+#include "moko-dialer-panel.h"
+
+#include <string.h>
+
+typedef struct
+{
+  GtkWidget *display;
+  GtkWidget *dialog;
+  gchar *pin;
+} MokoPinData;
+
+static void
+on_pad_user_input (MokoDialerPanel *panel, const gchar digit,
+                   MokoPinData *data)
+{
+  gchar buf[2];
+  gchar *new_pin;
+
+  /* Phones use '#' for PIN 'entered' signal */
+  if (digit == '#')
+  {
+    gtk_dialog_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK);
+    return;
+  }
+  
+  /* "*" acts as delete for now */
+  if (digit == '*')
+  {
+    moko_dialer_textview_delete (MOKO_DIALER_TEXTVIEW (data->display));
+    data->pin[strlen(data->pin)-1] = '\0';
+    return;
+  }
+
+  /* Create a string from the new digit */
+  buf[0] = digit;
+  buf[1] = '\0';
+  
+  if (!data->pin)
+  {
+    new_pin = g_strdup (buf);
+  }
+  else
+  {
+    new_pin = g_strconcat (data->pin, buf, NULL);
+    g_free (data->pin);
+  }
+  data->pin = new_pin;
+
+  moko_dialer_textview_insert (MOKO_DIALER_TEXTVIEW (data->display), "*");
+}
+
+
+
+char*
+get_pin_from_user ()
+{
+  GtkWidget *pad;
+  gchar *pin;
+  MokoPinData data;
+  
+  data.dialog = gtk_dialog_new_with_buttons ("Enter PIN", NULL, 0,
+                                             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                             GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+  gtk_dialog_set_has_separator (GTK_DIALOG (data.dialog), FALSE);
+
+  data.display = moko_dialer_textview_new ();
+  gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (data.dialog)->vbox), data.display);
+  
+  pad = moko_dialer_panel_new ();
+  gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (data.dialog)->vbox), pad);
+  g_signal_connect (pad, "user_input", G_CALLBACK (on_pad_user_input), &data);
+  
+  gtk_widget_show_all (GTK_DIALOG (data.dialog)->vbox);
+  
+  data.pin = NULL;
+  if (gtk_dialog_run (GTK_DIALOG (data.dialog)) == GTK_RESPONSE_OK)
+  {
+    pin = data.pin;
+  }
+  else
+  {
+    pin = NULL;
+    g_free (data.pin);
+  }
+  gtk_widget_destroy (data.dialog);
+
+  return pin;
+}

Added: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-pin.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-pin.h	2007-11-21 16:00:08 UTC (rev 3465)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/phone-kit/moko-pin.h	2007-11-21 16:05:13 UTC (rev 3466)
@@ -0,0 +1,16 @@
+/*
+ *  Authored by OpenedHand Ltd <info at openedhand.com>
+ *
+ *  Copyright (C) 2007 OpenMoko Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Lesser Public License for more details.
+ */
+
+char *get_pin_from_user ();





More information about the commitlog mailing list