// Report to all the notifiers in mStateChangeNotifiers a new event // 'dialogEvent' for AOR 'contact'. void SipDialogMonitor::notifyStateChange(UtlString& contact, StateChangeNotifier::Status status) { OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::notifyStateChange " "AOR = '%s', status = %s", contact.data(), (status == StateChangeNotifier::ON_HOOK ? "ON_HOOK" : status == StateChangeNotifier::OFF_HOOK ? "OFF_HOOK" : "UNKNOWN")); Url contactUrl(contact); // Loop through the notifier list, reporting the status to the notifiers. UtlHashMapIterator iterator(mStateChangeNotifiers); UtlString* listUri; UtlVoidPtr* container; StateChangeNotifier* notifier; while ((listUri = dynamic_cast <UtlString *> (iterator()))) { container = dynamic_cast <UtlVoidPtr *> (mStateChangeNotifiers.findValue(listUri)); notifier = (StateChangeNotifier *) container->getValue(); // Report the status to the notifier. notifier->setStatus(contactUrl, status); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::notifyStateChange setting state to %d", status); } }
// Caller must hold mLock. void SipPresenceMonitor::notifyStateChange(UtlString& contact, SipPresenceEvent* presenceEvent) { // Loop through the notifier list UtlHashMapIterator iterator(mStateChangeNotifiers); UtlString* listUri; StateChangeNotifier* notifier; Url contactUrl(contact); while ((listUri = dynamic_cast <UtlString *> (iterator()))) { notifier = dynamic_cast <StateChangeNotifier *> (mStateChangeNotifiers.findValue(listUri)); UtlString id; makeId(id, contact); Tuple* tuple = presenceEvent->getTuple(id); if (tuple) { UtlString status; tuple->getStatus(status); notifier->setStatus(contactUrl, status.compareTo(STATUS_CLOSED) == 0 ? StateChangeNotifier::AWAY : StateChangeNotifier::PRESENT); } else { notifier->setStatus(contactUrl, StateChangeNotifier::AWAY); } } }
void SipDialogMonitor::notifyStateChange(UtlString& contact, SipDialogEvent* dialogEvent) { OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::notifyStateChange contact = %s", contact.data()); // Loop through the notifier list UtlHashMapIterator iterator(mStateChangeNotifiers); UtlString* listUri; UtlVoidPtr* container; StateChangeNotifier* notifier; Url contactUrl(contact); mLock.acquire(); while (listUri = dynamic_cast <UtlString *> (iterator())) { container = dynamic_cast <UtlVoidPtr *> (mStateChangeNotifiers.findValue(listUri)); notifier = (StateChangeNotifier *) container->getValue(); if (dialogEvent->isEmpty()) { notifier->setStatus(contactUrl, StateChangeNotifier::ON_HOOK); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::notifyStateChange dialog is empty, setting state to on hook"); } else { Dialog* dialog = dialogEvent->getFirstDialog(); UtlString state, event, code; dialog->getState(state, event, code); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::notifyStateChange dialog state = %s", state.data()); if (state.compareTo(STATE_CONFIRMED) == 0) { notifier->setStatus(contactUrl, StateChangeNotifier::OFF_HOOK); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::notifyStateChange setting state to off hook"); } else { if (state.compareTo(STATE_TERMINATED) == 0) { notifier->setStatus(contactUrl, StateChangeNotifier::ON_HOOK); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::notifyStateChange setting state to on hook"); } else { notifier->setStatus(contactUrl, StateChangeNotifier::RINGING); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::notifyStateChange setting state to ringing"); } } } } mLock.release(); }
void SipPresenceMonitor::notifyStateChange(UtlString& contact, SipPresenceEvent* presenceEvent) { // Loop through the notifier list UtlHashMapIterator iterator(mStateChangeNotifiers); UtlString* listUri; StateChangeNotifier* notifier; Url contactUrl(contact); mLock.acquire(); while (listUri = dynamic_cast <UtlString *> (iterator())) { notifier = dynamic_cast <StateChangeNotifier *> (mStateChangeNotifiers.findValue(listUri)); if (presenceEvent->isEmpty()) { notifier->setStatus(contactUrl, StateChangeNotifier::AWAY); } else { UtlString id; NetMd5Codec::encode(contact, id); Tuple* tuple = presenceEvent->getTuple(id); UtlString status; tuple->getStatus(status); if (status.compareTo(STATUS_CLOSE) == 0) { notifier->setStatus(contactUrl, StateChangeNotifier::AWAY); } else { notifier->setStatus(contactUrl, StateChangeNotifier::PRESENT); } } } mLock.release(); }