Commit 3eb4d41a authored by Emmanuel Lepage's avatar Emmanuel Lepage
Browse files
parents c270b1d6 53622593
...@@ -113,14 +113,14 @@ main (int argc, char **argv) ...@@ -113,14 +113,14 @@ main (int argc, char **argv)
if (fp) { // PID file exists. Check the former process still alive or not. If alive, give user a hint. if (fp) { // PID file exists. Check the former process still alive or not. If alive, give user a hint.
int oldPid; int oldPid;
if (fscanf(fp, "%d", &oldPid) != 1) { if (fscanf(fp, "%d", &oldPid) != 1) {
fprintf(stderr, "Couldn't read pidfile %s\n", pidfile.c_str()); std::cerr << "Couldn't read pidfile " << pidfile << std::endl;
return 1; return 1;
} }
fclose (fp); fclose (fp);
if (kill (oldPid, 0) == 0) { if (kill (oldPid, 0) == 0) {
fprintf (stderr, "There is already a sflphoned daemon running in the system. Starting Failed."); std::cerr << "There is already a sflphoned daemon running in the system. Starting Failed." << std::endl;
return 1; return 1;
} }
} }
...@@ -140,11 +140,11 @@ main (int argc, char **argv) ...@@ -140,11 +140,11 @@ main (int argc, char **argv)
try { try {
Manager::instance().init(); Manager::instance().init();
} catch (std::exception &e) { } catch (const std::exception &e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
return 1; return 1;
} catch (...) { } catch (...) {
fprintf (stderr, "An exception occured when initializing the system."); std::cerr << "An exception occured when initializing the system." << std::endl;
return 1; return 1;
} }
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
<listOptionValue builtIn="false" value="/usr/include/libgnome-2.0"/> <listOptionValue builtIn="false" value="/usr/include/libgnome-2.0"/>
<listOptionValue builtIn="false" value="/usr/include/libgnomeui-2.0"/> <listOptionValue builtIn="false" value="/usr/include/libgnomeui-2.0"/>
<listOptionValue builtIn="false" value="/usr/include"/> <listOptionValue builtIn="false" value="/usr/include"/>
<listOptionValue builtIn="false" value="/usr/include/evolution-data-server-2.30"/>
</option> </option>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1676995808" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> <option id="gnu.c.compiler.option.preprocessor.def.symbols.1676995808" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="&quot;ICONS_DIR=&quot;/usr/share/sflphone\&quot;"/> <listOptionValue builtIn="false" value="&quot;ICONS_DIR=&quot;/usr/share/sflphone\&quot;"/>
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
#include "widget/imwidget.h" #include "widget/imwidget.h"
static GHashTable * ip2ip_profile=NULL; static GHashTable * ip2ip_profile;
static gchar ** sflphone_order_history_hash_table(GHashTable *result) static gchar ** sflphone_order_history_hash_table(GHashTable *result)
{ {
...@@ -138,7 +138,7 @@ sflphone_notify_voice_mail (const gchar* accountID , guint count) ...@@ -138,7 +138,7 @@ sflphone_notify_voice_mail (const gchar* accountID , guint count)
static gboolean _is_direct_call (callable_obj_t * c) static gboolean _is_direct_call (callable_obj_t * c)
{ {
if (g_strcasecmp (c->_accountID, EMPTY_ENTRY) == 0) { if (g_strcasecmp (c->_accountID, "empty") == 0) {
if (!g_str_has_prefix (c->_peer_number, "sip:")) { if (!g_str_has_prefix (c->_peer_number, "sip:")) {
gchar * new_number = g_strconcat ("sip:", c->_peer_number, NULL); gchar * new_number = g_strconcat ("sip:", c->_peer_number, NULL);
g_free (c->_peer_number); g_free (c->_peer_number);
...@@ -333,7 +333,7 @@ gboolean sflphone_init (GError **error) ...@@ -333,7 +333,7 @@ gboolean sflphone_init (GError **error)
if (!dbus_connect (error) || !dbus_register (getpid (), "Gtk+ Client", error)) if (!dbus_connect (error) || !dbus_register (getpid (), "Gtk+ Client", error))
return FALSE; return FALSE;
abookfactory_init_factory(); abook_init();
// Init icons factory // Init icons factory
init_icon_factory (); init_icon_factory ();
...@@ -414,7 +414,6 @@ sflphone_hang_up() ...@@ -414,7 +414,6 @@ sflphone_hang_up()
call_remove_all_errors (selectedCall); call_remove_all_errors (selectedCall);
selectedCall->_state = CALL_STATE_DIALING; selectedCall->_state = CALL_STATE_DIALING;
DEBUG ("from sflphone_hang_up : "); DEBUG ("from sflphone_hang_up : ");
stop_notification();
break; break;
case CALL_STATE_TRANSFER: case CALL_STATE_TRANSFER:
dbus_hang_up (selectedCall); dbus_hang_up (selectedCall);
...@@ -465,7 +464,6 @@ sflphone_pick_up() ...@@ -465,7 +464,6 @@ sflphone_pick_up()
} }
dbus_accept (selectedCall); dbus_accept (selectedCall);
stop_notification();
break; break;
case CALL_STATE_TRANSFER: case CALL_STATE_TRANSFER:
dbus_transfer (selectedCall); dbus_transfer (selectedCall);
...@@ -766,11 +764,9 @@ sflphone_keypad (guint keyval, gchar * key) ...@@ -766,11 +764,9 @@ sflphone_keypad (guint keyval, gchar * key)
c->_history_state = INCOMING; c->_history_state = INCOMING;
calltree_update_call (history, c, NULL); calltree_update_call (history, c, NULL);
dbus_accept (c); dbus_accept (c);
stop_notification();
break; break;
case GDK_Escape: case GDK_Escape:
dbus_refuse (c); dbus_refuse (c);
stop_notification();
break; break;
} }
...@@ -825,15 +821,14 @@ sflphone_keypad (guint keyval, gchar * key) ...@@ -825,15 +821,14 @@ sflphone_keypad (guint keyval, gchar * key)
break; break;
} }
} else { } else
sflphone_new_call(); sflphone_new_call();
}
} }
static void place_direct_call (const callable_obj_t * c) static void place_direct_call (const callable_obj_t * c)
{ {
assert(c->_state == CALL_STATE_DIALING); g_assert(c->_state == CALL_STATE_DIALING);
dbus_place_call (c); dbus_place_call(c);
} }
static int place_registered_call (callable_obj_t * c) static int place_registered_call (callable_obj_t * c)
...@@ -861,7 +856,7 @@ static int place_registered_call (callable_obj_t * c) ...@@ -861,7 +856,7 @@ static int place_registered_call (callable_obj_t * c)
DEBUG ("Actions: Get account for this call"); DEBUG ("Actions: Get account for this call");
if (g_strcasecmp (c->_accountID, "") != 0) { if (strlen(c->_accountID) != 0) {
DEBUG ("Actions: Account %s already set for this call", c->_accountID); DEBUG ("Actions: Account %s already set for this call", c->_accountID);
current = account_list_get_by_id (c->_accountID); current = account_list_get_by_id (c->_accountID);
} else { } else {
...@@ -1055,40 +1050,29 @@ sflphone_rec_call() ...@@ -1055,40 +1050,29 @@ sflphone_rec_call()
void sflphone_fill_codec_list () void sflphone_fill_codec_list ()
{ {
guint account_list_size; guint account_list_size = account_list_get_size();
guint i;
account_t *current = NULL;
DEBUG ("SFLphone: Fill codec list"); for (guint i = 0; i < account_list_size; i++) {
account_t *current = account_list_get_nth(i);
account_list_size = account_list_get_size ();
for (i=0; i<account_list_size; i++) {
current = account_list_get_nth (i);
if (current) if (current)
sflphone_fill_codec_list_per_account (&current); sflphone_fill_codec_list_per_account(current);
} }
} }
void sflphone_fill_codec_list_per_account (account_t **account) void sflphone_fill_codec_list_per_account (account_t *account)
{ {
gchar **order; gchar **order = dbus_get_active_audio_codec_list(account->accountID);
gchar** pl;
GQueue *codeclist;
order = (gchar**) dbus_get_active_audio_codec_list ( (*account)->accountID); GQueue *codeclist = account->codecs;
codeclist = (*account)->codecs;
// First clean the list // First clean the list
codec_list_clear (&codeclist); codec_list_clear(&codeclist);
if (!(*order)) if (!(*order))
ERROR ("SFLphone: No codec list provided"); ERROR ("SFLphone: No codec list provided");
else { else {
for (pl = order; *pl; pl++) { for (gchar **pl = order; *pl; pl++) {
codec_t * cpy = NULL; codec_t * cpy = NULL;
// Each account will have a copy of the system-wide capabilities // Each account will have a copy of the system-wide capabilities
...@@ -1104,8 +1088,7 @@ void sflphone_fill_codec_list_per_account (account_t **account) ...@@ -1104,8 +1088,7 @@ void sflphone_fill_codec_list_per_account (account_t **account)
guint caps_size = codec_list_get_size (); guint caps_size = codec_list_get_size ();
guint i; for (guint i = 0; i < caps_size; i++) {
for (i = 0; i < caps_size; i++) {
codec_t * current_cap = capabilities_get_nth (i); codec_t * current_cap = capabilities_get_nth (i);
// Check if this codec has already been enabled for this account // Check if this codec has already been enabled for this account
...@@ -1114,7 +1097,7 @@ void sflphone_fill_codec_list_per_account (account_t **account) ...@@ -1114,7 +1097,7 @@ void sflphone_fill_codec_list_per_account (account_t **account)
codec_list_add (current_cap, &codeclist); codec_list_add (current_cap, &codeclist);
} }
} }
(*account)->codecs = codeclist; account->codecs = codeclist;
} }
void sflphone_fill_call_list (void) void sflphone_fill_call_list (void)
...@@ -1367,9 +1350,8 @@ sflphone_request_go_clear (void) ...@@ -1367,9 +1350,8 @@ sflphone_request_go_clear (void)
{ {
callable_obj_t * selectedCall = calltab_get_selected_call (current_calls); callable_obj_t * selectedCall = calltab_get_selected_call (current_calls);
if (selectedCall) { if (selectedCall)
dbus_request_go_clear (selectedCall); dbus_request_go_clear (selectedCall);
}
} }
void void
...@@ -1389,37 +1371,3 @@ sflphone_call_state_changed (callable_obj_t * c, const gchar * description, cons ...@@ -1389,37 +1371,3 @@ sflphone_call_state_changed (callable_obj_t * c, const gchar * description, cons
update_actions(); update_actions();
} }
void sflphone_get_interface_addr_from_name (char *iface_name, char **iface_addr, int size)
{
struct ifreq ifr;
int fd;
// static char iface_addr[18];
char *tmp_addr;
struct sockaddr_in *saddr_in;
struct in_addr *addr_in;
if ( (fd = socket (AF_INET, SOCK_DGRAM,0)) < 0)
DEBUG ("getInterfaceAddrFromName error could not open socket\n");
memset (&ifr, 0, sizeof (struct ifreq));
strcpy (ifr.ifr_name, iface_name);
ifr.ifr_addr.sa_family = AF_INET;
if ( ioctl (fd, SIOCGIFADDR, &ifr) < 0)
DEBUG ("getInterfaceAddrFromName use default interface (0.0.0.0)\n");
saddr_in = (struct sockaddr_in *) &ifr.ifr_addr;
addr_in = & (saddr_in->sin_addr);
tmp_addr = (char *) addr_in;
snprintf (*iface_addr, size, "%d.%d.%d.%d",
UC (tmp_addr[0]), UC (tmp_addr[1]), UC (tmp_addr[2]), UC (tmp_addr[3]));
close (fd);
}
...@@ -35,13 +35,10 @@ ...@@ -35,13 +35,10 @@
#include <libintl.h> #include <libintl.h>
#include <locale.h> #include <locale.h>
#include <accountlist.h> #include "accountlist.h"
#include <codeclist.h> #include "codeclist.h"
#include <sflphone_const.h> #include "sflphone_const.h"
#include <conference_obj.h> #include "conference_obj.h"
#define UC(b) (((int)b)&0xff)
/** @file actions.h /** @file actions.h
* @brief General functions that change the state of the application. * @brief General functions that change the state of the application.
...@@ -191,8 +188,7 @@ void sflphone_set_current_account(); ...@@ -191,8 +188,7 @@ void sflphone_set_current_account();
*/ */
void sflphone_fill_codec_list (); void sflphone_fill_codec_list ();
void sflphone_fill_codec_list_per_account (account_t **); void sflphone_fill_codec_list_per_account (account_t *);
void sflphone_add_participant(); void sflphone_add_participant();
...@@ -278,11 +274,6 @@ void sflphone_request_go_clear (void); ...@@ -278,11 +274,6 @@ void sflphone_request_go_clear (void);
*/ */
void sflphone_call_state_changed (callable_obj_t * c, const gchar * description, const guint code); void sflphone_call_state_changed (callable_obj_t * c, const gchar * description, const guint code);
/**
* Resolve an interface address given its name
*/
void sflphone_get_interface_addr_from_name (char *iface_name, char **iface_addr, int size);
void sflphone_add_main_participant (const conference_obj_t * c); void sflphone_add_main_participant (const conference_obj_t * c);
void void
......
...@@ -177,7 +177,7 @@ callable_obj_t *create_history_entry_from_serialized_form (const gchar *entry) ...@@ -177,7 +177,7 @@ callable_obj_t *create_history_entry_from_serialized_form (const gchar *entry)
gint token; gint token;
for (ptr = ptr_orig, token = 0; ptr && token < 10; token++, ptr++) for (ptr = ptr_orig, token = 0; ptr && token < 10; token++, ptr++)
switch (token) { switch (token) {
case 0: history_state = get_history_state_from_id (*ptr); break; case 0: history_state = get_history_state_from_id(*ptr); break;
case 1: peer_number = *ptr; break; case 1: peer_number = *ptr; break;
case 2: peer_name = *ptr; break; case 2: peer_name = *ptr; break;
case 3: time_start = *ptr; break; case 3: time_start = *ptr; break;
......
This diff is collapsed.
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "addressbook-config.h" #include "addressbook-config.h"
#include "searchbar.h" #include "searchbar.h"
#include "contacts/addrbookfactory.h" #include "contacts/addrbookfactory.h"
// #include "contacts/addressbook/eds.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -44,44 +43,33 @@ enum { ...@@ -44,44 +43,33 @@ enum {
COLUMN_BOOK_ACTIVE, COLUMN_BOOK_NAME, COLUMN_BOOK_UID COLUMN_BOOK_ACTIVE, COLUMN_BOOK_NAME, COLUMN_BOOK_UID
}; };
void AddressBook_Config *addressbook_config_load_parameters ()
addressbook_config_load_parameters (AddressBook_Config **settings)
{ {
AddressBook_Config *config = g_new0 (AddressBook_Config, 1);
GHashTable *_params = NULL; GHashTable *params = dbus_get_addressbook_settings();
AddressBook_Config *_settings;
if (params == NULL) {
// Allocate a struct config->enable = 1;
_settings = g_new0 (AddressBook_Config, 1); config->max_results = 30;
config->display_contact_photo = 0;
// Fetch the settings from D-Bus config->search_phone_business = 1;
_params = (GHashTable*) dbus_get_addressbook_settings(); config->search_phone_home = 1;
config->search_phone_mobile = 1;
if (_params == NULL) {
DEBUG ("Addressbook: No parameters received, use default");
_settings->enable = 1;
_settings->max_results = 30;
_settings->display_contact_photo = 0;
_settings->search_phone_business = 1;
_settings->search_phone_home = 1;
_settings->search_phone_mobile = 1;
} }
else { else {
_settings->enable = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_ENABLE)); config->enable = (size_t) (g_hash_table_lookup (params, ADDRESSBOOK_ENABLE));
_settings->max_results = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_MAX_RESULTS)); config->max_results = (size_t) (g_hash_table_lookup (params, ADDRESSBOOK_MAX_RESULTS));
_settings->display_contact_photo = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO)); config->display_contact_photo = (size_t) (g_hash_table_lookup (params, ADDRESSBOOK_DISPLAY_CONTACT_PHOTO));
_settings->search_phone_business = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS)); config->search_phone_business = (size_t) (g_hash_table_lookup (params, ADDRESSBOOK_DISPLAY_PHONE_BUSINESS));
_settings->search_phone_home = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_HOME)); config->search_phone_home = (size_t) (g_hash_table_lookup (params, ADDRESSBOOK_DISPLAY_PHONE_HOME));
_settings->search_phone_mobile = (size_t) (g_hash_table_lookup (_params, ADDRESSBOOK_DISPLAY_PHONE_MOBILE)); config->search_phone_mobile = (size_t) (g_hash_table_lookup (params, ADDRESSBOOK_DISPLAY_PHONE_MOBILE));
} }
DEBUG ("Addressbook: Settings: enabled %d, max_result %d, photo %d, business %d, home %d, mobile %d", DEBUG ("Addressbook: Settings: enabled %d, max_result %d, photo %d, business %d, home %d, mobile %d",
_settings->enable, _settings->max_results, _settings->display_contact_photo, config->enable, config->max_results, config->display_contact_photo,
_settings->search_phone_business, _settings->search_phone_home, _settings->search_phone_mobile); config->search_phone_business, config->search_phone_home, config->search_phone_mobile);
*settings = _settings; return config;
} }
void void
...@@ -211,9 +199,8 @@ addressbook_config_book_active_toggled ( ...@@ -211,9 +199,8 @@ addressbook_config_book_active_toggled (
gchar* name; gchar* name;
gchar* uid; gchar* uid;
if(!abookfactory_is_addressbook_loaded()) { if(!addrbook)
return; return;
}
// Get path of clicked book active toggle box // Get path of clicked book active toggle box
treePath = gtk_tree_path_new_from_string (path); treePath = gtk_tree_path_new_from_string (path);
...@@ -223,8 +210,6 @@ addressbook_config_book_active_toggled ( ...@@ -223,8 +210,6 @@ addressbook_config_book_active_toggled (
return; return;
} }
AddrBookFactory *factory = abookfactory_get_factory();
gtk_tree_model_get_iter (model, &iter, treePath); gtk_tree_model_get_iter (model, &iter, treePath);
// Get active value at iteration // Get active value at iteration
...@@ -240,7 +225,7 @@ addressbook_config_book_active_toggled ( ...@@ -240,7 +225,7 @@ addressbook_config_book_active_toggled (
gtk_tree_path_free (treePath); gtk_tree_path_free (treePath);
// Update current memory stored books data // Update current memory stored books data
book_data = factory->addrbook->get_book_data_by_uid(uid); book_data = addrbook->get_book_data_by_uid(uid);
if(book_data == NULL) { if(book_data == NULL) {
ERROR("Addressbook: Error: Could not find addressbook %s", uid); ERROR("Addressbook: Error: Could not find addressbook %s", uid);
} }
...@@ -292,14 +277,11 @@ addressbook_config_fill_book_list() ...@@ -292,14 +277,11 @@ addressbook_config_fill_book_list()
book_data_t *book_data; book_data_t *book_data;
gchar **book_list; gchar **book_list;
if(!abookfactory_is_addressbook_loaded()) { if(!addrbook)
return; return;
}
AddrBookFactory *factory = abookfactory_get_factory();
book_list = dbus_get_addressbook_list(); book_list = dbus_get_addressbook_list();
GSList *books_data = factory->addrbook->get_books_data(book_list); GSList *books_data = addrbook->get_books_data(book_list);
if (!books_data) { if (!books_data) {
DEBUG ("Addressbook: No valid books data (%s:%d)", __FILE__, __LINE__); DEBUG ("Addressbook: No valid books data (%s:%d)", __FILE__, __LINE__);
...@@ -338,7 +320,7 @@ create_addressbook_settings() ...@@ -338,7 +320,7 @@ create_addressbook_settings()
GtkTreeViewColumn *tree_view_column; GtkTreeViewColumn *tree_view_column;
// Load the user value // Load the user value
addressbook_config_load_parameters (&addressbook_config); addressbook_config = addressbook_config_load_parameters();
ret = gtk_vbox_new (FALSE, 10); ret = gtk_vbox_new (FALSE, 10);
gtk_container_set_border_width (GTK_CONTAINER (ret), 10); gtk_container_set_border_width (GTK_CONTAINER (ret), 10);
......
...@@ -67,12 +67,9 @@ void ...@@ -67,12 +67,9 @@ void
addressbook_config_save_parameters (void); addressbook_config_save_parameters (void);
/** /**
* Initialize the address book structure, and retrieve the saved parameters through D-Bus * Return the saved parameters through D-Bus
*
* @param settings The addressbook structure
*/ */
void AddressBook_Config *addressbook_config_load_parameters();
addressbook_config_load_parameters (AddressBook_Config **settings);
gboolean gboolean
addressbook_display (AddressBook_Config *settings, const gchar *field); addressbook_display (AddressBook_Config *settings, const gchar *field);
......
...@@ -285,7 +285,7 @@ create_general_settings () ...@@ -285,7 +285,7 @@ create_general_settings ()
void void
save_configuration_parameters (void) save_configuration_parameters (void)
{ {
if(abookfactory_is_addressbook_loaded()) { if (addrbook) {
// Address book config // Address book config
addressbook_config_save_parameters (); addressbook_config_save_parameters ();
} }
...@@ -410,7 +410,7 @@ show_preferences_dialog () ...@@ -410,7 +410,7 @@ show_preferences_dialog ()
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new (_ ("Shortcuts"))); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new (_ ("Shortcuts")));
gtk_notebook_page_num (GTK_NOTEBOOK (notebook), tab); gtk_notebook_page_num (GTK_NOTEBOOK (notebook), tab);
if(abookfactory_is_addressbook_loaded()) { if(addrbook) {
// Addressbook tab // Addressbook tab
tab = create_addressbook_settings (); tab = create_addressbook_settings ();
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new (_ ("Address Book"))); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), tab, gtk_label_new (_ ("Address Book")));
...@@ -451,7 +451,7 @@ GtkTreeModel* createModel() ...@@ -451,7 +451,7 @@ GtkTreeModel* createModel()