Commit 690085ff authored by Simon Morlat's avatar Simon Morlat

Fix target factorization, remove unwanted "regid" parameters.

parent eaa794b0
......@@ -327,3 +327,11 @@ void ResponseSipEvent::setOutgoingAgent(const shared_ptr<OutgoingAgent> &agent)
ResponseSipEvent::~ResponseSipEvent() {
}
std::ostream &operator<<(std::ostream &strm, const url_t &obj){
SofiaAutoHome home;
strm<<url_as_string(home.home(), &obj);
return strm;
}
......@@ -233,6 +233,10 @@ inline std::ostream &operator<<(std::ostream &strm, MsgSip const &obj) {
return strm;
}
/*
* Nice << operator to serialize sofia-sip 's url_t */
std::ostream &operator<<(std::ostream &strm, const url_t &obj);
/*nice wrapper of the sofia-sip su_home_t, that performs automatic destruction of the home when it leaving a code block
* or function.*/
class SofiaAutoHome {
......
......@@ -524,12 +524,12 @@ class ForkGroupSorter {
dest.mSipContact = (*it).first;
dest.mExtendedContact = (*it).second;
targetUris << "<" << dest.mExtendedContact->mSipContact->m_url << ">";
targetUris << "<" << *dest.mExtendedContact->toSofiaUrlClean(home.home()) << ">";
url_t *url = url_make(home.home(), (*it).second->mPath.back().c_str());
// remove it and now search for other contacts that have the same route.
it = mAllContacts.erase(it);
while ((sameDestinationIt = findDestination(url)) != mAllContacts.end()) {
targetUris << ", <" << (*sameDestinationIt).second->mSipContact->m_url << ">";
targetUris << ", <" << *(*sameDestinationIt).second->toSofiaUrlClean(home.home()) << ">";
mAllContacts.erase(sameDestinationIt);
foundGroup = true;
}
......
......@@ -544,8 +544,7 @@ void RegistrarDbRedisAsync::serializeAndSendToRedis(RegistrarUserData *data, for
for (auto it = contacts.begin(); it != contacts.end(); ++it) {
shared_ptr<ExtendedContact> ec = (*it);
string uid = ec->getUniqueId();
argv[i] = strdup(uid.c_str());
argv[i] = strdup(ec->getUniqueId().c_str());
argvlen[i] = strlen(argv[i]);
i += 1;
......
......@@ -79,6 +79,15 @@ void ExtendedContact::transferRegId(const std::shared_ptr<ExtendedContact> &oldE
}
}
url_t *ExtendedContact::toSofiaUrlClean(su_home_t *home){
url_t *ret = NULL;
if (mSipContact && mSipContact->m_url){
ret = url_hdup(home, mSipContact->m_url);
ret->url_params = url_strip_param_string((char*)ret->url_params, "regid");
}
return ret;
}
string ExtendedContact::getOrgLinphoneSpecs() {
if (!mSipContact) return string();
const char *specs = msg_params_find(mSipContact->m_params, "+org.linphone.specs");
......@@ -886,7 +895,9 @@ class RecursiveRegistrarDbListener : public ContactUpdateListener,
*/
shared_ptr<ExtendedContact> newEc = make_shared<ExtendedContact>(*ec);
newEc->mSipContact = sip_contact_create(newEc->mHome.home(), (url_string_t*)uri, NULL);
newEc->mPath.push_back(ExtendedContact::urlToString(ec->mSipContact->m_url));
ostringstream path;
path<<*ec->toSofiaUrlClean(newEc->mHome.home());
newEc->mPath.push_back(path.str());
// LOGD("transformContactUsedAsRoute(): path to %s added for %s", ec->mSipUri.c_str(), uri);
newEc->mUsedAsRoute = false;
return newEc;
......
......@@ -119,7 +119,7 @@ struct ExtendedContact {
return std::string(url);
}
std::string getUniqueId() {
const std::string &getUniqueId() {
return (mUniqueId.empty() ? mCallId : mUniqueId);
}
......@@ -168,7 +168,8 @@ struct ExtendedContact {
std::ostream &print(std::ostream &stream, time_t _now = getCurrentTime(), time_t offset = 0) const;
sip_contact_t *toSofiaContact(su_home_t *home, time_t now) const;
sip_route_t *toSofiaRoute(su_home_t *home) const;
/*returns a new url_t where regid (private flexisip parameter) is removed*/
url_t *toSofiaUrlClean(su_home_t *home);
};
template <typename TraitsT>
......
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