Beispiel #1
0
void SERVER::SendDeleteNotifications (void)
{
   LPENUM pEnum;
   for (pEnum = m_lAggregates->FindFirst(); pEnum; pEnum = pEnum->FindNext())
      {
      LPAGGREGATE lpAggregate = (LPAGGREGATE)(pEnum->GetObject());
      lpAggregate->SendDeleteNotifications ();
      }

   for (pEnum = m_lServices->FindFirst(); pEnum; pEnum = pEnum->FindNext())
      {
      LPSERVICE lpService = (LPSERVICE)(pEnum->GetObject());
      lpService->SendDeleteNotifications();
      }

   NOTIFYCALLBACK::SendNotificationToAll (evtDestroy, GetIdentifier());
}
Beispiel #2
0
BOOL SERVER::RefreshServices (BOOL fNotify, ULONG *pStatus)
{
   BOOL rc = TRUE;
   DWORD status = 0;

   if (m_fServicesOutOfDate)
      {
      m_fServicesOutOfDate = FALSE;

      if (fIsMonitored())
         {
         if (fNotify)
            NOTIFYCALLBACK::SendNotificationToAll (evtRefreshServicesBegin, GetIdentifier());

         // First thing is to forget about what services we think we have now.
         //
         LPENUM pEnum;
         for (pEnum = m_lServices->FindLast(); pEnum; pEnum = pEnum->FindPrevious())
            {
            LPSERVICE lpService = (LPSERVICE)(pEnum->GetObject());
            lpService->SendDeleteNotifications();
            m_lServices->Remove (lpService);
            Delete (lpService);
            }

         // Next, the harder part: look through the server to find a list
         // of services.
         //
         PVOID hCell;
         PVOID hBOS;
         if ((hBOS = OpenBosObject (&hCell, &status)) == NULL)
            rc = FALSE;
         else
            {
            WORKERPACKET wpBegin;
            wpBegin.wpBosProcessNameGetBegin.hServer = hBOS;
            if (!Worker_DoTask (wtaskBosProcessNameGetBegin, &wpBegin, &status))
               rc = FALSE;
            else
               {
               LPSERVICE lpService = New2 (SERVICE,(this, TEXT("BOS")));
               m_lServices->Add (lpService);
               NOTIFYCALLBACK::SendNotificationToAll (evtCreate, lpService->GetIdentifier());

               for (;;)
                  {
                  TCHAR szServiceName[ cchNAME ];

                  WORKERPACKET wpNext;
                  wpNext.wpBosProcessNameGetNext.hEnum = wpBegin.wpBosProcessNameGetBegin.hEnum;
                  wpNext.wpBosProcessNameGetNext.pszService = szServiceName;

                  if (!Worker_DoTask (wtaskBosProcessNameGetNext, &wpNext, &status))
                     {
                     if (status == ADMITERATORDONE)
                        status = 0;
                     else
                        rc = FALSE;
                     break;
                     }

                  lpService = New2 (SERVICE,(this, wpNext.wpBosProcessNameGetNext.pszService));
                  m_lServices->Add (lpService);
                  NOTIFYCALLBACK::SendNotificationToAll (evtCreate, lpService->GetIdentifier());
                  }

               WORKERPACKET wpDone;
               wpDone.wpBosProcessNameGetDone.hEnum = wpBegin.wpBosProcessNameGetBegin.hEnum;
               Worker_DoTask (wtaskBosProcessNameGetDone, &wpDone);
               }

            CloseBosObject();
            }

         if (fNotify)
            NOTIFYCALLBACK::SendNotificationToAll (evtRefreshServicesEnd, GetIdentifier(), ((rc) ? 0 : status));
         }
      }

   if (pStatus && !rc)
      *pStatus = status;
   return TRUE;
}