SipLine* SipLineList::getLine(const UtlString& lineId) { SipLine* nextline = NULL; if ( !lineId.isNull() ) { int iteratorHandle = m_LineList.getIteratorHandle(); while(NULL != (nextline = (SipLine*) m_LineList.next(iteratorHandle))) { if (nextline->matchesLineId(lineId)) { break; } } m_LineList.releaseIteratorHandle(iteratorHandle); } return nextline; }
// // Priorities: // 1. Matches first lineID & realm // 2. Matches first matches toFromUrl & realm // 3. Matches first user & realm // 4. Matches first default line & realm // SipLine* SipLineList::findLine(const char* lineId, const char* realm, const Url& toFromUrl, const char* userId, const Url& defaultLine) { SipLine* pLineMatchingLineID = NULL ; SipLine* pLineMatchingUrl = NULL ; SipLine* pLineMatchingUser = NULL ; SipLine* pLineMatchingDefault = NULL ; Os::Logger::instance().log(FAC_LINE_MGR, PRI_DEBUG, "SipLineList::findLine " "searching for lineId '%s' realm '%s' toFromUrl '%s' userId '%s' defaultLine '%s'", lineId, realm, toFromUrl.toString().data(), userId, defaultLine.toString().data() ); int iteratorHandle = m_LineList.getIteratorHandle(); SipLine* nextLine = NULL; for (nextLine = (SipLine*) m_LineList.next(iteratorHandle); pLineMatchingLineID == NULL && nextLine != NULL; nextLine = (SipLine*) m_LineList.next(iteratorHandle) ) { # ifdef TEST_PRINT Url tmpLineUrl = nextLine->getIdentity(); Os::Logger::instance().log(FAC_LINE_MGR, PRI_DEBUG, "SipLineList::findLine checking tmpLineUrl='%s'", tmpLineUrl.toString().data()); # endif // If the realm doesn't match, simply skip it if ((realm != NULL) && strlen(realm) && (nextLine->IsDuplicateRealm(realm))) { // // Priority 1: Check LineId // if ( lineId != NULL && nextLine->matchesLineId(lineId)) { // We have match for the given lineId pLineMatchingLineID = nextLine ; // since this is the best possible match, it will exit the loop. Os::Logger::instance().log(FAC_LINE_MGR, PRI_DEBUG, "SipLineList::findLine matched line id '%s'", lineId); } else { if (Os::Logger::instance().willLog(FAC_LINE_MGR, PRI_DEBUG)) { Url nextLineIdentity = nextLine->getIdentity(); Os::Logger::instance().log(FAC_LINE_MGR, PRI_DEBUG, "SipLineList::findLine checking nextLineIdentity='%s'", nextLineIdentity.toString().data()); } // // Priority 2: check ToFromUrl // if ( pLineMatchingUrl == NULL && nextLine->matchesIdentity(toFromUrl) ) { pLineMatchingUrl = nextLine ; // Continue searching, because we may find a better match } else { // // Priority 3: Matches user & realm // if ( pLineMatchingUser == NULL && userId != NULL && nextLine->matchesUserId(userId) // should be case sensitive ) { pLineMatchingUser = nextLine ; // Continue searching, because we may find a better match } else { // // Priority 4: Check for default line // if (nextLine->matchesIdentity(defaultLine)) { pLineMatchingDefault = nextLine ; // Continue searching, because we may find a better match } } } } } } m_LineList.releaseIteratorHandle(iteratorHandle) ; // This is ugly, but needed for the desired effect SipLine* foundLine = ( pLineMatchingLineID ? pLineMatchingLineID : pLineMatchingUrl ? pLineMatchingUrl : pLineMatchingUser ? pLineMatchingUser : pLineMatchingDefault ? pLineMatchingDefault : NULL ); Os::Logger::instance().log(FAC_LINE_MGR, PRI_DEBUG, "SipLineList::findLine %s", foundLine ? "found" : "NOT found"); return foundLine; }