Commit 3eb4d41a authored by Emmanuel Lepage's avatar Emmanuel Lepage
Browse files
parents c270b1d6 53622593
......@@ -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.
int oldPid;
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;
}
fclose (fp);
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;
}
}
......@@ -140,11 +140,11 @@ main (int argc, char **argv)
try {
Manager::instance().init();
} catch (std::exception &e) {
} catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
return 1;
} catch (...) {
fprintf (stderr, "An exception occured when initializing the system.");
std::cerr << "An exception occured when initializing the system." << std::endl;
return 1;
}
......
......@@ -31,7 +31,6 @@
<listOptionValue builtIn="false" value="/usr/include/libgnome-2.0"/>
<listOptionValue builtIn="false" value="/usr/include/libgnomeui-2.0"/>
<listOptionValue builtIn="false" value="/usr/include"/>
<listOptionValue builtIn="false" value="/usr/include/evolution-data-server-2.30"/>
</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">
<listOptionValue builtIn="false" value="&quot;ICONS_DIR=&quot;/usr/share/sflphone\&quot;"/>
......
......@@ -62,7 +62,7 @@
#include "widget/imwidget.h"
static GHashTable * ip2ip_profile=NULL;
static GHashTable * ip2ip_profile;
static gchar ** sflphone_order_history_hash_table(GHashTable *result)
{
......@@ -138,7 +138,7 @@ sflphone_notify_voice_mail (const gchar* accountID , guint count)
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:")) {
gchar * new_number = g_strconcat ("sip:", c->_peer_number, NULL);
g_free (c->_peer_number);
......@@ -333,7 +333,7 @@ gboolean sflphone_init (GError **error)
if (!dbus_connect (error) || !dbus_register (getpid (), "Gtk+ Client", error))
return FALSE;
abookfactory_init_factory();
abook_init();
// Init icons factory
init_icon_factory ();
......@@ -414,7 +414,6 @@ sflphone_hang_up()
call_remove_all_errors (selectedCall);
selectedCall->_state = CALL_STATE_DIALING;
DEBUG ("from sflphone_hang_up : ");
stop_notification();
break;
case CALL_STATE_TRANSFER:
dbus_hang_up (selectedCall);
......@@ -465,7 +464,6 @@ sflphone_pick_up()
}
dbus_accept (selectedCall);
stop_notification();
break;
case CALL_STATE_TRANSFER:
dbus_transfer (selectedCall);
......@@ -766,11 +764,9 @@ sflphone_keypad (guint keyval, gchar * key)
c->_history_state = INCOMING;
calltree_update_call (history, c, NULL);
dbus_accept (c);
stop_notification();
break;
case GDK_Escape:
dbus_refuse (c);
stop_notification();
break;
}
......@@ -825,15 +821,14 @@ sflphone_keypad (guint keyval, gchar * key)
break;
}
} else {
} else
sflphone_new_call();
}
}
static void place_direct_call (const callable_obj_t * c)
{
assert(c->_state == CALL_STATE_DIALING);
dbus_place_call (c);
g_assert(c->_state == CALL_STATE_DIALING);
dbus_place_call(c);
}
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");
if (g_strcasecmp (c->_accountID, "") != 0) {
if (strlen(c->_accountID) != 0) {
DEBUG ("Actions: Account %s already set for this call", c->_accountID);
current = account_list_get_by_id (c->_accountID);
} else {
......@@ -1055,40 +1050,29 @@ sflphone_rec_call()
void sflphone_fill_codec_list ()
{
guint account_list_size;
guint i;
account_t *current = NULL;
guint account_list_size = account_list_get_size();
DEBUG ("SFLphone: Fill codec list");
account_list_size = account_list_get_size ();
for (i=0; i<account_list_size; i++) {
current = account_list_get_nth (i);
for (guint i = 0; i < account_list_size; i++) {
account_t *current = account_list_get_nth(i);
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** pl;
GQueue *codeclist;
gchar **order = dbus_get_active_audio_codec_list(account->accountID);
order = (gchar**) dbus_get_active_audio_codec_list ( (*account)->accountID);
codeclist = (*account)->codecs;
GQueue *codeclist = account->codecs;
// First clean the list
codec_list_clear (&codeclist);
codec_list_clear(&codeclist);
if (!(*order))
ERROR ("SFLphone: No codec list provided");
else {
for (pl = order; *pl; pl++) {
for (gchar **pl = order; *pl; pl++) {
codec_t * cpy = NULL;
// 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)
guint caps_size = codec_list_get_size ();
guint i;
for (i = 0; i < caps_size; i++) {
for (guint i = 0; i < caps_size; i++) {
codec_t * current_cap = capabilities_get_nth (i);
// 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)
codec_list_add (current_cap, &codeclist);
}
}
(*account)->codecs = codeclist;
account->codecs = codeclist;
}
void sflphone_fill_call_list (void)
......@@ -1367,9 +1350,8 @@ sflphone_request_go_clear (void)
{
callable_obj_t * selectedCall = calltab_get_selected_call (current_calls);
if (selectedCall) {
if (selectedCall)
dbus_request_go_clear (selectedCall);
}
}
void
......@@ -1389,37 +1371,3 @@ sflphone_call_state_changed (callable_obj_t * c, const gchar * description, cons
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 @@
#include <libintl.h>
#include <locale.h>
#include <accountlist.h>
#include <codeclist.h>
#include <sflphone_const.h>
#include <conference_obj.h>
#define UC(b) (((int)b)&0xff)
#include "accountlist.h"
#include "codeclist.h"
#include "sflphone_const.h"
#include "conference_obj.h"
/** @file actions.h
* @brief General functions that change the state of the application.
......@@ -191,8 +188,7 @@ void sflphone_set_current_account();
*/
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();
......@@ -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);
/**
* 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
......
......@@ -177,7 +177,7 @@ callable_obj_t *create_history_entry_from_serialized_form (const gchar *entry)
gint token;
for (ptr = ptr_orig, token = 0; ptr && token < 10; token++, ptr++)
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 2: peer_name = *ptr; break;
case 3: time_start = *ptr; break;
......
......@@ -31,17 +31,14 @@
* as that of the covered work.
*/
#include <actions.h>
#include <mainwindow.h>
#include <accountlist.h>
#include <audioconf.h>
#include <accountconfigdialog.h>
#include <zrtpadvanceddialog.h>
#include <tlsadvanceddialog.h>
#include <audioconf.h>
#include <assert.h>
#include "actions.h"
#include "mainwindow.h"
#include "accountlist.h"
#include "audioconf.h"
#include "accountconfigdialog.h"
#include "zrtpadvanceddialog.h"
#include "tlsadvanceddialog.h"
#include "audioconf.h"
// From version 2.16, gtk provides the functionalities libsexy used to provide
#if GTK_CHECK_VERSION(2,16,0)
......@@ -49,6 +46,10 @@
#include <libsexy/sexy-icon-entry.h>
#endif
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <string.h>
#include <dbus/dbus.h>
#include <config.h>
......@@ -62,55 +63,45 @@
* in a private structure.
* Local variables
*/
GtkDialog * dialog;
GtkWidget * hbox;
GtkWidget * label;
GtkWidget * entryID;
GtkWidget * entryAlias;
GtkWidget * protocolComboBox;
GtkWidget * entryUsername;
GtkWidget * entryRouteSet;
GtkWidget * entryHostname;
GtkWidget * entryPassword;
GtkWidget * entryMailbox;
GtkWidget * entryUseragent;
GtkWidget * entryResolveNameOnlyOnce;
GtkWidget * expireSpinBox;
GtkListStore * credentialStore = NULL;
GtkWidget * deleteCredButton;
GtkWidget * treeViewCredential;
// GtkWidget * scrolledWindowCredential;
GtkWidget * advancedZrtpButton;
GtkWidget * keyExchangeCombo;
GtkWidget * useSipTlsCheckBox;
GtkWidget * localAddressEntry;
GtkWidget * publishedAddressEntry;
GtkWidget * localAddressLabel;
GtkWidget * localAddressCombo;
GtkWidget * useStunCheckBox;
GtkWidget * sameAsLocalRadioButton;
GtkWidget * publishedAddrRadioButton;
GtkWidget * sameAsLocalLabel;
GtkWidget * publishedAddrLabel;
GtkWidget * publishedPortSpinBox;
GtkWidget * localPortLabel;
GtkWidget * localPortSpinBox;
GtkWidget * publishedAddressLabel;
GtkWidget * publishedPortLabel;
GtkWidget * stunServerLabel;
GtkWidget * stunServerEntry;
GtkWidget * enableTone;
GtkWidget * fileChooser;
GtkWidget * displayNameEntry;
GtkWidget * security_tab;
GtkWidget * advanced_tab;
GtkWidget * overrtp;
GHashTable * directIpCallsProperties = NULL;
static GtkDialog * dialog;
static GtkWidget * hbox;
static GtkWidget * label;
static GtkWidget * entryAlias;
static GtkWidget * protocolComboBox;
static GtkWidget * entryUsername;
static GtkWidget * entryRouteSet;
static GtkWidget * entryHostname;
static GtkWidget * entryPassword;
static GtkWidget * entryMailbox;
static GtkWidget * entryUseragent;
static GtkWidget * entryResolveNameOnlyOnce;
static GtkWidget * expireSpinBox;
static GtkListStore * credentialStore;
static GtkWidget * deleteCredButton;
static GtkWidget * treeViewCredential;
static GtkWidget * advancedZrtpButton;
static GtkWidget * keyExchangeCombo;
static GtkWidget * useSipTlsCheckBox;
static GtkWidget * localAddressEntry;
static GtkWidget * publishedAddressEntry;
static GtkWidget * localAddressCombo;
static GtkWidget * useStunCheckBox;
static GtkWidget * sameAsLocalRadioButton;
static GtkWidget * publishedAddrRadioButton;
static GtkWidget * publishedPortSpinBox;
static GtkWidget * localPortSpinBox;
static GtkWidget * publishedAddressLabel;
static GtkWidget * publishedPortLabel;
static GtkWidget * stunServerLabel;
static GtkWidget * stunServerEntry;
static GtkWidget * enableTone;
static GtkWidget * fileChooser;
static GtkWidget * security_tab;
static GtkWidget * advanced_tab;
static GtkWidget * overrtp;
// Credentials
enum {
......@@ -139,98 +130,81 @@ static void reset()
/*
* Display / Hide the password
*/
static void show_password_cb (GtkWidget *widget UNUSED, gpointer data)
static void show_password_cb(GtkWidget *widget UNUSED, gpointer data)
{
gtk_entry_set_visibility (GTK_ENTRY (data), !gtk_entry_get_visibility (GTK_ENTRY (data)));
gtk_entry_set_visibility(GTK_ENTRY(data), !gtk_entry_get_visibility(GTK_ENTRY(data)));
}
/* Signal to protocolComboBox 'changed' */
void change_protocol_cb (account_t *currentAccount UNUSED)
void change_protocol_cb(account_t *currentAccount UNUSED)
{
gchar *protocol = gtk_combo_box_get_active_text (GTK_COMBO_BOX (protocolComboBox));
gchar *protocol = gtk_combo_box_get_active_text(GTK_COMBO_BOX(protocolComboBox));
// Only if tabs are not NULL
if (security_tab && advanced_tab) {
if (g_strcasecmp (protocol, "IAX") == 0) {
gtk_widget_hide (GTK_WIDGET (security_tab));
gtk_widget_hide (GTK_WIDGET (advanced_tab));
if (g_strcasecmp(protocol, "IAX") == 0) {
gtk_widget_hide(security_tab);
gtk_widget_hide(advanced_tab);
} else {
gtk_widget_show (GTK_WIDGET (security_tab));
gtk_widget_show (GTK_WIDGET (advanced_tab));
gtk_widget_show(security_tab);
gtk_widget_show(advanced_tab);
}
}
g_free(protocol);
}
int
is_iax_enabled (void)
{
int res = dbus_is_iax2_enabled();
if (res == 1)
return TRUE;
else
return FALSE;
}
void
select_dtmf_type (void)
select_dtmf_type(void)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (overrtp)))
DEBUG ("Selected DTMF over RTP");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(overrtp)))
DEBUG("Selected DTMF over RTP");
else
DEBUG ("Selected DTMF over SIP");
DEBUG("Selected DTMF over SIP");
}
static GPtrArray* getNewCredential (void)
static GPtrArray* getNewCredential(void)
{
GtkTreeIter iter;
gint row_count = 0;
GPtrArray *credential_array = g_ptr_array_new ();
GPtrArray *credential_array = g_ptr_array_new();
gboolean valid;
for (valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (credentialStore), &iter) ;
valid ;
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (credentialStore), &iter)
) {
for (valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(credentialStore), &iter) ;
valid;
valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(credentialStore), &iter)) {
gchar *username;
gchar *realm;
gchar *password;
gtk_tree_model_get (GTK_TREE_MODEL (credentialStore), &iter,
gtk_tree_model_get(GTK_TREE_MODEL(credentialStore), &iter,
COLUMN_CREDENTIAL_REALM, &realm,
COLUMN_CREDENTIAL_USERNAME, &username,
COLUMN_CREDENTIAL_PASSWORD, &password,
-1);
DEBUG ("Row %d: %s %s %s", row_count++, username, password, realm);
DEBUG("Row %d: %s %s %s", row_count++, username, password, realm);
GHashTable * new_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
g_hash_table_insert (new_table, g_strdup (ACCOUNT_REALM), realm);
g_hash_table_insert (new_table, g_strdup (ACCOUNT_USERNAME), username);
g_hash_table_insert (new_table, g_strdup (ACCOUNT_PASSWORD), password);
GHashTable * new_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
g_hash_table_insert(new_table, g_strdup(ACCOUNT_REALM), realm);
g_hash_table_insert(new_table, g_strdup(ACCOUNT_USERNAME), username);
g_hash_table_insert(new_table, g_strdup(ACCOUNT_PASSWORD), password);
g_ptr_array_add (credential_array, new_table);
g_ptr_array_add(credential_array, new_table);
}
return credential_array;
}
static void update_credential_cb (GtkWidget *widget, gpointer data UNUSED)
static void update_credential_cb(GtkWidget *widget, gpointer data UNUSED)
{
GtkTreeIter iter;
if (credentialStore) {
if (gtk_tree_model_get_iter_from_string ( (GtkTreeModel *) credentialStore, &iter, "0")) {
gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "column"));
gtk_list_store_set (GTK_LIST_STORE (credentialStore), &iter, column, (gchar *) gtk_entry_get_text (GTK_ENTRY (widget)), -1);
}
if (credentialStore && gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(credentialStore), &iter, "0")) {
gint column = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "column"));
gtk_list_store_set(GTK_LIST_STORE(credentialStore), &iter, column,(gchar *) gtk_entry_get_text(GTK_ENTRY(widget)), -1);
}
}
static GtkWidget* create_basic_tab (account_t *currentAccount)
static GtkWidget* create_basic_tab(account_t *currentAccount)
{
GtkWidget * frame;
GtkWidget * table;
......@@ -240,440 +214,433 @@ static GtkWidget* create_basic_tab (account_t *currentAccount)
GtkWidget *image;
#endif
// Default settings
gchar *curAccountType;
gchar *curAlias;
gchar *curUsername;
gchar *curHostname;
gchar *curPassword;
/* TODO: add curProxy, and add boxes for Proxy support */
gchar *curMailbox;
gchar *curUseragent;
gchar *curRouteSet;
int row = 0;
assert(currentAccount);
DEBUG ("Config: Create basic account tab");
g_assert(currentAccount);
DEBUG("Config: Create basic account tab");
// Load from SIP/IAX/Unknown ?
curAccountType = g_hash_table_lookup (currentAccount->properties, ACCOUNT_TYPE);
curAlias = g_hash_table_lookup (currentAccount->properties, ACCOUNT_ALIAS);
curHostname = g_hash_table_lookup (currentAccount->properties, ACCOUNT_HOSTNAME);
if (g_strcmp0 (curAccountType, "SIP") == 0) {
gchar *curAccountType = g_hash_table_lookup(currentAccount->properties, ACCOUNT_TYPE);
gchar *curAlias = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ALIAS);
gchar *curHostname = g_hash_table_lookup(currentAccount->properties, ACCOUNT_HOSTNAME);
gchar *curPassword;
gchar *curUsername;
gchar *curUseragent;
gchar *curRouteSet;
gchar *curMailbox;
if (g_strcmp0(curAccountType, "SIP") == 0) {
/* get password from credentials list */
if (currentAccount->credential_information) {
GHashTable * element = g_ptr_array_index (currentAccount->credential_information, 0);
curPassword = g_hash_table_lookup (element, ACCOUNT_PASSWORD);
} else {
curPassword = "";
}
} else {
curPassword = g_hash_table_lookup (currentAccount->properties, ACCOUNT_PASSWORD);
}
curUsername = g_hash_table_lookup (currentAccount->properties, ACCOUNT_USERNAME);
GHashTable * element = g_ptr_array_index(currentAccount->credential_information, 0);
curPassword = g_hash_table_lookup(element, ACCOUNT_PASSWORD);
} else
curPassword = "";
} else
curPassword = g_hash_table_lookup(currentAccount->properties, ACCOUNT_PASSWORD);
curUsername = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERNAME);
curRouteSet = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ROUTE);
curMailbox = g_hash_table_lookup (currentAccount->properties, ACCOUNT_MAILBOX);
curMailbox = g_hash_table_lookup(currentAccount->properties, ACCOUNT_MAILBOX);
curMailbox = curMailbox != NULL ? curMailbox : "";
curUseragent = g_hash_table_lookup (currentAccount->properties, ACCOUNT_USERAGENT);
curUseragent = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERAGENT);
gnome_main_section_new (_ ("Account Parameters"), &frame);
gtk_widget_show (frame);
gnome_main_section_new(_("Account Parameters"), &frame);
gtk_widget_show(frame);