예제 #1
0
// Delete a subscription from the set.
void SubscriptionSet::deleteInstance(const char* instanceName,
                                     const char* subscriptionState,
                                     const char* resourceSubscriptionState)
{
   OsSysLog::add(FAC_RLS, PRI_DEBUG,
                 "SubscriptionSet::deleteInstance instanceName = '%s', subscriptionState = '%s'",
                 instanceName, subscriptionState);

   // Search for the resource instance in question.
   UtlSListIterator itor(mSubscriptions);
   ResourceInstance* inst;
   UtlBoolean found = FALSE;
   while (!found && (inst = dynamic_cast <ResourceInstance*> (itor())))
   {
      if (inst->getInstanceName()->compareTo(instanceName) == 0)
      {
         found = TRUE;
         // Set the state of the resource instance to terminated.
         // This call sets the containing ResourceList's to publish,
         // eventually.
         inst->terminateContent(subscriptionState);
         // We do not remove the element from mSubscriptions, but rather
         // let it be removed by ResourceCache::purgeTerminated().
      }
   }
   if (!found)
   {
      OsSysLog::add(FAC_RLS, PRI_WARNING,
                    "SubscriptionSet::deleteInstance instanceName = '%s' not found",
                    instanceName);
   }
}
예제 #2
0
// Add to the HttpBody the current state of the resource instances.
void SubscriptionSet::generateBody(UtlString& rlmi,
                                   HttpBody& body,
                                   UtlBoolean consolidated,
                                   const UtlString& displayName) const
{
   // Iterate through the instances of the resource.
   UtlSListIterator instancesItor(mSubscriptions);
   ResourceInstance* instance;
   while ((instance =
           dynamic_cast <ResourceInstance*> (instancesItor())))
   {
      instance->generateBody(rlmi, body, consolidated, displayName);
   }
}
예제 #3
0
// Dump the object's internal state.
void SubscriptionSet::dumpState()
{
   // indented 10

   OsSysLog::add(FAC_RLS, PRI_INFO,
                 "\t          SubscriptionSet %p mUri = '%s', mSubscriptionEarlyDialogHandle = '%s'",
                 this, mUri.data(), mSubscriptionEarlyDialogHandle.data());

   UtlSListIterator itor(mSubscriptions);
   ResourceInstance* ri;
   while ((ri = dynamic_cast <ResourceInstance*> (itor())))
   {
      ri->dumpState();
   }
}
예제 #4
0
// Destructor
SubscriptionSet::~SubscriptionSet()
{
   OsSysLog::add(FAC_RLS, PRI_DEBUG,
                 "SubscriptionSet::~ mUri = '%s'",
                 mUri.data());

   // Delete this SubscriptionSet from mSubscribeMap.
   getResourceListSet()->deleteSubscribeMapping(&mSubscriptionEarlyDialogHandle);

   // Terminate the master subscription.
   UtlBoolean ret;
   ret = getResourceListServer()->getSubscribeClient().
      endSubscription(mSubscriptionEarlyDialogHandle.data());
   OsSysLog::add(FAC_RLS,
                 ret ? PRI_DEBUG : PRI_WARNING,
                 "SubscriptionSet::~ endSubscription %s mUri = '%s', mSubscriptionEarlyDialogHandle = '%s'",
                 ret ? "succeeded" : "failed",
                 mUri.data(),
                 mSubscriptionEarlyDialogHandle.data());

   // Delete all the child subscriptions.

   // First, send their termination content.
   UtlSListIterator itor(mSubscriptions);
   ResourceInstance* inst;
   while ((inst = dynamic_cast <ResourceInstance*> (itor())))
   {
      // Set the state of the resource instance to terminated.
      // We do not know what their termination reason is.
      // (:TODO: But it might be possible to determine that.)
      inst->terminateContent("terminated");
   }

   // Since we are about to delete the ResourceInstances, we have to
   // publish their terminated state now or forgo doing so.
   getResourceCached()->setToBePublished(TRUE);

   // Delete the ResourceInstance objects.
   mSubscriptions.destroyAll();

   // Record that the content has been changed again and needs to be
   // published.
   getResourceCached()->setToBePublished();
}
예제 #5
0
// Find a subscription in the set.
ResourceInstance* SubscriptionSet::getInstance(const char* instanceName)
{
   Os::Logger::instance().log(FAC_RLS, PRI_DEBUG,
                 "SubscriptionSet::getInstance instanceName = '%s'",
                 instanceName);

   // Search for the resource instance in question.
   UtlSListIterator itor(mSubscriptions);
   ResourceInstance* inst;
   UtlBoolean found = FALSE;
   while (!found && (inst = dynamic_cast <ResourceInstance*> (itor())))
   {
      if (inst->getInstanceName()->compareTo(instanceName) == 0)
      {
         found = TRUE;
      }
   }

   return inst;
}
예제 #6
0
// Remove dialogs in terminated state and terminated resource instances.
void SubscriptionSet::purgeTerminated()
{
   OsSysLog::add(FAC_RLS, PRI_DEBUG,
                 "SubscriptionSet::purgeTerminated mUri = '%s'",
                 mUri.data());

   // Iterate through the instances of the resource.
   UtlSListIterator instancesItor(mSubscriptions);
   ResourceInstance* instance;
   while ((instance =
           dynamic_cast <ResourceInstance*> (instancesItor())))
   {
      if (instance->isSubscriptionStateTerminated())
      {
         // If the instance itself is terminated, destroy it.
         mSubscriptions.destroy(instance);
      }
      else
      {
         // Purge any terminated dialogs in the instance.
         instance->purgeTerminatedDialogs();
      }
   }
}