Commit 2fce6bfc authored by Tristan Matthews's avatar Tristan Matthews

Merge branch 'master' of...

Merge branch 'master' of git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone into video_preview
parents fa4617b2 2cbee41e
......@@ -51,7 +51,10 @@ void NetworkManager::StateChanged(const uint32_t &state)
void NetworkManager::PropertiesChanged(const std::map<std::string, ::DBus::Variant> &argin0)
{
WARN("Properties changed: %s", argin0.begin()->first.c_str());
WARN("Properties changed: ");
for (std::map<std::string, ::DBus::Variant>::const_iterator iter = argin0.begin();
iter != argin0.end(); ++iter)
WARN("%s", iter->first.c_str());
Manager::instance().registerAccounts();
}
......
......@@ -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)
......@@ -419,7 +420,7 @@ void SIPAccount::setAccountDetails(std::map<std::string, std::string> details)
publishedIpAddress_ = details[CONFIG_PUBLISHED_ADDRESS];
localPort_ = atoi(details[CONFIG_LOCAL_PORT].c_str());
publishedPort_ = atoi(details[CONFIG_PUBLISHED_PORT].c_str());
if(stunServer_ != details[CONFIG_STUN_SERVER]) {
if (stunServer_ != details[CONFIG_STUN_SERVER]) {
DEBUG("Stun server changed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
link_->sipTransport.destroyStunResolver(stunServer_);
// pj_stun_sock_destroy(pj_stun_sock *stun_sock);
......
......@@ -469,7 +469,7 @@ class SIPAccount : public Account {
* @param The public IPV4 address in the standard dot notation.
* @return void
*/
void setPublishedAddress(const std::string& publishedIpAddress) {
void setPublishedAddress(const std::string &publishedIpAddress) {
publishedIpAddress_ = publishedIpAddress;
}
......@@ -497,6 +497,14 @@ class SIPAccount : public Account {
return zrtpHelloHash_;
}
void setReceivedParameter(const std::string &received) {
receivedParameter_ = received;
}
std::string getReceivedParameter() const {
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
......@@ -342,10 +342,14 @@ void SipTransport::createSipTransport(SIPAccount &account)
}
if (!account.transport_) {
DEBUG("SipTransport: Looking into previously created transport map for %s:%d",
account.getLocalInterface().c_str(), account.getLocalPort());
std::ostringstream key;
key << account.getLocalInterface();
key << ":";
key << account.getLocalPort();
DEBUG("SipTransport: Looking into previously created transport map for"
" %s", key.str().c_str());
// Could not create new transport, this transport may already exists
pjsip_transport *cachedTransport = transportMap_[account.getLocalPort()];
pjsip_transport *cachedTransport = transportMap_[key.str()];
if (cachedTransport) {
account.transport_ = cachedTransport;
......@@ -418,7 +422,8 @@ SipTransport::createUdpTransport(const std::string &interface, unsigned int port
std::ostringstream fullAddress;
fullAddress << listeningAddress << ":" << listeningPort;
pj_str_t udpString;
pj_cstr(&udpString, fullAddress.str().c_str());
std::string fullAddressStr(fullAddress.str());
pj_cstr(&udpString, fullAddressStr.c_str());
pj_sockaddr boundAddr;
pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &udpString, &boundAddr);
pj_status_t status;
......@@ -435,10 +440,10 @@ SipTransport::createUdpTransport(const std::string &interface, unsigned int port
}
}
DEBUG("SipTransport: Listening address %s, listening port %d", listeningAddress.c_str(), listeningPort);
DEBUG("SipTransport: Listening address %s", fullAddressStr.c_str());
// dump debug information to stdout
pjsip_tpmgr_dump_transports(pjsip_endpt_get_tpmgr(endpt_));
transportMap_[listeningPort] = transport;
transportMap_[fullAddressStr] = transport;
return transport;
}
......
......@@ -169,7 +169,7 @@ class SipTransport {
* UDP Transports are stored in this map in order to retreive them in case
* several accounts would share the same port number.
*/
std::map<pj_uint16_t, pjsip_transport*> transportMap_;
std::map<std::string, pjsip_transport*> transportMap_;
/**
* Stun resolver array
......
......@@ -524,6 +524,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");
......@@ -1632,6 +1635,17 @@ void update_contact_header(pjsip_regc_cbparam *param, SIPAccount *account)
pj_pool_release(pool);
}
void lookForReceivedParameter(pjsip_regc_cbparam *param, SIPAccount *account)
{
pj_str_t receivedValue = param->rdata->msg_info.via->recvd_param;
if (receivedValue.slen) {
std::string publicIpFromReceived(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) {
......@@ -1670,22 +1684,23 @@ void registration_cb(pjsip_regc_cbparam *param)
if (param->code < 0 || param->code >= 300) {
switch (param->code) {
case 606:
case PJSIP_SC_NOT_ACCEPTABLE_ANYWHERE:
lookForReceivedParameter(param, account);
account->setRegistrationState(ErrorNotAcceptable);
break;
case 503:
case 408:
case PJSIP_SC_SERVICE_UNAVAILABLE:
case PJSIP_SC_REQUEST_TIMEOUT:
account->setRegistrationState(ErrorHost);
break;
case 401:
case 403:
case 404:
case PJSIP_SC_UNAUTHORIZED:
case PJSIP_SC_FORBIDDEN:
case PJSIP_SC_NOT_FOUND:
account->setRegistrationState(ErrorAuth);
break;
case 423:
case PJSIP_SC_INTERVAL_TOO_BRIEF:
// Expiration Interval Too Brief
account->doubleRegistrationExpire();
account->registerVoIPLink();
......
......@@ -740,15 +740,12 @@ sflphone_keypad(guint keyval, gchar * key)
sflphone_new_call();
}
static void place_direct_call(const callable_obj_t * c)
int
sflphone_place_call(callable_obj_t * c)
{
g_assert(c->_state == CALL_STATE_DIALING);
dbus_place_call(c);
}
account_t * account = NULL;
static int place_registered_call(callable_obj_t * c)
{
account_t * current = NULL;
DEBUG("Actions: Placing call with %s @ %s and accountid %s", c->_display_name, c->_peer_number, c->_accountID);
if (c->_state != CALL_STATE_DIALING)
return -1;
......@@ -756,51 +753,38 @@ static int place_registered_call(callable_obj_t * c)
if (!*c->_peer_number)
return -1;
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);
......@@ -808,26 +792,6 @@ static int place_registered_call(callable_obj_t * c)
return 0;
}
void
sflphone_place_call(callable_obj_t * c)
{
DEBUG("Actions: Placing call with %s @ %s and accountid %s", c->_display_name, c->_peer_number, c->_accountID);
if (place_registered_call(c) < 0)
DEBUG("An error occured while placing registered call in %s at %d", __FILE__, __LINE__);
/*
if (is_direct_call(c)) {
gchar *msg = g_markup_printf_escaped(_("Direct SIP call"));
statusbar_pop_message(__MSG_ACCOUNT_DEFAULT);
statusbar_push_message(msg , NULL, __MSG_ACCOUNT_DEFAULT);
g_free(msg);
place_direct_call(c);
} else if (place_registered_call(c) < 0)
DEBUG("An error occured while placing registered call in %s at %d", __FILE__, __LINE__);
*/
}
void
sflphone_detach_participant(const gchar* callID)
{
......
......@@ -157,7 +157,7 @@ void sflphone_keypad(guint keyval, gchar * key);
* Place a call with a filled callable_obj_t.to
* @param c A call in CALL_STATE_DIALING state
*/
void sflphone_place_call(callable_obj_t * c);
int sflphone_place_call(callable_obj_t * c);
/**
* Fetch the ip2ip profile through dbus and fill
......
......@@ -539,7 +539,7 @@ static void use_sip_tls_cb(GtkWidget *widget, gpointer data)
static gchar *
get_interface_addr_from_name(const gchar * const iface_name)
{
#define UC(b) (((int)b)&0xff)
#define UC(b) (((int)b)&0xff)
int fd;
......
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