Commit 09031a76 authored by areversat's avatar areversat

Add history to sflphone

parent 18f27b18
......@@ -8,7 +8,7 @@ sflphone_gtk_SOURCES = \
calllist.c \
dialpad.c \
menus.c \
notebook.c \
calltab.c \
calltree.c \
screen.c \
actions.c \
......@@ -23,7 +23,7 @@ sflphone_gtk_SOURCES = \
MemManager.c
noinst_HEADERS = actions.h dbus.h SFLnotify.h mainwindow.h calllist.h dialpad.h codeclist.h\
callmanager-glue.h configurationmanager-glue.h instance-glue.h menus.h notebook.h calltree.h screen.h configwindow.h \
callmanager-glue.h configurationmanager-glue.h instance-glue.h menus.h calltab.h calltree.h screen.h configwindow.h \
accountlist.h accountwindow.h marshaller.h sliders.h statusicon.h
EXTRA_DIST = marshaller.list
sflphone_gtk_LDADD = $(DEPS_LIBS) -lnotify
......
......@@ -25,7 +25,7 @@
#include <menus.h>
#include <screen.h>
#include <statusicon.h>
#include <notebook.h>
#include <calltab.h>
#include <gtk/gtk.h>
#include <string.h>
......@@ -101,7 +101,7 @@ status_bar_display_account( call_t* c)
sflphone_quit ()
{
gboolean quit = FALSE;
guint count = call_list_get_size(tabs[TAB_CALL]);
guint count = call_list_get_size(current_calls);
if(count > 0){
quit = main_window_ask_quit();
}
......@@ -124,29 +124,29 @@ sflphone_quit ()
sflphone_hold(call_t * c )
{
c->state = CALL_STATE_HOLD;
update_call_tree(tabs[TAB_CALL],c);
update_call_tree(current_calls,c);
update_menus();
}
void
void
sflphone_ringing(call_t * c )
{
c->state = CALL_STATE_RINGING;
update_call_tree(tabs[TAB_CALL],c);
update_call_tree(current_calls,c);
update_menus();
}
void
void
sflphone_hung_up( call_t * c)
{
call_list_remove( tabs[TAB_CALL], c->callID);
update_call_tree_remove(tabs[TAB_CALL], c);
call_list_remove( current_calls, c->callID);
update_call_tree_remove(current_calls, c);
update_menus();
status_tray_icon_blink( FALSE );
}
/** Internal to actions: Fill account list */
void
void
sflphone_fill_account_list()
{
account_list_clear ( );
......@@ -192,19 +192,16 @@ sflphone_fill_account_list()
}
printf("Updating buttons\n");
//toolbar_update_buttons();
}
gboolean
gboolean
sflphone_init()
{
int i;
for (i=0; i < NR_TABS; i++){
tabs[i] = calltab_init();
call_list_init (tabs[i]);
}
current_calls = calltab_init();
history = calltab_init();
account_list_init ();
codec_list_init();
if(!dbus_connect ()){
......@@ -222,24 +219,32 @@ sflphone_init()
}
}
void
void
sflphone_hang_up()
{
call_t * selectedCall = call_get_selected(tabs[TAB_CALL]);
call_t * selectedCall = call_get_selected(current_calls);
if(selectedCall)
{
switch(selectedCall->state)
{
case CALL_STATE_DIALING:
dbus_hang_up (selectedCall);
break;
case CALL_STATE_CURRENT:
case CALL_STATE_HOLD:
case CALL_STATE_DIALING:
case CALL_STATE_RINGING:
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
dbus_hang_up (selectedCall);
selectedCall->state = CALL_STATE_DIALING;
call_list_add(history, selectedCall);
update_call_tree_add(history, selectedCall);
break;
case CALL_STATE_INCOMING:
dbus_refuse (selectedCall);
selectedCall->state = CALL_STATE_DIALING;
call_list_add(history, selectedCall);
update_call_tree_add(history, selectedCall);
break;
case CALL_STATE_TRANSFERT:
dbus_hang_up (selectedCall);
......@@ -255,7 +260,7 @@ sflphone_hang_up()
void
sflphone_pick_up()
{
call_t * selectedCall = call_get_selected(tabs[TAB_CALL]);
call_t * selectedCall = call_get_selected(active_calltree);
if(selectedCall)
{
switch(selectedCall->state)
......@@ -288,7 +293,7 @@ sflphone_pick_up()
void
sflphone_on_hold ()
{
call_t * selectedCall = call_get_selected(tabs[TAB_CALL]);
call_t * selectedCall = call_get_selected(current_calls);
if(selectedCall)
{
switch(selectedCall->state)
......@@ -306,7 +311,7 @@ sflphone_on_hold ()
void
sflphone_off_hold ()
{
call_t * selectedCall = call_get_selected(tabs[TAB_CALL]);
call_t * selectedCall = call_get_selected(current_calls);
if(selectedCall)
{
switch(selectedCall->state)
......@@ -326,7 +331,7 @@ sflphone_off_hold ()
sflphone_fail( call_t * c )
{
c->state = CALL_STATE_FAILURE;
update_call_tree(tabs[TAB_CALL],c);
update_call_tree(current_calls,c);
update_menus();
}
......@@ -334,7 +339,7 @@ sflphone_fail( call_t * c )
sflphone_busy( call_t * c )
{
c->state = CALL_STATE_BUSY;
update_call_tree(tabs[TAB_CALL], c);
update_call_tree(current_calls, c);
update_menus();
}
......@@ -342,19 +347,19 @@ sflphone_busy( call_t * c )
sflphone_current( call_t * c )
{
c->state = CALL_STATE_CURRENT;
update_call_tree(tabs[TAB_CALL],c);
update_call_tree(current_calls,c);
update_menus();
}
void
sflphone_set_transfert()
{
call_t * c = call_get_selected(tabs[TAB_CALL]);
call_t * c = call_get_selected(current_calls);
if(c)
{
c->state = CALL_STATE_TRANSFERT;
c->to = g_strdup("");
update_call_tree(tabs[TAB_CALL],c);
update_call_tree(current_calls,c);
update_menus();
}
toolbar_update_buttons();
......@@ -363,12 +368,12 @@ sflphone_set_transfert()
void
sflphone_unset_transfert()
{
call_t * c = call_get_selected(tabs[TAB_CALL]);
call_t * c = call_get_selected(current_calls);
if(c)
{
c->state = CALL_STATE_CURRENT;
c->to = g_strdup("");
update_call_tree(tabs[TAB_CALL],c);
update_call_tree(current_calls,c);
update_menus();
}
toolbar_update_buttons();
......@@ -377,9 +382,9 @@ sflphone_unset_transfert()
void
sflphone_incoming_call (call_t * c)
{
call_list_add ( tabs[TAB_CALL],c );
call_list_add ( current_calls,c );
//status_icon_unminimize();
update_call_tree_add(tabs[TAB_CALL],c);
update_call_tree_add(current_calls,c);
update_menus();
}
......@@ -412,7 +417,7 @@ void process_dialing(call_t * c, guint keyval, gchar * key)
g_free(c->from);
c->from = g_strconcat("\"\" <", c->to, ">", NULL);
}
update_call_tree(tabs[TAB_CALL],c);
update_call_tree(current_calls,c);
}
else if(strlen(c->to) == 0)
{
......@@ -440,7 +445,7 @@ void process_dialing(call_t * c, guint keyval, gchar * key)
g_free(c->from);
c->from = g_strconcat("\"\" <", c->to, ">", NULL);
}
update_call_tree(tabs[TAB_CALL],c);
update_call_tree(current_calls,c);
}
break;
}
......@@ -451,7 +456,7 @@ void process_dialing(call_t * c, guint keyval, gchar * key)
call_t * sflphone_new_call()
{
// Play a tone when creating a new call
if( call_list_get_size(tabs[TAB_CALL]) == 0 )
if( call_list_get_size(current_calls) == 0 )
dbus_start_tone( TRUE , ( voice_mails > 0 )? TONE_WITH_MESSAGE : TONE_WITHOUT_MESSAGE) ;
call_t * c = g_new0 (call_t, 1);
......@@ -464,17 +469,18 @@ call_t * sflphone_new_call()
c->to = g_strdup("");
call_list_add(tabs[TAB_CALL],c);
update_call_tree_add(tabs[TAB_CALL],c);
call_list_add(current_calls,c);
update_call_tree_add(current_calls,c);
update_menus();
return c;
}
void
void
sflphone_keypad( guint keyval, gchar * key){
call_t * c = call_get_selected(current_tab);
call_t * c = call_get_selected(current_calls);
if(c)
{
......@@ -499,7 +505,7 @@ sflphone_keypad( guint keyval, gchar * key){
c->from = g_strconcat("\"",call_get_name(c) ,"\" <", temp, ">", NULL);
g_free(before);
g_free(temp);
//update_call_tree(tabs[TAB_CALL],c);
//update_call_tree(current_calls,c);
}
break;
}
......@@ -601,7 +607,6 @@ sflphone_place_call ( call_t * c )
{
c->accountID = default_account;
dbus_place_call(c);
update_call_tree_add(tabs[TAB_CALLED], c);
}
else
{
......@@ -615,7 +620,6 @@ sflphone_place_call ( call_t * c )
{
c->accountID = account->accountID;
dbus_place_call(c);
update_call_tree_add(tabs[TAB_CALLED], c);
}
else
{
......
......@@ -78,6 +78,9 @@ typedef struct {
call_t* selectedCall;
} calltab_t;
calltab_t* current_calls;
calltab_t* history;
/** This function initialize a call list. */
void call_list_init (calltab_t* tab);
......
......@@ -21,9 +21,11 @@
#include <stdlib.h>
#include <calltree.h>
#include <calllist.h>
#include <notebook.h>
#include <calltab.h>
calltab_t* calltab_init(){
calltab_t*
calltab_init()
{
calltab_t* ret;
ret = malloc(sizeof(calltab_t));
......@@ -32,33 +34,9 @@ calltab_t* calltab_init(){
ret->tree = NULL;
ret->callQueue = NULL;
ret->selectedCall = NULL;
create_call_tree(ret);
call_list_init(ret);
return ret;
}
void*
calltab_change(GtkNotebook* notebook,
GtkNotebookPage* page,
guint page_num,
gpointer data){
current_tab = tabs[page_num];
}
GtkWidget*
create_call_notebook(){
GtkWidget* notebook;
int i;
notebook = gtk_notebook_new();
for(i=0; i < NR_TABS; i++){
create_call_tree(tabs[i]);
}
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tabs[TAB_CALL]->tree, gtk_label_new("Call"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tabs[TAB_CALLED]->tree, gtk_label_new("Called"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tabs[TAB_RCVD]->tree, gtk_label_new("Received"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tabs[TAB_MISSED]->tree, gtk_label_new("Missed"));
current_tab = tabs[TAB_CALL];
g_signal_connect(notebook, "switch-page", G_CALLBACK(calltab_change), NULL);
return notebook;
}
......@@ -24,19 +24,6 @@
#include <gtk/gtk.h>
enum {
TAB_CALL,
TAB_CALLED,
TAB_RCVD,
TAB_MISSED
};
#define NR_TABS 4
calltab_t* calltab_init();
GtkWidget* create_call_notebook();
calltab_t* tabs[NR_TABS];
//calltab_t* call_tab, *called_tab, *rcvd_tab, *missed_tab;
calltab_t* current_tab;
#endif
......@@ -35,7 +35,9 @@ GtkToolItem * hangupButton;
GtkToolItem * holdButton;
GtkToolItem * transfertButton;
GtkToolItem * unholdButton;
GtkToolItem * historyButton;
guint transfertButtonConnId; //The button toggled signal connection ID
gboolean history_shown;
/**
......@@ -65,9 +67,23 @@ button_pressed(GtkWidget* widget, GdkEventButton *event, gpointer user_data)
static void
call_button( GtkWidget *widget, gpointer data )
{
if(call_list_get_size(current_tab)>0)
call_t * selectedCall;
printf("Call button pressed\n");
if(call_list_get_size(current_calls)>0)
sflphone_pick_up();
else
else if(call_list_get_size(active_calltree) > 0){
printf("Calling a called num\n");
selectedCall = call_get_selected(active_calltree);
if(!selectedCall->to){
selectedCall->to = call_get_number(selectedCall);
selectedCall->from = g_strconcat("\"\" <", selectedCall->to, ">",NULL);
}
gtk_toggle_tool_button_set_active(historyButton, FALSE);
printf("call : from : %s to %s\n", selectedCall->from, selectedCall->to);
call_list_add(current_calls, selectedCall);
update_call_tree_add(current_calls, selectedCall);
sflphone_place_call(selectedCall);
}else
sflphone_new_call();
}
......@@ -116,6 +132,26 @@ unhold( GtkWidget *widget, gpointer data )
sflphone_off_hold();
}
static void
toggle_history(GtkToggleToolButton *toggle_tool_button,
gpointer user_data)
{
GtkTreeSelection *sel;
if(history_shown){
active_calltree = current_calls;
gtk_widget_hide(history->tree);
gtk_widget_show(current_calls->tree);
history_shown = FALSE;
}else{
active_calltree = history;
gtk_widget_hide(current_calls->tree);
gtk_widget_show(history->tree);
history_shown = TRUE;
}
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_calltree->view));
g_signal_emit_by_name(sel, "changed");
toolbar_update_buttons();
}
void
toolbar_update_buttons ()
{
......@@ -141,7 +177,7 @@ toolbar_update_buttons ()
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(transfertButton), FALSE);
gtk_signal_handler_unblock(transfertButton, transfertButtonConnId);
call_t * selectedCall = call_get_selected(current_tab);
call_t * selectedCall = call_get_selected(active_calltree);
if (selectedCall)
{
switch(selectedCall->state)
......@@ -209,12 +245,13 @@ toolbar_update_buttons ()
}
}
/* Call back when the user click on a call in the list */
static void
static void
selected(GtkTreeSelection *sel, void* data)
{
GtkTreeIter iter;
GValue val;
GtkTreeModel *model = (GtkTreeModel*)current_tab->store;
GtkTreeModel *model = (GtkTreeModel*)active_calltree->store;
printf("Select !\n");
if (! gtk_tree_selection_get_selected (sel, &model, &iter))
return;
......@@ -222,7 +259,7 @@ selected(GtkTreeSelection *sel, void* data)
val.g_type = 0;
gtk_tree_model_get_value (model, &iter, 2, &val);
call_select(current_tab, (call_t*) g_value_get_pointer(&val));
call_select(active_calltree, (call_t*) g_value_get_pointer(&val));
g_value_unset(&val);
toolbar_update_buttons();
......@@ -234,7 +271,7 @@ void row_activated(GtkTreeView *tree_view,
GtkTreeViewColumn *column,
void * data)
{
call_t * selectedCall = call_get_selected(current_tab);
call_t * selectedCall = call_get_selected(current_calls);
if (selectedCall)
{
switch(selectedCall->state)
......@@ -321,6 +358,15 @@ create_toolbar (){
G_CALLBACK (transfert), NULL);
gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(transfertButton), -1);
historyButton = gtk_toggle_tool_button_new_from_stock (GTK_STOCK_INDEX);
gtk_widget_set_tooltip_text(GTK_WIDGET(historyButton), _("History"));
gtk_tool_button_set_label(GTK_TOOL_BUTTON(historyButton), _("History"));
g_signal_connect (G_OBJECT (historyButton), "toggled",
G_CALLBACK (toggle_history), NULL);
gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(historyButton), -1);
history_shown = FALSE;
active_calltree = current_calls;
return ret;
}
......
......@@ -22,15 +22,18 @@
#include <gtk/gtk.h>
#include <calllist.h>
#include <notebook.h>
#include <calltab.h>
/** @file calltree.h
* @brief The GtkTreeView that list calls in the main window.
*/
calltab_t* active_calltree;
void create_call_tree(calltab_t* tab);
void toolbar_update_buttons();
static void toggle_history(GtkToggleToolButton *toggle_tool_button, gpointer user_data);
void update_call_tree_add (calltab_t* ct, call_t * c);
void update_call_tree (calltab_t* ct, call_t * c);
......
......@@ -21,7 +21,7 @@
#include <accountlist.h>
#include <calllist.h>
#include <notebook.h>
#include <calltab.h>
#include <callmanager-glue.h>
#include <configurationmanager-glue.h>
#include <instance-glue.h>
......@@ -98,7 +98,7 @@ call_state_cb (DBusGProxy *proxy,
void * foo )
{
g_print ("Call %s state %s\n",callID, state);
call_t * c = call_list_get(tabs[TAB_CALL], callID);
call_t * c = call_list_get(current_calls, callID);
if(c)
{
if ( strcmp(state, "HUNGUP") == 0 )
......
......@@ -19,7 +19,7 @@
#include <config.h>
#include <actions.h>
#include <notebook.h>
#include <calltab.h>
#include <calllist.h>
#include <calltree.h>
#include <configwindow.h>
......@@ -54,7 +54,7 @@ on_delete (GtkWidget * widget, gpointer data)
/** Ask the user if he wants to hangup current calls */
gboolean
main_window_ask_quit(){
guint count = call_list_get_size(tabs[TAB_CALL]);
guint count = call_list_get_size(current_calls);
GtkWidget * dialog;
guint response;
gchar * question;
......@@ -147,7 +147,8 @@ create_main_window ()
widget = create_toolbar();
gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
gtk_box_pack_start (GTK_BOX (vbox), create_call_notebook(), TRUE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
gtk_box_pack_start (GTK_BOX (vbox), current_calls->tree, TRUE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
gtk_box_pack_start (GTK_BOX (vbox), history->tree, TRUE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
gtk_box_pack_start (GTK_BOX (vbox), subvbox, FALSE /*expand*/, FALSE /*fill*/, 0 /*padding*/);
......@@ -168,6 +169,10 @@ create_main_window ()
/* make sure that everything, window and label, are visible */
gtk_widget_show_all (window);
/* dont't show the history */
gtk_widget_hide(history->tree);
//gtk_widget_show(current_calls->tree);
//screen_clear();
// Welcome screen
......
......@@ -26,7 +26,7 @@
#include <dbus.h>
#include <mainwindow.h>
#include <screen.h>
#include <notebook.h>
#include <calltab.h>
#include <gtk/gtk.h>
#include <string.h> // for strlen
......@@ -41,61 +41,61 @@ guint holdConnId; //The hold_menu signal connection ID
void update_menus()
{
//Block signals for holdMenu
gtk_signal_handler_block(GTK_OBJECT(holdMenu), holdConnId);
gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(holdMenu), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(copyMenu), FALSE);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(holdMenu), FALSE);
call_t * selectedCall = call_get_selected(current_tab);
//Block signals for holdMenu
gtk_signal_handler_block(GTK_OBJECT(holdMenu), holdConnId);
gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(holdMenu), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(copyMenu), FALSE);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(holdMenu), FALSE);
call_t * selectedCall = call_get_selected(active_calltree);
if (selectedCall)
{
gtk_widget_set_sensitive( GTK_WIDGET(copyMenu), TRUE);
switch(selectedCall->state)
{
case CALL_STATE_INCOMING:
gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
break;
case CALL_STATE_HOLD:
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(holdMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),TRUE);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(holdMenu), TRUE);
break;
case CALL_STATE_RINGING:
gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
break;
case CALL_STATE_DIALING:
gtk_widget_set_sensitive( GTK_WIDGET(pickUpMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),TRUE);