Commit 173a40fd authored by Tristan Matthews's avatar Tristan Matthews

* #14568: gnome: auto answer feature working

The setting itself is stored in the daemon (and persists in the config
file), but it is up to the client to use it.
parent 5a3731bf
......@@ -59,6 +59,7 @@ const char * const Account::AUTHENTICATION_USERNAME_KEY = "authenticationUsernam
const char * const Account::PASSWORD_KEY = "password";
const char * const Account::HOSTNAME_KEY = "hostname";
const char * const Account::ACCOUNT_ENABLE_KEY = "enable";
const char * const Account::ACCOUNT_AUTOANSWER_KEY = "autoAnswer";
const char * const Account::MAILBOX_KEY = "mailbox";
using std::map;
......@@ -72,6 +73,7 @@ Account::Account(const string &accountID, const string &type) :
, hostname_()
, alias_()
, enabled_(true)
, autoAnswerEnabled_(false)
, type_(type)
, registrationState_(UNREGISTERED)
, audioCodecList_()
......
......@@ -211,6 +211,7 @@ class Account : public Serializable {
static const char * const PASSWORD_KEY;
static const char * const HOSTNAME_KEY;
static const char * const ACCOUNT_ENABLE_KEY;
static const char * const ACCOUNT_AUTOANSWER_KEY;
static const char * const MAILBOX_KEY;
static std::string mapStateNumberToString(RegistrationState state);
......@@ -242,6 +243,9 @@ class Account : public Serializable {
*/
bool enabled_;
/* If true, automatically answer calls to this account */
bool autoAnswerEnabled_;
/*
* The account type
* IAX2 or SIP
......
......@@ -45,6 +45,7 @@ static const char *const CONFIG_ACCOUNT_TYPE = "Account.type"
static const char *const CONFIG_ACCOUNT_ALIAS = "Account.alias";
static const char *const CONFIG_ACCOUNT_MAILBOX = "Account.mailbox";
static const char *const CONFIG_ACCOUNT_ENABLE = "Account.enable";
static const char *const CONFIG_ACCOUNT_AUTOANSWER = "Account.autoAnswer";
static const char *const CONFIG_ACCOUNT_REGISTRATION_EXPIRE = "Account.registrationExpire";
static const char *const CONFIG_ACCOUNT_REGISTRATION_STATUS = "Account.registrationStatus";
static const char *const CONFIG_ACCOUNT_REGISTRATION_STATE_CODE = "Account.registrationCode";
......
......@@ -1359,11 +1359,12 @@ void ManagerImpl::removeWaitingCall(const std::string& id)
void ManagerImpl::incomingCall(Call &call, const std::string& accountId)
{
stopTone();
const std::string callID(call.getCallId());
associateCallToAccount(call.getCallId(), accountId);
associateCallToAccount(callID, accountId);
if (accountId.empty())
setIPToIPForCall(call.getCallId(), true);
setIPToIPForCall(callID, true);
else {
// strip sip: which is not required and bring confusion with ip to ip calls
// when placing new call from history (if call is IAX, do nothing)
......@@ -1381,12 +1382,12 @@ void ManagerImpl::incomingCall(Call &call, const std::string& accountId)
ringtone(accountId);
}
addWaitingCall(call.getCallId());
addWaitingCall(callID);
std::string number(call.getPeerNumber());
std::string from("<" + number + ">");
dbus_.getCallManager()->incomingCall(accountId, call.getCallId(), call.getDisplayName() + " " + from);
dbus_.getCallManager()->incomingCall(accountId, callID, call.getDisplayName() + " " + from);
}
......
This diff is collapsed.
......@@ -55,6 +55,9 @@ static const char *const CONFIG_RINGTONE_PATH = "Account.ringtone
static const char *const CONFIG_RINGTONE_ENABLED = "Account.ringtoneEnabled";
static const char *const CONFIG_KEEP_ALIVE_ENABLED = "Account.keepAliveEnabled";
static const char *const CONFIG_DEFAULT_REGISTRATION_EXPIRE = "60";
static const char *const CONFIG_ACCOUNT_HOSTNAME = "Account.hostname";
static const char *const CONFIG_ACCOUNT_USERNAME = "Account.username";
static const char *const CONFIG_ACCOUNT_ROUTESET = "Account.routeset";
......@@ -62,19 +65,23 @@ static const char *const CONFIG_ACCOUNT_PASSWORD = "Account.password
static const char *const CONFIG_ACCOUNT_REALM = "Account.realm";
static const char *const CONFIG_ACCOUNT_DEFAULT_REALM = "*";
static const char *const CONFIG_ACCOUNT_USERAGENT = "Account.useragent";
static const char *const CONFIG_ACCOUNT_AUTOANSWER = "Account.autoAnswer";
static const char *const CONFIG_LOCAL_INTERFACE = "Account.localInterface";
static const char *const CONFIG_INTERFACE = "Account.interface";
static const char *const CONFIG_PUBLISHED_SAMEAS_LOCAL = "Account.publishedSameAsLocal";
static const char *const CONFIG_LOCAL_PORT = "Account.localPort";
static const char *const CONFIG_PUBLISHED_PORT = "Account.publishedPort";
static const char *const CONFIG_PUBLISHED_ADDRESS = "Account.publishedAddress";
static const char *const CONFIG_DEFAULT_LOCAL_PORT = "5060";
static const char *const CONFIG_DEFAULT_PUBLISHED_PORT = "5060";
static const char *const CONFIG_DEFAULT_PUBLISHED_SAMEAS_LOCAL = "true";
static const char *const CONFIG_DEFAULT_INTERFACE = "default";
static const char *const CONFIG_DISPLAY_NAME = "Account.displayName";
static const char *const CONFIG_DEFAULT_ADDRESS = "0.0.0.0";
// SIP specific parameters
static const char *const CONFIG_SIP_PROXY = "SIP.proxy";
static const char *const CONFIG_SIP_AUTOANSWER = "SIP.autoAnswer";
static const char *const CONFIG_STUN_SERVER = "STUN.server";
static const char *const CONFIG_STUN_ENABLE = "STUN.enable";
......
......@@ -303,6 +303,11 @@ gboolean current_account_has_new_message(void)
return current && current->_messages_number > 0;
}
gboolean account_has_autoanswer_on(const account_t *account)
{
return g_strcmp0(account_lookup(account, CONFIG_ACCOUNT_AUTOANSWER), "true") == 0;
}
gboolean account_is_IP2IP(const account_t *account)
{
g_assert(account);
......
......@@ -183,6 +183,7 @@ void current_account_set_message_number(guint nb);
gboolean current_account_has_new_message(void);
gboolean account_has_autoanswer_on(const account_t *account);
gboolean account_is_IP2IP(const account_t *account);
gboolean account_is_SIP(const account_t *account);
gboolean account_is_IAX(const account_t *account);
......
......@@ -513,6 +513,11 @@ sflphone_incoming_call(callable_obj_t * c)
statusbar_push_message(msg , NULL, __MSG_ACCOUNT_DEFAULT);
g_free(msg);
}
account_t *account = account_list_get_by_id(c->_accountID);
if (account_has_autoanswer_on(account)) {
calltab_set_selected_call(active_calltree_tab, c);
sflphone_pick_up();
}
}
static void
......
......@@ -127,7 +127,7 @@ static void reset()
static void
auto_answer_cb(GtkToggleButton *widget, account_t *account)
{
account_replace(account, CONFIG_SIP_AUTOANSWER,
account_replace(account, CONFIG_ACCOUNT_AUTOANSWER,
gtk_toggle_button_get_active(widget) ? "true" : "false");
}
......@@ -379,6 +379,7 @@ create_basic_tab(account_t *account)
row++;
GtkWidget *auto_answer_checkbox = gtk_check_button_new_with_mnemonic(_("_Auto-answer calls"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auto_answer_checkbox), account_has_autoanswer_on(account));
g_signal_connect(auto_answer_checkbox, "toggled", G_CALLBACK(auto_answer_cb), account);
gtk_table_attach(GTK_TABLE(table), auto_answer_checkbox, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
......
......@@ -80,6 +80,13 @@ calltab_get_selected_type(calltab_t* tab)
return tab->selectedType;
}
void
calltab_set_selected_call(calltab_t *tab, callable_obj_t *call)
{
g_assert(tab);
tab->selectedCall = call;
}
callable_obj_t *
calltab_get_selected_call(calltab_t *tab)
{
......
......@@ -59,6 +59,9 @@ calltab_get_selected_type (calltab_t *);
callable_obj_t *
calltab_get_selected_call (calltab_t *);
void
calltab_set_selected_call (calltab_t *, callable_obj_t *call);
conference_obj_t *
calltab_get_selected_conf (calltab_t *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment