Commit 7e94677e authored by Julien Bonjean's avatar Julien Bonjean
Browse files

Refactoring - step 4

Function renaming to make more homogeneous
Introduce search bar and make search stuff more generic
...
parent 292f811d
......@@ -16,13 +16,10 @@ sflphone_gtk_SOURCES = \
sflnotify.c \
assistant.c \
mainwindow.c \
calllist.c \
dialpad.c \
menus.c \
toolbar.c \
call.c \
calltab.c \
calltree.c \
actions.c \
accountlist.c \
marshaller.c \
......@@ -32,8 +29,8 @@ sflphone_gtk_SOURCES = \
timestamp.c \
reqaccount.c
noinst_HEADERS = actions.h dbus.h sflnotify.h mainwindow.h calllist.h dialpad.h codeclist.h assistant.h timestamp.h reqaccount.h \
callmanager-glue.h errors.h sflphone_const.h configurationmanager-glue.h instance-glue.h menus.h calltab.h calltree.h \
noinst_HEADERS = actions.h dbus.h sflnotify.h mainwindow.h dialpad.h codeclist.h assistant.h timestamp.h reqaccount.h \
callmanager-glue.h errors.h sflphone_const.h configurationmanager-glue.h instance-glue.h menus.h \
accountlist.h marshaller.h sliders.h statusicon.h call.h toolbar.h
EXTRA_DIST = marshaller.list
......
......@@ -24,8 +24,7 @@
#include <menus.h>
#include <statusicon.h>
#include <toolbar.h>
#include <contacts/searchfilter.h>
#include <contacts/addressbook/eds.h>
#include <contacts/searchbar.h>
#include <gtk/gtk.h>
#include <string.h>
#include <glib/gprintf.h>
......@@ -89,7 +88,7 @@ status_bar_display_account( call_t* c)
sflphone_quit ()
{
gboolean quit = FALSE;
guint count = call_list_get_size(current_calls);
guint count = calllist_get_size(current_calls);
if(count > 0){
quit = main_window_ask_quit();
}
......@@ -112,7 +111,7 @@ sflphone_quit ()
sflphone_hold(call_t * c )
{
c->state = CALL_STATE_HOLD;
update_call_tree(current_calls,c);
calltree_update_call(current_calls,c);
update_menus();
}
......@@ -120,15 +119,15 @@ sflphone_hold(call_t * c )
sflphone_ringing(call_t * c )
{
c->state = CALL_STATE_RINGING;
update_call_tree(current_calls,c);
calltree_update_call(current_calls,c);
update_menus();
}
void
sflphone_hung_up( call_t * c)
{
call_list_remove( current_calls, c->callID);
update_call_tree_remove(current_calls, c);
calllist_remove( current_calls, c->callID);
calltree_remove_call(current_calls, c);
c->state = CALL_STATE_DIALING;
update_menus();
#if GTK_CHECK_VERSION(2,10,0)
......@@ -229,11 +228,8 @@ gboolean sflphone_init()
{
dbus_register(getpid(), "Gtk+ Client");
current_calls = calltab_init(NULL);
// history = calltab_init("history");
contacts = calltab_init("contacts");
history = calltab_init("history");
histfilter = create_filter(GTK_TREE_MODEL(history->store));
init();
account_list_init ();
codec_list_init();
sflphone_fill_account_list(FALSE);
......@@ -246,7 +242,7 @@ gboolean sflphone_init()
void
sflphone_hang_up()
{
call_t * selectedCall = call_get_selected(current_calls);
call_t * selectedCall = calltab_get_selected_call(current_calls);
if(selectedCall)
{
switch(selectedCall->state)
......@@ -287,7 +283,7 @@ sflphone_hang_up()
break;
}
}
update_call_tree( history , selectedCall );
calltree_update_call( history , selectedCall );
}
......@@ -295,7 +291,7 @@ sflphone_hang_up()
sflphone_pick_up()
{
call_t * selectedCall = call_get_selected(active_calltree);
call_t * selectedCall = calltab_get_selected_call(active_calltree);
if(selectedCall)
{
switch(selectedCall->state)
......@@ -305,7 +301,7 @@ sflphone_pick_up()
break;
case CALL_STATE_INCOMING:
selectedCall->history_state = INCOMING;
update_call_tree( history , selectedCall );
calltree_update_call( history , selectedCall );
dbus_accept (selectedCall);
g_print("from sflphone_pick_up : "); stop_notification();
break;
......@@ -333,7 +329,7 @@ sflphone_pick_up()
void
sflphone_on_hold ()
{
call_t * selectedCall = call_get_selected(current_calls);
call_t * selectedCall = calltab_get_selected_call(current_calls);
if(selectedCall)
{
switch(selectedCall->state)
......@@ -355,7 +351,7 @@ sflphone_on_hold ()
void
sflphone_off_hold ()
{
call_t * selectedCall = call_get_selected(current_calls);
call_t * selectedCall = calltab_get_selected_call(current_calls);
if(selectedCall)
{
switch(selectedCall->state)
......@@ -380,7 +376,7 @@ sflphone_off_hold ()
sflphone_fail( call_t * c )
{
c->state = CALL_STATE_FAILURE;
update_call_tree(current_calls,c);
calltree_update_call(current_calls,c);
update_menus();
}
......@@ -388,7 +384,7 @@ sflphone_fail( call_t * c )
sflphone_busy( call_t * c )
{
c->state = CALL_STATE_BUSY;
update_call_tree(current_calls, c);
calltree_update_call(current_calls, c);
update_menus();
}
......@@ -398,7 +394,7 @@ sflphone_current( call_t * c )
if( c->state != CALL_STATE_HOLD )
(void) time(&c->_start);
c->state = CALL_STATE_CURRENT;
update_call_tree(current_calls,c);
calltree_update_call(current_calls,c);
update_menus();
}
......@@ -408,19 +404,19 @@ sflphone_record( call_t * c )
if( c->state != CALL_STATE_HOLD )
(void) time(&c->_start);
c->state = CALL_STATE_RECORD;
update_call_tree(current_calls,c);
calltree_update_call(current_calls,c);
update_menus();
}
void
sflphone_set_transfert()
{
call_t * c = call_get_selected(current_calls);
call_t * c = calltab_get_selected_call(current_calls);
if(c)
{
c->state = CALL_STATE_TRANSFERT;
c->to = g_strdup("");
update_call_tree(current_calls,c);
calltree_update_call(current_calls,c);
update_menus();
}
toolbar_update_buttons();
......@@ -429,12 +425,12 @@ sflphone_set_transfert()
void
sflphone_unset_transfert()
{
call_t * c = call_get_selected(current_calls);
call_t * c = calltab_get_selected_call(current_calls);
if(c)
{
c->state = CALL_STATE_CURRENT;
c->to = g_strdup("");
update_call_tree(current_calls,c);
calltree_update_call(current_calls,c);
update_menus();
}
toolbar_update_buttons();
......@@ -444,11 +440,11 @@ sflphone_unset_transfert()
sflphone_incoming_call (call_t * c)
{
c->history_state = MISSED;
call_list_add ( current_calls, c );
call_list_add( history, c );
update_call_tree_add( current_calls , c );
calllist_add ( current_calls, c );
calllist_add( history, c );
calltree_add_call( current_calls , c );
update_menus();
display_calltree (current_calls);
calltree_display (current_calls);
}
void
......@@ -486,7 +482,7 @@ process_dialing(call_t * c, guint keyval, gchar * key)
g_free(c->from);
c->from = g_strconcat("\"\" <", c->to, ">", NULL);
}
update_call_tree(current_calls,c);
calltree_update_call(current_calls,c);
}
else if(strlen(c->to) == 0)
{
......@@ -518,7 +514,7 @@ process_dialing(call_t * c, guint keyval, gchar * key)
g_free(c->from);
c->from = g_strconcat("\"\" <", c->to, ">", NULL);
}
update_call_tree(current_calls,c);
calltree_update_call(current_calls,c);
}
break;
}
......@@ -535,15 +531,15 @@ sflphone_new_call()
sflphone_on_hold();
// Play a tone when creating a new call
if( call_list_get_size(current_calls) == 0 )
if( calllist_get_size(current_calls) == 0 )
dbus_start_tone( TRUE , ( voice_mails > 0 )? TONE_WITH_MESSAGE : TONE_WITHOUT_MESSAGE) ;
to = g_strdup("");
from = g_strconcat("\"\" <>", NULL);
create_new_call (to, from, CALL_STATE_DIALING, "", &c);
call_list_add(current_calls,c);
update_call_tree_add(current_calls,c);
calllist_add(current_calls,c);
calltree_add_call(current_calls,c);
update_menus();
return c;
......@@ -553,7 +549,7 @@ sflphone_new_call()
void
sflphone_keypad( guint keyval, gchar * key)
{
call_t * c = call_get_selected(current_calls);
call_t * c = calltab_get_selected_call(current_calls);
if((active_calltree != current_calls) || (active_calltree == current_calls && !c))
{
......@@ -566,7 +562,7 @@ sflphone_keypad( guint keyval, gchar * key)
case 65307: /* ESCAPE */
break;
default:
display_calltree (current_calls);
calltree_display (current_calls);
process_dialing(sflphone_new_call(), keyval, key);
break;
}
......@@ -586,7 +582,7 @@ sflphone_keypad( guint keyval, gchar * key)
case 65307: /* ESCAPE */
dbus_hang_up(c);
(void) time(&c->_stop);
update_call_tree( history , c );
calltree_update_call( history , c );
break;
default:
// To play the dtmf when calling mail box for instance
......@@ -609,7 +605,7 @@ sflphone_keypad( guint keyval, gchar * key)
case 65293: /* ENTER */
case 65421: /* ENTER numpad */
c->history_state = INCOMING;
update_call_tree( history , c );
calltree_update_call( history , c );
dbus_accept(c);
g_print("from sflphone_keypad ( enter ) : "); stop_notification();
break;
......@@ -659,7 +655,7 @@ sflphone_keypad( guint keyval, gchar * key)
case 65307: /* ESCAPE */
dbus_hang_up(c);
c->_stop = 0;
update_call_tree( history , c );
calltree_update_call( history , c );
break;
}
break;
......@@ -753,7 +749,7 @@ sflphone_place_call ( call_t * c )
// Update history
c->history_state = OUTGOING;
g_print ("add in history\n");
call_list_add(history, c);
calllist_add(history, c);
}
}
......@@ -762,7 +758,7 @@ sflphone_place_call ( call_t * c )
sflphone_display_selected_codec (const gchar* codecName)
{
call_t * selectedCall = call_get_selected(current_calls);
call_t * selectedCall = calltab_get_selected_call(current_calls);
gchar* msg;
account_t* acc;
if(selectedCall->accountID != NULL){
......@@ -780,14 +776,14 @@ sflphone_display_selected_codec (const gchar* codecName)
gchar*
sflphone_get_current_codec_name()
{
call_t * selectedCall = call_get_selected(current_calls);
call_t * selectedCall = calltab_get_selected_call(current_calls);
return dbus_get_current_codec_name(selectedCall);
}
void
sflphone_rec_call()
{
call_t * selectedCall = call_get_selected(current_calls);
call_t * selectedCall = calltab_get_selected_call(current_calls);
dbus_set_record(selectedCall);
......@@ -803,7 +799,7 @@ sflphone_rec_call()
g_warning("Should not happen in sflphone_off_hold ()!");
break;
}
update_call_tree(current_calls,selectedCall);
calltree_update_call(current_calls,selectedCall);
update_menus();
// gchar* codname = sflphone_get_current_codec_name();
......
/*
* Copyright (C) 2009 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
......@@ -28,7 +28,7 @@ void addressbook_load_parameters (AddressBook_Config **settings) {
// Allocate a struct
_settings = g_new0 (AddressBook_Config, 1);
// Fetch the settings from D-Bus
_params = (GHashTable*) dbus_get_addressbook_settings ();
......@@ -46,14 +46,14 @@ void addressbook_load_parameters (AddressBook_Config **settings) {
_settings->search_phone_home = (guint) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_HOME));
_settings->search_phone_mobile = (guint) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_MOBILE));
}
*settings = _settings;
}
void addressbook_save_parameters (void) {
GHashTable *params = NULL;
params = g_hash_table_new (NULL, g_str_equal);
g_hash_table_replace (params, (gpointer)ADDRESSBOOK_MAX_RESULTS, (gpointer)addressbook_config->max_results);
g_hash_table_replace (params, (gpointer)ADDRESSBOOK_DISPLAY_CONTACT_PHOTO, (gpointer)addressbook_config->display_contact_photo);
......@@ -93,7 +93,7 @@ static void search_phone_mobile_cb (GtkWidget *widget) {
}
GtkWidget* create_addressbook_settings () {
GtkWidget *ret, *result_frame, *table, *value, *label, *photo, *item;
// Load the user value
......@@ -118,7 +118,7 @@ GtkWidget* create_addressbook_settings () {
value = gtk_hscale_new_with_range (25.0 , 50.0 , 5.0);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), value);
gtk_scale_set_digits (GTK_SCALE(value) , 0);
gtk_scale_set_value_pos (GTK_SCALE(value) , GTK_POS_RIGHT);
gtk_scale_set_value_pos (GTK_SCALE(value) , GTK_POS_RIGHT);
gtk_range_set_value (GTK_RANGE( value ) , addressbook_config->max_results);
g_signal_connect (G_OBJECT (value) , "value-changed" , G_CALLBACK(max_results_cb), NULL );
gtk_table_attach ( GTK_TABLE( table ), value, 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
......@@ -128,25 +128,25 @@ GtkWidget* create_addressbook_settings () {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(photo), addressbook_config->display_contact_photo);
g_signal_connect (G_OBJECT(photo) , "clicked" , G_CALLBACK (display_contact_photo_cb), NULL);
gtk_table_attach ( GTK_TABLE( table ), photo, 0, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new (_("Search for and display: "));
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
item = gtk_check_button_new_with_mnemonic( _("_Business phone"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(item), addressbook_config->search_phone_business);
g_signal_connect (G_OBJECT(item) , "clicked" , G_CALLBACK (search_phone_business_cb) , NULL);
gtk_table_attach ( GTK_TABLE( table ), item, 1, 3, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
item = gtk_check_button_new_with_mnemonic( _("_Home phone"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(item), addressbook_config->search_phone_home);
g_signal_connect (G_OBJECT(item) , "clicked" , G_CALLBACK (search_phone_home_cb) , NULL);
gtk_table_attach ( GTK_TABLE( table ), item, 1, 3, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
item = gtk_check_button_new_with_mnemonic( _("_Mobile phone"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(item), addressbook_config->search_phone_mobile);
g_signal_connect (G_OBJECT(item) , "clicked" , G_CALLBACK (search_phone_mobile_cb) , NULL);
gtk_table_attach ( GTK_TABLE( table ), item, 1, 3, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 10);
gtk_widget_show_all(ret);
return ret;
......
/*
* Copyright (C) 2009 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
......@@ -49,7 +49,7 @@ void addressbook_save_parameters (void);
/**
* Initialize the address book structure, and retrieve the saved parameters through D-Bus
*
* @param settings The addressbook structure
* @param settings The addressbook structure
*/
void addressbook_load_parameters (AddressBook_Config **settings);
......
......@@ -177,7 +177,7 @@ update_max_value( GtkRange* scale )
void
clean_history( void )
{
call_list_clean_history();
calllist_clean_history();
}
/**
......
......@@ -4,7 +4,13 @@ SUBDIRS = addressbook
noinst_LTLIBRARIES = libcontacts.la
libcontacts_la_SOURCES = searchfilter.c
libcontacts_la_SOURCES = \
searchbar.c \
calllist.c \
calltab.c \
calltree.c \
history.c \
addressbook.c
libcontacts_la_LDFLAGS = @DEPS_LDFLAGS@
......
/*
* Copyright (C) 2009 Savoir-Faire Linux inc.
* Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <addressbook.h>
#include <searchbar.h>
#include <addressbook-config.h>
static void handler_async_search (GList *, gpointer);
void
addressbook_search(GtkEntry* entry){
AddressBook_Config *addressbook_config;
// Activate waiting layer
activateWaitingLayer();
// Load the address book parameters
addressbook_load_parameters (&addressbook_config);
// Start the asynchronous search as soon as we have an entry */
search_async (gtk_entry_get_text (GTK_ENTRY (entry)), addressbook_config->max_results, &handler_async_search, addressbook_config);
}
void
addressbook_init(){
init();
}
static void handler_async_search (GList *hits, gpointer user_data) {
GList *i;
GdkPixbuf *photo = NULL;
AddressBook_Config *addressbook_config;
call_t *j;
// freeing calls
while((j = (call_t *)g_queue_pop_tail (contacts->callQueue)) != NULL)
{
free_call_t(j);
}
// Retrieve the address book parameters
addressbook_config = (AddressBook_Config*) user_data;
// reset previous results
calltree_reset(contacts);
calllist_reset(contacts);
for (i = hits; i != NULL; i = i->next)
{
Hit *entry;
entry = i->data;
if (entry)
{
/* Get the photo */
if (addressbook_display (addressbook_config, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO))
photo = entry->photo;
/* Create entry for business phone information */
if (addressbook_display (addressbook_config, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS))
calllist_add_contact (entry->name, entry->phone_business, CONTACT_PHONE_BUSINESS, photo);
/* Create entry for home phone information */
if (addressbook_display (addressbook_config, ADDRESSBOOK_DISPLAY_PHONE_HOME))
calllist_add_contact (entry->name, entry->phone_home, CONTACT_PHONE_HOME, photo);
/* Create entry for mobile phone information */
if (addressbook_display (addressbook_config, ADDRESSBOOK_DISPLAY_PHONE_MOBILE))
calllist_add_contact (entry->name, entry->phone_mobile, CONTACT_PHONE_MOBILE, photo);
}
free_hit(entry);
}
g_list_free(hits);
// Deactivate waiting image
deactivateWaitingLayer();
}
/*
* Copyright (C) 2009 Savoir-Faire Linux inc.
* Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* This file contains functions specific for addressbook.
* It is used as a "mapping" between real search implementation
* and search bar.
*/
#ifndef __ADDRESSBOOK_H__
#define __ADDRESSBOOK_H__
#include <gtk/gtk.h>
#include <addressbook/eds.h>
/**
* Execute a search in addressbook
*/
void
addressbook_search(GtkEntry*);
/**
* Initialize addressbook
*/
void
addressbook_init();
#endif
......@@ -19,9 +19,10 @@
#include <calllist.h>
#include <calltree.h>
#include <contacts/addressbook/eds.h>