Changeset 1880


Ignore:
Timestamp:
04/30/07 18:20:27 (6 years ago)
Author:
thomas
Message:

openmoko-dialer: Use MokoJournal? to retrieve call history

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

Legend:

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

    r1857 r1880  
    181181 
    182182  /* application object */ 
    183 //    MokoApplication* app = MOKO_APPLICATION(moko_application_get_instance()); 
    184183  g_set_application_name ("OpenMoko Dialer"); 
    185184 
     
    189188  g_signal_connect (G_OBJECT (conn), "incoming-call", (GCallback) incoming_call_cb, NULL); 
    190189  g_signal_connect (G_OBJECT (conn), "incoming-clip", (GCallback) incoming_clip_cb, NULL); 
     190 
     191  /* Set up journal handling */ 
     192  p_dialer_data->journal = moko_journal_open_default (); 
    191193 
    192194  signal (SIGUSR1, handle_sigusr1); 
     
    207209 
    208210 
    209 //release everything     
     211  //release everything 
    210212  contact_release_contact_list (&(p_dialer_data->g_contactlist)); 
    211213 
     214  /* closes the journal and frees allocated memory */ 
     215  moko_journal_close (p_dialer_data->journal); 
     216 
    212217  return 0; 
    213218} 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.h

    r1857 r1880  
    1818#include "moko-dialer-includes.h" 
    1919#include <libmokogsmd/moko-gsmd-connection.h> 
    20 /* 
     20#include <libmokojournal/moko-journal.h> 
    2121 
    22 typedef struct _window_outgoing 
    23 { 
    24  
    25 MokoDialerStatus * status_outgoing; 
    26  
    27 GtkWidget* window_outgoing; 
    28  
    29 GtkWidget* buttonSpeaker; 
    30 GtkWidget* buttonCancel; 
    31 GtkWidget* buttonRedial; 
    32 }WindowOutgoing; 
    33 */ 
    3422typedef struct _dialer_data 
    3523{ 
    3624  //the global data area begins here 
     25 
    3726  MokoGsmdConnection *connection; 
     27  MokoJournal *journal; 
     28 
     29  GtkListStore *history; 
    3830 
    3931  char str_sim_pin[MOKO_DIALER_MAX_PIN_LEN + 1]; 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.c

    r1857 r1880  
    425425  GtkTreeModel *model; 
    426426  GtkTreeSelection *selection; 
    427   /*HISTORY_ENTRY*/void *p; 
    428   int hasname; 
     427  //HISTORY_ENTRY void *p; 
     428  //int hasname; 
    429429  MokoDialerData *p_dialer_data = (MokoDialerData *) user_data; 
    430430 
     
    439439  } 
    440440 
    441   gtk_tree_model_get (model, &iter, COLUMN_ENTRYPOINTER, &p, -1); 
     441  /*gtk_tree_model_get (model, &iter, COLUMN_ENTRYPOINTER, &p, -1); 
    442442 
    443443  //p_dialer_data->g_currentselected = p; 
     
    445445  gtk_tree_model_get (model, &iter, COLUMN_HASNAME, &hasname, -1); 
    446446  history_update_counter (p_dialer_data); 
     447  */ 
    447448 
    448449} 
     
    588589  GtkListStore *list_store; 
    589590 
    590 //  GtkTreeIter iter; 
    591 //  HISTORY_ENTRY *entry; 
    592  
    593   //copied 
    594591  GtkTreeViewColumn *col; 
    595592  GtkCellRenderer *renderer; 
    596593 
    597   //GtkTreeModel        *model; 
    598594  GtkWidget *contactview = NULL; 
    599595 
     
    606602  if (contactview == NULL) 
    607603    return 0; 
    608 //pack image and label 
     604 
     605  /* Create column with icon and text */ 
    609606  col = gtk_tree_view_column_new (); 
    610  
    611   gtk_tree_view_column_set_title (col, ("Title")); 
    612   gtk_tree_view_column_set_resizable (col, TRUE); 
    613  
    614  
    615607 
    616608  renderer = gtk_cell_renderer_pixbuf_new (); 
    617609  gtk_tree_view_column_pack_start (col, renderer, FALSE); 
    618610  gtk_tree_view_column_set_attributes (col, renderer, 
    619                                        "pixbuf", COLUMN_TYPEICON, NULL); 
    620  
    621   renderer = gtk_cell_renderer_text_new (); 
    622   gtk_tree_view_column_pack_start (col, renderer, FALSE); 
    623   gtk_tree_view_column_set_attributes (col, renderer, 
    624                                        "text", COLUMN_TIME, NULL); 
    625  
    626   renderer = gtk_cell_renderer_text_new (); 
    627   gtk_tree_view_column_pack_start (col, renderer, FALSE); 
    628   gtk_tree_view_column_set_attributes (col, renderer, 
    629                                        "text", COLUMN_SEPRATE, NULL); 
     611                                       "icon-name", HISTORY_ICON_NAME_COLUMN, NULL); 
    630612 
    631613  renderer = gtk_cell_renderer_text_new (); 
    632614  gtk_tree_view_column_pack_start (col, renderer, TRUE); 
    633615  gtk_tree_view_column_set_attributes (col, renderer, 
    634                                        "text", COLUMN_NAME_NUMBER, NULL); 
    635  
     616                                       "text", HISTORY_DISPLAY_TEXT_COLUMN, NULL); 
    636617 
    637618  gtk_tree_view_append_column (GTK_TREE_VIEW (contactview), col); 
    638619 
    639620 
    640   //entry = p_dialer_data->g_historylist.first; 
    641  
    642   list_store = gtk_list_store_new (N_COLUMN, G_TYPE_INT, GDK_TYPE_PIXBUF, 
    643                                    G_TYPE_STRING, G_TYPE_STRING, 
    644                                    G_TYPE_STRING, G_TYPE_INT, G_TYPE_POINTER, 
    645                                    G_TYPE_INT, -1); 
    646   //we will use a filter to facilitate the filtering in treeview without rebuilding the database.                          
     621  /* Set up a list store for the history items */ 
     622  /* UID, DSTART, MISSED, DIRECTION */ 
     623  list_store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_INT); 
     624 
     625 
     626  //we will use a filter to facilitate the filtering in treeview without rebuilding the database. 
    647627  p_dialer_data->g_list_store_filter = 
    648628    gtk_tree_model_filter_new (GTK_TREE_MODEL (list_store), NULL); 
     
    654634 
    655635  //load the three icons to memory. 
    656  
    657   // GError *error = NULL; 
    658   p_dialer_data->g_iconReceived = create_pixbuf ("received.png"); 
    659  
    660   /* FIXME: error handling hasn't been implemented yet! 
    661      p_dialer_data->g_iconReceived = create_pixbuf ("received.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_iconReceived = NULL; 
    667      error = NULL; 
    668      } 
    669    */ 
    670  
    671   p_dialer_data->g_iconDialed = create_pixbuf ("dialed.png"); 
    672   /* FIXME: error handling hasn't been implemented yet! 
    673      p_dialer_data->g_iconDialed = create_pixbuf ("dialed.png", &error); 
    674      if (error) 
    675      { 
    676      DBG_WARN ("Cound not load icon :%s", error->message); 
    677      g_error_free (error); 
    678      p_dialer_data->g_iconDialed = NULL; 
    679      error = NULL; 
    680      } 
    681    */ 
    682  
    683   p_dialer_data->g_iconMissed = create_pixbuf ("missed.png"); 
    684   /* FIXME: error handling hasn't been implemented yet! 
    685      p_dialer_data->g_iconMissed = create_pixbuf ("missed.png", &error); 
    686      if (error) 
    687      { 
    688      DBG_WARN ("Cound not load icon :%s", error->message); 
    689      g_error_free (error); 
    690      p_dialer_data->g_iconMissed = NULL; 
    691      error = NULL; 
    692      } 
    693    */ 
    694 #if 0 
    695   while (entry) 
    696   { 
    697     //DBG_MESSAGE(entry->number); 
    698     gtk_list_store_append (list_store, &iter); 
    699     gtk_list_store_set (list_store, &iter, COLUMN_TYPE, entry->type, 
    700                         COLUMN_SEPRATE, "--", COLUMN_TIME, entry->time, 
    701                         COLUMN_DURATION, entry->durationsec, 
    702                         COLUMN_ENTRYPOINTER, entry, COLUMN_HASNAME, 0, -1); 
    703     if (entry->name == 0) 
    704     { 
    705       //DBG_MESSAGE(entry->number); 
    706       gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER, 
    707                           entry->number, -1); 
    708       gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 0, -1); 
    709     } 
    710     else 
    711     { 
    712       gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER, 
    713                           entry->name, -1); 
    714       gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 1, -1); 
    715     } 
    716     switch (entry->type) 
    717     { 
    718     case INCOMING: 
    719       { 
    720         gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON, 
    721                             p_dialer_data->g_iconReceived, -1); 
    722         //      icon=gdk_pixbuf_new_from_file("./received.png",&error); 
    723         break; 
    724       } 
    725     case OUTGOING: 
    726       {                         //     icon=gdk_pixbuf_new_from_file("./dialed.png",&error); 
    727         gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON, 
    728                             p_dialer_data->g_iconDialed, -1); 
    729         break; 
    730       } 
    731     case MISSED: 
    732       {                         //icon=gdk_pixbuf_new_from_file("./missed.png",&error); 
    733         gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON, 
    734                             p_dialer_data->g_iconMissed, -1); 
    735         break; 
    736       } 
    737  
    738     default: 
    739  
    740       {                         //icon=gdk_pixbuf_new_from_file("./missed.png",&error); 
    741         gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON, 
    742                             p_dialer_data->g_iconMissed, -1); 
    743         break; 
    744       } 
    745     } 
    746  
    747  
    748  
    749     entry = entry->next; 
    750   } 
    751 #endif 
    752636  gtk_tree_view_set_model (GTK_TREE_VIEW (contactview), 
    753637                           GTK_TREE_MODEL (p_dialer_data-> 
    754638                                           g_list_store_filter)); 
    755639 
    756   g_object_unref (list_store); 
     640 
     641  /* add the initial contents of the list store */ 
     642  int i = 0; 
     643  MokoJournalEntry *j_entry; 
     644 
     645  /* if there aren't any entries in the journal, we don't need to do any more 
     646   * here 
     647   */ 
     648  if (moko_journal_get_nb_entries (p_dialer_data->journal)) 
     649    return 1; 
     650 
     651  j_entry = moko_journal_entry_new (VOICE_JOURNAL_ENTRY); 
     652 
     653  while (moko_journal_get_entry_at (p_dialer_data->journal, i, &j_entry)) 
     654  { 
     655    const gchar *uid, *number; 
     656    gchar *icon_name, *display_text; 
     657    int dstart; 
     658    enum MessageDirection direction; 
     659    gboolean was_missed; 
     660    const MokoTime *time; 
     661 
     662    uid = moko_journal_entry_get_contact_uid (j_entry); 
     663    moko_journal_entry_get_direction (j_entry, &direction); 
     664    time = moko_journal_entry_get_dtstart (j_entry); 
     665    was_missed = moko_journal_voice_info_get_was_missed ((MokoJournalVoiceInfo*) j_entry); 
     666    number = moko_journal_voice_info_get_distant_number ((MokoJournalVoiceInfo*)j_entry); 
     667 
     668    if (direction == DIRECTION_OUT) 
     669      icon_name = "call-in"; 
     670    else 
     671      if (was_missed) 
     672        icon_name = "call-missed"; 
     673      else 
     674        icon_name = "call-out"; 
     675 
     676    /* display text should be either the contact name, or the number if the 
     677     * contact name is not know */ 
     678    /* FIXME: look up uid */ 
     679    display_text = number; 
     680 
     681    gtk_list_store_insert_with_values (list_store, NULL, 0, 
     682        HISTORY_NUMBER_COLUMN, number, 
     683        HISTORY_DSTART_COLUMN, dstart, 
     684        HISTORY_ICON_NAME_COLUMN, icon_name, 
     685        HISTORY_DISPLAY_TEXT_COLUMN, display_text, 
     686        -1); 
     687  } 
     688 
     689 
    757690 
    758691  return 1; 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.h

    r1857 r1880  
    2020#ifndef _OPENMOKO_DIALER_WINDOW_HISTORY_H 
    2121 
     22/* columns available in the history list store */ 
     23enum history_columns { 
     24  HISTORY_NUMBER_COLUMN, /* number for re-dial */ 
     25  HISTORY_DSTART_COLUMN, /* call time, used for sorting */ 
     26  HISTORY_ICON_NAME_COLUMN, /* icon name for display */ 
     27  HISTORY_DISPLAY_TEXT_COLUMN, /* name or number for display */ 
     28}; 
     29 
     30 
    2231gint window_history_init (MokoDialerData * p_dialer_data); 
    2332 
  • trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h

    r1857 r1880  
    9393} TIMER_DATA; 
    9494 
    95 enum 
    96 { 
    97   COLUMN_TYPE, 
    98   COLUMN_TYPEICON, 
    99   COLUMN_SEPRATE, 
    100   COLUMN_NAME_NUMBER, 
    101   COLUMN_TIME, 
    102   COLUMN_DURATION, 
    103   COLUMN_ENTRYPOINTER, 
    104   COLUMN_HASNAME, 
    105   N_COLUMN 
    106 }; 
    10795void gsm_incoming_call (gchar * number); 
    10896void gsm_peer_accept (); 
Note: See TracChangeset for help on using the changeset viewer.