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

thomas at sita.openmoko.org thomas at sita.openmoko.org
Mon Feb 5 10:35:06 CET 2007


Author: thomas
Date: 2007-02-05 10:34:59 +0100 (Mon, 05 Feb 2007)
New Revision: 668

Modified:
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c
   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-status.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.h
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-history.c
   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-outgoing.c
   trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.c
Log:
Re-apply indendation fixes to the files that got reverted


Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c	2007-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c	2007-02-05 09:34:59 UTC (rev 668)
@@ -15,27 +15,28 @@
  *
  *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $]
  */
-#include "contacts.h" 
+#include "contacts.h"
 
 /**
  * @brief initialze the contact list, this will be called from outside, contactlist
 */
-int contact_init_contact_data(DIALER_CONTACTS_LIST_HEAD   *p_contactlist)
-{ 
-	
+int
+contact_init_contact_data (DIALER_CONTACTS_LIST_HEAD * p_contactlist)
+{
 
-  DBG_ENTER();
 
+  DBG_ENTER ();
+
   int res = contact_init_contact_list (p_contactlist);
 
-  if(res == -1)
+  if (res == -1)
   {
     res = contact_init_from_cmd (p_contactlist);
   }
 //  DBG_MESSAGE("CONTACTS:%d,list at 0x%x,first at 0x%x",p_contactlist->length,p_contactlist,p_contactlist->contacts);
-  
-  DBG_LEAVE();
-  
+
+  DBG_LEAVE ();
+
   return res;
 }
 
@@ -49,23 +50,25 @@
  * @return the number of the contacts. 
  * @retval 1
  */
-int contact_release_contact_entry(DIALER_CONTACT_ENTRY* contactentry)
+int
+contact_release_contact_entry (DIALER_CONTACT_ENTRY * contactentry)
 {
-	if(contactentry==0) return 1;
-		if(contactentry->desc)
-		{
-		free(contactentry->desc);
-		contactentry->desc=0;	
-		}
-		if(contactentry->content)
-		{
-			free(contactentry->content);
-			contactentry->content=0;
-		}
-		contactentry->next=0;
-		free(contactentry);
-	
-		return 1;
+  if (contactentry == 0)
+    return 1;
+  if (contactentry->desc)
+  {
+    free (contactentry->desc);
+    contactentry->desc = 0;
+  }
+  if (contactentry->content)
+  {
+    free (contactentry->content);
+    contactentry->content = 0;
+  }
+  contactentry->next = 0;
+  free (contactentry);
+
+  return 1;
 }
 
 /**
@@ -77,37 +80,39 @@
  * @return 
  * @retval 1
  */
-int contact_release_contact(DIALER_CONTACT *contact)
+int
+contact_release_contact (DIALER_CONTACT * contact)
 {
-	DIALER_CONTACT_ENTRY * entry=0;
-	DIALER_CONTACT_ENTRY * nextentry=0;
-	if(contact==0)return 1;
-	entry=contact->entry;
-	//free every entry
-	while(entry)
-	{
-		nextentry=entry->next;
-		contact_release_contact_entry(entry);
-		entry=nextentry;
-	}
-	contact->entry=0;
-	
-	//free name
-	if(contact->name)
-	{
-	free(contact->name);
-	contact->name=0;
-	}
-	//free picpath
-	if(contact->picpath)
-	{
-		free(contact->picpath);
-		contact->picpath=0;
-	}
-	//free contact itself
-	contact->entry=0;
-	free(contact);
-	return 1;
+  DIALER_CONTACT_ENTRY *entry = 0;
+  DIALER_CONTACT_ENTRY *nextentry = 0;
+  if (contact == 0)
+    return 1;
+  entry = contact->entry;
+  //free every entry
+  while (entry)
+  {
+    nextentry = entry->next;
+    contact_release_contact_entry (entry);
+    entry = nextentry;
+  }
+  contact->entry = 0;
+
+  //free name
+  if (contact->name)
+  {
+    free (contact->name);
+    contact->name = 0;
+  }
+  //free picpath
+  if (contact->picpath)
+  {
+    free (contact->picpath);
+    contact->picpath = 0;
+  }
+  //free contact itself
+  contact->entry = 0;
+  free (contact);
+  return 1;
 }
 
 /**
@@ -119,28 +124,30 @@
  * @return 
  * @retval 1
  */
-int contact_release_contact_list(DIALER_CONTACTS_LIST_HEAD * head)
+int
+contact_release_contact_list (DIALER_CONTACTS_LIST_HEAD * head)
 {
-//	g_printf("releasing %s\n",contact->name);
-	DIALER_CONTACT* contact=0;
-	DIALER_CONTACT* nextcontact=0;
-	if(head==0)return 1;
-	contact=head->contacts;
-	if(contact==0)
-		return 1;
-	
-	while(contact)
-	{
-	//	g_printf("releasing %s\n",contact->name);
-		nextcontact=contact->next;
-		contact_release_contact(contact);
-		contact=nextcontact;
-	}
-	head->length=0;
-	head->contacts=0;
-	return 1;
-	
-	
+//      g_printf("releasing %s\n",contact->name);
+  DIALER_CONTACT *contact = 0;
+  DIALER_CONTACT *nextcontact = 0;
+  if (head == 0)
+    return 1;
+  contact = head->contacts;
+  if (contact == 0)
+    return 1;
+
+  while (contact)
+  {
+    //      g_printf("releasing %s\n",contact->name);
+    nextcontact = contact->next;
+    contact_release_contact (contact);
+    contact = nextcontact;
+  }
+  head->length = 0;
+  head->contacts = 0;
+  return 1;
+
+
 }
 
 /**
@@ -155,29 +162,34 @@
  */
 
 
-int contact_add_contact_to_list(DIALER_CONTACTS_LIST_HEAD * head,DIALER_CONTACT*   contact)
+int
+contact_add_contact_to_list (DIALER_CONTACTS_LIST_HEAD * head,
+                             DIALER_CONTACT * contact)
 {
-if(head==0)return 0;
-if(contact==0)return 0;
+  if (head == 0)
+    return 0;
+  if (contact == 0)
+    return 0;
 
-if(head->contacts==0)
-{
-	//we are the first
-	head->length=1;
-	head->contacts=contact;
-	contact->next=0;
+  if (head->contacts == 0)
+  {
+    //we are the first
+    head->length = 1;
+    head->contacts = contact;
+    contact->next = 0;
 
-}else
-{
-	contact->next=head->contacts;
-	head->contacts=contact;
-	head->length++;
-	
-}
+  }
+  else
+  {
+    contact->next = head->contacts;
+    head->contacts = contact;
+    head->length++;
 
-	return 	head->length;
-	
-	
+  }
+
+  return head->length;
+
+
 }
 
 /**
@@ -192,20 +204,21 @@
  */
 
 
-DIALER_CONTACT*  contact_new_contact(char* name, char* id)
+DIALER_CONTACT *
+contact_new_contact (char *name, char *id)
 {
-	DIALER_CONTACT* nextcontact;
+  DIALER_CONTACT *nextcontact;
 
-	nextcontact=(DIALER_CONTACT* )calloc(1,sizeof(DIALER_CONTACT));
-	nextcontact->ID=0;
-	nextcontact->name=(char *)calloc(1,30);
-	strcpy(nextcontact->name,name);
-	nextcontact->name[29]='\0';
-	
-	nextcontact->ID=(char *)calloc(1,255);
-	strcpy(nextcontact->ID,id);
-	nextcontact->ID[254]='\0';
-	return nextcontact;
+  nextcontact = (DIALER_CONTACT *) calloc (1, sizeof (DIALER_CONTACT));
+  nextcontact->ID = 0;
+  nextcontact->name = (char *) calloc (1, 30);
+  strcpy (nextcontact->name, name);
+  nextcontact->name[29] = '\0';
+
+  nextcontact->ID = (char *) calloc (1, 255);
+  strcpy (nextcontact->ID, id);
+  nextcontact->ID[254] = '\0';
+  return nextcontact;
 }
 
 /**
@@ -221,26 +234,31 @@
  */
 
 
-DIALER_CONTACT_ENTRY* contact_add_entry(DIALER_CONTACT* contact, char* desc,char* content)
+DIALER_CONTACT_ENTRY *
+contact_add_entry (DIALER_CONTACT * contact, char *desc, char *content)
 {
-	
-	DIALER_CONTACT_ENTRY* nextentry;
-	
-	if(contact==0)return 0;
-	if(desc==0)return 0;
-	if(content==0)return 0;
-	nextentry=(DIALER_CONTACT_ENTRY*)calloc(1,sizeof(DIALER_CONTACT_ENTRY));
-	nextentry->desc=(char *)calloc(1,30);
-	strcpy(nextentry->desc,desc);
-	nextentry->desc[29]='\0';
-	nextentry->content=(char *)calloc(1,30);
-	strcpy(nextentry->content,content);
-	nextentry->content[29]='\0';
-	
-	nextentry->next=contact->entry;
-	contact->entry=nextentry;
-	
-	return nextentry;
+
+  DIALER_CONTACT_ENTRY *nextentry;
+
+  if (contact == 0)
+    return 0;
+  if (desc == 0)
+    return 0;
+  if (content == 0)
+    return 0;
+  nextentry =
+    (DIALER_CONTACT_ENTRY *) calloc (1, sizeof (DIALER_CONTACT_ENTRY));
+  nextentry->desc = (char *) calloc (1, 30);
+  strcpy (nextentry->desc, desc);
+  nextentry->desc[29] = '\0';
+  nextentry->content = (char *) calloc (1, 30);
+  strcpy (nextentry->content, content);
+  nextentry->content[29] = '\0';
+
+  nextentry->next = contact->entry;
+  contact->entry = nextentry;
+
+  return nextentry;
 }
 
 /**
@@ -256,76 +274,85 @@
 
 
 
-int contact_init_contact_list(DIALER_CONTACTS_LIST_HEAD * head)
+int
+contact_init_contact_list (DIALER_CONTACTS_LIST_HEAD * head)
 {
 
-	EBook *book;
-	gboolean status;
-	EBookQuery *query;
-	GList *c, *contacts;
-	DIALER_CONTACT* dialercontact;
+  EBook *book;
+  gboolean status;
+  EBookQuery *query;
+  GList *c, *contacts;
+  DIALER_CONTACT *dialercontact;
 
-	if(head==0)return 0;
+  if (head == 0)
+    return 0;
 
 
-	query=e_book_query_field_exists(E_CONTACT_FULL_NAME);
-	printf("query=%s\n",e_book_query_to_string(query));
-	
-	
-	book = e_book_new_system_addressbook (NULL);
-	if (!book) {
-		printf ("failed to create ebook\n");
-		return -1;
-	}
+  query = e_book_query_field_exists (E_CONTACT_FULL_NAME);
+  printf ("query=%s\n", e_book_query_to_string (query));
 
-	status = e_book_open (book, TRUE, NULL);
-	if (status == FALSE) {
-		printf ("failed to open addressbook\n");
-		return -1;
-	}
 
-	status = e_book_get_contacts (book, query, &contacts, NULL);
-	if (status == FALSE) {
-		printf ("failed to get contacts\n");
-		return -1;
-	}
-for (c = contacts; c; c = c->next)
- {
+  book = e_book_new_system_addressbook (NULL);
+  if (!book)
+  {
+    printf ("failed to create ebook\n");
+    return -1;
+  }
 
-     	EContact *contact = E_CONTACT (c->data);
-      dialercontact=0;
-//	  printf("id=%s\n",e_contact_get_const(contact,E_CONTACT_UID));
-	  gchar * name_or_org=e_contact_get_const(contact,E_CONTACT_NAME_OR_ORG);
-	  gchar * phone;
-	  if(name_or_org)
-		  {
+  status = e_book_open (book, TRUE, NULL);
+  if (status == FALSE)
+  {
+    printf ("failed to open addressbook\n");
+    return -1;
+  }
 
-		 dialercontact=contact_new_contact(name_or_org,e_contact_get_const(contact,E_CONTACT_UID));
-		  contact_add_contact_to_list(head,dialercontact);
+  status = e_book_get_contacts (book, query, &contacts, NULL);
+  if (status == FALSE)
+  {
+    printf ("failed to get contacts\n");
+    return -1;
+  }
+  for (c = contacts; c; c = c->next)
+  {
 
-		  printf("%s\n",name_or_org);
-//	    g_object_unref(name_or_org);
+    EContact *contact = E_CONTACT (c->data);
+    dialercontact = 0;
+//        printf("id=%s\n",e_contact_get_const(contact,E_CONTACT_UID));
+    gchar *name_or_org = e_contact_get_const (contact, E_CONTACT_NAME_OR_ORG);
+    gchar *phone;
+    if (name_or_org)
+    {
 
-		}
-	int i=0;
-	if(dialercontact)
-	{
-		for(i=E_CONTACT_FIRST_PHONE_ID;i<=E_CONTACT_LAST_PHONE_ID;i++)
-		{		phone = e_contact_get_const (contact, i);
-				if (phone) printf ("%s: %s\n",e_contact_field_name(i),phone);
-				contact_add_entry(dialercontact,e_contact_field_name(i),phone);
+      dialercontact =
+        contact_new_contact (name_or_org,
+                             e_contact_get_const (contact, E_CONTACT_UID));
+      contact_add_contact_to_list (head, dialercontact);
 
-		}
-	}
+      printf ("%s\n", name_or_org);
+//          g_object_unref(name_or_org);
 
-		g_object_unref (contact);
-}
+    }
+    int i = 0;
+    if (dialercontact)
+    {
+      for (i = E_CONTACT_FIRST_PHONE_ID; i <= E_CONTACT_LAST_PHONE_ID; i++)
+      {
+        phone = e_contact_get_const (contact, i);
+        if (phone)
+          printf ("%s: %s\n", e_contact_field_name (i), phone);
+        contact_add_entry (dialercontact, e_contact_field_name (i), phone);
 
-	g_list_free (contacts);
+      }
+    }
 
-	g_object_unref (book);
+    g_object_unref (contact);
+  }
 
-	return 0;
+  g_list_free (contacts);
+
+  g_object_unref (book);
+
+  return 0;
 }
 
 
@@ -340,41 +367,43 @@
  * @retval 
  */
 
-int contact_init_from_cmd(DIALER_CONTACTS_LIST_HEAD * head)
+int
+contact_init_from_cmd (DIALER_CONTACTS_LIST_HEAD * head)
 {
-	DIALER_CONTACT* contact;
-	if(head==0)return 0;
-	contact=contact_new_contact("Tony Guan","tony.png");
-	contact_add_entry(contact,"cell","13917209523");
-	contact_add_entry(contact,"work","02162495726");
-	contact_add_contact_to_list(head,contact);
-	
-	contact=contact_new_contact("Sally Xu","sally.png");
-	contact_add_entry(contact,"cell","13361900551");
-	contact_add_entry(contact,"work","02165538452");
-	contact_add_contact_to_list(head,contact);
-	
-	contact=contact_new_contact("Chaowei Song","chaowei.png");
-	contact_add_entry(contact,"work1","02162495727");
-	contact_add_entry(contact,"work4","02162495730");
-	contact_add_entry(contact,"work5","02162495731");
-	contact_add_contact_to_list(head,contact);
-	
-	contact=contact_new_contact("Ken Zhao","ken.png");
-	contact_add_entry(contact,"work2","02162495728");
-	contact_add_contact_to_list(head,contact);
-	
-	contact=contact_new_contact("Steven Chen","steven.png");
-	contact_add_entry(contact,"work3","02162495729");
-	contact_add_contact_to_list(head,contact);
-	
-	contact=contact_new_contact("10086","10086.png");
-	contact_add_entry(contact,"work","10086");
-	contact_add_contact_to_list(head,contact);
+  DIALER_CONTACT *contact;
+  if (head == 0)
+    return 0;
+  contact = contact_new_contact ("Tony Guan", "tony.png");
+  contact_add_entry (contact, "cell", "13917209523");
+  contact_add_entry (contact, "work", "02162495726");
+  contact_add_contact_to_list (head, contact);
 
-	return head->length;	
-	
-	
+  contact = contact_new_contact ("Sally Xu", "sally.png");
+  contact_add_entry (contact, "cell", "13361900551");
+  contact_add_entry (contact, "work", "02165538452");
+  contact_add_contact_to_list (head, contact);
+
+  contact = contact_new_contact ("Chaowei Song", "chaowei.png");
+  contact_add_entry (contact, "work1", "02162495727");
+  contact_add_entry (contact, "work4", "02162495730");
+  contact_add_entry (contact, "work5", "02162495731");
+  contact_add_contact_to_list (head, contact);
+
+  contact = contact_new_contact ("Ken Zhao", "ken.png");
+  contact_add_entry (contact, "work2", "02162495728");
+  contact_add_contact_to_list (head, contact);
+
+  contact = contact_new_contact ("Steven Chen", "steven.png");
+  contact_add_entry (contact, "work3", "02162495729");
+  contact_add_contact_to_list (head, contact);
+
+  contact = contact_new_contact ("10086", "10086.png");
+  contact_add_entry (contact, "work", "10086");
+  contact_add_contact_to_list (head, contact);
+
+  return head->length;
+
+
 }
 
 /**
@@ -390,42 +419,46 @@
  * @retval 
  */
 
-int contact_get_info_from_number(DIALER_CONTACT* contacts,char* name,char* picpath,const char* number)
+int
+contact_get_info_from_number (DIALER_CONTACT * contacts, char *name,
+                              char *picpath, const char *number)
 {
 
 
-	strcpy(name,"");
-	strcpy(picpath,MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);
-	if(number==0)return 0;
-	if(strlen(number)==0)return 0;
-	
+  strcpy (name, "");
+  strcpy (picpath, MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);
+  if (number == 0)
+    return 0;
+  if (strlen (number) == 0)
+    return 0;
+
 //  DIALER_CONTACT* contacts=g_contactlist.contacts;
 
-DIALER_CONTACT_ENTRY* entry;
- 
-   while(contacts!= 0)
-   {
-     entry=contacts->entry;
+  DIALER_CONTACT_ENTRY *entry;
 
-	 while(entry)
-	 {
-	
-	 //judge if the entry includes the string
-		 
-	 if(strcmp(entry->content,number)==0)
-	 {	
-	 strcpy(picpath,contacts->picpath);
-     strcpy(name,contacts->name);
-	// DBG_MESSAGE("Yeah, we know the owner is %s.",name);
-	 
-	 return 1;
-	 }
-     entry=entry->next;
-	 }
-    
-	 
-	 contacts= contacts->next;
-	
+  while (contacts != 0)
+  {
+    entry = contacts->entry;
+
+    while (entry)
+    {
+
+      //judge if the entry includes the string
+
+      if (strcmp (entry->content, number) == 0)
+      {
+        strcpy (picpath, contacts->picpath);
+        strcpy (name, contacts->name);
+        // DBG_MESSAGE("Yeah, we know the owner is %s.",name);
+
+        return 1;
+      }
+      entry = entry->next;
+    }
+
+
+    contacts = contacts->next;
+
   }
   //DBG_MESSAGE("Can not find the number.");
   return 0;
@@ -443,44 +476,48 @@
  * @retval 
  */
 
-int contact_get_peer_info_from_number(DIALER_CONTACT* contacts, DIALER_CONTACT_PEER_INFO * peer)
+int
+contact_get_peer_info_from_number (DIALER_CONTACT * contacts,
+                                   DIALER_CONTACT_PEER_INFO * peer)
 {
 
-	peer->hasname=0;
-	peer->searched=1;
-	peer->name=0;
-	peer->picpath=0;
+  peer->hasname = 0;
+  peer->searched = 1;
+  peer->name = 0;
+  peer->picpath = 0;
 
-	if(peer->number==0)return 0;
-	if(strlen(peer->number)==0)return 0;
-	
+  if (peer->number == 0)
+    return 0;
+  if (strlen (peer->number) == 0)
+    return 0;
+
 //  DIALER_CONTACT* contacts=g_contactlist.contacts;
 
-	DIALER_CONTACT_ENTRY* entry;
- 
-   while(contacts!= 0)
-   {
-     entry=contacts->entry;
+  DIALER_CONTACT_ENTRY *entry;
 
-	 while(entry)
-	 {
-	
-	 //judge if the entry includes the string
-		 
-	 if(strcmp(entry->content,peer->number)==0)
-	 {	
-	 peer->ID=contacts->ID;
-	 peer->name=contacts->name;
-	// DBG_MESSAGE("Yeah, we know the owner is %s.",name);
- 	peer->hasname=1;
-	 return 1;
-	 }
-     entry=entry->next;
-	 }
-    
-	 
-	 contacts= contacts->next;
-	
+  while (contacts != 0)
+  {
+    entry = contacts->entry;
+
+    while (entry)
+    {
+
+      //judge if the entry includes the string
+
+      if (strcmp (entry->content, peer->number) == 0)
+      {
+        peer->ID = contacts->ID;
+        peer->name = contacts->name;
+        // DBG_MESSAGE("Yeah, we know the owner is %s.",name);
+        peer->hasname = 1;
+        return 1;
+      }
+      entry = entry->next;
+    }
+
+
+    contacts = contacts->next;
+
   }
   //DBG_MESSAGE("Can not find the number.");
   return 0;
@@ -497,129 +534,136 @@
  * @return 0-no 1-yes
  */
 
-int contact_string_has_sensentive (char * content, char *string)
+int
+contact_string_has_sensentive (char *content, char *string)
 {
-	int i;
-//	g_printf("hassensentive:%s,%s\n",content,string);
-	if(content==0) 
-	return 0;
-	
-	if(string==0) 
-	return 1;
-	
-	if(strlen(string)==0)
-		return 1;
-	if(strlen(string)>strlen(content))
-		return 0;
-	for(i=0;string[i];i++)
-	{
-		if(content[i]==0)
-			return 1;
-		if(string[i]==content[i])
-			continue;
-		return 0;
-		
-	}
-	return 1;
+  int i;
+//      g_printf("hassensentive:%s,%s\n",content,string);
+  if (content == 0)
+    return 0;
+
+  if (string == 0)
+    return 1;
+
+  if (strlen (string) == 0)
+    return 1;
+  if (strlen (string) > strlen (content))
+    return 0;
+  for (i = 0; string[i]; i++)
+  {
+    if (content[i] == 0)
+      return 1;
+    if (string[i] == content[i])
+      continue;
+    return 0;
+
+  }
+  return 1;
 }
-int contact_print_contact_list(DIALER_CONTACTS_LIST_HEAD * head)
+
+int
+contact_print_contact_list (DIALER_CONTACTS_LIST_HEAD * head)
 {
-DIALER_CONTACT* contacts;
-DIALER_CONTACT_ENTRY* entry;
- contacts=head->contacts;
+  DIALER_CONTACT *contacts;
+  DIALER_CONTACT_ENTRY *entry;
+  contacts = head->contacts;
 
-DBG_MESSAGE("\n\nThere are %d contacts here:",head->length);
+  DBG_MESSAGE ("\n\nThere are %d contacts here:", head->length);
 
-   while(contacts!= 0)
-   {
-   DBG_MESSAGE("%s",contacts->name);
-     entry=contacts->entry;
+  while (contacts != 0)
+  {
+    DBG_MESSAGE ("%s", contacts->name);
+    entry = contacts->entry;
 
-	 while(entry)
-	 {
-	
-	 DBG_MESSAGE("--%s:%s",entry->desc,entry->content);
-        entry=entry->next;
-	 }
+    while (entry)
+    {
 
-      contacts= contacts->next;
+      DBG_MESSAGE ("--%s:%s", entry->desc, entry->content);
+      entry = entry->next;
+    }
+
+    contacts = contacts->next;
   }
   return 0;
 
 }
 
-int contact_load_contact_photo(GtkImage* image,const char* id)
+int
+contact_load_contact_photo (GtkImage * image, const char *id)
 {
 
-EBook *book;
-EContact * contact;
-GError *error = NULL;
-printf(">>>contact_load_contact_photo   id=%s\n",id);
-if(id==0||!strcmp(id,""))
-{//we load the default image for non-exist ID.
- gtk_image_set_from_stock(image,"gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR);
-return 0;
-}
+  EBook *book;
+  EContact *contact;
+  GError *error = NULL;
+  printf (">>>contact_load_contact_photo   id=%s\n", id);
+  if (id == 0 || !strcmp (id, ""))
+  {                             //we load the default image for non-exist ID.
+    gtk_image_set_from_stock (image, "gtk-yes", GTK_ICON_SIZE_LARGE_TOOLBAR);
+    return 0;
+  }
 
-book = e_book_new_system_addressbook (NULL);
-	if (!book) {
-		printf ("failed to create ebook\n");
-		  gtk_image_set_from_stock(image,"gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR);
-	return 0;
-	}
+  book = e_book_new_system_addressbook (NULL);
+  if (!book)
+  {
+    printf ("failed to create ebook\n");
+    gtk_image_set_from_stock (image, "gtk-yes", GTK_ICON_SIZE_LARGE_TOOLBAR);
+    return 0;
+  }
 
 
-if ( !e_book_open (book, TRUE, NULL)) {
-		printf ("failed to open addressbook\n");
-		  gtk_image_set_from_stock(image,"gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR);
-		return 0;
-	}
+  if (!e_book_open (book, TRUE, NULL))
+  {
+    printf ("failed to open addressbook\n");
+    gtk_image_set_from_stock (image, "gtk-yes", GTK_ICON_SIZE_LARGE_TOOLBAR);
+    return 0;
+  }
 
 
 //get the contact;
 
-if (!e_book_get_contact (book, id, &contact, &error)) {
-		printf ("error %d getting card: %s\n", error->code, error->message);
-		g_clear_error (&error);
-	  gtk_image_set_from_stock(image,"gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR);
-		return 0;
-	}
+  if (!e_book_get_contact (book, id, &contact, &error))
+  {
+    printf ("error %d getting card: %s\n", error->code, error->message);
+    g_clear_error (&error);
+    gtk_image_set_from_stock (image, "gtk-yes", GTK_ICON_SIZE_LARGE_TOOLBAR);
+    return 0;
+  }
 
 
-EContactPhoto *photo = e_contact_get (contact, E_CONTACT_PHOTO);
+  EContactPhoto *photo = e_contact_get (contact, E_CONTACT_PHOTO);
 
-GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
-GdkPixbuf *pixbuf;
+  GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
+  GdkPixbuf *pixbuf;
 
-			/* figure out if we need to downscale the
-			   image here.  we don't scale the pixbuf
-			   itself, just insert width/height tags in
-			   the html */
+  /* figure out if we need to downscale the
+     image here.  we don't scale the pixbuf
+     itself, just insert width/height tags in
+     the html */
 
-if(photo)
-gdk_pixbuf_loader_write (loader, photo->data.inlined.data, photo->data.inlined.length, NULL);
+  if (photo)
+    gdk_pixbuf_loader_write (loader, photo->data.inlined.data,
+                             photo->data.inlined.length, NULL);
 
-gdk_pixbuf_loader_close (loader, NULL);
+  gdk_pixbuf_loader_close (loader, NULL);
 
-pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
-if (pixbuf)
-	g_object_ref (pixbuf);
+  pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+  if (pixbuf)
+    g_object_ref (pixbuf);
 
 
-g_object_unref (loader);
+  g_object_unref (loader);
 
-if (pixbuf)
-{
-printf ("now we set the image from pixbuf\n");
-gtk_image_set_from_pixbuf(image,pixbuf);  
-g_object_unref (pixbuf);
-return 1;
-}
-else
-{
-  gtk_image_set_from_stock(image,"gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR);
-  return 0;
-}
+  if (pixbuf)
+  {
+    printf ("now we set the image from pixbuf\n");
+    gtk_image_set_from_pixbuf (image, pixbuf);
+    g_object_unref (pixbuf);
+    return 1;
+  }
+  else
+  {
+    gtk_image_set_from_stock (image, "gtk-yes", GTK_ICON_SIZE_LARGE_TOOLBAR);
+    return 0;
+  }
 
 }
-

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h	2007-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h	2007-02-05 09:34:59 UTC (rev 668)
@@ -21,8 +21,8 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
- 
- 
+
+
 #ifndef _CONTACTS_H
 #define _CONTACTS_H
 
@@ -38,79 +38,83 @@
 
 
 
-	
+
 /**
  * @brief phone number entry for the contact  structure in open dialer.
  */
-typedef struct dialer_contact_entry {
-  int ID;///<the unique ID for an contact entry
-  char *desc; ///<the description of this entry,such as homenumber
-  char *content; ///<the content of this entry, such as 62495726
-  struct dialer_contact_entry* next;
-}DIALER_CONTACT_ENTRY;
+  typedef struct dialer_contact_entry
+  {
+    int ID;                     ///<the unique ID for an contact entry
+    char *desc;                 ///<the description of this entry,such as homenumber
+    char *content;              ///<the content of this entry, such as 62495726
+    struct dialer_contact_entry *next;
+  } DIALER_CONTACT_ENTRY;
 
 
 /**
  * @brief contact  structure for open dialer.
  */
-typedef struct dialer_contact {
+  typedef struct dialer_contact
+  {
 //  int ID;///<the unique ID for an contact entry
-  char * ID;///<the unique ID for an contact entry
-  char *name;       	///<person name
-  char *picpath;  ///<the picture file path for the person
-  DIALER_CONTACT_ENTRY * entry;                    ///<first number entry for the person
-  
-  struct dialer_contact* next;         ///<pointer to next contact
-}DIALER_CONTACT;
+    char *ID;                   ///<the unique ID for an contact entry
+    char *name;                 ///<person name
+    char *picpath;              ///<the picture file path for the person
+    DIALER_CONTACT_ENTRY *entry;        ///<first number entry for the person
 
+    struct dialer_contact *next;        ///<pointer to next contact
+  } DIALER_CONTACT;
 
+
 /**
  * @brief contact  structure for open dialer.
  */
-typedef struct peer_info_
-{
+  typedef struct peer_info_
+  {
 //we should at least have the number called.
-  char number[MOKO_DIALER_MAX_NUMBER_LEN+1];        ///<the number of the peer
-  char *name;       	///<person name
-  char *ID;       	///<the id in the addressbook, we count on it to load photo
-  char *picpath;  ///<the picture file path for the person
-  int searched; ///<if true; no need to search for the name 
-  int hasname; ///<if true, we the picpath & name can be used.
-}DIALER_CONTACT_PEER_INFO;
+    char number[MOKO_DIALER_MAX_NUMBER_LEN + 1];        ///<the number of the peer
+    char *name;                 ///<person name
+    char *ID;                   ///<the id in the addressbook, we count on it to load photo
+    char *picpath;              ///<the picture file path for the person
+    int searched;               ///<if true; no need to search for the name 
+    int hasname;                ///<if true, we the picpath & name can be used.
+  } DIALER_CONTACT_PEER_INFO;
 
 
 /**
  * @brief the structure for intelligent search results.
- */	
-typedef struct dialer_ready_contact
-{
-	DIALER_CONTACT_ENTRY* p_entry;
-	DIALER_CONTACT* p_contact;
-}DIALER_READY_CONTACT;
+ */
+  typedef struct dialer_ready_contact
+  {
+    DIALER_CONTACT_ENTRY *p_entry;
+    DIALER_CONTACT *p_contact;
+  } DIALER_READY_CONTACT;
 
 /**
  * @brief contacts list head structure.
  */
-typedef struct dialer_contacts_list_head {
-  int length;                   ///<the number of contacts
-  DIALER_CONTACT *contacts;        ///<package list head pointer
-}DIALER_CONTACTS_LIST_HEAD;
+  typedef struct dialer_contacts_list_head
+  {
+    int length;                 ///<the number of contacts
+    DIALER_CONTACT *contacts;   ///<package list head pointer
+  } DIALER_CONTACTS_LIST_HEAD;
 
-int contact_load_contact_photo(GtkImage* image,const char* id);
-int contact_init_contact_list(DIALER_CONTACTS_LIST_HEAD * head);
-int contact_release_contact_entry(DIALER_CONTACT_ENTRY* contactentry);
-int contact_release_contact(DIALER_CONTACT *contact);
-int contact_release_contact_list(DIALER_CONTACTS_LIST_HEAD * head);
-int contact_init_from_cmd(DIALER_CONTACTS_LIST_HEAD * head);
-int contact_get_info_from_number(DIALER_CONTACT* contacts,char* name,char* picpath,const char* number);
-int contact_get_peer_info_from_number(DIALER_CONTACT* contacts, DIALER_CONTACT_PEER_INFO * peer);
-int contact_init_contact_data(DIALER_CONTACTS_LIST_HEAD   *p_contactlist);
-int contact_print_contact_list(DIALER_CONTACTS_LIST_HEAD * head);
-int contact_string_has_sensentive (char * content, char *string);
+  int contact_load_contact_photo (GtkImage * image, const char *id);
+  int contact_init_contact_list (DIALER_CONTACTS_LIST_HEAD * head);
+  int contact_release_contact_entry (DIALER_CONTACT_ENTRY * contactentry);
+  int contact_release_contact (DIALER_CONTACT * contact);
+  int contact_release_contact_list (DIALER_CONTACTS_LIST_HEAD * head);
+  int contact_init_from_cmd (DIALER_CONTACTS_LIST_HEAD * head);
+  int contact_get_info_from_number (DIALER_CONTACT * contacts, char *name,
+                                    char *picpath, const char *number);
+  int contact_get_peer_info_from_number (DIALER_CONTACT * contacts,
+                                         DIALER_CONTACT_PEER_INFO * peer);
+  int contact_init_contact_data (DIALER_CONTACTS_LIST_HEAD * p_contactlist);
+  int contact_print_contact_list (DIALER_CONTACTS_LIST_HEAD * head);
+  int contact_string_has_sensentive (char *content, char *string);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* _CONTACTS_H */
-
+#endif                          /* _CONTACTS_H */

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c	2007-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c	2007-02-05 09:34:59 UTC (rev 668)
@@ -210,6 +210,7 @@
 
   return FALSE;
 }
+
 static gboolean
 gsm_watcher_check (GSource * source)
 {

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c	2007-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c	2007-02-05 09:34:59 UTC (rev 668)
@@ -21,9 +21,9 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
- 
-#include "history.h" 
-#include "error.h" 
+
+#include "history.h"
+#include "error.h"
 #include <stdlib.h>
 /**
  * @brief initialze the contact list by calling the external APIs.
@@ -34,9 +34,10 @@
  * @return the number of the contacts. 
  * @retval
  */
-int history_read_list(HISTORY_LIST_HEAD* historyhead)
+int
+history_read_list (HISTORY_LIST_HEAD * historyhead)
 {
-	return 0;
+  return 0;
 }
 
 
@@ -50,37 +51,39 @@
  * @retval 0 failed 
  * @retval other success
  */
-int history_read_list_cmd(HISTORY_LIST_HEAD* historyhead)
+int
+history_read_list_cmd (HISTORY_LIST_HEAD * historyhead)
 {
-	
-historyhead->length=0;
-historyhead->first=0;
-historyhead->last=0;
-	history_add_entry(historyhead,MISSED,"","1391721112",
-	"","17:58","12/20",100);
 
-	history_add_entry(historyhead,INCOMING,"tony","13917309523",
-	"./tony.png","13:58","12/20",10);
-history_add_entry(historyhead,OUTGOING,"sally","13361900551",
-	"./sally.png","10:58","12/20",106);
-history_add_entry(historyhead,MISSED,"chaowei","1391110923",
-	"./chaowei.png","11:58","12/20",120);
-	history_add_entry(historyhead,OUTGOING,"","1395721111",
-	"","17:58","12/20",100);
+  historyhead->length = 0;
+  historyhead->first = 0;
+  historyhead->last = 0;
+  history_add_entry (historyhead, MISSED, "", "1391721112",
+                     "", "17:58", "12/20", 100);
 
-	history_add_entry(historyhead,INCOMING,"steven","1391721111",
-	"./steven.png","17:58","12/20",100);
-history_add_entry(historyhead,INCOMING,"ken","1381720923",
-	"./ken.png","18:58","12/20",200);
-	history_add_entry(historyhead,MISSED,"","1391721113",
-	"","17:58","12/20",100);
-	history_add_entry(historyhead,MISSED,"","1394721111",
-	"","17:58","12/20",100);
-	history_add_entry(historyhead,MISSED,"","1396721111",
-	"","17:58","12/20",100);
-return historyhead->length;
+  history_add_entry (historyhead, INCOMING, "tony", "13917309523",
+                     "./tony.png", "13:58", "12/20", 10);
+  history_add_entry (historyhead, OUTGOING, "sally", "13361900551",
+                     "./sally.png", "10:58", "12/20", 106);
+  history_add_entry (historyhead, MISSED, "chaowei", "1391110923",
+                     "./chaowei.png", "11:58", "12/20", 120);
+  history_add_entry (historyhead, OUTGOING, "", "1395721111",
+                     "", "17:58", "12/20", 100);
 
+  history_add_entry (historyhead, INCOMING, "steven", "1391721111",
+                     "./steven.png", "17:58", "12/20", 100);
+  history_add_entry (historyhead, INCOMING, "ken", "1381720923",
+                     "./ken.png", "18:58", "12/20", 200);
+  history_add_entry (historyhead, MISSED, "", "1391721113",
+                     "", "17:58", "12/20", 100);
+  history_add_entry (historyhead, MISSED, "", "1394721111",
+                     "", "17:58", "12/20", 100);
+  history_add_entry (historyhead, MISSED, "", "1396721111",
+                     "", "17:58", "12/20", 100);
+  return historyhead->length;
+
 }
+
 /* 
 typedef struct historyentry
 {
@@ -106,37 +109,41 @@
  * @retval 0 failed
  * @retval 1 success
  */
-int history_delete_entry(HISTORY_LIST_HEAD* historyhead,HISTORY_ENTRY* entry)
+int
+history_delete_entry (HISTORY_LIST_HEAD * historyhead, HISTORY_ENTRY * entry)
 {
-	DBG_ENTER();
-	if(entry==0)return 0;
-	if(entry->number==0)return 0;
-	if(entry->prev==0&&entry->next==0)return 0;
-		
-	DBG_MESSAGE("deleting %s",entry->number);
-	
-	if(entry->prev)
-	{
-		entry->prev->next=entry->next;
-	}
-	else
-	{//entry is the first one.
-		historyhead->first=entry->next;
-	}
-	
-	if(entry->next)
-	{
-		entry->next->prev=entry->prev;
-	}
-	else
-	{
-		historyhead->last=entry->prev;
-	}
+  DBG_ENTER ();
+  if (entry == 0)
+    return 0;
+  if (entry->number == 0)
+    return 0;
+  if (entry->prev == 0 && entry->next == 0)
+    return 0;
 
-	history_release_entry(entry);
+  DBG_MESSAGE ("deleting %s", entry->number);
 
-	historyhead->length--;
-	return historyhead->length;
+  if (entry->prev)
+  {
+    entry->prev->next = entry->next;
+  }
+  else
+  {                             //entry is the first one.
+    historyhead->first = entry->next;
+  }
+
+  if (entry->next)
+  {
+    entry->next->prev = entry->prev;
+  }
+  else
+  {
+    historyhead->last = entry->prev;
+  }
+
+  history_release_entry (entry);
+
+  historyhead->length--;
+  return historyhead->length;
 }
 
 
@@ -155,110 +162,116 @@
  * @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 *id,  char *time,char *date,int durationsec)
+HISTORY_ENTRY *
+history_add_entry (HISTORY_LIST_HEAD * historyhead, HISTORY_TYPE type,
+                   const char *name, const char *number, const char *id,
+                   char *time, char *date, int durationsec)
 {
 
-	DBG_ENTER();
-	HISTORY_ENTRY * pentry=(HISTORY_ENTRY *)calloc(1,sizeof(HISTORY_ENTRY ));
+  DBG_ENTER ();
+  HISTORY_ENTRY *pentry =
+    (HISTORY_ENTRY *) calloc (1, sizeof (HISTORY_ENTRY));
 
-//	DBG_MESSAGE("pentry add:0X%x",pentry);
-	
-	if(name&&strlen(name)>0)
-	{	pentry->name=(char*)calloc(1,strlen(name)+1);
-		strcpy(pentry->name,name);
-		pentry->hasname=1;
-	}
-	else
-		{
-		pentry->name=0;
-		pentry->hasname=0;
-		}
+//      DBG_MESSAGE("pentry add:0X%x",pentry);
 
-	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;
-		}
+  if (name && strlen (name) > 0)
+  {
+    pentry->name = (char *) calloc (1, strlen (name) + 1);
+    strcpy (pentry->name, name);
+    pentry->hasname = 1;
+  }
+  else
+  {
+    pentry->name = 0;
+    pentry->hasname = 0;
+  }
 
-	//DBG_MESSAGE("History add:0X%x,%s,%s,%s,%s,%s,%d",historyhead,name,number,picpath,time,date,durationsec);
-	
-	if(id&&strlen(id)>0)
-	{
-		pentry->ID=(char*)calloc(1,strlen(id)+1);
-		strcpy(pentry->ID,id);
-	}
-		if(time&&strlen(time)>0)
-	{
-		pentry->time=(char*)calloc(1,strlen(time)+1);
-		strcpy(pentry->time,time);
-	}
-		pentry->durationsec=durationsec;
-	
-	pentry->type=type;
-	historyhead->length++;
-	
-	
-	if(historyhead->first)
-	{	//DBG_TRACE();
-		//DBG_MESSAGE("first=0x%x",historyhead->first);
-		//DBG_MESSAGE("first=%s",historyhead->first->number);
-		historyhead->first->prev=pentry;
-		//DBG_TRACE();
-		pentry->next=historyhead->first;
-		//DBG_TRACE();
-		historyhead->first=pentry;
-		//DBG_TRACE();
-	}
-	else
-	{//DBG_TRACE();
-		historyhead->first=pentry;
-		historyhead->last=pentry;
-	}
-//	DBG_LEAVE();
-	return pentry;
+  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,%s,%d",historyhead,name,number,picpath,time,date,durationsec);
+
+  if (id && strlen (id) > 0)
+  {
+    pentry->ID = (char *) calloc (1, strlen (id) + 1);
+    strcpy (pentry->ID, id);
+  }
+  if (time && strlen (time) > 0)
+  {
+    pentry->time = (char *) calloc (1, strlen (time) + 1);
+    strcpy (pentry->time, time);
+  }
+  pentry->durationsec = durationsec;
+
+  pentry->type = type;
+  historyhead->length++;
+
+
+  if (historyhead->first)
+  {                             //DBG_TRACE();
+    //DBG_MESSAGE("first=0x%x",historyhead->first);
+    //DBG_MESSAGE("first=%s",historyhead->first->number);
+    historyhead->first->prev = pentry;
+    //DBG_TRACE();
+    pentry->next = historyhead->first;
+    //DBG_TRACE();
+    historyhead->first = pentry;
+    //DBG_TRACE();
+  }
+  else
+  {                             //DBG_TRACE();
+    historyhead->first = pentry;
+    historyhead->last = pentry;
+  }
+//      DBG_LEAVE();
+  return pentry;
 }
 
-int history_release_entry(HISTORY_ENTRY * 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->ID)
-{
-free(pentry->ID);
-pentry->ID=0;
-}
-if(pentry->time)
-{
-free(pentry->time);
-pentry->time=0;
-}
-if(pentry->date)
-{
-free(pentry->date);
-pentry->date=0;
-}
+  if (!pentry)
+    return 1;
+  if (pentry->name)
+  {
+    free (pentry->name);
+    pentry->name = 0;
+  }
+  if (pentry->number)
+  {
+    free (pentry->number);
+    pentry->number = 0;
+  }
+  if (pentry->ID)
+  {
+    free (pentry->ID);
+    pentry->ID = 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;
+  pentry->prev = 0;
+  pentry->next = 0;
+  free (pentry);
+  pentry = 0;
+  return 1;
 
 }
 
@@ -272,35 +285,36 @@
  * @retval 0 failed 
  * @retval 1 success
  */
-int history_release_history_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;
+  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)
+int
+history_init_history_data (HISTORY_LIST_HEAD * historyhead)
 {
 
- DBG_ENTER();
-  int res = history_read_list(historyhead);
+  DBG_ENTER ();
+  int res = history_read_list (historyhead);
 
-  if(res == 0)
+  if (res == 0)
   {
     res = history_read_list_cmd (historyhead);
   }
-  DBG_MESSAGE("History:%d",historyhead->length);
-  DBG_LEAVE();
+  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-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.h	2007-02-05 09:34:59 UTC (rev 668)
@@ -21,7 +21,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
- 
+
 #ifndef _HISTORY_H
 #define _HISTORY_H
 
@@ -30,50 +30,51 @@
 
 
 extern "C"
-
 {
 #endif
 
-	
 
+
 /**
  * @brief enum of history type
  */
-	
-typedef enum _historytype{
-	INCOMING=0, ///<incoming calls
-	OUTGOING,///<outgoing calls
-	MISSED,///<missed calls 
-	ALL ///<all the types including the above
-}HISTORY_TYPE;
 
+  typedef enum _historytype
+  {
+    INCOMING = 0,               ///<incoming calls
+    OUTGOING,                   ///<outgoing calls
+    MISSED,                     ///<missed calls 
+    ALL                         ///<all the types including the above
+  } HISTORY_TYPE;
+
 /**
  * @brief history entry item structure
  */
-typedef struct historyentry
-{
-  int ID;///<the unique ID for an contact entry 
-  HISTORY_TYPE type;
-  char *name;       	///<person name
-  char *number;       	///<person number
+  typedef struct historyentry
+  {
+    int ID;                     ///<the unique ID for an contact entry 
+    HISTORY_TYPE type;
+    char *name;                 ///<person name
+    char *number;               ///<person number
 //  char *id;  ///<the id
-  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;
+    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;
 
 
 /**
  * @brief contacts list head structure.
  */
-typedef struct history_list_head {
-  int length;                   ///<the number of history
-  HISTORY_ENTRY *first;        ///<list head pointer
-  HISTORY_ENTRY *last;        ///<list head pointer
-}HISTORY_LIST_HEAD;
+  typedef struct history_list_head
+  {
+    int length;                 ///<the number of history
+    HISTORY_ENTRY *first;       ///<list head pointer
+    HISTORY_ENTRY *last;        ///<list head pointer
+  } HISTORY_LIST_HEAD;
 /**
  * @brief read the history list using the external APIs,currently only return 0
  * 
@@ -83,7 +84,7 @@
  * @retval 0 failed 
  * @retval other success
  */
-int history_read_list(HISTORY_LIST_HEAD* historyhead);
+  int history_read_list (HISTORY_LIST_HEAD * historyhead);
 
 /**
  * @brief read the history list using internal data,just for debug use
@@ -95,7 +96,7 @@
  * @retval 0 failed 
  * @retval other success
  */
-int history_read_list_cmd(HISTORY_LIST_HEAD* historyhead);
+  int history_read_list_cmd (HISTORY_LIST_HEAD * historyhead);
 
 /**
  * @brief release the momory by the list and it's entry
@@ -107,7 +108,7 @@
  * @retval 0 failed 
  * @retval 1 success
  */
-int history_release_history_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.
@@ -122,7 +123,10 @@
  * @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,char *date,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 
  * 
@@ -134,11 +138,12 @@
  * @retval 0 failed
  * @retval 1 success
  */
-int history_delete_entry(HISTORY_LIST_HEAD* historyhead,HISTORY_ENTRY* entry);
+  int history_delete_entry (HISTORY_LIST_HEAD * historyhead,
+                            HISTORY_ENTRY * entry);
 
-int history_init_history_data(HISTORY_LIST_HEAD* historyhead);
+  int history_init_history_data (HISTORY_LIST_HEAD * historyhead);
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* _HISTORY_H */
+#endif                          /* _HISTORY_H */

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-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.c	2007-02-05 09:34:59 UTC (rev 668)
@@ -1,416 +1,446 @@
-/* moko-dialer-autolist .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 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-autolist.h"
-  #include "error.h"
-#include "common.h" 
-G_DEFINE_TYPE (MokoDialerAutolist, moko_dialer_autolist, GTK_TYPE_HBOX)
-
-enum {
-  SELECTED_SIGNAL,
-  CONFIRMED_SIGNAL,
-  NOMATCH_SIGNAL,
-  LAST_SIGNAL
-};
-
-//forward definition
-
-gboolean on_tip_press_event (MokoDialerTip       *tip,GdkEventButton  *event,gpointer        user_data);
-
-static gint moko_dialer_autolist_signals[LAST_SIGNAL] = { 0 };
-
-static void
-moko_dialer_autolist_class_init (MokoDialerAutolistClass *class)
-{
-/*
-  GtkVBoxClass* vbox_class;
-
-  vbox_class= (GtkVBoxClass*) class;
-*/
-
-  GtkObjectClass *object_class;
-
-  object_class = (GtkObjectClass*) class;
-
- g_print("moko_dialer_autolist:start signal register\n");
-  
-  moko_dialer_autolist_signals[SELECTED_SIGNAL] = 
-  		g_signal_new ("user_selected",
-               G_OBJECT_CLASS_TYPE (object_class),
-		G_SIGNAL_RUN_FIRST,
-		 G_STRUCT_OFFSET (MokoDialerAutolistClass, moko_dialer_autolist_selected),
-               NULL,NULL,
-               g_cclosure_marshal_VOID__POINTER,
-		G_TYPE_NONE, 1,g_type_from_name("gpointer"));
-
-
-
-
-
-  moko_dialer_autolist_signals[CONFIRMED_SIGNAL] = 
-  		g_signal_new ("user_confirmed",
-               G_OBJECT_CLASS_TYPE (object_class),
-		G_SIGNAL_RUN_FIRST,
-		 G_STRUCT_OFFSET (MokoDialerAutolistClass, moko_dialer_autolist_confirmed),
-               NULL,NULL,
-               g_cclosure_marshal_VOID__POINTER,
-		G_TYPE_NONE, 1,g_type_from_name("gpointer"));
-
-//moko_dialer_autolist_nomatch
-  moko_dialer_autolist_signals[NOMATCH_SIGNAL] = 
-  		g_signal_new ("autolist_nomatch",
-               G_OBJECT_CLASS_TYPE (object_class),
-		G_SIGNAL_RUN_FIRST,
-		 G_STRUCT_OFFSET (MokoDialerAutolistClass, moko_dialer_autolist_nomatch),
-               NULL,NULL,
-               g_cclosure_marshal_VOID__VOID,
-		G_TYPE_NONE, 0);
-
-
-
-}
-
-
-static void
-moko_dialer_autolist_init (MokoDialerAutolist *moko_dialer_autolist)
-{
-//DBG_ENTER();
-int i;
-for(i=0;i<MOKO_DIALER_MAX_TIPS;i++)
-	moko_dialer_autolist->tips[i]=0;
-moko_dialer_autolist->  tipscreated=FALSE;  
-moko_dialer_autolist->head=0;
-moko_dialer_autolist->g_alternatecount=0;
-moko_dialer_autolist->imagePerson=0;
-gtk_widget_set_size_request (GTK_WIDGET(moko_dialer_autolist), 480, 40); 
-
-}
-/**
- * @brief please call this function first before the autolist start to work.
-*/
-gboolean moko_dialer_autolist_set_data (MokoDialerAutolist *moko_dialer_autolist,DIALER_CONTACTS_LIST_HEAD* head)
-{
-/*
-if(moko_dialer_autolist->head)
-	contact_release_contact_list(moko_dialer_autolist->head);
-	*/
-	
-moko_dialer_autolist->head=head;
-
-//contact_print_contact_list(moko_dialer_autolist->head);
-
-return TRUE;
-}
-
-gint moko_dialer_autolist_hide_all_tips(MokoDialerAutolist *moko_dialer_autolist)
-{
-
-if(moko_dialer_autolist->tipscreated)
-{
-		moko_dialer_autolist->selected=FALSE;
-			//no alternative, hide all 3 labels.
-			gint i;
-		for(i=0;i<MOKO_DIALER_MAX_TIPS;i++)
-		{
-		moko_dialer_tip_set_selected(moko_dialer_autolist->tips[i],FALSE);
-		gtk_widget_hide(moko_dialer_autolist->tips[i]);
-		}
-		//hide the imagePerson
-		gtk_widget_hide(moko_dialer_autolist->imagePerson);
-}
-		return 1;
-
-}
-
-/**
- * @brief initiate the font for widget of textviewCodes 
- *
- *
- *
- * @param text_view GtkWidget*, any widget which can help to lookup for labelcontactN
- * @param count gint, the count of the alternative, max set to MAXDISPNAMENUM.
- * @param selectdefault if selectdefault, then we will automatically emit the message to fill the sensed string,
- *  else, we only refresh our tip list.
- * @retval 
- */
-
-int moko_dialer_autolist_fill_alternative(MokoDialerAutolist *moko_dialer_autolist,gint count,gboolean selectdefault)
-{
-gint i;
-//DBG_ENTER();
-moko_dialer_autolist->selected=FALSE;
-
-moko_dialer_autolist->g_alternatecount=count;
-
-if(count>0)
-{
-	//init the labels.
-	for(i=0;i<count&&i<MOKO_DIALER_MAX_TIPS;i++)
-	{
-	moko_dialer_tip_set_label(moko_dialer_autolist->tips[i],moko_dialer_autolist->readycontacts[i].p_contact->name);
-	moko_dialer_tip_set_index(moko_dialer_autolist->tips[i],i);
-	moko_dialer_tip_set_selected(moko_dialer_autolist->tips[i],FALSE);
-	gtk_widget_show(moko_dialer_autolist->tips[i]);
-	}
-
-	for(;i<MOKO_DIALER_MAX_TIPS;i++)
-	{
-	moko_dialer_tip_set_index(moko_dialer_autolist->tips[i],-1);
-	moko_dialer_tip_set_label(moko_dialer_autolist->tips[i],"");
-	gtk_widget_hide(moko_dialer_autolist->tips[i]);
-	moko_dialer_tip_set_selected(moko_dialer_autolist->tips[i],FALSE);
-	}
-
-	if(selectdefault)
-	{
-		//we set the first one as defaultly selected
-		moko_dialer_autolist_set_select(moko_dialer_autolist, 0);
-	}
-}	
-else
-	{
-	moko_dialer_autolist_hide_all_tips(moko_dialer_autolist);	
-		//notify the client that no match has been foudn
-//		autolist_nomatch
-   g_signal_emit (moko_dialer_autolist,   moko_dialer_autolist_signals[NOMATCH_SIGNAL],0,0);
-	}
-	return 1;
-}
-
-//if selectdefault, then we will automatically emit the message to fill the sensed string
-//else, we only refresh our tip list.
-gint  moko_dialer_autolist_refresh_by_string (MokoDialerAutolist *moko_dialer_autolist,gchar * string,gboolean selectdefault)
-{
-//first, we fill the ready list
-
-  DIALER_CONTACT* contacts;//=moko_dialer_autolist->head->contacts;
-
-  DIALER_CONTACT_ENTRY* entry;
-
-  gint inserted=0;
-
-  
-  gint len;
-  
-  if(string)
-	  len=strlen(string);
-  else
-	  len=0;
-//  DBG_TRACE();
-  
-//insert the tips here to avoid the _show_all show it from the start.
-  GtkWidget * imagePerson;
-  GtkWidget * tip;
-
-if(!moko_dialer_autolist->tipscreated)
-{
-  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);
-  	}
-  else
-  	{
-  	imagePerson=gtk_image_new_from_stock("gtk-yes",GTK_ICON_SIZE_DND);
-  	}
- gtk_widget_hide (imagePerson);
- gtk_widget_set_size_request (imagePerson, 40, 40);	
-//  gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, TRUE, TRUE, 0);
-//gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, TRUE, FALSE, 0);
- gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, FALSE, FALSE, 0);
-  
-  moko_dialer_autolist->imagePerson=imagePerson;
-			gint i;
-  for(i=0;i<MOKO_DIALER_MAX_TIPS;i++)
-  	{
-  	tip=moko_dialer_tip_new();
-  	
-  	moko_dialer_tip_set_index(tip, i);
-  	
-  	moko_dialer_tip_set_label(tip,"tony guan");
-
-	moko_dialer_tip_set_selected(tip,FALSE);
-
-	 gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, TRUE, TRUE, 0);  	
-//	 gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, FALSE,FALSE, 0);  		
-//	 gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, FALSE,TRUE, 0);
-//			 gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, TRUE, FALSE,0);
-	
-	  g_signal_connect ((gpointer) tip, "button_press_event",G_CALLBACK (on_tip_press_event),moko_dialer_autolist);
-
-//	gtk_widget_set_size_request (tip, 20, 20);	
-
-	gtk_widget_hide(tip);
-
-  	moko_dialer_autolist-> tips[i]=tip;
-  	}
-	moko_dialer_autolist->  tipscreated=TRUE;
-}
-
- contacts=moko_dialer_autolist->head->contacts;
-
-//  DBG_MESSAGE("CONTACTS:%d,list at 0x%x,first at 0x%x",moko_dialer_autolist->head->length,moko_dialer_autolist->head,moko_dialer_autolist->head->contacts);
-
-//	  DBG_TRACE();  
-   while(contacts!= NULL&&inserted<MOKO_DIALER_MAX_TIPS)
-   {
-	//  DBG_TRACE();
-      entry=contacts->entry;
-	//  DBG_TRACE();
-	 while(entry!=NULL&&inserted<MOKO_DIALER_MAX_TIPS)
-	 {
-//	 DBG_TRACE();
-	 //judge if the entry includes the string
-	 if(contact_string_has_sensentive(entry->content,string))
-	 {	
-		//if the person not inserted, then insert first
-	moko_dialer_autolist->readycontacts[inserted].p_contact=contacts;
-	moko_dialer_autolist->readycontacts[inserted].p_entry=entry;
-       inserted++;
-		 //break;
-	 }
- 	    entry=entry->next;
-	 }
-	 
-	 contacts= contacts->next;
-	
-  }
-
-//DBG_MESSAGE("inserted=%d",inserted);
-moko_dialer_autolist_fill_alternative(moko_dialer_autolist,inserted,selectdefault);
-
-//DBG_LEAVE();
-  return inserted;
-}
-
-gboolean on_tip_press_event (MokoDialerTip       *tip,GdkEventButton  *event,gpointer         user_data)
-{
-
-//DBG_ENTER();
-MokoDialerAutolist *moko_dialer_autolist;
-moko_dialer_autolist=(MokoDialerAutolist *)user_data;
-
-gint selected=moko_dialer_tip_get_index(tip);
-
-
-if(selected!=-1&&selected<MOKO_DIALER_MAX_TIPS&&moko_dialer_autolist->g_alternatecount)
-{
-
-		return  moko_dialer_autolist_set_select(moko_dialer_autolist,selected);
-
-}
-else
-{
-//we notify the client that no match found!
-DBG_WARN("the selected index is out of range!");
-return FALSE;
-}
-
-
-}
-
-gboolean moko_dialer_autolist_has_selected(MokoDialerAutolist *moko_dialer_autolist)
-{
-	return moko_dialer_autolist->selected;
-}
-
-// selected ==-1 means there are no selected tips
-gboolean moko_dialer_autolist_set_select(MokoDialerAutolist *moko_dialer_autolist,gint selected)
-{
-gint i;
-		if(selected==-1)
-		{
-
-			//set the selected status to be false
-			for( i=0;i<moko_dialer_autolist->g_alternatecount;i++)
-			{
-			moko_dialer_tip_set_selected( moko_dialer_autolist->tips[i], FALSE);
-			}
-			//set
-			gtk_widget_hide(moko_dialer_autolist->imagePerson);	
-			moko_dialer_autolist->selected=FALSE;
-			return TRUE;
-		}
-
-
-if(selected<MOKO_DIALER_MAX_TIPS&&moko_dialer_autolist->g_alternatecount)
-	{
-	//first of all, determin if this tip is already selected previously.
-	if(moko_dialer_tip_is_selected(moko_dialer_autolist->tips[selected]))
-	{
-
-		//hide the others;
-		for( i=0;i<moko_dialer_autolist->g_alternatecount;i++)
-		{
-			if(i!=selected)
-			{//hide the others
-			gtk_widget_hide( moko_dialer_autolist->tips[i]);
-			}
-		}
-	moko_dialer_autolist->selected=FALSE;
-	//emit confirm message;
-//		DBG_MESSAGE("we confirm %s is right.",moko_dialer_autolist->readycontacts[selected].p_contact->name);			
-	g_signal_emit (moko_dialer_autolist,   moko_dialer_autolist_signals[CONFIRMED_SIGNAL],0,&(moko_dialer_autolist->readycontacts[selected]));
-
-	}
-	else
-	{
-
-	//refresh the imagePerson widget
-//	file_load_person_image_from_relative_path(moko_dialer_autolist->imagePerson,moko_dialer_autolist->readycontacts[selected].p_contact->picpath);
-//	file_load_person_image_scalable_from_relative_path(moko_dialer_autolist->imagePerson,moko_dialer_autolist->readycontacts[selected].p_contact->picpath);
-	contact_load_contact_photo(moko_dialer_autolist->imagePerson,moko_dialer_autolist->readycontacts[selected].p_contact->ID);
-		gtk_widget_show(moko_dialer_autolist->imagePerson);	
-	//just change the selected attribute of the tips
-		for( i=0;i<moko_dialer_autolist->g_alternatecount;i++)
-		{
-			if(i!=selected)
-			{//set selected to false;
-			moko_dialer_tip_set_selected( moko_dialer_autolist->tips[i], FALSE);
-			}
-			else
-			moko_dialer_tip_set_selected( moko_dialer_autolist->tips[i], TRUE);
-		}
-	moko_dialer_autolist->selected=TRUE;
-		//emit selected message
-//		DBG_MESSAGE(" %s is selectd.",moko_dialer_autolist->readycontacts[selected].p_contact->name);
-		g_signal_emit (moko_dialer_autolist,   moko_dialer_autolist_signals[SELECTED_SIGNAL],0,&(moko_dialer_autolist->readycontacts[selected]));	
-	}
-		return TRUE;
-	}
-else
-	{
-	DBG_WARN("the selected index is out of range!");
-	return FALSE;
-	}
-		
-}
-
-GtkWidget*      moko_dialer_autolist_new()
-{
-DBG_ENTER();
-
-MokoDialerAutolist * dp;
-
-dp=(MokoDialerAutolist * )g_object_new (MOKO_TYPE_DIALER_AUTOLIST, NULL);
-return GTK_WIDGET(dp);
-
-}
-
- 
-
+/* moko-dialer-autolist .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 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-autolist.h"
+#include "error.h"
+#include "common.h"
+G_DEFINE_TYPE (MokoDialerAutolist, moko_dialer_autolist, GTK_TYPE_HBOX)
+     enum
+     {
+       SELECTED_SIGNAL,
+       CONFIRMED_SIGNAL,
+       NOMATCH_SIGNAL,
+       LAST_SIGNAL
+     };
+
+//forward definition
+
+     gboolean on_tip_press_event (MokoDialerTip * tip, GdkEventButton * event,
+                                  gpointer user_data);
+
+     static gint moko_dialer_autolist_signals[LAST_SIGNAL] = { 0 };
+
+static void
+moko_dialer_autolist_class_init (MokoDialerAutolistClass * class)
+{
+/*
+  GtkVBoxClass* vbox_class;
+
+  vbox_class= (GtkVBoxClass*) class;
+*/
+
+  GtkObjectClass *object_class;
+
+  object_class = (GtkObjectClass *) class;
+
+  g_print ("moko_dialer_autolist:start signal register\n");
+
+  moko_dialer_autolist_signals[SELECTED_SIGNAL] =
+    g_signal_new ("user_selected",
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (MokoDialerAutolistClass,
+                                   moko_dialer_autolist_selected), NULL, NULL,
+                  g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+                  g_type_from_name ("gpointer"));
+
+
+
+
+
+  moko_dialer_autolist_signals[CONFIRMED_SIGNAL] =
+    g_signal_new ("user_confirmed",
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (MokoDialerAutolistClass,
+                                   moko_dialer_autolist_confirmed), NULL,
+                  NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+                  g_type_from_name ("gpointer"));
+
+//moko_dialer_autolist_nomatch
+  moko_dialer_autolist_signals[NOMATCH_SIGNAL] =
+    g_signal_new ("autolist_nomatch",
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (MokoDialerAutolistClass,
+                                   moko_dialer_autolist_nomatch), NULL, NULL,
+                  g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+
+
+}
+
+
+static void
+moko_dialer_autolist_init (MokoDialerAutolist * moko_dialer_autolist)
+{
+//DBG_ENTER();
+  int i;
+  for (i = 0; i < MOKO_DIALER_MAX_TIPS; i++)
+    moko_dialer_autolist->tips[i] = 0;
+  moko_dialer_autolist->tipscreated = FALSE;
+  moko_dialer_autolist->head = 0;
+  moko_dialer_autolist->g_alternatecount = 0;
+  moko_dialer_autolist->imagePerson = 0;
+  gtk_widget_set_size_request (GTK_WIDGET (moko_dialer_autolist), 480, 40);
+
+}
+
+/**
+ * @brief please call this function first before the autolist start to work.
+*/
+gboolean
+moko_dialer_autolist_set_data (MokoDialerAutolist * moko_dialer_autolist,
+                               DIALER_CONTACTS_LIST_HEAD * head)
+{
+/*
+if(moko_dialer_autolist->head)
+	contact_release_contact_list(moko_dialer_autolist->head);
+	*/
+
+  moko_dialer_autolist->head = head;
+
+//contact_print_contact_list(moko_dialer_autolist->head);
+
+  return TRUE;
+}
+
+gint
+moko_dialer_autolist_hide_all_tips (MokoDialerAutolist * moko_dialer_autolist)
+{
+
+  if (moko_dialer_autolist->tipscreated)
+  {
+    moko_dialer_autolist->selected = FALSE;
+    //no alternative, hide all 3 labels.
+    gint i;
+    for (i = 0; i < MOKO_DIALER_MAX_TIPS; i++)
+    {
+      moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE);
+      gtk_widget_hide (moko_dialer_autolist->tips[i]);
+    }
+    //hide the imagePerson
+    gtk_widget_hide (moko_dialer_autolist->imagePerson);
+  }
+  return 1;
+
+}
+
+/**
+ * @brief initiate the font for widget of textviewCodes 
+ *
+ *
+ *
+ * @param text_view GtkWidget*, any widget which can help to lookup for labelcontactN
+ * @param count gint, the count of the alternative, max set to MAXDISPNAMENUM.
+ * @param selectdefault if selectdefault, then we will automatically emit the message to fill the sensed string,
+ *  else, we only refresh our tip list.
+ * @retval 
+ */
+
+int
+moko_dialer_autolist_fill_alternative (MokoDialerAutolist *
+                                       moko_dialer_autolist, gint count,
+                                       gboolean selectdefault)
+{
+  gint i;
+//DBG_ENTER();
+  moko_dialer_autolist->selected = FALSE;
+
+  moko_dialer_autolist->g_alternatecount = count;
+
+  if (count > 0)
+  {
+    //init the labels.
+    for (i = 0; i < count && i < MOKO_DIALER_MAX_TIPS; i++)
+    {
+      moko_dialer_tip_set_label (moko_dialer_autolist->tips[i],
+                                 moko_dialer_autolist->readycontacts[i].
+                                 p_contact->name);
+      moko_dialer_tip_set_index (moko_dialer_autolist->tips[i], i);
+      moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE);
+      gtk_widget_show (moko_dialer_autolist->tips[i]);
+    }
+
+    for (; i < MOKO_DIALER_MAX_TIPS; i++)
+    {
+      moko_dialer_tip_set_index (moko_dialer_autolist->tips[i], -1);
+      moko_dialer_tip_set_label (moko_dialer_autolist->tips[i], "");
+      gtk_widget_hide (moko_dialer_autolist->tips[i]);
+      moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE);
+    }
+
+    if (selectdefault)
+    {
+      //we set the first one as defaultly selected
+      moko_dialer_autolist_set_select (moko_dialer_autolist, 0);
+    }
+  }
+  else
+  {
+    moko_dialer_autolist_hide_all_tips (moko_dialer_autolist);
+    //notify the client that no match has been foudn
+//              autolist_nomatch
+    g_signal_emit (moko_dialer_autolist,
+                   moko_dialer_autolist_signals[NOMATCH_SIGNAL], 0, 0);
+  }
+  return 1;
+}
+
+//if selectdefault, then we will automatically emit the message to fill the sensed string
+//else, we only refresh our tip list.
+gint
+moko_dialer_autolist_refresh_by_string (MokoDialerAutolist *
+                                        moko_dialer_autolist, gchar * string,
+                                        gboolean selectdefault)
+{
+//first, we fill the ready list
+
+  DIALER_CONTACT *contacts;     //=moko_dialer_autolist->head->contacts;
+
+  DIALER_CONTACT_ENTRY *entry;
+
+  gint inserted = 0;
+
+
+  gint len;
+
+  if (string)
+    len = strlen (string);
+  else
+    len = 0;
+//  DBG_TRACE();
+
+//insert the tips here to avoid the _show_all show it from the start.
+  GtkWidget *imagePerson;
+  GtkWidget *tip;
+
+  if (!moko_dialer_autolist->tipscreated)
+  {
+    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);
+    }
+    else
+    {
+      imagePerson = gtk_image_new_from_stock ("gtk-yes", GTK_ICON_SIZE_DND);
+    }
+    gtk_widget_hide (imagePerson);
+    gtk_widget_set_size_request (imagePerson, 40, 40);
+//  gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, TRUE, TRUE, 0);
+//gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, TRUE, FALSE, 0);
+    gtk_box_pack_start (GTK_CONTAINER (moko_dialer_autolist), imagePerson,
+                        FALSE, FALSE, 0);
+
+    moko_dialer_autolist->imagePerson = imagePerson;
+    gint i;
+    for (i = 0; i < MOKO_DIALER_MAX_TIPS; i++)
+    {
+      tip = moko_dialer_tip_new ();
+
+      moko_dialer_tip_set_index (tip, i);
+
+      moko_dialer_tip_set_label (tip, "tony guan");
+
+      moko_dialer_tip_set_selected (tip, FALSE);
+
+      gtk_box_pack_start (GTK_CONTAINER (moko_dialer_autolist), tip, TRUE,
+                          TRUE, 0);
+//       gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, FALSE,FALSE, 0);                  
+//       gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, FALSE,TRUE, 0);
+//                       gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, TRUE, FALSE,0);
+
+      g_signal_connect ((gpointer) tip, "button_press_event",
+                        G_CALLBACK (on_tip_press_event),
+                        moko_dialer_autolist);
+
+//      gtk_widget_set_size_request (tip, 20, 20);      
+
+      gtk_widget_hide (tip);
+
+      moko_dialer_autolist->tips[i] = tip;
+    }
+    moko_dialer_autolist->tipscreated = TRUE;
+  }
+
+  contacts = moko_dialer_autolist->head->contacts;
+
+//  DBG_MESSAGE("CONTACTS:%d,list at 0x%x,first at 0x%x",moko_dialer_autolist->head->length,moko_dialer_autolist->head,moko_dialer_autolist->head->contacts);
+
+//        DBG_TRACE();  
+  while (contacts != NULL && inserted < MOKO_DIALER_MAX_TIPS)
+  {
+    //  DBG_TRACE();
+    entry = contacts->entry;
+    //  DBG_TRACE();
+    while (entry != NULL && inserted < MOKO_DIALER_MAX_TIPS)
+    {
+//       DBG_TRACE();
+      //judge if the entry includes the string
+      if (contact_string_has_sensentive (entry->content, string))
+      {
+        //if the person not inserted, then insert first
+        moko_dialer_autolist->readycontacts[inserted].p_contact = contacts;
+        moko_dialer_autolist->readycontacts[inserted].p_entry = entry;
+        inserted++;
+        //break;
+      }
+      entry = entry->next;
+    }
+
+    contacts = contacts->next;
+
+  }
+
+//DBG_MESSAGE("inserted=%d",inserted);
+  moko_dialer_autolist_fill_alternative (moko_dialer_autolist, inserted,
+                                         selectdefault);
+
+//DBG_LEAVE();
+  return inserted;
+}
+
+gboolean
+on_tip_press_event (MokoDialerTip * tip, GdkEventButton * event,
+                    gpointer user_data)
+{
+
+//DBG_ENTER();
+  MokoDialerAutolist *moko_dialer_autolist;
+  moko_dialer_autolist = (MokoDialerAutolist *) user_data;
+
+  gint selected = moko_dialer_tip_get_index (tip);
+
+
+  if (selected != -1 && selected < MOKO_DIALER_MAX_TIPS
+      && moko_dialer_autolist->g_alternatecount)
+  {
+
+    return moko_dialer_autolist_set_select (moko_dialer_autolist, selected);
+
+  }
+  else
+  {
+//we notify the client that no match found!
+    DBG_WARN ("the selected index is out of range!");
+    return FALSE;
+  }
+
+
+}
+
+gboolean
+moko_dialer_autolist_has_selected (MokoDialerAutolist * moko_dialer_autolist)
+{
+  return moko_dialer_autolist->selected;
+}
+
+// selected ==-1 means there are no selected tips
+gboolean
+moko_dialer_autolist_set_select (MokoDialerAutolist * moko_dialer_autolist,
+                                 gint selected)
+{
+  gint i;
+  if (selected == -1)
+  {
+
+    //set the selected status to be false
+    for (i = 0; i < moko_dialer_autolist->g_alternatecount; i++)
+    {
+      moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE);
+    }
+    //set
+    gtk_widget_hide (moko_dialer_autolist->imagePerson);
+    moko_dialer_autolist->selected = FALSE;
+    return TRUE;
+  }
+
+
+  if (selected < MOKO_DIALER_MAX_TIPS
+      && moko_dialer_autolist->g_alternatecount)
+  {
+    //first of all, determin if this tip is already selected previously.
+    if (moko_dialer_tip_is_selected (moko_dialer_autolist->tips[selected]))
+    {
+
+      //hide the others;
+      for (i = 0; i < moko_dialer_autolist->g_alternatecount; i++)
+      {
+        if (i != selected)
+        {                       //hide the others
+          gtk_widget_hide (moko_dialer_autolist->tips[i]);
+        }
+      }
+      moko_dialer_autolist->selected = FALSE;
+      //emit confirm message;
+//              DBG_MESSAGE("we confirm %s is right.",moko_dialer_autolist->readycontacts[selected].p_contact->name);                   
+      g_signal_emit (moko_dialer_autolist,
+                     moko_dialer_autolist_signals[CONFIRMED_SIGNAL], 0,
+                     &(moko_dialer_autolist->readycontacts[selected]));
+
+    }
+    else
+    {
+
+      //refresh the imagePerson widget
+//      file_load_person_image_from_relative_path(moko_dialer_autolist->imagePerson,moko_dialer_autolist->readycontacts[selected].p_contact->picpath);
+//      file_load_person_image_scalable_from_relative_path(moko_dialer_autolist->imagePerson,moko_dialer_autolist->readycontacts[selected].p_contact->picpath);
+      contact_load_contact_photo (moko_dialer_autolist->imagePerson,
+                                  moko_dialer_autolist->
+                                  readycontacts[selected].p_contact->ID);
+      gtk_widget_show (moko_dialer_autolist->imagePerson);
+      //just change the selected attribute of the tips
+      for (i = 0; i < moko_dialer_autolist->g_alternatecount; i++)
+      {
+        if (i != selected)
+        {                       //set selected to false;
+          moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE);
+        }
+        else
+          moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], TRUE);
+      }
+      moko_dialer_autolist->selected = TRUE;
+      //emit selected message
+//              DBG_MESSAGE(" %s is selectd.",moko_dialer_autolist->readycontacts[selected].p_contact->name);
+      g_signal_emit (moko_dialer_autolist,
+                     moko_dialer_autolist_signals[SELECTED_SIGNAL], 0,
+                     &(moko_dialer_autolist->readycontacts[selected]));
+    }
+    return TRUE;
+  }
+  else
+  {
+    DBG_WARN ("the selected index is out of range!");
+    return FALSE;
+  }
+
+}
+
+GtkWidget *
+moko_dialer_autolist_new ()
+{
+  DBG_ENTER ();
+
+  MokoDialerAutolist *dp;
+
+  dp = (MokoDialerAutolist *) g_object_new (MOKO_TYPE_DIALER_AUTOLIST, NULL);
+  return GTK_WIDGET (dp);
+
+}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.c	2007-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.c	2007-02-05 09:34:59 UTC (rev 668)
@@ -1,205 +1,240 @@
-/* moko-dialer-autolist .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 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-status.h"
-  #include "error.h"
-#include "common.h" 
-G_DEFINE_TYPE (MokoDialerStatus, moko_dialer_status, GTK_TYPE_VBOX)
-
-
-static void
-moko_dialer_status_class_init (MokoDialerStatusClass *class)
-{
-/*
-  GtkVBoxClass* vbox_class;
-
-  vbox_class= (GtkVBoxClass*) class;
-*/
-
-  GtkObjectClass *object_class;
-
-  object_class = (GtkObjectClass*) class;
-
-
-}
-
-
-static void
-moko_dialer_status_init (MokoDialerStatus *moko_dialer_status)
-{
-DBG_ENTER();
-moko_dialer_status->imagePerson=0;
-
-//upper section
-; ///<the topmost title bar of the status
-moko_dialer_status->labelStatusTitle= gtk_label_new("");
-
-/*
-for(gint i=0;i<MOKO_DIALER_MAX_STATUS_ICONS;i++)
-	moko_dialer_status->iconStatus[i]=gtk_image_new();
-*/
-
-moko_dialer_status->icon=gtk_image_new();
-
-
-//lower section  
-	moko_dialer_status->imagePerson=gtk_image_new();  ///<the image of the person we care
-gtk_widget_set_size_request (moko_dialer_status->imagePerson, 130,130);
-  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->imagePerson), 1, 0);
-
-	
-	moko_dialer_status->labelStatus=gtk_label_new("");	///<the status label
-        	  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelStatus), 0, 0);
-//          	  gtk_misc_set_padding(GTK_MISC (moko_dialer_status->labelStatus), 20,0);
-	moko_dialer_status->labelPersonName=gtk_label_new(""); ///<the person name
-		  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelPersonName), 0, 0);
-	moko_dialer_status->labelNumber=gtk_label_new(""); ///<the number of the person
-		  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelNumber), 0, 0);
-//private section
-	moko_dialer_status->number_of_the_icons=0;
-
- gtk_widget_set_size_request (moko_dialer_status->icon, 64,64);
- gtk_box_pack_start( GTK_BOX(moko_dialer_status),	moko_dialer_status->labelStatusTitle , FALSE, FALSE, 20 );
- gtk_box_pack_start( GTK_BOX(moko_dialer_status),	moko_dialer_status->icon, FALSE, FALSE, 20);
- 
-//ok now, we arrange them in the vbox.
-
-// we create another vbox to hold the status labels.
-    GtkVBox *  vbox2 = gtk_vbox_new( FALSE, 0 );
-   gtk_box_pack_start( GTK_BOX(vbox2),	moko_dialer_status->labelStatus, TRUE, TRUE, 0);
-   
-   gtk_box_pack_start( GTK_BOX(vbox2),	moko_dialer_status->labelPersonName, TRUE, TRUE, 0 );
-
-
-    
-   gtk_box_pack_start( GTK_BOX(vbox2),	moko_dialer_status->labelNumber, TRUE, TRUE, 0 );
-// a hbox to hold the image and the vbox2
-    GtkVBox *  hbox2 = gtk_hbox_new( FALSE, 0 );
-
-
-    
-//   gtk_box_pack_start( GTK_BOX(hbox2),	moko_dialer_status->imagePerson, FALSE, FALSE, 0 );
-   gtk_box_pack_start( GTK_BOX(hbox2),	moko_dialer_status->imagePerson, TRUE,TRUE, 0 );
-
-// gtk_box_pack_start( GTK_BOX(hbox2),vbox2, FALSE, FALSE, 0 );
- gtk_box_pack_start( GTK_BOX(hbox2),vbox2, TRUE,TRUE, 36 );
-
-gtk_box_pack_start( GTK_BOX(moko_dialer_status),hbox2, TRUE, TRUE, 0 );
-
-//gtk_widget_set_size_request (GTK_WIDGET(moko_dialer_status), 320, 200); 
-
-DBG_LEAVE();
-
-}
-
-GtkWidget*      moko_dialer_status_new()
-{
-DBG_ENTER();
-
-MokoDialerStatus * dp;
-
-dp=(MokoDialerStatus * )g_object_new (MOKO_TYPE_DIALER_STATUS, NULL);
-return GTK_WIDGET(dp);
-
-}
-
-void moko_dialer_status_set_title_label(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-
-gtk_label_set_text(GTK_LABEL(moko_dialer_status->labelStatusTitle),text);
-}
-void moko_dialer_status_set_status_label(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-
-//DBG_MESSAGE("moko_dialer_status_set_status_label:moko_dialer_status=0X%x",moko_dialer_status);
-gtk_label_set_text(GTK_LABEL(moko_dialer_status->labelStatus),text);
-}
-
-void moko_dialer_status_set_person_name(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-gtk_label_set_text(GTK_LABEL(moko_dialer_status->labelPersonName),text);
-} 
-void moko_dialer_status_set_person_number(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-gtk_label_set_text(GTK_LABEL(moko_dialer_status->labelNumber),text);
-} 
-
-void moko_dialer_status_set_person_image(MokoDialerStatus *moko_dialer_status,const gchar* id)
-{
-//file_load_person_image_scalable_from_relative_path(moko_dialer_status->imagePerson,path);
-//file_load_person_image_from_relative_path(moko_dialer_status->imagePerson,path);
-
-contact_load_contact_photo(moko_dialer_status->imagePerson,id);
-//file_load_person_image_scalable_from_relative_path(moko_dialer_status->imagePerson,path);
-} 
-int moko_dialer_status_add_status_icon(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-if(moko_dialer_status->number_of_the_icons<MOKO_DIALER_MAX_STATUS_ICONS)
-{
-	moko_dialer_status->iconStatus[moko_dialer_status->number_of_the_icons]=create_pixbuf (text);
-
-	moko_dialer_status->number_of_the_icons++;
-	return 1;
-}
-else
-{
-	DBG_ERROR("MOKO_DIALER_MAX_STATUS_ICONS has reached, add no more icons.");
-	return 0;
-}
-} 
-
-void moko_dialer_status_set_error_icon(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-
-	moko_dialer_status->iconError=create_pixbuf (text);
-//	file_load_person_image_from_relative_path(moko_dialer_status->iconError,text);
-} 
-void moko_dialer_status_set_success_icon(MokoDialerStatus *moko_dialer_status,const gchar* text)
-{
-	moko_dialer_status->iconError=create_pixbuf (text);
-//	file_load_person_image_from_relative_path(moko_dialer_status->iconSuccuss,text);
-}
-
-void moko_dialer_status_set_icon_by_index(MokoDialerStatus *moko_dialer_status,gint index)
-{
-if( moko_dialer_status->iconStatus[index]!=0&&index<moko_dialer_status->number_of_the_icons)
-	gtk_image_set_from_pixbuf(moko_dialer_status->icon, moko_dialer_status->iconStatus[index]);
-}
-void moko_dialer_status_update_icon(MokoDialerStatus *moko_dialer_status)
-{
-static gint currenticon=0;
-currenticon=(currenticon+1)%moko_dialer_status->number_of_the_icons;
-if( moko_dialer_status->iconStatus[currenticon])
-	moko_dialer_status_set_icon_by_index(moko_dialer_status,currenticon);
-}
-	
-
-void moko_dialer_status_set_error(MokoDialerStatus *moko_dialer_status)
-{
-if(moko_dialer_status->iconError)
-	gtk_image_set_from_pixbuf(moko_dialer_status->icon, moko_dialer_status->iconError);
-moko_dialer_status_set_status_label(moko_dialer_status,"");
-}
-
-void moko_dialer_status_set_success(MokoDialerStatus *moko_dialer_status)
-{
-if(moko_dialer_status->iconSuccess)
-	gtk_image_set_from_pixbuf(moko_dialer_status->icon, moko_dialer_status->iconSuccess);
-
-}
-
+/* moko-dialer-autolist .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 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-status.h"
+#include "error.h"
+#include "common.h"
+G_DEFINE_TYPE (MokoDialerStatus, moko_dialer_status, GTK_TYPE_VBOX)
+     static void moko_dialer_status_class_init (MokoDialerStatusClass * class)
+{
+/*
+  GtkVBoxClass* vbox_class;
+
+  vbox_class= (GtkVBoxClass*) class;
+*/
+
+  GtkObjectClass *object_class;
+
+  object_class = (GtkObjectClass *) class;
+
+
+}
+
+
+static void
+moko_dialer_status_init (MokoDialerStatus * moko_dialer_status)
+{
+  DBG_ENTER ();
+  moko_dialer_status->imagePerson = 0;
+
+//upper section
+  ;                             ///<the topmost title bar of the status
+  moko_dialer_status->labelStatusTitle = gtk_label_new ("");
+
+/*
+for(gint i=0;i<MOKO_DIALER_MAX_STATUS_ICONS;i++)
+	moko_dialer_status->iconStatus[i]=gtk_image_new();
+*/
+
+  moko_dialer_status->icon = gtk_image_new ();
+
+
+//lower section  
+  moko_dialer_status->imagePerson = gtk_image_new ();   ///<the image of the person we care
+  gtk_widget_set_size_request (moko_dialer_status->imagePerson, 130, 130);
+  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->imagePerson), 1, 0);
+
+
+  moko_dialer_status->labelStatus = gtk_label_new (""); ///<the status label
+  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelStatus), 0, 0);
+//                gtk_misc_set_padding(GTK_MISC (moko_dialer_status->labelStatus), 20,0);
+  moko_dialer_status->labelPersonName = gtk_label_new ("");     ///<the person name
+  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelPersonName), 0,
+                          0);
+  moko_dialer_status->labelNumber = gtk_label_new (""); ///<the number of the person
+  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelNumber), 0, 0);
+//private section
+  moko_dialer_status->number_of_the_icons = 0;
+
+  gtk_widget_set_size_request (moko_dialer_status->icon, 64, 64);
+  gtk_box_pack_start (GTK_BOX (moko_dialer_status),
+                      moko_dialer_status->labelStatusTitle, FALSE, FALSE, 20);
+  gtk_box_pack_start (GTK_BOX (moko_dialer_status), moko_dialer_status->icon,
+                      FALSE, FALSE, 20);
+
+//ok now, we arrange them in the vbox.
+
+// we create another vbox to hold the status labels.
+  GtkVBox *vbox2 = gtk_vbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox2), moko_dialer_status->labelStatus, TRUE,
+                      TRUE, 0);
+
+  gtk_box_pack_start (GTK_BOX (vbox2), moko_dialer_status->labelPersonName,
+                      TRUE, TRUE, 0);
+
+
+
+  gtk_box_pack_start (GTK_BOX (vbox2), moko_dialer_status->labelNumber, TRUE,
+                      TRUE, 0);
+// a hbox to hold the image and the vbox2
+  GtkVBox *hbox2 = gtk_hbox_new (FALSE, 0);
+
+
+
+//   gtk_box_pack_start( GTK_BOX(hbox2),        moko_dialer_status->imagePerson, FALSE, FALSE, 0 );
+  gtk_box_pack_start (GTK_BOX (hbox2), moko_dialer_status->imagePerson, TRUE,
+                      TRUE, 0);
+
+// gtk_box_pack_start( GTK_BOX(hbox2),vbox2, FALSE, FALSE, 0 );
+  gtk_box_pack_start (GTK_BOX (hbox2), vbox2, TRUE, TRUE, 36);
+
+  gtk_box_pack_start (GTK_BOX (moko_dialer_status), hbox2, TRUE, TRUE, 0);
+
+//gtk_widget_set_size_request (GTK_WIDGET(moko_dialer_status), 320, 200); 
+
+  DBG_LEAVE ();
+
+}
+
+GtkWidget *
+moko_dialer_status_new ()
+{
+  DBG_ENTER ();
+
+  MokoDialerStatus *dp;
+
+  dp = (MokoDialerStatus *) g_object_new (MOKO_TYPE_DIALER_STATUS, NULL);
+  return GTK_WIDGET (dp);
+
+}
+
+void
+moko_dialer_status_set_title_label (MokoDialerStatus * moko_dialer_status,
+                                    const gchar * text)
+{
+
+  gtk_label_set_text (GTK_LABEL (moko_dialer_status->labelStatusTitle), text);
+}
+
+void
+moko_dialer_status_set_status_label (MokoDialerStatus * moko_dialer_status,
+                                     const gchar * text)
+{
+
+//DBG_MESSAGE("moko_dialer_status_set_status_label:moko_dialer_status=0X%x",moko_dialer_status);
+  gtk_label_set_text (GTK_LABEL (moko_dialer_status->labelStatus), text);
+}
+
+void
+moko_dialer_status_set_person_name (MokoDialerStatus * moko_dialer_status,
+                                    const gchar * text)
+{
+  gtk_label_set_text (GTK_LABEL (moko_dialer_status->labelPersonName), text);
+}
+
+void
+moko_dialer_status_set_person_number (MokoDialerStatus * moko_dialer_status,
+                                      const gchar * text)
+{
+  gtk_label_set_text (GTK_LABEL (moko_dialer_status->labelNumber), text);
+}
+
+void
+moko_dialer_status_set_person_image (MokoDialerStatus * moko_dialer_status,
+                                     const gchar * id)
+{
+//file_load_person_image_scalable_from_relative_path(moko_dialer_status->imagePerson,path);
+//file_load_person_image_from_relative_path(moko_dialer_status->imagePerson,path);
+
+  contact_load_contact_photo (moko_dialer_status->imagePerson, id);
+//file_load_person_image_scalable_from_relative_path(moko_dialer_status->imagePerson,path);
+}
+
+int
+moko_dialer_status_add_status_icon (MokoDialerStatus * moko_dialer_status,
+                                    const gchar * text)
+{
+  if (moko_dialer_status->number_of_the_icons < MOKO_DIALER_MAX_STATUS_ICONS)
+  {
+    moko_dialer_status->iconStatus[moko_dialer_status->number_of_the_icons] =
+      create_pixbuf (text);
+
+    moko_dialer_status->number_of_the_icons++;
+    return 1;
+  }
+  else
+  {
+    DBG_ERROR
+      ("MOKO_DIALER_MAX_STATUS_ICONS has reached, add no more icons.");
+    return 0;
+  }
+}
+
+void
+moko_dialer_status_set_error_icon (MokoDialerStatus * moko_dialer_status,
+                                   const gchar * text)
+{
+  
moko_dialer_status->iconError = create_pixbuf (text);
+//      file_load_person_image_from_relative_path(moko_dialer_status->iconError,text);
+}
+
+void
+moko_dialer_status_set_success_icon (MokoDialerStatus * moko_dialer_status,
+                                     const gchar * text)
+{
+  moko_dialer_status->iconError = create_pixbuf (text);
+//      file_load_person_image_from_relative_path(moko_dialer_status->iconSuccuss,text);
+}
+
+void
+moko_dialer_status_set_icon_by_index (MokoDialerStatus * moko_dialer_status,
+                                      gint index)
+{
+  if (moko_dialer_status->iconStatus[index] != 0
+      && index < moko_dialer_status->number_of_the_icons)
+    gtk_image_set_from_pixbuf (moko_dialer_status->icon,
+                               moko_dialer_status->iconStatus[index]);
+}
+
+void
+moko_dialer_status_update_icon (MokoDialerStatus * moko_dialer_status)
+{
+  static gint currenticon = 0;
+  currenticon = (currenticon + 1) % moko_dialer_status->number_of_the_icons;
+  if (moko_dialer_status->iconStatus[currenticon])
+    moko_dialer_status_set_icon_by_index (moko_dialer_status, currenticon);
+}
+
+
+void
+moko_dialer_status_set_error (MokoDialerStatus * moko_dialer_status)
+{
+  if (moko_dialer_status->iconError)
+    gtk_image_set_from_pixbuf (moko_dialer_status->icon,
+                               moko_dialer_status->iconError);
+  moko_dialer_status_set_status_label (moko_dialer_status, "");
+}
+
+void
+moko_dialer_status_set_success (MokoDialerStatus * moko_dialer_status)
+{
+  if (moko_dialer_status->iconSuccess)
+    gtk_image_set_from_pixbuf (moko_dialer_status->icon,
+                               moko_dialer_status->iconSuccess);
+
+}

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.h	2007-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.h	2007-02-05 09:34:59 UTC (rev 668)
@@ -1,97 +1,97 @@
-/* moko-dialer-status.h
- *  to display the person name, picuter,number. etc.
- *  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 $]
- */
- #ifndef _MOKO_DIALER_STATUS_H_
-#define _MOKO_DIALER_STATUS_H_
-
-
-
-
-#include <gdk/gdk.h>
-#include <gtk/gtkhbox.h>
-#include <glib-object.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkobject.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtktextview.h>
-#include "moko-dialer-tip.h"
-#include "moko-dialer-declares.h"
-#include "contacts.h"
-
-//#include "moko-dialer-includes.h"
-
-G_BEGIN_DECLS
-
-
-
-#define MOKO_TYPE_DIALER_STATUS                (moko_dialer_status_get_type())
-#define MOKO_DIALER_STATUS (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_STATUS, MokoDialerStatus))
-#define MOKO_DIALER_STATUS_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass),MOKO_TYPE_DIALER_STATUS,MokoDialerStatusClass))
-#define MOKO_IS_DIALER_STATUS(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIALER_STATUS))
-#define MOKO_IS_DIALER_STATUS_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIALER_STATUS))
-#define MOKO_DIALER_STATUS_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIALER_STATUS, MokoDialerStatusClass))
-
-
-
-typedef struct _MokoDialerStatusClass   MokoDialerStatusClass;
-
-typedef struct _MokoDialerStatus        MokoDialerStatus;
-struct _MokoDialerStatus
-{
-  GtkVBox vbox;
-//upper section
-  GtkWidget * labelStatusTitle; ///<the topmost title bar of the status
-  GtkWidget * icon;
-  GdkPixbuf * iconStatus[MOKO_DIALER_MAX_STATUS_ICONS];
-  GdkPixbuf * iconError;
-  GdkPixbuf * iconSuccess;
-//lower section  
-  GtkWidget * imagePerson;  ///<the image of the person we care
-  GtkWidget * labelStatus;	///<the status label
-  GtkWidget * labelPersonName; ///<the person name
-  GtkWidget * labelNumber; ///<the number of the person
-
-//private section
-  gint number_of_the_icons;
-  
-
-};
-
-struct _MokoDialerStatusClass
-{
-  GtkVBoxClass parent_class;
-};
-
-
-GType          moko_dialer_status_get_type         (void) ;
-
-GtkWidget*      moko_dialer_status_new();
-
-void moko_dialer_status_set_title_label(MokoDialerStatus *moko_dialer_status,const gchar* text);
-void moko_dialer_status_set_person_name(MokoDialerStatus *moko_dialer_status,const gchar* text);
-void moko_dialer_status_set_person_number(MokoDialerStatus *moko_dialer_status,const gchar* text);
-void moko_dialer_status_set_person_image(MokoDialerStatus *moko_dialer_status,const gchar* id);
-void moko_dialer_status_set_icons(MokoDialerStatus *moko_dialer_status,const gchar* text);
-void moko_dialer_status_set_status_label(MokoDialerStatus *moko_dialer_status,const gchar* text);
-
-G_END_DECLS
-
-#endif // 
-
-
-
-
+/* moko-dialer-status.h
+ *  to display the person name, picuter,number. etc.
+ *  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 $]
+ */
+#ifndef _MOKO_DIALER_STATUS_H_
+#define _MOKO_DIALER_STATUS_H_
+
+
+
+
+#include <gdk/gdk.h>
+#include <gtk/gtkhbox.h>
+#include <glib-object.h>
+#include <gtk/gtktable.h>
+#include <gtk/gtkobject.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtktextview.h>
+#include "moko-dialer-tip.h"
+#include "moko-dialer-declares.h"
+#include "contacts.h"
+
+//#include "moko-dialer-includes.h"
+
+G_BEGIN_DECLS
+#define MOKO_TYPE_DIALER_STATUS                (moko_dialer_status_get_type())
+#define MOKO_DIALER_STATUS (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_STATUS, MokoDialerStatus))
+#define MOKO_DIALER_STATUS_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass),MOKO_TYPE_DIALER_STATUS,MokoDialerStatusClass))
+#define MOKO_IS_DIALER_STATUS(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOKO_TYPE_DIALER_STATUS))
+#define MOKO_IS_DIALER_STATUS_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIALER_STATUS))
+#define MOKO_DIALER_STATUS_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIALER_STATUS, MokoDialerStatusClass))
+typedef struct _MokoDialerStatusClass MokoDialerStatusClass;
+
+typedef struct _MokoDialerStatus MokoDialerStatus;
+struct _MokoDialerStatus
+{
+  GtkVBox vbox;
+//upper section
+  GtkWidget *labelStatusTitle;  ///<the topmost title bar of the status
+  GtkWidget *icon;
+  GdkPixbuf *iconStatus[MOKO_DIALER_MAX_STATUS_ICONS];
+  GdkPixbuf *iconError;
+  GdkPixbuf *iconSuccess;
+//lower section  
+  GtkWidget *imagePerson;       ///<the image of the person we care
+  GtkWidget *labelStatus;       ///<the status label
+  GtkWidget *labelPersonName;   ///<the person name
+  GtkWidget *labelNumber;       ///<the number of the person
+
+//private section
+  gint number_of_the_icons;
+
+
+};
+
+struct _MokoDialerStatusClass
+{
+  GtkVBoxClass parent_class;
+};
+
+
+GType moko_dialer_status_get_type (void);
+
+GtkWidget *moko_dialer_status_new ();
+
+void moko_dialer_status_set_title_label (MokoDialerStatus *
+                                         moko_dialer_status,
+                                         const gchar * text);
+void moko_dialer_status_set_person_name (MokoDialerStatus *
+                                         moko_dialer_status,
+                                         const gchar * text);
+void moko_dialer_status_set_person_number (MokoDialerStatus *
+                                           moko_dialer_status,
+                                           const gchar * text);
+void moko_dialer_status_set_person_image (MokoDialerStatus *
+                                          moko_dialer_status,
+                                          const gchar * id);
+void moko_dialer_status_set_icons (MokoDialerStatus * moko_dialer_status,
+                                   const gchar * text);
+void moko_dialer_status_set_status_label (MokoDialerStatus *
+                                          moko_dialer_status,
+                                          const gchar * text);
+
+G_END_DECLS
+#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-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-textview.c	2007-02-05 09:34:59 UTC (rev 668)
@@ -334,7 +334,7 @@
 int
 moko_dialer_textview_empty (MokoDialerTextview * moko_dialer_textview)
 {
-  GtkTextBuffer * buffer;
+  GtkTextBuffer *buffer;
 
   buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (moko_dialer_textview));
 

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-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c	2007-02-05 09:34:59 UTC (rev 668)
@@ -36,129 +36,141 @@
 #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()
+MOKO_DIALER_APP_DATA *p_dialer_data = 0;
+MOKO_DIALER_APP_DATA *
+moko_get_app_data ()
 {
-return p_dialer_data;
+  return p_dialer_data;
 }
 
-void gsm_incoming_call(gchar * number)
+void
+gsm_incoming_call (gchar * number)
 {
 
-MOKO_DIALER_APP_DATA* appdata=moko_get_app_data();
+  MOKO_DIALER_APP_DATA *appdata = moko_get_app_data ();
 
-if(appdata)
-{
+  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--;
+    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);	
+    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);
+    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 (appdata->g_contactlist.contacts,
+                                       &(appdata->g_peer_info));
 // contact_get_peer_info_from_number
 
 
 //transfer the contact info
-window_incoming_prepare(appdata);
+    window_incoming_prepare (appdata);
 
-gtk_widget_show(appdata->window_incoming);
-}
-else
-{
-DBG_ERROR("gui failed to initialize.try another time.");
-}
+    gtk_widget_show (appdata->window_incoming);
+  }
+  else
+  {
+    DBG_ERROR ("gui failed to initialize.try another time.");
+  }
 
 
 }
 
-void gsm_peer_accept()
+void
+gsm_peer_accept ()
 {
-MOKO_DIALER_APP_DATA* appdata=moko_get_app_data();
-DBG_ENTER();
+  MOKO_DIALER_APP_DATA *appdata = moko_get_app_data ();
+  DBG_ENTER ();
 //moko_dialer_status_update_icon(appdata->status_outgoing);
 
 
-appdata->g_state.callstate=STATE_TALKING;
+  appdata->g_state.callstate = STATE_TALKING;
 
-gtk_widget_hide(appdata->window_outgoing);
+  gtk_widget_hide (appdata->window_outgoing);
 
 
 //transfer the contact info
-window_talking_prepare(appdata);
+  window_talking_prepare (appdata);
 
 //start talking.
 
-gtk_widget_show(appdata->window_talking);
+  gtk_widget_show (appdata->window_talking);
 
 
-DBG_LEAVE();
+  DBG_LEAVE ();
 }
 
-void gsm_peer_refuse()
+void
+gsm_peer_refuse ()
 {
-MOKO_DIALER_APP_DATA* appdata=moko_get_app_data();
-window_outgoing_fails(appdata);
+  MOKO_DIALER_APP_DATA *appdata = moko_get_app_data ();
+  window_outgoing_fails (appdata);
 }
 
-void gsm_peer_abort()
+void
+gsm_peer_abort ()
 {
 
-MOKO_DIALER_APP_DATA* appdata=moko_get_app_data();
-if(appdata->window_incoming)
-	gtk_widget_hide(appdata->window_incoming);
+  MOKO_DIALER_APP_DATA *appdata = moko_get_app_data ();
+  if (appdata->window_incoming)
+    gtk_widget_hide (appdata->window_incoming);
 
 
 }
 
-void gsm_peer_disconnect()
+void
+gsm_peer_disconnect ()
 {
 
-     MOKO_DIALER_APP_DATA* appdata=moko_get_app_data();
-     gsm_hangup();
-     gtk_widget_hide(appdata->window_talking);
+  MOKO_DIALER_APP_DATA *appdata = moko_get_app_data ();
+  gsm_hangup ();
+  gtk_widget_hide (appdata->window_talking);
 
 }
-int main( int argc, char** argv )
+
+int
+main (int argc, char **argv)
 {
-    p_dialer_data=calloc(1,sizeof(MOKO_DIALER_APP_DATA));
-    /* Initialize GTK+ */
-    gtk_init( &argc, &argv );
+  p_dialer_data = calloc (1, sizeof (MOKO_DIALER_APP_DATA));
+  /* Initialize GTK+ */
+  gtk_init (&argc, &argv);
 
 
-    //init application data
-   contact_init_contact_data(&(p_dialer_data->g_contactlist));
-   history_init_history_data(&(p_dialer_data->g_historylist));
-   
+  //init application data
+  contact_init_contact_data (&(p_dialer_data->g_contactlist));
+  history_init_history_data (&(p_dialer_data->g_historylist));
 
-    /* application object */
+
+  /* application object */
 //    MokoApplication* app = MOKO_APPLICATION(moko_application_get_instance());
-    g_set_application_name( "OpenMoko Dialer" );
+  g_set_application_name ("OpenMoko Dialer");
 
 
 //   gtk_main();
 
 
 
- GMainLoop* mainloop=0;
- mainloop = g_main_loop_new(NULL, FALSE );
- p_dialer_data->mainloop=mainloop;
+  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_dialer_init (p_dialer_data);
 //  window_incoming_init(p_dialer_data); 
 //  window_outgoing_init(p_dialer_data); 
 //  window_history_init(p_dialer_data); 
@@ -166,23 +178,23 @@
 
 
 //from now on we will not use multithreads.
-  gsm_lgsm_start(mainloop);
+  gsm_lgsm_start (mainloop);
   //start a timer to monitor incoming calls
   //gtk_timeout_add(100,incoming_calls,0);
- 
+
 //instead, we add a g_source
 
 
   //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);
+  g_main_loop_run (mainloop);
 
 
 
@@ -191,9 +203,8 @@
 
 
 //release everything    
-    contact_release_contact_list(&(p_dialer_data->g_contactlist)); 
+  contact_release_contact_list (&(p_dialer_data->g_contactlist));
 
-  history_release_history_list(&(p_dialer_data->g_historylist));
-    return 0;
+  history_release_history_list (&(p_dialer_data->g_historylist));
+  return 0;
 }
-

Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-history.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-history.c	2007-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-history.c	2007-02-05 09:34:59 UTC (rev 668)
@@ -1,961 +1,1014 @@
-/*   openmoko-dialer-window-talking.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 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 <gtk/gtktreeview.h>
-#include <gtk/gtktreemodelfilter.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtkimagemenuitem.h>
-#include <gtk/gtkmenu.h>
-#include "contacts.h"
-#include "openmoko-dialer-main.h"
-#include "moko-dialer-status.h"
-#include  "history.h"
-#include "openmoko-dialer-window-history.h"
-
-/**
- * @brief re-filter the treeview widget by the history type
- *
- * 
- *
- * @param type HISTORY_TYPE, indicating only the history items of that type will be displayed
- * @return 1
- * @retval
- */
- 
-int history_view_change_filter(MOKO_DIALER_APP_DATA* p_dialer_data,HISTORY_TYPE  type)
-{
-GtkWidget* historyview;
-GtkTreePath* path;
-DBG_TRACE();
-p_dialer_data->g_history_filter_type=type;
-gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(p_dialer_data->g_list_store_filter));
-
-path=gtk_tree_path_new_first();
-gtk_tree_view_set_cursor(GTK_TREE_VIEW(p_dialer_data->treeview_history),path,0,0);   
-gtk_tree_path_free(path);
-
-	
-return 1;
-}
-
-void
-on_all_calls_activate                  (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-	MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data;
-	GtkWidget* label=p_dialer_data->label_filter_history;
-	gtk_label_set_text(GTK_LABEL(label),"All");
-	history_view_change_filter(p_dialer_data,ALL);
-	history_update_counter(p_dialer_data);
-}
-
-
-void
-on_missed_calls_activate               (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-	MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data;
-	GtkWidget* label=p_dialer_data->label_filter_history;
-	gtk_label_set_text(GTK_LABEL(label),"Missed");
-	history_view_change_filter(p_dialer_data,MISSED);
-	history_update_counter(p_dialer_data);
-}
-
-
-void
-on_dialed_calls_activate               (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-	MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data;
-	GtkWidget* label=p_dialer_data->label_filter_history;
-	gtk_label_set_text(GTK_LABEL(label),"Dialed");
-	history_view_change_filter(p_dialer_data,OUTGOING);
-	history_update_counter(p_dialer_data);
-}
-
-
-void
-on_received_calls_activate            (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-	MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data;
-	GtkWidget* label=p_dialer_data->label_filter_history;
-	gtk_label_set_text(GTK_LABEL(label),"Received");
-	history_view_change_filter(p_dialer_data,INCOMING);
-	history_update_counter(p_dialer_data);
-}
-
-gboolean
-on_eventboxTop_button_release_event    (GtkWidget       *widget,
-                                        GdkEventButton  *event,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-	
- gtk_menu_popup(GTK_MENU(appdata->menu_history),0,0,0,0,0,0);
- 
-  return FALSE;
-}
-
-void
-openmoko_history_wheel_press_left_up_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
- GtkTreeSelection    *selection;
- GtkTreeModel        *model;
- GtkTreeIter         iter;
- GtkTreePath* path;
- GtkTreeView * treeview;
- //DBG_ENTER();
-
-treeview=GTK_TREE_VIEW(appdata->treeview_history);
- if(treeview==0)return ;
-	 
- selection = gtk_tree_view_get_selection(treeview);
-
- if (!gtk_tree_selection_get_selected(selection, &model, &iter))
- {
-	 DBG_WARN("no current selection\n");
-	 return ;
- }
- 		path=gtk_tree_model_get_path(model,&iter);
-		if(!gtk_tree_path_prev(path))
-		{
-				DBG_WARN("no prev for the top level\n");
-				gtk_tree_path_free(path);
-				return;
-		}
-		gtk_tree_view_set_cursor(treeview,path,0,0);
-  return ;
-
-
-}
-
-void
-openmoko_history_wheel_press_right_down_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
- GtkTreeSelection    *selection;
- GtkTreeModel        *model;
- GtkTreeIter         iter;
- GtkTreePath* path;
- GtkTreeView * treeview;
- //DBG_ENTER();
-treeview=GTK_TREE_VIEW(appdata->treeview_history);
- if(treeview==0)return ;
-	 
- selection = gtk_tree_view_get_selection(treeview);
-
- if (!gtk_tree_selection_get_selected(selection, &model, &iter))
- {
-	 DBG_WARN("no current selection\n");
-	 return ;
- }
-	 if(gtk_tree_model_iter_next(model,&iter))
-	 {
-		path=gtk_tree_model_get_path(model,&iter);
-		gtk_tree_view_set_cursor(treeview,path,0,0);
-		gtk_tree_path_free(path);
-		return ;
-	 }
- 
-  return ;
-}
-
-
-void cb_tool_button_history_delete_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-GtkTreeIter iter; //iter of the filter store
-GtkTreeIter iter0; //iter of the back store
-GtkTreeModel* model;
-GtkTreeModel* model0;
-GtkTreeSelection * selection;
-GtkTreeView* treeview;
-GtkTreePath* path;
-treeview=GTK_TREE_VIEW(appdata->treeview_history);
-selection = gtk_tree_view_get_selection(treeview);
-
-	
-if (!gtk_tree_selection_get_selected(selection, &model, &iter))
-{
-	return;
-}
-	
-if(appdata->g_currentselected)
-{
-DBG_MESSAGE("to delete %s",appdata->g_currentselected->number);
-history_delete_entry(&(appdata->g_historylist),appdata->g_currentselected);
-}
-
-path=gtk_tree_model_get_path(model,&iter);
-
-
-model0=gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model));
-
-
-gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model),&iter0,&iter);
-
-gtk_list_store_remove(GTK_LIST_STORE(model0),&iter0);
-
-
-gtk_tree_view_set_cursor(treeview,path,0,0);
-
-
-if (!gtk_tree_selection_get_selected(selection, &model, &iter))
-{
-	if(!gtk_tree_path_prev(path))
-	{
-		gtk_tree_view_set_cursor(treeview,path,0,0);
-		DBG_WARN("history is empty now!");
-		history_update_counter(appdata);
-	}
-	else
-	{
-		gtk_tree_view_set_cursor(treeview,path,0,0);
-	}
-	//we deleted the last one.
-	
-}
-
-gtk_tree_path_free(path);
-
-return ;
-
-  DBG_ENTER();
-}
-
-void cb_tool_button_history_call_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-	DBG_ENTER();
-	
-
+/*   openmoko-dialer-window-talking.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 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 <gtk/gtktreeview.h>
+#include <gtk/gtktreemodelfilter.h>
+#include <gtk/gtkscrolledwindow.h>
+#include <gtk/gtkimagemenuitem.h>
+#include <gtk/gtkmenu.h>
+#include "contacts.h"
+#include "openmoko-dialer-main.h"
+#include "moko-dialer-status.h"
+#include  "history.h"
+#include "openmoko-dialer-window-history.h"
+
+/**
+ * @brief re-filter the treeview widget by the history type
+ *
+ * 
+ *
+ * @param type HISTORY_TYPE, indicating only the history items of that type will be displayed
+ * @return 1
+ * @retval
+ */
+
+int
+history_view_change_filter (MOKO_DIALER_APP_DATA * p_dialer_data,
+                            HISTORY_TYPE type)
+{
+  GtkWidget *historyview;
+  GtkTreePath *path;
+  DBG_TRACE ();
+  p_dialer_data->g_history_filter_type = type;
+  gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER
+                                  (p_dialer_data->g_list_store_filter));
+
+  path = gtk_tree_path_new_first ();
+  gtk_tree_view_set_cursor (GTK_TREE_VIEW (p_dialer_data->treeview_history),
+                            path, 0, 0);
+  gtk_tree_path_free (path);
+
+
+  return 1;
+}
+
+void
+on_all_calls_activate (GtkMenuItem * menuitem, gpointer user_data)
+{
+  MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data;
+  GtkWidget *label = p_dialer_data->label_filter_history;
+  gtk_label_set_text (GTK_LABEL (label), "All");
+  history_view_change_filter (p_dialer_data, ALL);
+  history_update_counter (p_dialer_data);
+}
+
+
+void
+on_missed_calls_activate (GtkMenuItem * menuitem, gpointer user_data)
+{
+  MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data;
+  GtkWidget *label = p_dialer_data->label_filter_history;
+  gtk_label_set_text (GTK_LABEL (label), "Missed");
+  history_view_change_filter (p_dialer_data, MISSED);
+  history_update_counter (p_dialer_data);
+}
+
+
+void
+on_dialed_calls_activate (GtkMenuItem * menuitem, gpointer user_data)
+{
+  MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data;
+  GtkWidget *label = p_dialer_data->label_filter_history;
+  gtk_label_set_text (GTK_LABEL (label), "Dialed");
+  history_view_change_filter (p_dialer_data, OUTGOING);
+  history_update_counter (p_dialer_data);
+}
+
+
+void
+on_received_calls_activate (GtkMenuItem * menuitem, gpointer user_data)
+{
+  MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data;
+  GtkWidget *label = p_dialer_data->label_filter_history;
+  gtk_label_set_text (GTK_LABEL (label), "Received");
+  history_view_change_filter (p_dialer_data, INCOMING);
+  history_update_counter (p_dialer_data);
+}
+
+gboolean
+on_eventboxTop_button_release_event (GtkWidget * widget,
+                                     GdkEventButton * event,
+                                     MOKO_DIALER_APP_DATA * appdata)
+{
+
+  gtk_menu_popup (GTK_MENU (appdata->menu_history), 0, 0, 0, 0, 0, 0);
+
+  return FALSE;
+}
+
+void
+openmoko_history_wheel_press_left_up_cb (GtkWidget * widget,
+                                         MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  GtkTreeSelection *selection;
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  GtkTreePath *path;
+  GtkTreeView *treeview;
+  //DBG_ENTER();
+
+  treeview = GTK_TREE_VIEW (appdata->treeview_history);
+  if (treeview == 0)
+    return;
+
+  selection = gtk_tree_view_get_selection (treeview);
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+  {
+    DBG_WARN ("no current selection\n");
+    return;
+  }
+  path = gtk_tree_model_get_path (model, &iter);
+  if (!gtk_tree_path_prev (path))
+  {
+    DBG_WARN ("no prev for the top level\n");
+    gtk_tree_path_free (path);
+    return;
+  }
+  gtk_tree_view_set_cursor (treeview, path, 0, 0);
+  return;
+
+
+}
+
+void
+openmoko_history_wheel_press_right_down_cb (GtkWidget * widget,
+                                            MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  GtkTreeSelection *selection;
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  GtkTreePath *path;
+  GtkTreeView *treeview;
+  //DBG_ENTER();
+  treeview = GTK_TREE_VIEW (appdata->treeview_history);
+  if (treeview == 0)
+    return;
+
+  selection = gtk_tree_view_get_selection (treeview);
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+  {
+    DBG_WARN ("no current selection\n");
+    return;
+  }
+  if (gtk_tree_model_iter_next (model, &iter))
+  {
+    path = gtk_tree_model_get_path (model, &iter);
+    gtk_tree_view_set_cursor (treeview, path, 0, 0);
+    gtk_tree_path_free (path);
+    return;
+  }
+
+  return;
+}
+
+
+void
+cb_tool_button_history_delete_clicked (GtkButton * button,
+                                       MOKO_DIALER_APP_DATA * appdata)
+{
+  GtkTreeIter iter;             //iter of the filter store
+  GtkTreeIter iter0;            //iter of the back store
+  GtkTreeModel *model;
+  GtkTreeModel *model0;
+  GtkTreeSelection *selection;
+  GtkTreeView *treeview;
+  GtkTreePath *path;
+  treeview = GTK_TREE_VIEW (appdata->treeview_history);
+  selection = gtk_tree_view_get_selection (treeview);
+
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+  {
+    return;
+  }
+
+  if (appdata->g_currentselected)
+  {
+    DBG_MESSAGE ("to delete %s", appdata->g_currentselected->number);
+    history_delete_entry (&(appdata->g_historylist),
+                          appdata->g_currentselected);
+  }
+
+  path = gtk_tree_model_get_path (model, &iter);
+
+
+  model0 = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
+
+
+  gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER
+                                                    (model), &iter0, &iter);
+
+  gtk_list_store_remove (GTK_LIST_STORE (model0), &iter0);
+
+
+  gtk_tree_view_set_cursor (treeview, path, 0, 0);
+
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+  {
+    if (!gtk_tree_path_prev (path))
+    {
+      gtk_tree_view_set_cursor (treeview, path, 0, 0);
+      DBG_WARN ("history is empty now!");
+      history_update_counter (appdata);
+    }
+    else
+    {
+      gtk_tree_view_set_cursor (treeview, path, 0, 0);
+    }
+    //we deleted the last one.
+
+  }
+
+  gtk_tree_path_free (path);
+
+  return;
+
+  DBG_ENTER ();
+}
+
+void
+cb_tool_button_history_call_clicked (GtkButton * button,
+                                     MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+
+
+
+}
+
+void
+cb_tool_button_history_sms_clicked (GtkButton * button,
+                                    MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+
+
+
+}
+
+void
+cb_tool_button_history_back_clicked (GtkButton * button,
+                                     MOKO_DIALER_APP_DATA * appdata)
+{
+  gtk_widget_hide (appdata->window_history);
+
+}
+
+
+void
+on_window_history_hide (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata)
+{
+
+  gtk_widget_hide (appdata->wheel_history);
+  gtk_widget_hide (appdata->toolbox_history);
+
+}
+
+void
+on_window_history_show (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+
+  if (appdata->wheel_history)
+    gtk_widget_show (appdata->wheel_history);
+
+  if (appdata->toolbox_history)
+    gtk_widget_show (appdata->toolbox_history);
+
+  if (appdata->history_need_to_update)
+  {
+    DBG_MESSAGE ("NEED TO UPDATE HISTORY");
+  }
+
+  DBG_LEAVE ();
+}
+
+
+
+
+gint
+window_history_init (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+
+  DBG_ENTER ();
+
+
+  if (p_dialer_data->window_history == 0)
+  {
+
+    history_create_menu_history (p_dialer_data);
+
+    MokoFingerWindow *window = NULL;
+    MokoFingerToolBox *tools = NULL;
+    GtkWidget *button;
+    GtkWidget *image;
+
+//now the container--window
+    window = MOKO_FINGER_WINDOW (moko_finger_window_new ());
+    p_dialer_data->window_history = window;
+
+
+    moko_finger_window_set_contents (window,
+                                     create_window_history_content
+                                     (p_dialer_data));
+
+    g_signal_connect ((gpointer) window, "show",
+                      G_CALLBACK (on_window_history_show), p_dialer_data);
+    g_signal_connect ((gpointer) window, "hide",
+                      G_CALLBACK (on_window_history_hide), p_dialer_data);
+
+
+
+    gtk_widget_show_all (GTK_WIDGET (window));
+
+//the gtk_widget_show_all is really bad, cause i have to call it and then hide some widgets.
+
+
+    //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_history_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_history_wheel_press_right_down_cb),
+                      p_dialer_data);
+
+
+
+    tools = moko_finger_window_get_toolbox (window);
+
+    button = moko_finger_tool_box_add_button_without_label (tools);
+    image = file_new_image_from_relative_path ("phone.png");
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image);
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_tool_button_history_call_clicked),
+                      p_dialer_data);
+
+    button = moko_finger_tool_box_add_button_without_label (tools);
+    image = file_new_image_from_relative_path ("sms.png");
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image);
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_tool_button_history_sms_clicked),
+                      p_dialer_data);
+
+
+    button = moko_finger_tool_box_add_button_without_label (tools);
+    image = file_new_image_from_relative_path ("delete.png");
+    moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image);
+    g_signal_connect (G_OBJECT (button), "clicked",
+                      G_CALLBACK (cb_tool_button_history_delete_clicked),
+                      p_dialer_data);
+    gtk_widget_show (GTK_WIDGET (tools));
+
+    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_history_back_clicked),
+                      p_dialer_data);
+    gtk_widget_show (GTK_WIDGET (tools));
+
+    p_dialer_data->wheel_history = moko_finger_window_get_wheel (window);
+    p_dialer_data->toolbox_history = tools;
+
+    gtk_widget_hide (window);
+
+    DBG_LEAVE ();
+  }
+  else
+  {
+    //here we have to refresh it.
+    DBG_TRACE ();
+  }
+  return 1;
+}
+
+void
+on_treeviewHistory_cursor_changed (GtkTreeView * treeview, gpointer user_data)
+{
+  GtkTreeIter iter;
+  GtkTreeModel *model;
+  GtkTreeSelection *selection;
+  HISTORY_ENTRY *p;
+  int hasname;
+  MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data;
+
+  selection = gtk_tree_view_get_selection (p_dialer_data->treeview_history);
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+  {
+    p_dialer_data->g_currentselected = 0;
+    return;
+  }
+
+  gtk_tree_model_get (model, &iter, COLUMN_ENTRYPOINTER, &p, -1);
+
+  p_dialer_data->g_currentselected = p;
+
+  gtk_tree_model_get (model, &iter, COLUMN_HASNAME, &hasname, -1);
+  history_update_counter (p_dialer_data);
+
+}
+
+
+
+GtkWidget *
+create_window_history_content (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+
+  GtkWidget *treeviewHistory;
+  GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
+  //FIRST of all, the top title area;
+  GtkWidget *eventboxTop = gtk_event_box_new ();
+  gtk_widget_show (eventboxTop);
+  gtk_box_pack_start (GTK_BOX (vbox), eventboxTop, FALSE, FALSE, 5);
+  gtk_widget_set_size_request (eventboxTop, 480, 64);
+  gtk_widget_set_name (eventboxTop, "gtkeventbox-black");
+
+  GtkWidget *hbox67 = gtk_hbox_new (FALSE, 0);
+  gtk_widget_show (hbox67);
+  gtk_container_add (GTK_CONTAINER (eventboxTop), hbox67);
+
+  GtkWidget *eventboxLeftTop = gtk_event_box_new ();
+  gtk_widget_show (eventboxLeftTop);
+  gtk_box_pack_start (GTK_BOX (hbox67), eventboxLeftTop, FALSE, TRUE, 0);
+  gtk_widget_set_name (eventboxLeftTop, "gtkeventbox-black");
+
+
+
+  GtkWidget *imageLeftMenu = file_new_image_from_relative_path ("all.png");
+  gtk_widget_show (imageLeftMenu);
+  gtk_container_add (GTK_CONTAINER (eventboxLeftTop), imageLeftMenu);
+
+  GtkWidget *labelHistoryTitle = gtk_label_new (("History-"));
+  gtk_widget_show (labelHistoryTitle);
+  gtk_box_pack_start (GTK_BOX (hbox67), labelHistoryTitle, FALSE, FALSE, 0);
+  gtk_widget_set_size_request (labelHistoryTitle, 221, -1);
+  gtk_label_set_justify (GTK_LABEL (labelHistoryTitle), GTK_JUSTIFY_RIGHT);
+  gtk_misc_set_alignment (GTK_MISC (labelHistoryTitle), 1, 0.5);
+
+  GtkWidget *labelFilter = gtk_label_new (("All"));
+  gtk_widget_show (labelFilter);
+  gtk_box_pack_start (GTK_BOX (hbox67), labelFilter, TRUE, TRUE, 0);
+  gtk_misc_set_alignment (GTK_MISC (labelFilter), 0, 0.5);
+  p_dialer_data->label_filter_history = labelFilter;
+
+  GtkWidget *labelCounter = gtk_label_new (("1/21"));
+  gtk_widget_show (labelCounter);
+  gtk_box_pack_start (GTK_BOX (hbox67), labelCounter, TRUE, TRUE, 0);
+  gtk_label_set_justify (GTK_LABEL (labelCounter), GTK_JUSTIFY_RIGHT);
+  gtk_misc_set_alignment (GTK_MISC (labelCounter), 0.8, 0.5);
+  p_dialer_data->label_counter_history = labelCounter;
+
+  g_signal_connect ((gpointer) eventboxTop, "button_release_event",
+                    G_CALLBACK (on_eventboxTop_button_release_event),
+                    p_dialer_data);
+
+  GtkWidget *align = gtk_alignment_new (0, 0, 1, 1);
+  gtk_alignment_set_padding (align, 0, 150, 0, 0);      //FIXME too many numbers has to be retrieved from style
+
+  GtkWidget *scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
+  gtk_widget_show (scrolledwindow);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
+                                  GTK_POLICY_NEVER, GTK_POLICY_NEVER);
+
+  treeviewHistory = gtk_tree_view_new ();
+  gtk_container_add (GTK_CONTAINER (align), scrolledwindow);
+  gtk_container_add (GTK_CONTAINER (scrolledwindow), treeviewHistory);
+
+  gtk_widget_show (treeviewHistory);
+  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeviewHistory), FALSE);
+  gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeviewHistory), FALSE);
+//   gtk_misc_set_alignment (GTK_MISC (treeviewHistory), 0.5, 0.5);
+  gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
+
+
+  gtk_widget_set_name (treeviewHistory, "gtktreeview-black");
+  p_dialer_data->treeview_history = treeviewHistory;
+  history_build_history_list_view (p_dialer_data);
+  gtk_widget_set_size_request (scrolledwindow, -1, 400);
+//  gtk_misc_set_alignment (GTK_MISC (treeviewHistory),1,0.1);
+
+
+  g_signal_connect ((gpointer) treeviewHistory, "cursor_changed",
+                    G_CALLBACK (on_treeviewHistory_cursor_changed),
+                    p_dialer_data);
+
+
+  return vbox;
+}
+
+
+/**
+ * @brief re-filter the treeview widget by current history type,a callback when the history treeview refreshes
+ *
+ * this callback will be called for every treemodel iters,whenever the treeview filter is refreshing
+ *
+ * @param model GtkTreeModel *, the background database of the treeview
+ * @param iter GtkTreeIter *, the iterator of every item of the model.
+ * @param  data gpointer , of no use currently
+ * @return boolean
+ * @retval TRUE means the iter will be displayed
+ * @retval  FALSE means the iter will not be displayed
+ */
+static gboolean
+history_view_filter_visible_function (GtkTreeModel * model,
+                                      GtkTreeIter * iter, gpointer data)
+{
+  MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) data;
+  HISTORY_TYPE type;
+  if (p_dialer_data->g_history_filter_type == ALL)
+    return TRUE;
+  gtk_tree_model_get (model, iter, COLUMN_TYPE, &type, -1);
+  if (type == p_dialer_data->g_history_filter_type)
+    return TRUE;
+  else
+    return FALSE;
+}
+
+
+
+/**
+ * @brief find the treeview in the window, fill-in the data and show it on the screen.
+ *
+ *
+ *
+ * @param window GtkWidget* the window which contains the history treeview. but it's not necessarilly
+ *to be a window, any widget that can help to lookup the treeview will be OK.
+ * @return 
+ * @retval 0 error occured
+ * @retval 1 everything is OK
+ */
+
+gint
+history_build_history_list_view (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+  GtkListStore *list_store;
+
+  GtkTreeIter iter;
+  HISTORY_ENTRY *entry;
+
+  //copied
+  GtkTreeViewColumn *col;
+  GtkCellRenderer *renderer;
+
+  //GtkTreeModel        *model;
+  GtkWidget *contactview = NULL;
+
+  //DBG_ENTER();
+  //DBG_MESSAGE("History:%d",g_historylist.length);
+
+  //DBG_TRACE();
+  p_dialer_data->g_history_filter_type = ALL;
+  contactview = p_dialer_data->treeview_history;
+
+  if (contactview == NULL)
+    return 0;
+//pack image and label
+  col = gtk_tree_view_column_new ();
+
+  gtk_tree_view_column_set_title (col, ("Title"));
+  gtk_tree_view_column_set_resizable (col, TRUE);
+
+
+
+  renderer = gtk_cell_renderer_pixbuf_new ();
+  gtk_tree_view_column_pack_start (col, renderer, FALSE);
+  gtk_tree_view_column_set_attributes (col, renderer,
+                                       "pixbuf", COLUMN_TYPEICON, NULL);
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_tree_view_column_pack_start (col, renderer, FALSE);
+  gtk_tree_view_column_set_attributes (col, renderer,
+                                       "text", COLUMN_TIME, NULL);
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_tree_view_column_pack_start (col, renderer, FALSE);
+  gtk_tree_view_column_set_attributes (col, renderer,
+                                       "text", COLUMN_SEPRATE, NULL);
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_tree_view_column_pack_start (col, renderer, TRUE);
+  gtk_tree_view_column_set_attributes (col, renderer,
+                                       "text", COLUMN_NAME_NUMBER, NULL);
+
+
+  gtk_tree_view_append_column (GTK_TREE_VIEW (contactview), col);
+
+
+  entry = p_dialer_data->g_historylist.first;
+
+  list_store = gtk_list_store_new (N_COLUMN, G_TYPE_INT, GDK_TYPE_PIXBUF,
+                                   G_TYPE_STRING, G_TYPE_STRING,
+                                   G_TYPE_STRING, G_TYPE_INT, G_TYPE_POINTER,
+                                   G_TYPE_INT, -1);
+  //we will use a filter to facilitate the filtering in treeview without rebuilding the database.                         
+  p_dialer_data->g_list_store_filter =
+    gtk_tree_model_filter_new (GTK_TREE_MODEL (list_store), NULL);
+  gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER
+                                          (p_dialer_data->
+                                           g_list_store_filter),
+                                          history_view_filter_visible_function,
+                                          p_dialer_data, NULL);
+
+//load the three icons to memory.
+  GError *error = NULL;
+  p_dialer_data->g_iconReceived = create_pixbuf ("received.png", &error);
+  if (error)
+  {
+    DBG_WARN ("Cound not load icon :%s", error->message);
+    g_error_free (error);
+    p_dialer_data->g_iconReceived = NULL;
+    error = NULL;
+  }
+
+  p_dialer_data->g_iconDialed = create_pixbuf ("dialed.png", &error);
+  if (error)
+  {
+    DBG_WARN ("Cound not load icon :%s", error->message);
+    g_error_free (error);
+    p_dialer_data->g_iconDialed = NULL;
+    error = NULL;
+  }
+
+
+  p_dialer_data->g_iconMissed = create_pixbuf ("missed.png", &error);
+  if (error)
+  {
+    DBG_WARN ("Cound not load icon :%s", error->message);
+    g_error_free (error);
+    p_dialer_data->g_iconMissed = NULL;
+    error = NULL;
+  }
+
+
+  while (entry)
+  {
+    //DBG_MESSAGE(entry->number);
+    gtk_list_store_append (list_store, &iter);
+    gtk_list_store_set (list_store, &iter, COLUMN_TYPE, entry->type,
+                        COLUMN_SEPRATE, "--", COLUMN_TIME, entry->time,
+                        COLUMN_DURATION, entry->durationsec,
+                        COLUMN_ENTRYPOINTER, entry, COLUMN_HASNAME, 0, -1);
+    if (entry->name == 0)
+    {
+      //DBG_MESSAGE(entry->number);
+      gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER,
+                          entry->number, -1);
+      gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 0, -1);
+    }
+    else
+    {
+      gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER, entry->name,
+                          -1);
+      gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 1, -1);
+    }
+    switch (entry->type)
+    {
+      case INCOMING:
+        {
+          gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                              p_dialer_data->g_iconReceived, -1);
+          //      icon=gdk_pixbuf_new_from_file("./received.png",&error);
+          break;
+        }
+      case OUTGOING:
+        {                       //     icon=gdk_pixbuf_new_from_file("./dialed.png",&error);
+          gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                              p_dialer_data->g_iconDialed, -1);
+          break;
+        }
+      case MISSED:
+        {                       //icon=gdk_pixbuf_new_from_file("./missed.png",&error);
+          gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                              p_dialer_data->g_iconMissed, -1);
+          break;
+        }
+
+      default:
+
+        {                       //icon=gdk_pixbuf_new_from_file("./missed.png",&error);
+          gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                              p_dialer_data->g_iconMissed, -1);
+          break;
+        }
+    }
+
+
+
+    entry = entry->next;
+  }
+
+  gtk_tree_view_set_model (GTK_TREE_VIEW (contactview),
+                           GTK_TREE_MODEL (p_dialer_data->
+                                           g_list_store_filter));
+
+  g_object_unref (list_store);
+
+  return 1;
+}
+
+
+/**
+ * @brief update the counter display widget - labelCounter
+ *
+ * @param widget GtkWidget*, any widget in the same window with treeviewHistory and labelCounter
+ *
+ * @return 1
+ */
+gint
+history_update_counter (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+  DBG_ENTER ();
+  GtkTreeIter iter;
+  GtkTreeModel *model;
+  GtkTreeSelection *selection;
+  GtkTreePath *path;
+  GtkTreeView *treeview;
+  int count = 0;
+  int nth = 0;
+  char *pathstring;
+  char display[10];
+
+  treeview = GTK_TREE_VIEW (p_dialer_data->treeview_history);
+  if (!p_dialer_data->treeview_history)
+  {
+    DBG_WARN ("COUNTER NOT READY ");
+    return 0;
+  }
+
+
+  model = gtk_tree_view_get_model (treeview);
+
+  count = gtk_tree_model_iter_n_children (model, NULL);
+
+  selection = gtk_tree_view_get_selection (treeview);
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+  {
+    nth = 0;
+  }
+  else
+  {
+    path = gtk_tree_model_get_path (model, &iter);
+    pathstring = gtk_tree_path_to_string (path);
+    nth = atoi (pathstring) + 1;
+    gtk_tree_path_free (path);
+
+  }
+
+  GtkWidget *labelcounter;
+  labelcounter = p_dialer_data->label_counter_history;
+  sprintf (display, "%d/%d", nth, count);
+  gtk_label_set_text (GTK_LABEL (labelcounter), display);
+  return 1;
+
+}
+
+GtkWidget *
+history_create_menu_history (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+  if (!p_dialer_data->menu_history)
+  {
+    GtkWidget *menu_history;
+    GtkWidget *all_calls;
+    GtkWidget *imageAll;
+    GtkWidget *separator1;
+    GtkWidget *missed_calls;
+    GtkWidget *imageMissed;
+    GtkWidget *separator3;
+    GtkWidget *dialed_calls;
+    GtkWidget *imageDialed;
+    GtkWidget *separator2;
+    GtkWidget *received_calls;
+    GtkWidget *imageReceived;
+
+    menu_history = gtk_menu_new ();
+    gtk_container_set_border_width (GTK_CONTAINER (menu_history), 2);
+
+    all_calls = gtk_image_menu_item_new_with_mnemonic (("Calls All"));
+    gtk_widget_show (all_calls);
+    gtk_container_add (GTK_CONTAINER (menu_history), all_calls);
+    gtk_widget_set_size_request (all_calls, 250, 60);
+
+
+    imageAll = file_new_image_from_relative_path ("all.png");
+    gtk_widget_show (imageAll);
+    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (all_calls), imageAll);
+
+    separator1 = gtk_separator_menu_item_new ();
+    gtk_widget_show (separator1);
+    gtk_container_add (GTK_CONTAINER (menu_history), separator1);
+    gtk_widget_set_size_request (separator1, 120, -1);
+    gtk_widget_set_sensitive (separator1, FALSE);
+
+    missed_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Missed "));
+    gtk_widget_show (missed_calls);
+    gtk_container_add (GTK_CONTAINER (menu_history), missed_calls);
+    gtk_widget_set_size_request (missed_calls, 120, 60);
+
+    //imageMissed = gtk_image_new_from_stock ("gtk-goto-bottom", GTK_ICON_SIZE_MENU);
+    imageMissed = file_new_image_from_relative_path ("missed.png");
+
+    gtk_widget_show (imageMissed);
+    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (missed_calls),
+                                   imageMissed);
+
+    separator3 = gtk_separator_menu_item_new ();
+    gtk_widget_show (separator3);
+    gtk_container_add (GTK_CONTAINER (menu_history), separator3);
+    gtk_widget_set_size_request (separator3, 120, -1);
+    gtk_widget_set_sensitive (separator3, FALSE);
+
+    dialed_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Dialed"));
+    gtk_widget_show (dialed_calls);
+    gtk_container_add (GTK_CONTAINER (menu_history), dialed_calls);
+    gtk_widget_set_size_request (dialed_calls, 120, 60);
+
+    // imageDialed = gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_MENU);
+    imageDialed = file_new_image_from_relative_path ("dialed.png");
+    gtk_widget_show (imageDialed);
+    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (dialed_calls),
+                                   imageDialed);
+
+    separator2 = gtk_separator_menu_item_new ();
+    gtk_widget_show (separator2);
+    gtk_container_add (GTK_CONTAINER (menu_history), separator2);
+    gtk_widget_set_size_request (separator2, 120, -1);
+    gtk_widget_set_sensitive (separator2, FALSE);
+
+    received_calls =
+      gtk_image_menu_item_new_with_mnemonic (("Calls Received "));
+    gtk_widget_show (received_calls);
+    gtk_container_add (GTK_CONTAINER (menu_history), received_calls);
+    gtk_widget_set_size_request (received_calls, 120, 60);
+
+//  imageReceived = gtk_image_new_from_stock ("gtk-go-down", GTK_ICON_SIZE_MENU);
+    imageReceived = file_new_image_from_relative_path ("received.png");
+    gtk_widget_show (imageReceived);
+    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (received_calls),
+                                   imageReceived);
+
+    g_signal_connect ((gpointer) all_calls, "activate",
+                      G_CALLBACK (on_all_calls_activate), p_dialer_data);
+    g_signal_connect ((gpointer) missed_calls, "activate",
+                      G_CALLBACK (on_missed_calls_activate), p_dialer_data);
+    g_signal_connect ((gpointer) dialed_calls, "activate",
+                      G_CALLBACK (on_dialed_calls_activate), p_dialer_data);
+    g_signal_connect ((gpointer) received_calls, "activate",
+                      G_CALLBACK (on_received_calls_activate), p_dialer_data);
+
+    p_dialer_data->menu_history = menu_history;
+    return menu_history;
+  }
+  else
+    return p_dialer_data->menu_history;
+}
+
+
+
+/**
+ * @brief add an entry to the history treeview
+ *
+ *
+ *
+ * @param entry HISTORY_ENTRY *, the history entry to be added to the treeview.
+ * @return 
+ * @retval 0 error occured
+ * @retval 1 everything is OK
+ */
+gint
+history_list_view_add (MOKO_DIALER_APP_DATA * appdata, HISTORY_ENTRY * entry)
+{
+  DBG_ENTER ();
+  if (entry == 0)
+  {
+    DBG_ERROR ("THE ENTRY IS ZERO");
+    return 0;
+  }
+
+  if (appdata->treeview_history == 0)
+  {
+    DBG_WARN ("not ready");
+    return 0;
+
+  }
+  //
+  GtkTreeIter iter;             //iter of the filter store
+  GtkTreeModel *model;
+  GtkListStore *list_store;
+  GtkTreeView *treeview;
+
+  treeview = GTK_TREE_VIEW (appdata->treeview_history);
+
+  model =
+    gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER
+                                     (appdata->g_list_store_filter));
+
+  list_store = GTK_LIST_STORE (model);
+  //
+
+
+  //DBG_MESSAGE(entry->number);
+  gtk_list_store_insert (list_store, &iter, 0);
+  gtk_list_store_set (list_store, &iter, COLUMN_TYPE, entry->type,
+                      COLUMN_SEPRATE, "--", COLUMN_TIME, entry->time,
+                      COLUMN_DURATION, entry->durationsec,
+                      COLUMN_ENTRYPOINTER, entry, COLUMN_HASNAME, 0, -1);
+  if (entry->name == 0)
+  {
+    //DBG_MESSAGE(entry->number);
+    gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER, entry->number,
+                        -1);
+    gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 0, -1);
+  }
+  else
+  {
+    gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER, entry->name,
+                        -1);
+    gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 1, -1);
+  }
+  switch (entry->type)
+  {
+    case INCOMING:
+      {
+        gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                            appdata->g_iconReceived, -1);
+        //      icon=gdk_pixbuf_new_from_file("./received.png",&error);
+        break;
+      }
+    case OUTGOING:
+      {                         //     icon=gdk_pixbuf_new_from_file("./dialed.png",&error);
+        gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                            appdata->g_iconDialed, -1);
+        break;
+      }
+    case MISSED:
+      {                         //icon=gdk_pixbuf_new_from_file("./missed.png",&error);
+        gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                            appdata->g_iconMissed, -1);
+        break;
+      }
+
+    default:
+
+      {                         //icon=gdk_pixbuf_new_from_file("./missed.png",&error);
+        gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
+                            appdata->g_iconMissed, -1);
+        break;
+      }
+  }
+  history_update_counter (appdata);
+  return 1;
+}
+
+
+gint
+add_histroy_entry (MOKO_DIALER_APP_DATA * appdata, HISTORY_TYPE type,
+                   const char *name, const char *number, const char *id,
+                   char *time, char *date, int durationsec)
+{
   
-}
-
-void cb_tool_button_history_sms_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-	DBG_ENTER();
-	
-
-  
-}
-
-void cb_tool_button_history_back_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-     gtk_widget_hide(appdata->window_history);
-     
-}
-
-
-void
-on_window_history_hide                 (GtkWidget       *widget,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-
-gtk_widget_hide(appdata->wheel_history);
-gtk_widget_hide(appdata->toolbox_history);
-
-}
-
-void
-on_window_history_show                  (GtkWidget       *widget,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-
-if(appdata->wheel_history)
-gtk_widget_show(appdata->wheel_history);
-
-if(appdata->toolbox_history)
-gtk_widget_show(appdata->toolbox_history);
-
-if(appdata->history_need_to_update)
-{
-DBG_MESSAGE("NEED TO UPDATE HISTORY");
-}
-   
-DBG_LEAVE();
-}
-
-
-
-
-gint window_history_init( MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-
-DBG_ENTER();
-
-
-if(p_dialer_data->window_history==0)
-{
-
-	 history_create_menu_history (p_dialer_data);
-
-	MokoFingerWindow* window=NULL;
-      MokoFingerToolBox *tools = NULL;
-	GtkWidget* button;
-	GtkWidget* image;
-
-//now the container--window
-     window = MOKO_FINGER_WINDOW(moko_finger_window_new());
-     p_dialer_data->window_history=window;
-
-    
-     moko_finger_window_set_contents(window, create_window_history_content(p_dialer_data));
-
-     g_signal_connect ((gpointer) window, "show",
-	                    G_CALLBACK (on_window_history_show),
-	                    p_dialer_data);
-    g_signal_connect ((gpointer) window, "hide",
-	                    G_CALLBACK (on_window_history_hide),
-	                    p_dialer_data);
-
-    
-     
-     gtk_widget_show_all( GTK_WIDGET(window) );
-
-//the gtk_widget_show_all is really bad, cause i have to call it and then hide some widgets.
-
-
- //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_history_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_history_wheel_press_right_down_cb),
-		    p_dialer_data);
-
-
-
-        tools = moko_finger_window_get_toolbox(window);
-     
-	button = moko_finger_tool_box_add_button_without_label(tools);
-       image = file_new_image_from_relative_path("phone.png");
-	moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image);
-        g_signal_connect(G_OBJECT(button), "clicked",
-			G_CALLBACK(cb_tool_button_history_call_clicked), p_dialer_data);
-	
-	button = moko_finger_tool_box_add_button_without_label(tools);
-       image = file_new_image_from_relative_path("sms.png");
-	moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image);
-	g_signal_connect(G_OBJECT(button), "clicked",
-			G_CALLBACK(cb_tool_button_history_sms_clicked), p_dialer_data);
-	
-
-	button = moko_finger_tool_box_add_button_without_label(tools);
-       image = file_new_image_from_relative_path("delete.png");
-	moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image);
-	g_signal_connect(G_OBJECT(button), "clicked",
-			G_CALLBACK(cb_tool_button_history_delete_clicked), p_dialer_data);
-	gtk_widget_show(GTK_WIDGET(tools));
-
-	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_history_back_clicked), p_dialer_data);
-	gtk_widget_show(GTK_WIDGET(tools));
-	
-	p_dialer_data->wheel_history=moko_finger_window_get_wheel(window);
-	p_dialer_data->toolbox_history=tools;
-
-	gtk_widget_hide(window);
-
-	DBG_LEAVE();
-}
-else
-{
-	//here we have to refresh it.
-	DBG_TRACE();
-}
-    return 1;
-}
-
-void on_treeviewHistory_cursor_changed      (GtkTreeView     *treeview,
-                                        gpointer         user_data)
-{
-GtkTreeIter iter;
-GtkTreeModel* model;
-GtkTreeSelection * selection;
-HISTORY_ENTRY * p;
-int hasname;
-MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data;
-	
-selection = gtk_tree_view_get_selection(p_dialer_data->treeview_history);
- 
-if (!gtk_tree_selection_get_selected(selection, &model, &iter))
- {
- 	 p_dialer_data->g_currentselected=0;
-	 return ;
- }
-	
-gtk_tree_model_get(model,&iter,COLUMN_ENTRYPOINTER,&p,-1);
-
- p_dialer_data->g_currentselected=p;
-
-gtk_tree_model_get(model,&iter,COLUMN_HASNAME,&hasname,-1);
-history_update_counter(p_dialer_data);
-
-}
-
-
-
-GtkWidget* create_window_history_content (MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-
-  GtkWidget *treeviewHistory;
-  GtkWidget *vbox=gtk_vbox_new(FALSE,0); 
-  //FIRST of all, the top title area;
-  GtkWidget *eventboxTop = gtk_event_box_new ();
-  gtk_widget_show (eventboxTop);
-  gtk_box_pack_start(GTK_BOX(vbox),eventboxTop,FALSE,FALSE,5);
-  gtk_widget_set_size_request (eventboxTop, 480, 64);
-  gtk_widget_set_name(eventboxTop,"gtkeventbox-black");
-	
-  GtkWidget *  hbox67 = gtk_hbox_new (FALSE, 0);
-  gtk_widget_show (hbox67);
-  gtk_container_add (GTK_CONTAINER (eventboxTop), hbox67);
-
-  GtkWidget * eventboxLeftTop = gtk_event_box_new ();
-  gtk_widget_show (eventboxLeftTop);
-  gtk_box_pack_start (GTK_BOX (hbox67), eventboxLeftTop, FALSE, TRUE, 0);
-  gtk_widget_set_name(eventboxLeftTop,"gtkeventbox-black");
-
-
-
-  GtkWidget * imageLeftMenu =file_new_image_from_relative_path("all.png");
-  gtk_widget_show (imageLeftMenu);
-  gtk_container_add (GTK_CONTAINER (eventboxLeftTop), imageLeftMenu);
-
-  GtkWidget *labelHistoryTitle = gtk_label_new (("History-"));
-  gtk_widget_show (labelHistoryTitle);
-  gtk_box_pack_start (GTK_BOX (hbox67), labelHistoryTitle, FALSE, FALSE, 0);
-  gtk_widget_set_size_request (labelHistoryTitle, 221, -1);
-  gtk_label_set_justify (GTK_LABEL (labelHistoryTitle), GTK_JUSTIFY_RIGHT);
-  gtk_misc_set_alignment (GTK_MISC (labelHistoryTitle), 1, 0.5);
-
-  GtkWidget *labelFilter = gtk_label_new (("All"));
-  gtk_widget_show (labelFilter);
-  gtk_box_pack_start (GTK_BOX (hbox67), labelFilter, TRUE, TRUE, 0);
-  gtk_misc_set_alignment (GTK_MISC (labelFilter), 0, 0.5);
-  p_dialer_data->label_filter_history=labelFilter;
-
-  GtkWidget *labelCounter = gtk_label_new (("1/21"));
-  gtk_widget_show (labelCounter);
-  gtk_box_pack_start (GTK_BOX (hbox67), labelCounter, TRUE, TRUE, 0);
-  gtk_label_set_justify (GTK_LABEL (labelCounter), GTK_JUSTIFY_RIGHT);
-  gtk_misc_set_alignment (GTK_MISC (labelCounter), 0.8, 0.5);
-  p_dialer_data->label_counter_history=labelCounter;
- 
-    g_signal_connect ((gpointer) eventboxTop, "button_release_event",
-                    G_CALLBACK (on_eventboxTop_button_release_event),
-                    p_dialer_data);
-
-  GtkWidget *align=gtk_alignment_new(0,0,1,1);
-  gtk_alignment_set_padding(align, 0, 150, 0, 0); //FIXME too many numbers has to be retrieved from style
-  
-  GtkWidget *scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
-  gtk_widget_show (scrolledwindow);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_NEVER);
- 
-  treeviewHistory = gtk_tree_view_new ();
-  gtk_container_add (GTK_CONTAINER (align), scrolledwindow);
-  gtk_container_add (GTK_CONTAINER (scrolledwindow), treeviewHistory);
-
-  gtk_widget_show (treeviewHistory);
-  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeviewHistory), FALSE);
-  gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeviewHistory), FALSE);
-//   gtk_misc_set_alignment (GTK_MISC (treeviewHistory), 0.5, 0.5);
-  gtk_box_pack_start(GTK_BOX(vbox),align,TRUE,TRUE,0);
-
-
-  gtk_widget_set_name(treeviewHistory,"gtktreeview-black");
-  p_dialer_data->treeview_history=treeviewHistory;
-   history_build_history_list_view(p_dialer_data);
-  gtk_widget_set_size_request (scrolledwindow, -1, 400);    
-//  gtk_misc_set_alignment (GTK_MISC (treeviewHistory),1,0.1);
-
-
-  g_signal_connect ((gpointer) treeviewHistory, "cursor_changed",
-                    G_CALLBACK (on_treeviewHistory_cursor_changed),
-                    p_dialer_data);
-
-
-  return vbox;
-}
-
-
-/**
- * @brief re-filter the treeview widget by current history type,a callback when the history treeview refreshes
- *
- * this callback will be called for every treemodel iters,whenever the treeview filter is refreshing
- *
- * @param model GtkTreeModel *, the background database of the treeview
- * @param iter GtkTreeIter *, the iterator of every item of the model.
- * @param  data gpointer , of no use currently
- * @return boolean
- * @retval TRUE means the iter will be displayed
- * @retval  FALSE means the iter will not be displayed
- */
-static gboolean history_view_filter_visible_function(GtkTreeModel *model,GtkTreeIter *iter,gpointer data)
-{
-	MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )data;
-	HISTORY_TYPE type;
-	if(p_dialer_data->g_history_filter_type==ALL)
-		return TRUE;
-	gtk_tree_model_get(model,iter,COLUMN_TYPE,&type,-1);
-	if(type==p_dialer_data->g_history_filter_type)
-		return TRUE;
-	else
-		return FALSE;
-}
-
-
-
-/**
- * @brief find the treeview in the window, fill-in the data and show it on the screen.
- *
- *
- *
- * @param window GtkWidget* the window which contains the history treeview. but it's not necessarilly
- *to be a window, any widget that can help to lookup the treeview will be OK.
- * @return 
- * @retval 0 error occured
- * @retval 1 everything is OK
- */
-
-gint history_build_history_list_view(MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-	GtkListStore * list_store;
-	
-	GtkTreeIter iter;
-	HISTORY_ENTRY * entry;
-	
-	//copied
-	GtkTreeViewColumn   *col;
-  	GtkCellRenderer     *renderer;
-  	
-  	//GtkTreeModel        *model;
-	GtkWidget           *contactview=NULL;
-	
-	//DBG_ENTER();
-	//DBG_MESSAGE("History:%d",g_historylist.length);
-	
-	//DBG_TRACE();
-  p_dialer_data->g_history_filter_type=ALL;
-  contactview = p_dialer_data->treeview_history;
-
-  if(contactview == NULL)
-    return 0;
-//pack image and label
-  col = gtk_tree_view_column_new ();
-
-  gtk_tree_view_column_set_title (col, ("Title"));
-  gtk_tree_view_column_set_resizable (col, TRUE);
- 
-	
-  
-  renderer = gtk_cell_renderer_pixbuf_new ();
-  gtk_tree_view_column_pack_start (col, renderer, FALSE);
-  gtk_tree_view_column_set_attributes (col, renderer, 
-  "pixbuf",COLUMN_TYPEICON,NULL);
-
-  renderer = gtk_cell_renderer_text_new ();
-  gtk_tree_view_column_pack_start (col, renderer, FALSE);
-  gtk_tree_view_column_set_attributes(col, renderer, 
-  "text",COLUMN_TIME,NULL);
- 
-  renderer = gtk_cell_renderer_text_new ();
-  gtk_tree_view_column_pack_start (col, renderer, FALSE);
-  gtk_tree_view_column_set_attributes(col, renderer, 
-  "text",COLUMN_SEPRATE,NULL);
- 
-  renderer = gtk_cell_renderer_text_new ();
-  gtk_tree_view_column_pack_start (col, renderer, TRUE);
-  gtk_tree_view_column_set_attributes(col, renderer, 
-  "text",COLUMN_NAME_NUMBER,NULL);
-
-
-   gtk_tree_view_append_column (GTK_TREE_VIEW (contactview), col);
-
-
-	entry=p_dialer_data->g_historylist.first;
-	
-	list_store=gtk_list_store_new(N_COLUMN,	G_TYPE_INT,GDK_TYPE_PIXBUF,
-					G_TYPE_STRING,	G_TYPE_STRING,	
-					G_TYPE_STRING,	G_TYPE_INT,G_TYPE_POINTER,G_TYPE_INT,-1);
-	//we will use a filter to facilitate the filtering in treeview without rebuilding the database.				
-	p_dialer_data->g_list_store_filter=gtk_tree_model_filter_new(GTK_TREE_MODEL(list_store),NULL);
-	gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(p_dialer_data->g_list_store_filter),
-	history_view_filter_visible_function,p_dialer_data,NULL);
-
-//load the three icons to memory.
-GError *error=NULL;	
-		p_dialer_data->g_iconReceived=create_pixbuf("received.png",&error);
-  		if(error)
-				{
-					DBG_WARN("Cound not load icon :%s",error->message);
-					g_error_free(error);
-					p_dialer_data->g_iconReceived=NULL;
-					error=NULL;
-				}
-
-		p_dialer_data->g_iconDialed=create_pixbuf("dialed.png",&error);
-		if(error)
-				{
-					DBG_WARN("Cound not load icon :%s",error->message);
-					g_error_free(error);
-					p_dialer_data->g_iconDialed=NULL;
-					error=NULL;
-				}
-
-  
-		 p_dialer_data->g_iconMissed=create_pixbuf("missed.png",&error);
-		if(error)
-				{
-					DBG_WARN("Cound not load icon :%s",error->message);
-					g_error_free(error);
-					p_dialer_data->g_iconMissed=NULL;
-					error=NULL;
-				}
-
-
-	while(entry)
-	{
-		//DBG_MESSAGE(entry->number);
-		gtk_list_store_append(list_store,&iter);
-		gtk_list_store_set(list_store,&iter,COLUMN_TYPE,entry->type,COLUMN_SEPRATE,"--",
-		COLUMN_TIME,entry->time,COLUMN_DURATION,entry->durationsec,COLUMN_ENTRYPOINTER,entry,COLUMN_HASNAME,0,-1);
-		if(entry->name==0)
-		{
-		//DBG_MESSAGE(entry->number);
-		gtk_list_store_set(list_store,&iter,COLUMN_NAME_NUMBER,entry->number,-1);
-		gtk_list_store_set(list_store,&iter,COLUMN_HASNAME,0,-1);
-		}
-		else
-		{
-		gtk_list_store_set(list_store,&iter,COLUMN_NAME_NUMBER,entry->name,-1);		
-		gtk_list_store_set(list_store,&iter,COLUMN_HASNAME,1,-1);
-		}
-		switch(entry->type)
-		{
-			case INCOMING:
-			{
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,p_dialer_data->g_iconReceived,-1);		
-			//	icon=gdk_pixbuf_new_from_file("./received.png",&error);
-				break;
-			}
-			case OUTGOING:
-			{//	icon=gdk_pixbuf_new_from_file("./dialed.png",&error);
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,p_dialer_data->g_iconDialed,-1);		
-				break;
-			}
-			case MISSED:
-			{	//icon=gdk_pixbuf_new_from_file("./missed.png",&error);
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,p_dialer_data->g_iconMissed,-1);		
-				break;
-			}
-
-			default:
-			
-			{	//icon=gdk_pixbuf_new_from_file("./missed.png",&error);
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,p_dialer_data->g_iconMissed,-1);		
-				break;
-			}
-		}
-						
-
-		
-		entry=entry->next;
-	}
-	
-  gtk_tree_view_set_model (GTK_TREE_VIEW(contactview),GTK_TREE_MODEL(p_dialer_data->g_list_store_filter));
-
-  g_object_unref (list_store);
-
-  return 1;
-}
-
-
-/**
- * @brief update the counter display widget - labelCounter
- *
- * @param widget GtkWidget*, any widget in the same window with treeviewHistory and labelCounter
- *
- * @return 1
- */
-gint history_update_counter(MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-DBG_ENTER();
-GtkTreeIter iter;
-GtkTreeModel* model;
-GtkTreeSelection * selection;
-GtkTreePath *path;
-GtkTreeView * treeview;
-int count=0;
-int nth=0;
-char * pathstring;
-char display[10];
-	
-treeview=GTK_TREE_VIEW(p_dialer_data->treeview_history);
-if(!p_dialer_data->treeview_history)
-{
-DBG_WARN("COUNTER NOT READY ");
-return 0;
-}
-
-
-model=gtk_tree_view_get_model(treeview);	
-
-count=gtk_tree_model_iter_n_children(model,NULL);
-	
-selection = gtk_tree_view_get_selection(treeview);
- 
-if (!gtk_tree_selection_get_selected(selection, &model, &iter))
-{
-	nth=0;
-}
-else
-{
-path=gtk_tree_model_get_path(model,&iter);
-pathstring=gtk_tree_path_to_string(path);
-nth=atoi(pathstring)+1;
-gtk_tree_path_free(path);	
-
-}
-	
-GtkWidget *labelcounter;
-labelcounter=p_dialer_data->label_counter_history;
-sprintf(display,"%d/%d",nth,count);
-gtk_label_set_text(GTK_LABEL(labelcounter),display);
-return 1;	
-
-}
-
-GtkWidget* history_create_menu_history (MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-if(!p_dialer_data->menu_history)
-{
-  GtkWidget *menu_history;
-  GtkWidget *all_calls;
-  GtkWidget *imageAll;
-  GtkWidget *separator1;
-  GtkWidget *missed_calls;
-  GtkWidget *imageMissed;
-  GtkWidget *separator3;
-  GtkWidget *dialed_calls;
-  GtkWidget *imageDialed;
-  GtkWidget *separator2;
-  GtkWidget *received_calls;
-  GtkWidget *imageReceived;
-
-  menu_history = gtk_menu_new ();
-  gtk_container_set_border_width (GTK_CONTAINER (menu_history), 2);
-
-  all_calls = gtk_image_menu_item_new_with_mnemonic (("Calls All"));
-  gtk_widget_show (all_calls);
-  gtk_container_add (GTK_CONTAINER (menu_history), all_calls);
-  gtk_widget_set_size_request (all_calls, 250, 60);
-
-
-  imageAll =file_new_image_from_relative_path("all.png");
-  gtk_widget_show (imageAll);
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (all_calls), imageAll);
-
-  separator1 = gtk_separator_menu_item_new ();
-  gtk_widget_show (separator1);
-  gtk_container_add (GTK_CONTAINER (menu_history), separator1);
-  gtk_widget_set_size_request (separator1, 120, -1);
-  gtk_widget_set_sensitive (separator1, FALSE);
-
-  missed_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Missed "));
-  gtk_widget_show (missed_calls);
-  gtk_container_add (GTK_CONTAINER (menu_history), missed_calls);
-  gtk_widget_set_size_request (missed_calls, 120, 60);
-
-  //imageMissed = gtk_image_new_from_stock ("gtk-goto-bottom", GTK_ICON_SIZE_MENU);
-  imageMissed =file_new_image_from_relative_path("missed.png");
-  
-  gtk_widget_show (imageMissed);
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (missed_calls), imageMissed);
-
-  separator3 = gtk_separator_menu_item_new ();
-  gtk_widget_show (separator3);
-  gtk_container_add (GTK_CONTAINER (menu_history), separator3);
-  gtk_widget_set_size_request (separator3, 120, -1);
-  gtk_widget_set_sensitive (separator3, FALSE);
-
-  dialed_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Dialed"));
-  gtk_widget_show (dialed_calls);
-  gtk_container_add (GTK_CONTAINER (menu_history), dialed_calls);
-  gtk_widget_set_size_request (dialed_calls, 120, 60);
-
- // imageDialed = gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_MENU);
-  imageDialed =file_new_image_from_relative_path("dialed.png");
-  gtk_widget_show (imageDialed);
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (dialed_calls), imageDialed);
-
-  separator2 = gtk_separator_menu_item_new ();
-  gtk_widget_show (separator2);
-  gtk_container_add (GTK_CONTAINER (menu_history), separator2);
-  gtk_widget_set_size_request (separator2, 120, -1);
-  gtk_widget_set_sensitive (separator2, FALSE);
-
-  received_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Received "));
-  gtk_widget_show (received_calls);
-  gtk_container_add (GTK_CONTAINER (menu_history), received_calls);
-  gtk_widget_set_size_request (received_calls, 120, 60);
-
-//  imageReceived = gtk_image_new_from_stock ("gtk-go-down", GTK_ICON_SIZE_MENU);
- imageReceived=file_new_image_from_relative_path("received.png");
-  gtk_widget_show (imageReceived);
-  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (received_calls), imageReceived);
-
-  g_signal_connect ((gpointer) all_calls, "activate",
-                    G_CALLBACK (on_all_calls_activate),
-                    p_dialer_data);
-  g_signal_connect ((gpointer) missed_calls, "activate",
-                    G_CALLBACK (on_missed_calls_activate),
-                    p_dialer_data);
-  g_signal_connect ((gpointer) dialed_calls, "activate",
-                    G_CALLBACK (on_dialed_calls_activate),
-                    p_dialer_data);
-  g_signal_connect ((gpointer) received_calls, "activate",
-                    G_CALLBACK (on_received_calls_activate),
-                    p_dialer_data);
-
-p_dialer_data->menu_history=menu_history;
-  return menu_history;
-}
-else
-	return p_dialer_data->menu_history;
-}
-
-
-
-/**
- * @brief add an entry to the history treeview
- *
- *
- *
- * @param entry HISTORY_ENTRY *, the history entry to be added to the treeview.
- * @return 
- * @retval 0 error occured
- * @retval 1 everything is OK
- */
-gint history_list_view_add(MOKO_DIALER_APP_DATA* appdata,HISTORY_ENTRY * entry)
-{
-DBG_ENTER();
-if(entry==0)
-	{
-		DBG_ERROR("THE ENTRY IS ZERO");
-		return 0;
-	}
-
-if(appdata->treeview_history==0)
-{
-		DBG_WARN("not ready");
-		return 0;
-
-}
-	//
-GtkTreeIter iter; //iter of the filter store
-GtkTreeModel* model;
-GtkListStore* list_store;
-GtkTreeView* treeview;
-
-treeview=GTK_TREE_VIEW(appdata->treeview_history);
-
-model=gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(appdata->g_list_store_filter));	
-
-list_store=GTK_LIST_STORE(model);
-	//
-	
-	
-	//DBG_MESSAGE(entry->number);
-		gtk_list_store_insert(list_store,&iter,0);
-		gtk_list_store_set(list_store,&iter,COLUMN_TYPE,entry->type,COLUMN_SEPRATE,"--",
-		COLUMN_TIME,entry->time,COLUMN_DURATION,entry->durationsec,COLUMN_ENTRYPOINTER,entry,COLUMN_HASNAME,0,-1);
-		if(entry->name==0)
-		{
-		//DBG_MESSAGE(entry->number);
-		gtk_list_store_set(list_store,&iter,COLUMN_NAME_NUMBER,entry->number,-1);
-		gtk_list_store_set(list_store,&iter,COLUMN_HASNAME,0,-1);
-		}
-		else
-		{
-		gtk_list_store_set(list_store,&iter,COLUMN_NAME_NUMBER,entry->name,-1);		
-		gtk_list_store_set(list_store,&iter,COLUMN_HASNAME,1,-1);
-		}
-		switch(entry->type)
-		{
-			case INCOMING:
-			{
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,appdata->g_iconReceived,-1);		
-			//	icon=gdk_pixbuf_new_from_file("./received.png",&error);
-				break;
-			}
-			case OUTGOING:
-			{//	icon=gdk_pixbuf_new_from_file("./dialed.png",&error);
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,appdata->g_iconDialed,-1);		
-				break;
-			}
-			case MISSED:
-			{	//icon=gdk_pixbuf_new_from_file("./missed.png",&error);
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,appdata->g_iconMissed,-1);		
-				break;
-			}
-
-			default:
-			
-			{	//icon=gdk_pixbuf_new_from_file("./missed.png",&error);
-				gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,appdata->g_iconMissed,-1);		
-				break;
-			}
-		}
-history_update_counter(appdata); 
-return 1;	
-}
-
-
-gint add_histroy_entry(MOKO_DIALER_APP_DATA* appdata,HISTORY_TYPE type,const char *name,const char *number,const char *id,  char *time,char *date,int durationsec)
-{
-//DBG_ENTER();
-
-	//DBG_MESSAGE("History add:%s,%s,%s,%s,%s,%d",name,number,picpath,time,date,durationsec);
- HISTORY_ENTRY * pentry=history_add_entry(&(appdata->g_historylist),type,name,number,id,time,date,durationsec);	
- return history_list_view_add(appdata,pentry);	
-}
-
-
+//DBG_ENTER();
+    //DBG_MESSAGE("History add:%s,%s,%s,%s,%s,%d",name,number,picpath,time,date,durationsec);
+    HISTORY_ENTRY * pentry =
+    history_add_entry (&(appdata->g_historylist), type, name, number, id,
+                       time, date, durationsec);
+  return history_list_view_add (appdata, pentry);
+}

Modified: 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-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.c	2007-02-05 09:34:59 UTC (rev 668)
@@ -1,309 +1,320 @@
-/*   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 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);
-
-
-//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();
-gsm_hangup();
-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.ID);  
-   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_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)
-{
-
-DBG_ENTER();
-
-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.ID,
-	appdata->g_state.starttime,
-	appdata->g_state.startdate,
-	0);
-
-}
-
-DBG_LEAVE();     
-}
-
-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)
-{
-
-DBG_ENTER();
-appdata->g_state.callstate=STATE_INCOMING;
-window_incoming_setup_timer(appdata);
-DBG_LEAVE();     
-
-}
-
-
-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;
-}
-
+/*   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 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);
+
+
+//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 ();
+  gsm_hangup ();
+  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.ID);
+    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_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)
+{
+
+  DBG_ENTER ();
+
+  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.ID,
+                       appdata->g_state.starttime,
+                       appdata->g_state.startdate, 0);
+
+  }
+
+  DBG_LEAVE ();
+}
+
+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)
+{
+
+  DBG_ENTER ();
+  appdata->g_state.callstate = STATE_INCOMING;
+  window_incoming_setup_timer (appdata);
+  DBG_LEAVE ();
+
+}
+
+
+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;
+}

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-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.c	2007-02-05 09:34:59 UTC (rev 668)
@@ -1,313 +1,329 @@
-/*   openmoko-dialer-window-outgoing.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 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-outgoing.h"
-
-void cb_speaker_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-//moko_dialer_status_update_icon(appdata->status_outgoing);
-
-
-appdata->g_state.callstate=STATE_TALKING;
-
-gtk_widget_hide(appdata->window_outgoing);
-
-
-//transfer the contact info
-window_talking_prepare(appdata);
-
-//start dialling.
-
-DBG_TRACE();
-gtk_widget_show(appdata->window_talking);
-
-
-DBG_LEAVE();
-}
-
-void cb_redial_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-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)
-{
-DBG_ENTER();
-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.ID);  
-   moko_dialer_status_set_person_name(appdata->status_outgoing, appdata->g_peer_info.name);
-}
-else
-{
-   moko_dialer_status_set_person_image(appdata->status_outgoing, "");  
-   moko_dialer_status_set_person_name(appdata->status_outgoing, "");
-
-}
-strcpy(appdata->g_state.lastnumber,appdata->g_peer_info.number);
-DBG_LEAVE();
-
-}
-
-gint window_outgoing_fails(MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-     moko_dialer_status_set_error(appdata->status_outgoing);
-     moko_dialer_status_set_title_label(appdata->status_outgoing, "Call Failure");
-     gtk_widget_hide( appdata->buttonSpeaker);
-     gtk_widget_show(appdata->buttonRedial);
-DBG_LEAVE();     
-}
-
-gint timer_outgoing_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,"Calling ... (%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_outgoing,timer_data->timestring);
-moko_dialer_status_update_icon(appdata->status_outgoing);
-
-if(timer_data->stopsec!=0&&timer_data->ticks>=timer_data->stopsec)
-{
-
-timer_data->timeout=1;
-gtk_timeout_remove(timer_data->ptimer);
-timer_data->ptimer=0;
-//maybe it failes
-window_outgoing_fails(appdata);
-return 0;//0 stops the timer.
-}
-else
-return 1;
-}
-
-
-
-void
-on_window_outgoing_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;
-}
-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;
-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));
-// 1:30 timeout
-appdata->g_timer_data.stopsec=90;
-
-appdata->g_timer_data.ptimer=gtk_timeout_add(1000,timer_outgoing_time_out,appdata);
-
-
-}
-
-void
-on_window_outgoing_show                  (GtkWidget       *widget,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-
-DBG_ENTER();
-window_outgoing_setup_timer(appdata);
-DBG_TRACE();
-appdata->g_state.callstate=STATE_CALLING;
-DBG_TRACE();
-appdata->g_state.historytype=OUTGOING;	
-DBG_TRACE();
-gsm_dial(appdata->g_peer_info.number);
-DBG_LEAVE();
-
-}
-
-
-gint window_outgoing_init( MOKO_DIALER_APP_DATA* p_dialer_data)
-{
-
-DBG_ENTER();
-MokoFingerWindow* window;
-GtkWidget* vbox;
-MokoDialerStatus * status;
-
-if(p_dialer_data->window_outgoing==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("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, 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, 40 );
-//gtk_widget_set_size_request(button,60,24);
-
-
-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, 40);
-
-
-
-
-   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( p_dialer_data->buttonRedial);
-
-
-     gtk_widget_hide( GTK_WIDGET(window) );   
-
-
-   moko_dialer_status_set_title_label(status, "Outgoing call");
-   moko_dialer_status_set_status_label(status, "Calling ... (00:00:00)");
-
-   p_dialer_data->window_outgoing=window;
-   p_dialer_data->status_outgoing=status;
-   
-//   DBG_MESSAGE("p_dialer_data->status_outgoing=0X%x",p_dialer_data->status_outgoing);
-
-
-  g_signal_connect ((gpointer) window, "show",
-                    G_CALLBACK (on_window_outgoing_show),
-                    p_dialer_data);
-  g_signal_connect ((gpointer) window, "hide",
-                    G_CALLBACK (on_window_outgoing_hide),
-                    p_dialer_data);
-
-}
-
-
-
-// gtk_widget_show(p_dialer_data->window_outgoing);
-
-DBG_LEAVE();
-    return 1;
-}
-
+/*   openmoko-dialer-window-outgoing.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 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-outgoing.h"
+
+void
+cb_speaker_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+//moko_dialer_status_update_icon(appdata->status_outgoing);
+
+
+  appdata->g_state.callstate = STATE_TALKING;
+
+  gtk_widget_hide (appdata->window_outgoing);
+
+
+//transfer the contact info
+  window_talking_prepare (appdata);
+
+//start dialling.
+
+  DBG_TRACE ();
+  gtk_widget_show (appdata->window_talking);
+
+
+  DBG_LEAVE ();
+}
+
+void
+cb_redial_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata)
+{
+  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)
+{
+  DBG_ENTER ();
+  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.ID);
+    moko_dialer_status_set_person_name (appdata->status_outgoing,
+                                        appdata->g_peer_info.name);
+  }
+  else
+  {
+    moko_dialer_status_set_person_image (appdata->status_outgoing, "");
+    moko_dialer_status_set_person_name (appdata->status_outgoing, "");
+
+  }
+  strcpy (appdata->g_state.lastnumber, appdata->g_peer_info.number);
+  DBG_LEAVE ();
+
+}
+
+gint
+window_outgoing_fails (MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  moko_dialer_status_set_error (appdata->status_outgoing);
+  moko_dialer_status_set_title_label (appdata->status_outgoing,
+                                      "Call Failure");
+  gtk_widget_hide (appdata->buttonSpeaker);
+  gtk_widget_show (appdata->buttonRedial);
+  DBG_LEAVE ();
+}
+
+gint
+timer_outgoing_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, "Calling ... (%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_outgoing,
+                                       timer_data->timestring);
+  moko_dialer_status_update_icon (appdata->status_outgoing);
+
+  if (timer_data->stopsec != 0 && timer_data->ticks >= timer_data->stopsec)
+  {
+
+    timer_data->timeout = 1;
+    gtk_timeout_remove (timer_data->ptimer);
+    timer_data->ptimer = 0;
+//maybe it failes
+    window_outgoing_fails (appdata);
+    return 0;                   //0 stops the timer.
+  }
+  else
+    return 1;
+}
+
+
+
+void
+on_window_outgoing_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;
+  }
+  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;
+  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));
+// 1:30 timeout
+  appdata->g_timer_data.stopsec = 90;
+
+  appdata->g_timer_data.ptimer =
+    gtk_timeout_add (1000, timer_outgoing_time_out, appdata);
+
+
+}
+
+void
+on_window_outgoing_show (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata)
+{
+
+  DBG_ENTER ();
+  window_outgoing_setup_timer (appdata);
+  DBG_TRACE ();
+  appdata->g_state.callstate = STATE_CALLING;
+  DBG_TRACE ();
+  appdata->g_state.historytype = OUTGOING;
+  DBG_TRACE ();
+  gsm_dial (appdata->g_peer_info.number);
+  DBG_LEAVE ();
+
+}
+
+
+gint
+window_outgoing_init (MOKO_DIALER_APP_DATA * p_dialer_data)
+{
+
+  DBG_ENTER ();
+  MokoFingerWindow *window;
+  GtkWidget *vbox;
+  MokoDialerStatus *status;
+
+  if (p_dialer_data->window_outgoing == 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 ("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, 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, 40);
+//gtk_widget_set_size_request(button,60,24);
+
+
+    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, 40);
+
+
+
+
+    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 (p_dialer_data->buttonRedial);
+
+
+    gtk_widget_hide (GTK_WIDGET (window));
+
+
+    moko_dialer_status_set_title_label (status, "Outgoing call");
+    moko_dialer_status_set_status_label (status, "Calling ... (00:00:00)");
+
+    p_dialer_data->window_outgoing = window;
+    p_dialer_data->status_outgoing = status;
+
+//   DBG_MESSAGE("p_dialer_data->status_outgoing=0X%x",p_dialer_data->status_outgoing);
+
+
+    g_signal_connect ((gpointer) window, "show",
+                      G_CALLBACK (on_window_outgoing_show), p_dialer_data);
+    g_signal_connect ((gpointer) window, "hide",
+                      G_CALLBACK (on_window_outgoing_hide), p_dialer_data);
+
+  }
+
+
+
+// gtk_widget_show(p_dialer_data->window_outgoing);
+
+  DBG_LEAVE ();
+  return 1;
+}

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-02-04 21:23:23 UTC (rev 667)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.c	2007-02-05 09:34:59 UTC (rev 668)
@@ -1,398 +1,420 @@
-/*   openmoko-dialer-window-talking.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 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 "alsa.h"
-#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-talking.h"
-
-void
-openmoko_wheel_press_left_up_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
- gint l , r;
- alsa_get_volume(&l, &r);
-alsa_set_volume(l+10, r+10);
-
- alsa_get_volume(&l, &r);
- g_print("l = %d, r = %d\n", l, r);
-
-/*
-    l = 90; 
-    r = 90;
-
-*/    
-
-}
-
-void
-openmoko_wheel_press_right_down_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata)
-{
- gint l , r;
-  alsa_get_volume(&l, &r);
-alsa_set_volume(l-10, r-10);
- alsa_get_volume(&l, &r);
- g_print("l = %d, r = %d\n", l, r);
-
-DBG_ENTER();
-}
-
-
-void cb_tool_button_speaker_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-  DBG_ENTER();
-}
-
-void cb_tool_button_dtmf_talk_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-	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);
-		       
-
-		}
-
-  
-}
-
-void cb_tool_button_hangup_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata)
-{
-     gsm_hangup();
-     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);
-
-
-gsm_dtmf_send(input[0]);
-//lgsm_voice_dtmf(lgsmh, buf[1]);
-
-}
-
-
-
-void window_talking_prepare(MOKO_DIALER_APP_DATA * appdata)
-{
-DBG_ENTER();
-
-//   moko_dialer_status_set_person_number(appdata->status_talking, appdata->g_peer_info.number);
-
-if(!appdata->window_talking)
-	window_talking_init(appdata);
-
-if(!appdata->window_talking)
-{
-	DBG_WARN("NO TALKING WINDOW INITIATED");
-	return;
-}
-
-
-if(appdata->g_peer_info.hasname)
-{
-DBG_TRACE();
-   moko_dialer_status_set_person_image(appdata->status_talking, appdata->g_peer_info.ID);  
-DBG_TRACE();
-   moko_dialer_status_set_person_name(appdata->status_talking, appdata->g_peer_info.name);
-   DBG_TRACE();
-}
-else
-{
-   moko_dialer_status_set_person_image(appdata->status_talking, "");  
-   moko_dialer_status_set_person_name(appdata->status_talking, "");
-
-}
-
-DBG_LEAVE();
-
-}
-
-gint timer_talking_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,"Talking (%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_talking,timer_data->timestring);
-moko_dialer_status_update_icon(appdata->status_talking);
-
-if(timer_data->stopsec!=0&&timer_data->ticks>=timer_data->stopsec)
-{
-
-timer_data->timeout=1;
-gtk_timeout_remove(timer_data->ptimer);
-timer_data->ptimer=0;
-return 0;//0 stops the timer.
-}
-else
-return 1;
-}
-
-void
-on_window_talking_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;
-}
-
-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
-on_window_talking_show                  (GtkWidget       *widget,
-                                        MOKO_DIALER_APP_DATA * appdata)
-{
-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+1900,p->tm_mon,p->tm_mday);
-
-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_talking_time_out,appdata);
-
-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();
-
-
-if(p_dialer_data->window_talking==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);
-   
-   
-   moko_dialer_status_set_title_label(status, "In Call");
-   moko_dialer_status_set_status_label(status, "Talking ...(00:00:00)");
-
-   gtk_box_pack_start( GTK_BOX(content_talk),status, FALSE, FALSE, 0 );
-
-
-   p_dialer_data->status_talking=status;
-   p_dialer_data->content_talk= content_talk;
-
-   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_container_add (GTK_CONTAINER (eventbox1), mokotextview);
-
-   	p_dialer_data->moko_dtmf_text_view=mokotextview;
-    
-  	gtk_box_pack_start( GTK_BOX(content_dtmf), GTK_WIDGET(eventbox1), FALSE,FALSE, 2 );
-
-
-
-	 mokodialerpanel=moko_dialer_panel_new();
-
-   	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;
-
-
-//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) );
-//the gtk_widget_show_all is really bad, cause i have to call it and then hide some widgets.
-
-   gtk_widget_hide(content_dtmf);
-
-
- //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);
-
-
-
-        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));
-
-	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();
-}
-
-    return 1;
-}
-
+/*   openmoko-dialer-window-talking.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 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 "alsa.h"
+#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-talking.h"
+
+void
+openmoko_wheel_press_left_up_cb (GtkWidget * widget,
+                                 MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+  gint l, r;
+  alsa_get_volume (&l, &r);
+  alsa_set_volume (l + 10, r + 10);
+
+  alsa_get_volume (&l, &r);
+  g_print ("l = %d, r = %d\n", l, r);
+
+/*
+    l = 90; 
+    r = 90;
+
+*/
+
+}
+
+void
+openmoko_wheel_press_right_down_cb (GtkWidget * widget,
+                                    MOKO_DIALER_APP_DATA * appdata)
+{
+  gint l, r;
+  alsa_get_volume (&l, &r);
+  alsa_set_volume (l - 10, r - 10);
+  alsa_get_volume (&l, &r);
+  g_print ("l = %d, r = %d\n", l, r);
+
+  DBG_ENTER ();
+}
+
+
+void
+cb_tool_button_speaker_clicked (GtkButton * button,
+                                MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+}
+
+void
+cb_tool_button_dtmf_talk_clicked (GtkButton * button,
+                                  MOKO_DIALER_APP_DATA * appdata)
+{
+  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);
+
+
+  }
+
+
+}
+
+void
+cb_tool_button_hangup_clicked (GtkButton * button,
+                               MOKO_DIALER_APP_DATA * appdata)
+{
+  gsm_hangup ();
+  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);
+
+
+  gsm_dtmf_send (input[0]);
+//lgsm_voice_dtmf(lgsmh, buf[1]);
+
+}
+
+
+
+void
+window_talking_prepare (MOKO_DIALER_APP_DATA * appdata)
+{
+  DBG_ENTER ();
+
+//   moko_dialer_status_set_person_number(appdata->status_talking, appdata->g_peer_info.number);
+
+  if (!appdata->window_talking)
+    window_talking_init (appdata);
+
+  if (!appdata->window_talking)
+  {
+    DBG_WARN ("NO TALKING WINDOW INITIATED");
+    return;
+  }
+
+
+  if (appdata->g_peer_info.hasname)
+  {
+    DBG_TRACE ();
+    moko_dialer_status_set_person_image (appdata->status_talking,
+                                         appdata->g_peer_info.ID);
+    DBG_TRACE ();
+    moko_dialer_status_set_person_name (appdata->status_talking,
+                                        appdata->g_peer_info.name);
+    DBG_TRACE ();
+  }
+  else
+  {
+    moko_dialer_status_set_person_image (appdata->status_talking, "");
+    moko_dialer_status_set_person_name (appdata->status_talking, "");
+
+  }
+
+  DBG_LEAVE ();
+
+}
+
+gint
+timer_talking_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, "Talking (%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_talking,
+                                       timer_data->timestring);
+  moko_dialer_status_update_icon (appdata->status_talking);
+
+  if (timer_data->stopsec != 0 && timer_data->ticks >= timer_data->stopsec)
+  {
+
+    timer_data->timeout = 1;
+    gtk_timeout_remove (timer_data->ptimer);
+    timer_data->ptimer = 0;
+    return 0;                   //0 stops the timer.
+  }
+  else
+    return 1;
+}
+
+void
+on_window_talking_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;
+  }
+
+  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
+on_window_talking_show (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata)
+{
+  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 + 1900,
+           p->tm_mon, p->tm_mday);
+
+  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_talking_time_out, appdata);
+
+  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 ();
+
+
+  if (p_dialer_data->window_talking == 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);
+
+
+    moko_dialer_status_set_title_label (status, "In Call");
+    moko_dialer_status_set_status_label (status, "Talking ...(00:00:00)");
+
+    gtk_box_pack_start (GTK_BOX (content_talk), status, FALSE, FALSE, 0);
+
+
+    p_dialer_data->status_talking = status;
+    p_dialer_data->content_talk = content_talk;
+
+    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_container_add (GTK_CONTAINER (eventbox1), mokotextview);
+
+    p_dialer_data->moko_dtmf_text_view = mokotextview;
+
+    gtk_box_pack_start (GTK_BOX (content_dtmf), GTK_WIDGET (eventbox1), FALSE,
+                        FALSE, 2);
+
+
+
+    mokodialerpanel = moko_dialer_panel_new ();
+
+    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;
+
+
+//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));
+//the gtk_widget_show_all is really bad, cause i have to call it and then hide some widgets.
+
+    gtk_widget_hide (content_dtmf);
+
+
+    //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);
+
+
+
+    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));
+
+    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 ();
+  }
+
+  return 1;
+}





More information about the commitlog mailing list