UtlBoolean DialByNameDB::insertRow ( const Url& contact ) const { UtlBoolean result = FALSE; if ( m_pFastDB != NULL ) { // Fetch the display name UtlString identity, displayName, contactString; contact.getIdentity( identity ); contact.getDisplayName( displayName ); contact.toString( contactString ); // Make sure that the contact URL is valid and contains // a contactIdentity and a contactDisplayName if ( !identity.isNull() && !displayName.isNull() ) { UtlSList dtmfStrings; getDigitStrings ( displayName, dtmfStrings ); if ( !dtmfStrings.isEmpty() ) { // Thread Local Storage m_pFastDB->attach(); // Search for a matching row before deciding to update or insert dbCursor< DialByNameRow > cursor(dbCursorForUpdate); DialByNameRow row; dbQuery query; // Primary Key is identity query="np_identity=",identity; // Purge all existing entries associated with this identity if ( cursor.select( query ) > 0 ) { cursor.removeAllSelected(); } // insert all dtmf combinations for this user unsigned int i; for (i=0; i<dtmfStrings.entries(); i++) { UtlString* digits = (UtlString*)dtmfStrings.at(i); row.np_contact = contactString; row.np_identity = identity; row.np_digits = digits->data(); insert (row); } // Commit rows to memory - multiprocess workaround m_pFastDB->detach(0); } } } return result; }
bool SipPresenceMonitor::addExtension(UtlString& groupName, Url& contactUrl) { bool result = false; mLock.acquire(); // Check whether the group has already existed. If not, create one. SipResourceList* list = dynamic_cast <SipResourceList *> (mMonitoredLists.findValue(&groupName)); if (list == NULL) { UtlString* listName = new UtlString(groupName); list = new SipResourceList((UtlBoolean)TRUE, listName->data(), PRESENCE_EVENT_TYPE); mMonitoredLists.insertKeyAndValue(listName, list); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipPresenceMonitor::addExtension insert listName %s and object %p to the resource list", groupName.data(), list); } // Check whether the contact has already been added to the group UtlString resourceId; contactUrl.getIdentity(resourceId); Resource* resource = list->getResource(resourceId); if (resource == NULL) { resource = new Resource(resourceId); UtlString userName; contactUrl.getDisplayName(userName); resource->setName(userName); UtlString id; makeId(id, resourceId); resource->setInstance(id, STATE_PENDING); list->insertResource(resource); result = true; } else { OsSysLog::add(FAC_LOG, PRI_WARNING, "SipPresenceMonitor::addExtension contact %s already exists.", resourceId.data()); } int dummy; list->buildBody(&dummy); mLock.release(); return result; }
/// Add identity info to a message. bool SipXauthIdentity::insert(SipMessage & message, HeaderName headerName, const OsDateTime * timestamp) { // Don't proceed if the encapsulated identity is invalid if (!mIsValidIdentity) { Os::Logger::instance().log(FAC_SIP, PRI_CRIT, "SipXauthIdentity::insert: " "encapsulated SipXauthIdentity is invalid"); } else { // make sure no existing identity in the message remove(message, headerName); // set Call-Id and from-tag for the signature calculation UtlString callId; UtlString fromTag; Url fromUrl; message.getCallIdField(&callId); message.getFromUrl(fromUrl); fromUrl.getFieldParameter("tag", fromTag); OsDateTime now; OsDateTime::getCurTime(now); if (NULL==timestamp) { timestamp = &now; } UtlString value; encode(value, callId, fromTag, *timestamp); // Insert displayName if it is an P-Asserted-Identity header. if (headerName == SipXauthIdentity::PAssertedIdentityHeaderName) { UtlString displayName; fromUrl.getDisplayName(displayName); value.prepend(displayName.data()); } message.addHeaderField(headerName, value.data()); } return mIsValidIdentity; }
bool SipDialogMonitor::addExtension(UtlString& groupName, Url& contactUrl) { bool result = false; mLock.acquire(); // Check whether the group already exists. If not, create one. SipResourceList* list = dynamic_cast <SipResourceList *> (mMonitoredLists.findValue(&groupName)); if (list == NULL) { UtlString* listName = new UtlString(groupName); list = new SipResourceList((UtlBoolean)TRUE, listName->data(), DIALOG_EVENT_TYPE); mMonitoredLists.insertKeyAndValue(listName, list); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::addExtension insert listName %s and object %p to the resource list", groupName.data(), list); } // Check whether the contact has already been added to the group. UtlString resourceId; contactUrl.getIdentity(resourceId); Resource* resource = list->getResource(resourceId); if (resource == NULL) { // If not, add it. resource = new Resource(resourceId); UtlString userName; contactUrl.getDisplayName(userName); resource->setName(userName); UtlString id; NetMd5Codec::encode(resourceId, id); resource->setInstance(id, STATE_PENDING); list->insertResource(resource); // Set up the subscription to the URI. OsSysLog::add(FAC_LOG, PRI_DEBUG, "SipDialogMonitor::addExtension Sending out the SUBSCRIBE to contact %s", resourceId.data()); UtlString toUrl; contactUrl.toString(toUrl); UtlString fromUri = "dialogMonitor@" + mDomainName; UtlString earlyDialogHandle; UtlBoolean status = mpSipSubscribeClient->addSubscription(resourceId.data(), DIALOG_EVENT_TYPE, DIALOG_EVENT_CONTENT_TYPE, fromUri.data(), toUrl.data(), mContact.data(), mRefreshTimeout, (void *) this, SipDialogMonitor::subscriptionStateCallback, SipDialogMonitor::notifyEventCallback, earlyDialogHandle); if (!status) { result = false; OsSysLog::add(FAC_LOG, PRI_ERR, "SipDialogMonitor::addExtension Subscription failed to contact %s.", resourceId.data()); } else { mDialogHandleList.insertKeyAndValue(new UtlString(resourceId), new UtlString(earlyDialogHandle)); createDialogState(&earlyDialogHandle); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::addExtension Added earlyDialogHandle: %s", earlyDialogHandle.data()); result = true; } } else { OsSysLog::add(FAC_LOG, PRI_WARNING, "SipDialogMonitor::addExtension contact %s already exists.", resourceId.data()); } int dummy; list->buildBody(dummy); mLock.release(); return result; }