Commit bf28b8a9 authored by Tristan Matthews's avatar Tristan Matthews
parents 7db69f10 90cc0a5e
......@@ -226,7 +226,6 @@ bool ManagerImpl::outgoingCall(const std::string& account_id,
try {
Call *call = getAccountLink(account_id)->newOutgoingCall(call_id, to_cleaned);
switchCall(call_id);
call->setConfId(conf_id);
} catch (const VoipLinkException &e) {
......
......@@ -98,6 +98,7 @@ SIPAccount::SIPAccount(const std::string& accountID)
, registrationStateDetailed_()
, keepAliveTimer_()
, link_(SIPVoIPLink::instance())
, receivedParameter_()
{}
void SIPAccount::serialize(Conf::YamlEmitter &emitter)
......
......@@ -497,6 +497,14 @@ class SIPAccount : public Account {
return zrtpHelloHash_;
}
void setReceivedParameter(std::string received) {
receivedParameter_ = received;
}
std::string getReceivedParameter() {
return receivedParameter_;
}
/**
* Timer used to periodically send re-register request based
* on the "Expire" sip header (or the "expire" Contact parameter)
......@@ -720,6 +728,11 @@ class SIPAccount : public Account {
* Voice over IP Link contains a listener thread and calls
*/
SIPVoIPLink* link_;
/**
* Received via parameters
*/
std::string receivedParameter_;
};
#endif
......@@ -515,6 +515,9 @@ void SIPVoIPLink::sendRegister(Account *a)
std::string contact(account->getContactHeader());
pj_str_t pjContact = pj_str((char*) contact.c_str());
std::string received(account->getReceivedParameter());
pj_str_t pjReceived = pj_str((char *) received.c_str());
if (pjsip_regc_init(regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, account->getRegistrationExpire()) != PJ_SUCCESS)
throw VoipLinkException("Unable to initialize account registration structure");
......@@ -1560,6 +1563,18 @@ void update_contact_header(pjsip_regc_cbparam *param, SIPAccount *account)
pj_pool_release(pool);
}
static void looksForReceivedParameter(pjsip_regc_cbparam *param, SIPAccount *account) {
pj_str_t receivedValue = param->rdata->msg_info.via->recvd_param;
std::string publicIpFromReceived = "";
ERROR("looksForReceivedParameter");
if(receivedValue.slen) {
publicIpFromReceived = std::string(receivedValue.ptr, receivedValue.slen);
DEBUG("Cool received received parameter... uhhh?, the value is %s", publicIpFromReceived.c_str());
account->setReceivedParameter(publicIpFromReceived);
}
}
void registration_cb(pjsip_regc_cbparam *param)
{
if (param == NULL) {
......@@ -1599,6 +1614,7 @@ void registration_cb(pjsip_regc_cbparam *param)
if (param->code < 0 || param->code >= 300) {
switch (param->code) {
case 606:
looksForReceivedParameter(param, account);
account->setRegistrationState(ErrorNotAcceptable);
break;
......
......@@ -752,7 +752,7 @@ static void place_direct_call(const callable_obj_t * c)
static int place_registered_call(callable_obj_t * c)
{
account_t * current = NULL;
account_t * account = NULL;
if (c->_state != CALL_STATE_DIALING)
return -1;
......@@ -760,51 +760,54 @@ static int place_registered_call(callable_obj_t * c)
if (!*c->_peer_number)
return -1;
// No longer usefull
/*
if (account_list_get_size() == 0) {
notify_no_accounts();
sflphone_fail(c);
return -1;
}
*/
/*
if (account_list_get_by_state(ACCOUNT_STATE_REGISTERED) == NULL) {
DEBUG("Actions: No registered account, cannot make a call");
notify_no_registered_accounts();
sflphone_fail(c);
return -1;
}
*/
DEBUG("Actions: Get account for this call");
if (strlen(c->_accountID) != 0) {
DEBUG("Actions: Account %s already set for this call", c->_accountID);
current = account_list_get_by_id(c->_accountID);
account = account_list_get_by_id(c->_accountID);
} else {
DEBUG("Actions: No account set for this call, use first of the list");
current = account_list_get_current();
account = account_list_get_current();
}
if (current == NULL) {
if (account == NULL) {
DEBUG("Actions: Unexpected condition: account_t is NULL in %s at %d for accountID %s", __FILE__, __LINE__, c->_accountID);
return -1;
}
gpointer status = g_hash_table_lookup(current->properties, "Status");
gpointer status = g_hash_table_lookup(account->properties, "Status");
if (utf8_case_equal(status, "REGISTERED")) {
/* The call is made with the current account */
// free memory for previous account id and get a new one
g_free(c->_accountID);
c->_accountID = g_strdup(current->accountID);
c->_accountID = g_strdup(account->accountID);
dbus_place_call(c);
} else {
/* Place the call with the first registered account
* and switch the current account.
* If we are here, we can be sure that there is at least one.
*/
current = account_list_get_by_state(ACCOUNT_STATE_REGISTERED);
account = account_list_get_by_state(ACCOUNT_STATE_REGISTERED);
g_free(c->_accountID);
c->_accountID = g_strdup(current->accountID);
c->_accountID = g_strdup(account->accountID);
dbus_place_call(c);
notify_current_account(current);
notify_current_account(account);
}
c->_history_state = g_strdup(OUTGOING_STRING);
......
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