r1880 - trunk/src/target/OM-2007/applications/openmoko-dialer/src
thomas at sita.openmoko.org
thomas at sita.openmoko.org
Mon Apr 30 18:20:29 CEST 2007
Author: thomas
Date: 2007-04-30 18:20:27 +0200 (Mon, 30 Apr 2007)
New Revision: 1880
Modified:
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.c
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.h
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.c
trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.h
trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h
Log:
openmoko-dialer: Use MokoJournal to retrieve call history
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.c 2007-04-30 15:56:54 UTC (rev 1879)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.c 2007-04-30 16:20:27 UTC (rev 1880)
@@ -180,7 +180,6 @@
/* application object */
-// MokoApplication* app = MOKO_APPLICATION(moko_application_get_instance());
g_set_application_name ("OpenMoko Dialer");
/* Set up gsmd connection object */
@@ -189,6 +188,9 @@
g_signal_connect (G_OBJECT (conn), "incoming-call", (GCallback) incoming_call_cb, NULL);
g_signal_connect (G_OBJECT (conn), "incoming-clip", (GCallback) incoming_clip_cb, NULL);
+ /* Set up journal handling */
+ p_dialer_data->journal = moko_journal_open_default ();
+
signal (SIGUSR1, handle_sigusr1);
//init the dialer window
@@ -206,8 +208,11 @@
gtk_main ();
-//release everything
+ //release everything
contact_release_contact_list (&(p_dialer_data->g_contactlist));
+ /* closes the journal and frees allocated memory */
+ moko_journal_close (p_dialer_data->journal);
+
return 0;
}
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.h 2007-04-30 15:56:54 UTC (rev 1879)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-main.h 2007-04-30 16:20:27 UTC (rev 1880)
@@ -17,25 +17,17 @@
*/
#include "moko-dialer-includes.h"
#include <libmokogsmd/moko-gsmd-connection.h>
-/*
+#include <libmokojournal/moko-journal.h>
-typedef struct _window_outgoing
-{
-
-MokoDialerStatus * status_outgoing;
-
-GtkWidget* window_outgoing;
-
-GtkWidget* buttonSpeaker;
-GtkWidget* buttonCancel;
-GtkWidget* buttonRedial;
-}WindowOutgoing;
-*/
typedef struct _dialer_data
{
//the global data area begins here
+
MokoGsmdConnection *connection;
+ MokoJournal *journal;
+ GtkListStore *history;
+
char str_sim_pin[MOKO_DIALER_MAX_PIN_LEN + 1];
gint int_sim_pin_end_point;
MokoDialerTextview *moko_dialer_text_view; ///<the textview for the dialer window
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.c 2007-04-30 15:56:54 UTC (rev 1879)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.c 2007-04-30 16:20:27 UTC (rev 1880)
@@ -424,8 +424,8 @@
GtkTreeIter iter;
GtkTreeModel *model;
GtkTreeSelection *selection;
- /*HISTORY_ENTRY*/void *p;
- int hasname;
+ //HISTORY_ENTRY void *p;
+ //int hasname;
MokoDialerData *p_dialer_data = (MokoDialerData *) user_data;
selection =
@@ -438,12 +438,13 @@
return;
}
- gtk_tree_model_get (model, &iter, COLUMN_ENTRYPOINTER, &p, -1);
+ /*gtk_tree_model_get (model, &iter, COLUMN_ENTRYPOINTER, &p, -1);
//p_dialer_data->g_currentselected = p;
gtk_tree_model_get (model, &iter, COLUMN_HASNAME, &hasname, -1);
history_update_counter (p_dialer_data);
+ */
}
@@ -587,14 +588,9 @@
{
GtkListStore *list_store;
-// GtkTreeIter iter;
-// HISTORY_ENTRY *entry;
-
- //copied
GtkTreeViewColumn *col;
GtkCellRenderer *renderer;
- //GtkTreeModel *model;
GtkWidget *contactview = NULL;
//DBG_ENTER();
@@ -605,45 +601,29 @@
if (contactview == NULL)
return 0;
-//pack image and label
+
+ /* Create column with icon and text */
col = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (col, ("Title"));
- gtk_tree_view_column_set_resizable (col, TRUE);
-
-
-
renderer = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (col, renderer, FALSE);
gtk_tree_view_column_set_attributes (col, renderer,
- "pixbuf", COLUMN_TYPEICON, NULL);
+ "icon-name", HISTORY_ICON_NAME_COLUMN, NULL);
renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (col, renderer, FALSE);
- gtk_tree_view_column_set_attributes (col, renderer,
- "text", COLUMN_TIME, NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (col, renderer, FALSE);
- gtk_tree_view_column_set_attributes (col, renderer,
- "text", COLUMN_SEPRATE, NULL);
-
- renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (col, renderer, TRUE);
gtk_tree_view_column_set_attributes (col, renderer,
- "text", COLUMN_NAME_NUMBER, NULL);
+ "text", HISTORY_DISPLAY_TEXT_COLUMN, NULL);
-
gtk_tree_view_append_column (GTK_TREE_VIEW (contactview), col);
- //entry = p_dialer_data->g_historylist.first;
+ /* Set up a list store for the history items */
+ /* UID, DSTART, MISSED, DIRECTION */
+ list_store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_INT);
- list_store = gtk_list_store_new (N_COLUMN, G_TYPE_INT, GDK_TYPE_PIXBUF,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_INT, G_TYPE_POINTER,
- G_TYPE_INT, -1);
- //we will use a filter to facilitate the filtering in treeview without rebuilding the database.
+
+ //we will use a filter to facilitate the filtering in treeview without rebuilding the database.
p_dialer_data->g_list_store_filter =
gtk_tree_model_filter_new (GTK_TREE_MODEL (list_store), NULL);
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER
@@ -653,108 +633,61 @@
p_dialer_data, NULL);
//load the three icons to memory.
+ gtk_tree_view_set_model (GTK_TREE_VIEW (contactview),
+ GTK_TREE_MODEL (p_dialer_data->
+ g_list_store_filter));
- // GError *error = NULL;
- p_dialer_data->g_iconReceived = create_pixbuf ("received.png");
- /* FIXME: error handling hasn't been implemented yet!
- p_dialer_data->g_iconReceived = create_pixbuf ("received.png", &error);
- if (error)
- {
- DBG_WARN ("Cound not load icon :%s", error->message);
- g_error_free (error);
- p_dialer_data->g_iconReceived = NULL;
- error = NULL;
- }
- */
+ /* add the initial contents of the list store */
+ int i = 0;
+ MokoJournalEntry *j_entry;
- p_dialer_data->g_iconDialed = create_pixbuf ("dialed.png");
- /* FIXME: error handling hasn't been implemented yet!
- p_dialer_data->g_iconDialed = create_pixbuf ("dialed.png", &error);
- if (error)
- {
- DBG_WARN ("Cound not load icon :%s", error->message);
- g_error_free (error);
- p_dialer_data->g_iconDialed = NULL;
- error = NULL;
- }
+ /* if there aren't any entries in the journal, we don't need to do any more
+ * here
*/
+ if (moko_journal_get_nb_entries (p_dialer_data->journal))
+ return 1;
- p_dialer_data->g_iconMissed = create_pixbuf ("missed.png");
- /* FIXME: error handling hasn't been implemented yet!
- p_dialer_data->g_iconMissed = create_pixbuf ("missed.png", &error);
- if (error)
- {
- DBG_WARN ("Cound not load icon :%s", error->message);
- g_error_free (error);
- p_dialer_data->g_iconMissed = NULL;
- error = NULL;
- }
- */
-#if 0
- while (entry)
+ j_entry = moko_journal_entry_new (VOICE_JOURNAL_ENTRY);
+
+ while (moko_journal_get_entry_at (p_dialer_data->journal, i, &j_entry))
{
- //DBG_MESSAGE(entry->number);
- gtk_list_store_append (list_store, &iter);
- gtk_list_store_set (list_store, &iter, COLUMN_TYPE, entry->type,
- COLUMN_SEPRATE, "--", COLUMN_TIME, entry->time,
- COLUMN_DURATION, entry->durationsec,
- COLUMN_ENTRYPOINTER, entry, COLUMN_HASNAME, 0, -1);
- if (entry->name == 0)
- {
- //DBG_MESSAGE(entry->number);
- gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER,
- entry->number, -1);
- gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 0, -1);
- }
- else
- {
- gtk_list_store_set (list_store, &iter, COLUMN_NAME_NUMBER,
- entry->name, -1);
- gtk_list_store_set (list_store, &iter, COLUMN_HASNAME, 1, -1);
- }
- switch (entry->type)
- {
- case INCOMING:
- {
- gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
- p_dialer_data->g_iconReceived, -1);
- // icon=gdk_pixbuf_new_from_file("./received.png",&error);
- break;
- }
- case OUTGOING:
- { // icon=gdk_pixbuf_new_from_file("./dialed.png",&error);
- gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
- p_dialer_data->g_iconDialed, -1);
- break;
- }
- case MISSED:
- { //icon=gdk_pixbuf_new_from_file("./missed.png",&error);
- gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
- p_dialer_data->g_iconMissed, -1);
- break;
- }
+ const gchar *uid, *number;
+ gchar *icon_name, *display_text;
+ int dstart;
+ enum MessageDirection direction;
+ gboolean was_missed;
+ const MokoTime *time;
- default:
+ uid = moko_journal_entry_get_contact_uid (j_entry);
+ moko_journal_entry_get_direction (j_entry, &direction);
+ time = moko_journal_entry_get_dtstart (j_entry);
+ was_missed = moko_journal_voice_info_get_was_missed ((MokoJournalVoiceInfo*) j_entry);
+ number = moko_journal_voice_info_get_distant_number ((MokoJournalVoiceInfo*)j_entry);
- { //icon=gdk_pixbuf_new_from_file("./missed.png",&error);
- gtk_list_store_set (list_store, &iter, COLUMN_TYPEICON,
- p_dialer_data->g_iconMissed, -1);
- break;
- }
- }
+ if (direction == DIRECTION_OUT)
+ icon_name = "call-in";
+ else
+ if (was_missed)
+ icon_name = "call-missed";
+ else
+ icon_name = "call-out";
+ /* display text should be either the contact name, or the number if the
+ * contact name is not know */
+ /* FIXME: look up uid */
+ display_text = number;
-
- entry = entry->next;
+ gtk_list_store_insert_with_values (list_store, NULL, 0,
+ HISTORY_NUMBER_COLUMN, number,
+ HISTORY_DSTART_COLUMN, dstart,
+ HISTORY_ICON_NAME_COLUMN, icon_name,
+ HISTORY_DISPLAY_TEXT_COLUMN, display_text,
+ -1);
}
-#endif
- gtk_tree_view_set_model (GTK_TREE_VIEW (contactview),
- GTK_TREE_MODEL (p_dialer_data->
- g_list_store_filter));
- g_object_unref (list_store);
+
return 1;
}
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.h 2007-04-30 15:56:54 UTC (rev 1879)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/dialer-window-history.h 2007-04-30 16:20:27 UTC (rev 1880)
@@ -19,6 +19,15 @@
#ifndef _OPENMOKO_DIALER_WINDOW_HISTORY_H
+/* columns available in the history list store */
+enum history_columns {
+ HISTORY_NUMBER_COLUMN, /* number for re-dial */
+ HISTORY_DSTART_COLUMN, /* call time, used for sorting */
+ HISTORY_ICON_NAME_COLUMN, /* icon name for display */
+ HISTORY_DISPLAY_TEXT_COLUMN, /* name or number for display */
+};
+
+
gint window_history_init (MokoDialerData * p_dialer_data);
#define _OPENMOKO_DIALER_WINDOW_HISTORY_H
Modified: trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h 2007-04-30 15:56:54 UTC (rev 1879)
+++ trunk/src/target/OM-2007/applications/openmoko-dialer/src/moko-dialer-includes.h 2007-04-30 16:20:27 UTC (rev 1880)
@@ -92,18 +92,6 @@
char timestring[MOKO_DIALER_MAX_TIME_STATUS_LEN + 1];
} TIMER_DATA;
-enum
-{
- COLUMN_TYPE,
- COLUMN_TYPEICON,
- COLUMN_SEPRATE,
- COLUMN_NAME_NUMBER,
- COLUMN_TIME,
- COLUMN_DURATION,
- COLUMN_ENTRYPOINTER,
- COLUMN_HASNAME,
- N_COLUMN
-};
void gsm_incoming_call (gchar * number);
void gsm_peer_accept ();
void gsm_peer_abort ();
More information about the commitlog
mailing list