bool SipPresenceMonitor::removeExtension(UtlString& groupName, Url& contactUrl) { bool result = false; mLock.acquire(); // Check whether the group has existed or not. If not, return false. SipResourceList* list = dynamic_cast <SipResourceList *> (mMonitoredLists.findValue(&groupName)); if (list == NULL) { OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipPresenceMonitor::removeExtension group %s does not exist", groupName.data()); } else { // Check whether the contact has existed or not UtlString resourceId; contactUrl.getIdentity(resourceId); Resource* resource = list->getResource(resourceId); if (resource) { resource = list->removeResource(resource); delete resource; result = true; } else { OsSysLog::add(FAC_LOG, PRI_WARNING, "SipPresenceMonitor::removeExtension subscription for contact %s does not exists.", resourceId.data()); } } mLock.release(); return result; }
bool SipDialogMonitor::removeExtension(UtlString& groupName, Url& contactUrl) { bool result = false; mLock.acquire(); // Check whether the group has existed or not. If not, return false. SipResourceList* list = dynamic_cast <SipResourceList *> (mMonitoredLists.findValue(&groupName)); if (list == NULL) { OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::removeExtension group %s does not exist", groupName.data()); } else { // Check whether the contact has existed or not UtlString resourceId; contactUrl.getIdentity(resourceId); Resource* resource = list->getResource(resourceId); if (resource) { UtlString* dialogHandle = dynamic_cast <UtlString *> (mDialogHandleList.findValue(&resourceId)); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::removeExtension Calling endSubscription(%s)", dialogHandle->data()); UtlBoolean status = mpSipSubscribeClient->endSubscription(dialogHandle->data()); if (!status) { OsSysLog::add(FAC_SIP, PRI_ERR, "SipDialogMonitor::removeExtension Unsubscription failed for %s.", resourceId.data()); } mDialogHandleList.destroy(&resourceId); resource = list->removeResource(resource); delete resource; result = true; } else { OsSysLog::add(FAC_LOG, PRI_WARNING, "SipDialogMonitor::removeExtension subscription for contact %s does not exists.", resourceId.data()); } } mLock.release(); return result; }
bool SipDialogMonitor::removeExtension(UtlString& groupName, Url& contactUrl) { bool result = false; mLock.acquire(); // Check whether the group exists or not. If not, return false. SipResourceList* list = dynamic_cast <SipResourceList *> (mMonitoredLists.findValue(&groupName)); if (list == NULL) { OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::removeExtension group %s does not exist", groupName.data()); } else { // Check whether the contact exists in the group or not. UtlString resourceId; contactUrl.getIdentity(resourceId); Resource* resource = list->getResource(resourceId); if (resource) { // If it exists, get the early dialog handle for the SUBSCRIBE, // which specifies all of its subscriptions. UtlString* earlyDialogHandle = dynamic_cast <UtlString *> (mDialogHandleList.findValue(&resourceId)); if (earlyDialogHandle) { OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::removeExtension Calling endSubscription(%s)", earlyDialogHandle->data()); // Terminate the subscription. UtlBoolean status = mpSipSubscribeClient->endSubscription(earlyDialogHandle->data()); if (!status) { OsSysLog::add(FAC_SIP, PRI_ERR, "SipDialogMonitor::removeExtension Unsubscription failed for %s.", resourceId.data()); } // Remove the remembered state for dialog event notices. destroyDialogState(earlyDialogHandle); } else { OsSysLog::add(FAC_SIP, PRI_ERR, "SipDialogMonitor::removeExtension no dialogHandle for %s.", resourceId.data()); } // Now delete all the references to this URI. mDialogHandleList.destroy(&resourceId); resource = list->removeResource(resource); delete resource; result = true; } else { OsSysLog::add(FAC_LOG, PRI_WARNING, "SipDialogMonitor::removeExtension subscription for contact %s does not exists.", resourceId.data()); } } mLock.release(); return result; }