r1528 - trunk/src/target/OM-2007/applications/openmoko-dialer/src
tony_guan at sita.openmoko.org
tony_guan at sita.openmoko.org
Wed Mar 28 11:00:34 CEST 2007
Author: tony_guan
Date: 2007-03-28 11:00:26 +0200 (Wed, 28 Mar 2007)
New Revision: 1528
Modified:
trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c
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/moko-dialer-autolist.c
trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.h
trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.c
trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-pin.c
Log:
Improved the auto-completion algorithm taking advantage of last search results.
replaced the strlen to avoid the warning messages.
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c 2007-03-28 08:44:36 UTC (rev 1527)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c 2007-03-28 09:00:26 UTC (rev 1528)
@@ -289,7 +289,8 @@
return 0;
- query = e_book_query_field_exists (E_CONTACT_FULL_NAME);
+ //query = e_book_query_field_exists (E_CONTACT_FULL_NAME); //we change this query to catch the pace of contact application.
+ query = e_book_query_any_field_contains ("");
printf ("query=%s\n", e_book_query_to_string (query));
@@ -321,6 +322,8 @@
// 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 ) || (g_utf8_strlen (name_or_org , -1) <= 0))
+ name_or_org = "Unnamed";
if (name_or_org)
{
@@ -430,7 +433,7 @@
g_stpcpy (picpath, MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH);
if (number == 0)
return 0;
- if (strlen (number) == 0)
+ if (g_utf8_strlen (number,-1) == 0)
return 0;
// DIALER_CONTACT* contacts=g_contactlist.contacts;
@@ -489,7 +492,7 @@
if (peer->number == 0)
return 0;
- if (strlen (peer->number) == 0)
+ if (g_utf8_strlen (peer->number,-1) == 0)
return 0;
// DIALER_CONTACT* contacts=g_contactlist.contacts;
@@ -546,9 +549,9 @@
if (string == 0)
return 1;
- if (strlen (string) == 0)
+ if (g_utf8_strlen (string,-1) == 0)
return 1;
- if (strlen (string) > strlen (content))
+ if (g_utf8_strlen(string,-1) > g_utf8_strlen(content,-1))
return 0;
for (i = 0; string[i]; i++)
{
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c 2007-03-28 08:44:36 UTC (rev 1527)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialergsm.c 2007-03-28 09:00:26 UTC (rev 1528)
@@ -170,8 +170,8 @@
{
struct lgsm_addr addr;
addr.type = 129;
- strncpy (addr.addr, number, strlen (number));
- addr.addr[strlen (number)] = '\0';
+ strncpy (addr.addr, number, g_utf8_strlen (number,-1));
+ addr.addr[g_utf8_strlen (number,-1)] = '\0';
return lgsm_voice_out_init (lgsmh, &addr);
}
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c 2007-03-28 08:44:36 UTC (rev 1527)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c 2007-03-28 09:00:26 UTC (rev 1528)
@@ -174,9 +174,9 @@
// DBG_MESSAGE("pentry add:0X%x",pentry);
- if (name && strlen (name) > 0)
+ if (name && g_utf8_strlen(name,-1) > 0)
{
- pentry->name = (char *) calloc (1, strlen (name) + 1);
+ pentry->name = (char *) calloc (1, g_utf8_strlen (name,-1) + 1);
g_stpcpy (pentry->name, name);
pentry->hasname = 1;
}
@@ -186,9 +186,9 @@
pentry->hasname = 0;
}
- if (number && strlen (number) > 0)
+ if (number && g_utf8_strlen (number,-1) > 0)
{
- pentry->number = (char *) calloc (1, strlen (number) + 1);
+ pentry->number = (char *) calloc (1, g_utf8_strlen (number,-1) + 1);
g_stpcpy (pentry->number, number);
}
else
@@ -200,14 +200,14 @@
//DBG_MESSAGE("History add:0X%x,%s,%s,%s,%s,%s,%d",historyhead,name,number,picpath,time,date,durationsec);
- if (id && strlen (id) > 0)
+ if (id && g_utf8_strlen (id,-1) > 0)
{
- pentry->ID = (char *) calloc (1, strlen (id) + 1);
+ pentry->ID = (char *) calloc (1, g_utf8_strlen (id,-1) + 1);
g_stpcpy (pentry->ID, id);
}
- if (time && strlen (time) > 0)
+ if (time && g_utf8_strlen (time,-1) > 0)
{
- pentry->time = (char *) calloc (1, strlen (time) + 1);
+ pentry->time = (char *) calloc (1, g_utf8_strlen(time,-1) + 1);
g_stpcpy (pentry->time, time);
}
pentry->durationsec = durationsec;
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-03-28 08:44:36 UTC (rev 1527)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.c 2007-03-28 09:00:26 UTC (rev 1528)
@@ -97,6 +97,9 @@
moko_dialer_autolist->head = 0;
moko_dialer_autolist->g_alternatecount = 0;
moko_dialer_autolist->imagePerson = 0;
+ moko_dialer_autolist->g_alternatecount_last_time=0;
+ moko_dialer_autolist->g_last_string[0]=0; ///<memorize last sensentive string.
+
gtk_widget_set_size_request (GTK_WIDGET (moko_dialer_autolist), 480, 40);
}
@@ -272,23 +275,60 @@
}
moko_dialer_autolist->tipscreated = TRUE;
}
+ //if last time, we searched ,so we want to know if the last results can be used for this time.
+ int included=contact_string_has_sensentive(string,moko_dialer_autolist->g_last_string)&&(g_utf8_strlen (moko_dialer_autolist->g_last_string, -1) >= MOKO_DIALER_MIN_SENSATIVE_LEN);
+
+ if(included&&(moko_dialer_autolist->g_alternatecount_last_time==0)){
+ inserted=0;
+ DBG_MESSAGE("NO NEED TO SEARCH ANYMORE");
+ //last result is null, so we save time by not searching it at all.
+ }
+ else if(included&&(moko_dialer_autolist->g_alternatecount_last_time<MOKO_DIALER_MAX_TIPS)){
+ //we search last result here.
+ //now we start from the end of the list.
+ int i=moko_dialer_autolist->g_alternatecount_last_time-1;
+ DBG_MESSAGE("we search the last resutls.");
+ while(i>=0&&i>=inserted){
+ //here inserted stands as the next inserted position.
- contacts = moko_dialer_autolist->head->contacts;
+ if (contact_string_has_sensentive (moko_dialer_autolist->readycontacts[i].p_entry->content, string))
+ {
+ DBG_MESSAGE("find one match.");
+ //we use the idle readycontacts[MOKO_DIALER_MAX_TIPS] for exchange space,to swap the 2 items.
+ if(i>inserted)
+ {
+ moko_dialer_autolist->readycontacts[MOKO_DIALER_MAX_TIPS].p_entry=moko_dialer_autolist->readycontacts[inserted].p_entry;
+ moko_dialer_autolist->readycontacts[MOKO_DIALER_MAX_TIPS].p_contact=moko_dialer_autolist->readycontacts[inserted].p_contact;
+ moko_dialer_autolist->readycontacts[inserted].p_entry=moko_dialer_autolist->readycontacts[i].p_entry;
+ moko_dialer_autolist->readycontacts[inserted].p_contact=moko_dialer_autolist->readycontacts[i].p_contact;
+ moko_dialer_autolist->readycontacts[i].p_entry=moko_dialer_autolist->readycontacts[MOKO_DIALER_MAX_TIPS].p_entry;
+ moko_dialer_autolist->readycontacts[i].p_contact=moko_dialer_autolist->readycontacts[MOKO_DIALER_MAX_TIPS].p_contact;
+ }
+ inserted++;
+ }
+ else
+ {
+ //we just move the point back.
+ i--;
+ }
-// 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);
+ }
+
+ }
+ else{
+ //we had to search all the contact list. may be we can improve the performance by draw every suitalbe items to be the first of the list.
+ contacts = moko_dialer_autolist->head->contacts;
-// DBG_TRACE();
+ DBG_MESSAGE("we search the whole contact list.");
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))
{
+ DBG_MESSAGE("find one match from the whole list.");
//if the person not inserted, then insert first
moko_dialer_autolist->readycontacts[inserted].p_contact = contacts;
moko_dialer_autolist->readycontacts[inserted].p_entry = entry;
@@ -301,6 +341,10 @@
contacts = contacts->next;
}
+
+ }//
+ strcpy(moko_dialer_autolist->g_last_string,string);
+ moko_dialer_autolist->g_alternatecount_last_time=inserted;
//DBG_MESSAGE("inserted=%d",inserted);
moko_dialer_autolist_fill_alternative (moko_dialer_autolist, inserted,
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.h 2007-03-28 08:44:36 UTC (rev 1527)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.h 2007-03-28 09:00:26 UTC (rev 1528)
@@ -56,6 +56,10 @@
DIALER_READY_CONTACT readycontacts[MOKO_DIALER_MAX_TIPS]; ///<the prepared contact list which will display to the user when he/she inputs part of the digits he/she wants to dial out
+ gint g_alternatecount_last_time; ///<indicate how many alternatives that we had from last search.
+
+ gchar g_last_string[MOKO_DIALER_MAX_NUMBER_LEN]; ///<memorize last sensentive string.
+
gboolean selected; ///<indicates wether some tip is currently selected.
gint g_alternatecount; ///<indicates how many alternative is ready in the ready list array.
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.c 2007-03-28 08:44:36 UTC (rev 1527)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-dialer.c 2007-03-28 09:00:26 UTC (rev 1528)
@@ -172,8 +172,15 @@
MokoDialerTextview *moko_dialer_text_view = appdata->moko_dialer_text_view;
DIALER_READY_CONTACT *ready_contact = (DIALER_READY_CONTACT *) para_pointer;
codesinput = moko_dialer_textview_get_input (moko_dialer_text_view, FALSE);
+ if(ready_contact->p_entry->content)
lenstring = g_utf8_strlen (ready_contact->p_entry->content, -1);
+ else
+ lenstring=0;
+
+ if(codesinput)
leninput = g_utf8_strlen (codesinput, -1);
+ else
+ leninput =0;
if (lenstring > leninput)
{
@@ -256,7 +263,7 @@
codesinput =
g_strdup (moko_dialer_textview_get_input (moko_dialer_text_view, FALSE));
- if (g_utf8_strlen (codesinput, -1) >= MOKO_DIALER_MIN_SENSATIVE_LEN)
+ if (codesinput&&(g_utf8_strlen (codesinput, -1) >= MOKO_DIALER_MIN_SENSATIVE_LEN))
{
moko_dialer_autolist_refresh_by_string (appdata->moko_dialer_autolist,
codesinput, TRUE);
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-pin.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-pin.c 2007-03-28 08:44:36 UTC (rev 1527)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-pin.c 2007-03-28 09:00:26 UTC (rev 1528)
@@ -47,7 +47,7 @@
// gchar *codesinput;
// codesinput =g_strdup(moko_dialer_textview_get_input (appdata->moko_pin_text_view, TRUE));
- if (g_utf8_strlen (appdata->str_sim_pin, -1) < 1)
+ if (!appdata->str_sim_pin||g_utf8_strlen (appdata->str_sim_pin, -1) < 1)
{
//user didn't input anything
DBG_MESSAGE ("no input for pin");
More information about the commitlog
mailing list