Commit 2dea0427 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Improve codec processing on client side + info screen on call

Add a class codec on client side to manipulate codec-related data.
Add a screen that displays on call the number called and the codec used.

note: the screen doesn't display when a call is made with the keypad. TODO
parent dcc3c20e
......@@ -15,9 +15,10 @@ sflphone_gtk_SOURCES = \
accountwindow.c \
marshaller.c \
sliders.c \
statusicon.c
statusicon.c \
codeclist.c
noinst_HEADERS = actions.h dbus.h mainwindow.h calllist.h dialpad.h \
noinst_HEADERS = actions.h dbus.h mainwindow.h calllist.h dialpad.h codeclist.h\
callmanager-glue.h configurationmanager-glue.h instance-glue.h menus.h calltree.h screen.h configwindow.h \
accountlist.h accountwindow.h marshaller.h sliders.h statusicon.h
EXTRA_DIST = marshaller.list
......
......@@ -18,7 +18,6 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <accountlist.h>
#include <actions.h>
#include <calltree.h>
#include <dbus.h>
......@@ -80,7 +79,7 @@ sflphone_hold(call_t * c )
c->state = CALL_STATE_HOLD;
update_call_tree(c);
update_menus();
screen_clear();
//screen_clear();
}
void
......@@ -146,6 +145,7 @@ sflphone_init()
{
call_list_init ();
account_list_init ();
codec_list_init();
if(!dbus_connect ())
{
main_window_error_message("Unable to connect to the SFLphone server.\nMake sure the daemon is running.");
......@@ -156,7 +156,7 @@ sflphone_init()
dbus_register(getpid(), "Gtk+ Client");
sflphone_fill_account_list();
sflphone_set_default_account();
sflphone_get_codec_list();
sflphone_fill_codec_list();
return TRUE;
}
}
......@@ -165,6 +165,7 @@ sflphone_init()
sflphone_hang_up()
{
call_t * selectedCall = call_get_selected();
main_window_callinfo(FALSE, selectedCall);
if(selectedCall)
{
switch(selectedCall->state)
......@@ -195,6 +196,8 @@ sflphone_hang_up()
sflphone_pick_up()
{
call_t * selectedCall = call_get_selected();
//screen_set_call(selectedCall);
main_window_callinfo(TRUE, selectedCall);
if(selectedCall)
{
switch(selectedCall->state)
......@@ -264,7 +267,7 @@ sflphone_fail( call_t * c )
c->state = CALL_STATE_FAILURE;
update_call_tree(c);
update_menus();
screen_set_call(c);
main_window_callinfo(FALSE, c);
}
void
......@@ -273,7 +276,7 @@ sflphone_busy( call_t * c )
c->state = CALL_STATE_BUSY;
update_call_tree(c);
update_menus();
screen_set_call(c);
//screen_set_call(c);
}
void
......@@ -282,7 +285,7 @@ sflphone_current( call_t * c )
c->state = CALL_STATE_CURRENT;
update_call_tree(c);
update_menus();
screen_set_call(c);
//screen_set_call(c);
}
void
......@@ -293,7 +296,7 @@ sflphone_set_transfert()
{
c->state = CALL_STATE_TRANSFERT;
c->to = g_strdup("");
screen_set_call(c);
//screen_set_call(c);
update_call_tree(c);
update_menus();
}
......@@ -308,7 +311,7 @@ sflphone_unset_transfert()
{
c->state = CALL_STATE_CURRENT;
c->to = g_strdup("");
screen_set_call(c);
//screen_set_call(c);
update_call_tree(c);
update_menus();
}
......@@ -329,7 +332,7 @@ sflphone_hung_up (call_t * c )
call_list_remove(c->callID);
update_call_tree_remove(c);
update_menus();
screen_clear();
main_window_callinfo(FALSE, c);
}
void process_dialing(call_t * c, guint keyval, gchar * key)
......@@ -356,7 +359,7 @@ void process_dialing(call_t * c, guint keyval, gchar * key)
g_free(c->from);
c->from = g_strconcat("\"\" <", c->to, ">", NULL);
}
screen_set_call(c);
//screen_set_call(c);
update_call_tree(c);
}
else if(strlen(c->to) == 1)
......@@ -384,7 +387,7 @@ void process_dialing(call_t * c, guint keyval, gchar * key)
g_free(c->from);
c->from = g_strconcat("\"\" <", c->to, ">", NULL);
}
screen_set_call(c);
//screen_set_call(c);
update_call_tree(c);
}
break;
......@@ -405,7 +408,7 @@ call_t * sflphone_new_call()
c->to = g_strdup("");
call_list_add(c);
screen_set_call(c);
//screen_set_call(c);
update_call_tree_add(c);
update_menus();
......@@ -439,7 +442,7 @@ sflphone_keypad( guint keyval, gchar * key)
c->from = g_strconcat("\"",call_get_name(c) ,"\" <", temp, ">", NULL);
g_free(before);
g_free(temp);
screen_set_call(c);
//screen_set_call(c);
update_call_tree(c);
}
break;
......@@ -572,14 +575,29 @@ sflphone_set_default_account( )
/* Internal to action - get the codec list */
gchar**
sflphone_get_codec_list()
void
sflphone_fill_codec_list()
{
int i=0;
gchar** codecs = (gchar**)dbus_codec_list();
while(codecs[i]!=NULL){
printf("%s\n", codecs[i]);
i++;
}
int i=0;
gchar** codecs = (gchar**)dbus_codec_list();
while(codecs[i]!=NULL)
{
printf("%s\n", codecs[i]);
codec_t * c = g_new0(codec_t, 1);
c->name = codecs[i];
codec_set_active(codecs[i]); // active by default
codec_list_add(c);
i++;
}
}
......@@ -23,6 +23,7 @@
#include <calllist.h>
#include <accountlist.h>
#include <codeclist.h>
/** @file actions.h
* @brief General functions that change the state of the application.
......@@ -105,5 +106,5 @@ void sflphone_place_call ( call_t * c );
void sflphone_fill_account_list();
void sflphone_set_default_account();
gchar** sflphone_get_codec_list();
void sflphone_fill_codec_list();
#endif
/*
* Copyright (C) 2007 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.net>
*
* 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 <codeclist.h>
#include <string.h>
GQueue * codecQueue = NULL;
gint
is_name_codecstruct (gconstpointer a, gconstpointer b)
{
codec_t * c = (codec_t *)a;
if(strcmp(c->name, (const gchar *)b)==0)
return 0;
else
return 1;
}
void
codec_list_init()
{
codecQueue = g_queue_new();
}
void
codec_list_add(codec_t * c)
{
g_queue_push_tail (codecQueue, (gpointer *) c);
}
void
codec_set_active(gchar * codec_name)
{
codec_t * c = codec_list_get(codec_name);
if(c)
c->is_active = TRUE;
}
void
codec_set_inactive(gchar * codec_name)
{
codec_t * c = codec_list_get(codec_name);
if(c)
c->is_active = FALSE;
}
guint
codec_list_get_size()
{
return g_queue_get_length(codecQueue);
}
codec_t*
codec_list_get( const gchar * name)
{
GList * c = g_queue_find_custom(codecQueue, name, is_name_codecstruct);
if(c)
return (codec_t *)c->data;
else
return NULL;
}
codec_t*
codec_list_get_nth(guint index)
{
return g_queue_peek_nth(codecQueue, index);
}
void
codec_set_prefered_order(guint index)
{
codec_t * prefered = codec_list_get_nth(index);
g_queue_pop_nth(codecQueue, index);
g_queue_push_head(codecQueue, prefered);
}
/*
* Copyright (C) 2007 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.net>
*
* 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.
*/
#ifndef __CODECLIST_H__
#define __CODECLIST_H__
#include <gtk/gtk.h>
/** @file codeclist.h
* @brief A list to hold codecs.
*/
typedef struct {
gchar * name;
guint sample_rate;
gboolean is_active;
}codec_t;
void codec_list_init();
void codec_list_add(codec_t * c);
void codec_set_active(gchar * codec_name);
void codec_set_inactive(gchar * codec_name);
guint codec_list_get_size();
codec_t * codec_list_get(const gchar * codec_name);
codec_t* codec_list_get_nth(guint index);
/**
* Set the prefered codec first in the codec list
* @param index The position in the list of the prefered codec
*/
void codec_set_prefered_order(guint index);
//gchar * codec_get_name(codec_t * c);
//guint codec_get_rate(gchar * codec_name);
#endif
......@@ -353,10 +353,10 @@ static
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order (DBusGProxy *proxy, const char ** IN_ringtone, GError **error)
org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order (DBusGProxy *proxy, const char * IN_codec_name, GError **error)
{
return dbus_g_proxy_call (proxy, "setCodecPreferedOrder", error, G_TYPE_STRV, IN_ringtone, G_TYPE_INVALID, G_TYPE_INVALID);
return dbus_g_proxy_call (proxy, "setCodecPreferedOrder", error, G_TYPE_STRING, IN_codec_name, G_TYPE_INVALID, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
......@@ -376,36 +376,36 @@ static
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order_async (DBusGProxy *proxy, const char ** IN_ringtone, org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order_reply callback, gpointer userdata)
org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order_async (DBusGProxy *proxy, const char * IN_codec_name, org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order_reply callback, gpointer userdata)
{
DBusGAsyncData *stuff;
stuff = g_new (DBusGAsyncData, 1);
stuff->cb = G_CALLBACK (callback);
stuff->userdata = userdata;
return dbus_g_proxy_begin_call (proxy, "setCodecPreferedOrder", org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order_async_callback, stuff, g_free, G_TYPE_STRV, IN_ringtone, G_TYPE_INVALID);
return dbus_g_proxy_begin_call (proxy, "setCodecPreferedOrder", org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order_async_callback, stuff, g_free, G_TYPE_STRING, IN_codec_name, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order (DBusGProxy *proxy, char *** OUT_ringtone, GError **error)
org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order (DBusGProxy *proxy, char ** OUT_codec_name, GError **error)
{
return dbus_g_proxy_call (proxy, "getCodecPreferedOrder", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_ringtone, G_TYPE_INVALID);
return dbus_g_proxy_call (proxy, "getCodecPreferedOrder", error, G_TYPE_INVALID, G_TYPE_STRING, OUT_codec_name, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order_reply) (DBusGProxy *proxy, char * *OUT_ringtone, GError *error, gpointer userdata);
typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order_reply) (DBusGProxy *proxy, char * OUT_codec_name, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
{
DBusGAsyncData *data = (DBusGAsyncData*) user_data;
GError *error = NULL;
char ** OUT_ringtone;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_ringtone, G_TYPE_INVALID);
(*(org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order_reply)data->cb) (proxy, OUT_ringtone, error, data->userdata);
char * OUT_codec_name;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_codec_name, G_TYPE_INVALID);
(*(org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order_reply)data->cb) (proxy, OUT_codec_name, error, data->userdata);
return;
}
......
......@@ -74,25 +74,25 @@ config_window_fill_account_list ()
config_window_fill_codec_list()
{
if(dialogOpen)
{
GtkTreeIter iter;
gtk_list_store_clear(codec_store);
//gchar * description = "Select a codec:";
//gtk_list_store_append(codec_store, &iter);
//gtk_list_store_set(codec_store, &iter, 0, description, -1);
int i=0;
gchar** codecs = (gchar**)dbus_codec_list();
while(codecs[i]!=NULL)
{
gtk_list_store_append (codec_store, &iter);
gtk_list_store_set(codec_store, &iter,0,codecs[i],-1);
i++;
}
}
if(dialogOpen)
{
GtkTreeIter iter;
int i;
gtk_list_store_clear(codec_store);
gchar * description = "Select a codec:";
//gtk_list_store_append(codec_store, &iter);
//gtk_list_store_set(codec_store, &iter, 0, description, -1);
for(i=0; i<codec_list_get_size(); i++)
{
codec_t* c = codec_list_get_nth(i);
printf("%s\n",c->name);
if(c)
{
gtk_list_store_append (codec_store, &iter);
gtk_list_store_set(codec_store, &iter,0,c->name,-1);
}
}
}
}
/**
......@@ -178,12 +178,8 @@ select_codec( GtkComboBox* wid)
guint item = gtk_combo_box_get_active(wid);
/* now we want this selected codec to be used as the preferred codec */
/* ie first in the list in the user config */
gchar** codecs = (gchar**)dbus_codec_list();
gchar* tmp;
tmp = codecs[0];
codecs[0] = codecs[item];
codecs[item]=tmp;
dbus_set_prefered_codec(codecs);
codec_set_prefered_order(item);
dbus_set_prefered_codec(codec_list_get_nth(0)->name);
}
void
......
......@@ -689,14 +689,14 @@ dbus_codec_list()
}
void
dbus_set_prefered_codec(const gchar** codecList)
dbus_set_prefered_codec(const gchar* codec)
{
g_print("Before");
GError *error = NULL;
org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order (
configurationManagerProxy,
codecList,
codec,
&error);
g_print("After");
......
......@@ -36,8 +36,9 @@ GtkWidget * window = NULL;
GtkWidget * subvbox = NULL;
GtkWidget * dialpad = NULL;
GtkWidget * statusBar = NULL;
gboolean showDialpad = FALSE; // true if the dialpad have been showned
GtkWidget * infoScreen = NULL;
gboolean showDialpad = FALSE; // true if the dialpad have been shown
gboolean showInfoScreen = FALSE; // true if the info screen have been shown
/**
* Terminate the main loop.
......@@ -149,9 +150,10 @@ create_main_window ()
gtk_box_pack_start (GTK_BOX (vbox), subvbox, FALSE /*expand*/, FALSE /*fill*/, 0 /*padding*/);
widget = create_screen();
//widget = create_screen();
// TODO Add the screen when we are decided
//gtk_box_pack_start (GTK_BOX (subvbox), widget, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
widget = create_slider("speaker");
gtk_box_pack_start (GTK_BOX (subvbox), widget, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
......@@ -166,8 +168,7 @@ create_main_window ()
/* make sure that everything, window and label, are visible */
gtk_widget_show_all (window);
screen_clear();
//screen_clear();
// Welcome screen
if (account_list_get_size() == 0)
{
......@@ -244,6 +245,22 @@ main_window_dialpad(gboolean show){
showDialpad = show;
}
void
main_window_callinfo(gboolean show, call_t* current)
{
if(show && !showInfoScreen)
{
infoScreen = create_screen();
gtk_box_pack_start (GTK_BOX (subvbox), infoScreen, FALSE /*expand*/, TRUE /*fill*/, 0 /*padding*/);
gtk_widget_show_all(infoScreen);
screen_set_call(current);
}
else if(!show && showInfoScreen)
{
gtk_container_remove(GTK_CONTAINER (subvbox), infoScreen);
}
showInfoScreen = show;
}
void
status_bar_message(const gchar * message)
......
......@@ -19,7 +19,7 @@
#include <dialpad.h>
#include <screen.h>
#include <codeclist.h>
GtkWidget * label;
GtkWidget * hbox;
......@@ -43,7 +43,8 @@ create_screen()
event = gtk_event_box_new ();
gtk_widget_modify_bg (event, GTK_STATE_NORMAL, &color);
label = gtk_label_new ("test");
//label = gtk_label_new ("test");
label = gtk_label_new("");
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
gtk_misc_set_padding(GTK_MISC(label), 5, 5);
gtk_misc_set_alignment(GTK_MISC(label), 0,0);
......@@ -60,13 +61,16 @@ create_screen()
void
screen_clear()
{
gtk_label_set_markup(GTK_LABEL(label), "<big><b>Welcome to SFLphone</b></big>\n");
gtk_label_set_markup(GTK_LABEL(label), "<b>CALL INFOS</b>\n");
}
void
screen_set_call(const call_t * c)
{
gchar * markup = g_strconcat("<big><b>", call_get_name(c), "</b></big>\n", call_get_number(c), NULL);
//printf("accountID = %s\ncall to = %s\n", c->accountID, c->to);
//gchar * markup = g_strconcat("<big><b>", call_get_name(c), "</b></big>\n", call_get_number(c), NULL);
gchar * markup = g_strconcat("<b><i>Calling to:</i></b>", "\t", call_get_number(c),
"\n<b><i>Codec:</i></b>", "\t", codec_list_get_nth(0)->name, NULL);
gtk_label_set_markup(GTK_LABEL(label), markup);
g_free(markup);
}
......@@ -89,12 +89,12 @@ public:
};
static ::DBus::IntrospectedArgument setCodecPreferedOrder_args[] =
{
{ "ringtone", "as", true },
{ "codec_name", "s", true },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getCodecPreferedOrder_args[] =
{
{ "ringtone", "as", false },
{ "codec_name", "s", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getPlaybackDeviceList_args[] =
......@@ -191,8 +191,8 @@ public:
virtual std::vector< ::DBus::String > getRingtoneList( ) = 0;
virtual std::vector< ::DBus::String > getCodecList( ) = 0;
virtual std::vector< ::DBus::String > getToneLocaleList( ) = 0;
virtual void setCodecPreferedOrder( const std::vector< ::DBus::String >& ringtone ) = 0;
virtual std::vector< ::DBus::String > getCodecPreferedOrder( ) = 0;
virtual void setCodecPreferedOrder( const ::DBus::String& codec_name ) = 0;
virtual ::DBus::String getCodecPreferedOrder( ) = 0;
virtual std::vector< ::DBus::String > getPlaybackDeviceList( ) = 0;
virtual std::vector< ::DBus::String > getRecordDeviceList( ) = 0;
virtual std::vector< ::DBus::String > getSampleRateList( ) = 0;
......@@ -313,7 +313,7 @@ private:
{
::DBus::MessageIter ri = call.reader();
std::vector< ::DBus::String > argin1; ri >> argin1;
::DBus::String argin1; ri >> argin1;
setCodecPreferedOrder(argin1);
::DBus::ReturnMessage reply(call);
return reply;
......@@ -322,7 +322,7 @@ private:
{
::DBus::MessageIter ri = call.reader();
std::vector< ::DBus::String > argout1 = getCodecPreferedOrder();
::DBus::String argout1 = getCodecPreferedOrder();
::DBus::ReturnMessage reply(call);