r494 - in trunk/src/target/OM-2007/applications/openmoko-dialer: . data src

tony_guan at gta01.hmw-consulting.de tony_guan at gta01.hmw-consulting.de
Thu Jan 4 03:15:42 CET 2007


Author: tony_guan
Date: 2007-01-04 03:14:40 +0100 (Thu, 04 Jan 2007)
New Revision: 494

Added:
   trunk/src/target/OM-2007/applications/openmoko-dialer/data/all.png
   trunk/src/target/OM-2007/applications/openmoko-dialer/data/delete.png
   trunk/src/target/OM-2007/applications/openmoko-dialer/data/dtmf.png
   trunk/src/target/OM-2007/applications/openmoko-dialer/data/email.png
   trunk/src/target/OM-2007/applications/openmoko-dialer/data/phone.png
   trunk/src/target/OM-2007/applications/openmoko-dialer/data/sms.png
   trunk/src/target/OM-2007/applications/openmoko-dialer/data/speaker.png
   trunk/src/target/OM-2007/applications/openmoko-dialer/data/talking.png
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.h
Modified:
   trunk/src/target/OM-2007/applications/openmoko-dialer/configure.ac
   trunk/src/target/OM-2007/applications/openmoko-dialer/data/Makefile.am
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/Makefile.am
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-declares.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.c
Log:
dialer almost done, gsmd integrated, but libgsmd is not working very well.


Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/configure.ac
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/configure.ac	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/configure.ac	2007-01-04 02:14:40 UTC (rev 494)
@@ -13,9 +13,12 @@
 # base deps
 PKG_CHECK_MODULES(OPENMOKO, openmoko-libs >= 0.0.1,,
                  AC_MSG_ERROR([*** Required OpenMoko Libraries >= 0.0.1 not installed ***]))
-LIBS="$LIBS $GTK_LIBS"
-CFLAGS="$CFLAGS $OPENMOKO_CFLAGS"
+PKG_CHECK_MODULES(LIBGSMD, libgsmd ,,
+                 AC_MSG_ERROR([*** Required libgsmd not installed ***]))
 
+LIBS="$LIBS $GTK_LIBS $LIBGSMD_LIBS"
+CFLAGS="$CFLAGS $OPENMOKO_CFLAGS $LIBGSMD_CFLAGS"
+
 # output stuff
 AC_OUTPUT([
 Makefile

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/data/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/data/Makefile.am	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/data/Makefile.am	2007-01-04 02:14:40 UTC (rev 494)
@@ -7,8 +7,18 @@
                 unkown.png\
                 status0.png\
                 status1.png\
-                status2.png
-                
+                status2.png\
+                dialed.png\
+                missed.png\
+                received.png\
+                speaker.png\
+                email.png\
+                phone.png\
+                delete.png\
+                dtmf.png\
+                talking.png\
+                sms.png\
+                all.png
 resourcedir = $(pkgdatadir)
 
 resource_DATA = tony.png\
@@ -20,4 +30,16 @@
                 unkown.png\
                 status0.png\
                 status1.png\
-                status2.png
+                status2.png\
+                dialed.png\
+                missed.png\
+                received.png\
+                received.png\
+                speaker.png\
+                email.png\
+                phone.png\
+                delete.png\
+                dtmf.png\
+                talking.png\
+                sms.png\
+                all.png

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/all.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/all.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/delete.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/delete.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/dtmf.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/dtmf.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/email.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/email.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/phone.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/phone.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/sms.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/sms.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/speaker.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/speaker.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/data/talking.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/target/OM-2007/applications/openmoko-dialer/data/talking.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/Makefile.am	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/Makefile.am	2007-01-04 02:14:40 UTC (rev 494)
@@ -8,10 +8,16 @@
 moko-dialer-textview.c\
 moko-dialer-tip.c\
 moko-dialer-autolist.c\
+event.c\
+pin.c\
+history.c\
 contacts.c\
 common.c\
+dialergsm.c\
+openmoko-dialer-window-history.c\
 openmoko-dialer-window-dialer.c\
 openmoko-dialer-window-outgoing.c\
+openmoko-dialer-window-incoming.c\
 openmoko-dialer-window-talking.c\
 moko-dialer-status.c
 

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.c	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.c	2007-01-04 02:14:40 UTC (rev 494)
@@ -15,7 +15,7 @@
  *
  *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
  */
-
+#include "moko-dialer-declares.h"
  #include "common.h"
  #include "error.h"
 /**
@@ -105,31 +105,49 @@
     }
   else
     {
+    //first we load the default picture 
+ 	  pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S, 
+                              MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);
+	  if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+	    {
+	    gtk_image_set_from_file(image,pathname);   	
+	    g_free (pathname);
+	    return TRUE;
+	    }
+	  else
+	  	{
 	      g_debug ("Can not find the file %s", pathname);
 	       gtk_image_set_from_stock(image,"gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR);
 	      g_free (pathname);
 	      return FALSE;
+	  	}
     }
+}
 
-/*
-GtkImage *image=GTK_IMAGE(widget);	
 
-struct stat statdata;
+GtkWidget * file_new_image_from_relative_path(char * rela_path)
+{
 
-if(image==NULL)
-	{
-		DBG_ERROR("Can not find widget ");
-		return 0;
-		}
- if(lstat(path,&statdata)==-1)
- {
-	 gtk_image_set_from_stock(image,"icon_dialer_people",GTK_ICON_SIZE_LARGE_TOOLBAR);
- }
- else
-	gtk_image_set_from_file(image,path);
- return 1;
-*/
+ 
+  gchar     *pathname;
+  GtkImage *image=0;	  
 
+  pathname = g_strdup_printf ("%s%s%s", PKGDATADIR, G_DIR_SEPARATOR_S, 
+                              rela_path);
+
+
+  if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+    {
+	   image= gtk_image_new_from_file(pathname);   	
+    }
+  else
+    {
+//	      g_debug ("Can not find the file %s", pathname);
+	   image=  gtk_image_new_from_stock("gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR);
+
+    }
+	      g_free (pathname);
+	      return image;
 }
 
 

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.h	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/common.h	2007-01-04 02:14:40 UTC (rev 494)
@@ -23,7 +23,7 @@
 GdkPixbuf *create_pixbuf (const gchar *filename);
 gboolean file_create_data_path_for_the_file(const gchar* filename, gchar* path);
 gboolean file_load_person_image_from_relative_path(GtkWidget *widget,char * rela_path);
-
+GtkWidget * file_new_image_from_relative_path(char * rela_path);
 #endif
 
 

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h	2007-01-04 02:14:40 UTC (rev 494)
@@ -66,7 +66,7 @@
 typedef struct peer_info_
 {
 //we should at least have the number called.
-  char number[MOKO_DIALER_MAX_NUMBER_LEN];        ///<the number of the peer
+  char number[MOKO_DIALER_MAX_NUMBER_LEN+1];        ///<the number of the peer
   char *name;       	///<person name
   char *picpath;  ///<the picture file path for the person
   int searched; ///<if true; no need to search for the name 

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c	2007-01-04 02:14:40 UTC (rev 494)
@@ -0,0 +1,271 @@
+/**
+ * @file dialergsm.c
+ * @brief this file includes the definitions of the functions which is called by the GUI app to perform
+ * phone operations such as hangup, callout, answer. and the functions then calls the APIs of libgsmd, so 
+ * this file is a bridge from GUI to libgsmd.
+ *
+ * Copyright (C) 2006 FIC-SH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2, or (at
+ * your option) any later version.
+ *
+ * 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
+ * General Public License for more details.
+ *
+ * @author Tony Guan (tonyguan at fic-sh.com.cn)
+ * @date 2006-10-12
+ */
+
+#include <dialergsm.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <sys/time.h>
+#include <string.h>
+#include "moko-dialer-includes.h"
+
+pthread_t thread;///<the gsm_monitor_thread thread handler
+
+static struct lgsm_handle *lgsmh; ///< the handle of the libgsmd
+
+static GPollFD GPfd;
+
+
+/**
+ * @brief monitor the connection with libgsmd, dispatch the event handler when needed.
+ *
+ * This function should be discarded once libgsmd evolves completely
+ *
+ * @param lgsmh struct lgsm_handle *,the handle of the libgsmd
+ * @return 
+ * @retval
+ */
+
+void *gsm_monitor_thread(struct lgsm_handle *lgsmh)
+{
+	int rc;
+	char buf[STDIN_BUF_SIZE+1];
+	//char rbuf[STDIN_BUF_SIZE+1];
+	//int rlen = sizeof(rbuf);
+	fd_set readset;
+//	lgsm_register_handler(lgsmh, GSMD_MSG_PASSTHROUGH, &pt_msghandler);
+
+	FD_ZERO(&readset);
+
+	while (1) {
+		int gsm_fd = lgsm_fd(lgsmh);
+//		FD_SET(0, &readset);
+		FD_SET(gsm_fd, &readset);
+
+		rc = select(gsm_fd+1, &readset, NULL, NULL, NULL);
+		if (rc <= 0)	
+			break;
+		/* we've received something on the gsmd socket, pass it
+			 * on to the library */
+			rc = read(gsm_fd, buf, sizeof(buf));
+			if (rc <= 0) {
+				printf("ERROR reding from gsm_fd\n");
+				break;
+			}
+			rc = lgsm_handle_packet(lgsmh, buf, rc);
+	}
+	
+	
+		printf("you know what? i quit!");
+        pthread_exit(NULL);
+}
+
+/**
+ * @brief create the thread to monitor events from libgsmd
+ *
+ * 
+ *
+ * @param 
+ * @return 
+ * @retval -1 failed
+ * @retval 0  success
+ */
+int gsm_start_loop()
+{
+        
+        //pthread_mutex_init(&mut,NULL);
+	    memset(&thread, 0, sizeof(thread));          //comment1
+        
+        if(pthread_create(&thread, NULL, gsm_monitor_thread, lgsmh) != 0)       //comment2
+		{  printf("failed to create libgsmd monitor thread\n");
+			return -1;
+		}
+        
+        return 0;
+}
+
+
+
+/**
+ * @brief this is the handler for receiving passthrough responses 
+ *
+ * 
+ *
+ * @param lh struct lgsm_handle *, the libgsm handle
+ * @param gmh struct gsmd_msg_hdr *, the data to passthrough
+ * @return 
+ * @retval -1 failed
+ * @retval 0  success
+ */
+
+static int pt_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
+{
+	char *payload = (char *)gmh + sizeof(*gmh);
+	printf("RSTR=`%s'\n", payload);
+	return 0;
+}
+
+
+
+/**
+ * @brief take care the early initialization of libgsmd,this must be called before any physical phone operations such as dialing out.
+ * @retval 1 failed, and the whole app will exit too.
+ * @retval 0  success
+ */
+	
+int gsm_lgsm_start(GMainLoop* mainloop)
+{
+
+	char *pin = NULL;
+	lgsmh = lgsm_init(LGSMD_DEVICE_GSMD);
+	if (!lgsmh) {
+		fprintf(stderr, "Can't connect to gsmd\n");
+		exit(1);
+		}
+	pin_init(lgsmh, pin);
+	event_init(lgsmh);
+	lgsm_register_handler(lgsmh, GSMD_MSG_PASSTHROUGH, &pt_msghandler);
+	lgsm_netreg_register(lgsmh, 0);
+	
+	gsm_watcher_install(mainloop);
+	//gsm_start_loop();
+	return 0;
+
+}
+
+
+
+/**
+ * @brief calls a number out
+ * @param number the number to be called
+ * @retval 0  success 
+ * @retval other failed
+ */
+int gsm_dial(const char * number)
+{
+				struct lgsm_addr addr;
+				addr.type = 129;
+				strncpy(addr.addr, number, strlen(number));
+				addr.addr[strlen(number)] = '\0';
+				return lgsm_voice_out_init(lgsmh, &addr);
+				
+}
+
+/**
+ * @brief accept an incoming call
+ * @retval 0  success 
+ * @retval other failed
+ */
+int gsm_answer()
+{
+	return lgsm_voice_in_accept(lgsmh);
+	
+}
+
+/**
+ * @brief hangup an outgoing call or incoming call or talking call
+ * @retval 0  success 
+ * @retval other failed
+ */
+int gsm_hangup()
+{
+	
+return lgsm_voice_hangup(lgsmh);
+	
+}
+
+
+static gboolean
+gsm_watcher_prepare (GSource * source,
+		       gint * timeout)
+{
+	//DBG_ENTER();
+	*timeout = -1;
+
+	return FALSE;
+}
+static gboolean gsm_watcher_check (GSource * source)
+{
+
+	//DBG_ENTER();
+	//|G_IO_IN|G_IO_HUP|G_IO_ERR|G_IO_PRI;
+	if(GPfd.revents&(G_IO_IN|G_IO_PRI))
+	{	
+
+		//GPfd.revents=0;
+		return TRUE;
+	}
+	else
+	{
+		//DBG_MESSAGE("FALSE");
+		return FALSE;
+	}
+	
+}
+static gboolean
+gsm_watcher_dispatch (GSource     * source,
+                        GSourceFunc   callback,
+                        gpointer      user_data)
+{
+
+
+	int rc;
+	char buf[STDIN_BUF_SIZE+1];
+	int gsm_fd = lgsm_fd(lgsmh);
+	/* we've received something on the gsmd socket, pass it
+			 * on to the library */
+
+	rc = read(gsm_fd, buf, sizeof(buf));
+			if (rc <= 0) {
+				DBG_MESSAGE("ERROR reding from gsm_fd");
+				return FALSE;
+			}
+			else
+			{
+				rc = lgsm_handle_packet(lgsmh, buf, rc);
+			}
+	return TRUE;
+}
+void gsm_watcher_install (GMainLoop* mainloop)
+{
+	DBG_ENTER();
+	static GSourceFuncs gsm_watcher_funcs = {
+		gsm_watcher_prepare,
+		gsm_watcher_check,
+		gsm_watcher_dispatch,
+		NULL
+	};
+	/* FIXME: we never unref the watcher. */
+	GSource * gsm_watcher =
+		g_source_new (&gsm_watcher_funcs, sizeof (GSource));
+	GPfd.fd=lgsm_fd(lgsmh);
+	GPfd.events=G_IO_IN|G_IO_HUP|G_IO_ERR|G_IO_PRI;
+	GPfd.revents=0;
+	
+	g_source_add_poll(gsm_watcher,&GPfd);
+
+	DBG_MESSAGE("ATACH");
+	g_source_attach(gsm_watcher,NULL);
+	DBG_MESSAGE("ATACH OUT");
+	DBG_LEAVE();
+	return;
+
+}

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.h	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.h	2007-01-04 02:14:40 UTC (rev 494)
@@ -0,0 +1,111 @@
+/**
+ * @file dialergsm.h
+ * @brief this file includes the definitions of the functions which is called by the GUI app to perform
+ * phone operations such as hangup, callout, answer. and the functions then calls the APIs of libgsmd, so 
+ * this file is a bridge from GUI to libgsmd.
+ *
+ * Copyright (C) 2006 FIC-SH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2, or (at
+ * your option) any later version.
+ *
+ * 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
+ * General Public License for more details.
+ *
+ * @author Tony Guan (tonyguan at fic-sh.com.cn)
+ * @date 2006-10-12
+ */
+
+#ifndef _DIALERGSM_H
+#define _DIALERGSM_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <libgsmd/libgsmd.h>
+#include <libgsmd/voicecall.h>
+#include <libgsmd/misc.h>
+#include "pin.h"
+#include "event.h"
+#include <glib/gmain.h>
+#include <glib/giochannel.h>
+/*
+int event_init(struct lgsm_handle *lh);
+
+int shell_main(struct lgsm_handle *lgsmh);
+	
+int pin_init(struct lgsm_handle *lh, const char *pin_preset);
+*/
+	
+//#include "lgsm_internals.h"
+	
+//#include "dialer.h"
+
+#define STDIN_BUF_SIZE	1024
+/**
+ * @brief create the thread to monitor events from libgsmd
+ *
+ * 
+ *
+ * @param 
+ * @return 
+ * @retval -1 failed
+ * @retval 0  success
+ */
+int gsm_start_loop();
+/**
+ * @brief take care the early initialization of libgsmd,this must be called before any physical phone operations such as dialing out.
+ * @retval 1 failed, and the whole app will exit too.
+ * @retval 0  success
+ */
+int gsm_lgsm_start(GMainLoop* mainloop);
+/**
+ * @brief hangup an outgoing call or incoming call or talking call
+ * @retval 0  success 
+ * @retval other failed
+ */
+int gsm_hangup();
+
+/**
+ * @brief accept an incoming call
+ * @retval 0  success 
+ * @retval other failed
+ */
+int gsm_answer();
+/**
+ * @brief calls a number out
+ * @param number the number to be called
+ * @retval 0  success 
+ * @retval other failed
+ */
+int gsm_dial(const char * number);
+/**
+ * @brief monitor the connection with libgsmd, dispatch the event handler when needed.
+ *
+ * This function should be discarded once libgsmd evolves completely
+ *
+ * @param lgsmh struct lgsm_handle *,the handle of the libgsmd
+ * @return 
+ * @retval
+ */
+
+void *gsm_monitor_thread(struct lgsm_handle *lgsmh);
+
+
+void gsm_watcher_install (GMainLoop* mainloop);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DIALERGSM_H */

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.c	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.c	2007-01-04 02:14:40 UTC (rev 494)
@@ -0,0 +1,154 @@
+#include <stdio.h>
+#include <string.h>
+
+#include <libgsmd/libgsmd.h>
+#include <libgsmd/event.h>
+//#include "../include/dialer.h"
+static int IncomingSignaled; ///<to keep communication with GUI
+static int ClipSignaled;///<to keep communication with GUI
+static int KeepCalling;
+
+
+int event_get_incoming_signaled()
+{
+	return IncomingSignaled;
+}
+
+int event_set_incoming_signaled()
+{
+	IncomingSignaled=1;
+	return IncomingSignaled;
+}
+
+int event_reset_incoming_signaled()
+{
+	IncomingSignaled=0;
+	return 1;
+}
+int event_get_clip_signaled()
+{
+	return ClipSignaled;
+	
+}
+int event_set_clip_signaled()
+{
+	ClipSignaled=1;
+	return 1;
+	
+}
+int event_reset_clip_signaled()
+{
+	ClipSignaled=0;
+	return 1;
+	
+}
+int event_get_keep_calling()
+{
+	return KeepCalling;
+}
+int event_set_keep_calling()
+{
+	KeepCalling=1;
+	return 1;
+}
+int event_reset_keep_calling()
+{
+	KeepCalling=0;
+	return 1;
+}
+
+static int incall_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+{
+	printf("EVENT: Incoming call type = %u\n", aux->u.call.type);
+	
+	if(event_get_incoming_signaled())
+	{
+		printf("already signaled, just set keep_calling");
+		event_set_keep_calling();
+	}
+	else
+	{
+		printf("set incoming signaled");
+		event_set_incoming_signaled();
+		//PhoneIncoming(0);	
+	}
+	return 0;
+}
+
+
+static int clip_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+{
+	printf("EVENT: Incoming call clip = %s\n", aux->u.clip.addr.number);
+	if(event_get_clip_signaled())
+	{
+		printf("already signaled, just set keep_calling");
+		event_set_keep_calling();
+	}
+	else
+	{
+		event_set_clip_signaled();
+		printf("set clip signaled and call phoneincoming");
+		gdk_threads_enter();
+		//here!
+		gsm_incoming_call(aux->u.clip.addr.number);
+//		PhoneIncomingClip(aux->u.clip.addr.number);
+		gdk_threads_leave();
+	}
+	return 0;
+}
+
+static int netreg_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+{
+	printf("EVENT: Netreg ");
+
+	switch (aux->u.netreg.state) {
+	case 0:
+		printf("not searching for network ");
+		break;
+	case 1:
+		printf("registered (home network) ");
+		break;
+	case 2:
+		printf("searching for network ");
+		break;
+	case 3:
+		printf("registration denied ");
+		break;
+	case 5:
+		printf("registered (roaming) ");
+		break;
+	}
+
+	if (aux->u.netreg.lac)
+		printf("LocationAreaCode = 0x%04X ", aux->u.netreg.lac);
+	if (aux->u.netreg.ci)
+		printf("CellID = 0x%04X ", aux->u.netreg.ci);
+	
+	printf("\n");
+
+	return 0;
+}
+
+static int sigq_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+{
+	printf("EVENT: Signal Quality: %u\n", aux->u.signal.sigq.rssi);
+	return 0;
+}
+static int out_status_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+{
+	printf("EVENT: OUT GOING CALL status\n");
+	return 0;
+}
+
+
+int event_init(struct lgsm_handle *lh)
+{
+	int rc;
+
+	rc  = lgsm_evt_handler_register(lh, GSMD_EVT_IN_CALL, &incall_handler);
+	rc |= lgsm_evt_handler_register(lh, GSMD_EVT_IN_CLIP, &clip_handler);
+	rc |= lgsm_evt_handler_register(lh, GSMD_EVT_NETREG, &netreg_handler);
+	rc |= lgsm_evt_handler_register(lh, GSMD_EVT_SIGNAL, &sigq_handler);
+	//rc|=lgsm_evt_handler_register(lh, GSMD_EVT_OUT_STATUS, &out_status_handler);
+	return rc;
+}

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.h	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/event.h	2007-01-04 02:14:40 UTC (rev 494)
@@ -0,0 +1,14 @@
+
+extern int event_init(struct lgsm_handle *lh);
+extern int event_get_incoming_signaled();
+
+extern int event_set_incoming_signaled();
+
+extern int event_reset_incoming_signaled();
+extern int event_get_clip_signaled();
+extern int event_set_clip_signaled();
+extern int event_reset_clip_signaled();
+
+extern int event_get_keep_calling();
+extern int event_set_keep_calling();
+extern int event_reset_keep_calling();

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c	2007-01-04 02:14:40 UTC (rev 494)
@@ -57,27 +57,27 @@
 historyhead->first=0;
 historyhead->last=0;
 	history_add_entry(historyhead,MISSED,"","1391721112",
-	"","17:58",100);
+	"","17:58","12/20",100);
 
 	history_add_entry(historyhead,INCOMING,"tony","13917309523",
-	"./tony.png","13:58",10);
+	"./tony.png","13:58","12/20",10);
 history_add_entry(historyhead,OUTGOING,"sally","13361900551",
-	"./sally.png","10:58",106);
+	"./sally.png","10:58","12/20",106);
 history_add_entry(historyhead,MISSED,"chaowei","1391110923",
-	"./chaowei.png","11:58",120);
+	"./chaowei.png","11:58","12/20",120);
 	history_add_entry(historyhead,OUTGOING,"","1395721111",
-	"","17:58",100);
+	"","17:58","12/20",100);
 
 	history_add_entry(historyhead,INCOMING,"steven","1391721111",
-	"./steven.png","17:58",100);
+	"./steven.png","17:58","12/20",100);
 history_add_entry(historyhead,INCOMING,"ken","1381720923",
-	"./ken.png","18:58",200);
+	"./ken.png","18:58","12/20",200);
 	history_add_entry(historyhead,MISSED,"","1391721113",
-	"","17:58",100);
+	"","17:58","12/20",100);
 	history_add_entry(historyhead,MISSED,"","1394721111",
-	"","17:58",100);
+	"","17:58","12/20",100);
 	history_add_entry(historyhead,MISSED,"","1396721111",
-	"","17:58",100);
+	"","17:58","12/20",100);
 return historyhead->length;
 
 }
@@ -132,14 +132,9 @@
 	{
 		historyhead->last=entry->prev;
 	}
-	free(entry->name);
-	entry->name=0;
-	free(entry->number);
-	entry->number=0;
-	free(entry->time);
-	entry->time=0;
-	entry->prev=0;
-	entry->next=0;
+
+	history_release_entry(entry);
+
 	historyhead->length--;
 	return historyhead->length;
 }
@@ -154,15 +149,17 @@
  * @param name  const char*, the name of the counterpart
  * @param number const char*, the number of the counterpart
  * @param picpath const char*, the picture path of the counterpart
- * @param time char*, the time of that connection,may include date&time, and may be seperated into 2 fields in the future.
+ * @param time char*, the time of that connection
+ * @param date char*, the date of that connection
  * @param durationsec int, the duaration of that connection in seconds
  * @return 
  * @retval the newly created entry pointer
  */
 HISTORY_ENTRY * history_add_entry(HISTORY_LIST_HEAD* historyhead, HISTORY_TYPE type,
-	const char *name,const char *number,
-	const char *picpath,  char *time,int durationsec)
+const char *name,const char *number,const char *picpath,  char *time,char *date,int durationsec)
 {
+
+	DBG_ENTER();
 	HISTORY_ENTRY * pentry=(HISTORY_ENTRY *)calloc(1,sizeof(HISTORY_ENTRY ));
 
 //	DBG_MESSAGE("pentry add:0X%x",pentry);
@@ -170,14 +167,27 @@
 	if(name&&strlen(name)>0)
 	{	pentry->name=(char*)calloc(1,strlen(name)+1);
 		strcpy(pentry->name,name);
+		pentry->hasname=1;
 	}
-		if(number&&strlen(number)>0)
+	else
+		{
+		pentry->name=0;
+		pentry->hasname=0;
+		}
+
+	if(number&&strlen(number)>0)
 	{
 		pentry->number=(char*)calloc(1,strlen(number)+1);
 		strcpy(pentry->number,number);
 	}
+	else
+		{
+		//release memory, and return;
+		history_release_entry(pentry);
+		return 0;
+		}
 
-	//DBG_MESSAGE("History add:0X%x,%s,%s,%s,%s,%d",historyhead,name,number,picpath,time,durationsec);
+	//DBG_MESSAGE("History add:0X%x,%s,%s,%s,%s,%s,%d",historyhead,name,number,picpath,time,date,durationsec);
 	
 	if(picpath&&strlen(picpath)>0)
 	{
@@ -215,6 +225,43 @@
 	return pentry;
 }
 
+int history_release_entry(HISTORY_ENTRY * pentry)
+{
+if(!pentry)return 1;
+if(pentry->name)
+{
+free(pentry->name);
+pentry->name=0;
+}
+if(pentry->number)
+{
+free(pentry->number);
+pentry->number=0;
+}
+if(pentry->picpath)
+{
+free(pentry->picpath);
+pentry->picpath=0;
+}
+if(pentry->time)
+{
+free(pentry->time);
+pentry->time=0;
+}
+if(pentry->date)
+{
+free(pentry->date);
+pentry->date=0;
+}
+
+pentry->prev=0;
+pentry->next=0;
+free(pentry);
+pentry=0;
+return 1;
+
+}
+
 /**
  * @brief release the momory by the list and it's entry
  * 
@@ -225,8 +272,35 @@
  * @retval 0 failed 
  * @retval 1 success
  */
-
-int history_release_list(HISTORY_LIST_HEAD* historyhead)
+int history_release_history_list(HISTORY_LIST_HEAD* historyhead)
 {
+	HISTORY_ENTRY * pentry;
+	HISTORY_ENTRY * next;
+	pentry=historyhead->first;
+	while(pentry)
+		{
+		next=pentry->next;
+		history_release_entry(pentry);
+		pentry=next;
+		}
+	historyhead->first=0;
+	historyhead->last=0;
+	historyhead->length=0;
 	return 1;
 }
+
+int history_init_history_data(HISTORY_LIST_HEAD* historyhead)
+{
+
+ DBG_ENTER();
+  int res = history_read_list(historyhead);
+
+  if(res == 0)
+  {
+    res = history_read_list_cmd (historyhead);
+  }
+  DBG_MESSAGE("History:%d",historyhead->length);
+  DBG_LEAVE();
+  return res;
+}
+

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.h	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.h	2007-01-04 02:14:40 UTC (rev 494)
@@ -57,10 +57,12 @@
   char *name;       	///<person name
   char *number;       	///<person number
   char *picpath;  ///<the picture file path for the person
-  char *time;	///<date and time of that talk
+  char *time;	///< start time of that talk 
+  char *date;///<start date  of that talk
   int durationsec;///<seconds of the duaration 
   struct historyentry* next;         ///<pointer to next entry
   struct historyentry* prev;         ///<pointer to next entry
+  int hasname;
 }HISTORY_ENTRY;
 
 
@@ -105,7 +107,7 @@
  * @retval 0 failed 
  * @retval 1 success
  */
-int history_release_list(HISTORY_LIST_HEAD* historyhead);
+int history_release_history_list(HISTORY_LIST_HEAD* historyhead);
 
 /**
  * @brief create a history entry, and add this entry to the list.
@@ -120,7 +122,7 @@
  * @return 
  * @retval the newly created entry pointer
  */
-HISTORY_ENTRY * history_add_entry(HISTORY_LIST_HEAD* historyhead, HISTORY_TYPE type,const char *name,const char *number,const char *picpath,  char *time,int durationsec);
+HISTORY_ENTRY * history_add_entry(HISTORY_LIST_HEAD* historyhead, HISTORY_TYPE type,const char *name,const char *number,const char *picpath,  char *time,char *date,int durationsec);
 /**
  * @brief delete the supplied entry from the list 
  * 
@@ -133,6 +135,8 @@
  * @retval 1 success
  */
 int history_delete_entry(HISTORY_LIST_HEAD* historyhead,HISTORY_ENTRY* entry);
+
+int history_init_history_data(HISTORY_LIST_HEAD* historyhead);
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.c	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.c	2007-01-04 02:14:40 UTC (rev 494)
@@ -217,8 +217,8 @@
 
 if(!moko_dialer_autolist->tipscreated)
 {
-  gchar filepath[MOKO_DIALER_MAX_PATH_LEN];
-  if(file_create_data_path_for_the_file("unkown.png",filepath))
+  gchar filepath[MOKO_DIALER_MAX_PATH_LEN+1];
+  if(file_create_data_path_for_the_file(MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH,filepath))
   	{
 	  imagePerson = gtk_image_new_from_file(filepath);
   	}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-declares.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-declares.h	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-declares.h	2007-01-04 02:14:40 UTC (rev 494)
@@ -17,15 +17,15 @@
  */
 #ifndef _MOKO_DIALER_DECLARES_H_
 #define _MOKO_DIALER_DECLARES_H_
-
-#define MOKO_DIALER_MAX_NUMBER_LEN	(64)
-#define MOKO_DIALER_MAX_DISP_NAME_LEN (20)
-#define MOKO_DIALER_MAX_PATH_LEN (128)	
+#define MOKO_DIALER_MAX_TIME_STATUS_LEN (128)  ///<TO HOLD THE STRINGS LIKE "CALL...(00:00:30)
+#define MOKO_DIALER_MAX_NUMBER_LEN	(64)          ///<TO HOLD THE PHONE NUMBERS
+#define MOKO_DIALER_MAX_DISP_NAME_LEN (20)   ///<THE MAXIMUM LENGTH OF THE DISPLAYED CONTACT NAME
+#define MOKO_DIALER_MAX_PATH_LEN (128)	 ///<THE MAX PATH LEN
 //MAXDISPNAMENUM MUST >=1 & <=9!
-//only when user inputs at least MINSENSATIVELEN, should we start to search.
-#define MOKO_DIALER_MIN_SENSATIVE_LEN (1)
-#define MOKO_DIALER_MAX_STATUS_ICONS (3)
-#define MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH ("unkown.png")
-#define MOKO_DIALER_MAX_TIPS (3)
 
+#define MOKO_DIALER_MIN_SENSATIVE_LEN (1) ///<only when user inputs at least MINSENSATIVELEN, should we start to search.
+#define MOKO_DIALER_MAX_STATUS_ICONS (3) ///<THE NUMBERS OF THE ICONS WHEN OUTGOING CALL IS ON
+#define MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH ("unkown.png") ///<THE DEFAULT PERSON IMAGE
+#define MOKO_DIALER_MAX_TIPS (4)
+
 #endif

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h	2007-01-04 02:14:40 UTC (rev 494)
@@ -29,6 +29,8 @@
 #include "moko-digit-button.h"
 #include "moko-dialer-status.h"
 #include <libmokoui/moko-dialog-window.h>
+#include <time.h>
+#include <gtk/gtkliststore.h>
 //
 
 
@@ -39,6 +41,7 @@
   STATE_TALKING,
   STATE_FINISHED,
   STATE_FAILED,
+  STATE_REJECTED,
   STATE_TIMEOUT,
   STATE_IGNORED,
   STATE_MISSED
@@ -62,14 +65,13 @@
 
 typedef struct _globalstate
 {
-	DIALER_READY_CONTACT contactinfo;
 	CONNECTION_STATE callstate;
 	WINDOW_STATE talkingstate;
 	SPEAKER_STATE speakerstate;
 	HISTORY_TYPE historytype;
-	char starttime[9];
-	char startdate[11];
-	char lastnumber[MOKO_DIALER_MAX_NUMBER_LEN];
+	char starttime[24];
+	char startdate[24];
+	char lastnumber[MOKO_DIALER_MAX_NUMBER_LEN+1];
 }GLOBAL_STATE;
 
 typedef int (*TimeExpireCallback)();
@@ -84,7 +86,7 @@
 	gint sec;   
 	gint min;
 	gint hour;
-	char timestring[MOKO_DIALER_MAX_NUMBER_LEN] ;
+	char timestring[MOKO_DIALER_MAX_TIME_STATUS_LEN+1] ;
 }TIMER_DATA;
 
 enum {
@@ -98,6 +100,6 @@
 	COLUMN_HASNAME,
 	N_COLUMN
 };
+void gsm_incoming_call(gchar * number);
 
-
 #endif

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.c	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.c	2007-01-04 02:14:40 UTC (rev 494)
@@ -18,6 +18,7 @@
  */
 
  #include "moko-dialer-textview.h"
+ #include "moko-dialer-declares.h"
  #include "error.h"
 G_DEFINE_TYPE (MokoDialerTextview, moko_dialer_textview, GTK_TYPE_TEXT_VIEW)
 
@@ -202,6 +203,8 @@
 GtkTextIter selectioniter,insertiter;
 GtkTextMark *selectmark,*insertmark;
 
+//DBG_MESSAGE("number=%s",number);
+
  /* Obtaining the buffer associated with the widget. */
 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
 	
@@ -222,15 +225,14 @@
  gtk_text_buffer_get_start_iter (buffer, &start);
  gtk_text_buffer_get_end_iter (buffer, &end);
 
-  /* Get the entire buffer text. */
-  //codestring = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+
    len=gtk_text_buffer_get_char_count(buffer);
   //len=strlen(codestring);
-	if(len>=0&&len<MOKO_DIALER_TEXT_VIEW_MAXDIALNUMBERLEN)
+	if(len>=0&&len<MOKO_DIALER_MAX_NUMBER_LEN)
 	{
 	
-	gtk_text_buffer_insert_at_cursor( buffer,number,1);
-	len=len+1;
+	gtk_text_buffer_insert_at_cursor( buffer,number,strlen(number));
+	len=len+strlen(number);
 	}
 	else
 	{

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.h	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.h	2007-01-04 02:14:40 UTC (rev 494)
@@ -31,7 +31,6 @@
 
 G_BEGIN_DECLS
 
-#define MOKO_DIALER_TEXT_VIEW_MAXDIALNUMBERLEN 128
 
 #define MOKO_TYPE_DIALER_TEXTVIEW                (moko_dialer_textview_get_type())
 #define MOKO_DIALER_TEXTVIEW (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_TEXTVIEW, MokoDialerTextview))

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c	2007-01-04 02:14:40 UTC (rev 494)
@@ -29,13 +29,63 @@
 #include <gtk/gtktogglebutton.h>
 #include <gtk/gtkvbox.h>
 #include "contacts.h"
+#include  "history.h"
+#include "error.h"
+#include "dialergsm.h"
 #include "openmoko-dialer-main.h"
 #include "openmoko-dialer-window-dialer.h"
 #include "openmoko-dialer-window-outgoing.h"
+#include "openmoko-dialer-window-incoming.h"
+MOKO_DIALER_APP_DATA* p_dialer_data=0;
+MOKO_DIALER_APP_DATA*  moko_get_app_data()
+{
+return p_dialer_data;
+}
+
+void gsm_incoming_call(gchar * number)
+{
+
+MOKO_DIALER_APP_DATA* appdata=moko_get_app_data();
+
+if(appdata)
+{
+//first, we should remove the "" from the number.
+char temp[20];
+int start=0;
+int end=strlen(number);
+while(number[start]=='\"'&&start<end)start++;
+if(end>1)while(number[end-1]=='\"'&&start<end)end--;
+
+DBG_MESSAGE("START=%d,END=%d",start,end);
+strcpy(temp,number+start);
+temp[end-1]=0;
+DBG_MESSAGE("%s",temp);	
+
+
+
+//got the number;
+strcpy(appdata->g_peer_info.number,temp);
+
+//retrieve the contact information if any.
+contact_get_peer_info_from_number(appdata->g_contactlist.contacts , &(appdata->g_peer_info));
+// contact_get_peer_info_from_number
+
+
+//transfer the contact info
+window_incoming_prepare(appdata);
+
+gtk_widget_show(appdata->window_incoming);
+}
+else
+{
+DBG_ERROR("gui failed to initialize.try another time.");
+}
+
+
+}
+
 int main( int argc, char** argv )
 {
-
-    MOKO_DIALER_APP_DATA* p_dialer_data;
     p_dialer_data=calloc(1,sizeof(MOKO_DIALER_APP_DATA));
     /* Initialize GTK+ */
     gtk_init( &argc, &argv );
@@ -43,21 +93,60 @@
 
     //init application data
    contact_init_contact_data(&(p_dialer_data->g_contactlist));
+   history_init_history_data(&(p_dialer_data->g_historylist));
+   
 
     /* application object */
-    MokoApplication* app = MOKO_APPLICATION(moko_application_get_instance());
+//    MokoApplication* app = MOKO_APPLICATION(moko_application_get_instance());
     g_set_application_name( "OpenMoko Dialer" );
 
+
+//   gtk_main();
+
+
+
+ GMainLoop* mainloop=0;
+ mainloop = g_main_loop_new(NULL, FALSE );
+ p_dialer_data->mainloop=mainloop;
+
+
 //init the dialer window
+  window_dialer_init(p_dialer_data); 
+//  window_incoming_init(p_dialer_data); 
+//  window_outgoing_init(p_dialer_data); 
+//  window_history_init(p_dialer_data); 
 
-   window_outgoing_init(p_dialer_data);
 
 
-   window_dialer_init(p_dialer_data); 
+//from now on we will not use multithreads.
+  gsm_lgsm_start(mainloop);
+  //start a timer to monitor incoming calls
+  //gtk_timeout_add(100,incoming_calls,0);
+ 
+//instead, we add a g_source
 
-    gtk_main();
-    
+
+  //gdk_threads_enter();
+  //gtk_main ();
+  //gdk_threads_leave();
+  
+//  GMainLoop* mainloop = g_main_loop_new(NULL, FALSE );
+  
+//  [ set up a GSource ]
+//  [ add a GPollFD ]
+//  g_source_attach( gsource, NULL );
+  g_main_loop_run(mainloop);
+
+
+
+
+
+
+
+//release everything    
     contact_release_contact_list(&(p_dialer_data->g_contactlist)); 
 
+  history_release_history_list(&(p_dialer_data->g_historylist));
     return 0;
 }
+

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.h	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.h	2007-01-04 02:14:40 UTC (rev 494)
@@ -34,9 +34,13 @@
 {
  //the global data area begins here
 
+ GMainLoop* mainloop;
 
-MokoDialerTextview *moko_dialer_text_view;
+MokoDialerTextview *moko_dialer_text_view; ///<the textview for the dialer window 
 
+MokoDialerTextview *moko_dtmf_text_view; ///<the textview for the dtmf window
+
+
 MokoDialerAutolist *moko_dialer_autolist;
 
 DIALER_CONTACTS_LIST_HEAD       g_contactlist; ///< the whole list of the contacts from the contact book.
@@ -44,19 +48,20 @@
 DIALER_CONTACT_PEER_INFO g_peer_info; ///<hold the peer's name, number, etc.
 
 HISTORY_LIST_HEAD g_historylist; ///< the whole list of the talk history
-
+HISTORY_ENTRY * g_currentselected; ///<pointer to the history entry which in the GUI the user selects.
 GLOBAL_STATE g_state; ///< the global states holder. we count on it a lot.
 
-//gint g_ptimeout; ///< the timer hanle
 
 TIMER_DATA g_timer_data;///< the data used by the timers
 
 MokoDialerStatus * status_outgoing;
+MokoDialerStatus * status_talking;
+MokoDialerStatus * status_incoming;
+
+GtkWidget* window_incoming;
 GtkWidget* window_outgoing;
-
-MokoDialerStatus * status_talking;
 GtkWidget* window_talking;
-
+GtkWidget * window_history;
 GtkWidget * window_dialer;
 
 //buttons
@@ -64,11 +69,32 @@
 GtkWidget* buttonCancel;
 GtkWidget* buttonRedial;
 
-//WindowOutgoing window_outgoing_data;
-// GtkListStore  *g_list_store_filter;///<the list store used by the gtktreeview, for displaying the history list dynamically.
+GtkWidget* imageTALK;
+GtkWidget* imageDTMF;
 
-// HISTORY_TYPE g_historyfiltertype;///<indicates the current history filter type, the gtktreeview will be filtered on the value.
+GtkWidget* content_talk;
+GtkWidget* content_dtmf;
 
-// GdkPixbuf * g_iconReceived,*g_iconMissed,*g_iconDialed;///<the global pixbuf for the 3 icons displayed in the history window.}DIALER_APP_DATA;
+
+GtkWidget* wheel_talking;
+GtkWidget* toolbox_talking;
+
+
+GtkWidget* wheel_history;
+GtkWidget* toolbox_history;
+GtkWidget* label_filter_history;
+GtkWidget* label_counter_history;
+GtkWidget* treeview_history;
+GtkWidget* menu_history;
+
+gboolean dtmf_in_talking_window;
+gboolean history_need_to_update;
+
+ GtkListStore  *g_list_store_filter;///<the list store used by the gtktreeview, for displaying the history list dynamically.
+
+ HISTORY_TYPE g_history_filter_type;///<indicates the current history filter type, the gtktreeview will be filtered on the value.
+
+ GdkPixbuf * g_iconReceived,*g_iconMissed,*g_iconDialed;///<the global pixbuf for the 3 icons displayed in the history window.}DIALER_APP_DATA;
 }MOKO_DIALER_APP_DATA;
 
+

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.c	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.c	2007-01-04 02:14:40 UTC (rev 494)
@@ -32,6 +32,7 @@
 #include "contacts.h"
 #include "openmoko-dialer-main.h"
 #include "openmoko-dialer-window-dialer.h"
+#include "openmoko-dialer-window-history.h"
 
 void cb_delete_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
 {
@@ -50,7 +51,7 @@
 {
 moko_dialer_textview_delete(appdata->moko_dialer_text_view);
 //refresh the autolist,but do not automaticall fill the textview
-char codesinput[MOKO_DIALER_MAX_NUMBER_LEN];
+char codesinput[MOKO_DIALER_MAX_NUMBER_LEN+1];
 moko_dialer_textview_get_input(appdata->moko_dialer_text_view,codesinput, 0);
 
 if(strlen(codesinput)>=MOKO_DIALER_MIN_SENSATIVE_LEN)
@@ -68,23 +69,37 @@
 
 void cb_history_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
 {
-    g_debug( "history button clicked" );
+if(!appdata->window_history)
+	window_history_init(appdata);
+
+//start dialling.
+gtk_widget_show(appdata->window_history);
+
 }
 
 void window_dialer_dial_out(MOKO_DIALER_APP_DATA * appdata)
 {
-gchar codesinput[MOKO_DIALER_MAX_NUMBER_LEN];
+gchar codesinput[MOKO_DIALER_MAX_NUMBER_LEN+1];
  //get the input digits
  moko_dialer_textview_get_input(appdata->moko_dialer_text_view, codesinput, 0);
-if(strlen(codesinput)<=1)
+if(strlen(codesinput)<1)
+{
+	if(strlen(appdata->g_state.lastnumber)>0)
+	{
+	moko_dialer_textview_insert(appdata->moko_dialer_text_view,appdata->g_state.lastnumber);
+	moko_dialer_autolist_refresh_by_string(appdata->moko_dialer_autolist,appdata->g_state.lastnumber,TRUE);
+	}
+	//user didn't input anything, maybe it's a redial
+	
 	return;
+}
 //empty the textview
 moko_dialer_textview_empty(appdata->moko_dialer_text_view);
 
 //and we set the selected autolist to be No
 moko_dialer_autolist_set_select(appdata->moko_dialer_autolist,-1);
+moko_dialer_autolist_hide_all_tips(appdata->moko_dialer_autolist);
 
-
 //got the number;
 strcpy(appdata->g_peer_info.number,codesinput);
 
@@ -92,15 +107,25 @@
 contact_get_peer_info_from_number(appdata->g_contactlist.contacts , &(appdata->g_peer_info));
 // contact_get_peer_info_from_number
 
+/*
 if(!appdata->window_outgoing)
-	window_outgoing_init(appdata);
+	window_incoming_init(appdata);
 
 //transfer the contact info
+window_incoming_prepare(appdata);
+
+//start dialling.
+gtk_widget_show(appdata->window_incoming);
+*/
+
+//transfer the contact info
 window_outgoing_prepare(appdata);
 
 //start dialling.
 gtk_widget_show(appdata->window_outgoing);
 
+
+
 }
 
 void cb_dialer_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
@@ -114,7 +139,7 @@
 on_dialer_autolist_user_selected(GtkWidget * widget,gpointer para_pointer,
                                         gpointer         user_data)
 {
-gchar codesinput[MOKO_DIALER_MAX_NUMBER_LEN];
+gchar codesinput[MOKO_DIALER_MAX_NUMBER_LEN+1];
 gint lenstring=0;
 gint leninput=0;
 MOKO_DIALER_APP_DATA * appdata=(MOKO_DIALER_APP_DATA*)user_data;
@@ -144,7 +169,7 @@
 DBG_MESSAGE("GOT THE MESSAGE OF confirmed:%s",ready_contact->p_entry->content);
 moko_dialer_textview_confirm_it(moko_dialer_text_view,ready_contact->p_entry->content);
 DBG_MESSAGE("And here we are supposed to call out directly");
-window_dialer_dial_out(appdata);
+//window_dialer_dial_out(appdata);
 
 
 }
@@ -168,19 +193,29 @@
 char input[2];
 input[0]=parac;
 input[1]=0;
-char codesinput[MOKO_DIALER_MAX_NUMBER_LEN];
+char codesinput[MOKO_DIALER_MAX_NUMBER_LEN+1];
 
-
+//DBG_TRACE();
 MOKO_DIALER_APP_DATA * appdata=(MOKO_DIALER_APP_DATA*)user_data;
 MokoDialerTextview *moko_dialer_text_view=appdata->moko_dialer_text_view;
 
+
 moko_dialer_textview_insert(moko_dialer_text_view, input);
+//DBG_TRACE();
 
+
 moko_dialer_textview_get_input(moko_dialer_text_view,codesinput, 0);
+//DBG_TRACE();
+
+//DBG_MESSAGE("LEN=%d,MAX=%d",strlen(codesinput),MOKO_DIALER_MAX_NUMBER_LEN);
+
 if(strlen(codesinput)>=MOKO_DIALER_MIN_SENSATIVE_LEN)
+{
 	moko_dialer_autolist_refresh_by_string(appdata->moko_dialer_autolist,codesinput,TRUE);
+}
 else
-	moko_dialer_autolist_hide_all_tips(appdata->moko_dialer_autolist);
+{	moko_dialer_autolist_hide_all_tips(appdata->moko_dialer_autolist);
+}
 
 }
 void
@@ -196,6 +231,9 @@
 gint window_dialer_init( MOKO_DIALER_APP_DATA* p_dialer_data)
 {
 
+if(!p_dialer_data-> window_dialer)
+{
+
 	GdkColor  color;
 	gdk_color_parse("black",&color);
 
@@ -204,7 +242,7 @@
 
     MokoFingerWindow* window = MOKO_FINGER_WINDOW(moko_finger_window_new());
 
-    /* application menu */
+/*
     GtkMenu* appmenu = GTK_MENU(gtk_menu_new());
 
     GtkMenuItem* closeitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label( "Close" ));
@@ -213,21 +251,16 @@
     
     gtk_menu_shell_append( appmenu, closeitem );
     moko_finger_window_set_application_menu( window, appmenu );
-
-    /* connect close event */
     g_signal_connect( G_OBJECT(window), "delete_event", G_CALLBACK( gtk_main_quit ), NULL );
+*/
 
-
     /* contents */
     vbox = gtk_vbox_new( FALSE, 0 );
-    GtkHBox* hbox = gtk_hbox_new( FALSE, 10 );
+  GtkHBox* hbox = gtk_hbox_new( FALSE, 10 );
 
-
-
-  
 	
-	 GtkEventBox *eventbox1 = gtk_event_box_new ();
-	 gtk_widget_show (eventbox1);
+ GtkEventBox *eventbox1 = gtk_event_box_new ();
+ gtk_widget_show (eventbox1);
 	//  gtk_widget_set_size_request (eventbox1, 480, 132);
   gtk_widget_set_name(GTK_WIDGET(eventbox1),"gtkeventbox-black");
 
@@ -300,7 +333,8 @@
     GtkButton* button3 = moko_pixmap_button_new();
     g_signal_connect( G_OBJECT(button3), "clicked", G_CALLBACK(cb_history_button_clicked), p_dialer_data );
     gtk_widget_set_name( GTK_WIDGET(button3), "mokofingerbutton-orange" );
-moko_pixmap_button_set_center_stock(button3,"gtk-refresh");
+//moko_pixmap_button_set_center_stock(button3,"gtk-refresh");
+moko_pixmap_button_set_finger_toolbox_btn_center_image(button3, file_new_image_from_relative_path("all.png"));
 moko_pixmap_button_set_action_btn_lower_label(button3,"History");
   gtk_widget_set_size_request (button3, WINDOW_DIALER_BUTTON_SIZE_X, WINDOW_DIALER_BUTTON_SIZE_Y);	
     gtk_box_pack_start( GTK_BOX(vbox2), GTK_WIDGET(button3),FALSE, FALSE, 5 );
@@ -310,8 +344,8 @@
 	
     g_signal_connect( G_OBJECT(button2), "clicked", G_CALLBACK(cb_dialer_button_clicked), p_dialer_data );
     gtk_widget_set_name( GTK_WIDGET(button2), "mokofingerbutton-black" );
-	moko_pixmap_button_set_center_stock(button2,"gtk-yes");
-	moko_pixmap_button_set_action_btn_lower_label(button2,"Dial");
+ moko_pixmap_button_set_finger_toolbox_btn_center_image(button2, file_new_image_from_relative_path("phone.png"));
+moko_pixmap_button_set_action_btn_lower_label(button2,"Dial");
   gtk_widget_set_size_request (button2, WINDOW_DIALER_BUTTON_SIZE_X+20, WINDOW_DIALER_BUTTON_SIZE_Y+80);
   
     gtk_box_pack_start( GTK_BOX(vbox2), GTK_WIDGET(button2), FALSE, FALSE, 20 );
@@ -331,30 +365,10 @@
 
     p_dialer_data-> window_dialer=window;
 
+   gtk_widget_show_all( GTK_WIDGET(window) );
 
-//now the wheel and tool box
+}
 
-  MokoFingerToolBox* tools = NULL;
-  tools = moko_finger_window_get_toolbox(window);
-        for ( int i = 0; i < 4; ++i )
-        {
-            GtkButton* newbutton = moko_finger_tool_box_add_button( tools );
-//            g_signal_connect( G_OBJECT(newbutton), "clicked", G_CALLBACK(cb_tool_button_clicked), window );
-        }
-  //     gtk_widget_show( GTK_WIDGET(tools));
-    gtk_widget_show(moko_finger_window_get_toolbox(window));
-
-// MokoFingerWheel* wheel = NULL;
- gtk_widget_show( GTK_WIDGET(moko_finger_window_get_wheel(window)) );
-
-
- gtk_widget_show_all( GTK_WIDGET(window) );
-
-
-
-
-    
-
     return 1;
 }
 

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.c	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.c	2007-01-04 02:14:40 UTC (rev 494)
@@ -0,0 +1,304 @@
+/*   openmoko-dialer-window-incoming.c
+ *
+ *  Authored by Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 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.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+
+#include <libmokoui/moko-finger-tool-box.h>
+#include <libmokoui/moko-finger-window.h>
+#include <libmokoui/moko-finger-wheel.h>
+#include <libmokoui/moko-pixmap-button.h>
+
+#include <gtk/gtkalignment.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkmenu.h>
+#include <gtk/gtkmenuitem.h>
+#include <gtk/gtkvbox.h>
+#include "contacts.h"
+#include "openmoko-dialer-main.h"
+#include "moko-dialer-status.h"
+#include "openmoko-dialer-window-incoming.h"
+
+void cb_answer_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
+{
+DBG_ENTER();
+
+appdata->g_state.callstate=STATE_TALKING;
+gsm_answer();
+
+gtk_widget_hide(appdata->window_incoming);
+
+if(!appdata->window_talking)
+	window_talking_init(appdata);
+
+//transfer the contact info
+window_talking_prepare(appdata);
+
+
+gtk_widget_show(appdata->window_talking);
+
+DBG_LEAVE();
+}
+
+void cb_ignore_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
+{
+DBG_ENTER();
+DBG_MESSAGE("We will mute the phone for this call.");
+appdata->g_state.callstate=STATE_IGNORED;
+DBG_LEAVE();
+}
+
+void cb_reject_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
+{
+DBG_ENTER();
+appdata->g_state.callstate=STATE_REJECTED;
+gtk_widget_hide(appdata->window_incoming);
+DBG_LEAVE();
+}
+
+void window_incoming_prepare(MOKO_DIALER_APP_DATA * appdata)
+{
+if(!appdata)
+{
+DBG_WARN("appdata=NULL!");
+return;
+}
+
+if(appdata->window_incoming==0)
+{
+window_incoming_init(appdata);
+}
+
+   moko_dialer_status_set_person_number(appdata->status_incoming, appdata->g_peer_info.number);
+if(appdata->g_peer_info.hasname)
+{
+   moko_dialer_status_set_person_image(appdata->status_incoming, appdata->g_peer_info.picpath);  
+   moko_dialer_status_set_person_name(appdata->status_incoming, appdata->g_peer_info.name);
+}
+else
+{
+   moko_dialer_status_set_person_image(appdata->status_incoming, MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);  
+   moko_dialer_status_set_person_name(appdata->status_incoming, "");
+
+}
+
+
+
+}
+
+gint window_incoming_fails(MOKO_DIALER_APP_DATA * appdata)
+{
+DBG_ENTER();
+DBG_LEAVE();     
+}
+
+gint timer_incoming_time_out(MOKO_DIALER_APP_DATA * appdata)
+{
+//DBG_ENTER();
+TIMER_DATA* timer_data=&(appdata->g_timer_data);
+
+/*	
+timer_data->ticks++;
+timer_data->hour=timer_data->ticks/3600;
+timer_data->min=(timer_data->ticks-timer_data->hour*3600)/60;
+timer_data->sec=timer_data->ticks%60;
+
+
+sprintf(timer_data->timestring,"%02d:%02d:%02d",timer_data->hour,timer_data->min,timer_data->sec);
+//ok,we update the label now.
+moko_dialer_status_set_status_label(appdata->status_incoming,timer_data->timestring);
+moko_dialer_status_update_icon(appdata->status_incoming);
+*/
+if(event_get_keep_calling())
+{
+	event_reset_keep_calling();
+	timer_data->ticks=0;
+}
+else
+{	//we count 4 before we confirm that there are no calling at all.
+	if(timer_data->ticks>=3)
+	{
+		DBG_MESSAGE("THE CALLER aborted, we quit.");
+		gsm_hangup();
+		appdata->g_state.callstate=STATE_MISSED;
+		appdata->g_state.historytype=MISSED;
+		gdk_threads_enter();
+		gtk_widget_hide(appdata->window_incoming);
+		gdk_threads_leave();
+		return 0; //don't lookout the timeout.
+	}
+	else
+	{
+	DBG_MESSAGE("ticks=%d",timer_data->ticks);
+	timer_data->ticks++;
+	}
+}
+
+return 1;
+
+
+}
+
+
+
+void
+on_window_incoming_hide                 (GtkWidget       *widget,
+                                        MOKO_DIALER_APP_DATA * appdata)
+{
+if(appdata->g_timer_data.ptimer!=0)
+{
+gtk_timeout_remove(appdata->g_timer_data.ptimer);
+appdata->g_timer_data.ptimer=0;
+}
+
+event_reset_clip_signaled();
+event_reset_incoming_signaled();
+event_reset_keep_calling();
+
+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);
+
+}
+
+}
+
+gint window_incoming_setup_timer(MOKO_DIALER_APP_DATA * 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)
+{
+gtk_timeout_remove(appdata->g_timer_data.ptimer);
+appdata->g_timer_data.ptimer=0;
+}
+
+memset(&(appdata->g_timer_data),0,sizeof(appdata->g_timer_data));
+
+appdata->g_timer_data.stopsec=0;
+
+appdata->g_timer_data.ptimer=gtk_timeout_add(1000,timer_incoming_time_out,appdata);
+
+
+}
+
+void
+on_window_incoming_show                  (GtkWidget       *widget,
+                                        MOKO_DIALER_APP_DATA * appdata)
+{
+
+appdata->g_state.callstate=STATE_INCOMING;
+window_incoming_setup_timer(appdata);
+
+
+}
+
+
+gint window_incoming_init( MOKO_DIALER_APP_DATA* p_dialer_data)
+{
+
+DBG_ENTER();
+MokoFingerWindow* window;
+GtkWidget* vbox;
+MokoDialerStatus * status;
+
+if(p_dialer_data->window_incoming==0)
+{
+
+  vbox = gtk_vbox_new( FALSE, 0 );
+   status=moko_dialer_status_new();
+   moko_dialer_status_add_status_icon(status,"status0.png");
+   moko_dialer_status_add_status_icon(status,"status1.png");
+   moko_dialer_status_add_status_icon(status,"status2.png");
+   moko_dialer_status_set_icon_by_index(status,0);
+   
+   gtk_box_pack_start( GTK_BOX(vbox),status, FALSE, FALSE, 0 );
+
+ 	
+    GtkHBox *  hbox2 = gtk_hbox_new( FALSE, 0 );
+    GtkButton* button = gtk_button_new_with_label("Answer");
+    g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_answer_button_clicked), p_dialer_data );
+
+    gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 10);
+
+  button = gtk_button_new_with_label("Ignore");
+  g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_ignore_button_clicked), p_dialer_data );
+  gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button), TRUE, TRUE, 10 );
+
+
+
+button = gtk_button_new_with_label("Reject");
+ g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_reject_button_clicked), p_dialer_data );
+ gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 10);
+
+
+
+
+   gtk_box_pack_start( GTK_BOX(vbox),hbox2, FALSE, FALSE, 50 );
+
+
+//currently     MokoDialogWindow is not finished, wating...
+//   MokoDialogWindow* window = (MokoDialogWindow *)(moko_dialog_window_new());
+//  moko_dialog_window_set_contents( window, GTK_WIDGET(vbox) );
+
+    window = MOKO_FINGER_WINDOW(moko_finger_window_new());
+    moko_finger_window_set_contents(window, GTK_WIDGET(vbox) );
+
+
+     gtk_widget_show_all( GTK_WIDGET(window) );
+
+
+     gtk_widget_hide( GTK_WIDGET(window) );   
+
+
+   moko_dialer_status_set_title_label(status, "Incoming call");
+   moko_dialer_status_set_status_label(status, "");
+
+   p_dialer_data->window_incoming=window;
+   p_dialer_data->status_incoming=status;
+   
+//   DBG_MESSAGE("p_dialer_data->status_incoming=0X%x",p_dialer_data->status_incoming);
+
+
+  g_signal_connect ((gpointer) window, "show",
+                    G_CALLBACK (on_window_incoming_show),
+                    p_dialer_data);
+  g_signal_connect ((gpointer) window, "hide",
+                    G_CALLBACK (on_window_incoming_hide),
+                    p_dialer_data);
+
+}
+
+
+DBG_LEAVE();
+    return 1;
+}
+

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.h	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.h	2007-01-04 02:14:40 UTC (rev 494)
@@ -0,0 +1,41 @@
+/*  openmoko-dialer-window-outgoing.h
+ *
+ *  Authored By Tony Guan<tonyguan at fic-sh.com.cn>
+ *
+ *  Copyright (C) 2006 FIC Shanghai Lab
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 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.
+ *
+ *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
+ */
+ #include "moko-dialer-includes.h"
+
+ #ifndef _OPENMOKO_DIALER_WINDOW_INCOMING_H
+#define _OPENMOKO_DIALER_WINDOW_INCOMING_H
+
+#ifdef __cplusplus
+
+
+
+extern "C"
+
+{
+#endif
+
+
+
+gint window_incoming_init( MOKO_DIALER_APP_DATA* p_dialer_data);
+
+void window_incoming_prepare(MOKO_DIALER_APP_DATA * appdata);
+#ifdef __cplusplus
+}
+#endif
+
+#endif 

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.c	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.c	2007-01-04 02:14:40 UTC (rev 494)
@@ -39,6 +39,9 @@
 DBG_ENTER();
 //moko_dialer_status_update_icon(appdata->status_outgoing);
 
+
+appdata->g_state.callstate=STATE_TALKING;
+
 gtk_widget_hide(appdata->window_outgoing);
 
 if(!appdata->window_talking)
@@ -61,20 +64,33 @@
 DBG_ENTER();
 gtk_widget_hide(appdata->buttonRedial);
 gtk_widget_show( appdata->buttonSpeaker);
+moko_dialer_status_set_title_label(appdata->status_outgoing, "Outgoing call");
+ moko_dialer_status_set_status_label(appdata->status_outgoing, "Calling ... (00:00:00)");
 window_outgoing_setup_timer(appdata);
+
+appdata->g_state.callstate=STATE_CALLING;
+appdata->g_state.historytype=OUTGOING;	
+gsm_dial(appdata->g_peer_info.number);
+
 DBG_LEAVE();
 }
 
 void cb_cancel_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
 {
 DBG_ENTER();
+gsm_hangup();
+appdata->g_state.callstate=STATE_FAILED;
 gtk_widget_hide(appdata->window_outgoing);
 DBG_LEAVE();
 }
 
 void window_outgoing_prepare(MOKO_DIALER_APP_DATA * appdata)
 {
-   moko_dialer_status_set_person_number(appdata->status_outgoing, appdata->g_peer_info.number);
+if(appdata->window_outgoing==0)
+	window_outgoing_init( appdata);
+
+	
+ moko_dialer_status_set_person_number(appdata->status_outgoing, appdata->g_peer_info.number);
 if(appdata->g_peer_info.hasname)
 {
    moko_dialer_status_set_person_image(appdata->status_outgoing, appdata->g_peer_info.picpath);  
@@ -82,13 +98,13 @@
 }
 else
 {
-   moko_dialer_status_set_person_image(appdata->status_outgoing, "");  
+   moko_dialer_status_set_person_image(appdata->status_outgoing, MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);  
    moko_dialer_status_set_person_name(appdata->status_outgoing, "");
 
 }
+strcpy(appdata->g_state.lastnumber,appdata->g_peer_info.number);
 
 
-
 }
 
 gint window_outgoing_fails(MOKO_DIALER_APP_DATA * appdata)
@@ -113,7 +129,7 @@
 timer_data->sec=timer_data->ticks%60;
 
 
-sprintf(timer_data->timestring,"Calling... (%02d:%02d:%02d)",timer_data->hour,timer_data->min,timer_data->sec);
+sprintf(timer_data->timestring,"Calling ... (%02d:%02d:%02d)",timer_data->hour,timer_data->min,timer_data->sec);
 
 //ok,we update the label now.
 
@@ -146,10 +162,23 @@
 gtk_timeout_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);
 
 }
 
+
+
+}
+
 gint window_outgoing_setup_timer(MOKO_DIALER_APP_DATA * appdata)
 {
 time_t timep;
@@ -180,8 +209,15 @@
                                         MOKO_DIALER_APP_DATA * appdata)
 {
 
+
 window_outgoing_setup_timer(appdata);
 
+
+appdata->g_state.callstate=STATE_CALLING;
+appdata->g_state.historytype=OUTGOING;	
+gsm_dial(appdata->g_peer_info.number);
+
+
 }
 
 
@@ -211,13 +247,13 @@
     g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_speaker_button_clicked), p_dialer_data );
 p_dialer_data->buttonSpeaker=button;
 //gtk_widget_set_size_request(button,100,32);
-    gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 10 );
+    gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 40 );
 
   button = gtk_button_new_with_label("Redial");
     p_dialer_data->buttonRedial=button;
   g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_redial_button_clicked), p_dialer_data );
 //gtk_widget_set_size_request(button,100,32);
-  gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button), TRUE, TRUE, 20 );
+  gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button), TRUE, TRUE, 40 );
 //gtk_widget_set_size_request(button,60,24);
 
 
@@ -225,7 +261,7 @@
   p_dialer_data->buttonCancel=button;
  g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_cancel_button_clicked), p_dialer_data );
 //gtk_widget_set_size_request(button,100,32);
- gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 10 );
+ gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 40);
 
 
 
@@ -250,7 +286,7 @@
 
 
    moko_dialer_status_set_title_label(status, "Outgoing call");
-   moko_dialer_status_set_status_label(status, "Calling ...(00:00:00)");
+   moko_dialer_status_set_status_label(status, "Calling ... (00:00:00)");
 
    p_dialer_data->window_outgoing=window;
    p_dialer_data->status_outgoing=status;

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.c	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.c	2007-01-04 02:14:40 UTC (rev 494)
@@ -34,30 +34,74 @@
 #include "moko-dialer-status.h"
 #include "openmoko-dialer-window-talking.h"
 
-/*
-void cb_speaker_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
+void
+openmoko_wheel_press_left_up_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata)
+{DBG_ENTER();
+}
+
+void
+openmoko_wheel_press_right_down_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata)
 {
 DBG_ENTER();
-moko_dialer_status_update_icon(appdata->status_talking);
+}
 
-DBG_LEAVE();
+
+void cb_tool_button_speaker_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER();
 }
 
-void cb_redial_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
+void cb_tool_button_dtmf_talk_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
 {
-DBG_ENTER();
+	DBG_ENTER();
+	
+	appdata->dtmf_in_talking_window=!appdata->dtmf_in_talking_window;
+	if(appdata->dtmf_in_talking_window)
+		{
+		
+			
+			moko_pixmap_button_set_finger_toolbox_btn_center_image(button, appdata->imageTALK);
+		       gtk_widget_hide(appdata->content_talk);
+			gtk_widget_show(appdata->content_dtmf);
+		}
+	else
+		{
+			moko_pixmap_button_set_finger_toolbox_btn_center_image(button, appdata->imageDTMF);
+			gtk_widget_hide(appdata->content_dtmf);
+		       gtk_widget_show(appdata->content_talk);
+		       
 
-DBG_LEAVE();
+		}
+
+  
 }
 
-void cb_cancel_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
+void cb_tool_button_hangup_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
 {
-DBG_ENTER();
-gtk_widget_hide(appdata->window_talking);
-DBG_LEAVE();
+     gtk_widget_hide(appdata->window_talking);
+     
 }
 
-*/
+
+void
+on_dtmf_panel_user_input(GtkWidget * widget,gchar parac,
+                                        gpointer         user_data)
+{
+char input[2];
+input[0]=parac;
+input[1]=0;
+char codesinput[MOKO_DIALER_MAX_NUMBER_LEN+1];
+
+
+MOKO_DIALER_APP_DATA * appdata=(MOKO_DIALER_APP_DATA*)user_data;
+MokoDialerTextview *moko_dtmf_text_view=appdata->moko_dtmf_text_view;
+
+moko_dialer_textview_insert(moko_dtmf_text_view, input);
+
+}
+
+
+
 void window_talking_prepare(MOKO_DIALER_APP_DATA * appdata)
 {
 DBG_ENTER();
@@ -69,7 +113,7 @@
 }
 else
 {
-   moko_dialer_status_set_person_image(appdata->status_talking, "");  
+   moko_dialer_status_set_person_image(appdata->status_talking, MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);  
    moko_dialer_status_set_person_name(appdata->status_talking, "");
 
 }
@@ -80,15 +124,9 @@
 
 gint timer_talking_time_out(MOKO_DIALER_APP_DATA * appdata)
 {
-DBG_ENTER();
+//DBG_ENTER();
 TIMER_DATA* timer_data=&(appdata->g_timer_data);
 
-DBG_MESSAGE("timer :p_dialer_data->status_talking=0X%x",appdata->status_talking);
-
-//gtk_label_set_text(appdata->status_talking->labelStatus,"laskdfas");
-
-
-//first of all, reset the timer to be called after 1 minute.
 	
 timer_data->ticks++;
 timer_data->hour=timer_data->ticks/3600;
@@ -126,7 +164,19 @@
 appdata->g_timer_data.ptimer=0;
 }
 
+gtk_widget_hide(appdata->wheel_talking);
+gtk_widget_hide(appdata->toolbox_talking);
 
+//DBG_MESSAGE("%s, %s",appdata->g_state.starttime,appdata->g_state.startdate);
+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,
+	appdata->g_timer_data.ticks);
+
+
 }
 
 void
@@ -135,13 +185,16 @@
 {
 DBG_ENTER();
 
+appdata->dtmf_in_talking_window=TRUE;
+	//hide the talking button in talking mode.
+
 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);
+sprintf(appdata->g_state.startdate,"%04d/%02d/%02d",p->tm_year+1900,p->tm_mon,p->tm_mday);
 
 memset(&(appdata->g_timer_data),0,sizeof(appdata->g_timer_data));
 
@@ -149,112 +202,152 @@
 
 appdata->g_timer_data.ptimer=gtk_timeout_add(1000,timer_talking_time_out,appdata);
 
-DBG_MESSAGE("on_window_talking_show status_talking=0X%x",appdata->status_talking);
+if(appdata->wheel_talking)
+gtk_widget_show(appdata->wheel_talking);
+
+if(appdata->toolbox_talking)
+gtk_widget_show(appdata->toolbox_talking);
+
+
    
 DBG_LEAVE();
 }
 
 
+
+
 gint window_talking_init( MOKO_DIALER_APP_DATA* p_dialer_data)
 {
 
 DBG_ENTER();
-MokoFingerWindow* window;
-GtkWidget* vbox;
-MokoDialerStatus * status;
 
+
 if(p_dialer_data->window_talking==0)
 {
 
-  vbox = gtk_vbox_new( FALSE, 0 );
+	MokoFingerWindow* window=NULL;
+	GtkWidget* vbox=gtk_vbox_new( FALSE, 0 );;
+	MokoDialerStatus * status=NULL;
+	GtkWidget* content_talk= NULL;
+	GtkWidget* content_dtmf= NULL;
+      MokoFingerToolBox *tools = NULL;
+      MokoDialerPanel* mokodialerpanel=NULL;
+      GtkWidget *button;
+      GtkWidget* image;
+
+
+//first, the talking content.
+
+   content_talk = gtk_vbox_new( FALSE, 0 );
    status=moko_dialer_status_new();
    moko_dialer_status_add_status_icon(status,"status0.png");
    moko_dialer_status_add_status_icon(status,"status1.png");
    moko_dialer_status_add_status_icon(status,"status2.png");
    moko_dialer_status_set_icon_by_index(status,0);
    
-   gtk_box_pack_start( GTK_BOX(vbox),status, FALSE, FALSE, 0 );
+   
+   moko_dialer_status_set_title_label(status, "In Call");
+   moko_dialer_status_set_status_label(status, "Talking ...(00:00:00)");
 
-/*
- 	
-    GtkHBox *  hbox2 = gtk_hbox_new( FALSE, 0 );
-    GtkButton* button = gtk_button_new_with_label("Speaker");
-    g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_speaker_button_clicked), p_dialer_data );
-p_dialer_data->buttonSpeaker=button;
-//gtk_widget_set_size_request(button,100,32);
-    gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 10 );
+   gtk_box_pack_start( GTK_BOX(content_talk),status, FALSE, FALSE, 0 );
 
-button = gtk_button_new_with_label("Cancel");
-  p_dialer_data->buttonCancel=button;
- g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_cancel_button_clicked), p_dialer_data );
-//gtk_widget_set_size_request(button,100,32);
- gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 10 );
 
+   p_dialer_data->status_talking=status;
+   p_dialer_data->content_talk= content_talk;
 
-  button = gtk_button_new_with_label("Redial");
-    p_dialer_data->buttonRedial=button;
-  g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_redial_button_clicked), p_dialer_data );
-//gtk_widget_set_size_request(button,100,32);
-  gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button), TRUE, TRUE, 20 );
-//gtk_widget_set_size_request(button,60,24);
+   gtk_box_pack_start( GTK_BOX(vbox),content_talk, FALSE, FALSE, 0 );
+   
+  
+//now the dtmf content
+  	content_dtmf= gtk_vbox_new( FALSE, 0 );
+  	GtkEventBox* eventbox1 = gtk_event_box_new ();
+	gtk_widget_show (eventbox1);
+	gtk_widget_set_name(GTK_WIDGET(eventbox1),"gtkeventbox-black");
 
+   	MokoDialerTextview * mokotextview=moko_dialer_textview_new();
 
-   gtk_box_pack_start( GTK_BOX(vbox),hbox2, FALSE, FALSE, 50 );
-*/
+  	gtk_container_add (GTK_CONTAINER (eventbox1), mokotextview);
 
-//currently     MokoDialogWindow is not finished, wating...
-//   MokoDialogWindow* window = (MokoDialogWindow *)(moko_dialog_window_new());
-//  moko_dialog_window_set_contents( window, GTK_WIDGET(vbox) );
+   	p_dialer_data->moko_dtmf_text_view=mokotextview;
+    
+  	gtk_box_pack_start( GTK_BOX(content_dtmf), GTK_WIDGET(eventbox1), FALSE,FALSE, 2 );
 
-    window = MOKO_FINGER_WINDOW(moko_finger_window_new());
-    moko_finger_window_set_contents(window, GTK_WIDGET(vbox) );
 
 
-     gtk_widget_show_all( GTK_WIDGET(window) );
+	 mokodialerpanel=moko_dialer_panel_new();
 
-     gtk_widget_hide( p_dialer_data->buttonRedial);
+   	gtk_widget_set_size_request (mokodialerpanel, 380, 384);
+   	g_signal_connect (GTK_OBJECT (mokodialerpanel), "user_input",  G_CALLBACK (on_dtmf_panel_user_input),p_dialer_data);
+    	gtk_box_pack_start( GTK_BOX(content_dtmf), GTK_WIDGET(mokodialerpanel), TRUE, TRUE, 5 );
+  
+   	gtk_box_pack_start( GTK_BOX(vbox),content_dtmf, FALSE, FALSE, 0 );
+   	p_dialer_data->content_dtmf=content_dtmf;
 
 
-     gtk_widget_hide( GTK_WIDGET(window) );   
+//now the container--window
+     window = MOKO_FINGER_WINDOW(moko_finger_window_new());
+     p_dialer_data->window_talking=window;
+     moko_finger_window_set_contents(window, GTK_WIDGET(vbox) );
+    g_signal_connect ((gpointer) window, "show",
+	                    G_CALLBACK (on_window_talking_show),
+	                    p_dialer_data);
+    g_signal_connect ((gpointer) window, "hide",
+	                    G_CALLBACK (on_window_talking_hide),
+	                    p_dialer_data);
 
+     
+     gtk_widget_show_all( GTK_WIDGET(window) );
 
-   moko_dialer_status_set_title_label(status, "In Call");
-   moko_dialer_status_set_status_label(status, "Talking ...(00:00:00)");
+//the gtk_widget_show_all is really bad, cause i have to call it and then hide some widgets.
 
-   p_dialer_data->window_talking=window;
-   p_dialer_data->status_talking=status;
-   
-//   DBG_MESSAGE("p_dialer_data->status_talking=0X%x",p_dialer_data->status_talking);
+   gtk_widget_hide(content_dtmf);
 
 
-  g_signal_connect ((gpointer) window, "show",
-                    G_CALLBACK (on_window_talking_show),
-                    p_dialer_data);
-  g_signal_connect ((gpointer) window, "hide",
-                    G_CALLBACK (on_window_talking_hide),
-                    p_dialer_data);
+ //now the wheel and tool box, why should the wheel and toolbox created after the gtk_widget_show_all???
+   gtk_widget_show(GTK_WIDGET(moko_finger_window_get_wheel(window)));
+    
+    g_signal_connect(G_OBJECT(moko_finger_window_get_wheel(window)),
+		    "press_left_up",
+		    G_CALLBACK(openmoko_wheel_press_left_up_cb),
+		    p_dialer_data);
+    g_signal_connect(G_OBJECT(moko_finger_window_get_wheel(window)),
+		    "press_right_down",
+		    G_CALLBACK(openmoko_wheel_press_right_down_cb),
+		    p_dialer_data);
 
- //now the wheel and tool box
 
-  MokoFingerToolBox* tools = NULL;
-  tools = moko_finger_window_get_toolbox(window);
-        for ( int i = 0; i < 4; ++i )
-        {
-            GtkButton* newbutton = moko_finger_tool_box_add_button( tools );
-//            g_signal_connect( G_OBJECT(newbutton), "clicked", G_CALLBACK(cb_tool_button_clicked), window );
-        }
- //     gtk_widget_show( GTK_WIDGET(tools));
-    gtk_widget_show(moko_finger_window_get_toolbox(window));
 
-// MokoFingerWheel* wheel = NULL;
- gtk_widget_show( GTK_WIDGET(moko_finger_window_get_wheel(window)) );
+        tools = moko_finger_window_get_toolbox(window);
+     
+	button = moko_finger_tool_box_add_button_without_label(tools);
+       image = file_new_image_from_relative_path("speaker.png");
+	moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image);
+        g_signal_connect(G_OBJECT(button), "clicked",
+			G_CALLBACK(cb_tool_button_speaker_clicked), p_dialer_data);
+	
+	button = moko_finger_tool_box_add_button_without_label(tools);
+       image = file_new_image_from_relative_path("dtmf.png");
+	moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image);
+	g_signal_connect(G_OBJECT(button), "clicked",
+			G_CALLBACK(cb_tool_button_dtmf_talk_clicked), p_dialer_data);
+	p_dialer_data->imageDTMF=image;
+	p_dialer_data->imageTALK=file_new_image_from_relative_path("talking.png");
+	
 
+	button = moko_finger_tool_box_add_button_without_label(tools);
+       image = file_new_image_from_relative_path("tony.png");
+	moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image);
+	g_signal_connect(G_OBJECT(button), "clicked",
+			G_CALLBACK(cb_tool_button_hangup_clicked), p_dialer_data);
+	gtk_widget_show(GTK_WIDGET(tools));
 
-// gtk_widget_show(p_dialer_data->window_talking);
+	p_dialer_data->dtmf_in_talking_window=0;
+	p_dialer_data->wheel_talking=moko_finger_window_get_wheel(window);
+	p_dialer_data->toolbox_talking=tools;
 
-DBG_LEAVE();
+
+	DBG_LEAVE();
+}
     return 1;
 }
 
-}
-

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.c	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.c	2007-01-04 02:14:40 UTC (rev 494)
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <string.h>
+
+#include <libgsmd/libgsmd.h>
+#include <libgsmd/event.h>
+
+#define PIN_SIZE 32
+
+static char *pin;
+static char pinbuf[PIN_SIZE+1];
+
+static int pin_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
+{
+	int rc;
+
+	printf("EVENT: PIN request (type=%u) ", aux->u.pin.type);
+
+	/* FIXME: read pin from STDIN and send it back via lgsm_pin */
+	if (aux->u.pin.type == 1 && pin) {
+		printf("Auto-responding with pin `%s'\n", pin);
+		lgsm_pin(lh, pin);
+	} else {
+		do {
+			printf("Please enter PIN: ");
+			rc = fscanf(stdin, "%32s", &pinbuf);
+		} while (rc < 1);
+
+		return lgsm_pin(lh, pinbuf);
+	}
+
+	return 0;
+}
+
+int pin_init(struct lgsm_handle *lh, const char *pin_preset)
+{
+	pin = pin_preset;
+	return lgsm_evt_handler_register(lh, GSMD_EVT_PIN, &pin_handler);
+}
+

Added: trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.h	2007-01-04 01:26:43 UTC (rev 493)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/pin.h	2007-01-04 02:14:40 UTC (rev 494)
@@ -0,0 +1,2 @@
+
+extern int pin_init(struct lgsm_handle *lh, const char *pin_preset);





More information about the commitlog mailing list