presence: with user=phone longterm subscription

parent 0ec911a0
......@@ -105,10 +105,11 @@ void FileAuthDb::sync() {
if (!ss.eof()) {
getline(ss, phone);
} else {
phone = user;
phone = "";
}
} else {
userid = phone = user;
userid = user;
phone = "";
}
cacheUserWithPhone(phone, domain, user);
......
......@@ -130,7 +130,10 @@ bool AuthDbBackend::cachePassword(const string &key, const string &domain, const
bool AuthDbBackend::cacheUserWithPhone(const std::string &phone, const std::string &domain, const std::string &user) {
unique_lock<mutex> lck(mCachedUserWithPhoneMutex);
mPhone2User[phone + "@" + domain] = user;
if (phone != "") {
mPhone2User[phone + "@" + domain + ";user=phone"] = user;
}
mPhone2User[user + "@" + domain] = user;
return true;
}
......@@ -165,7 +168,7 @@ void AuthDbBackend::createCachedAccount(const char* user, const char* host, cons
if (user && host) {
string key = createPasswordKey(user, auth_username ? auth_username : "");
cachePassword(key, host, password, expires);
cacheUserWithPhone(phone_alias ? phone_alias : user, host, user);
cacheUserWithPhone(phone_alias ? phone_alias : "", host, user);
}
}
......@@ -178,6 +181,9 @@ AuthDbBackend::CacheResult AuthDbBackend::getCachedUserWithPhone(const string &p
time_t now = getCurrentTime();
unique_lock<mutex> lck(mCachedUserWithPhoneMutex);
auto it = mPhone2User.find(phone + "@" + domain);
if (it == mPhone2User.end()) {
it = mPhone2User.find(phone + "@" + domain + ";user=phone");
}
if (it != mPhone2User.end()) {
user.assign(it->second);
return VALID_PASS_FOUND;
......
......@@ -26,10 +26,11 @@ public:
// result is a phone alias if (and only if) user is not the same as the entity user
bool isPhone = (strcmp(user.c_str(), belle_sip_uri_get_user(mInfo->getEntity())) != 0);
if (isPhone) {
SLOGD << "Found user " << user << " for phone " << belle_sip_uri_get_user(mInfo->getEntity()) << ", adding presence information";
SLOGD << __FILE__ << ": " << "Found user " << user << " for phone " << belle_sip_uri_get_user(mInfo->getEntity()) << ", adding presence information";
// change contact accordingly
char *contact_as_string = belle_sip_uri_to_string(mInfo->getEntity());
belle_sip_uri_t *uri = belle_sip_uri_parse(contact_as_string);
belle_sip_uri_set_user_param(uri, NULL);
belle_sip_uri_set_user(uri, user.c_str());
belle_sip_free(contact_as_string);
contact_as_string = belle_sip_uri_to_string(uri);
......@@ -37,7 +38,7 @@ public:
mInfo->setDefaultElement(contact_as_string);
belle_sip_free(contact_as_string);
} else {
SLOGD << "Found user " << user << ", adding presence information";
SLOGD << __FILE__ << ": " << "Found user " << user << ", adding presence information";
mInfo->setDefaultElement();
}
}
......@@ -50,6 +51,6 @@ private:
void PresenceLongterm::onNewPresenceInfo(const std::shared_ptr<PresentityPresenceInformation>& info) const {
const belle_sip_uri_t* uri = info->getEntity();
SLOGD << "New presence info for " << belle_sip_uri_get_user(uri) << ", checking if this user is already registered";
SLOGD << __FILE__ << ": " << "New presence info for " << belle_sip_uri_get_user(uri) << ", checking if this user is already registered";
AuthDbBackend::get()->getUserWithPhone(belle_sip_uri_get_user(info->getEntity()), belle_sip_uri_get_host(info->getEntity()), new OnAuthListener(mMainLoop, info));
}
......@@ -130,9 +130,9 @@ PresenceServer::~PresenceServer() {
belle_sip_object_unref(mStack);
belle_sip_object_unref(mListener);
// must be done before cleaning xerces
SLOGD << "Still ["<<mPresenceInformations.size()<<"] PresenceInformations referenced, clearing";
if (mPresenceInformations.size()) SLOGD << "Still ["<<mPresenceInformations.size()<<"] PresenceInformations referenced, clearing";
mPresenceInformations.clear();
SLOGD << "Still ["<<mPresenceInformationsByEtag.size()<<"] PresenceInformationsByEtag referenced, clearing";
if (mPresenceInformationsByEtag.size()) SLOGD << "Still ["<<mPresenceInformationsByEtag.size()<<"] PresenceInformationsByEtag referenced, clearing";
mPresenceInformationsByEtag.clear();
xercesc::XMLPlatformUtils::Terminate();
belle_sip_object_dump_active_objects();
......
sofia-sip @ 1e7b47b5
Subproject commit 991c8157c982c5a7b982f8e0a20d1f3b89838904
Subproject commit 1e7b47b5f6d72f809cef73cb4f673f76649a41f5
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