Commit 8a708851 authored by Guillaume Roguez's avatar Guillaume Roguez

fix account type checkings

Account::getAccountType() returns a raw pointer on char,
but we use it with simple operators like == or != to check
the semantic behind. This results to pointer comparaison
and not "string" comparaison, causing many bugs.

Fixed by changing the comparaison operators by "strcmp" function.

Change-Id: I74baba083af0159d445c1505ddd5df55e6ca4fa7
Tuleap: #1575
Reviewed-by: Philippe Gorley's avatarPhilippe Gorley <>
parent f8a70740
......@@ -76,12 +76,12 @@ AccountFactory::isSupportedType(const char* const name) const
AccountFactory::removeAccount(Account& account)
const auto account_type = account.getAccountType();
const auto* account_type = account.getAccountType();
std::lock_guard<std::recursive_mutex> lock(mutex_);
const auto& id = account.getAccountID();
RING_DBG("Removing account %s", id.c_str());
auto& map =;
auto& map =;
RING_DBG("Remaining %zu %s account(s)", map.size(), account_type);
......@@ -3023,12 +3023,12 @@ Manager::newOutgoingCall(const std::string& toUrl,
// If no prefered or not suitable account given,
// find first usable account depending on url scheme.
if (toUrl.find("ring:") != std::string::npos) {
if (!account or account->getAccountType() != RingAccount::ACCOUNT_TYPE) {
account = findAccount<RingAccount>([](const std::shared_ptr<RingAccount>& acc){
return acc->isUsable();
if (!account or ::strcmp(account->getAccountType(), RingAccount::ACCOUNT_TYPE)) {
account = findAccount<RingAccount>([] (const std::shared_ptr<RingAccount>& acc) {
return acc->isUsable();
} else if (!account or account->getAccountType() != SIPAccount::ACCOUNT_TYPE) {
} else if (!account or ::strcmp(account->getAccountType(), SIPAccount::ACCOUNT_TYPE)) {
// For IP url restricts results on IP2IP accounts
auto strippedToUrl = toUrl;
......@@ -294,7 +294,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
// Append PJSIP transport to the broker's SipTransport list
auto transport = link->sipTransportBroker->addTransport(rdata->tp_info.transport);
if (!transport) {
if (account->getAccountType() == SIPAccount::ACCOUNT_TYPE) {
if (::strcmp(account->getAccountType(), SIPAccount::ACCOUNT_TYPE)) {
RING_WARN("Using transport from account.");
transport = std::static_pointer_cast<SIPAccount>(account)->getTransport();
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