Skip to content
Snippets Groups Projects
Commit d555cd5f authored by Jérémy Quentin's avatar Jérémy Quentin
Browse files

make daemon find the account, added userMatch

parent 54afba69
No related branches found
No related tags found
No related merge requests found
......@@ -2533,24 +2533,44 @@ ManagerImpl::getAccountIdFromNameAndServer(const std::string& userName, const st
{
AccountMap::iterator iter;
SIPAccount *account;
_debug("getAccountIdFromNameAndServer : username = %s , server = %s\n", userName.c_str(), server.c_str());
// Try to find the account id from username and server name by full match
for(iter = _accountMap.begin(); iter != _accountMap.end(); ++iter) {
_debug("for : account = %s\n", iter->first.c_str());
account = dynamic_cast<SIPAccount *>(iter->second);
_debug("account != NULL = %i\n", (account != NULL));
if (account != NULL){
if(account->fullMatch(userName, server))
{
_debug("fullMatch\n");
return iter->first;
}
}
}
// We failed! Then only match the hostname
for(iter = _accountMap.begin(); iter != _accountMap.end(); ++iter) {
account = dynamic_cast<SIPAccount *>(iter->second);
if ( account != NULL ) {
if(account->hostnameMatch(server))
{
_debug("hostnameMatch\n");
return iter->first;
}
}
}
// We failed! Then only match the username
for(iter = _accountMap.begin(); iter != _accountMap.end(); ++iter) {
account = dynamic_cast<SIPAccount *>(iter->second);
if ( account != NULL ) {
if(account->userMatch(userName))
{
_debug("userMatch\n");
return iter->first;
}
}
}
// Failed again! return AccountNULL
return AccountNULL;
......
......@@ -92,11 +92,13 @@ bool SIPAccount::fullMatch(const std::string& username, const std::string& hostn
bool SIPAccount::userMatch(const std::string& username)
{
_debug("username = %s , getUserName() = %s, == : %i\n", username.c_str(), getUsername().c_str() , username == getUsername());
return (username == getUsername());
}
bool SIPAccount::hostnameMatch(const std::string& hostname)
{
_debug("hostname = %s , getHostname() = %s, == : %i\n", hostname.c_str(), getHostname().c_str() , hostname == getHostname());
return (hostname == getHostname());
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment