Changeset 649


Ignore:
Timestamp:
02/02/07 03:51:37 (6 years ago)
Author:
tony_guan
Message:

libebook integrated.

Location:
trunk/src/target/OM-2007/applications/openmoko-dialer/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.c

    r648 r649  
    1616 *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $] 
    1717 */ 
    18 #include "contacts.h" 
     18#include "contacts.h"  
    1919 
    2020/** 
    2121 * @brief initialze the contact list, this will be called from outside, contactlist 
    2222*/ 
    23 int 
    24 contact_init_contact_data (DIALER_CONTACTS_LIST_HEAD * p_contactlist) 
    25 { 
    26  
    27  
    28   DBG_ENTER (); 
     23int contact_init_contact_data(DIALER_CONTACTS_LIST_HEAD   *p_contactlist) 
     24{  
     25         
     26 
     27  DBG_ENTER(); 
    2928 
    3029  int res = contact_init_contact_list (p_contactlist); 
    3130 
    32   if (res == -1) 
     31  if(res == -1) 
    3332  { 
    3433    res = contact_init_from_cmd (p_contactlist); 
    3534  } 
    36   DBG_MESSAGE ("CONTACTS:%d,list@0x%x,first@0x%x", p_contactlist->length, 
    37                p_contactlist, p_contactlist->contacts); 
    38  
    39   DBG_LEAVE (); 
    40  
     35//  DBG_MESSAGE("CONTACTS:%d,list@0x%x,first@0x%x",p_contactlist->length,p_contactlist,p_contactlist->contacts); 
     36   
     37  DBG_LEAVE(); 
     38   
    4139  return res; 
    4240} 
    4341 
    44  
    45 /** 
    46  * @brief initialze the contact list by calling the external APIs. 
    47  * 
    48  * This function should be called once at the initial process. 
    49  * 
    50  * @param head DIALER_CONTACTS_LIST_HEAD head pointer 
    51  * @return the number of the contacts.  
    52  * @retval 
    53  */ 
    54  
    55  
    56  
    57  
    58 int 
    59 contact_init_contact_list (DIALER_CONTACTS_LIST_HEAD * head) 
    60 { 
    61  
    62   return -1; 
    63 } 
    6442 
    6543/** 
     
    7250 * @retval 1 
    7351 */ 
    74 int 
    75 contact_release_contact_entry (DIALER_CONTACT_ENTRY * contactentry) 
    76 { 
    77   if (contactentry == 0) 
    78     return 1; 
    79   if (contactentry->desc) 
    80   { 
    81     free (contactentry->desc); 
    82     contactentry->desc = 0; 
    83   } 
    84   if (contactentry->content) 
    85   { 
    86     free (contactentry->content); 
    87     contactentry->content = 0; 
    88   } 
    89   contactentry->next = 0; 
    90   free (contactentry); 
    91  
    92   return 1; 
     52int contact_release_contact_entry(DIALER_CONTACT_ENTRY* contactentry) 
     53{ 
     54        if(contactentry==0) return 1; 
     55                if(contactentry->desc) 
     56                { 
     57                free(contactentry->desc); 
     58                contactentry->desc=0;    
     59                } 
     60                if(contactentry->content) 
     61                { 
     62                        free(contactentry->content); 
     63                        contactentry->content=0; 
     64                } 
     65                contactentry->next=0; 
     66                free(contactentry); 
     67         
     68                return 1; 
    9369} 
    9470 
     
    10278 * @retval 1 
    10379 */ 
    104 int 
    105 contact_release_contact (DIALER_CONTACT * contact) 
    106 { 
    107   DIALER_CONTACT_ENTRY *entry = 0; 
    108   DIALER_CONTACT_ENTRY *nextentry = 0; 
    109   if (contact == 0) 
    110     return 1; 
    111   entry = contact->entry; 
    112   //free every entry 
    113   while (entry) 
    114   { 
    115     nextentry = entry->next; 
    116     contact_release_contact_entry (entry); 
    117     entry = nextentry; 
    118   } 
    119   contact->entry = 0; 
    120  
    121   //free name 
    122   if (contact->name) 
    123   { 
    124     free (contact->name); 
    125     contact->name = 0; 
    126   } 
    127   //free picpath 
    128   if (contact->picpath) 
    129   { 
    130     free (contact->picpath); 
    131     contact->picpath = 0; 
    132   } 
    133   //free contact itself 
    134   contact->entry = 0; 
    135   free (contact); 
    136   return 1; 
     80int contact_release_contact(DIALER_CONTACT *contact) 
     81{ 
     82        DIALER_CONTACT_ENTRY * entry=0; 
     83        DIALER_CONTACT_ENTRY * nextentry=0; 
     84        if(contact==0)return 1; 
     85        entry=contact->entry; 
     86        //free every entry 
     87        while(entry) 
     88        { 
     89                nextentry=entry->next; 
     90                contact_release_contact_entry(entry); 
     91                entry=nextentry; 
     92        } 
     93        contact->entry=0; 
     94         
     95        //free name 
     96        if(contact->name) 
     97        { 
     98        free(contact->name); 
     99        contact->name=0; 
     100        } 
     101        //free picpath 
     102        if(contact->picpath) 
     103        { 
     104                free(contact->picpath); 
     105                contact->picpath=0; 
     106        } 
     107        //free contact itself 
     108        contact->entry=0; 
     109        free(contact); 
     110        return 1; 
    137111} 
    138112 
     
    146120 * @retval 1 
    147121 */ 
    148 int 
    149 contact_release_contact_list (DIALER_CONTACTS_LIST_HEAD * head) 
    150 { 
    151 //      g_printf("releasing %s\n",contact->name); 
    152   DIALER_CONTACT *contact = 0; 
    153   DIALER_CONTACT *nextcontact = 0; 
    154   if (head == 0) 
    155     return 1; 
    156   contact = head->contacts; 
    157   if (contact == 0) 
    158     return 1; 
    159  
    160   while (contact) 
    161   { 
    162     //      g_printf("releasing %s\n",contact->name); 
    163     nextcontact = contact->next; 
    164     contact_release_contact (contact); 
    165     contact = nextcontact; 
    166   } 
    167   head->length = 0; 
    168   head->contacts = 0; 
    169   return 1; 
    170  
    171  
     122int contact_release_contact_list(DIALER_CONTACTS_LIST_HEAD * head) 
     123{ 
     124//      g_printf("releasing %s\n",contact->name); 
     125        DIALER_CONTACT* contact=0; 
     126        DIALER_CONTACT* nextcontact=0; 
     127        if(head==0)return 1; 
     128        contact=head->contacts; 
     129        if(contact==0) 
     130                return 1; 
     131         
     132        while(contact) 
     133        { 
     134        //      g_printf("releasing %s\n",contact->name); 
     135                nextcontact=contact->next; 
     136                contact_release_contact(contact); 
     137                contact=nextcontact; 
     138        } 
     139        head->length=0; 
     140        head->contacts=0; 
     141        return 1; 
     142         
     143         
    172144} 
    173145 
     
    184156 
    185157 
    186 int 
    187 contact_add_contact_to_list (DIALER_CONTACTS_LIST_HEAD * head, 
    188                              DIALER_CONTACT * contact) 
    189 { 
    190   if (head == 0) 
    191     return 0; 
    192   if (contact == 0) 
    193     return 0; 
    194  
    195   if (head->contacts == 0) 
    196   { 
    197     //we are the first 
    198     head->length = 1; 
    199     head->contacts = contact; 
    200     contact->next = 0; 
    201     contact->ID = 0; 
    202   } 
    203   else 
    204   { 
    205     contact->ID = head->length; 
    206     contact->next = head->contacts; 
    207     head->contacts = contact; 
    208     head->length++; 
    209  
    210   } 
    211  
    212   return contact->ID; 
    213  
    214  
     158int contact_add_contact_to_list(DIALER_CONTACTS_LIST_HEAD * head,DIALER_CONTACT*   contact) 
     159{ 
     160if(head==0)return 0; 
     161if(contact==0)return 0; 
     162 
     163if(head->contacts==0) 
     164{ 
     165        //we are the first 
     166        head->length=1; 
     167        head->contacts=contact; 
     168        contact->next=0; 
     169 
     170}else 
     171{ 
     172        contact->next=head->contacts; 
     173        head->contacts=contact; 
     174        head->length++; 
     175         
     176} 
     177 
     178        return  head->length; 
     179         
     180         
    215181} 
    216182 
     
    227193 
    228194 
    229 DIALER_CONTACT * 
    230 contact_new_contact (char *name, char *picpath) 
    231 { 
    232   DIALER_CONTACT *nextcontact; 
    233  
    234   nextcontact = (DIALER_CONTACT *) calloc (1, sizeof (DIALER_CONTACT)); 
    235   nextcontact->ID = 0; 
    236   nextcontact->name = (char *) calloc (1, 30); 
    237   strcpy (nextcontact->name, name); 
    238  
    239   nextcontact->picpath = (char *) calloc (1, 128); 
    240   strcpy (nextcontact->picpath, picpath); 
    241  
    242   return nextcontact; 
     195DIALER_CONTACT*  contact_new_contact(char* name, char* id) 
     196{ 
     197        DIALER_CONTACT* nextcontact; 
     198 
     199        nextcontact=(DIALER_CONTACT* )calloc(1,sizeof(DIALER_CONTACT)); 
     200        nextcontact->ID=0; 
     201        nextcontact->name=(char *)calloc(1,30); 
     202        strcpy(nextcontact->name,name); 
     203        nextcontact->name[29]='\0'; 
     204         
     205        nextcontact->ID=(char *)calloc(1,255); 
     206        strcpy(nextcontact->ID,id); 
     207        nextcontact->ID[254]='\0'; 
     208        return nextcontact; 
    243209} 
    244210 
     
    256222 
    257223 
    258 DIALER_CONTACT_ENTRY * 
    259 contact_add_entry (DIALER_CONTACT * contact, char *desc, char *content) 
    260 { 
    261  
    262   DIALER_CONTACT_ENTRY *nextentry; 
    263  
    264   if (contact == 0) 
    265     return 0; 
    266   if (desc == 0) 
    267     return 0; 
    268   if (content == 0) 
    269     return 0; 
    270   nextentry = 
    271     (DIALER_CONTACT_ENTRY *) calloc (1, sizeof (DIALER_CONTACT_ENTRY)); 
    272   nextentry->desc = (char *) calloc (1, 30); 
    273   strcpy (nextentry->desc, desc); 
    274   nextentry->content = (char *) calloc (1, 30); 
    275   strcpy (nextentry->content, content); 
    276  
    277  
    278   nextentry->next = contact->entry; 
    279   contact->entry = nextentry; 
    280  
    281   return nextentry; 
    282 } 
     224DIALER_CONTACT_ENTRY* contact_add_entry(DIALER_CONTACT* contact, char* desc,char* content) 
     225{ 
     226         
     227        DIALER_CONTACT_ENTRY* nextentry; 
     228         
     229        if(contact==0)return 0; 
     230        if(desc==0)return 0; 
     231        if(content==0)return 0; 
     232        nextentry=(DIALER_CONTACT_ENTRY*)calloc(1,sizeof(DIALER_CONTACT_ENTRY)); 
     233        nextentry->desc=(char *)calloc(1,30); 
     234        strcpy(nextentry->desc,desc); 
     235        nextentry->desc[29]='\0'; 
     236        nextentry->content=(char *)calloc(1,30); 
     237        strcpy(nextentry->content,content); 
     238        nextentry->content[29]='\0'; 
     239         
     240        nextentry->next=contact->entry; 
     241        contact->entry=nextentry; 
     242         
     243        return nextentry; 
     244} 
     245 
     246/** 
     247 * @brief initialze the contact list by calling the external APIs. 
     248 * 
     249 * This function should be called once at the initial process. this will call libebook apis to retrieve the contact information. 
     250 * 
     251 * @param head DIALER_CONTACTS_LIST_HEAD head pointer 
     252 * @return the number of the contacts.  
     253 * @retval 
     254 */ 
     255 
     256 
     257 
     258 
     259int contact_init_contact_list(DIALER_CONTACTS_LIST_HEAD * head) 
     260{ 
     261 
     262        EBook *book; 
     263        gboolean status; 
     264        EBookQuery *query; 
     265        GList *c, *contacts; 
     266        DIALER_CONTACT* dialercontact; 
     267 
     268        if(head==0)return 0; 
     269 
     270 
     271        query=e_book_query_field_exists(E_CONTACT_FULL_NAME); 
     272        printf("query=%s\n",e_book_query_to_string(query)); 
     273         
     274         
     275        book = e_book_new_system_addressbook (NULL); 
     276        if (!book) { 
     277                printf ("failed to create ebook\n"); 
     278                return -1; 
     279        } 
     280 
     281        status = e_book_open (book, TRUE, NULL); 
     282        if (status == FALSE) { 
     283                printf ("failed to open addressbook\n"); 
     284                return -1; 
     285        } 
     286 
     287        status = e_book_get_contacts (book, query, &contacts, NULL); 
     288        if (status == FALSE) { 
     289                printf ("failed to get contacts\n"); 
     290                return -1; 
     291        } 
     292for (c = contacts; c; c = c->next) 
     293 { 
     294 
     295        EContact *contact = E_CONTACT (c->data); 
     296      dialercontact=0; 
     297//        printf("id=%s\n",e_contact_get_const(contact,E_CONTACT_UID)); 
     298          gchar * name_or_org=e_contact_get_const(contact,E_CONTACT_NAME_OR_ORG); 
     299          gchar * phone; 
     300          if(name_or_org) 
     301                  { 
     302 
     303                 dialercontact=contact_new_contact(name_or_org,e_contact_get_const(contact,E_CONTACT_UID)); 
     304                  contact_add_contact_to_list(head,dialercontact); 
     305 
     306                  printf("%s\n",name_or_org); 
     307//          g_object_unref(name_or_org); 
     308 
     309                } 
     310        int i=0; 
     311        if(dialercontact) 
     312        { 
     313                for(i=E_CONTACT_FIRST_PHONE_ID;i<=E_CONTACT_LAST_PHONE_ID;i++) 
     314                {               phone = e_contact_get_const (contact, i); 
     315                                if (phone) printf ("%s: %s\n",e_contact_field_name(i),phone); 
     316                                contact_add_entry(dialercontact,e_contact_field_name(i),phone); 
     317 
     318                } 
     319        } 
     320 
     321                g_object_unref (contact); 
     322} 
     323 
     324        g_list_free (contacts); 
     325 
     326        g_object_unref (book); 
     327 
     328        return 0; 
     329} 
     330 
    283331 
    284332/** 
     
    293341 */ 
    294342 
    295 int 
    296 contact_init_from_cmd (DIALER_CONTACTS_LIST_HEAD * head) 
    297 { 
    298   DIALER_CONTACT *contact; 
    299   if (head == 0) 
    300     return 0; 
    301   contact = contact_new_contact ("Tony Guan", "tony.png"); 
    302   contact_add_entry (contact, "cell", "13917209523"); 
    303   contact_add_entry (contact, "work", "02162495726"); 
    304   contact_add_contact_to_list (head, contact); 
    305  
    306   contact = contact_new_contact ("Sally Xu", "sally.png"); 
    307   contact_add_entry (contact, "cell", "13361900551"); 
    308   contact_add_entry (contact, "work", "02165538452"); 
    309   contact_add_contact_to_list (head, contact); 
    310  
    311   contact = contact_new_contact ("Chaowei Song", "chaowei.png"); 
    312   contact_add_entry (contact, "work1", "02162495727"); 
    313   contact_add_entry (contact, "work4", "02162495730"); 
    314   contact_add_entry (contact, "work5", "02162495731"); 
    315   contact_add_contact_to_list (head, contact); 
    316  
    317   contact = contact_new_contact ("Ken Zhao", "ken.png"); 
    318   contact_add_entry (contact, "work2", "02162495728"); 
    319   contact_add_contact_to_list (head, contact); 
    320  
    321   contact = contact_new_contact ("Steven Chen", "steven.png"); 
    322   contact_add_entry (contact, "work3", "02162495729"); 
    323   contact_add_contact_to_list (head, contact); 
    324  
    325   contact = contact_new_contact ("10086", "10086.png"); 
    326   contact_add_entry (contact, "work", "10086"); 
    327   contact_add_contact_to_list (head, contact); 
    328  
    329   return head->length; 
    330  
    331  
     343int contact_init_from_cmd(DIALER_CONTACTS_LIST_HEAD * head) 
     344{ 
     345        DIALER_CONTACT* contact; 
     346        if(head==0)return 0; 
     347        contact=contact_new_contact("Tony Guan","tony.png"); 
     348        contact_add_entry(contact,"cell","13917209523"); 
     349        contact_add_entry(contact,"work","02162495726"); 
     350        contact_add_contact_to_list(head,contact); 
     351         
     352        contact=contact_new_contact("Sally Xu","sally.png"); 
     353        contact_add_entry(contact,"cell","13361900551"); 
     354        contact_add_entry(contact,"work","02165538452"); 
     355        contact_add_contact_to_list(head,contact); 
     356         
     357        contact=contact_new_contact("Chaowei Song","chaowei.png"); 
     358        contact_add_entry(contact,"work1","02162495727"); 
     359        contact_add_entry(contact,"work4","02162495730"); 
     360        contact_add_entry(contact,"work5","02162495731"); 
     361        contact_add_contact_to_list(head,contact); 
     362         
     363        contact=contact_new_contact("Ken Zhao","ken.png"); 
     364        contact_add_entry(contact,"work2","02162495728"); 
     365        contact_add_contact_to_list(head,contact); 
     366         
     367        contact=contact_new_contact("Steven Chen","steven.png"); 
     368        contact_add_entry(contact,"work3","02162495729"); 
     369        contact_add_contact_to_list(head,contact); 
     370         
     371        contact=contact_new_contact("10086","10086.png"); 
     372        contact_add_entry(contact,"work","10086"); 
     373        contact_add_contact_to_list(head,contact); 
     374 
     375        return head->length;     
     376         
     377         
    332378} 
    333379 
     
    345391 */ 
    346392 
    347 int 
    348 contact_get_info_from_number (DIALER_CONTACT * contacts, char *name, 
    349                               char *picpath, const char *number) 
    350 { 
    351  
    352  
    353   strcpy (name, ""); 
    354   strcpy (picpath, MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH); 
    355   if (number == 0) 
    356     return 0; 
    357   if (strlen (number) == 0) 
    358     return 0; 
    359  
     393int contact_get_info_from_number(DIALER_CONTACT* contacts,char* name,char* picpath,const char* number) 
     394{ 
     395 
     396 
     397        strcpy(name,""); 
     398        strcpy(picpath,MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH); 
     399        if(number==0)return 0; 
     400        if(strlen(number)==0)return 0; 
     401         
    360402//  DIALER_CONTACT* contacts=g_contactlist.contacts; 
    361403 
    362   DIALER_CONTACT_ENTRY *entry; 
    363  
    364   while (contacts != 0) 
    365   { 
    366     entry = contacts->entry; 
    367  
    368     while (entry) 
    369     { 
    370  
    371       //judge if the entry includes the string 
    372  
    373       if (strcmp (entry->content, number) == 0) 
    374       { 
    375         strcpy (picpath, contacts->picpath); 
    376         strcpy (name, contacts->name); 
    377         // DBG_MESSAGE("Yeah, we know the owner is %s.",name); 
    378  
    379         return 1; 
    380       } 
    381       entry = entry->next; 
    382     } 
    383  
    384  
    385     contacts = contacts->next; 
    386  
     404DIALER_CONTACT_ENTRY* entry; 
     405  
     406   while(contacts!= 0) 
     407   { 
     408     entry=contacts->entry; 
     409 
     410         while(entry) 
     411        { 
     412         
     413        //judge if the entry includes the string 
     414                  
     415         if(strcmp(entry->content,number)==0) 
     416         {       
     417         strcpy(picpath,contacts->picpath); 
     418     strcpy(name,contacts->name); 
     419        // DBG_MESSAGE("Yeah, we know the owner is %s.",name); 
     420          
     421        return 1; 
     422        } 
     423     entry=entry->next; 
     424        } 
     425     
     426          
     427         contacts= contacts->next; 
     428         
    387429  } 
    388430  //DBG_MESSAGE("Can not find the number."); 
     
    402444 */ 
    403445 
    404 int 
    405 contact_get_peer_info_from_number (DIALER_CONTACT * contacts, 
    406                                    DIALER_CONTACT_PEER_INFO * peer) 
    407 { 
    408  
    409   peer->hasname = 0; 
    410   peer->searched = 1; 
    411   peer->name = 0; 
    412   peer->picpath = 0; 
    413  
    414   if (peer->number == 0) 
    415     return 0; 
    416   if (strlen (peer->number) == 0) 
    417     return 0; 
    418  
     446int contact_get_peer_info_from_number(DIALER_CONTACT* contacts, DIALER_CONTACT_PEER_INFO * peer) 
     447{ 
     448 
     449        peer->hasname=0; 
     450        peer->searched=1; 
     451        peer->name=0; 
     452        peer->picpath=0; 
     453 
     454        if(peer->number==0)return 0; 
     455        if(strlen(peer->number)==0)return 0; 
     456         
    419457//  DIALER_CONTACT* contacts=g_contactlist.contacts; 
    420458 
    421   DIALER_CONTACT_ENTRY *entry; 
    422  
    423   while (contacts != 0) 
    424   { 
    425     entry = contacts->entry; 
    426  
    427     while (entry) 
    428     { 
    429  
    430       //judge if the entry includes the string 
    431  
    432       if (strcmp (entry->content, peer->number) == 0) 
    433       { 
    434         peer->picpath = contacts->picpath; 
    435         peer->name = contacts->name; 
    436         // DBG_MESSAGE("Yeah, we know the owner is %s.",name); 
    437         peer->hasname = 1; 
    438         return 1; 
    439       } 
    440       entry = entry->next; 
    441     } 
    442  
    443  
    444     contacts = contacts->next; 
    445  
     459        DIALER_CONTACT_ENTRY* entry; 
     460  
     461   while(contacts!= 0) 
     462   { 
     463     entry=contacts->entry; 
     464 
     465         while(entry) 
     466        { 
     467         
     468        //judge if the entry includes the string 
     469                  
     470         if(strcmp(entry->content,peer->number)==0) 
     471         {       
     472         peer->ID=contacts->ID; 
     473         peer->name=contacts->name; 
     474        // DBG_MESSAGE("Yeah, we know the owner is %s.",name); 
     475        peer->hasname=1; 
     476        return 1; 
     477        } 
     478     entry=entry->next; 
     479        } 
     480     
     481          
     482         contacts= contacts->next; 
     483         
    446484  } 
    447485  //DBG_MESSAGE("Can not find the number."); 
     
    460498 */ 
    461499 
    462 int 
    463 contact_string_has_sensentive (char *content, char *string) 
    464 { 
    465   int i; 
    466 //      g_printf("hassensentive:%s,%s\n",content,string); 
    467   if (content == 0) 
    468     return 0; 
    469  
    470   if (string == 0) 
    471     return 1; 
    472  
    473   if (strlen (string) == 0) 
    474     return 1; 
    475   if (strlen (string) > strlen (content)) 
    476     return 0; 
    477   for (i = 0; string[i]; i++) 
    478   { 
    479     if (content[i] == 0) 
    480       return 1; 
    481     if (string[i] == content[i]) 
    482       continue; 
    483     return 0; 
    484  
    485   } 
    486   return 1; 
    487 } 
    488  
    489 int 
    490 contact_print_contact_list (DIALER_CONTACTS_LIST_HEAD * head) 
    491 { 
    492   DIALER_CONTACT *contacts; 
    493   DIALER_CONTACT_ENTRY *entry; 
    494   contacts = head->contacts; 
    495  
    496   DBG_MESSAGE ("\n\nThere are %d contacts here:", head->length); 
    497  
    498   while (contacts != 0) 
    499   { 
    500     DBG_MESSAGE ("%s", contacts->name); 
    501     entry = contacts->entry; 
    502  
    503     while (entry) 
    504     { 
    505  
    506       DBG_MESSAGE ("--%s:%s", entry->desc, entry->content); 
    507       entry = entry->next; 
    508     } 
    509  
    510     contacts = contacts->next; 
     500int contact_string_has_sensentive (char * content, char *string) 
     501{ 
     502        int i; 
     503//      g_printf("hassensentive:%s,%s\n",content,string); 
     504        if(content==0)  
     505        return 0; 
     506         
     507        if(string==0)  
     508        return 1; 
     509         
     510        if(strlen(string)==0) 
     511                return 1; 
     512        if(strlen(string)>strlen(content)) 
     513                return 0; 
     514        for(i=0;string[i];i++) 
     515        { 
     516                if(content[i]==0) 
     517                        return 1; 
     518                if(string[i]==content[i]) 
     519                        continue; 
     520                return 0; 
     521                 
     522        } 
     523        return 1; 
     524} 
     525int contact_print_contact_list(DIALER_CONTACTS_LIST_HEAD * head) 
     526{ 
     527DIALER_CONTACT* contacts; 
     528DIALER_CONTACT_ENTRY* entry; 
     529 contacts=head->contacts; 
     530 
     531DBG_MESSAGE("\n\nThere are %d contacts here:",head->length); 
     532 
     533   while(contacts!= 0) 
     534   { 
     535   DBG_MESSAGE("%s",contacts->name); 
     536     entry=contacts->entry; 
     537 
     538         while(entry) 
     539         { 
     540         
     541         DBG_MESSAGE("--%s:%s",entry->desc,entry->content); 
     542        entry=entry->next; 
     543         } 
     544 
     545      contacts= contacts->next; 
    511546  } 
    512547  return 0; 
    513548 
    514549} 
     550 
     551int contact_load_contact_photo(GtkImage* image,const char* id) 
     552{ 
     553 
     554EBook *book; 
     555EContact * contact; 
     556GError *error = NULL; 
     557printf(">>>contact_load_contact_photo   id=%s\n",id); 
     558if(id==0||!strcmp(id,"")) 
     559{//we load the default image for non-exist ID. 
     560 gtk_image_set_from_stock(image,"gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR); 
     561return 0; 
     562} 
     563 
     564book = e_book_new_system_addressbook (NULL); 
     565        if (!book) { 
     566                printf ("failed to create ebook\n"); 
     567                  gtk_image_set_from_stock(image,"gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR); 
     568        return 0; 
     569        } 
     570 
     571 
     572if ( !e_book_open (book, TRUE, NULL)) { 
     573                printf ("failed to open addressbook\n"); 
     574                  gtk_image_set_from_stock(image,"gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR); 
     575                return 0; 
     576        } 
     577 
     578 
     579//get the contact; 
     580 
     581if (!e_book_get_contact (book, id, &contact, &error)) { 
     582                printf ("error %d getting card: %s\n", error->code, error->message); 
     583                g_clear_error (&error); 
     584          gtk_image_set_from_stock(image,"gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR); 
     585                return 0; 
     586        } 
     587 
     588 
     589EContactPhoto *photo = e_contact_get (contact, E_CONTACT_PHOTO); 
     590 
     591GdkPixbufLoader *loader = gdk_pixbuf_loader_new (); 
     592GdkPixbuf *pixbuf; 
     593 
     594                        /* figure out if we need to downscale the 
     595                           image here.  we don't scale the pixbuf 
     596                           itself, just insert width/height tags in 
     597                           the html */ 
     598 
     599if(photo) 
     600gdk_pixbuf_loader_write (loader, photo->data, photo->length, NULL); 
     601 
     602gdk_pixbuf_loader_close (loader, NULL); 
     603 
     604pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); 
     605if (pixbuf) 
     606        g_object_ref (pixbuf); 
     607 
     608 
     609g_object_unref (loader); 
     610 
     611if (pixbuf) 
     612{ 
     613printf ("now we set the image from pixbuf\n"); 
     614gtk_image_set_from_pixbuf(image,pixbuf);   
     615g_object_unref (pixbuf); 
     616return 1; 
     617} 
     618else 
     619{ 
     620  gtk_image_set_from_stock(image,"gtk-yes",GTK_ICON_SIZE_LARGE_TOOLBAR); 
     621  return 0; 
     622} 
     623 
     624} 
     625 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/contacts.h

    r648 r649  
    2222 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
    2323 */ 
    24  
    25  
     24  
     25  
    2626#ifndef _CONTACTS_H 
    2727#define _CONTACTS_H 
     
    2929#include "moko-dialer-declares.h" 
    3030#include "error.h" 
     31#include <bonobo/bonobo-main.h> 
     32#include <stdlib.h> 
     33#include <libebook/e-book.h> 
     34#include <gtk/gtk.h> 
    3135#ifdef __cplusplus 
    3236extern "C" 
     
    3640 
    3741 
    38  
     42         
    3943/** 
    4044 * @brief phone number entry for the contact  structure in open dialer. 
    4145 */ 
    42   typedef struct dialer_contact_entry 
    43   { 
    44     int ID;                     ///<the unique ID for an contact entry 
    45     char *desc;                 ///<the description of this entry,such as homenumber 
    46     char *content;              ///<the content of this entry, such as 62495726 
    47     struct dialer_contact_entry *next; 
    48   } DIALER_CONTACT_ENTRY; 
     46typedef struct dialer_contact_entry { 
     47  int ID;///<the unique ID for an contact entry 
     48  char *desc; ///<the description of this entry,such as homenumber 
     49  char *content; ///<the content of this entry, such as 62495726 
     50  struct dialer_contact_entry* next; 
     51}DIALER_CONTACT_ENTRY; 
    4952 
    5053 
     
    5255 * @brief contact  structure for open dialer. 
    5356 */ 
    54   typedef struct dialer_contact 
    55   { 
    56     int ID;                     ///<the unique ID for an contact entry 
    57     char *name;                 ///<person name 
    58     char *picpath;              ///<the picture file path for the person 
    59     DIALER_CONTACT_ENTRY *entry;        ///<first number entry for the person 
    60  
    61     struct dialer_contact *next;        ///<pointer to next contact 
    62   } DIALER_CONTACT; 
     57typedef struct dialer_contact { 
     58//  int ID;///<the unique ID for an contact entry 
     59  char * ID;///<the unique ID for an contact entry 
     60  char *name;           ///<person name 
     61  char *picpath;  ///<the picture file path for the person 
     62  DIALER_CONTACT_ENTRY * entry;                    ///<first number entry for the person 
     63   
     64  struct dialer_contact* next;         ///<pointer to next contact 
     65}DIALER_CONTACT; 
    6366 
    6467 
     
    6669 * @brief contact  structure for open dialer. 
    6770 */ 
    68   typedef struct peer_info_ 
    69   { 
     71typedef struct peer_info_ 
     72{ 
    7073//we should at least have the number called. 
    71     char number[MOKO_DIALER_MAX_NUMBER_LEN + 1];        ///<the number of the peer 
    72     char *name;                 ///<person name 
    73     char *picpath;              ///<the picture file path for the person 
    74     int searched;               ///<if true; no need to search for the name  
    75     int hasname;                ///<if true, we the picpath & name can be used. 
    76   } DIALER_CONTACT_PEER_INFO; 
     74  char number[MOKO_DIALER_MAX_NUMBER_LEN+1];        ///<the number of the peer 
     75  char *name;           ///<person name 
     76  char *ID;             ///<the id in the addressbook, we count on it to load photo 
     77  char *picpath;  ///<the picture file path for the person 
     78  int searched; ///<if true; no need to search for the name  
     79  int hasname; ///<if true, we the picpath & name can be used. 
     80}DIALER_CONTACT_PEER_INFO; 
    7781 
    7882 
    7983/** 
    8084 * @brief the structure for intelligent search results. 
    81  */ 
    82   typedef struct dialer_ready_contact 
    83   { 
    84     DIALER_CONTACT_ENTRY *p_entry; 
    85     DIALER_CONTACT *p_contact; 
    86   } DIALER_READY_CONTACT; 
     85 */      
     86typedef struct dialer_ready_contact 
     87{ 
     88        DIALER_CONTACT_ENTRY* p_entry; 
     89        DIALER_CONTACT* p_contact; 
     90}DIALER_READY_CONTACT; 
    8791 
    8892/** 
    8993 * @brief contacts list head structure. 
    9094 */ 
    91   typedef struct dialer_contacts_list_head 
    92   { 
    93     int length;                 ///<the number of contacts 
    94     DIALER_CONTACT *contacts;   ///<package list head pointer 
    95   } DIALER_CONTACTS_LIST_HEAD; 
     95typedef struct dialer_contacts_list_head { 
     96  int length;                   ///<the number of contacts 
     97  DIALER_CONTACT *contacts;        ///<package list head pointer 
     98}DIALER_CONTACTS_LIST_HEAD; 
    9699 
     100int contact_load_contact_photo(GtkImage* image,const char* id); 
     101int contact_init_contact_list(DIALER_CONTACTS_LIST_HEAD * head); 
     102int contact_release_contact_entry(DIALER_CONTACT_ENTRY* contactentry); 
     103int contact_release_contact(DIALER_CONTACT *contact); 
     104int contact_release_contact_list(DIALER_CONTACTS_LIST_HEAD * head); 
     105int contact_init_from_cmd(DIALER_CONTACTS_LIST_HEAD * head); 
     106int contact_get_info_from_number(DIALER_CONTACT* contacts,char* name,char* picpath,const char* number); 
     107int contact_get_peer_info_from_number(DIALER_CONTACT* contacts, DIALER_CONTACT_PEER_INFO * peer); 
     108int contact_init_contact_data(DIALER_CONTACTS_LIST_HEAD   *p_contactlist); 
     109int contact_print_contact_list(DIALER_CONTACTS_LIST_HEAD * head); 
     110int contact_string_has_sensentive (char * content, char *string); 
    97111 
    98   int contact_init_contact_list (DIALER_CONTACTS_LIST_HEAD * head); 
    99   int contact_release_contact_entry (DIALER_CONTACT_ENTRY * contactentry); 
    100   int contact_release_contact (DIALER_CONTACT * contact); 
    101   int contact_release_contact_list (DIALER_CONTACTS_LIST_HEAD * head); 
    102   int contact_init_from_cmd (DIALER_CONTACTS_LIST_HEAD * head); 
    103   int contact_get_info_from_number (DIALER_CONTACT * contacts, char *name, 
    104                                     char *picpath, const char *number); 
    105   int contact_get_peer_info_from_number (DIALER_CONTACT * contacts, 
    106                                          DIALER_CONTACT_PEER_INFO * peer); 
    107   int contact_init_contact_data (DIALER_CONTACTS_LIST_HEAD * p_contactlist); 
    108   int contact_print_contact_list (DIALER_CONTACTS_LIST_HEAD * head); 
    109   int contact_string_has_sensentive (char *content, char *string); 
    110112#ifdef __cplusplus 
    111113} 
    112114#endif 
    113115 
    114 #endif                          /* _CONTACTS_H */ 
     116#endif /* _CONTACTS_H */ 
     117 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.c

    r648 r649  
    2222 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
    2323 */ 
    24  
    25 #include "history.h" 
    26 #include "error.h" 
     24  
     25#include "history.h"  
     26#include "error.h"  
    2727#include <stdlib.h> 
    2828/** 
     
    3535 * @retval 
    3636 */ 
    37 int 
    38 history_read_list (HISTORY_LIST_HEAD * historyhead) 
    39 { 
    40   return 0; 
     37int history_read_list(HISTORY_LIST_HEAD* historyhead) 
     38{ 
     39        return 0; 
    4140} 
    4241 
     
    5251 * @retval other success 
    5352 */ 
    54 int 
    55 history_read_list_cmd (HISTORY_LIST_HEAD * historyhead) 
    56 { 
    57  
    58   historyhead->length = 0; 
    59   historyhead->first = 0; 
    60   historyhead->last = 0; 
    61   history_add_entry (historyhead, MISSED, "", "1391721112", 
    62                      "", "17:58", "12/20", 100); 
    63  
    64   history_add_entry (historyhead, INCOMING, "tony", "13917309523", 
    65                      "./tony.png", "13:58", "12/20", 10); 
    66   history_add_entry (historyhead, OUTGOING, "sally", "13361900551", 
    67                      "./sally.png", "10:58", "12/20", 106); 
    68   history_add_entry (historyhead, MISSED, "chaowei", "1391110923", 
    69                      "./chaowei.png", "11:58", "12/20", 120); 
    70   history_add_entry (historyhead, OUTGOING, "", "1395721111", 
    71                      "", "17:58", "12/20", 100); 
    72  
    73   history_add_entry (historyhead, INCOMING, "steven", "1391721111", 
    74                      "./steven.png", "17:58", "12/20", 100); 
    75   history_add_entry (historyhead, INCOMING, "ken", "1381720923", 
    76                      "./ken.png", "18:58", "12/20", 200); 
    77   history_add_entry (historyhead, MISSED, "", "1391721113", 
    78                      "", "17:58", "12/20", 100); 
    79   history_add_entry (historyhead, MISSED, "", "1394721111", 
    80                      "", "17:58", "12/20", 100); 
    81   history_add_entry (historyhead, MISSED, "", "1396721111", 
    82                      "", "17:58", "12/20", 100); 
    83   return historyhead->length; 
    84  
    85 } 
    86  
     53int history_read_list_cmd(HISTORY_LIST_HEAD* historyhead) 
     54{ 
     55         
     56historyhead->length=0; 
     57historyhead->first=0; 
     58historyhead->last=0; 
     59        history_add_entry(historyhead,MISSED,"","1391721112", 
     60        "","17:58","12/20",100); 
     61 
     62        history_add_entry(historyhead,INCOMING,"tony","13917309523", 
     63        "./tony.png","13:58","12/20",10); 
     64history_add_entry(historyhead,OUTGOING,"sally","13361900551", 
     65        "./sally.png","10:58","12/20",106); 
     66history_add_entry(historyhead,MISSED,"chaowei","1391110923", 
     67        "./chaowei.png","11:58","12/20",120); 
     68        history_add_entry(historyhead,OUTGOING,"","1395721111", 
     69        "","17:58","12/20",100); 
     70 
     71        history_add_entry(historyhead,INCOMING,"steven","1391721111", 
     72        "./steven.png","17:58","12/20",100); 
     73history_add_entry(historyhead,INCOMING,"ken","1381720923", 
     74        "./ken.png","18:58","12/20",200); 
     75        history_add_entry(historyhead,MISSED,"","1391721113", 
     76        "","17:58","12/20",100); 
     77        history_add_entry(historyhead,MISSED,"","1394721111", 
     78        "","17:58","12/20",100); 
     79        history_add_entry(historyhead,MISSED,"","1396721111", 
     80        "","17:58","12/20",100); 
     81return historyhead->length; 
     82 
     83} 
    8784/*  
    8885typedef struct historyentry 
     
    110107 * @retval 1 success 
    111108 */ 
    112 int 
    113 history_delete_entry (HISTORY_LIST_HEAD * historyhead, HISTORY_ENTRY * entry) 
    114 { 
    115   DBG_ENTER (); 
    116   if (entry == 0) 
    117     return 0; 
    118   if (entry->number == 0) 
    119     return 0; 
    120   if (entry->prev == 0 && entry->next == 0) 
    121     return 0; 
    122  
    123   DBG_MESSAGE ("deleting %s", entry->number); 
    124  
    125   if (entry->prev) 
    126   { 
    127     entry->prev->next = entry->next; 
    128   } 
    129   else 
    130   {                             //entry is the first one. 
    131     historyhead->first = entry->next; 
    132   } 
    133  
    134   if (entry->next) 
    135   { 
    136     entry->next->prev = entry->prev; 
    137   } 
    138   else 
    139   { 
    140     historyhead->last = entry->prev; 
    141   } 
    142  
    143   history_release_entry (entry); 
    144  
    145   historyhead->length--; 
    146   return historyhead->length; 
     109int history_delete_entry(HISTORY_LIST_HEAD* historyhead,HISTORY_ENTRY* entry) 
     110{ 
     111        DBG_ENTER(); 
     112        if(entry==0)return 0; 
     113        if(entry->number==0)return 0; 
     114        if(entry->prev==0&&entry->next==0)return 0; 
     115                 
     116        DBG_MESSAGE("deleting %s",entry->number); 
     117         
     118        if(entry->prev) 
     119        { 
     120                entry->prev->next=entry->next; 
     121        } 
     122        else 
     123        {//entry is the first one. 
     124                historyhead->first=entry->next; 
     125        } 
     126         
     127        if(entry->next) 
     128        { 
     129                entry->next->prev=entry->prev; 
     130        } 
     131        else 
     132        { 
     133                historyhead->last=entry->prev; 
     134        } 
     135 
     136        history_release_entry(entry); 
     137 
     138        historyhead->length--; 
     139        return historyhead->length; 
    147140} 
    148141 
     
    163156 * @retval the newly created entry pointer 
    164157 */ 
    165 HISTORY_ENTRY * 
    166 history_add_entry (HISTORY_LIST_HEAD * historyhead, HISTORY_TYPE type, 
    167                    const char *name, const char *number, const char *picpath, 
    168                    char *time, char *date, int durationsec) 
    169 { 
    170  
    171   DBG_ENTER (); 
    172   HISTORY_ENTRY *pentry = 
    173     (HISTORY_ENTRY *) calloc (1, sizeof (HISTORY_ENTRY)); 
    174  
    175 //      DBG_MESSAGE("pentry add:0X%x",pentry); 
    176  
    177   if (name && strlen (name) > 0) 
    178   { 
    179     pentry->name = (char *) calloc (1, strlen (name) + 1); 
    180     strcpy (pentry->name, name); 
    181     pentry->hasname = 1; 
    182   } 
    183   else 
    184   { 
    185     pentry->name = 0; 
    186     pentry->hasname = 0; 
    187   } 
    188  
    189   if (number && strlen (number) > 0) 
    190   { 
    191     pentry->number = (char *) calloc (1, strlen (number) + 1); 
    192     strcpy (pentry->number, number); 
    193   } 
    194   else 
    195   { 
    196     //release memory, and return; 
    197     history_release_entry (pentry); 
    198     return 0; 
    199   } 
    200  
    201   //DBG_MESSAGE("History add:0X%x,%s,%s,%s,%s,%s,%d",historyhead,name,number,picpath,time,date,durationsec); 
    202  
    203   if (picpath && strlen (picpath) > 0) 
    204   { 
    205     pentry->picpath = (char *) calloc (1, strlen (picpath) + 1); 
    206     strcpy (pentry->picpath, picpath); 
    207   } 
    208   if (time && strlen (time) > 0) 
    209   { 
    210     pentry->time = (char *) calloc (1, strlen (time) + 1); 
    211     strcpy (pentry->time, time); 
    212   } 
    213   pentry->durationsec = durationsec; 
    214  
    215   pentry->type = type; 
    216   historyhead->length++; 
    217   pentry->ID = historyhead->length; 
    218  
    219   if (historyhead->first) 
    220   {                             //DBG_TRACE(); 
    221     //DBG_MESSAGE("first=0x%x",historyhead->first); 
    222     //DBG_MESSAGE("first=%s",historyhead->first->number); 
    223     historyhead->first->prev = pentry; 
    224     //DBG_TRACE(); 
    225     pentry->next = historyhead->first; 
    226     //DBG_TRACE(); 
    227     historyhead->first = pentry; 
    228     //DBG_TRACE(); 
    229   } 
    230   else 
    231   {                             //DBG_TRACE(); 
    232     historyhead->first = pentry; 
    233     historyhead->last = pentry; 
    234   } 
    235 //      DBG_LEAVE(); 
    236   return pentry; 
    237 } 
    238  
    239 int 
    240 history_release_entry (HISTORY_ENTRY * pentry) 
    241 { 
    242   if (!pentry) 
    243     return 1; 
    244   if (pentry->name) 
    245   { 
    246     free (pentry->name); 
    247     pentry->name = 0; 
    248   } 
    249   if (pentry->number) 
    250   { 
    251     free (pentry->number); 
    252     pentry->number = 0; 
    253   } 
    254   if (pentry->picpath) 
    255   { 
    256     free (pentry->picpath); 
    257     pentry->picpath = 0; 
    258   } 
    259   if (pentry->time) 
    260   { 
    261     free (pentry->time); 
    262     pentry->time = 0; 
    263   } 
    264   if (pentry->date) 
    265   { 
    266     free (pentry->date); 
    267     pentry->date = 0; 
    268   } 
    269  
    270   pentry->prev = 0; 
    271   pentry->next = 0; 
    272   free (pentry); 
    273   pentry = 0; 
    274   return 1; 
     158HISTORY_ENTRY * history_add_entry(HISTORY_LIST_HEAD* historyhead, HISTORY_TYPE type, 
     159const char *name,const char *number,const char *id,  char *time,char *date,int durationsec) 
     160{ 
     161 
     162        DBG_ENTER(); 
     163        HISTORY_ENTRY * pentry=(HISTORY_ENTRY *)calloc(1,sizeof(HISTORY_ENTRY )); 
     164 
     165//      DBG_MESSAGE("pentry add:0X%x",pentry); 
     166         
     167        if(name&&strlen(name)>0) 
     168        {       pentry->name=(char*)calloc(1,strlen(name)+1); 
     169                strcpy(pentry->name,name); 
     170                pentry->hasname=1; 
     171        } 
     172        else 
     173                { 
     174                pentry->name=0; 
     175                pentry->hasname=0; 
     176                } 
     177 
     178        if(number&&strlen(number)>0) 
     179        { 
     180                pentry->number=(char*)calloc(1,strlen(number)+1); 
     181                strcpy(pentry->number,number); 
     182        } 
     183        else 
     184                { 
     185                //release memory, and return; 
     186                history_release_entry(pentry); 
     187                return 0; 
     188                } 
     189 
     190        //DBG_MESSAGE("History add:0X%x,%s,%s,%s,%s,%s,%d",historyhead,name,number,picpath,time,date,durationsec); 
     191         
     192        if(id&&strlen(id)>0) 
     193        { 
     194                pentry->ID=(char*)calloc(1,strlen(id)+1); 
     195                strcpy(pentry->ID,id); 
     196        } 
     197                if(time&&strlen(time)>0) 
     198        { 
     199                pentry->time=(char*)calloc(1,strlen(time)+1); 
     200                strcpy(pentry->time,time); 
     201        } 
     202                pentry->durationsec=durationsec; 
     203         
     204        pentry->type=type; 
     205        historyhead->length++; 
     206         
     207         
     208        if(historyhead->first) 
     209        {       //DBG_TRACE(); 
     210                //DBG_MESSAGE("first=0x%x",historyhead->first); 
     211                //DBG_MESSAGE("first=%s",historyhead->first->number); 
     212                historyhead->first->prev=pentry; 
     213                //DBG_TRACE(); 
     214                pentry->next=historyhead->first; 
     215                //DBG_TRACE(); 
     216                historyhead->first=pentry; 
     217                //DBG_TRACE(); 
     218        } 
     219        else 
     220        {//DBG_TRACE(); 
     221                historyhead->first=pentry; 
     222                historyhead->last=pentry; 
     223        } 
     224//      DBG_LEAVE(); 
     225        return pentry; 
     226} 
     227 
     228int history_release_entry(HISTORY_ENTRY * pentry) 
     229{ 
     230if(!pentry)return 1; 
     231if(pentry->name) 
     232{ 
     233free(pentry->name); 
     234pentry->name=0; 
     235} 
     236if(pentry->number) 
     237{ 
     238free(pentry->number); 
     239pentry->number=0; 
     240} 
     241if(pentry->ID) 
     242{ 
     243free(pentry->ID); 
     244pentry->ID=0; 
     245} 
     246if(pentry->time) 
     247{ 
     248free(pentry->time); 
     249pentry->time=0; 
     250} 
     251if(pentry->date) 
     252{ 
     253free(pentry->date); 
     254pentry->date=0; 
     255} 
     256 
     257pentry->prev=0; 
     258pentry->next=0; 
     259free(pentry); 
     260pentry=0; 
     261return 1; 
    275262 
    276263} 
     
    286273 * @retval 1 success 
    287274 */ 
    288 int 
    289 history_release_history_list (HISTORY_LIST_HEAD * historyhead) 
    290 { 
    291   HISTORY_ENTRY *pentry; 
    292   HISTORY_ENTRY *next; 
    293   pentry = historyhead->first; 
    294   while (pentry) 
    295   { 
    296     next = pentry->next; 
    297     history_release_entry (pentry); 
    298     pentry = next; 
    299   } 
    300   historyhead->first = 0; 
    301   historyhead->last = 0; 
    302   historyhead->length = 0; 
    303   return 1; 
    304 } 
    305  
    306 int 
    307 history_init_history_data (HISTORY_LIST_HEAD * historyhead) 
    308 { 
    309  
    310   DBG_ENTER (); 
    311   int res = history_read_list (historyhead); 
    312  
    313   if (res == 0) 
     275int history_release_history_list(HISTORY_LIST_HEAD* historyhead) 
     276{ 
     277        HISTORY_ENTRY * pentry; 
     278        HISTORY_ENTRY * next; 
     279        pentry=historyhead->first; 
     280        while(pentry) 
     281                { 
     282                next=pentry->next; 
     283                history_release_entry(pentry); 
     284                pentry=next; 
     285                } 
     286        historyhead->first=0; 
     287        historyhead->last=0; 
     288        historyhead->length=0; 
     289        return 1; 
     290} 
     291 
     292int history_init_history_data(HISTORY_LIST_HEAD* historyhead) 
     293{ 
     294 
     295 DBG_ENTER(); 
     296  int res = history_read_list(historyhead); 
     297 
     298  if(res == 0) 
    314299  { 
    315300    res = history_read_list_cmd (historyhead); 
    316301  } 
    317   DBG_MESSAGE ("History:%d", historyhead->length); 
    318   DBG_LEAVE (); 
     302  DBG_MESSAGE("History:%d",historyhead->length); 
     303  DBG_LEAVE(); 
    319304  return res; 
    320305} 
     306 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/history.h

    r648 r649  
    2222 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
    2323 */ 
    24  
     24  
    2525#ifndef _HISTORY_H 
    2626#define _HISTORY_H 
     
    3131 
    3232extern "C" 
     33 
    3334{ 
    3435#endif 
    3536 
    36  
     37         
    3738 
    3839/** 
    3940 * @brief enum of history type 
    4041 */ 
    41  
    42   typedef enum _historytype 
    43   { 
    44     INCOMING = 0,               ///<incoming calls 
    45     OUTGOING,                   ///<outgoing calls 
    46     MISSED,                     ///<missed calls  
    47     ALL                         ///<all the types including the above 
    48   } HISTORY_TYPE; 
     42         
     43typedef enum _historytype{ 
     44        INCOMING=0, ///<incoming calls 
     45        OUTGOING,///<outgoing calls 
     46        MISSED,///<missed calls  
     47        ALL ///<all the types including the above 
     48}HISTORY_TYPE; 
    4949 
    5050/** 
    5151 * @brief history entry item structure 
    5252 */ 
    53   typedef struct historyentry 
    54   { 
    55     int ID;                     ///<the unique ID for an contact entry  
    56     HISTORY_TYPE type; 
    57     char *name;                 ///<person name 
    58     char *number;               ///<person number 
    59     char *picpath;              ///<the picture file path for the person 
    60     char *time;                 ///< start time of that talk  
    61     char *date;                 ///<start date  of that talk 
    62     int durationsec;            ///<seconds of the duaration  
    63     struct historyentry *next;  ///<pointer to next entry 
    64     struct historyentry *prev;  ///<pointer to next entry 
    65     int hasname; 
    66   } HISTORY_ENTRY; 
     53typedef struct historyentry 
     54{ 
     55  int ID;///<the unique ID for an contact entry  
     56  HISTORY_TYPE type; 
     57  char *name;           ///<person name 
     58  char *number;         ///<person number 
     59//  char *id;  ///<the id 
     60  char *time;   ///< start time of that talk  
     61  char *date;///<start date  of that talk 
     62  int durationsec;///<seconds of the duaration  
     63  struct historyentry* next;         ///<pointer to next entry 
     64  struct historyentry* prev;         ///<pointer to next entry 
     65  int hasname; 
     66}HISTORY_ENTRY; 
    6767 
    6868 
     
    7070 * @brief contacts list head structure. 
    7171 */ 
    72   typedef struct history_list_head 
    73   { 
    74     int length;                 ///<the number of history 
    75     HISTORY_ENTRY *first;       ///<list head pointer 
    76     HISTORY_ENTRY *last;        ///<list head pointer 
    77   } HISTORY_LIST_HEAD; 
     72typedef struct history_list_head { 
     73  int length;                   ///<the number of history 
     74  HISTORY_ENTRY *first;        ///<list head pointer 
     75  HISTORY_ENTRY *last;        ///<list head pointer 
     76}HISTORY_LIST_HEAD; 
    7877/** 
    7978 * @brief read the history list using the external APIs,currently only return 0 
     
    8584 * @retval other success 
    8685 */ 
    87   int history_read_list (HISTORY_LIST_HEAD * historyhead); 
     86int history_read_list(HISTORY_LIST_HEAD* historyhead); 
    8887 
    8988/** 
     
    9796 * @retval other success 
    9897 */ 
    99   int history_read_list_cmd (HISTORY_LIST_HEAD * historyhead); 
     98int history_read_list_cmd(HISTORY_LIST_HEAD* historyhead); 
    10099 
    101100/** 
     
    109108 * @retval 1 success 
    110109 */ 
    111   int history_release_history_list (HISTORY_LIST_HEAD * historyhead); 
     110int history_release_history_list(HISTORY_LIST_HEAD* historyhead); 
    112111 
    113112/** 
     
    124123 * @retval the newly created entry pointer 
    125124 */ 
    126   HISTORY_ENTRY *history_add_entry (HISTORY_LIST_HEAD * historyhead, 
    127                                     HISTORY_TYPE type, const char *name, 
    128                                     const char *number, const char *picpath, 
    129                                     char *time, char *date, int durationsec); 
     125HISTORY_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); 
    130126/** 
    131127 * @brief delete the supplied entry from the list  
     
    139135 * @retval 1 success 
    140136 */ 
    141   int history_delete_entry (HISTORY_LIST_HEAD * historyhead, 
    142                             HISTORY_ENTRY * entry); 
     137int history_delete_entry(HISTORY_LIST_HEAD* historyhead,HISTORY_ENTRY* entry); 
    143138 
    144   int history_init_history_data (HISTORY_LIST_HEAD * historyhead); 
     139int history_init_history_data(HISTORY_LIST_HEAD* historyhead); 
    145140#ifdef __cplusplus 
    146141} 
    147142#endif 
    148143 
    149 #endif                          /* _HISTORY_H */ 
     144#endif /* _HISTORY_H */ 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-autolist.c

    r648 r649  
    1717 */ 
    1818 
    19 #include "moko-dialer-autolist.h" 
    20 #include "error.h" 
    21 #include "common.h" 
     19 #include "moko-dialer-autolist.h" 
     20  #include "error.h" 
     21#include "common.h"  
    2222G_DEFINE_TYPE (MokoDialerAutolist, moko_dialer_autolist, GTK_TYPE_HBOX) 
    23      enum 
    24     { 
    25        SELECTED_SIGNAL, 
    26        CONFIRMED_SIGNAL, 
    27        NOMATCH_SIGNAL, 
    28        LAST_SIGNAL 
    29      }; 
     23 
     24enum { 
     25  SELECTED_SIGNAL, 
     26  CONFIRMED_SIGNAL, 
     27  NOMATCH_SIGNAL, 
     28  LAST_SIGNAL 
     29}; 
    3030 
    3131//forward definition 
    3232 
    33      gboolean on_tip_press_event (MokoDialerTip * tip, GdkEventButton * event, 
    34                                   gpointer user_data); 
    35  
    36      static gint moko_dialer_autolist_signals[LAST_SIGNAL] = { 0 }; 
     33gboolean on_tip_press_event (MokoDialerTip       *tip,GdkEventButton  *event,gpointer        user_data); 
     34 
     35static gint moko_dialer_autolist_signals[LAST_SIGNAL] = { 0 }; 
    3736 
    3837static void 
    39 moko_dialer_autolist_class_init (MokoDialerAutolistClass * class) 
     38moko_dialer_autolist_class_init (MokoDialerAutolistClass *class) 
    4039{ 
    4140/* 
     
    4746  GtkObjectClass *object_class; 
    4847 
    49   object_class = (GtkObjectClass *) class; 
    50  
    51   g_print ("moko_dialer_autolist:start signal register\n"); 
    52  
    53   moko_dialer_autolist_signals[SELECTED_SIGNAL] = 
    54     g_signal_new ("user_selected", 
    55                   G_OBJECT_CLASS_TYPE (object_class), 
    56                   G_SIGNAL_RUN_FIRST, 
    57                   G_STRUCT_OFFSET (MokoDialerAutolistClass, 
    58                                    moko_dialer_autolist_selected), NULL, NULL, 
    59                   g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, 
    60                   g_type_from_name ("gpointer")); 
    61  
    62  
    63  
    64  
    65  
    66   moko_dialer_autolist_signals[CONFIRMED_SIGNAL] = 
    67     g_signal_new ("user_confirmed", 
    68                   G_OBJECT_CLASS_TYPE (object_class), 
    69                   G_SIGNAL_RUN_FIRST, 
    70                   G_STRUCT_OFFSET (MokoDialerAutolistClass, 
    71                                    moko_dialer_autolist_confirmed), NULL, 
    72                   NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, 
    73                   g_type_from_name ("gpointer")); 
     48  object_class = (GtkObjectClass*) class; 
     49 
     50 g_print("moko_dialer_autolist:start signal register\n"); 
     51   
     52  moko_dialer_autolist_signals[SELECTED_SIGNAL] =  
     53                g_signal_new ("user_selected", 
     54               G_OBJECT_CLASS_TYPE (object_class), 
     55                G_SIGNAL_RUN_FIRST, 
     56                 G_STRUCT_OFFSET (MokoDialerAutolistClass, moko_dialer_autolist_selected), 
     57               NULL,NULL, 
     58               g_cclosure_marshal_VOID__POINTER, 
     59                G_TYPE_NONE, 1,g_type_from_name("gpointer")); 
     60 
     61 
     62 
     63 
     64 
     65  moko_dialer_autolist_signals[CONFIRMED_SIGNAL] =  
     66                g_signal_new ("user_confirmed", 
     67               G_OBJECT_CLASS_TYPE (object_class), 
     68                G_SIGNAL_RUN_FIRST, 
     69                 G_STRUCT_OFFSET (MokoDialerAutolistClass, moko_dialer_autolist_confirmed), 
     70               NULL,NULL, 
     71               g_cclosure_marshal_VOID__POINTER, 
     72                G_TYPE_NONE, 1,g_type_from_name("gpointer")); 
    7473 
    7574//moko_dialer_autolist_nomatch 
    76   moko_dialer_autolist_signals[NOMATCH_SIGNAL] = 
    77     g_signal_new ("autolist_nomatch", 
    78                   G_OBJECT_CLASS_TYPE (object_class), 
    79                   G_SIGNAL_RUN_FIRST, 
    80                   G_STRUCT_OFFSET (MokoDialerAutolistClass, 
    81                                    moko_dialer_autolist_nomatch), NULL, NULL, 
    82                   g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); 
     75  moko_dialer_autolist_signals[NOMATCH_SIGNAL] =  
     76                g_signal_new ("autolist_nomatch", 
     77               G_OBJECT_CLASS_TYPE (object_class), 
     78                G_SIGNAL_RUN_FIRST, 
     79                 G_STRUCT_OFFSET (MokoDialerAutolistClass, moko_dialer_autolist_nomatch), 
     80               NULL,NULL, 
     81               g_cclosure_marshal_VOID__VOID, 
     82                G_TYPE_NONE, 0); 
    8383 
    8484 
     
    8888 
    8989static void 
    90 moko_dialer_autolist_init (MokoDialerAutolist * moko_dialer_autolist) 
     90moko_dialer_autolist_init (MokoDialerAutolist *moko_dialer_autolist) 
    9191{ 
    9292//DBG_ENTER(); 
    93   int i; 
    94   for (i = 0; i < MOKO_DIALER_MAX_TIPS; i++) 
    95     moko_dialer_autolist->tips[i] = 0; 
    96   moko_dialer_autolist->tipscreated = FALSE; 
    97   moko_dialer_autolist->head = 0; 
    98   moko_dialer_autolist->g_alternatecount = 0; 
    99   moko_dialer_autolist->imagePerson = 0; 
    100   gtk_widget_set_size_request (GTK_WIDGET (moko_dialer_autolist), 480, 40); 
    101  
    102 } 
    103  
     93int i; 
     94for(i=0;i<MOKO_DIALER_MAX_TIPS;i++) 
     95        moko_dialer_autolist->tips[i]=0; 
     96moko_dialer_autolist->  tipscreated=FALSE;   
     97moko_dialer_autolist->head=0; 
     98moko_dialer_autolist->g_alternatecount=0; 
     99moko_dialer_autolist->imagePerson=0; 
     100gtk_widget_set_size_request (GTK_WIDGET(moko_dialer_autolist), 480, 40);  
     101 
     102} 
    104103/** 
    105104 * @brief please call this function first before the autolist start to work. 
    106105*/ 
    107 gboolean 
    108 moko_dialer_autolist_set_data (MokoDialerAutolist * moko_dialer_autolist, 
    109                                DIALER_CONTACTS_LIST_HEAD * head) 
     106gboolean moko_dialer_autolist_set_data (MokoDialerAutolist *moko_dialer_autolist,DIALER_CONTACTS_LIST_HEAD* head) 
    110107{ 
    111108/* 
     
    113110        contact_release_contact_list(moko_dialer_autolist->head); 
    114111        */ 
    115  
    116   moko_dialer_autolist->head = head; 
     112         
     113moko_dialer_autolist->head=head; 
    117114 
    118115//contact_print_contact_list(moko_dialer_autolist->head); 
    119116 
    120   return TRUE; 
    121 } 
    122  
    123 gint 
    124 moko_dialer_autolist_hide_all_tips (MokoDialerAutolist * moko_dialer_autolist) 
    125 { 
    126  
    127   if (moko_dialer_autolist->tipscreated) 
    128   { 
    129     moko_dialer_autolist->selected = FALSE; 
    130     //no alternative, hide all 3 labels. 
    131     gint i; 
    132     for (i = 0; i < MOKO_DIALER_MAX_TIPS; i++) 
    133     { 
    134       moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE); 
    135       gtk_widget_hide (moko_dialer_autolist->tips[i]); 
    136     } 
    137     //hide the imagePerson 
    138     gtk_widget_hide (moko_dialer_autolist->imagePerson); 
    139   } 
    140   return 1; 
     117return TRUE; 
     118} 
     119 
     120gint moko_dialer_autolist_hide_all_tips(MokoDialerAutolist *moko_dialer_autolist) 
     121{ 
     122 
     123if(moko_dialer_autolist->tipscreated) 
     124{ 
     125                moko_dialer_autolist->selected=FALSE; 
     126                        //no alternative, hide all 3 labels. 
     127                        gint i; 
     128                for(i=0;i<MOKO_DIALER_MAX_TIPS;i++) 
     129                { 
     130                moko_dialer_tip_set_selected(moko_dialer_autolist->tips[i],FALSE); 
     131                gtk_widget_hide(moko_dialer_autolist->tips[i]); 
     132                } 
     133                //hide the imagePerson 
     134                gtk_widget_hide(moko_dialer_autolist->imagePerson); 
     135} 
     136                return 1; 
    141137 
    142138} 
     
    154150 */ 
    155151 
    156 int 
    157 moko_dialer_autolist_fill_alternative (MokoDialerAutolist * 
    158                                        moko_dialer_autolist, gint count, 
    159                                        gboolean selectdefault) 
    160 { 
    161   gint i; 
     152int moko_dialer_autolist_fill_alternative(MokoDialerAutolist *moko_dialer_autolist,gint count,gboolean selectdefault) 
     153{ 
     154gint i; 
    162155//DBG_ENTER(); 
    163   moko_dialer_autolist->selected = FALSE; 
    164  
    165   moko_dialer_autolist->g_alternatecount = count; 
    166  
    167   if (count > 0) 
    168   { 
    169     //init the labels. 
    170     for (i = 0; i < count && i < MOKO_DIALER_MAX_TIPS; i++) 
    171     { 
    172       moko_dialer_tip_set_label (moko_dialer_autolist->tips[i], 
    173                                  moko_dialer_autolist->readycontacts[i]. 
    174                                  p_contact->name); 
    175       moko_dialer_tip_set_index (moko_dialer_autolist->tips[i], i); 
    176       moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE); 
    177       gtk_widget_show (moko_dialer_autolist->tips[i]); 
    178     } 
    179  
    180     for (; i < MOKO_DIALER_MAX_TIPS; i++) 
    181     { 
    182       moko_dialer_tip_set_index (moko_dialer_autolist->tips[i], -1); 
    183       moko_dialer_tip_set_label (moko_dialer_autolist->tips[i], ""); 
    184       gtk_widget_hide (moko_dialer_autolist->tips[i]); 
    185       moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE); 
    186     } 
    187  
    188     if (selectdefault) 
    189     { 
    190       //we set the first one as defaultly selected 
    191       moko_dialer_autolist_set_select (moko_dialer_autolist, 0); 
    192     } 
    193   } 
    194   else 
    195   { 
    196     moko_dialer_autolist_hide_all_tips (moko_dialer_autolist); 
    197     //notify the client that no match has been foudn 
    198 //              autolist_nomatch 
    199     g_signal_emit (moko_dialer_autolist, 
    200                    moko_dialer_autolist_signals[NOMATCH_SIGNAL], 0, 0); 
    201   } 
    202   return 1; 
     156moko_dialer_autolist->selected=FALSE; 
     157 
     158moko_dialer_autolist->g_alternatecount=count; 
     159 
     160if(count>0) 
     161{ 
     162        //init the labels. 
     163        for(i=0;i<count&&i<MOKO_DIALER_MAX_TIPS;i++) 
     164        { 
     165        moko_dialer_tip_set_label(moko_dialer_autolist->tips[i],moko_dialer_autolist->readycontacts[i].p_contact->name); 
     166        moko_dialer_tip_set_index(moko_dialer_autolist->tips[i],i); 
     167        moko_dialer_tip_set_selected(moko_dialer_autolist->tips[i],FALSE); 
     168        gtk_widget_show(moko_dialer_autolist->tips[i]); 
     169        } 
     170 
     171        for(;i<MOKO_DIALER_MAX_TIPS;i++) 
     172        { 
     173        moko_dialer_tip_set_index(moko_dialer_autolist->tips[i],-1); 
     174        moko_dialer_tip_set_label(moko_dialer_autolist->tips[i],""); 
     175        gtk_widget_hide(moko_dialer_autolist->tips[i]); 
     176        moko_dialer_tip_set_selected(moko_dialer_autolist->tips[i],FALSE); 
     177        } 
     178 
     179        if(selectdefault) 
     180        { 
     181                //we set the first one as defaultly selected 
     182                moko_dialer_autolist_set_select(moko_dialer_autolist, 0); 
     183        } 
     184}        
     185else 
     186        { 
     187        moko_dialer_autolist_hide_all_tips(moko_dialer_autolist);        
     188                //notify the client that no match has been foudn 
     189//              autolist_nomatch 
     190   g_signal_emit (moko_dialer_autolist,   moko_dialer_autolist_signals[NOMATCH_SIGNAL],0,0); 
     191        } 
     192        return 1; 
    203193} 
    204194 
    205195//if selectdefault, then we will automatically emit the message to fill the sensed string 
    206196//else, we only refresh our tip list. 
    207 gint 
    208 moko_dialer_autolist_refresh_by_string (MokoDialerAutolist * 
    209                                         moko_dialer_autolist, gchar * string, 
    210                                         gboolean selectdefault) 
     197gint  moko_dialer_autolist_refresh_by_string (MokoDialerAutolist *moko_dialer_autolist,gchar * string,gboolean selectdefault) 
    211198{ 
    212199//first, we fill the ready list 
    213200 
    214   DIALER_CONTACT *contacts;     //=moko_dialer_autolist->head->contacts; 
    215  
    216   DIALER_CONTACT_ENTRY *entry; 
    217  
    218   gint inserted = 0; 
    219  
    220  
     201  DIALER_CONTACT* contacts;//=moko_dialer_autolist->head->contacts; 
     202 
     203  DIALER_CONTACT_ENTRY* entry; 
     204 
     205  gint inserted=0; 
     206 
     207   
    221208  gint len; 
    222  
    223   if (string) 
    224     len = strlen (string); 
     209   
     210  if(string) 
     211          len=strlen(string); 
    225212  else 
    226     len = 0; 
     213          len=0; 
    227214//  DBG_TRACE(); 
    228  
     215   
    229216//insert the tips here to avoid the _show_all show it from the start. 
    230   GtkWidget *imagePerson; 
    231   GtkWidget *tip; 
    232  
    233   if (!moko_dialer_autolist->tipscreated) 
    234   { 
    235     gchar filepath[MOKO_DIALER_MAX_PATH_LEN + 1]; 
    236     if (file_create_data_path_for_the_file 
    237         (MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH, filepath)) 
    238     { 
    239       imagePerson = gtk_image_new_from_file (filepath); 
    240     } 
    241     else 
    242     { 
    243       imagePerson = gtk_image_new_from_stock ("gtk-yes", GTK_ICON_SIZE_DND); 
    244     } 
    245     gtk_widget_hide (imagePerson); 
    246     gtk_widget_set_size_request (imagePerson, 40, 40); 
     217  GtkWidget * imagePerson; 
     218  GtkWidget * tip; 
     219 
     220if(!moko_dialer_autolist->tipscreated) 
     221{ 
     222  gchar filepath[MOKO_DIALER_MAX_PATH_LEN+1]; 
     223  if(file_create_data_path_for_the_file(MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH,filepath)) 
     224        { 
     225          imagePerson = gtk_image_new_from_file(filepath); 
     226        } 
     227  else 
     228        { 
     229        imagePerson=gtk_image_new_from_stock("gtk-yes",GTK_ICON_SIZE_DND); 
     230        } 
     231 gtk_widget_hide (imagePerson); 
     232 gtk_widget_set_size_request (imagePerson, 40, 40);      
    247233//  gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, TRUE, TRUE, 0); 
    248234//gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, TRUE, FALSE, 0); 
    249     gtk_box_pack_start (GTK_CONTAINER (moko_dialer_autolist), imagePerson, 
    250                         FALSE, FALSE, 0); 
    251  
    252     moko_dialer_autolist->imagePerson = imagePerson; 
    253     gint i; 
    254     for (i = 0; i < MOKO_DIALER_MAX_TIPS; i++) 
    255     { 
    256       tip = moko_dialer_tip_new (); 
    257  
    258       moko_dialer_tip_set_index (tip, i); 
    259  
    260       moko_dialer_tip_set_label (tip, "tony guan"); 
    261  
    262       moko_dialer_tip_set_selected (tip, FALSE); 
    263  
    264       gtk_box_pack_start (GTK_CONTAINER (moko_dialer_autolist), tip, TRUE, 
    265                           TRUE, 0); 
    266 //       gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, FALSE,FALSE, 0);                   
    267 //       gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, FALSE,TRUE, 0); 
    268 //                       gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, TRUE, FALSE,0); 
    269  
    270       g_signal_connect ((gpointer) tip, "button_press_event", 
    271                         G_CALLBACK (on_tip_press_event), 
    272                         moko_dialer_autolist); 
    273  
    274 //      gtk_widget_set_size_request (tip, 20, 20);       
    275  
    276       gtk_widget_hide (tip); 
    277  
    278       moko_dialer_autolist->tips[i] = tip; 
    279     } 
    280     moko_dialer_autolist->tipscreated = TRUE; 
     235 gtk_box_pack_start (GTK_CONTAINER(moko_dialer_autolist), imagePerson, FALSE, FALSE, 0); 
     236   
     237  moko_dialer_autolist->imagePerson=imagePerson; 
     238                        gint i; 
     239  for(i=0;i<MOKO_DIALER_MAX_TIPS;i++) 
     240        { 
     241        tip=moko_dialer_tip_new(); 
     242         
     243        moko_dialer_tip_set_index(tip, i); 
     244         
     245        moko_dialer_tip_set_label(tip,"tony guan"); 
     246 
     247        moko_dialer_tip_set_selected(tip,FALSE); 
     248 
     249         gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, TRUE, TRUE, 0);    
     250//       gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, FALSE,FALSE, 0);                   
     251//       gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, FALSE,TRUE, 0); 
     252//                       gtk_box_pack_start(GTK_CONTAINER(moko_dialer_autolist), tip, TRUE, FALSE,0); 
     253         
     254          g_signal_connect ((gpointer) tip, "button_press_event",G_CALLBACK (on_tip_press_event),moko_dialer_autolist); 
     255 
     256//      gtk_widget_set_size_request (tip, 20, 20);       
     257 
     258        gtk_widget_hide(tip); 
     259 
     260        moko_dialer_autolist-> tips[i]=tip; 
     261        } 
     262        moko_dialer_autolist->  tipscreated=TRUE; 
     263} 
     264 
     265 contacts=moko_dialer_autolist->head->contacts; 
     266 
     267//  DBG_MESSAGE("CONTACTS:%d,list@0x%x,first@0x%x",moko_dialer_autolist->head->length,moko_dialer_autolist->head,moko_dialer_autolist->head->contacts); 
     268 
     269//        DBG_TRACE();   
     270   while(contacts!= NULL&&inserted<MOKO_DIALER_MAX_TIPS) 
     271   { 
     272        //  DBG_TRACE(); 
     273      entry=contacts->entry; 
     274        //  DBG_TRACE(); 
     275         while(entry!=NULL&&inserted<MOKO_DIALER_MAX_TIPS) 
     276         { 
     277//       DBG_TRACE(); 
     278         //judge if the entry includes the string 
     279         if(contact_string_has_sensentive(entry->content,string)) 
     280         {       
     281                //if the person not inserted, then insert first 
     282        moko_dialer_autolist->readycontacts[inserted].p_contact=contacts; 
     283        moko_dialer_autolist->readycontacts[inserted].p_entry=entry; 
     284       inserted++; 
     285                 //break; 
     286         } 
     287            entry=entry->next; 
     288         } 
     289          
     290         contacts= contacts->next; 
     291         
    281292  } 
    282293 
    283   contacts = moko_dialer_autolist->head->contacts; 
    284  
    285 //  DBG_MESSAGE("CONTACTS:%d,list@0x%x,first@0x%x",moko_dialer_autolist->head->length,moko_dialer_autolist->head,moko_dialer_autolist->head->contacts); 
    286  
    287 //        DBG_TRACE();   
    288   while (contacts != NULL && inserted < MOKO_DIALER_MAX_TIPS) 
    289   { 
    290     //  DBG_TRACE(); 
    291     entry = contacts->entry; 
    292     //  DBG_TRACE(); 
    293     while (entry != NULL && inserted < MOKO_DIALER_MAX_TIPS) 
    294     { 
    295 //       DBG_TRACE(); 
    296       //judge if the entry includes the string 
    297       if (contact_string_has_sensentive (entry->content, string)) 
    298       { 
    299         //if the person not inserted, then insert first 
    300         moko_dialer_autolist->readycontacts[inserted].p_contact = contacts; 
    301         moko_dialer_autolist->readycontacts[inserted].p_entry = entry; 
    302         inserted++; 
    303         //break; 
    304       } 
    305       entry = entry->next; 
    306     } 
    307  
    308     contacts = contacts->next; 
    309  
    310   } 
    311  
    312294//DBG_MESSAGE("inserted=%d",inserted); 
    313   moko_dialer_autolist_fill_alternative (moko_dialer_autolist, inserted, 
    314                                          selectdefault); 
     295moko_dialer_autolist_fill_alternative(moko_dialer_autolist,inserted,selectdefault); 
    315296 
    316297//DBG_LEAVE(); 
     
    318299} 
    319300 
    320 gboolean 
    321 on_tip_press_event (MokoDialerTip * tip, GdkEventButton * event, 
    322                     gpointer user_data) 
     301gboolean on_tip_press_event (MokoDialerTip       *tip,GdkEventButton  *event,gpointer         user_data) 
    323302{ 
    324303 
    325304//DBG_ENTER(); 
    326   MokoDialerAutolist *moko_dialer_autolist; 
    327   moko_dialer_autolist = (MokoDialerAutolist *) user_data; 
    328  
    329   gint selected = moko_dialer_tip_get_index (tip); 
    330  
    331  
    332   if (selected != -1 && selected < MOKO_DIALER_MAX_TIPS 
    333       && moko_dialer_autolist->g_alternatecount) 
    334   { 
    335  
    336     return moko_dialer_autolist_set_select (moko_dialer_autolist, selected); 
    337  
    338   } 
    339   else 
    340   { 
     305MokoDialerAutolist *moko_dialer_autolist; 
     306moko_dialer_autolist=(MokoDialerAutolist *)user_data; 
     307 
     308gint selected=moko_dialer_tip_get_index(tip); 
     309 
     310 
     311if(selected!=-1&&selected<MOKO_DIALER_MAX_TIPS&&moko_dialer_autolist->g_alternatecount) 
     312{ 
     313 
     314                return  moko_dialer_autolist_set_select(moko_dialer_autolist,selected); 
     315 
     316} 
     317else 
     318{ 
    341319//we notify the client that no match found! 
    342     DBG_WARN ("the selected index is out of range!"); 
    343     return FALSE; 
    344   } 
    345  
    346  
    347 } 
    348  
    349 gboolean 
    350 moko_dialer_autolist_has_selected (MokoDialerAutolist * moko_dialer_autolist) 
    351 { 
    352   return moko_dialer_autolist->selected; 
     320DBG_WARN("the selected index is out of range!"); 
     321return FALSE; 
     322} 
     323 
     324 
     325} 
     326 
     327gboolean moko_dialer_autolist_has_selected(MokoDialerAutolist *moko_dialer_autolist) 
     328{ 
     329        return moko_dialer_autolist->selected; 
    353330} 
    354331 
    355332// selected ==-1 means there are no selected tips 
    356 gboolean 
    357 moko_dialer_autolist_set_select (MokoDialerAutolist * moko_dialer_autolist, 
    358                                  gint selected) 
    359 { 
    360   gint i; 
    361   if (selected == -1) 
    362   { 
    363  
    364     //set the selected status to be false 
    365     for (i = 0; i < moko_dialer_autolist->g_alternatecount; i++) 
    366     { 
    367       moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE); 
    368     } 
    369     //set 
    370     gtk_widget_hide (moko_dialer_autolist->imagePerson); 
    371     moko_dialer_autolist->selected = FALSE; 
    372     return TRUE; 
    373   } 
    374  
    375  
    376   if (selected < MOKO_DIALER_MAX_TIPS 
    377       && moko_dialer_autolist->g_alternatecount) 
    378   { 
    379     //first of all, determin if this tip is already selected previously. 
    380     if (moko_dialer_tip_is_selected (moko_dialer_autolist->tips[selected])) 
    381     { 
    382  
    383       //hide the others; 
    384       for (i = 0; i < moko_dialer_autolist->g_alternatecount; i++) 
    385       { 
    386         if (i != selected) 
    387         {                       //hide the others 
    388           gtk_widget_hide (moko_dialer_autolist->tips[i]); 
    389         } 
    390       } 
    391       moko_dialer_autolist->selected = FALSE; 
    392       //emit confirm message; 
    393 //              DBG_MESSAGE("we confirm %s is right.",moko_dialer_autolist->readycontacts[selected].p_contact->name);                    
    394       g_signal_emit (moko_dialer_autolist, 
    395                      moko_dialer_autolist_signals[CONFIRMED_SIGNAL], 0, 
    396                      &(moko_dialer_autolist->readycontacts[selected])); 
    397  
    398     } 
    399     else 
    400     { 
    401  
    402       //refresh the imagePerson widget 
    403 //      file_load_person_image_from_relative_path(moko_dialer_autolist->imagePerson,moko_dialer_autolist->readycontacts[selected].p_contact->picpath); 
    404       file_load_person_image_scalable_from_relative_path 
    405         (moko_dialer_autolist->imagePerson, 
    406          moko_dialer_autolist->readycontacts[selected].p_contact->picpath); 
    407       gtk_widget_show (moko_dialer_autolist->imagePerson); 
    408       //just change the selected attribute of the tips 
    409       for (i = 0; i < moko_dialer_autolist->g_alternatecount; i++) 
    410       { 
    411         if (i != selected) 
    412         {                       //set selected to false; 
    413           moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], FALSE); 
    414         } 
    415         else 
    416           moko_dialer_tip_set_selected (moko_dialer_autolist->tips[i], TRUE); 
    417       } 
    418       moko_dialer_autolist->selected = TRUE; 
    419       //emit selected message 
    420 //              DBG_MESSAGE(" %s is selectd.",moko_dialer_autolist->readycontacts[selected].p_contact->name); 
    421       g_signal_emit (moko_dialer_autolist, 
    422                      moko_dialer_autolist_signals[SELECTED_SIGNAL], 0, 
    423                      &(moko_dialer_autolist->readycontacts[selected])); 
    424     } 
    425     return TRUE; 
    426   } 
    427   else 
    428   { 
    429     DBG_WARN ("the selected index is out of range!"); 
    430     return FALSE; 
    431   } 
    432  
    433 } 
    434  
    435 GtkWidget * 
    436 moko_dialer_autolist_new () 
    437 { 
    438   DBG_ENTER (); 
    439  
    440   MokoDialerAutolist *dp; 
    441  
    442   dp = (MokoDialerAutolist *) g_object_new (MOKO_TYPE_DIALER_AUTOLIST, NULL); 
    443   return GTK_WIDGET (dp); 
    444  
    445 } 
     333gboolean moko_dialer_autolist_set_select(MokoDialerAutolist *moko_dialer_autolist,gint selected) 
     334{ 
     335gint i; 
     336                if(selected==-1) 
     337                { 
     338 
     339                        //set the selected status to be false 
     340                        for( i=0;i<moko_dialer_autolist->g_alternatecount;i++) 
     341                        { 
     342                        moko_dialer_tip_set_selected( moko_dialer_autolist->tips[i], FALSE); 
     343                        } 
     344                        //set 
     345                        gtk_widget_hide(moko_dialer_autolist->imagePerson);      
     346                        moko_dialer_autolist->selected=FALSE; 
     347                        return TRUE; 
     348                } 
     349 
     350 
     351if(selected<MOKO_DIALER_MAX_TIPS&&moko_dialer_autolist->g_alternatecount) 
     352        { 
     353        //first of all, determin if this tip is already selected previously. 
     354        if(moko_dialer_tip_is_selected(moko_dialer_autolist->tips[selected])) 
     355        { 
     356 
     357                //hide the others; 
     358                for( i=0;i<moko_dialer_autolist->g_alternatecount;i++) 
     359                { 
     360                        if(i!=selected) 
     361                        {//hide the others 
     362                        gtk_widget_hide( moko_dialer_autolist->tips[i]); 
     363                        } 
     364                } 
     365        moko_dialer_autolist->selected=FALSE; 
     366        //emit confirm message; 
     367//              DBG_MESSAGE("we confirm %s is right.",moko_dialer_autolist->readycontacts[selected].p_contact->name);                    
     368        g_signal_emit (moko_dialer_autolist,   moko_dialer_autolist_signals[CONFIRMED_SIGNAL],0,&(moko_dialer_autolist->readycontacts[selected])); 
     369 
     370        } 
     371        else 
     372        { 
     373 
     374        //refresh the imagePerson widget 
     375//      file_load_person_image_from_relative_path(moko_dialer_autolist->imagePerson,moko_dialer_autolist->readycontacts[selected].p_contact->picpath); 
     376//      file_load_person_image_scalable_from_relative_path(moko_dialer_autolist->imagePerson,moko_dialer_autolist->readycontacts[selected].p_contact->picpath); 
     377        contact_load_contact_photo(moko_dialer_autolist->imagePerson,moko_dialer_autolist->readycontacts[selected].p_contact->ID); 
     378                gtk_widget_show(moko_dialer_autolist->imagePerson);      
     379        //just change the selected attribute of the tips 
     380                for( i=0;i<moko_dialer_autolist->g_alternatecount;i++) 
     381                { 
     382                        if(i!=selected) 
     383                        {//set selected to false; 
     384                        moko_dialer_tip_set_selected( moko_dialer_autolist->tips[i], FALSE); 
     385                        } 
     386                        else 
     387                        moko_dialer_tip_set_selected( moko_dialer_autolist->tips[i], TRUE); 
     388                } 
     389        moko_dialer_autolist->selected=TRUE; 
     390                //emit selected message 
     391//              DBG_MESSAGE(" %s is selectd.",moko_dialer_autolist->readycontacts[selected].p_contact->name); 
     392                g_signal_emit (moko_dialer_autolist,   moko_dialer_autolist_signals[SELECTED_SIGNAL],0,&(moko_dialer_autolist->readycontacts[selected]));        
     393        } 
     394                return TRUE; 
     395        } 
     396else 
     397        { 
     398        DBG_WARN("the selected index is out of range!"); 
     399        return FALSE; 
     400        } 
     401                 
     402} 
     403 
     404GtkWidget*      moko_dialer_autolist_new() 
     405{ 
     406DBG_ENTER(); 
     407 
     408MokoDialerAutolist * dp; 
     409 
     410dp=(MokoDialerAutolist * )g_object_new (MOKO_TYPE_DIALER_AUTOLIST, NULL); 
     411return GTK_WIDGET(dp); 
     412 
     413} 
     414 
     415  
     416 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.c

    r648 r649  
    1717 */ 
    1818 
    19 #include "moko-dialer-status.h" 
    20 #include "error.h" 
    21 #include "common.h" 
     19 #include "moko-dialer-status.h" 
     20  #include "error.h" 
     21#include "common.h"  
    2222G_DEFINE_TYPE (MokoDialerStatus, moko_dialer_status, GTK_TYPE_VBOX) 
    23      static void moko_dialer_status_class_init (MokoDialerStatusClass * class) 
     23 
     24 
     25static void 
     26moko_dialer_status_class_init (MokoDialerStatusClass *class) 
    2427{ 
    2528/* 
     
    3134  GtkObjectClass *object_class; 
    3235 
    33   object_class = (GtkObjectClass *) class; 
     36  object_class = (GtkObjectClass*) class; 
    3437 
    3538 
     
    3841 
    3942static void 
    40 moko_dialer_status_init (MokoDialerStatus * moko_dialer_status) 
    41 { 
    42   DBG_ENTER (); 
    43   moko_dialer_status->imagePerson = 0; 
     43moko_dialer_status_init (MokoDialerStatus *moko_dialer_status) 
     44{ 
     45DBG_ENTER(); 
     46moko_dialer_status->imagePerson=0; 
    4447 
    4548//upper section 
    46   ;                            ///<the topmost title bar of the status 
    47   moko_dialer_status->labelStatusTitle = gtk_label_new (""); 
     49; ///<the topmost title bar of the status 
     50moko_dialer_status->labelStatusTitle= gtk_label_new(""); 
    4851 
    4952/* 
     
    5255*/ 
    5356 
    54   moko_dialer_status->icon = gtk_image_new (); 
     57moko_dialer_status->icon=gtk_image_new(); 
    5558 
    5659 
    5760//lower section   
    58   moko_dialer_status->imagePerson = gtk_image_new ();   ///<the image of the person we care 
    59   gtk_widget_set_size_request (moko_dialer_status->imagePerson, 130, 130); 
     61        moko_dialer_status->imagePerson=gtk_image_new();  ///<the image of the person we care 
     62gtk_widget_set_size_request (moko_dialer_status->imagePerson, 130,130); 
    6063  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->imagePerson), 1, 0); 
    6164 
    62  
    63   moko_dialer_status->labelStatus = gtk_label_new (""); ///<the status label 
    64   gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelStatus), 0, 0); 
    65 //                gtk_misc_set_padding(GTK_MISC (moko_dialer_status->labelStatus), 20,0); 
    66   moko_dialer_status->labelPersonName = gtk_label_new ("");     ///<the person name 
    67   gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelPersonName), 0, 
    68                           0); 
    69   moko_dialer_status->labelNumber = gtk_label_new (""); ///<the number of the person 
    70   gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelNumber), 0, 0); 
     65         
     66        moko_dialer_status->labelStatus=gtk_label_new("");      ///<the status label 
     67                  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelStatus), 0, 0); 
     68//                gtk_misc_set_padding(GTK_MISC (moko_dialer_status->labelStatus), 20,0); 
     69        moko_dialer_status->labelPersonName=gtk_label_new(""); ///<the person name 
     70                  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelPersonName), 0, 0); 
     71        moko_dialer_status->labelNumber=gtk_label_new(""); ///<the number of the person 
     72                  gtk_misc_set_alignment (GTK_MISC (moko_dialer_status->labelNumber), 0, 0); 
    7173//private section 
    72   moko_dialer_status->number_of_the_icons = 0; 
    73  
    74   gtk_widget_set_size_request (moko_dialer_status->icon, 64, 64); 
    75   gtk_box_pack_start (GTK_BOX (moko_dialer_status), 
    76                       moko_dialer_status->labelStatusTitle, FALSE, FALSE, 20); 
    77   gtk_box_pack_start (GTK_BOX (moko_dialer_status), moko_dialer_status->icon, 
    78                       FALSE, FALSE, 20); 
    79  
     74        moko_dialer_status->number_of_the_icons=0; 
     75 
     76 gtk_widget_set_size_request (moko_dialer_status->icon, 64,64); 
     77 gtk_box_pack_start( GTK_BOX(moko_dialer_status),       moko_dialer_status->labelStatusTitle , FALSE, FALSE, 20 ); 
     78 gtk_box_pack_start( GTK_BOX(moko_dialer_status),       moko_dialer_status->icon, FALSE, FALSE, 20); 
     79  
    8080//ok now, we arrange them in the vbox. 
    8181 
    8282// we create another vbox to hold the status labels. 
    83   GtkVBox *vbox2 = gtk_vbox_new (FALSE, 0); 
    84   gtk_box_pack_start (GTK_BOX (vbox2), moko_dialer_status->labelStatus, TRUE, 
    85                       TRUE, 0); 
    86  
    87   gtk_box_pack_start (GTK_BOX (vbox2), moko_dialer_status->labelPersonName, 
    88                       TRUE, TRUE, 0); 
    89  
    90  
    91  
    92   gtk_box_pack_start (GTK_BOX (vbox2), moko_dialer_status->labelNumber, TRUE, 
    93                       TRUE, 0); 
     83    GtkVBox *  vbox2 = gtk_vbox_new( FALSE, 0 ); 
     84   gtk_box_pack_start( GTK_BOX(vbox2),  moko_dialer_status->labelStatus, TRUE, TRUE, 0); 
     85    
     86   gtk_box_pack_start( GTK_BOX(vbox2),  moko_dialer_status->labelPersonName, TRUE, TRUE, 0 ); 
     87 
     88 
     89     
     90   gtk_box_pack_start( GTK_BOX(vbox2),  moko_dialer_status->labelNumber, TRUE, TRUE, 0 ); 
    9491// a hbox to hold the image and the vbox2 
    95   GtkVBox *hbox2 = gtk_hbox_new (FALSE, 0); 
    96  
    97  
    98  
    99 //   gtk_box_pack_start( GTK_BOX(hbox2),        moko_dialer_status->imagePerson, FALSE, FALSE, 0 ); 
    100   gtk_box_pack_start (GTK_BOX (hbox2), moko_dialer_status->imagePerson, TRUE, 
    101                       TRUE, 0); 
     92    GtkVBox *  hbox2 = gtk_hbox_new( FALSE, 0 ); 
     93 
     94 
     95     
     96//   gtk_box_pack_start( GTK_BOX(hbox2),        moko_dialer_status->imagePerson, FALSE, FALSE, 0 ); 
     97   gtk_box_pack_start( GTK_BOX(hbox2),  moko_dialer_status->imagePerson, TRUE,TRUE, 0 ); 
    10298 
    10399// gtk_box_pack_start( GTK_BOX(hbox2),vbox2, FALSE, FALSE, 0 ); 
    104   gtk_box_pack_start (GTK_BOX (hbox2), vbox2, TRUE, TRUE, 36); 
    105  
    106   gtk_box_pack_start (GTK_BOX (moko_dialer_status), hbox2, TRUE, TRUE, 0); 
     100 gtk_box_pack_start( GTK_BOX(hbox2),vbox2, TRUE,TRUE, 36 ); 
     101 
     102gtk_box_pack_start( GTK_BOX(moko_dialer_status),hbox2, TRUE, TRUE, 0 ); 
    107103 
    108104//gtk_widget_set_size_request (GTK_WIDGET(moko_dialer_status), 320, 200);  
    109105 
    110   DBG_LEAVE (); 
    111  
    112 } 
    113  
    114 GtkWidget * 
    115 moko_dialer_status_new () 
    116 { 
    117   DBG_ENTER (); 
    118  
    119   MokoDialerStatus *dp; 
    120  
    121   dp = (MokoDialerStatus *) g_object_new (MOKO_TYPE_DIALER_STATUS, NULL); 
    122   return GTK_WIDGET (dp); 
    123  
    124 } 
    125  
    126 void 
    127 moko_dialer_status_set_title_label (MokoDialerStatus * moko_dialer_status, 
    128                                     const gchar * text) 
    129 { 
    130  
    131   gtk_label_set_text (GTK_LABEL (moko_dialer_status->labelStatusTitle), text); 
    132 } 
    133  
    134 void 
    135 moko_dialer_status_set_status_label (MokoDialerStatus * moko_dialer_status, 
    136                                      const gchar * text) 
     106DBG_LEAVE(); 
     107 
     108} 
     109 
     110GtkWidget*      moko_dialer_status_new() 
     111{ 
     112DBG_ENTER(); 
     113 
     114MokoDialerStatus * dp; 
     115 
     116dp=(MokoDialerStatus * )g_object_new (MOKO_TYPE_DIALER_STATUS, NULL); 
     117return GTK_WIDGET(dp); 
     118 
     119} 
     120 
     121void moko_dialer_status_set_title_label(MokoDialerStatus *moko_dialer_status,const gchar* text) 
     122{ 
     123 
     124gtk_label_set_text(GTK_LABEL(moko_dialer_status->labelStatusTitle),text); 
     125} 
     126void moko_dialer_status_set_status_label(MokoDialerStatus *moko_dialer_status,const gchar* text) 
    137127{ 
    138128 
    139129//DBG_MESSAGE("moko_dialer_status_set_status_label:moko_dialer_status=0X%x",moko_dialer_status); 
    140   gtk_label_set_text (GTK_LABEL (moko_dialer_status->labelStatus), text); 
    141 } 
    142  
    143 void 
    144 moko_dialer_status_set_person_name (MokoDialerStatus * moko_dialer_status, 
    145                                     const gchar * text) 
    146 { 
    147   gtk_label_set_text (GTK_LABEL (moko_dialer_status->labelPersonName), text); 
    148 } 
    149  
    150 void 
    151 moko_dialer_status_set_person_number (MokoDialerStatus * moko_dialer_status, 
    152                                       const gchar * text) 
    153 { 
    154   gtk_label_set_text (GTK_LABEL (moko_dialer_status->labelNumber), text); 
    155 } 
    156  
    157 void 
    158 moko_dialer_status_set_person_image (MokoDialerStatus * moko_dialer_status, 
    159                                      const gchar * path) 
     130gtk_label_set_text(GTK_LABEL(moko_dialer_status->labelStatus),text); 
     131} 
     132 
     133void moko_dialer_status_set_person_name(MokoDialerStatus *moko_dialer_status,const gchar* text) 
     134{ 
     135gtk_label_set_text(GTK_LABEL(moko_dialer_status->labelPersonName),text); 
     136}  
     137void moko_dialer_status_set_person_number(MokoDialerStatus *moko_dialer_status,const gchar* text) 
     138{ 
     139gtk_label_set_text(GTK_LABEL(moko_dialer_status->labelNumber),text); 
     140}  
     141 
     142void moko_dialer_status_set_person_image(MokoDialerStatus *moko_dialer_status,const gchar* id) 
    160143{ 
    161144//file_load_person_image_scalable_from_relative_path(moko_dialer_status->imagePerson,path); 
    162   file_load_person_image_from_relative_path (moko_dialer_status->imagePerson, 
    163                                              path); 
     145//file_load_person_image_from_relative_path(moko_dialer_status->imagePerson,path); 
     146 
     147contact_load_contact_photo(moko_dialer_status->imagePerson,id); 
    164148//file_load_person_image_scalable_from_relative_path(moko_dialer_status->imagePerson,path); 
    165 } 
    166  
    167 int 
    168 moko_dialer_status_add_status_icon (MokoDialerStatus * moko_dialer_status, 
    169                                     const gchar * text) 
    170 { 
    171   if (moko_dialer_status->number_of_the_icons < MOKO_DIALER_MAX_STATUS_ICONS) 
    172   { 
    173     moko_dialer_status->iconStatus[moko_dialer_status->number_of_the_icons] = 
    174       create_pixbuf (text); 
    175  
    176     moko_dialer_status->number_of_the_icons++; 
    177     return 1; 
    178   } 
    179   else 
    180   { 
    181     DBG_ERROR 
    182       ("MOKO_DIALER_MAX_STATUS_ICONS has reached, add no more icons."); 
    183     return 0; 
    184   } 
    185 } 
    186  
    187 void 
    188 moko_dialer_status_set_error_icon (MokoDialerStatus * moko_dialer_status, 
    189                                    const gchar * text) 
    190 { 
    191    
    192 moko_dialer_status->iconError = create_pixbuf (text); 
    193 //      file_load_person_image_from_relative_path(moko_dialer_status->iconError,text); 
    194 } 
    195  
    196 void 
    197 moko_dialer_status_set_success_icon (MokoDialerStatus * moko_dialer_status, 
    198                                      const gchar * text) 
    199 { 
    200   moko_dialer_status->iconError = create_pixbuf (text); 
    201 //      file_load_person_image_from_relative_path(moko_dialer_status->iconSuccuss,text); 
    202 } 
    203  
    204 void 
    205 moko_dialer_status_set_icon_by_index (MokoDialerStatus * moko_dialer_status, 
    206                                       gint index) 
    207 { 
    208   if (moko_dialer_status->iconStatus[index] != 0 
    209       && index < moko_dialer_status->number_of_the_icons) 
    210     gtk_image_set_from_pixbuf (moko_dialer_status->icon, 
    211                                moko_dialer_status->iconStatus[index]); 
    212 } 
    213  
    214 void 
    215 moko_dialer_status_update_icon (MokoDialerStatus * moko_dialer_status) 
    216 { 
    217   static gint currenticon = 0; 
    218   currenticon = (currenticon + 1) % moko_dialer_status->number_of_the_icons; 
    219   if (moko_dialer_status->iconStatus[currenticon]) 
    220     moko_dialer_status_set_icon_by_index (moko_dialer_status, currenticon); 
    221 } 
    222  
    223  
    224 void 
    225 moko_dialer_status_set_error (MokoDialerStatus * moko_dialer_status) 
    226 { 
    227   if (moko_dialer_status->iconError) 
    228     gtk_image_set_from_pixbuf (moko_dialer_status->icon, 
    229                                moko_dialer_status->iconError); 
    230   moko_dialer_status_set_status_label (moko_dialer_status, ""); 
    231 } 
    232  
    233 void 
    234 moko_dialer_status_set_success (MokoDialerStatus * moko_dialer_status) 
    235 { 
    236   if (moko_dialer_status->iconSuccess) 
    237     gtk_image_set_from_pixbuf (moko_dialer_status->icon, 
    238                                moko_dialer_status->iconSuccess); 
    239  
    240 } 
     149}  
     150int moko_dialer_status_add_status_icon(MokoDialerStatus *moko_dialer_status,const gchar* text) 
     151{ 
     152if(moko_dialer_status->number_of_the_icons<MOKO_DIALER_MAX_STATUS_ICONS) 
     153{ 
     154        moko_dialer_status->iconStatus[moko_dialer_status->number_of_the_icons]=create_pixbuf (text); 
     155 
     156        moko_dialer_status->number_of_the_icons++; 
     157        return 1; 
     158} 
     159else 
     160{ 
     161        DBG_ERROR("MOKO_DIALER_MAX_STATUS_ICONS has reached, add no more icons."); 
     162        return 0; 
     163} 
     164}  
     165 
     166void moko_dialer_status_set_error_icon(MokoDialerStatus *moko_dialer_status,const gchar* text) 
     167{ 
     168 
     169 
     170        moko_dialer_status->iconError=create_pixbuf (text); 
     171//      file_load_person_image_from_relative_path(moko_dialer_status->iconError,text); 
     172}  
     173void moko_dialer_status_set_success_icon(MokoDialerStatus *moko_dialer_status,const gchar* text) 
     174{ 
     175        moko_dialer_status->iconError=create_pixbuf (text); 
     176//      file_load_person_image_from_relative_path(moko_dialer_status->iconSuccuss,text); 
     177} 
     178 
     179void moko_dialer_status_set_icon_by_index(MokoDialerStatus *moko_dialer_status,gint index) 
     180{ 
     181if( moko_dialer_status->iconStatus[index]!=0&&index<moko_dialer_status->number_of_the_icons) 
     182        gtk_image_set_from_pixbuf(moko_dialer_status->icon, moko_dialer_status->iconStatus[index]); 
     183} 
     184void moko_dialer_status_update_icon(MokoDialerStatus *moko_dialer_status) 
     185{ 
     186static gint currenticon=0; 
     187currenticon=(currenticon+1)%moko_dialer_status->number_of_the_icons; 
     188if( moko_dialer_status->iconStatus[currenticon]) 
     189        moko_dialer_status_set_icon_by_index(moko_dialer_status,currenticon); 
     190} 
     191         
     192 
     193void moko_dialer_status_set_error(MokoDialerStatus *moko_dialer_status) 
     194{ 
     195if(moko_dialer_status->iconError) 
     196        gtk_image_set_from_pixbuf(moko_dialer_status->icon, moko_dialer_status->iconError); 
     197moko_dialer_status_set_status_label(moko_dialer_status,""); 
     198} 
     199 
     200void moko_dialer_status_set_success(MokoDialerStatus *moko_dialer_status) 
     201{ 
     202if(moko_dialer_status->iconSuccess) 
     203        gtk_image_set_from_pixbuf(moko_dialer_status->icon, moko_dialer_status->iconSuccess); 
     204 
     205} 
     206 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-status.h

    r648 r649  
    1616 *  Current Version: $Rev$ ($Date) [$Author: Tony Guan $] 
    1717 */ 
    18 #ifndef _MOKO_DIALER_STATUS_H_ 
     18 #ifndef _MOKO_DIALER_STATUS_H_ 
    1919#define _MOKO_DIALER_STATUS_H_ 
    2020 
     
    3636 
    3737G_BEGIN_DECLS 
     38 
     39 
     40 
    3841#define MOKO_TYPE_DIALER_STATUS                (moko_dialer_status_get_type()) 
    3942#define MOKO_DIALER_STATUS (obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOKO_TYPE_DIALER_STATUS, MokoDialerStatus)) 
     
    4245#define MOKO_IS_DIALER_STATUS_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), MOKO_TYPE_DIALER_STATUS)) 
    4346#define MOKO_DIALER_STATUS_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), MOKO_TYPE_DIALER_STATUS, MokoDialerStatusClass)) 
    44 typedef struct _MokoDialerStatusClass MokoDialerStatusClass; 
    4547 
    46 typedef struct _MokoDialerStatus MokoDialerStatus; 
     48 
     49 
     50typedef struct _MokoDialerStatusClass   MokoDialerStatusClass; 
     51 
     52typedef struct _MokoDialerStatus        MokoDialerStatus; 
    4753struct _MokoDialerStatus 
    4854{ 
    4955  GtkVBox vbox; 
    5056//upper section 
    51   GtkWidget *labelStatusTitle; ///<the topmost title bar of the status 
    52   GtkWidget *icon; 
    53   GdkPixbuf *iconStatus[MOKO_DIALER_MAX_STATUS_ICONS]; 
    54   GdkPixbuf *iconError; 
    55   GdkPixbuf *iconSuccess; 
     57  GtkWidget * labelStatusTitle; ///<the topmost title bar of the status 
     58  GtkWidget * icon; 
     59  GdkPixbuf * iconStatus[MOKO_DIALER_MAX_STATUS_ICONS]; 
     60  GdkPixbuf * iconError; 
     61  GdkPixbuf * iconSuccess; 
    5662//lower section   
    57   GtkWidget *imagePerson;       ///<the image of the person we care 
    58   GtkWidget *labelStatus;       ///<the status label 
    59   GtkWidget *labelPersonName;  ///<the person name 
    60   GtkWidget *labelNumber;      ///<the number of the person 
     63  GtkWidget * imagePerson;  ///<the image of the person we care 
     64  GtkWidget * labelStatus;      ///<the status label 
     65  GtkWidget * labelPersonName; ///<the person name 
     66  GtkWidget * labelNumber; ///<the number of the person 
    6167 
    6268//private section 
    6369  gint number_of_the_icons; 
    64  
     70   
    6571 
    6672}; 
     
    7278 
    7379 
    74 GType moko_dialer_status_get_type (void); 
     80GType          moko_dialer_status_get_type         (void) ; 
    7581 
    76 GtkWidget *moko_dialer_status_new (); 
     82GtkWidget*      moko_dialer_status_new(); 
    7783 
    78 void moko_dialer_status_set_title_label (MokoDialerStatus * 
    79                                          moko_dialer_status, 
    80                                          const gchar * text); 
    81 void moko_dialer_status_set_person_name (MokoDialerStatus * 
    82                                          moko_dialer_status, 
    83                                          const gchar * text); 
    84 void moko_dialer_status_set_person_number (MokoDialerStatus * 
    85                                            moko_dialer_status, 
    86                                            const gchar * text); 
    87 void moko_dialer_status_set_person_image (MokoDialerStatus * 
    88                                           moko_dialer_status, 
    89                                           const gchar * path); 
    90 void moko_dialer_status_set_icons (MokoDialerStatus * moko_dialer_status, 
    91                                    const gchar * text); 
    92 void moko_dialer_status_set_status_label (MokoDialerStatus * 
    93                                           moko_dialer_status, 
    94                                           const gchar * text); 
     84void moko_dialer_status_set_title_label(MokoDialerStatus *moko_dialer_status,const gchar* text); 
     85void moko_dialer_status_set_person_name(MokoDialerStatus *moko_dialer_status,const gchar* text); 
     86void moko_dialer_status_set_person_number(MokoDialerStatus *moko_dialer_status,const gchar* text); 
     87void moko_dialer_status_set_person_image(MokoDialerStatus *moko_dialer_status,const gchar* id); 
     88void moko_dialer_status_set_icons(MokoDialerStatus *moko_dialer_status,const gchar* text); 
     89void moko_dialer_status_set_status_label(MokoDialerStatus *moko_dialer_status,const gchar* text); 
    9590 
    9691G_END_DECLS 
    97 #endif // 
     92 
     93#endif //  
     94 
     95 
     96 
     97 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-main.c

    r648 r649  
    3737#include "openmoko-dialer-window-outgoing.h" 
    3838#include "openmoko-dialer-window-incoming.h" 
    39 MOKO_DIALER_APP_DATA *p_dialer_data = 0; 
    40 MOKO_DIALER_APP_DATA * 
    41 moko_get_app_data () 
     39MOKO_DIALER_APP_DATA* p_dialer_data=0; 
     40MOKO_DIALER_APP_DATA*  moko_get_app_data() 
    4241{ 
    43   return p_dialer_data; 
     42return p_dialer_data; 
    4443} 
    4544 
    46 void 
    47 gsm_incoming_call (gchar * number) 
     45void gsm_incoming_call(gchar * number) 
    4846{ 
    4947 
    50   MOKO_DIALER_APP_DATA *appdata = moko_get_app_data (); 
     48MOKO_DIALER_APP_DATA* appdata=moko_get_app_data(); 
    5149 
    52   if (appdata) 
    53   { 
     50if(appdata) 
     51{ 
    5452//first, we should remove the "" from the number. 
    55     char temp[20]; 
    56     int start = 0; 
    57     int end = strlen (number); 
    58     while (number[start] == '\"' && start < end) 
    59       start++; 
    60     if (end > 1) 
    61       while (number[end - 1] == '\"' && start < end) 
    62         end--; 
     53char temp[20]; 
     54int start=0; 
     55int end=strlen(number); 
     56while(number[start]=='\"'&&start<end)start++; 
     57if(end>1)while(number[end-1]=='\"'&&start<end)end--; 
    6358 
    64     DBG_MESSAGE ("START=%d,END=%d", start, end); 
    65     strcpy (temp, number + start); 
    66     temp[end - 1] = 0; 
    67     DBG_MESSAGE ("%s", temp); 
     59DBG_MESSAGE("START=%d,END=%d",start,end); 
     60strcpy(temp,number+start); 
     61temp[end-1]=0; 
     62DBG_MESSAGE("%s",temp);  
    6863 
    6964 
    7065 
    7166//got the number; 
    72     strcpy (appdata->g_peer_info.number, temp); 
     67strcpy(appdata->g_peer_info.number,temp); 
    7368 
    7469//retrieve the contact information if any. 
    75     contact_get_peer_info_from_number (appdata->g_contactlist.contacts, 
    76                                        &(appdata->g_peer_info)); 
     70contact_get_peer_info_from_number(appdata->g_contactlist.contacts , &(appdata->g_peer_info)); 
    7771// contact_get_peer_info_from_number 
    7872 
    7973 
    8074//transfer the contact info 
    81     window_incoming_prepare (appdata); 
     75window_incoming_prepare(appdata); 
    8276 
    83     gtk_widget_show (appdata->window_incoming); 
    84   } 
    85   else 
    86   { 
    87     DBG_ERROR ("gui failed to initialize.try another time."); 
    88   } 
     77gtk_widget_show(appdata->window_incoming); 
     78} 
     79else 
     80{ 
     81DBG_ERROR("gui failed to initialize.try another time."); 
     82} 
    8983 
    9084 
    9185} 
    9286 
    93 void 
    94 gsm_peer_accept () 
     87void gsm_peer_accept() 
    9588{ 
    96   MOKO_DIALER_APP_DATA *appdata = moko_get_app_data (); 
    97   DBG_ENTER (); 
     89MOKO_DIALER_APP_DATA* appdata=moko_get_app_data(); 
     90DBG_ENTER(); 
    9891//moko_dialer_status_update_icon(appdata->status_outgoing); 
    9992 
    10093 
    101   appdata->g_state.callstate = STATE_TALKING; 
     94appdata->g_state.callstate=STATE_TALKING; 
    10295 
    103   gtk_widget_hide (appdata->window_outgoing); 
     96gtk_widget_hide(appdata->window_outgoing); 
    10497 
    105   if (!appdata->window_talking) 
    106     window_talking_init (appdata); 
    10798 
    10899//transfer the contact info 
    109   window_talking_prepare (appdata); 
     100window_talking_prepare(appdata); 
    110101 
    111102//start talking. 
    112103 
    113   gtk_widget_show (appdata->window_talking); 
     104gtk_widget_show(appdata->window_talking); 
    114105 
    115106 
    116   DBG_LEAVE (); 
     107DBG_LEAVE(); 
    117108} 
    118109 
    119 void 
    120 gsm_peer_refuse () 
     110void gsm_peer_refuse() 
    121111{ 
    122   MOKO_DIALER_APP_DATA *appdata = moko_get_app_data (); 
    123   window_outgoing_fails (appdata); 
     112MOKO_DIALER_APP_DATA* appdata=moko_get_app_data(); 
     113window_outgoing_fails(appdata); 
    124114} 
    125115 
    126 void 
    127 gsm_peer_abort () 
     116void gsm_peer_abort() 
    128117{ 
    129118 
    130   MOKO_DIALER_APP_DATA *appdata = moko_get_app_data (); 
    131   if (appdata->window_incoming) 
    132     gtk_widget_hide (appdata->window_incoming); 
     119MOKO_DIALER_APP_DATA* appdata=moko_get_app_data(); 
     120if(appdata->window_incoming) 
     121        gtk_widget_hide(appdata->window_incoming); 
    133122 
    134123 
    135124} 
    136125 
    137 void 
    138 gsm_peer_disconnect () 
     126void gsm_peer_disconnect() 
    139127{ 
    140128 
    141   MOKO_DIALER_APP_DATA *appdata = moko_get_app_data (); 
    142   gsm_hangup (); 
    143   gtk_widget_hide (appdata->window_talking); 
     129     MOKO_DIALER_APP_DATA* appdata=moko_get_app_data(); 
     130     gsm_hangup(); 
     131     gtk_widget_hide(appdata->window_talking); 
    144132 
    145133} 
    146  
    147 int 
    148 main (int argc, char **argv) 
     134int main( int argc, char** argv ) 
    149135{ 
    150   p_dialer_data = calloc (1, sizeof (MOKO_DIALER_APP_DATA)); 
    151   /* Initialize GTK+ */ 
    152   gtk_init (&argc, &argv); 
     136    p_dialer_data=calloc(1,sizeof(MOKO_DIALER_APP_DATA)); 
     137    /* Initialize GTK+ */ 
     138    gtk_init( &argc, &argv ); 
    153139 
    154140 
    155   //init application data 
    156   contact_init_contact_data (&(p_dialer_data->g_contactlist)); 
    157   history_init_history_data (&(p_dialer_data->g_historylist)); 
     141    //init application data 
     142   contact_init_contact_data(&(p_dialer_data->g_contactlist)); 
     143   history_init_history_data(&(p_dialer_data->g_historylist)); 
     144    
    158145 
    159  
    160   /* application object */ 
     146    /* application object */ 
    161147//    MokoApplication* app = MOKO_APPLICATION(moko_application_get_instance()); 
    162   g_set_application_name ("OpenMoko Dialer"); 
     148    g_set_application_name( "OpenMoko Dialer" ); 
    163149 
    164150 
     
    167153 
    168154 
    169   GMainLoop *mainloop = 0; 
    170   mainloop = g_main_loop_new (NULL, FALSE); 
    171   p_dialer_data->mainloop = mainloop; 
     155 GMainLoop* mainloop=0; 
     156 mainloop = g_main_loop_new(NULL, FALSE ); 
     157 p_dialer_data->mainloop=mainloop; 
    172158 
    173159 
    174160//init the dialer window 
    175   window_dialer_init (p_dialer_data); 
     161  window_dialer_init(p_dialer_data);  
    176162//  window_incoming_init(p_dialer_data);  
    177163//  window_outgoing_init(p_dialer_data);  
     
    181167 
    182168//from now on we will not use multithreads. 
    183   gsm_lgsm_start (mainloop); 
     169  gsm_lgsm_start(mainloop); 
    184170  //start a timer to monitor incoming calls 
    185171  //gtk_timeout_add(100,incoming_calls,0); 
    186  
     172  
    187173//instead, we add a g_source 
    188174 
     
    191177  //gtk_main (); 
    192178  //gdk_threads_leave(); 
    193  
     179   
    194180//  GMainLoop* mainloop = g_main_loop_new(NULL, FALSE ); 
    195  
     181   
    196182//  [ set up a GSource ] 
    197183//  [ add a GPollFD ] 
    198184//  g_source_attach( gsource, NULL ); 
    199   g_main_loop_run (mainloop); 
     185  g_main_loop_run(mainloop); 
    200186 
    201187 
     
    206192 
    207193//release everything     
    208   contact_release_contact_list (&(p_dialer_data->g_contactlist)); 
     194    contact_release_contact_list(&(p_dialer_data->g_contactlist));  
    209195 
    210   history_release_history_list (&(p_dialer_data->g_historylist)); 
    211   return 0; 
     196  history_release_history_list(&(p_dialer_data->g_historylist)); 
     197    return 0; 
    212198} 
     199 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-history.c

    r648 r649  
    5050 * @retval 
    5151 */ 
    52  
    53 int 
    54 history_view_change_filter (MOKO_DIALER_APP_DATA * p_dialer_data, 
    55                             HISTORY_TYPE type) 
    56 { 
    57   GtkWidget *historyview; 
    58   GtkTreePath *path; 
    59   DBG_TRACE (); 
    60   p_dialer_data->g_history_filter_type = type; 
    61   gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER 
    62                                   (p_dialer_data->g_list_store_filter)); 
    63  
    64   path = gtk_tree_path_new_first (); 
    65   gtk_tree_view_set_cursor (GTK_TREE_VIEW (p_dialer_data->treeview_history), 
    66                             path, 0, 0); 
    67   gtk_tree_path_free (path); 
    68  
    69  
    70   return 1; 
     52  
     53int history_view_change_filter(MOKO_DIALER_APP_DATA* p_dialer_data,HISTORY_TYPE  type) 
     54{ 
     55GtkWidget* historyview; 
     56GtkTreePath* path; 
     57DBG_TRACE(); 
     58p_dialer_data->g_history_filter_type=type; 
     59gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(p_dialer_data->g_list_store_filter)); 
     60 
     61path=gtk_tree_path_new_first(); 
     62gtk_tree_view_set_cursor(GTK_TREE_VIEW(p_dialer_data->treeview_history),path,0,0);    
     63gtk_tree_path_free(path); 
     64 
     65         
     66return 1; 
    7167} 
    7268 
    7369void 
    74 on_all_calls_activate (GtkMenuItem * menuitem, gpointer user_data) 
    75 { 
    76   MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data; 
    77   GtkWidget *label = p_dialer_data->label_filter_history; 
    78   gtk_label_set_text (GTK_LABEL (label), "All"); 
    79   history_view_change_filter (p_dialer_data, ALL); 
    80   history_update_counter (p_dialer_data); 
     70on_all_calls_activate                  (GtkMenuItem     *menuitem, 
     71                                        gpointer         user_data) 
     72{ 
     73        MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data; 
     74        GtkWidget* label=p_dialer_data->label_filter_history; 
     75        gtk_label_set_text(GTK_LABEL(label),"All"); 
     76        history_view_change_filter(p_dialer_data,ALL); 
     77        history_update_counter(p_dialer_data); 
    8178} 
    8279 
    8380 
    8481void 
    85 on_missed_calls_activate (GtkMenuItem * menuitem, gpointer user_data) 
    86 { 
    87   MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data; 
    88   GtkWidget *label = p_dialer_data->label_filter_history; 
    89   gtk_label_set_text (GTK_LABEL (label), "Missed"); 
    90   history_view_change_filter (p_dialer_data, MISSED); 
    91   history_update_counter (p_dialer_data); 
     82on_missed_calls_activate               (GtkMenuItem     *menuitem, 
     83                                        gpointer         user_data) 
     84{ 
     85        MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data; 
     86        GtkWidget* label=p_dialer_data->label_filter_history; 
     87        gtk_label_set_text(GTK_LABEL(label),"Missed"); 
     88        history_view_change_filter(p_dialer_data,MISSED); 
     89        history_update_counter(p_dialer_data); 
    9290} 
    9391 
    9492 
    9593void 
    96 on_dialed_calls_activate (GtkMenuItem * menuitem, gpointer user_data) 
    97 { 
    98   MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data; 
    99   GtkWidget *label = p_dialer_data->label_filter_history; 
    100   gtk_label_set_text (GTK_LABEL (label), "Dialed"); 
    101   history_view_change_filter (p_dialer_data, OUTGOING); 
    102   history_update_counter (p_dialer_data); 
     94on_dialed_calls_activate               (GtkMenuItem     *menuitem, 
     95                                        gpointer         user_data) 
     96{ 
     97        MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data; 
     98        GtkWidget* label=p_dialer_data->label_filter_history; 
     99        gtk_label_set_text(GTK_LABEL(label),"Dialed"); 
     100        history_view_change_filter(p_dialer_data,OUTGOING); 
     101        history_update_counter(p_dialer_data); 
    103102} 
    104103 
    105104 
    106105void 
    107 on_received_calls_activate (GtkMenuItem * menuitem, gpointer user_data) 
    108 { 
    109   MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data; 
    110   GtkWidget *label = p_dialer_data->label_filter_history; 
    111   gtk_label_set_text (GTK_LABEL (label), "Received"); 
    112   history_view_change_filter (p_dialer_data, INCOMING); 
    113   history_update_counter (p_dialer_data); 
     106on_received_calls_activate            (GtkMenuItem     *menuitem, 
     107                                        gpointer         user_data) 
     108{ 
     109        MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data; 
     110        GtkWidget* label=p_dialer_data->label_filter_history; 
     111        gtk_label_set_text(GTK_LABEL(label),"Received"); 
     112        history_view_change_filter(p_dialer_data,INCOMING); 
     113        history_update_counter(p_dialer_data); 
    114114} 
    115115 
    116116gboolean 
    117 on_eventboxTop_button_release_event (GtkWidget * widget, 
    118                                      GdkEventButton * event, 
    119                                      MOKO_DIALER_APP_DATA * appdata) 
    120 { 
    121  
    122   gtk_menu_popup (GTK_MENU (appdata->menu_history), 0, 0, 0, 0, 0, 0); 
    123  
     117on_eventboxTop_button_release_event    (GtkWidget       *widget, 
     118                                        GdkEventButton  *event, 
     119                                        MOKO_DIALER_APP_DATA * appdata) 
     120{ 
     121         
     122 gtk_menu_popup(GTK_MENU(appdata->menu_history),0,0,0,0,0,0); 
     123  
    124124  return FALSE; 
    125125} 
    126126 
    127127void 
    128 openmoko_history_wheel_press_left_up_cb (GtkWidget * widget, 
    129                                          MOKO_DIALER_APP_DATA * appdata) 
    130 { 
    131   DBG_ENTER (); 
    132   GtkTreeSelection *selection; 
    133   GtkTreeModel *model; 
    134   GtkTreeIter iter; 
    135   GtkTreePath *path; 
    136   GtkTreeView *treeview; 
    137   //DBG_ENTER(); 
    138  
    139   treeview = GTK_TREE_VIEW (appdata->treeview_history); 
    140   if (treeview == 0) 
    141     return; 
    142  
    143   selection = gtk_tree_view_get_selection (treeview); 
    144  
    145   if (!gtk_tree_selection_get_selected (selection, &model, &iter)) 
    146   { 
    147     DBG_WARN ("no current selection\n"); 
    148     return; 
    149   } 
    150   path = gtk_tree_model_get_path (model, &iter); 
    151   if (!gtk_tree_path_prev (path)) 
    152   { 
    153     DBG_WARN ("no prev for the top level\n"); 
    154     gtk_tree_path_free (path); 
    155     return; 
    156   } 
    157   gtk_tree_view_set_cursor (treeview, path, 0, 0); 
    158   return; 
     128openmoko_history_wheel_press_left_up_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata) 
     129{ 
     130DBG_ENTER(); 
     131 GtkTreeSelection    *selection; 
     132 GtkTreeModel        *model; 
     133 GtkTreeIter         iter; 
     134 GtkTreePath* path; 
     135 GtkTreeView * treeview; 
     136 //DBG_ENTER(); 
     137 
     138treeview=GTK_TREE_VIEW(appdata->treeview_history); 
     139 if(treeview==0)return ; 
     140          
     141 selection = gtk_tree_view_get_selection(treeview); 
     142 
     143 if (!gtk_tree_selection_get_selected(selection, &model, &iter)) 
     144 { 
     145         DBG_WARN("no current selection\n"); 
     146         return ; 
     147 } 
     148                path=gtk_tree_model_get_path(model,&iter); 
     149                if(!gtk_tree_path_prev(path)) 
     150                { 
     151                                DBG_WARN("no prev for the top level\n"); 
     152                                gtk_tree_path_free(path); 
     153                                return; 
     154                } 
     155                gtk_tree_view_set_cursor(treeview,path,0,0); 
     156  return ; 
    159157 
    160158 
     
    162160 
    163161void 
    164 openmoko_history_wheel_press_right_down_cb (GtkWidget * widget, 
    165                                             MOKO_DIALER_APP_DATA * appdata) 
    166 { 
    167   DBG_ENTER (); 
    168   GtkTreeSelection *selection; 
    169   GtkTreeModel *model; 
    170   GtkTreeIter iter; 
    171   GtkTreePath *path; 
    172   GtkTreeView *treeview; 
    173   //DBG_ENTER(); 
    174   treeview = GTK_TREE_VIEW (appdata->treeview_history); 
    175   if (treeview == 0) 
    176     return; 
    177  
    178   selection = gtk_tree_view_get_selection (treeview); 
    179  
    180   if (!gtk_tree_selection_get_selected (selection, &model, &iter)) 
    181   { 
    182     DBG_WARN ("no current selection\n"); 
    183     return; 
    184   } 
    185   if (gtk_tree_model_iter_next (model, &iter)) 
    186   { 
    187     path = gtk_tree_model_get_path (model, &iter); 
    188     gtk_tree_view_set_cursor (treeview, path, 0, 0); 
    189     gtk_tree_path_free (path); 
    190     return; 
    191   } 
    192  
    193   return; 
     162openmoko_history_wheel_press_right_down_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata) 
     163{ 
     164DBG_ENTER(); 
     165 GtkTreeSelection    *selection; 
     166 GtkTreeModel        *model; 
     167 GtkTreeIter         iter; 
     168 GtkTreePath* path; 
     169 GtkTreeView * treeview; 
     170 //DBG_ENTER(); 
     171treeview=GTK_TREE_VIEW(appdata->treeview_history); 
     172 if(treeview==0)return ; 
     173          
     174 selection = gtk_tree_view_get_selection(treeview); 
     175 
     176 if (!gtk_tree_selection_get_selected(selection, &model, &iter)) 
     177 { 
     178         DBG_WARN("no current selection\n"); 
     179         return ; 
     180 } 
     181         if(gtk_tree_model_iter_next(model,&iter)) 
     182         { 
     183                path=gtk_tree_model_get_path(model,&iter); 
     184                gtk_tree_view_set_cursor(treeview,path,0,0); 
     185                gtk_tree_path_free(path); 
     186                return ; 
     187         } 
     188  
     189  return ; 
     190} 
     191 
     192 
     193void cb_tool_button_history_delete_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata) 
     194{ 
     195GtkTreeIter iter; //iter of the filter store 
     196GtkTreeIter iter0; //iter of the back store 
     197GtkTreeModel* model; 
     198GtkTreeModel* model0; 
     199GtkTreeSelection * selection; 
     200GtkTreeView* treeview; 
     201GtkTreePath* path; 
     202treeview=GTK_TREE_VIEW(appdata->treeview_history); 
     203selection = gtk_tree_view_get_selection(treeview); 
     204 
     205         
     206if (!gtk_tree_selection_get_selected(selection, &model, &iter)) 
     207{ 
     208        return; 
     209} 
     210         
     211if(appdata->g_currentselected) 
     212{ 
     213DBG_MESSAGE("to delete %s",appdata->g_currentselected->number); 
     214history_delete_entry(&(appdata->g_historylist),appdata->g_currentselected); 
     215} 
     216 
     217path=gtk_tree_model_get_path(model,&iter); 
     218 
     219 
     220model0=gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model)); 
     221 
     222 
     223gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model),&iter0,&iter); 
     224 
     225gtk_list_store_remove(GTK_LIST_STORE(model0),&iter0); 
     226 
     227 
     228gtk_tree_view_set_cursor(treeview,path,0,0); 
     229 
     230 
     231if (!gtk_tree_selection_get_selected(selection, &model, &iter)) 
     232{ 
     233        if(!gtk_tree_path_prev(path)) 
     234        { 
     235                gtk_tree_view_set_cursor(treeview,path,0,0); 
     236                DBG_WARN("history is empty now!"); 
     237                history_update_counter(appdata); 
     238        } 
     239        else 
     240        { 
     241                gtk_tree_view_set_cursor(treeview,path,0,0); 
     242        } 
     243        //we deleted the last one. 
     244         
     245} 
     246 
     247gtk_tree_path_free(path); 
     248 
     249return ; 
     250 
     251  DBG_ENTER(); 
     252} 
     253 
     254void cb_tool_button_history_call_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata) 
     255{ 
     256        DBG_ENTER(); 
     257         
     258 
     259   
     260} 
     261 
     262void cb_tool_button_history_sms_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata) 
     263{ 
     264        DBG_ENTER(); 
     265         
     266 
     267   
     268} 
     269 
     270void cb_tool_button_history_back_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata) 
     271{ 
     272     gtk_widget_hide(appdata->window_history); 
     273      
    194274} 
    195275 
    196276 
    197277void 
    198 cb_tool_button_history_delete_clicked (GtkButton * button, 
    199                                        MOKO_DIALER_APP_DATA * appdata) 
    200 { 
    201   GtkTreeIter iter;             //iter of the filter store 
    202   GtkTreeIter iter0;            //iter of the back store 
    203   GtkTreeModel *model; 
    204   GtkTreeModel *model0; 
    205   GtkTreeSelection *selection; 
    206   GtkTreeView *treeview; 
    207   GtkTreePath *path; 
    208   treeview = GTK_TREE_VIEW (appdata->treeview_history); 
    209   selection = gtk_tree_view_get_selection (treeview); 
    210  
    211  
    212   if (!gtk_tree_selection_get_selected (selection, &model, &iter)) 
    213   { 
    214     return; 
    215   } 
    216  
    217   if (appdata->g_currentselected) 
    218   { 
    219     DBG_MESSAGE ("to delete %s", appdata->g_currentselected->number); 
    220     history_delete_entry (&(appdata->g_historylist), 
    221                           appdata->g_currentselected); 
    222   } 
    223  
    224   path = gtk_tree_model_get_path (model, &iter); 
    225  
    226  
    227   model0 = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model)); 
    228  
    229  
    230   gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER 
    231                                                     (model), &iter0, &iter); 
    232  
    233   gtk_list_store_remove (GTK_LIST_STORE (model0), &iter0); 
    234  
    235  
    236   gtk_tree_view_set_cursor (treeview, path, 0, 0); 
    237  
    238  
    239   if (!gtk_tree_selection_get_selected (selection, &model, &iter)) 
    240   { 
    241     if (!gtk_tree_path_prev (path)) 
    242     { 
    243       gtk_tree_view_set_cursor (treeview, path, 0, 0); 
    244       DBG_WARN ("history is empty now!"); 
    245       history_update_counter (appdata); 
    246     } 
    247     else 
    248     { 
    249       gtk_tree_view_set_cursor (treeview, path, 0, 0); 
    250     } 
    251     //we deleted the last one. 
    252  
    253   } 
    254  
    255   gtk_tree_path_free (path); 
    256  
    257   return; 
    258  
    259   DBG_ENTER (); 
     278on_window_history_hide                 (GtkWidget       *widget, 
     279                                        MOKO_DIALER_APP_DATA * appdata) 
     280{ 
     281 
     282gtk_widget_hide(appdata->wheel_history); 
     283gtk_widget_hide(appdata->toolbox_history); 
     284 
    260285} 
    261286 
    262287void 
    263 cb_tool_button_history_call_clicked (GtkButton * button, 
    264                                      MOKO_DIALER_APP_DATA * appdata) 
    265 { 
    266   DBG_ENTER (); 
    267  
    268  
    269  
    270 } 
    271  
    272 void 
    273 cb_tool_button_history_sms_clicked (GtkButton * button, 
    274                                     MOKO_DIALER_APP_DATA * appdata) 
    275 { 
    276   DBG_ENTER (); 
    277  
    278  
    279  
    280 } 
    281  
    282 void 
    283 cb_tool_button_history_back_clicked (GtkButton * button, 
    284                                      MOKO_DIALER_APP_DATA * appdata) 
    285 { 
    286   gtk_widget_hide (appdata->window_history); 
    287  
    288 } 
    289  
    290  
    291 void 
    292 on_window_history_hide (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata) 
    293 { 
    294  
    295   gtk_widget_hide (appdata->wheel_history); 
    296   gtk_widget_hide (appdata->toolbox_history); 
    297  
    298 } 
    299  
    300 void 
    301 on_window_history_show (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata) 
    302 { 
    303   DBG_ENTER (); 
    304  
    305   if (appdata->wheel_history) 
    306     gtk_widget_show (appdata->wheel_history); 
    307  
    308   if (appdata->toolbox_history) 
    309     gtk_widget_show (appdata->toolbox_history); 
    310  
    311   if (appdata->history_need_to_update) 
    312   { 
    313     DBG_MESSAGE ("NEED TO UPDATE HISTORY"); 
    314   } 
    315  
    316   DBG_LEAVE (); 
    317 } 
    318  
    319  
    320  
    321  
    322 gint 
    323 window_history_init (MOKO_DIALER_APP_DATA * p_dialer_data) 
    324 { 
    325  
    326   DBG_ENTER (); 
    327  
    328  
    329   if (p_dialer_data->window_history == 0) 
    330   { 
    331  
    332     history_create_menu_history (p_dialer_data); 
    333  
    334     MokoFingerWindow *window = NULL; 
    335     MokoFingerToolBox *tools = NULL; 
    336     GtkWidget *button; 
    337     GtkWidget *image; 
     288on_window_history_show                  (GtkWidget       *widget, 
     289                                        MOKO_DIALER_APP_DATA * appdata) 
     290{ 
     291DBG_ENTER(); 
     292 
     293if(appdata->wheel_history) 
     294gtk_widget_show(appdata->wheel_history); 
     295 
     296if(appdata->toolbox_history) 
     297gtk_widget_show(appdata->toolbox_history); 
     298 
     299if(appdata->history_need_to_update) 
     300{ 
     301DBG_MESSAGE("NEED TO UPDATE HISTORY"); 
     302} 
     303    
     304DBG_LEAVE(); 
     305} 
     306 
     307 
     308 
     309 
     310gint window_history_init( MOKO_DIALER_APP_DATA* p_dialer_data) 
     311{ 
     312 
     313DBG_ENTER(); 
     314 
     315 
     316if(p_dialer_data->window_history==0) 
     317{ 
     318 
     319         history_create_menu_history (p_dialer_data); 
     320 
     321        MokoFingerWindow* window=NULL; 
     322      MokoFingerToolBox *tools = NULL; 
     323        GtkWidget* button; 
     324        GtkWidget* image; 
    338325 
    339326//now the container--window 
    340     window = MOKO_FINGER_WINDOW (moko_finger_window_new ()); 
    341     p_dialer_data->window_history = window; 
    342  
    343  
    344     moko_finger_window_set_contents (window, 
    345                                      create_window_history_content 
    346                                      (p_dialer_data)); 
    347  
    348     g_signal_connect ((gpointer) window, "show", 
    349                       G_CALLBACK (on_window_history_show), p_dialer_data); 
     327     window = MOKO_FINGER_WINDOW(moko_finger_window_new()); 
     328     p_dialer_data->window_history=window; 
     329 
     330     
     331     moko_finger_window_set_contents(window, create_window_history_content(p_dialer_data)); 
     332 
     333     g_signal_connect ((gpointer) window, "show", 
     334                            G_CALLBACK (on_window_history_show), 
     335                            p_dialer_data); 
    350336    g_signal_connect ((gpointer) window, "hide", 
    351                       G_CALLBACK (on_window_history_hide), p_dialer_data); 
    352  
    353  
    354  
    355     gtk_widget_show_all (GTK_WIDGET (window)); 
     337                            G_CALLBACK (on_window_history_hide), 
     338                            p_dialer_data); 
     339 
     340     
     341      
     342     gtk_widget_show_all( GTK_WIDGET(window) ); 
    356343 
    357344//the gtk_widget_show_all is really bad, cause i have to call it and then hide some widgets. 
    358345 
    359346 
    360     //now the wheel and tool box, why should the wheel and toolbox created after the gtk_widget_show_all??? 
    361     gtk_widget_show (GTK_WIDGET (moko_finger_window_get_wheel (window))); 
    362  
    363     g_signal_connect (G_OBJECT (moko_finger_window_get_wheel (window)), 
    364                       "press_left_up", 
    365                       G_CALLBACK (openmoko_history_wheel_press_left_up_cb), 
    366                       p_dialer_data); 
    367     g_signal_connect (G_OBJECT (moko_finger_window_get_wheel (window)), 
    368                       "press_right_down", 
    369                       G_CALLBACK (openmoko_history_wheel_press_right_down_cb), 
    370                       p_dialer_data); 
    371  
    372  
    373  
    374     tools = moko_finger_window_get_toolbox (window); 
    375  
    376     button = moko_finger_tool_box_add_button_without_label (tools); 
    377     image = file_new_image_from_relative_path ("phone.png"); 
    378     moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image); 
    379     g_signal_connect (G_OBJECT (button), "clicked", 
    380                       G_CALLBACK (cb_tool_button_history_call_clicked), 
    381                       p_dialer_data); 
    382  
    383     button = moko_finger_tool_box_add_button_without_label (tools); 
    384     image = file_new_image_from_relative_path ("sms.png"); 
    385     moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image); 
    386     g_signal_connect (G_OBJECT (button), "clicked", 
    387                       G_CALLBACK (cb_tool_button_history_sms_clicked), 
    388                       p_dialer_data); 
    389  
    390  
    391     button = moko_finger_tool_box_add_button_without_label (tools); 
    392     image = file_new_image_from_relative_path ("delete.png"); 
    393     moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image); 
    394     g_signal_connect (G_OBJECT (button), "clicked", 
    395                       G_CALLBACK (cb_tool_button_history_delete_clicked), 
    396                       p_dialer_data); 
    397     gtk_widget_show (GTK_WIDGET (tools)); 
    398  
    399     button = moko_finger_tool_box_add_button_without_label (tools); 
    400     image = file_new_image_from_relative_path ("tony.png"); 
    401     moko_pixmap_button_set_finger_toolbox_btn_center_image (button, image); 
    402     g_signal_connect (G_OBJECT (button), "clicked", 
    403                       G_CALLBACK (cb_tool_button_history_back_clicked), 
    404                       p_dialer_data); 
    405     gtk_widget_show (GTK_WIDGET (tools)); 
    406  
    407     p_dialer_data->wheel_history = moko_finger_window_get_wheel (window); 
    408     p_dialer_data->toolbox_history = tools; 
    409  
    410     gtk_widget_hide (window); 
    411  
    412     DBG_LEAVE (); 
    413   } 
    414   else 
    415   { 
    416     //here we have to refresh it. 
    417     DBG_TRACE (); 
    418   } 
    419   return 1; 
    420 } 
    421  
    422 void 
    423 on_treeviewHistory_cursor_changed (GtkTreeView * treeview, gpointer user_data) 
    424 { 
    425   GtkTreeIter iter; 
    426   GtkTreeModel *model; 
    427   GtkTreeSelection *selection; 
    428   HISTORY_ENTRY *p; 
    429   int hasname; 
    430   MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) user_data; 
    431  
    432   selection = gtk_tree_view_get_selection (p_dialer_data->treeview_history); 
    433  
    434   if (!gtk_tree_selection_get_selected (selection, &model, &iter)) 
    435   { 
    436     p_dialer_data->g_currentselected = 0; 
    437     return; 
    438   } 
    439  
    440   gtk_tree_model_get (model, &iter, COLUMN_ENTRYPOINTER, &p, -1); 
    441  
    442   p_dialer_data->g_currentselected = p; 
    443  
    444   gtk_tree_model_get (model, &iter, COLUMN_HASNAME, &hasname, -1); 
    445   history_update_counter (p_dialer_data); 
    446  
    447 } 
    448  
    449  
    450  
    451 GtkWidget * 
    452 create_window_history_content (MOKO_DIALER_APP_DATA * p_dialer_data) 
     347 //now the wheel and tool box, why should the wheel and toolbox created after the gtk_widget_show_all??? 
     348   gtk_widget_show(GTK_WIDGET(moko_finger_window_get_wheel(window))); 
     349     
     350    g_signal_connect(G_OBJECT(moko_finger_window_get_wheel(window)), 
     351                    "press_left_up", 
     352                    G_CALLBACK(openmoko_history_wheel_press_left_up_cb), 
     353                    p_dialer_data); 
     354    g_signal_connect(G_OBJECT(moko_finger_window_get_wheel(window)), 
     355                    "press_right_down", 
     356                    G_CALLBACK(openmoko_history_wheel_press_right_down_cb), 
     357                    p_dialer_data); 
     358 
     359 
     360 
     361        tools = moko_finger_window_get_toolbox(window); 
     362      
     363        button = moko_finger_tool_box_add_button_without_label(tools); 
     364       image = file_new_image_from_relative_path("phone.png"); 
     365        moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image); 
     366        g_signal_connect(G_OBJECT(button), "clicked", 
     367                        G_CALLBACK(cb_tool_button_history_call_clicked), p_dialer_data); 
     368         
     369        button = moko_finger_tool_box_add_button_without_label(tools); 
     370       image = file_new_image_from_relative_path("sms.png"); 
     371        moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image); 
     372        g_signal_connect(G_OBJECT(button), "clicked", 
     373                        G_CALLBACK(cb_tool_button_history_sms_clicked), p_dialer_data); 
     374         
     375 
     376        button = moko_finger_tool_box_add_button_without_label(tools); 
     377       image = file_new_image_from_relative_path("delete.png"); 
     378        moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image); 
     379        g_signal_connect(G_OBJECT(button), "clicked", 
     380                        G_CALLBACK(cb_tool_button_history_delete_clicked), p_dialer_data); 
     381        gtk_widget_show(GTK_WIDGET(tools)); 
     382 
     383        button = moko_finger_tool_box_add_button_without_label(tools); 
     384       image = file_new_image_from_relative_path("tony.png"); 
     385        moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image); 
     386        g_signal_connect(G_OBJECT(button), "clicked", 
     387                        G_CALLBACK(cb_tool_button_history_back_clicked), p_dialer_data); 
     388        gtk_widget_show(GTK_WIDGET(tools)); 
     389         
     390        p_dialer_data->wheel_history=moko_finger_window_get_wheel(window); 
     391        p_dialer_data->toolbox_history=tools; 
     392 
     393        gtk_widget_hide(window); 
     394 
     395        DBG_LEAVE(); 
     396} 
     397else 
     398{ 
     399        //here we have to refresh it. 
     400        DBG_TRACE(); 
     401} 
     402    return 1; 
     403} 
     404 
     405void on_treeviewHistory_cursor_changed      (GtkTreeView     *treeview, 
     406                                        gpointer         user_data) 
     407{ 
     408GtkTreeIter iter; 
     409GtkTreeModel* model; 
     410GtkTreeSelection * selection; 
     411HISTORY_ENTRY * p; 
     412int hasname; 
     413MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )user_data; 
     414         
     415selection = gtk_tree_view_get_selection(p_dialer_data->treeview_history); 
     416  
     417if (!gtk_tree_selection_get_selected(selection, &model, &iter)) 
     418 { 
     419         p_dialer_data->g_currentselected=0; 
     420         return ; 
     421 } 
     422         
     423gtk_tree_model_get(model,&iter,COLUMN_ENTRYPOINTER,&p,-1); 
     424 
     425 p_dialer_data->g_currentselected=p; 
     426 
     427gtk_tree_model_get(model,&iter,COLUMN_HASNAME,&hasname,-1); 
     428history_update_counter(p_dialer_data); 
     429 
     430} 
     431 
     432 
     433 
     434GtkWidget* create_window_history_content (MOKO_DIALER_APP_DATA* p_dialer_data) 
    453435{ 
    454436 
    455437  GtkWidget *treeviewHistory; 
    456   GtkWidget *vbox = gtk_vbox_new (FALSE, 0); 
     438  GtkWidget *vbox=gtk_vbox_new(FALSE,0);  
    457439  //FIRST of all, the top title area; 
    458440  GtkWidget *eventboxTop = gtk_event_box_new (); 
    459441  gtk_widget_show (eventboxTop); 
    460   gtk_box_pack_start (GTK_BOX (vbox), eventboxTop, FALSE, FALSE, 5); 
     442  gtk_box_pack_start(GTK_BOX(vbox),eventboxTop,FALSE,FALSE,5); 
    461443  gtk_widget_set_size_request (eventboxTop, 480, 64); 
    462   gtk_widget_set_name (eventboxTop, "gtkeventbox-black"); 
    463  
    464   GtkWidget *hbox67 = gtk_hbox_new (FALSE, 0); 
     444  gtk_widget_set_name(eventboxTop,"gtkeventbox-black"); 
     445         
     446  GtkWidget *  hbox67 = gtk_hbox_new (FALSE, 0); 
    465447  gtk_widget_show (hbox67); 
    466448  gtk_container_add (GTK_CONTAINER (eventboxTop), hbox67); 
    467449 
    468   GtkWidget *eventboxLeftTop = gtk_event_box_new (); 
     450  GtkWidget * eventboxLeftTop = gtk_event_box_new (); 
    469451  gtk_widget_show (eventboxLeftTop); 
    470452  gtk_box_pack_start (GTK_BOX (hbox67), eventboxLeftTop, FALSE, TRUE, 0); 
    471   gtk_widget_set_name (eventboxLeftTop, "gtkeventbox-black"); 
    472  
    473  
    474  
    475   GtkWidget *imageLeftMenu = file_new_image_from_relative_path ("all.png"); 
     453  gtk_widget_set_name(eventboxLeftTop,"gtkeventbox-black"); 
     454 
     455 
     456 
     457  GtkWidget * imageLeftMenu =file_new_image_from_relative_path("all.png"); 
    476458  gtk_widget_show (imageLeftMenu); 
    477459  gtk_container_add (GTK_CONTAINER (eventboxLeftTop), imageLeftMenu); 
     
    488470  gtk_box_pack_start (GTK_BOX (hbox67), labelFilter, TRUE, TRUE, 0); 
    489471  gtk_misc_set_alignment (GTK_MISC (labelFilter), 0, 0.5); 
    490   p_dialer_data->label_filter_history = labelFilter; 
     472  p_dialer_data->label_filter_history=labelFilter; 
    491473 
    492474  GtkWidget *labelCounter = gtk_label_new (("1/21")); 
     
    495477  gtk_label_set_justify (GTK_LABEL (labelCounter), GTK_JUSTIFY_RIGHT); 
    496478  gtk_misc_set_alignment (GTK_MISC (labelCounter), 0.8, 0.5); 
    497   p_dialer_data->label_counter_history = labelCounter; 
    498  
    499   g_signal_connect ((gpointer) eventboxTop, "button_release_event", 
     479  p_dialer_data->label_counter_history=labelCounter; 
     480  
     481    g_signal_connect ((gpointer) eventboxTop, "button_release_event", 
    500482                    G_CALLBACK (on_eventboxTop_button_release_event), 
    501483                    p_dialer_data); 
    502484 
    503   GtkWidget *align = gtk_alignment_new (0, 0, 1, 1); 
    504   gtk_alignment_set_padding (align, 0, 150, 0, 0);      //FIXME too many numbers has to be retrieved from style 
    505  
     485  GtkWidget *align=gtk_alignment_new(0,0,1,1); 
     486  gtk_alignment_set_padding(align, 0, 150, 0, 0); //FIXME too many numbers has to be retrieved from style 
     487   
    506488  GtkWidget *scrolledwindow = gtk_scrolled_window_new (NULL, NULL); 
    507489  gtk_widget_show (scrolledwindow); 
    508   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), 
    509                                   GTK_POLICY_NEVER, GTK_POLICY_NEVER); 
    510  
     490  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_NEVER); 
     491  
    511492  treeviewHistory = gtk_tree_view_new (); 
    512493  gtk_container_add (GTK_CONTAINER (align), scrolledwindow); 
     
    517498  gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeviewHistory), FALSE); 
    518499//   gtk_misc_set_alignment (GTK_MISC (treeviewHistory), 0.5, 0.5); 
    519   gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0); 
    520  
    521  
    522   gtk_widget_set_name (treeviewHistory, "gtktreeview-black"); 
    523   p_dialer_data->treeview_history = treeviewHistory; 
    524   history_build_history_list_view (p_dialer_data); 
    525   gtk_widget_set_size_request (scrolledwindow, -1, 400); 
     500  gtk_box_pack_start(GTK_BOX(vbox),align,TRUE,TRUE,0); 
     501 
     502 
     503  gtk_widget_set_name(treeviewHistory,"gtktreeview-black"); 
     504  p_dialer_data->treeview_history=treeviewHistory; 
     505   history_build_history_list_view(p_dialer_data); 
     506  gtk_widget_set_size_request (scrolledwindow, -1, 400);     
    526507//  gtk_misc_set_alignment (GTK_MISC (treeviewHistory),1,0.1); 
    527508 
     
    548529 * @retval  FALSE means the iter will not be displayed 
    549530 */ 
    550 static gboolean 
    551 history_view_filter_visible_function (GtkTreeModel * model, 
    552                                       GtkTreeIter * iter, gpointer data) 
    553 { 
    554   MOKO_DIALER_APP_DATA *p_dialer_data = (MOKO_DIALER_APP_DATA *) data; 
    555   HISTORY_TYPE type; 
    556   if (p_dialer_data->g_history_filter_type == ALL) 
    557     return TRUE; 
    558   gtk_tree_model_get (model, iter, COLUMN_TYPE, &type, -1); 
    559   if (type == p_dialer_data->g_history_filter_type) 
    560     return TRUE; 
    561   else 
    562     return FALSE; 
     531static gboolean history_view_filter_visible_function(GtkTreeModel *model,GtkTreeIter *iter,gpointer data) 
     532{ 
     533        MOKO_DIALER_APP_DATA* p_dialer_data=(MOKO_DIALER_APP_DATA* )data; 
     534        HISTORY_TYPE type; 
     535        if(p_dialer_data->g_history_filter_type==ALL) 
     536                return TRUE; 
     537        gtk_tree_model_get(model,iter,COLUMN_TYPE,&type,-1); 
     538        if(type==p_dialer_data->g_history_filter_type) 
     539                return TRUE; 
     540        else 
     541                return FALSE; 
    563542} 
    564543 
     
    577556 */ 
    578557 
    579 gint 
    580 history_build_history_list_view (MOKO_DIALER_APP_DATA * p_dialer_data) 
    581 { 
    582   GtkListStore *list_store; 
    583  
    584   GtkTreeIter iter; 
    585   HISTORY_ENTRY *entry; 
    586  
    587   //copied 
    588   GtkTreeViewColumn *col; 
    589   GtkCellRenderer *renderer; 
    590  
    591   //GtkTreeModel        *model; 
    592   GtkWidget *contactview = NULL; 
    593  
    594   //DBG_ENTER(); 
    595   //DBG_MESSAGE("History:%d",g_historylist.length); 
    596  
    597   //DBG_TRACE(); 
    598   p_dialer_data->g_history_filter_type = ALL; 
     558gint history_build_history_list_view(MOKO_DIALER_APP_DATA* p_dialer_data) 
     559{ 
     560        GtkListStore * list_store; 
     561         
     562        GtkTreeIter iter; 
     563        HISTORY_ENTRY * entry; 
     564         
     565        //copied 
     566        GtkTreeViewColumn   *col; 
     567        GtkCellRenderer     *renderer; 
     568         
     569        //GtkTreeModel        *model; 
     570        GtkWidget           *contactview=NULL; 
     571         
     572        //DBG_ENTER(); 
     573        //DBG_MESSAGE("History:%d",g_historylist.length); 
     574         
     575        //DBG_TRACE(); 
     576  p_dialer_data->g_history_filter_type=ALL; 
    599577  contactview = p_dialer_data->treeview_history; 
    600578 
    601   if (contactview == NULL) 
     579  if(contactview == NULL) 
    602580    return 0; 
    603581//pack image and label 
     
    606584  gtk_tree_view_column_set_title (col, ("Title")); 
    607585  gtk_tree_view_column_set_resizable (col, TRUE); 
    608  
    609  
    610  
     586  
     587         
     588   
    611589  renderer = gtk_cell_renderer_pixbuf_new (); 
    612590  gtk_tree_view_column_pack_start (col, renderer, FALSE); 
    613   gtk_tree_view_column_set_attributes (col, renderer, 
    614                                        "pixbuf", COLUMN_TYPEICON, NULL); 
     591  gtk_tree_view_column_set_attributes (col, renderer,  
     592  "pixbuf",COLUMN_TYPEICON,NULL); 
    615593 
    616594  renderer = gtk_cell_renderer_text_new (); 
    617595  gtk_tree_view_column_pack_start (col, renderer, FALSE); 
    618   gtk_tree_view_column_set_attributes (col, renderer, 
    619                                        "text", COLUMN_TIME, NULL); 
    620  
     596  gtk_tree_view_column_set_attributes(col, renderer,  
     597  "text",COLUMN_TIME,NULL); 
     598  
    621599  renderer = gtk_cell_renderer_text_new (); 
    622600  gtk_tree_view_column_pack_start (col, renderer, FALSE); 
    623   gtk_tree_view_column_set_attributes (col, renderer, 
    624                                        "text", COLUMN_SEPRATE, NULL); 
    625  
     601  gtk_tree_view_column_set_attributes(col, renderer,  
     602  "text",COLUMN_SEPRATE,NULL); 
     603  
    626604  renderer = gtk_cell_renderer_text_new (); 
    627605  gtk_tree_view_column_pack_start (col, renderer, TRUE); 
    628   gtk_tree_view_column_set_attributes (col, renderer, 
    629                                        "text", COLUMN_NAME_NUMBER, NULL); 
    630  
    631  
    632   gtk_tree_view_append_column (GTK_TREE_VIEW (contactview), col); 
    633  
    634  
    635   entry = p_dialer_data->g_historylist.first; 
    636  
    637   list_store = gtk_list_store_new (N_COLUMN, G_TYPE_INT, GDK_TYPE_PIXBUF, 
    638                                    G_TYPE_STRING, G_TYPE_STRING, 
    639                                    G_TYPE_STRING, G_TYPE_INT, G_TYPE_POINTER, 
    640                                    G_TYPE_INT, -1); 
    641   //we will use a filter to facilitate the filtering in treeview without rebuilding the database.                          
    642   p_dialer_data->g_list_store_filter = 
    643     gtk_tree_model_filter_new (GTK_TREE_MODEL (list_store), NULL); 
    644   gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER 
    645                                           (p_dialer_data-> 
    646                                            g_list_store_filter), 
    647                                           history_view_filter_visible_function, 
    648                                           p_dialer_data, NULL); 
     606  gtk_tree_view_column_set_attributes(col, renderer,  
     607  "text",COLUMN_NAME_NUMBER,NULL); 
     608 
     609 
     610   gtk_tree_view_append_column (GTK_TREE_VIEW (contactview), col); 
     611 
     612 
     613        entry=p_dialer_data->g_historylist.first; 
     614         
     615        list_store=gtk_list_store_new(N_COLUMN, G_TYPE_INT,GDK_TYPE_PIXBUF, 
     616                                        G_TYPE_STRING,  G_TYPE_STRING,   
     617                                        G_TYPE_STRING,  G_TYPE_INT,G_TYPE_POINTER,G_TYPE_INT,-1); 
     618        //we will use a filter to facilitate the filtering in treeview without rebuilding the database.                          
     619        p_dialer_data->g_list_store_filter=gtk_tree_model_filter_new(GTK_TREE_MODEL(list_store),NULL); 
     620        gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(p_dialer_data->g_list_store_filter), 
     621        history_view_filter_visible_function,p_dialer_data,NULL); 
    649622 
    650623//load the three icons to memory. 
    651   GError *error = NULL; 
    652   p_dialer_data->g_iconReceived = create_pixbuf ("received.png", &error); 
    653   if (error) 
    654   { 
    655     DBG_WARN ("Cound not load icon :%s", error->message); 
    656     g_error_free (error); 
    657     p_dialer_data->g_iconReceived = NULL; 
    658     error = NULL; 
    659   } 
    660  
    661   p_dialer_data->g_iconDialed = create_pixbuf ("dialed.png", &error); 
    662   if (error) 
    663   { 
    664     DBG_WARN ("Cound not load icon :%s", error->message); 
    665     g_error_free (error); 
    666     p_dialer_data->g_iconDialed = NULL; 
    667     error = NULL; 
    668   } 
    669  
    670  
    671   p_dialer_data->g_iconMissed = create_pixbuf ("missed.png", &error); 
    672   if (error) 
    673   { 
    674     DBG_WARN ("Cound not load icon :%s", error->message); 
    675     g_error_free (error); 
    676     p_dialer_data->g_iconMissed = NULL; 
    677     error = NULL; 
    678   } 
    679  
    680  
    681   while (entry) 
    682   { 
    683     //DBG_MESSAGE(entry->number); 
    684     gtk_list_store_append (list_store, &iter); 
    685     gtk_list_store_set (list_store, &iter, COLUMN_TYPE, entry->type, 
    686                         COLUMN_SEPRATE, "--", COLUMN_TIME, entry->time, 
    687                         COLUMN_DURATION, entry->durationsec, 
    688                         COLUMN_ENTRYPOINTER, entry, COLUMN_HASNAME, 0, -1); 
    689     if (entry->name == 0) 
    690     { 
    691       //DBG_MESSAGE(entry->number); 
    692       gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER, 
    693                           entry->number, -1); 
    694       gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 0, -1); 
    695     } 
    696     else 
    697     { 
    698       gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER, entry->name, 
    699                           -1); 
    700       gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 1, -1); 
    701     } 
    702     switch (entry->type) 
    703     { 
    704       case INCOMING: 
    705         { 
    706           gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON, 
    707                               p_dialer_data->g_iconReceived, -1); 
    708           //      icon=gdk_pixbuf_new_from_file("./received.png",&error); 
    709           break; 
    710         } 
    711       case OUTGOING: 
    712         {                       //     icon=gdk_pixbuf_new_from_file("./dialed.png",&error); 
    713           gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON, 
    714                               p_dialer_data->g_iconDialed, -1); 
    715           break; 
    716         } 
    717       case MISSED: 
    718         {                       //icon=gdk_pixbuf_new_from_file("./missed.png",&error); 
    719           gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON, 
    720                               p_dialer_data->g_iconMissed, -1); 
    721           break; 
    722         } 
    723  
    724       default: 
    725  
    726         {                       //icon=gdk_pixbuf_new_from_file("./missed.png",&error); 
    727           gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON, 
    728                               p_dialer_data->g_iconMissed, -1); 
    729           break; 
    730         } 
    731     } 
    732  
    733  
    734  
    735     entry = entry->next; 
    736   } 
    737  
    738   gtk_tree_view_set_model (GTK_TREE_VIEW (contactview), 
    739                            GTK_TREE_MODEL (p_dialer_data-> 
    740                                            g_list_store_filter)); 
     624GError *error=NULL;      
     625                p_dialer_data->g_iconReceived=create_pixbuf("received.png",&error); 
     626                if(error) 
     627                                { 
     628                                        DBG_WARN("Cound not load icon :%s",error->message); 
     629                                        g_error_free(error); 
     630                                        p_dialer_data->g_iconReceived=NULL; 
     631                                        error=NULL; 
     632                                } 
     633 
     634                p_dialer_data->g_iconDialed=create_pixbuf("dialed.png",&error); 
     635                if(error) 
     636                                { 
     637                                        DBG_WARN("Cound not load icon :%s",error->message); 
     638                                        g_error_free(error); 
     639                                        p_dialer_data->g_iconDialed=NULL; 
     640                                        error=NULL; 
     641                                } 
     642 
     643   
     644                 p_dialer_data->g_iconMissed=create_pixbuf("missed.png",&error); 
     645                if(error) 
     646                                { 
     647                                        DBG_WARN("Cound not load icon :%s",error->message); 
     648                                        g_error_free(error); 
     649                                        p_dialer_data->g_iconMissed=NULL; 
     650                                        error=NULL; 
     651                                } 
     652 
     653 
     654        while(entry) 
     655        { 
     656                //DBG_MESSAGE(entry->number); 
     657                gtk_list_store_append(list_store,&iter); 
     658                gtk_list_store_set(list_store,&iter,COLUMN_TYPE,entry->type,COLUMN_SEPRATE,"--", 
     659                COLUMN_TIME,entry->time,COLUMN_DURATION,entry->durationsec,COLUMN_ENTRYPOINTER,entry,COLUMN_HASNAME,0,-1); 
     660                if(entry->name==0) 
     661                { 
     662                //DBG_MESSAGE(entry->number); 
     663                gtk_list_store_set(list_store,&iter,COLUMN_NAME_NUMBER,entry->number,-1); 
     664                gtk_list_store_set(list_store,&iter,COLUMN_HASNAME,0,-1); 
     665                } 
     666                else 
     667                { 
     668                gtk_list_store_set(list_store,&iter,COLUMN_NAME_NUMBER,entry->name,-1);          
     669                gtk_list_store_set(list_store,&iter,COLUMN_HASNAME,1,-1); 
     670                } 
     671                switch(entry->type) 
     672                { 
     673                        case INCOMING: 
     674                        { 
     675                                gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,p_dialer_data->g_iconReceived,-1);           
     676                        //      icon=gdk_pixbuf_new_from_file("./received.png",&error); 
     677                                break; 
     678                        } 
     679                        case OUTGOING: 
     680                        {//     icon=gdk_pixbuf_new_from_file("./dialed.png",&error); 
     681                                gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,p_dialer_data->g_iconDialed,-1);             
     682                                break; 
     683                        } 
     684                        case MISSED: 
     685                        {       //icon=gdk_pixbuf_new_from_file("./missed.png",&error); 
     686                                gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,p_dialer_data->g_iconMissed,-1);             
     687                                break; 
     688                        } 
     689 
     690                        default: 
     691                         
     692                        {       //icon=gdk_pixbuf_new_from_file("./missed.png",&error); 
     693                                gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,p_dialer_data->g_iconMissed,-1);             
     694                                break; 
     695                        } 
     696                } 
     697                                                 
     698 
     699                 
     700                entry=entry->next; 
     701        } 
     702         
     703  gtk_tree_view_set_model (GTK_TREE_VIEW(contactview),GTK_TREE_MODEL(p_dialer_data->g_list_store_filter)); 
    741704 
    742705  g_object_unref (list_store); 
     
    753716 * @return 1 
    754717 */ 
    755 gint 
    756 history_update_counter (MOKO_DIALER_APP_DATA * p_dialer_data) 
    757 { 
    758   DBG_ENTER (); 
    759   GtkTreeIter iter; 
    760   GtkTreeModel *model; 
    761   GtkTreeSelection *selection; 
    762   GtkTreePath *path; 
    763   GtkTreeView *treeview; 
    764   int count = 0; 
    765   int nth = 0; 
    766   char *pathstring; 
    767   char display[10]; 
    768  
    769   treeview = GTK_TREE_VIEW (p_dialer_data->treeview_history); 
    770   if (!p_dialer_data->treeview_history) 
    771   { 
    772     DBG_WARN ("COUNTER NOT READY "); 
    773     return 0; 
    774   } 
    775  
    776  
    777   model = gtk_tree_view_get_model (treeview); 
    778  
    779   count = gtk_tree_model_iter_n_children (model, NULL); 
    780  
    781   selection = gtk_tree_view_get_selection (treeview); 
    782  
    783   if (!gtk_tree_selection_get_selected (selection, &model, &iter)) 
    784   { 
    785     nth = 0; 
    786   } 
    787   else 
    788   { 
    789     path = gtk_tree_model_get_path (model, &iter); 
    790     pathstring = gtk_tree_path_to_string (path); 
    791     nth = atoi (pathstring) + 1; 
    792     gtk_tree_path_free (path); 
    793  
    794   } 
    795  
    796   GtkWidget *labelcounter; 
    797   labelcounter = p_dialer_data->label_counter_history; 
    798   sprintf (display, "%d/%d", nth, count); 
    799   gtk_label_set_text (GTK_LABEL (labelcounter), display); 
    800   return 1; 
    801  
    802 } 
    803  
    804 GtkWidget * 
    805 history_create_menu_history (MOKO_DIALER_APP_DATA * p_dialer_data) 
    806 { 
    807   if (!p_dialer_data->menu_history) 
    808   { 
    809     GtkWidget *menu_history; 
    810     GtkWidget *all_calls; 
    811     GtkWidget *imageAll; 
    812     GtkWidget *separator1; 
    813     GtkWidget *missed_calls; 
    814     GtkWidget *imageMissed; 
    815     GtkWidget *separator3; 
    816     GtkWidget *dialed_calls; 
    817     GtkWidget *imageDialed; 
    818     GtkWidget *separator2; 
    819     GtkWidget *received_calls; 
    820     GtkWidget *imageReceived; 
    821  
    822     menu_history = gtk_menu_new (); 
    823     gtk_container_set_border_width (GTK_CONTAINER (menu_history), 2); 
    824  
    825     all_calls = gtk_image_menu_item_new_with_mnemonic (("Calls All")); 
    826     gtk_widget_show (all_calls); 
    827     gtk_container_add (GTK_CONTAINER (menu_history), all_calls); 
    828     gtk_widget_set_size_request (all_calls, 250, 60); 
    829  
    830  
    831     imageAll = file_new_image_from_relative_path ("all.png"); 
    832     gtk_widget_show (imageAll); 
    833     gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (all_calls), imageAll); 
    834  
    835     separator1 = gtk_separator_menu_item_new (); 
    836     gtk_widget_show (separator1); 
    837     gtk_container_add (GTK_CONTAINER (menu_history), separator1); 
    838     gtk_widget_set_size_request (separator1, 120, -1); 
    839     gtk_widget_set_sensitive (separator1, FALSE); 
    840  
    841     missed_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Missed ")); 
    842     gtk_widget_show (missed_calls); 
    843     gtk_container_add (GTK_CONTAINER (menu_history), missed_calls); 
    844     gtk_widget_set_size_request (missed_calls, 120, 60); 
    845  
    846     //imageMissed = gtk_image_new_from_stock ("gtk-goto-bottom", GTK_ICON_SIZE_MENU); 
    847     imageMissed = file_new_image_from_relative_path ("missed.png"); 
    848  
    849     gtk_widget_show (imageMissed); 
    850     gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (missed_calls), 
    851                                    imageMissed); 
    852  
    853     separator3 = gtk_separator_menu_item_new (); 
    854     gtk_widget_show (separator3); 
    855     gtk_container_add (GTK_CONTAINER (menu_history), separator3); 
    856     gtk_widget_set_size_request (separator3, 120, -1); 
    857     gtk_widget_set_sensitive (separator3, FALSE); 
    858  
    859     dialed_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Dialed")); 
    860     gtk_widget_show (dialed_calls); 
    861     gtk_container_add (GTK_CONTAINER (menu_history), dialed_calls); 
    862     gtk_widget_set_size_request (dialed_calls, 120, 60); 
    863  
    864     // imageDialed = gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_MENU); 
    865     imageDialed = file_new_image_from_relative_path ("dialed.png"); 
    866     gtk_widget_show (imageDialed); 
    867     gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (dialed_calls), 
    868                                    imageDialed); 
    869  
    870     separator2 = gtk_separator_menu_item_new (); 
    871     gtk_widget_show (separator2); 
    872     gtk_container_add (GTK_CONTAINER (menu_history), separator2); 
    873     gtk_widget_set_size_request (separator2, 120, -1); 
    874     gtk_widget_set_sensitive (separator2, FALSE); 
    875  
    876     received_calls = 
    877       gtk_image_menu_item_new_with_mnemonic (("Calls Received ")); 
    878     gtk_widget_show (received_calls); 
    879     gtk_container_add (GTK_CONTAINER (menu_history), received_calls); 
    880     gtk_widget_set_size_request (received_calls, 120, 60); 
     718gint history_update_counter(MOKO_DIALER_APP_DATA* p_dialer_data) 
     719{ 
     720DBG_ENTER(); 
     721GtkTreeIter iter; 
     722GtkTreeModel* model; 
     723GtkTreeSelection * selection; 
     724GtkTreePath *path; 
     725GtkTreeView * treeview; 
     726int count=0; 
     727int nth=0; 
     728char * pathstring; 
     729char display[10]; 
     730         
     731treeview=GTK_TREE_VIEW(p_dialer_data->treeview_history); 
     732if(!p_dialer_data->treeview_history) 
     733{ 
     734DBG_WARN("COUNTER NOT READY "); 
     735return 0; 
     736} 
     737 
     738 
     739model=gtk_tree_view_get_model(treeview);         
     740 
     741count=gtk_tree_model_iter_n_children(model,NULL); 
     742         
     743selection = gtk_tree_view_get_selection(treeview); 
     744  
     745if (!gtk_tree_selection_get_selected(selection, &model, &iter)) 
     746{ 
     747        nth=0; 
     748} 
     749else 
     750{ 
     751path=gtk_tree_model_get_path(model,&iter); 
     752pathstring=gtk_tree_path_to_string(path); 
     753nth=atoi(pathstring)+1; 
     754gtk_tree_path_free(path);        
     755 
     756} 
     757         
     758GtkWidget *labelcounter; 
     759labelcounter=p_dialer_data->label_counter_history; 
     760sprintf(display,"%d/%d",nth,count); 
     761gtk_label_set_text(GTK_LABEL(labelcounter),display); 
     762return 1;        
     763 
     764} 
     765 
     766GtkWidget* history_create_menu_history (MOKO_DIALER_APP_DATA* p_dialer_data) 
     767{ 
     768if(!p_dialer_data->menu_history) 
     769{ 
     770  GtkWidget *menu_history; 
     771  GtkWidget *all_calls; 
     772  GtkWidget *imageAll; 
     773  GtkWidget *separator1; 
     774  GtkWidget *missed_calls; 
     775  GtkWidget *imageMissed; 
     776  GtkWidget *separator3; 
     777  GtkWidget *dialed_calls; 
     778  GtkWidget *imageDialed; 
     779  GtkWidget *separator2; 
     780  GtkWidget *received_calls; 
     781  GtkWidget *imageReceived; 
     782 
     783  menu_history = gtk_menu_new (); 
     784  gtk_container_set_border_width (GTK_CONTAINER (menu_history), 2); 
     785 
     786  all_calls = gtk_image_menu_item_new_with_mnemonic (("Calls All")); 
     787  gtk_widget_show (all_calls); 
     788  gtk_container_add (GTK_CONTAINER (menu_history), all_calls); 
     789  gtk_widget_set_size_request (all_calls, 250, 60); 
     790 
     791 
     792  imageAll =file_new_image_from_relative_path("all.png"); 
     793  gtk_widget_show (imageAll); 
     794  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (all_calls), imageAll); 
     795 
     796  separator1 = gtk_separator_menu_item_new (); 
     797  gtk_widget_show (separator1); 
     798  gtk_container_add (GTK_CONTAINER (menu_history), separator1); 
     799  gtk_widget_set_size_request (separator1, 120, -1); 
     800  gtk_widget_set_sensitive (separator1, FALSE); 
     801 
     802  missed_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Missed ")); 
     803  gtk_widget_show (missed_calls); 
     804  gtk_container_add (GTK_CONTAINER (menu_history), missed_calls); 
     805  gtk_widget_set_size_request (missed_calls, 120, 60); 
     806 
     807  //imageMissed = gtk_image_new_from_stock ("gtk-goto-bottom", GTK_ICON_SIZE_MENU); 
     808  imageMissed =file_new_image_from_relative_path("missed.png"); 
     809   
     810  gtk_widget_show (imageMissed); 
     811  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (missed_calls), imageMissed); 
     812 
     813  separator3 = gtk_separator_menu_item_new (); 
     814  gtk_widget_show (separator3); 
     815  gtk_container_add (GTK_CONTAINER (menu_history), separator3); 
     816  gtk_widget_set_size_request (separator3, 120, -1); 
     817  gtk_widget_set_sensitive (separator3, FALSE); 
     818 
     819  dialed_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Dialed")); 
     820  gtk_widget_show (dialed_calls); 
     821  gtk_container_add (GTK_CONTAINER (menu_history), dialed_calls); 
     822  gtk_widget_set_size_request (dialed_calls, 120, 60); 
     823 
     824 // imageDialed = gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_MENU); 
     825  imageDialed =file_new_image_from_relative_path("dialed.png"); 
     826  gtk_widget_show (imageDialed); 
     827  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (dialed_calls), imageDialed); 
     828 
     829  separator2 = gtk_separator_menu_item_new (); 
     830  gtk_widget_show (separator2); 
     831  gtk_container_add (GTK_CONTAINER (menu_history), separator2); 
     832  gtk_widget_set_size_request (separator2, 120, -1); 
     833  gtk_widget_set_sensitive (separator2, FALSE); 
     834 
     835  received_calls = gtk_image_menu_item_new_with_mnemonic (("Calls Received ")); 
     836  gtk_widget_show (received_calls); 
     837  gtk_container_add (GTK_CONTAINER (menu_history), received_calls); 
     838  gtk_widget_set_size_request (received_calls, 120, 60); 
    881839 
    882840//  imageReceived = gtk_image_new_from_stock ("gtk-go-down", GTK_ICON_SIZE_MENU); 
    883     imageReceived = file_new_image_from_relative_path ("received.png"); 
    884     gtk_widget_show (imageReceived); 
    885     gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (received_calls), 
    886                                    imageReceived); 
    887  
    888     g_signal_connect ((gpointer) all_calls, "activate", 
    889                       G_CALLBACK (on_all_calls_activate), p_dialer_data); 
    890     g_signal_connect ((gpointer) missed_calls, "activate", 
    891                       G_CALLBACK (on_missed_calls_activate), p_dialer_data); 
    892     g_signal_connect ((gpointer) dialed_calls, "activate", 
    893                       G_CALLBACK (on_dialed_calls_activate), p_dialer_data); 
    894     g_signal_connect ((gpointer) received_calls, "activate", 
    895                       G_CALLBACK (on_received_calls_activate), p_dialer_data); 
    896  
    897     p_dialer_data->menu_history = menu_history; 
    898     return menu_history; 
    899   } 
    900   else 
    901     return p_dialer_data->menu_history; 
     841 imageReceived=file_new_image_from_relative_path("received.png"); 
     842  gtk_widget_show (imageReceived); 
     843  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (received_calls), imageReceived); 
     844 
     845  g_signal_connect ((gpointer) all_calls, "activate", 
     846                    G_CALLBACK (on_all_calls_activate), 
     847                    p_dialer_data); 
     848  g_signal_connect ((gpointer) missed_calls, "activate", 
     849                    G_CALLBACK (on_missed_calls_activate), 
     850                    p_dialer_data); 
     851  g_signal_connect ((gpointer) dialed_calls, "activate", 
     852                    G_CALLBACK (on_dialed_calls_activate), 
     853                    p_dialer_data); 
     854  g_signal_connect ((gpointer) received_calls, "activate", 
     855                    G_CALLBACK (on_received_calls_activate), 
     856                    p_dialer_data); 
     857 
     858p_dialer_data->menu_history=menu_history; 
     859  return menu_history; 
     860} 
     861else 
     862        return p_dialer_data->menu_history; 
    902863} 
    903864 
     
    914875 * @retval 1 everything is OK 
    915876 */ 
    916 gint 
    917 history_list_view_add (MOKO_DIALER_APP_DATA * appdata, HISTORY_ENTRY * entry) 
    918 { 
    919   DBG_ENTER (); 
    920   if (entry == 0) 
    921   { 
    922     DBG_ERROR ("THE ENTRY IS ZERO"); 
    923     return 0; 
    924   } 
    925  
    926   if (appdata->treeview_history == 0) 
    927   { 
    928     DBG_WARN ("not ready"); 
    929     return 0; 
    930  
    931   } 
    932   // 
    933   GtkTreeIter iter;             //iter of the filter store 
    934   GtkTreeModel *model; 
    935   GtkListStore *list_store; 
    936   GtkTreeView *treeview; 
    937  
    938   treeview = GTK_TREE_VIEW (appdata->treeview_history); 
    939  
    940   model = 
    941     gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER 
    942                                      (appdata->g_list_store_filter)); 
    943  
    944   list_store = GTK_LIST_STORE (model); 
    945   // 
    946  
    947  
    948   //DBG_MESSAGE(entry->number); 
    949   gtk_list_store_insert (list_store, &iter, 0); 
    950   gtk_list_store_set (list_store, &iter, COLUMN_TYPE, entry->type, 
    951                       COLUMN_SEPRATE, "--", COLUMN_TIME, entry->time, 
    952                       COLUMN_DURATION, entry->durationsec, 
    953                       COLUMN_ENTRYPOINTER, entry, COLUMN_HASNAME, 0, -1); 
    954   if (entry->name == 0) 
    955   { 
    956     //DBG_MESSAGE(entry->number); 
    957     gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER, entry->number, 
    958                         -1); 
    959     gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 0, -1); 
    960   } 
    961   else 
    962   { 
    963     gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER, entry->name, 
    964                         -1); 
    965     gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 1, -1); 
    966   } 
    967   switch (entry->type) 
    968   { 
    969     case INCOMING: 
    970       { 
    971         gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON, 
    972                             appdata->g_iconReceived, -1); 
    973         //      icon=gdk_pixbuf_new_from_file("./received.png",&error); 
    974         break; 
    975       } 
    976     case OUTGOING: 
    977       {                         //     icon=gdk_pixbuf_new_from_file("./dialed.png",&error); 
    978         gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON, 
    979                             appdata->g_iconDialed, -1); 
    980         break; 
    981       } 
    982     case MISSED: 
    983       {                         //icon=gdk_pixbuf_new_from_file("./missed.png",&error); 
    984         gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON, 
    985                             appdata->g_iconMissed, -1); 
    986         break; 
    987       } 
    988  
    989     default: 
    990  
    991       {                         //icon=gdk_pixbuf_new_from_file("./missed.png",&error); 
    992         gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON, 
    993                             appdata->g_iconMissed, -1); 
    994         break; 
    995       } 
    996   } 
    997   history_update_counter (appdata); 
    998   return 1; 
    999 } 
    1000  
    1001  
    1002 gint 
    1003 add_histroy_entry (MOKO_DIALER_APP_DATA * appdata, HISTORY_TYPE type, 
    1004                    const char *name, const char *number, const char *picpath, 
    1005                    char *time, char *date, int durationsec) 
    1006 { 
    1007    
     877gint history_list_view_add(MOKO_DIALER_APP_DATA* appdata,HISTORY_ENTRY * entry) 
     878{ 
     879DBG_ENTER(); 
     880if(entry==0) 
     881        { 
     882                DBG_ERROR("THE ENTRY IS ZERO"); 
     883                return 0; 
     884        } 
     885 
     886if(appdata->treeview_history==0) 
     887{ 
     888                DBG_WARN("not ready"); 
     889                return 0; 
     890 
     891} 
     892        // 
     893GtkTreeIter iter; //iter of the filter store 
     894GtkTreeModel* model; 
     895GtkListStore* list_store; 
     896GtkTreeView* treeview; 
     897 
     898treeview=GTK_TREE_VIEW(appdata->treeview_history); 
     899 
     900model=gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(appdata->g_list_store_filter));      
     901 
     902list_store=GTK_LIST_STORE(model); 
     903        // 
     904         
     905         
     906        //DBG_MESSAGE(entry->number); 
     907                gtk_list_store_insert(list_store,&iter,0); 
     908                gtk_list_store_set(list_store,&iter,COLUMN_TYPE,entry->type,COLUMN_SEPRATE,"--", 
     909                COLUMN_TIME,entry->time,COLUMN_DURATION,entry->durationsec,COLUMN_ENTRYPOINTER,entry,COLUMN_HASNAME,0,-1); 
     910                if(entry->name==0) 
     911                { 
     912                //DBG_MESSAGE(entry->number); 
     913                gtk_list_store_set(list_store,&iter,COLUMN_NAME_NUMBER,entry->number,-1); 
     914                gtk_list_store_set(list_store,&iter,COLUMN_HASNAME,0,-1); 
     915                } 
     916                else 
     917                { 
     918                gtk_list_store_set(list_store,&iter,COLUMN_NAME_NUMBER,entry->name,-1);          
     919                gtk_list_store_set(list_store,&iter,COLUMN_HASNAME,1,-1); 
     920                } 
     921                switch(entry->type) 
     922                { 
     923                        case INCOMING: 
     924                        { 
     925                                gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,appdata->g_iconReceived,-1);                 
     926                        //      icon=gdk_pixbuf_new_from_file("./received.png",&error); 
     927                                break; 
     928                        } 
     929                        case OUTGOING: 
     930                        {//     icon=gdk_pixbuf_new_from_file("./dialed.png",&error); 
     931                                gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,appdata->g_iconDialed,-1);           
     932                                break; 
     933                        } 
     934                        case MISSED: 
     935                        {       //icon=gdk_pixbuf_new_from_file("./missed.png",&error); 
     936                                gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,appdata->g_iconMissed,-1);           
     937                                break; 
     938                        } 
     939 
     940                        default: 
     941                         
     942                        {       //icon=gdk_pixbuf_new_from_file("./missed.png",&error); 
     943                                gtk_list_store_set(list_store,&iter,COLUMN_TYPEICON,appdata->g_iconMissed,-1);           
     944                                break; 
     945                        } 
     946                } 
     947history_update_counter(appdata);  
     948return 1;        
     949} 
     950 
     951 
     952gint 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) 
     953{ 
     954 
    1008955//DBG_ENTER(); 
    1009     //DBG_MESSAGE("History add:%s,%s,%s,%s,%s,%d",name,number,picpath,time,date,durationsec); 
    1010     HISTORY_ENTRY * pentry = 
    1011     history_add_entry (&(appdata->g_historylist), type, name, number, picpath, 
    1012                        time, date, durationsec); 
    1013   return history_list_view_add (appdata, pentry); 
    1014 } 
     956 
     957        //DBG_MESSAGE("History add:%s,%s,%s,%s,%s,%d",name,number,picpath,time,date,durationsec); 
     958 HISTORY_ENTRY * pentry=history_add_entry(&(appdata->g_historylist),type,name,number,id,time,date,durationsec);  
     959 return history_list_view_add(appdata,pentry);   
     960} 
     961 
     962 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-incoming.c

    r648 r649  
    3535#include "openmoko-dialer-window-incoming.h" 
    3636 
    37 void 
    38 cb_answer_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata) 
    39 { 
    40   DBG_ENTER (); 
    41  
    42   appdata->g_state.callstate = STATE_TALKING; 
    43   gsm_answer (); 
    44  
    45   gtk_widget_hide (appdata->window_incoming); 
    46  
    47   if (!appdata->window_talking) 
    48     window_talking_init (appdata); 
     37void cb_answer_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata) 
     38{ 
     39DBG_ENTER(); 
     40 
     41appdata->g_state.callstate=STATE_TALKING; 
     42gsm_answer(); 
     43 
     44gtk_widget_hide(appdata->window_incoming); 
     45 
    4946 
    5047//transfer the contact info 
    51   window_talking_prepare (appdata); 
    52  
    53  
    54   gtk_widget_show (appdata->window_talking); 
    55  
    56   DBG_LEAVE (); 
    57 } 
    58  
    59 void 
    60 cb_ignore_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata) 
    61 { 
    62   DBG_ENTER (); 
    63   DBG_MESSAGE ("We will mute the phone for this call."); 
    64   appdata->g_state.callstate = STATE_IGNORED; 
    65   DBG_LEAVE (); 
    66 } 
    67  
    68 void 
    69 cb_reject_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata) 
    70 { 
    71   DBG_ENTER (); 
    72   gsm_hangup (); 
    73   appdata->g_state.callstate = STATE_REJECTED; 
    74   gtk_widget_hide (appdata->window_incoming); 
    75   DBG_LEAVE (); 
    76 } 
    77  
    78 void 
    79 window_incoming_prepare (MOKO_DIALER_APP_DATA * appdata) 
    80 { 
    81   if (!appdata) 
    82   { 
    83     DBG_WARN ("appdata=NULL!"); 
    84     return; 
    85   } 
    86  
    87   if (appdata->window_incoming == 0) 
    88   { 
    89     window_incoming_init (appdata); 
    90   } 
    91  
    92   moko_dialer_status_set_person_number (appdata->status_incoming, 
    93                                         appdata->g_peer_info.number); 
    94   if (appdata->g_peer_info.hasname) 
    95   { 
    96     moko_dialer_status_set_person_image (appdata->status_incoming, 
    97                                          appdata->g_peer_info.picpath); 
    98     moko_dialer_status_set_person_name (appdata->status_incoming, 
    99                                         appdata->g_peer_info.name); 
    100   } 
    101   else 
    102   { 
    103     moko_dialer_status_set_person_image (appdata->status_incoming, 
    104                                          MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH); 
    105     moko_dialer_status_set_person_name (appdata->status_incoming, ""); 
    106  
    107   } 
    108  
    109  
    110  
    111 } 
    112  
    113 gint 
    114 window_incoming_fails (MOKO_DIALER_APP_DATA * appdata) 
    115 { 
    116   DBG_ENTER (); 
    117   DBG_LEAVE (); 
    118 } 
    119  
    120 gint 
    121 timer_incoming_time_out (MOKO_DIALER_APP_DATA * appdata) 
     48window_talking_prepare(appdata); 
     49 
     50 
     51gtk_widget_show(appdata->window_talking); 
     52 
     53DBG_LEAVE(); 
     54} 
     55 
     56void cb_ignore_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata) 
     57{ 
     58DBG_ENTER(); 
     59DBG_MESSAGE("We will mute the phone for this call."); 
     60appdata->g_state.callstate=STATE_IGNORED; 
     61DBG_LEAVE(); 
     62} 
     63 
     64void cb_reject_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata) 
     65{ 
     66DBG_ENTER(); 
     67gsm_hangup(); 
     68appdata->g_state.callstate=STATE_REJECTED; 
     69gtk_widget_hide(appdata->window_incoming); 
     70DBG_LEAVE(); 
     71} 
     72 
     73void window_incoming_prepare(MOKO_DIALER_APP_DATA * appdata) 
     74{ 
     75if(!appdata) 
     76{ 
     77DBG_WARN("appdata=NULL!"); 
     78return; 
     79} 
     80 
     81if(appdata->window_incoming==0) 
     82{ 
     83window_incoming_init(appdata); 
     84} 
     85 
     86   moko_dialer_status_set_person_number(appdata->status_incoming, appdata->g_peer_info.number); 
     87if(appdata->g_peer_info.hasname) 
     88{ 
     89 
     90   moko_dialer_status_set_person_image(appdata->status_incoming, appdata->g_peer_info.ID);   
     91   moko_dialer_status_set_person_name(appdata->status_incoming, appdata->g_peer_info.name); 
     92} 
     93else 
     94{ 
     95   moko_dialer_status_set_person_image(appdata->status_incoming, "");   
     96   moko_dialer_status_set_person_name(appdata->status_incoming, ""); 
     97 
     98} 
     99 
     100 
     101 
     102} 
     103 
     104gint window_incoming_fails(MOKO_DIALER_APP_DATA * appdata) 
     105{ 
     106DBG_ENTER(); 
     107DBG_LEAVE();      
     108} 
     109 
     110gint timer_incoming_time_out(MOKO_DIALER_APP_DATA * appdata) 
    122111{ 
    123112//DBG_ENTER(); 
    124   TIMER_DATA *timer_data = &(appdata->g_timer_data); 
     113TIMER_DATA* timer_data=&(appdata->g_timer_data); 
    125114 
    126115/*       
     
    136125moko_dialer_status_update_icon(appdata->status_incoming); 
    137126*/ 
    138   if (event_get_keep_calling ()) 
    139   { 
    140     event_reset_keep_calling (); 
    141     timer_data->ticks = 0; 
    142   } 
    143   else 
    144   {                             //we count 4 before we confirm that there are no calling at all. 
    145     if (timer_data->ticks >= 3) 
    146     { 
    147       DBG_MESSAGE ("THE CALLER aborted, we quit."); 
    148       gsm_hangup (); 
    149       appdata->g_state.callstate = STATE_MISSED; 
    150       appdata->g_state.historytype = MISSED; 
    151       gdk_threads_enter (); 
    152       gtk_widget_hide (appdata->window_incoming); 
    153       gdk_threads_leave (); 
    154       return 0;                //don't lookout the timeout. 
    155     } 
    156     else 
    157     { 
    158       DBG_MESSAGE ("ticks=%d", timer_data->ticks); 
    159       timer_data->ticks++; 
    160     } 
    161   } 
    162  
    163   return 1; 
     127if(event_get_keep_calling()) 
     128{ 
     129        event_reset_keep_calling(); 
     130        timer_data->ticks=0; 
     131} 
     132else 
     133{       //we count 4 before we confirm that there are no calling at all. 
     134        if(timer_data->ticks>=3) 
     135        { 
     136                DBG_MESSAGE("THE CALLER aborted, we quit."); 
     137                gsm_hangup(); 
     138                appdata->g_state.callstate=STATE_MISSED; 
     139                appdata->g_state.historytype=MISSED; 
     140                gdk_threads_enter(); 
     141                gtk_widget_hide(appdata->window_incoming); 
     142                gdk_threads_leave(); 
     143                return 0; //don't lookout the timeout. 
     144        } 
     145        else 
     146        { 
     147        DBG_MESSAGE("ticks=%d",timer_data->ticks); 
     148        timer_data->ticks++; 
     149        } 
     150} 
     151 
     152return 1; 
    164153 
    165154 
     
    169158 
    170159void 
    171 on_window_incoming_hide (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata) 
    172 { 
    173   if (appdata->g_timer_data.ptimer != 0) 
    174   { 
    175     gtk_timeout_remove (appdata->g_timer_data.ptimer); 
    176     appdata->g_timer_data.ptimer = 0; 
    177   } 
    178  
    179   event_reset_clip_signaled (); 
    180   event_reset_incoming_signaled (); 
    181   event_reset_keep_calling (); 
    182  
    183   if (appdata->g_state.callstate != STATE_TALKING) 
    184   {                             //     add_histroy_entry(g_state.historytype,g_state.contactinfo.name,g_state.contactinfo.number,g_state.contactinfo.picpath,g_state.starttime,0); 
    185  
    186     add_histroy_entry (appdata, appdata->g_state.historytype, 
    187                        appdata->g_peer_info.name, 
    188                        appdata->g_peer_info.number, 
    189                        appdata->g_peer_info.picpath, 
    190                        appdata->g_state.starttime, 
    191                        appdata->g_state.startdate, 0); 
    192  
    193   } 
    194  
    195 } 
    196  
    197 gint 
    198 window_incoming_setup_timer (MOKO_DIALER_APP_DATA * appdata) 
    199 { 
    200   time_t timep; 
    201   struct tm *p; 
    202   time (&timep); 
    203   p = localtime (&timep); 
    204  
    205   sprintf (appdata->g_state.starttime, "%02d:%02d:%02d", p->tm_hour, 
    206            p->tm_min, p->tm_sec); 
    207   sprintf (appdata->g_state.startdate, "%04d/%02d/%02d", p->tm_year, 
    208            p->tm_mon, p->tm_mday); 
    209  
    210   if (appdata->g_timer_data.ptimer != 0) 
    211   { 
    212     gtk_timeout_remove (appdata->g_timer_data.ptimer); 
    213     appdata->g_timer_data.ptimer = 0; 
    214   } 
    215  
    216   memset (&(appdata->g_timer_data), 0, sizeof (appdata->g_timer_data)); 
    217  
    218   appdata->g_timer_data.stopsec = 0; 
    219  
    220   appdata->g_timer_data.ptimer = 
    221     gtk_timeout_add (1000, timer_incoming_time_out, appdata); 
     160on_window_incoming_hide                 (GtkWidget       *widget, 
     161                                        MOKO_DIALER_APP_DATA * appdata) 
     162{ 
     163 
     164DBG_ENTER(); 
     165 
     166if(appdata->g_timer_data.ptimer!=0) 
     167{ 
     168gtk_timeout_remove(appdata->g_timer_data.ptimer); 
     169appdata->g_timer_data.ptimer=0; 
     170} 
     171 
     172event_reset_clip_signaled(); 
     173event_reset_incoming_signaled(); 
     174event_reset_keep_calling(); 
     175 
     176if(appdata->g_state.callstate!=STATE_TALKING) 
     177{//     add_histroy_entry(g_state.historytype,g_state.contactinfo.name,g_state.contactinfo.number,g_state.contactinfo.picpath,g_state.starttime,0); 
     178 
     179add_histroy_entry(appdata,appdata->g_state.historytype, 
     180        appdata->g_peer_info.name, 
     181        appdata->g_peer_info.number, 
     182        appdata->g_peer_info.id, 
     183        appdata->g_state.starttime, 
     184        appdata->g_state.startdate, 
     185        0); 
     186 
     187} 
     188 
     189DBG_LEAVE();      
     190} 
     191 
     192gint window_incoming_setup_timer(MOKO_DIALER_APP_DATA * appdata) 
     193{ 
     194time_t timep; 
     195struct tm *p; 
     196time(&timep); 
     197p=localtime(&timep); 
     198 
     199sprintf(appdata->g_state.starttime,"%02d:%02d:%02d",p->tm_hour,p->tm_min,p->tm_sec); 
     200sprintf(appdata->g_state.startdate,"%04d/%02d/%02d",p->tm_year,p->tm_mon,p->tm_mday); 
     201 
     202if(appdata->g_timer_data.ptimer!=0) 
     203{ 
     204gtk_timeout_remove(appdata->g_timer_data.ptimer); 
     205appdata->g_timer_data.ptimer=0; 
     206} 
     207 
     208memset(&(appdata->g_timer_data),0,sizeof(appdata->g_timer_data)); 
     209 
     210appdata->g_timer_data.stopsec=0; 
     211 
     212appdata->g_timer_data.ptimer=gtk_timeout_add(1000,timer_incoming_time_out,appdata); 
    222213 
    223214 
     
    225216 
    226217void 
    227 on_window_incoming_show (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata) 
    228 { 
    229  
    230   appdata->g_state.callstate = STATE_INCOMING; 
    231   window_incoming_setup_timer (appdata); 
    232  
    233  
    234 } 
    235  
    236  
    237 gint 
    238 window_incoming_init (MOKO_DIALER_APP_DATA * p_dialer_data) 
    239 { 
    240  
    241   DBG_ENTER (); 
    242   MokoFingerWindow *window; 
    243   GtkWidget *vbox; 
    244   MokoDialerStatus *status; 
    245  
    246   if (p_dialer_data->window_incoming == 0) 
    247   { 
    248  
    249     vbox = gtk_vbox_new (FALSE, 0); 
    250     status = moko_dialer_status_new (); 
    251     moko_dialer_status_add_status_icon (status, "status0.png"); 
    252     moko_dialer_status_add_status_icon (status, "status1.png"); 
    253     moko_dialer_status_add_status_icon (status, "status2.png"); 
    254     moko_dialer_status_set_icon_by_index (status, 0); 
    255  
    256     gtk_box_pack_start (GTK_BOX (vbox), status, FALSE, FALSE, 0); 
    257  
    258  
    259     GtkHBox *hbox2 = gtk_hbox_new (FALSE, 0); 
    260     GtkButton *button = gtk_button_new_with_label ("Answer"); 
    261     g_signal_connect (G_OBJECT (button), "clicked", 
    262                       G_CALLBACK (cb_answer_button_clicked), p_dialer_data); 
    263  
    264     gtk_box_pack_start (GTK_BOX (hbox2), GTK_WIDGET (button), TRUE, TRUE, 10); 
    265  
    266     button = gtk_button_new_with_label ("Ignore"); 
    267     g_signal_connect (G_OBJECT (button), "clicked", 
    268                       G_CALLBACK (cb_ignore_button_clicked), p_dialer_data); 
    269     gtk_box_pack_start (GTK_BOX (hbox2), GTK_WIDGET (button), TRUE, TRUE, 10); 
    270  
    271  
    272  
    273     button = gtk_button_new_with_label ("Reject"); 
    274     g_signal_connect (G_OBJECT (button), "clicked", 
    275                       G_CALLBACK (cb_reject_button_clicked), p_dialer_data); 
    276     gtk_box_pack_start (GTK_BOX (hbox2), GTK_WIDGET (button), TRUE, TRUE, 10); 
    277  
    278  
    279  
    280  
    281     gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 50); 
     218on_window_incoming_show                  (GtkWidget       *widget, 
     219                                        MOKO_DIALER_APP_DATA * appdata) 
     220{ 
     221 
     222DBG_ENTER(); 
     223appdata->g_state.callstate=STATE_INCOMING; 
     224window_incoming_setup_timer(appdata); 
     225DBG_LEAVE();      
     226 
     227} 
     228 
     229 
     230gint window_incoming_init( MOKO_DIALER_APP_DATA* p_dialer_data) 
     231{ 
     232 
     233DBG_ENTER(); 
     234MokoFingerWindow* window; 
     235GtkWidget* vbox; 
     236MokoDialerStatus * status; 
     237 
     238if(p_dialer_data->window_incoming==0) 
     239{ 
     240 
     241  vbox = gtk_vbox_new( FALSE, 0 ); 
     242   status=moko_dialer_status_new(); 
     243   moko_dialer_status_add_status_icon(status,"status0.png"); 
     244   moko_dialer_status_add_status_icon(status,"status1.png"); 
     245   moko_dialer_status_add_status_icon(status,"status2.png"); 
     246   moko_dialer_status_set_icon_by_index(status,0); 
     247    
     248   gtk_box_pack_start( GTK_BOX(vbox),status, FALSE, FALSE, 0 ); 
     249 
     250         
     251    GtkHBox *  hbox2 = gtk_hbox_new( FALSE, 0 ); 
     252    GtkButton* button = gtk_button_new_with_label("Answer"); 
     253    g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_answer_button_clicked), p_dialer_data ); 
     254 
     255    gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 10); 
     256 
     257  button = gtk_button_new_with_label("Ignore"); 
     258  g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_ignore_button_clicked), p_dialer_data ); 
     259  gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button), TRUE, TRUE, 10 ); 
     260 
     261 
     262 
     263button = gtk_button_new_with_label("Reject"); 
     264 g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_reject_button_clicked), p_dialer_data ); 
     265 gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 10); 
     266 
     267 
     268 
     269 
     270   gtk_box_pack_start( GTK_BOX(vbox),hbox2, FALSE, FALSE, 50 ); 
    282271 
    283272 
     
    286275//  moko_dialog_window_set_contents( window, GTK_WIDGET(vbox) ); 
    287276 
    288     window = MOKO_FINGER_WINDOW (moko_finger_window_new ()); 
    289     moko_finger_window_set_contents (window, GTK_WIDGET (vbox)); 
    290  
    291  
    292     gtk_widget_show_all (GTK_WIDGET (window)); 
    293  
    294  
    295     gtk_widget_hide (GTK_WIDGET (window)); 
    296  
    297  
    298     moko_dialer_status_set_title_label (status, "Incoming call"); 
    299     moko_dialer_status_set_status_label (status, ""); 
    300  
    301     p_dialer_data->window_incoming = window; 
    302     p_dialer_data->status_incoming = status; 
    303  
     277    window = MOKO_FINGER_WINDOW(moko_finger_window_new()); 
     278    moko_finger_window_set_contents(window, GTK_WIDGET(vbox) ); 
     279 
     280 
     281     gtk_widget_show_all( GTK_WIDGET(window) ); 
     282 
     283 
     284     gtk_widget_hide( GTK_WIDGET(window) );    
     285 
     286 
     287   moko_dialer_status_set_title_label(status, "Incoming call"); 
     288   moko_dialer_status_set_status_label(status, ""); 
     289 
     290   p_dialer_data->window_incoming=window; 
     291   p_dialer_data->status_incoming=status; 
     292    
    304293//   DBG_MESSAGE("p_dialer_data->status_incoming=0X%x",p_dialer_data->status_incoming); 
    305294 
    306295 
    307     g_signal_connect ((gpointer) window, "show", 
    308                       G_CALLBACK (on_window_incoming_show), p_dialer_data); 
    309     g_signal_connect ((gpointer) window, "hide", 
    310                       G_CALLBACK (on_window_incoming_hide), p_dialer_data); 
    311  
    312   } 
    313  
    314  
    315   DBG_LEAVE (); 
    316   return 1; 
    317 } 
     296  g_signal_connect ((gpointer) window, "show", 
     297                    G_CALLBACK (on_window_incoming_show), 
     298                    p_dialer_data); 
     299  g_signal_connect ((gpointer) window, "hide", 
     300                    G_CALLBACK (on_window_incoming_hide), 
     301                    p_dialer_data); 
     302 
     303} 
     304 
     305 
     306DBG_LEAVE(); 
     307    return 1; 
     308} 
     309 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-outgoing.c

    r648 r649  
    3535#include "openmoko-dialer-window-outgoing.h" 
    3636 
     37void cb_speaker_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata) 
     38{ 
     39DBG_ENTER(); 
     40//moko_dialer_status_update_icon(appdata->status_outgoing); 
     41 
     42 
     43appdata->g_state.callstate=STATE_TALKING; 
     44 
     45gtk_widget_hide(appdata->window_outgoing); 
     46 
     47 
     48//transfer the contact info 
     49window_talking_prepare(appdata); 
     50 
     51//start dialling. 
     52 
     53DBG_TRACE(); 
     54gtk_widget_show(appdata->window_talking); 
     55 
     56 
     57DBG_LEAVE(); 
     58} 
     59 
     60void cb_redial_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata) 
     61{ 
     62DBG_ENTER(); 
     63gtk_widget_hide(appdata->buttonRedial); 
     64gtk_widget_show( appdata->buttonSpeaker); 
     65moko_dialer_status_set_title_label(appdata->status_outgoing, "Outgoing call"); 
     66 moko_dialer_status_set_status_label(appdata->status_outgoing, "Calling ... (00:00:00)"); 
     67window_outgoing_setup_timer(appdata); 
     68 
     69appdata->g_state.callstate=STATE_CALLING; 
     70appdata->g_state.historytype=OUTGOING;   
     71gsm_dial(appdata->g_peer_info.number); 
     72 
     73DBG_LEAVE(); 
     74} 
     75 
     76void cb_cancel_button_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata) 
     77{ 
     78DBG_ENTER(); 
     79gsm_hangup(); 
     80appdata->g_state.callstate=STATE_FAILED; 
     81gtk_widget_hide(appdata->window_outgoing); 
     82DBG_LEAVE(); 
     83} 
     84 
     85void window_outgoing_prepare(MOKO_DIALER_APP_DATA * appdata) 
     86{ 
     87if(appdata->window_outgoing==0) 
     88        window_outgoing_init( appdata); 
     89 
     90         
     91 moko_dialer_status_set_person_number(appdata->status_outgoing, appdata->g_peer_info.number); 
     92if(appdata->g_peer_info.hasname) 
     93{ 
     94   moko_dialer_status_set_person_image(appdata->status_outgoing, appdata->g_peer_info.ID);   
     95   moko_dialer_status_set_person_name(appdata->status_outgoing, appdata->g_peer_info.name); 
     96} 
     97else 
     98{ 
     99   moko_dialer_status_set_person_image(appdata->status_outgoing, "");   
     100   moko_dialer_status_set_person_name(appdata->status_outgoing, ""); 
     101 
     102} 
     103strcpy(appdata->g_state.lastnumber,appdata->g_peer_info.number); 
     104 
     105 
     106} 
     107 
     108gint window_outgoing_fails(MOKO_DIALER_APP_DATA * appdata) 
     109{ 
     110DBG_ENTER(); 
     111     moko_dialer_status_set_error(appdata->status_outgoing); 
     112     moko_dialer_status_set_title_label(appdata->status_outgoing, "Call Failure"); 
     113     gtk_widget_hide( appdata->buttonSpeaker); 
     114     gtk_widget_show(appdata->buttonRedial); 
     115DBG_LEAVE();      
     116} 
     117 
     118gint timer_outgoing_time_out(MOKO_DIALER_APP_DATA * appdata) 
     119{ 
     120//DBG_ENTER(); 
     121TIMER_DATA* timer_data=&(appdata->g_timer_data); 
     122 
     123         
     124timer_data->ticks++; 
     125timer_data->hour=timer_data->ticks/3600; 
     126timer_data->min=(timer_data->ticks-timer_data->hour*3600)/60; 
     127timer_data->sec=timer_data->ticks%60; 
     128 
     129 
     130sprintf(timer_data->timestring,"Calling ... (%02d:%02d:%02d)",timer_data->hour,timer_data->min,timer_data->sec); 
     131 
     132//ok,we update the label now. 
     133 
     134 
     135moko_dialer_status_set_status_label(appdata->status_outgoing,timer_data->timestring); 
     136moko_dialer_status_update_icon(appdata->status_outgoing); 
     137 
     138if(timer_data->stopsec!=0&&timer_data->ticks>=timer_data->stopsec) 
     139{ 
     140 
     141timer_data->timeout=1; 
     142gtk_timeout_remove(timer_data->ptimer); 
     143timer_data->ptimer=0; 
     144//maybe it failes 
     145window_outgoing_fails(appdata); 
     146return 0;//0 stops the timer. 
     147} 
     148else 
     149return 1; 
     150} 
     151 
     152 
     153 
    37154void 
    38 cb_speaker_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata) 
    39 { 
    40   DBG_ENTER (); 
    41 //moko_dialer_status_update_icon(appdata->status_outgoing); 
    42  
    43  
    44   appdata->g_state.callstate = STATE_TALKING; 
    45  
    46   gtk_widget_hide (appdata->window_outgoing); 
    47  
    48   if (!appdata->window_talking) 
    49     window_talking_init (appdata); 
    50  
    51 //transfer the contact info 
    52   window_talking_prepare (appdata); 
    53  
    54 //start dialling. 
    55  
    56  
    57   gtk_widget_show (appdata->window_talking); 
    58  
    59  
    60   DBG_LEAVE (); 
     155on_window_outgoing_hide                 (GtkWidget       *widget, 
     156                                        MOKO_DIALER_APP_DATA * appdata) 
     157{ 
     158if(appdata->g_timer_data.ptimer!=0) 
     159{ 
     160gtk_timeout_remove(appdata->g_timer_data.ptimer); 
     161appdata->g_timer_data.ptimer=0; 
     162} 
     163if(appdata->g_state.callstate!=STATE_TALKING) 
     164{//     add_histroy_entry(g_state.historytype,g_state.contactinfo.name,g_state.contactinfo.number,g_state.contactinfo.picpath,g_state.starttime,0); 
     165 
     166add_histroy_entry(appdata,appdata->g_state.historytype, 
     167        appdata->g_peer_info.name, 
     168        appdata->g_peer_info.number, 
     169        appdata->g_peer_info.picpath, 
     170        appdata->g_state.starttime, 
     171        appdata->g_state.startdate, 
     172        0); 
     173 
     174} 
     175 
     176 
     177 
     178} 
     179 
     180gint window_outgoing_setup_timer(MOKO_DIALER_APP_DATA * appdata) 
     181{ 
     182time_t timep; 
     183struct tm *p; 
     184time(&timep); 
     185p=localtime(&timep); 
     186 
     187sprintf(appdata->g_state.starttime,"%02d:%02d:%02d",p->tm_hour,p->tm_min,p->tm_sec); 
     188sprintf(appdata->g_state.startdate,"%04d/%02d/%02d",p->tm_year,p->tm_mon,p->tm_mday); 
     189 
     190if(appdata->g_timer_data.ptimer!=0) 
     191{ 
     192gtk_timeout_remove(appdata->g_timer_data.ptimer); 
     193appdata->g_timer_data.ptimer=0; 
     194} 
     195 
     196memset(&(appdata->g_timer_data),0,sizeof(appdata->g_timer_data)); 
     197// 1:30 timeout 
     198appdata->g_timer_data.stopsec=90; 
     199 
     200appdata->g_timer_data.ptimer=gtk_timeout_add(1000,timer_outgoing_time_out,appdata); 
     201 
     202 
    61203} 
    62204 
    63205void 
    64 cb_redial_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata) 
    65 { 
    66   DBG_ENTER (); 
    67   gtk_widget_hide (appdata->buttonRedial); 
    68   gtk_widget_show (appdata->buttonSpeaker); 
    69   moko_dialer_status_set_title_label (appdata->status_outgoing, 
    70                                       "Outgoing call"); 
    71   moko_dialer_status_set_status_label (appdata->status_outgoing, 
    72                                        "Calling ... (00:00:00)"); 
    73   window_outgoing_setup_timer (appdata); 
    74  
    75   appdata->g_state.callstate = STATE_CALLING; 
    76   appdata->g_state.historytype = OUTGOING; 
    77   gsm_dial (appdata->g_peer_info.number); 
    78  
    79   DBG_LEAVE (); 
    80 } 
    81  
    82 void 
    83 cb_cancel_button_clicked (GtkButton * button, MOKO_DIALER_APP_DATA * appdata) 
    84 { 
    85   DBG_ENTER (); 
    86   gsm_hangup (); 
    87   appdata->g_state.callstate = STATE_FAILED; 
    88   gtk_widget_hide (appdata->window_outgoing); 
    89   DBG_LEAVE (); 
    90 } 
    91  
    92 void 
    93 window_outgoing_prepare (MOKO_DIALER_APP_DATA * appdata) 
    94 { 
    95   if (appdata->window_outgoing == 0) 
    96     window_outgoing_init (appdata); 
    97  
    98  
    99   moko_dialer_status_set_person_number (appdata->status_outgoing, 
    100                                         appdata->g_peer_info.number); 
    101   if (appdata->g_peer_info.hasname) 
    102   { 
    103     moko_dialer_status_set_person_image (appdata->status_outgoing, 
    104                                          appdata->g_peer_info.picpath); 
    105     moko_dialer_status_set_person_name (appdata->status_outgoing, 
    106                                         appdata->g_peer_info.name); 
    107   } 
    108   else 
    109   { 
    110     moko_dialer_status_set_person_image (appdata->status_outgoing, 
    111                                          MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH); 
    112     moko_dialer_status_set_person_name (appdata->status_outgoing, ""); 
    113  
    114   } 
    115   strcpy (appdata->g_state.lastnumber, appdata->g_peer_info.number); 
    116  
    117  
    118 } 
    119  
    120 gint 
    121 window_outgoing_fails (MOKO_DIALER_APP_DATA * appdata) 
    122 { 
    123   DBG_ENTER (); 
    124   moko_dialer_status_set_error (appdata->status_outgoing); 
    125   moko_dialer_status_set_title_label (appdata->status_outgoing, 
    126                                       "Call Failure"); 
    127   gtk_widget_hide (appdata->buttonSpeaker); 
    128   gtk_widget_show (appdata->buttonRedial); 
    129   DBG_LEAVE (); 
    130 } 
    131  
    132 gint 
    133 timer_outgoing_time_out (MOKO_DIALER_APP_DATA * appdata) 
    134 { 
    135 //DBG_ENTER(); 
    136   TIMER_DATA *timer_data = &(appdata->g_timer_data); 
    137  
    138  
    139   timer_data->ticks++; 
    140   timer_data->hour = timer_data->ticks / 3600; 
    141   timer_data->min = (timer_data->ticks - timer_data->hour * 3600) / 60; 
    142   timer_data->sec = timer_data->ticks % 60; 
    143  
    144  
    145   sprintf (timer_data->timestring, "Calling ... (%02d:%02d:%02d)", 
    146            timer_data->hour, timer_data->min, timer_data->sec); 
    147  
    148 //ok,we update the label now. 
    149  
    150  
    151   moko_dialer_status_set_status_label (appdata->status_outgoing, 
    152                                        timer_data->timestring); 
    153   moko_dialer_status_update_icon (appdata->status_outgoing); 
    154  
    155   if (timer_data->stopsec != 0 && timer_data->ticks >= timer_data->stopsec) 
    156   { 
    157  
    158     timer_data->timeout = 1; 
    159     gtk_timeout_remove (timer_data->ptimer); 
    160     timer_data->ptimer = 0; 
    161 //maybe it failes 
    162     window_outgoing_fails (appdata); 
    163     return 0;                   //0 stops the timer. 
    164   } 
    165   else 
    166     return 1; 
    167 } 
    168  
    169  
    170  
    171 void 
    172 on_window_outgoing_hide (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata) 
    173 { 
    174   if (appdata->g_timer_data.ptimer != 0) 
    175   { 
    176     gtk_timeout_remove (appdata->g_timer_data.ptimer); 
    177     appdata->g_timer_data.ptimer = 0; 
    178   } 
    179   if (appdata->g_state.callstate != STATE_TALKING) 
    180   {                             //     add_histroy_entry(g_state.historytype,g_state.contactinfo.name,g_state.contactinfo.number,g_state.contactinfo.picpath,g_state.starttime,0); 
    181  
    182     add_histroy_entry (appdata, appdata->g_state.historytype, 
    183                        appdata->g_peer_info.name, 
    184                        appdata->g_peer_info.number, 
    185                        appdata->g_peer_info.picpath, 
    186                        appdata->g_state.starttime, 
    187                        appdata->g_state.startdate, 0); 
    188  
    189   } 
    190  
    191  
    192  
    193 } 
    194  
    195 gint 
    196 window_outgoing_setup_timer (MOKO_DIALER_APP_DATA * appdata) 
    197 { 
    198   time_t timep; 
    199   struct tm *p; 
    200   time (&timep); 
    201   p = localtime (&timep); 
    202  
    203   sprintf (appdata->g_state.starttime, "%02d:%02d:%02d", p->tm_hour, 
    204            p->tm_min, p->tm_sec); 
    205   sprintf (appdata->g_state.startdate, "%04d/%02d/%02d", p->tm_year, 
    206            p->tm_mon, p->tm_mday); 
    207  
    208   if (appdata->g_timer_data.ptimer != 0) 
    209   { 
    210     gtk_timeout_remove (appdata->g_timer_data.ptimer); 
    211     appdata->g_timer_data.ptimer = 0; 
    212   } 
    213  
    214   memset (&(appdata->g_timer_data), 0, sizeof (appdata->g_timer_data)); 
    215 // 1:30 timeout 
    216   appdata->g_timer_data.stopsec = 90; 
    217  
    218   appdata->g_timer_data.ptimer = 
    219     gtk_timeout_add (1000, timer_outgoing_time_out, appdata); 
    220  
    221  
    222 } 
    223  
    224 void 
    225 on_window_outgoing_show (GtkWidget * widget, MOKO_DIALER_APP_DATA * appdata) 
    226 { 
    227  
    228  
    229   window_outgoing_setup_timer (appdata); 
    230  
    231  
    232   appdata->g_state.callstate = STATE_CALLING; 
    233   appdata->g_state.historytype = OUTGOING; 
    234   gsm_dial (appdata->g_peer_info.number); 
    235  
    236  
    237 } 
    238  
    239  
    240 gint 
    241 window_outgoing_init (MOKO_DIALER_APP_DATA * p_dialer_data) 
    242 { 
    243  
    244   DBG_ENTER (); 
    245   MokoFingerWindow *window; 
    246   GtkWidget *vbox; 
    247   MokoDialerStatus *status; 
    248  
    249   if (p_dialer_data->window_outgoing == 0) 
    250   { 
    251  
    252     vbox = gtk_vbox_new (FALSE, 0); 
    253     status = moko_dialer_status_new (); 
    254     moko_dialer_status_add_status_icon (status, "status0.png"); 
    255     moko_dialer_status_add_status_icon (status, "status1.png"); 
    256     moko_dialer_status_add_status_icon (status, "status2.png"); 
    257     moko_dialer_status_set_icon_by_index (status, 0); 
    258  
    259     gtk_box_pack_start (GTK_BOX (vbox), status, FALSE, FALSE, 0); 
    260  
    261  
    262     GtkHBox *hbox2 = gtk_hbox_new (FALSE, 0); 
    263     GtkButton *button = gtk_button_new_with_label ("Speaker"); 
    264     g_signal_connect (G_OBJECT (button), "clicked", 
    265                       G_CALLBACK (cb_speaker_button_clicked), p_dialer_data); 
    266     p_dialer_data->buttonSpeaker = button; 
     206on_window_outgoing_show                  (GtkWidget       *widget, 
     207                                        MOKO_DIALER_APP_DATA * appdata) 
     208{ 
     209 
     210 
     211window_outgoing_setup_timer(appdata); 
     212 
     213 
     214appdata->g_state.callstate=STATE_CALLING; 
     215appdata->g_state.historytype=OUTGOING;   
     216gsm_dial(appdata->g_peer_info.number); 
     217 
     218 
     219} 
     220 
     221 
     222gint window_outgoing_init( MOKO_DIALER_APP_DATA* p_dialer_data) 
     223{ 
     224 
     225DBG_ENTER(); 
     226MokoFingerWindow* window; 
     227GtkWidget* vbox; 
     228MokoDialerStatus * status; 
     229 
     230if(p_dialer_data->window_outgoing==0) 
     231{ 
     232 
     233  vbox = gtk_vbox_new( FALSE, 0 ); 
     234   status=moko_dialer_status_new(); 
     235   moko_dialer_status_add_status_icon(status,"status0.png"); 
     236   moko_dialer_status_add_status_icon(status,"status1.png"); 
     237   moko_dialer_status_add_status_icon(status,"status2.png"); 
     238   moko_dialer_status_set_icon_by_index(status,0); 
     239    
     240   gtk_box_pack_start( GTK_BOX(vbox),status, FALSE, FALSE, 0 ); 
     241 
     242         
     243    GtkHBox *  hbox2 = gtk_hbox_new( FALSE, 0 ); 
     244    GtkButton* button = gtk_button_new_with_label("Speaker"); 
     245    g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_speaker_button_clicked), p_dialer_data ); 
     246p_dialer_data->buttonSpeaker=button; 
    267247//gtk_widget_set_size_request(button,100,32); 
    268     gtk_box_pack_start (GTK_BOX (hbox2), GTK_WIDGET (button), TRUE, TRUE, 40); 
    269  
    270     button = gtk_button_new_with_label ("Redial"); 
    271     p_dialer_data->buttonRedial = button; 
    272     g_signal_connect (G_OBJECT (button), "clicked", 
    273                       G_CALLBACK (cb_redial_button_clicked), p_dialer_data); 
     248    gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 40 ); 
     249 
     250  button = gtk_button_new_with_label("Redial"); 
     251    p_dialer_data->buttonRedial=button; 
     252  g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_redial_button_clicked), p_dialer_data ); 
    274253//gtk_widget_set_size_request(button,100,32); 
    275     gtk_box_pack_start (GTK_BOX (hbox2), GTK_WIDGET (button), TRUE, TRUE, 40); 
     254  gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button), TRUE, TRUE, 40 ); 
    276255//gtk_widget_set_size_request(button,60,24); 
    277256 
    278257 
    279     button = gtk_button_new_with_label ("Cancel"); 
    280     p_dialer_data->buttonCancel = button; 
    281     g_signal_connect (G_OBJECT (button), "clicked", 
    282                       G_CALLBACK (cb_cancel_button_clicked), p_dialer_data); 
     258button = gtk_button_new_with_label("Cancel"); 
     259  p_dialer_data->buttonCancel=button; 
     260 g_signal_connect( G_OBJECT(button), "clicked", G_CALLBACK(cb_cancel_button_clicked), p_dialer_data ); 
    283261//gtk_widget_set_size_request(button,100,32); 
    284     gtk_box_pack_start (GTK_BOX (hbox2), GTK_WIDGET (button), TRUE, TRUE, 40); 
    285  
    286  
    287  
    288  
    289     gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 50); 
     262 gtk_box_pack_start( GTK_BOX(hbox2), GTK_WIDGET(button),TRUE, TRUE, 40); 
     263 
     264 
     265 
     266 
     267   gtk_box_pack_start( GTK_BOX(vbox),hbox2, FALSE, FALSE, 50 ); 
    290268 
    291269 
     
    294272//  moko_dialog_window_set_contents( window, GTK_WIDGET(vbox) ); 
    295273 
    296     window = MOKO_FINGER_WINDOW (moko_finger_window_new ()); 
    297     moko_finger_window_set_contents (window, GTK_WIDGET (vbox)); 
    298  
    299  
    300     gtk_widget_show_all (GTK_WIDGET (window)); 
    301  
    302     gtk_widget_hide (p_dialer_data->buttonRedial); 
    303  
    304  
    305     gtk_widget_hide (GTK_WIDGET (window)); 
    306  
    307  
    308     moko_dialer_status_set_title_label (status, "Outgoing call"); 
    309     moko_dialer_status_set_status_label (status, "Calling ... (00:00:00)"); 
    310  
    311     p_dialer_data->window_outgoing = window; 
    312     p_dialer_data->status_outgoing = status; 
    313  
     274    window = MOKO_FINGER_WINDOW(moko_finger_window_new()); 
     275    moko_finger_window_set_contents(window, GTK_WIDGET(vbox) ); 
     276 
     277 
     278     gtk_widget_show_all( GTK_WIDGET(window) ); 
     279 
     280     gtk_widget_hide( p_dialer_data->buttonRedial); 
     281 
     282 
     283     gtk_widget_hide( GTK_WIDGET(window) );    
     284 
     285 
     286   moko_dialer_status_set_title_label(status, "Outgoing call"); 
     287   moko_dialer_status_set_status_label(status, "Calling ... (00:00:00)"); 
     288 
     289   p_dialer_data->window_outgoing=window; 
     290   p_dialer_data->status_outgoing=status; 
     291    
    314292//   DBG_MESSAGE("p_dialer_data->status_outgoing=0X%x",p_dialer_data->status_outgoing); 
    315293 
    316294 
    317     g_signal_connect ((gpointer) window, "show", 
    318                       G_CALLBACK (on_window_outgoing_show), p_dialer_data); 
    319     g_signal_connect ((gpointer) window, "hide", 
    320                       G_CALLBACK (on_window_outgoing_hide), p_dialer_data); 
    321  
    322   } 
     295  g_signal_connect ((gpointer) window, "show", 
     296                    G_CALLBACK (on_window_outgoing_show), 
     297                    p_dialer_data); 
     298  g_signal_connect ((gpointer) window, "hide", 
     299                    G_CALLBACK (on_window_outgoing_hide), 
     300                    p_dialer_data); 
     301 
     302} 
    323303 
    324304 
     
    326306// gtk_widget_show(p_dialer_data->window_outgoing); 
    327307 
    328   DBG_LEAVE (); 
    329   return 1; 
    330 } 
     308DBG_LEAVE(); 
     309    return 1; 
     310} 
     311 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/openmoko-dialer-window-talking.c

    r648 r649  
    3636 
    3737void 
    38 openmoko_wheel_press_left_up_cb (GtkWidget * widget, 
    39                                  MOKO_DIALER_APP_DATA * appdata) 
    40 { 
    41   DBG_ENTER (); 
    42   gint l, r; 
    43   alsa_get_volume (&l, &r); 
    44   alsa_set_volume (l + 10, r + 10); 
    45  
    46   alsa_get_volume (&l, &r); 
    47   g_print ("l = %d, r = %d\n", l, r); 
     38openmoko_wheel_press_left_up_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata) 
     39{ 
     40DBG_ENTER(); 
     41 gint l , r; 
     42 alsa_get_volume(&l, &r); 
     43alsa_set_volume(l+10, r+10); 
     44 
     45 alsa_get_volume(&l, &r); 
     46 g_print("l = %d, r = %d\n", l, r); 
    4847 
    4948/* 
     
    5150    r = 90; 
    5251 
    53 */ 
    54  
    55 } 
    56  
    57 void 
    58 openmoko_wheel_press_right_down_cb (GtkWidget * widget, 
    59                                     MOKO_DIALER_APP_DATA * appdata) 
    60 { 
    61   gint l, r; 
    62   alsa_get_volume (&l, &r); 
    63   alsa_set_volume (l - 10, r - 10); 
    64   alsa_get_volume (&l, &r); 
    65   g_print ("l = %d, r = %d\n", l, r); 
    66  
    67   DBG_ENTER (); 
    68 } 
    69  
    70  
    71 void 
    72 cb_tool_button_speaker_clicked (GtkButton * button, 
    73                                 MOKO_DIALER_APP_DATA * appdata) 
    74 { 
    75   DBG_ENTER (); 
    76 } 
    77  
    78 void 
    79 cb_tool_button_dtmf_talk_clicked (GtkButton * button, 
    80                                   MOKO_DIALER_APP_DATA * appdata) 
    81 { 
    82   DBG_ENTER (); 
    83  
    84   appdata->dtmf_in_talking_window = !appdata->dtmf_in_talking_window; 
    85   if (appdata->dtmf_in_talking_window) 
    86   { 
    87  
    88  
    89     moko_pixmap_button_set_finger_toolbox_btn_center_image (button, 
    90                                                             appdata-> 
    91                                                             imageTALK); 
    92     gtk_widget_hide (appdata->content_talk); 
    93     gtk_widget_show (appdata->content_dtmf); 
    94   } 
    95   else 
    96   { 
    97     moko_pixmap_button_set_finger_toolbox_btn_center_image (button, 
    98                                                             appdata-> 
    99                                                             imageDTMF); 
    100     gtk_widget_hide (appdata->content_dtmf); 
    101     gtk_widget_show (appdata->content_talk); 
    102  
    103  
    104   } 
    105  
    106  
    107 } 
    108  
    109 void 
    110 cb_tool_button_hangup_clicked (GtkButton * button, 
    111                                MOKO_DIALER_APP_DATA * appdata) 
    112 { 
    113   gsm_hangup (); 
    114   gtk_widget_hide (appdata->window_talking); 
    115  
    116 } 
    117  
    118  
    119 void 
    120 on_dtmf_panel_user_input (GtkWidget * widget, gchar parac, gpointer user_data) 
    121 { 
    122   char input[2]; 
    123   input[0] = parac; 
    124   input[1] = 0; 
    125   char codesinput[MOKO_DIALER_MAX_NUMBER_LEN + 1]; 
    126  
    127  
    128   MOKO_DIALER_APP_DATA *appdata = (MOKO_DIALER_APP_DATA *) user_data; 
    129   MokoDialerTextview *moko_dtmf_text_view = appdata->moko_dtmf_text_view; 
    130  
    131   moko_dialer_textview_insert (moko_dtmf_text_view, input); 
    132  
    133  
    134   gsm_dtmf_send (input[0]); 
     52*/     
     53 
     54} 
     55 
     56void 
     57openmoko_wheel_press_right_down_cb(GtkWidget *widget, MOKO_DIALER_APP_DATA * appdata) 
     58{ 
     59 gint l , r; 
     60  alsa_get_volume(&l, &r); 
     61alsa_set_volume(l-10, r-10); 
     62 alsa_get_volume(&l, &r); 
     63 g_print("l = %d, r = %d\n", l, r); 
     64 
     65DBG_ENTER(); 
     66} 
     67 
     68 
     69void cb_tool_button_speaker_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata) 
     70{ 
     71  DBG_ENTER(); 
     72} 
     73 
     74void cb_tool_button_dtmf_talk_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata) 
     75{ 
     76        DBG_ENTER(); 
     77         
     78        appdata->dtmf_in_talking_window=!appdata->dtmf_in_talking_window; 
     79        if(appdata->dtmf_in_talking_window) 
     80                { 
     81                 
     82                         
     83                        moko_pixmap_button_set_finger_toolbox_btn_center_image(button, appdata->imageTALK); 
     84                       gtk_widget_hide(appdata->content_talk); 
     85                        gtk_widget_show(appdata->content_dtmf); 
     86                } 
     87        else 
     88                { 
     89                        moko_pixmap_button_set_finger_toolbox_btn_center_image(button, appdata->imageDTMF); 
     90                        gtk_widget_hide(appdata->content_dtmf); 
     91                       gtk_widget_show(appdata->content_talk); 
     92                        
     93 
     94                } 
     95 
     96   
     97} 
     98 
     99void cb_tool_button_hangup_clicked( GtkButton* button, MOKO_DIALER_APP_DATA * appdata) 
     100{ 
     101     gsm_hangup(); 
     102     gtk_widget_hide(appdata->window_talking); 
     103 
     104} 
     105 
     106 
     107void 
     108on_dtmf_panel_user_input(GtkWidget * widget,gchar parac, 
     109                                        gpointer         user_data) 
     110{ 
     111char input[2]; 
     112input[0]=parac; 
     113input[1]=0; 
     114char codesinput[MOKO_DIALER_MAX_NUMBER_LEN+1]; 
     115 
     116 
     117MOKO_DIALER_APP_DATA * appdata=(MOKO_DIALER_APP_DATA*)user_data; 
     118MokoDialerTextview *moko_dtmf_text_view=appdata->moko_dtmf_text_view; 
     119 
     120moko_dialer_textview_insert(moko_dtmf_text_view, input); 
     121 
     122 
     123gsm_dtmf_send(input[0]); 
    135124//lgsm_voice_dtmf(lgsmh, buf[1]); 
    136125 
     
    139128 
    140129 
    141 void 
    142 window_talking_prepare (MOKO_DIALER_APP_DATA * appdata) 
    143 { 
    144   DBG_ENTER (); 
    145   moko_dialer_status_set_person_number (appdata->status_talking, 
    146                                         appdata->g_peer_info.number); 
    147   if (appdata->g_peer_info.hasname) 
    148   { 
    149     moko_dialer_status_set_person_image (appdata->status_talking, 
    150                                          appdata->g_peer_info.picpath); 
    151     moko_dialer_status_set_person_name (appdata->status_talking, 
    152                                         appdata->g_peer_info.name); 
    153   } 
    154   else 
    155   { 
    156     moko_dialer_status_set_person_image (appdata->status_talking, 
    157                                          MOKO_DIALER_DEFAULT_PERSON_IMAGE_PATH); 
    158     moko_dialer_status_set_person_name (appdata->status_talking, ""); 
    159  
    160   } 
    161  
    162   DBG_LEAVE (); 
    163  
    164 } 
    165  
    166 gint 
    167 timer_talking_time_out (MOKO_DIALER_APP_DATA * appdata) 
     130void window_talking_prepare(MOKO_DIALER_APP_DATA * appdata) 
     131{ 
     132DBG_ENTER(); 
     133//   moko_dialer_status_set_person_number(appdata->status_talking, appdata->g_peer_info.number); 
     134 
     135if(!appdata->window_talking) 
     136        window_talking_init(appdata); 
     137 
     138if(!appdata->window_talking) 
     139        return; 
     140         
     141if(appdata->g_peer_info.hasname) 
     142{ 
     143DBG_TRACE(); 
     144   moko_dialer_status_set_person_image(appdata->status_talking, appdata->g_peer_info.ID);   
     145DBG_TRACE(); 
     146   moko_dialer_status_set_person_name(appdata->status_talking, appdata->g_peer_info.name); 
     147   DBG_TRACE(); 
     148} 
     149else 
     150{ 
     151   moko_dialer_status_set_person_image(appdata->status_talking, "");   
     152   moko_dialer_status_set_person_name(appdata->status_talking, ""); 
     153 
     154} 
     155 
     156DBG_LEAVE(); 
     157 
     158} 
     159 
     160gint timer_talking_time_out(MOKO_DIALER_APP_DATA * appdata) 
    168161{ 
    169162//DBG_ENTER(); 
    170   TIMER_DATA *timer_data = &(appdata->g_timer_data); 
    171  
    172  
    173   timer_data->ticks++; 
    174   timer_data->hour = timer_data->ticks / 3600; 
    175   timer_data->min = (timer_data->ticks - timer_data->hour * 3600) / 60; 
    176   timer_data->sec = timer_data->ticks % 60; 
    177  
    178  
    179   sprintf (timer_data->timestring, "Talking (%02d:%02d:%02d)", 
    180            timer_data->hour, timer_data->min, timer_data->sec); 
     163TIMER_DATA* timer_data=&(appdata->g_timer_data); 
     164 
     165         
     166timer_data->ticks++; 
     167timer_data->hour=timer_data->ticks/3600; 
     168timer_data->min=(timer_data->ticks-timer_data->hour*3600)/60; 
     169timer_data->sec=timer_data->ticks%60; 
     170 
     171 
     172sprintf(timer_data->timestring,"Talking (%02d:%02d:%02d)",timer_data->hour,timer_data->min,timer_data->sec); 
    181173 
    182174//ok,we update the label now. 
    183175 
    184176 
    185   moko_dialer_status_set_status_label (appdata->status_talking, 
    186                                        timer_data->timestring); 
    187   moko_dialer_status_update_icon (appdata->status_talking); 
    188  
    189   if (timer_data->stopsec != 0 && timer_data->ticks >= timer_data->stopsec) 
    190   { 
    191  
    192     timer_data->timeout = 1; 
    193     gtk_timeout_remove (timer_data->ptimer); 
    194     timer_data->ptimer = 0; 
    195     return 0;                   //0 stops the timer. 
    196   } 
    197   else 
     177moko_dialer_status_set_status_label(appdata->status_talking,timer_data->timestring); 
     178moko_dialer_status_update_icon(appdata->status_talking); 
     179 
     180if(timer_data->stopsec!=0&&timer_data->ticks>=timer_data->stopsec) 
     181{ 
     182 
     183timer_data->timeout=1; 
     184gtk_timeout_remove(timer_data->ptimer); 
     185timer_data->ptimer=0; 
     186return 0;//0 stops the timer. 
     187} 
     188else 
     189return 1; 
     190} 
     191 
     192void 
     193on_window_talking_hide                 (GtkWidget       *widget, 
     194                                        MOKO_DIALER_APP_DATA * appdata) 
     195{ 
     196if(appdata->g_timer_data.ptimer!=0) 
     197{ 
     198gtk_timeout_remove(appdata->g_timer_data.ptimer); 
     199appdata->g_timer_data.ptimer=0; 
     200} 
     201 
     202gtk_widget_hide(appdata->wheel_talking); 
     203gtk_widget_hide(appdata->toolbox_talking); 
     204 
     205//DBG_MESSAGE("%s, %s",appdata->g_state.starttime,appdata->g_state.startdate); 
     206add_histroy_entry(appdata,appdata->g_state.historytype, 
     207        appdata->g_peer_info.name, 
     208        appdata->g_peer_info.number, 
     209        appdata->g_peer_info.picpath, 
     210        appdata->g_state.starttime, 
     211        appdata->g_state.startdate, 
     212        appdata->g_timer_data.ticks); 
     213 
     214 
     215} 
     216 
     217void 
     218on_window_talking_show                  (GtkWidget       *widget, 
     219                                        MOKO_DIALER_APP_DATA * appdata) 
     220{ 
     221DBG_ENTER(); 
     222 
     223appdata->dtmf_in_talking_window=TRUE; 
     224        //hide the talking button in talking mode. 
     225 
     226time_t timep; 
     227struct tm *p; 
     228time(&timep); 
     229p=localtime(&timep); 
     230 
     231sprintf(appdata->g_state.starttime,"%02d:%02d:%02d",p->tm_hour,p->tm_min,p->tm_sec); 
     232sprintf(appdata->g_state.startdate,"%04d/%02d/%02d",p->tm_year+1900,p->tm_mon,p->tm_mday); 
     233 
     234memset(&(appdata->g_timer_data),0,sizeof(appdata->g_timer_data)); 
     235 
     236appdata->g_timer_data.stopsec=0; 
     237 
     238appdata->g_timer_data.ptimer=gtk_timeout_add(1000,timer_talking_time_out,appdata); 
     239 
     240if(appdata->wheel_talking) 
     241gtk_widget_show(appdata->wheel_talking); 
     242 
     243if(appdata->toolbox_talking) 
     244gtk_widget_show(appdata->toolbox_talking); 
     245 
     246 
     247    
     248DBG_LEAVE(); 
     249} 
     250 
     251 
     252 
     253 
     254gint window_talking_init( MOKO_DIALER_APP_DATA* p_dialer_data) 
     255{ 
     256 
     257DBG_ENTER(); 
     258 
     259 
     260if(p_dialer_data->window_talking==0) 
     261{ 
     262 
     263        MokoFingerWindow* window=NULL; 
     264        GtkWidget* vbox=gtk_vbox_new( FALSE, 0 );; 
     265        MokoDialerStatus * status=NULL; 
     266        GtkWidget* content_talk= NULL; 
     267        GtkWidget* content_dtmf= NULL; 
     268      MokoFingerToolBox *tools = NULL; 
     269      MokoDialerPanel* mokodialerpanel=NULL; 
     270      GtkWidget *button; 
     271      GtkWidget* image; 
     272 
     273 
     274//first, the talking content. 
     275 
     276   content_talk = gtk_vbox_new( FALSE, 0 ); 
     277   status=moko_dialer_status_new(); 
     278   moko_dialer_status_add_status_icon(status,"status0.png"); 
     279   moko_dialer_status_add_status_icon(status,"status1.png"); 
     280   moko_dialer_status_add_status_icon(status,"status2.png"); 
     281   moko_dialer_status_set_icon_by_index(status,0); 
     282    
     283    
     284   moko_dialer_status_set_title_label(status, "In Call"); 
     285   moko_dialer_status_set_status_label(status, "Talking ...(00:00:00)"); 
     286 
     287   gtk_box_pack_start( GTK_BOX(content_talk),status, FALSE, FALSE, 0 ); 
     288 
     289 
     290   p_dialer_data->status_talking=status; 
     291   p_dialer_data->content_talk= content_talk; 
     292 
     293   gtk_box_pack_start( GTK_BOX(vbox),content_talk, FALSE, FALSE, 0 ); 
     294    
     295   
     296//now the dtmf content 
     297        content_dtmf= gtk_vbox_new( FALSE, 0 ); 
     298        GtkEventBox* eventbox1 = gtk_event_box_new (); 
     299        gtk_widget_show (eventbox1); 
     300 
     301        gtk_widget_set_name(GTK_WIDGET(eventbox1),"gtkeventbox-black"); 
     302 
     303        MokoDialerTextview * mokotextview=moko_dialer_textview_new(); 
     304 
     305        gtk_container_add (GTK_CONTAINER (eventbox1), mokotextview); 
     306 
     307        p_dialer_data->moko_dtmf_text_view=mokotextview; 
     308     
     309        gtk_box_pack_start( GTK_BOX(content_dtmf), GTK_WIDGET(eventbox1), FALSE,FALSE, 2 ); 
     310 
     311 
     312 
     313         mokodialerpanel=moko_dialer_panel_new(); 
     314 
     315        gtk_widget_set_size_request (mokodialerpanel, 380, 384); 
     316        g_signal_connect (GTK_OBJECT (mokodialerpanel), "user_input",  G_CALLBACK (on_dtmf_panel_user_input),p_dialer_data); 
     317        gtk_box_pack_start( GTK_BOX(content_dtmf), GTK_WIDGET(mokodialerpanel), TRUE, TRUE, 5 ); 
     318   
     319        gtk_box_pack_start( GTK_BOX(vbox),content_dtmf, FALSE, FALSE, 0 ); 
     320        p_dialer_data->content_dtmf=content_dtmf; 
     321 
     322 
     323//now the container--window 
     324     window = MOKO_FINGER_WINDOW(moko_finger_window_new()); 
     325     p_dialer_data->window_talking=window; 
     326     moko_finger_window_set_contents(window, GTK_WIDGET(vbox) ); 
     327    g_signal_connect ((gpointer) window, "show", 
     328                            G_CALLBACK (on_window_talking_show), 
     329                            p_dialer_data); 
     330    g_signal_connect ((gpointer) window, "hide", 
     331                            G_CALLBACK (on_window_talking_hide), 
     332                            p_dialer_data); 
     333 
     334      
     335     gtk_widget_show_all( GTK_WIDGET(window) ); 
     336 
     337//the gtk_widget_show_all is really bad, cause i have to call it and then hide some widgets. 
     338 
     339   gtk_widget_hide(content_dtmf); 
     340 
     341 
     342 //now the wheel and tool box, why should the wheel and toolbox created after the gtk_widget_show_all??? 
     343   gtk_widget_show(GTK_WIDGET(moko_finger_window_get_wheel(window))); 
     344     
     345    g_signal_connect(G_OBJECT(moko_finger_window_get_wheel(window)), 
     346                    "press_left_up", 
     347                    G_CALLBACK(openmoko_wheel_press_left_up_cb), 
     348                    p_dialer_data); 
     349    g_signal_connect(G_OBJECT(moko_finger_window_get_wheel(window)), 
     350                    "press_right_down", 
     351                    G_CALLBACK(openmoko_wheel_press_right_down_cb), 
     352                    p_dialer_data); 
     353 
     354 
     355 
     356        tools = moko_finger_window_get_toolbox(window); 
     357      
     358        button = moko_finger_tool_box_add_button_without_label(tools); 
     359       image = file_new_image_from_relative_path("speaker.png"); 
     360        moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image); 
     361        g_signal_connect(G_OBJECT(button), "clicked", 
     362                        G_CALLBACK(cb_tool_button_speaker_clicked), p_dialer_data); 
     363         
     364        button = moko_finger_tool_box_add_button_without_label(tools); 
     365       image = file_new_image_from_relative_path("dtmf.png"); 
     366        moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image); 
     367        g_signal_connect(G_OBJECT(button), "clicked", 
     368                        G_CALLBACK(cb_tool_button_dtmf_talk_clicked), p_dialer_data); 
     369        p_dialer_data->imageDTMF=image; 
     370        p_dialer_data->imageTALK=file_new_image_from_relative_path("talking.png"); 
     371         
     372 
     373        button = moko_finger_tool_box_add_button_without_label(tools); 
     374       image = file_new_image_from_relative_path("tony.png"); 
     375        moko_pixmap_button_set_finger_toolbox_btn_center_image(button, image); 
     376        g_signal_connect(G_OBJECT(button), "clicked", 
     377                        G_CALLBACK(cb_tool_button_hangup_clicked), p_dialer_data); 
     378        gtk_widget_show(GTK_WIDGET(tools)); 
     379