Exemple #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);
   }
}
Exemple #2
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();
}