Commit 70bf9115 authored by Julien Bonjean's avatar Julien Bonjean

Switched everything to log4c (ticket #1162)

parent 9afb4b47
......@@ -2,7 +2,10 @@ SUBDIRS = src pixmaps
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = sflphone.desktop.in
log4crc_DATA = log4crc
log4crcdir = $(datadir)/sflphone
EXTRA_DIST = $(log4crc_DATA) sflphone.desktop.in
appsdir = $(datadir)/applications
apps_in_files = sflphone.desktop.in
apps_DATA = $(apps_in_files:.desktop.in=.desktop)
......
......@@ -8,6 +8,7 @@ AM_CPPFLAGS = $(DEPS_CFLAGS) \
-I$(src)/src/dbus \
-I$(src)/src/contacts \
-I$(src)/src/addressbook \
-DDATA_DIR=\""$(prefix)/share/sflphone"\" \
-DICONS_DIR=\""$(prefix)/share/sflphone"\" \
-DCODECS_DIR=\""$(prefix)/lib/sflphone/codecs"\"
-DPREFIX=\"$(prefix)\" \
......
......@@ -2,7 +2,6 @@
<!DOCTYPE log4c SYSTEM "">
<log4c version="1.2.1">
<config>
<bufsize>0</bufsize>
<debug level="2"/>
......@@ -20,6 +19,6 @@
<layout name="basic" type="basic"/>
<layout name="dated" type="dated"/>
<category name="root" priority="notice"/>
<category name="root" priority="warning"/>
<category name="org.sflphone.gtk" priority="warning" appender="stdout" />
</log4c>
......@@ -2,22 +2,22 @@
* Copyright (C) 2007 Savoir-Faire Linux inc.
* Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
* 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.
*/
#include <accountlist.h>
#include <actions.h>
#include <string.h>
......@@ -26,7 +26,7 @@ GQueue * accountQueue;
gchar* __CURRENT_ACCOUNT_ID = NULL;
/* GCompareFunc to compare a accountID (gchar* and a account_t) */
gint
gint
is_accountID_struct ( gconstpointer a, gconstpointer b)
{
account_t * c = (account_t*)a;
......@@ -41,7 +41,7 @@ is_accountID_struct ( gconstpointer a, gconstpointer b)
}
/* GCompareFunc to get current call (gchar* and a account_t) */
gint
gint
get_state_struct ( gconstpointer a, gconstpointer b)
{
account_t * c = (account_t*)a;
......@@ -55,26 +55,26 @@ get_state_struct ( gconstpointer a, gconstpointer b)
}
}
void
void
account_list_init ()
{
accountQueue = g_queue_new ();
}
void
void
account_list_clean ()
{
g_queue_free (accountQueue);
}
void
void
account_list_add (account_t * c)
{
g_queue_push_tail (accountQueue, (gpointer *) c);
}
void
void
account_list_remove (const gchar * accountID)
{
GList * c = g_queue_find_custom (accountQueue, accountID, is_accountID_struct);
......@@ -85,7 +85,7 @@ account_list_remove (const gchar * accountID)
}
account_t *
account_t *
account_list_get_by_state (account_state_t state )
{
GList * c = g_queue_find_custom (accountQueue, &state, get_state_struct);
......@@ -93,11 +93,11 @@ account_list_get_by_state (account_state_t state )
{
return (account_t *)c->data;
}
else
else
{
return NULL;
}
}
account_t *
......@@ -120,7 +120,7 @@ account_list_get_size ( )
return g_queue_get_length (accountQueue);
}
account_t *
account_t *
account_list_get_nth ( guint n )
{
return g_queue_peek_nth (accountQueue, n);
......@@ -138,7 +138,7 @@ account_list_get_current( )
void
account_list_set_current_id(const gchar * accountID)
{
g_print("set current id = %s\n", accountID);
DEBUG("set current id = %s", accountID);
__CURRENT_ACCOUNT_ID = g_strdup(accountID);
}
......@@ -227,14 +227,14 @@ account_list_get_registered_accounts( void )
if( account_list_get_nth( i ) -> state == ( ACCOUNT_STATE_REGISTERED ))
res ++;
}
g_print(" %d registered accounts \n" , res );
DEBUG(" %d registered accounts" , res );
return res;
}
gchar* account_list_get_current_id( void ){
if( __CURRENT_ACCOUNT_ID == NULL )
return "";
else
else
return __CURRENT_ACCOUNT_ID;
}
......
......@@ -273,14 +273,14 @@ sflphone_hang_up()
dbus_refuse (selectedCall);
selectedCall->state = CALL_STATE_DIALING;
selectedCall->_stop = 0;
g_print("from sflphone_hang_up : "); stop_notification();
DEBUG("from sflphone_hang_up : "); stop_notification();
break;
case CALL_STATE_TRANSFERT:
dbus_hang_up (selectedCall);
(void) time(&selectedCall->_stop);
break;
default:
g_warning("Should not happen in sflphone_hang_up()!");
WARN("Should not happen in sflphone_hang_up()!");
break;
}
}
......@@ -304,7 +304,7 @@ sflphone_pick_up()
selectedCall->history_state = INCOMING;
calltree_update_call( history , selectedCall );
dbus_accept (selectedCall);
g_print("from sflphone_pick_up : "); stop_notification();
DEBUG("from sflphone_pick_up : "); stop_notification();
break;
case CALL_STATE_HOLD:
sflphone_new_call();
......@@ -321,7 +321,7 @@ sflphone_pick_up()
sflphone_new_call();
break;
default:
g_warning("Should not happen in sflphone_pick_up()!");
WARN("Should not happen in sflphone_pick_up()!");
break;
}
}
......@@ -343,7 +343,7 @@ sflphone_on_hold ()
break;
default:
g_warning("Should not happen in sflphone_on_hold!");
WARN("Should not happen in sflphone_on_hold!");
break;
}
}
......@@ -361,15 +361,19 @@ sflphone_off_hold ()
dbus_unhold (selectedCall);
break;
default:
g_warning("Should not happen in sflphone_off_hold ()!");
WARN("Should not happen in sflphone_off_hold ()!");
break;
}
}
if(dbus_get_is_recording(selectedCall))
g_print("Currently recording! \n");
{
DEBUG("Currently recording!");
}
else
g_print("Not recording currently \n");
{
DEBUG("Not recording currently");
}
}
......@@ -457,8 +461,8 @@ process_dialing(call_t * c, guint keyval, gchar * key)
//dbus_play_dtmf( key );
}
g_print("process_dialing : keyval : %i \n",keyval);
g_print("process_dialing : key : %s \n",key);
DEBUG("process_dialing : keyval : %i",keyval);
DEBUG("process_dialing : key : %s",key);
switch (keyval)
{
......@@ -476,7 +480,7 @@ process_dialing(call_t * c, guint keyval, gchar * key)
c->to = g_strndup(c->to, strlen(c->to) -1);
g_free(before);
g_print("TO: backspace %s\n", c->to);
DEBUG("TO: backspace %s", c->to);
if(c->state == CALL_STATE_DIALING)
{
......@@ -508,7 +512,7 @@ process_dialing(call_t * c, guint keyval, gchar * key)
gchar * before = c->to;
c->to = g_strconcat(c->to, key, NULL);
g_free(before);
g_print("TO:default %s\n", c->to);
DEBUG("TO:default %s", c->to);
if(c->state == CALL_STATE_DIALING)
{
......@@ -570,7 +574,7 @@ sflphone_keypad( guint keyval, gchar * key)
}
else if(c)
{
printf("call\n");
DEBUG("call");
switch(c->state)
{
case CALL_STATE_DIALING: // Currently dialing => edit number
......@@ -608,11 +612,11 @@ sflphone_keypad( guint keyval, gchar * key)
c->history_state = INCOMING;
calltree_update_call( history , c );
dbus_accept(c);
g_print("from sflphone_keypad ( enter ) : "); stop_notification();
DEBUG("from sflphone_keypad ( enter ) : "); stop_notification();
break;
case 65307: /* ESCAPE */
dbus_refuse(c);
g_print("from sflphone_keypad ( escape ) : "); stop_notification();
DEBUG("from sflphone_keypad ( escape ) : "); stop_notification();
break;
}
break;
......@@ -711,7 +715,7 @@ sflphone_place_call ( call_t * c )
} else {
current = account_list_get_current();
}
// printf("sflphone_place_call :: c->accountID : %i \n",c->accountID);
// DEBUG("sflphone_place_call :: c->accountID : %i",c->accountID);
// account_t * current = c->accountID;
......@@ -807,14 +811,14 @@ sflphone_rec_call()
selectedCall->state = CALL_STATE_CURRENT;
break;
default:
g_warning("Should not happen in sflphone_off_hold ()!");
WARN("Should not happen in sflphone_off_hold ()!");
break;
}
calltree_update_call(current_calls,selectedCall);
update_menus();
// gchar* codname = sflphone_get_current_codec_name();
// printf("sflphone_get_current_codec_name: %s \n",codname);
// DEBUG("sflphone_get_current_codec_name: %s",codname);
}
/* Internal to action - set the __CURRENT_ACCOUNT variable */
......@@ -843,7 +847,7 @@ sflphone_fill_codec_list()
codec_t * c = g_new0(codec_t, 1);
c->_payload = atoi(*order);
details = (gchar **)dbus_codec_details(c->_payload);
//printf("Codec details: %s / %s / %s / %s\n",details[0],details[1],details[2],details[3]);
//DEBUG("Codec details: %s / %s / %s / %s",details[0],details[1],details[2],details[3]);
c->name = details[0];
c->is_active = TRUE;
c->sample_rate = atoi(details[1]);
......
......@@ -96,21 +96,21 @@ void create_new_call (gchar *to, gchar *from, call_state_t state, gchar *account
*new_call = call;
}
void create_new_call_from_details (const gchar *call_id, GHashTable *details, call_t **call)
void create_new_call_from_details (const gchar *call_id, GHashTable *details, call_t **call)
{
gchar *from, *to, *accountID;
call_t *new_call;
GHashTable *call_details;
// GHashTable *call_details;
accountID = g_hash_table_lookup (details, "ACCOUNTID");
to = g_hash_table_lookup (details, "PEER_NUMBER");
from = g_markup_printf_escaped("\"\" <%s>", to);
create_new_call (from, from, CALL_STATE_DIALING, accountID, &new_call);
*call = new_call;
}
void
free_call_t (call_t *c)
{
......
/*
* Copyright (C) 2007 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.net>
* 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
......@@ -66,13 +66,13 @@ codec_list_add(codec_t * c)
}
void
void
codec_set_active(gchar* name)
{
codec_t * c = codec_list_get(name);
if(c)
{
printf("%s set active\n", c->name);
DEBUG("%s set active", c->name);
c->is_active = TRUE;
}
}
......@@ -116,7 +116,7 @@ codec_set_prefered_order(guint index)
}
/**
*
*
*/
void
codec_list_move_codec_up(guint index)
......@@ -126,16 +126,16 @@ codec_list_move_codec_up(guint index)
gpointer codec = g_queue_pop_nth(codecQueue, index);
g_queue_push_nth(codecQueue, codec, index-1);
}
// DEBUG
unsigned int i;
printf("\nCodec list\n");
DEBUG("Codec list");
for(i=0; i < codecQueue->length; i++)
printf("%s\n", codec_list_get_nth(i)->name);
DEBUG("%s", codec_list_get_nth(i)->name);
}
/**
*
*
*/
void
codec_list_move_codec_down(guint index)
......@@ -148,29 +148,29 @@ codec_list_move_codec_down(guint index)
// PRINT
unsigned int i;
printf("\nCodec list\n");
DEBUG("Codec list");
for(i=0; i < codecQueue->length; i++)
printf("%s\n", codec_list_get_nth(i)->name);
DEBUG("%s", codec_list_get_nth(i)->name);
}
/**
*
*
*/
void
codec_list_update_to_daemon()
{
// String listing of all codecs payloads
const gchar** codecList;
// Length of the codec list
int length = codecQueue->length;
// Initiate double array char list for one string
codecList = (void*)malloc(sizeof(void*));
// Get all codecs in queue
int i, c = 0;
printf("List of active codecs :");
DEBUG("List of active codecs :");
for(i = 0; i < length; i++)
{
codec_t* currentCodec = codec_list_get_nth(i);
......@@ -189,18 +189,16 @@ codec_list_update_to_daemon()
// Put payload string in char array
sprintf(payload, "%d", currentCodec->_payload);
strcpy((char*)*(codecList+c), payload);
g_print(" %s", *(codecList+c));
DEBUG(" %s", *(codecList+c));
c++;
}
}
}
// Allocate NULL array at the end for Dbus
codecList = (void*)realloc(codecList, (c+1)*sizeof(void*));
*(codecList+c) = NULL;
printf("\n");
// call dbus function with array of strings
dbus_set_active_codec_list(codecList);
......
/*
* Copyright (C) 2008 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.
......@@ -62,7 +62,7 @@ config_window_fill_codec_list()
for(i = 0; i < codec_list_get_size(); i++)
{
codec_t *c = codec_list_get_nth(i);
printf("%s\n", c->name);
DEBUG("%s", c->name);
if(c)
{
gtk_list_store_append(codecStore, &iter);
......@@ -151,7 +151,7 @@ select_active_output_audio_device()
// Select active output device on server
devices = dbus_get_current_audio_devices_index();
currentDeviceIndex = atoi(devices[0]);
printf(_("audio device index for output = %d\n"), currentDeviceIndex);
DEBUG(_("audio device index for output = %d"), currentDeviceIndex);
model = gtk_combo_box_get_model(GTK_COMBO_BOX(output));
// Find the currently set output device
......@@ -167,7 +167,7 @@ select_active_output_audio_device()
} while(gtk_tree_model_iter_next(model, &iter));
// No index was found, select first one
g_print("Warning : No active output device found");
WARN("Warning : No active output device found");
gtk_combo_box_set_active(GTK_COMBO_BOX(output), 0);
}
}
......@@ -233,7 +233,7 @@ select_active_input_audio_device()
} while(gtk_tree_model_iter_next(model, &iter));
// No index was found, select first one
g_print("Warning : No active input device found");
WARN("Warning : No active input device found");
gtk_combo_box_set_active(GTK_COMBO_BOX(input), 0);
}
}
......@@ -255,7 +255,7 @@ select_output_audio_plugin(GtkComboBox* widget, gpointer data UNUSED)
{
model = gtk_combo_box_get_model(widget);
gtk_combo_box_get_active_iter(widget, &iter);
gtk_tree_model_get(model, &iter, 0, &pluginName, -1);
gtk_tree_model_get(model, &iter, 0, &pluginName, -1);
dbus_set_output_audio_plugin(pluginName);
//update_combo_box( pluginName);
}
......@@ -291,7 +291,7 @@ select_active_output_audio_plugin()
} while(gtk_tree_model_iter_next(model, &iter));
// No index was found, select first one
g_print("Warning : No active output device found\n");
WARN("Warning : No active output device found");
gtk_combo_box_set_active(GTK_COMBO_BOX(plugin), 0);
}
......@@ -386,7 +386,7 @@ codec_active_toggled(GtkCellRendererToggle *renderer UNUSED, gchar *path, gpoint
COLUMN_CODEC_NAME, &name,
-1);
printf("%s\n", name);
DEBUG("%s", name);
// Toggle active value
active = !active;
......@@ -398,7 +398,7 @@ codec_active_toggled(GtkCellRendererToggle *renderer UNUSED, gchar *path, gpoint
gtk_tree_path_free(treePath);
// Modify codec queue to represent change
// Modify codec queue to represent change
if(active)
codec_set_active(name);
else
......@@ -487,16 +487,16 @@ codec_move_down(GtkButton *button UNUSED, gpointer data)
codec_move(FALSE, data);
}
int
int
is_ringtone_enabled( void )
{
return dbus_is_ringtone_enabled();
return dbus_is_ringtone_enabled();
}
void
void
ringtone_enabled( void )
{
dbus_ringtone_enabled();
dbus_ringtone_enabled();
}
void
......@@ -604,24 +604,24 @@ GtkWidget* codecs_box()
select_audio_manager( void )
{
g_print("audio manager selected\n");
DEBUG("audio manager selected");
if( !SHOW_ALSA_CONF && !gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(pulse) ) )
{
dbus_set_audio_manager( ALSA );
g_print(" display alsa conf panel\n");
DEBUG(" display alsa conf panel");
alsabox = alsa_box();
gtk_container_add( GTK_CONTAINER(alsa_conf ) , alsabox);
gtk_widget_show( alsa_conf );
gtk_widget_show( alsa_conf );
}
else if( SHOW_ALSA_CONF && gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(pulse) ))
{
dbus_set_audio_manager( PULSEAUDIO );
g_print(" remove alsa conf panel\n");
DEBUG(" remove alsa conf panel");
gtk_container_remove( GTK_CONTAINER(alsa_conf) , alsabox );
}
else
g_print("alsa conf panel...nothing\n");
DEBUG("alsa conf panel...nothing");
//gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(pulse) )? dbus_set_audio_manager( PULSEAUDIO ):dbus_set_audio_manager( ALSA );
}
......@@ -662,7 +662,7 @@ GtkWidget* alsa_box()
gtk_box_pack_start( GTK_BOX(ret) , table , TRUE , TRUE , 1);
gtk_widget_show(table);
g_print("plugin\n");
DEBUG("plugin");
item = gtk_label_new(_("ALSA plugin"));
gtk_misc_set_alignment(GTK_MISC(item), 0, 0.5);
gtk_table_attach(GTK_TABLE(table), item, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
......@@ -684,7 +684,7 @@ GtkWidget* alsa_box()
// Device : Output device
// Create title label
g_print("output\n");
DEBUG("output");
item = gtk_label_new(_("Output"));
gtk_misc_set_alignment(GTK_MISC(item), 0, 0.5);
gtk_table_attach(GTK_TABLE(table), item, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
......@@ -706,7 +706,7 @@ GtkWidget* alsa_box()
// Device : Input device
// Create title label
g_print("input\n");
DEBUG("input");
item = gtk_label_new(_("Input"));
gtk_misc_set_alignment(GTK_MISC(item), 0, 0.5);
gtk_table_attach(GTK_TABLE(table), item, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
......@@ -728,7 +728,7 @@ GtkWidget* alsa_box()
gtk_widget_show_all(ret);
g_print("done\n");
DEBUG("done");
return ret;
}
......@@ -746,8 +746,8 @@ GtkWidget* ringtones_box()
g_signal_connect(G_OBJECT( enableTone) , "clicked" , G_CALLBACK( ringtone_enabled ) , NULL);
// file chooser button
fileChooser = gtk_file_chooser_button_new(_("Choose a ringtone"), GTK_FILE_CHOOSER_ACTION_OPEN);