diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 4c3a128d934745a4cc73880f91faa160d635bf57..8213c022f61c045670657df1fbf67b0db8af8aa8 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -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) { diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp index 8ed341cce56429ea1f3a5a32e6cc171ee2e25249..050123f442d28a525de1767900311ca2b8b0bce7 100644 --- a/daemon/src/sip/sipaccount.cpp +++ b/daemon/src/sip/sipaccount.cpp @@ -98,6 +98,7 @@ SIPAccount::SIPAccount(const std::string& accountID) , registrationStateDetailed_() , keepAliveTimer_() , link_(SIPVoIPLink::instance()) + , receivedParameter_() {} void SIPAccount::serialize(Conf::YamlEmitter &emitter) diff --git a/daemon/src/sip/sipaccount.h b/daemon/src/sip/sipaccount.h index 960b47f74fa0de0b544d370a316c055a04561521..fb6980f19d4b8b132a7450d931cb884f1ffd3dc3 100644 --- a/daemon/src/sip/sipaccount.h +++ b/daemon/src/sip/sipaccount.h @@ -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 diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index 1638532c7a712e9364b5af870c7dfdb14fef781c..b1ebcc915342f962d880979053a55d51dae5a02f 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -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; diff --git a/gnome/src/actions.c b/gnome/src/actions.c index 936440d70c31bd402eb3cba09172a881cf517332..78f96a4f9b03faabdb622e1c8e1e9267dab0c452 100644 --- a/gnome/src/actions.c +++ b/gnome/src/actions.c @@ -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);