示例#1
0
bool SipPresenceMonitor::addPresenceEvent(UtlString& contact, SipPresenceEvent* presenceEvent)
{
   bool requiredPublish = false;
   
   if (mPresenceEventList.find(&contact) == NULL)
   {
      requiredPublish = true;
      OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipPresenceMonitor::addPresenceEvent adding the presenceEvent %p for contact %s",
                    presenceEvent, contact.data());
   }
   else
   {
      OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipPresenceMonitor::addPresenceEvent presenceEvent %p for contact %s already exists, just update the content.",
                    presenceEvent, contact.data());
                    
      // Get the object from the presence event list
      UtlContainable* oldKey;
      UtlContainable* foundValue;
      foundValue = mPresenceEventList.findValue(&contact);
      SipPresenceEvent* oldPresenceEvent = dynamic_cast <SipPresenceEvent *> (foundValue);
      UtlString oldStatus, status;
      UtlString id;
      NetMd5Codec::encode(contact, id);
      oldPresenceEvent->getTuple(id)->getStatus(oldStatus);
      presenceEvent->getTuple(id)->getStatus(status);
      
      if (status.compareTo(oldStatus) != 0)
      {
         requiredPublish = true;
         oldKey = mPresenceEventList.removeKeyAndValue(&contact, foundValue);
         delete oldKey;

         OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipPresenceMonitor::addPresenceEvent remove the presenceEvent %p for contact %s",
                       oldPresenceEvent, contact.data()); 

         if (oldPresenceEvent)
         {
            delete oldPresenceEvent;
         }
      }
   }

   if (requiredPublish)
   {         
      // Insert it into the presence event list
      presenceEvent->buildBody();
      mPresenceEventList.insertKeyAndValue(new UtlString(contact), presenceEvent);

      if (mToBePublished)
      { 
         // Publish the content to the resource list
         publishContent(contact, presenceEvent);
      }
      
      // Notify the state change
      notifyStateChange(contact, presenceEvent);
   }
   
   return requiredPublish;
}
示例#2
0
// Add 'dialogEvent' to mDialogEventList as the last dialog event for
// AOR 'contact'.
// Call notifyStateChange(), and if mToBePUblished, publishContent()
// to report this information.
void SipDialogMonitor::addDialogEvent(UtlString& contact,
                                      SipDialogEvent* dialogEvent,
                                      const char* earlyDialogHandle,
                                      const char* dialogHandle)
{
   if (mDialogEventList.find(&contact) == NULL)
   {
      OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::addDialogEvent adding dialogEvent %p for contact '%s'",
                    dialogEvent, contact.data());
   }
   else
   {
      OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::addDialogEvent dialogEvent %p for contact '%s' already exists, updating the content.",
                    dialogEvent, contact.data());
                    
      // Get the object from the dialog event list
      UtlContainable* oldKey;
      UtlContainable* foundValue;
      oldKey = mDialogEventList.removeKeyAndValue(&contact, foundValue);
      delete oldKey;
      SipDialogEvent* oldDialogEvent = dynamic_cast <SipDialogEvent *> (foundValue);

      OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::addDialogEvent removing the dialogEvent %p for contact '%s'",
                    oldDialogEvent, contact.data()); 

      if (oldDialogEvent)
      {
         delete oldDialogEvent;
      }
   }
         
   // Insert the AOR that we subscribed to into the DialogEvent
   // object, to overwrite the entity URI provided in the body of the
   // dialog event.
   dialogEvent->setEntity(contact.data());   
   // Rebuild the body.
   int dummy;
   dialogEvent->buildBody(dummy);
   
   // Insert it into the dialog event list
   // :TODO: This does not merge partial dialogs with the previous state.
   mDialogEventList.insertKeyAndValue(new UtlString(contact), dialogEvent);
   
   if (mToBePublished)
   {
      // Publish the content to the resource list.
      publishContent(contact, dialogEvent);
   }
   
   // Merge the information in the current NOTIFY with the recorded state.
   // Return the on/off hook status.
   StateChangeNotifier::Status status = mergeEventInformation(dialogEvent,
                                                              earlyDialogHandle,
                                                              dialogHandle);

   // Notify listeners of the state change.
   notifyStateChange(contact, status);
}
示例#3
0
void SipDialogMonitor::addDialogEvent(UtlString& contact, SipDialogEvent* dialogEvent)
{
   if (mDialogEventList.find(&contact) == NULL)
   {
      OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::addDialogEvent adding the dialogEvent %p for contact %s",
                    dialogEvent, contact.data());
   }
   else
   {
      OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::addDialogEvent dialogEvent %p for contact %s already exists, just update the content.",
                    dialogEvent, contact.data());
                    
      // Get the object from the dialog event list
      UtlContainable* oldKey;
      UtlContainable* foundValue;
      oldKey = mDialogEventList.removeKeyAndValue(&contact, foundValue);
      delete oldKey;
      SipDialogEvent* oldDialogEvent = dynamic_cast <SipDialogEvent *> (foundValue);

      OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipDialogMonitor::addDialogEvent remove the dialogEvent %p for contact %s",
                    oldDialogEvent, contact.data()); 

      if (oldDialogEvent)
      {
         delete oldDialogEvent;
      }
   }
         
   // Modify the entity
   dialogEvent->setEntity(contact.data());   
   dialogEvent->buildBody();
   
   // Insert it into the dialog event list
   mDialogEventList.insertKeyAndValue(new UtlString(contact), dialogEvent);
   
   if (mToBePublished)
   {
      // Publish the content to the resource list
      publishContent(contact, dialogEvent);
   }
   
   // Notify the state change
   notifyStateChange(contact, dialogEvent);
}
示例#4
0
// Returns TRUE if the requested state is different from the current state.
bool SipPresenceMonitor::addPresenceEvent(UtlString& contact, SipPresenceEvent* presenceEvent)
{
   mLock.acquire();

   bool requiredPublish = false;

   if (mPresenceEventList.find(&contact) == NULL)
   {
      requiredPublish = true;
      OsSysLog::add(FAC_SIP, PRI_DEBUG,
                    "SipPresenceMonitor::addPresenceEvent adding presenceEvent %p for contact %s",
                    presenceEvent, contact.data());
   }
   else
   {
      OsSysLog::add(FAC_SIP, PRI_DEBUG,
                    "SipPresenceMonitor::addPresenceEvent presenceEvent %p for contact %s already exists, updating its contents.",
                    presenceEvent, contact.data());

      // Get the object from the presence event list
      UtlContainable* oldKey;
      UtlContainable* foundValue;
      foundValue = mPresenceEventList.findValue(&contact);
      SipPresenceEvent* oldPresenceEvent = dynamic_cast <SipPresenceEvent *> (foundValue);
      UtlString oldStatus, status;
      UtlString id;
      makeId(id, contact);
      oldPresenceEvent->getTuple(id)->getStatus(oldStatus);
      presenceEvent->getTuple(id)->getStatus(status);

      if (status.compareTo(oldStatus) != 0)
      {
         requiredPublish = true;

         // Since we will be saving a new value, remove the old one.
         oldKey = mPresenceEventList.removeKeyAndValue(&contact, foundValue);
         delete oldKey;
         if (oldPresenceEvent)
         {
            delete oldPresenceEvent;
         }
      }
   }

   if (requiredPublish)
   {
      // Insert it into the presence event list.
      presenceEvent->buildBody();
      mPresenceEventList.insertKeyAndValue(new UtlString(contact), presenceEvent);
      if (OsSysLog::willLog(FAC_SIP, PRI_DEBUG))
      {
         UtlString b;
         ssize_t l;
         presenceEvent->getBytes(&b, &l);

         OsSysLog::add(FAC_SIP, PRI_DEBUG,
                       "SipPresenceMonitor::addPresenceEvent presenceEvent %p for contact '%s' body '%s' is different from previous presenceEvent",
                       presenceEvent, contact.data(), b.data());
      }

      if (mToBePublished)
      {
         // Publish the content to the resource list.
         publishContent(contact, presenceEvent);
      }

      // Notify the state change.
      notifyStateChange(contact, presenceEvent);

      if (!mPersistentFile.isNull())
      {
         // Start the save timer.
         mPersistenceTimer.oneshotAfter(sPersistInterval);
      }
   }
   else
   {
      // Since this presenceEvent will not be published (it does not
      // change the state we've sent out), delete it now.
      delete presenceEvent;
   }

   mLock.release();
   return requiredPublish;
}