コード例 #1
0
ファイル: alert.cpp プロジェクト: bagdxk/openafs
void Alert_RemoveSecondary (LPIDENT lpiChild)
{
   BOOL fChangedAlerts = FALSE;

   LPOBJECTALERTS lpoa;
   if ((lpoa = Alert_GetObjectAlerts (lpiChild, TRUE)) != NULL)
      {
      size_t iAlert;
      for (iAlert = 0; iAlert < lpoa->nAlerts; )
         {
         if ( (lpoa->aAlerts[ iAlert ].alert == alertSECONDARY) &&
              (lpoa->aAlerts[ iAlert ].aiSECONDARY.lpiSecondary == lpiChild) )
            {
            Alert_RemoveFunc (lpoa, iAlert);
            fChangedAlerts = TRUE;
            }
         else
            {
            ++iAlert;
            }
         }


      BOOL fNeedBadCredsWarning = FALSE;

      for (iAlert = 0; iAlert < lpoa->nAlerts; ++iAlert)
         {
         if (lpoa->aAlerts[ iAlert ].alert == alertSECONDARY)
            {
            ALERT alert = Alert_GetAlert (lpoa->aAlerts[ iAlert ].aiSECONDARY.lpiSecondary,
                                          lpoa->aAlerts[ iAlert ].aiSECONDARY.iSecondary);
            if (alert == alertNO_SVRENT)
               fNeedBadCredsWarning = TRUE;
            }
         }

      if ( (!fNeedBadCredsWarning) &&
           (lpoa->nAlerts && (lpoa->aAlerts[ 0 ].alert == alertBADCREDS)) )
         {
         Alert_RemoveFunc (lpoa, 0);
         fChangedAlerts = TRUE;
         }
      }

   if (fChangedAlerts)
      {
      PostNotification (evtAlertsChanged, lpiChild->GetServer());
      PostNotification (evtAlertsChanged, lpiChild);
      }
}
コード例 #2
0
ファイル: MainWindow.cpp プロジェクト: JamesLinus/nui3
bool MainWindow::OnDialogDone(const nuiEvent& event)
{
  nuiDialog::DialogResult result = mpDialog->GetResult();
  
  // returning false in a dialog callback means: "close the dialog box".
  // returning true means "don't close the dialog box": it can be usefull if the user choice doesn't match with the application constraints for instance.
  
  if (result == nuiDialog::eDialogCanceled)
  {
    return false;
  }
  
  if (result == nuiDialog::eDialogAccepted)
  {
    // store the user choice
    mBrowsedFile = mpDialog->GetSelectedFile();
    
    // send an asynchrone message to the nuiNotificationManager (the MainWindow itself in that case), to tell the application to go on
    PostNotification(new nuiNotification(NOTIF_FILEBROWSE_DONE));
    
    // note: instead of using an asynchrone message, you can make a synchrone call to another method.
    // But in that case, returning false will close and delete the dialog, which will make your application crash since
    // you are still in the dialog process (OnDialogDone is an event callback from the dialog process).
    //
    // To avoid the crash, you could:
    // - hide the dialog: mpDialog->SetVisible(false)
    // - return true (<=> "don't close and delete the dialog automatically")
    // - delete manually the dialog when your main process exits
    // this solution is a bit ugly, and using an asynchrone message to get out of the dialog process is much better.
  }
  
  return false;
}
コード例 #3
0
void CDirChangeNotification::PostOn_WatchStopped(LPCTSTR szDirectoryName)
{
	ASSERT( szDirectoryName );

	m_eFunctionToDispatch = eOn_WatchStopped;
	m_szFileName1		  = _tcsdup(szDirectoryName);

	PostNotification();
}
コード例 #4
0
void CDirChangeNotification::PostOn_WatchStopped(const std::wstring & szDirectoryName)
{
    ASSERT( !szDirectoryName.empty() );

    m_eFunctionToDispatch = eOn_WatchStopped;
    m_szFileName1		  = szDirectoryName;

    PostNotification();
}
コード例 #5
0
void CDirChangeNotification::PostOn_WatchStarted(DWORD dwError, LPCTSTR szDirectoryName)
{
	ASSERT( szDirectoryName );

	m_eFunctionToDispatch = eOn_WatchStarted;
	m_dwError			  =	dwError;
	m_szFileName1		  = _tcsdup(szDirectoryName);

	PostNotification();
}
コード例 #6
0
void CDirChangeNotification::PostOn_FileModified(LPCTSTR szFileName)
{
	ASSERT( szFileName );

	m_eFunctionToDispatch	= eOn_FileModified;
	m_szFileName1			= _tcsdup( szFileName );
	//
	// post the message so it'll be dispatched by another thread.
	PostNotification();
}
コード例 #7
0
void CDirChangeNotification::PostOn_FileModified(const std::wstring &szFileName)
{
    ASSERT( !szFileName.empty() );

    m_eFunctionToDispatch	= eOn_FileModified;
    m_szFileName1			= szFileName;
    //
    // post the message so it'll be dispatched by another thread.
    PostNotification();
}
コード例 #8
0
void CDirChangeNotification::PostOn_UnknownChange()
{
    m_eFunctionToDispatch = eOn_UnknownChange;
    m_szFileName1.clear();
    m_szFileName2.clear();

    //
    // post the message so it'll be dispatched by another thread.
    PostNotification();
}
コード例 #9
0
void CDirChangeNotification::PostOn_ReadDirectoryChangesError(DWORD dwError, const std::wstring &szDirectoryName)
{
    ASSERT( !szDirectoryName.empty() );

    m_eFunctionToDispatch = eOn_ReadDirectoryChangesError;
    m_dwError			  = dwError;
    m_szFileName1		  = szDirectoryName;
    //
    // post the message so it'll be dispatched by the another thread.
    PostNotification();
}
コード例 #10
0
void CDirChangeNotification::PostOn_ReadDirectoryChangesError(DWORD dwError, LPCTSTR szDirectoryName)
{
	ASSERT( szDirectoryName );

	m_eFunctionToDispatch = eOn_ReadDirectoryChangesError;
	m_dwError			  = dwError;
	m_szFileName1		  = _tcsdup(szDirectoryName);
	//
	// post the message so it'll be dispatched by the another thread.
	PostNotification();
	
}
コード例 #11
0
ファイル: alert.cpp プロジェクト: bagdxk/openafs
void Alert_Scout_ServerStatus (LPIDENT lpi, ULONG status)
{
   LPOBJECTALERTS lpoa;
   if ((lpoa = Alert_GetObjectAlerts (lpi)) != NULL)
      {
      BOOL fChanged = FALSE;

      for (size_t iAlert = 0; iAlert < lpoa->nAlerts; ++iAlert)
         {
         if (lpoa->aAlerts[ iAlert ].alert == alertTIMEOUT)
            {
            fChanged = TRUE;
            Alert_RemoveFunc (lpoa, iAlert);
            break;
            }
         }

      if (status != 0)
         {
         size_t iInsert = 0;
         if (lpoa->nAlerts && (lpoa->aAlerts[0].alert == alertBADCREDS))
            iInsert = 1;

         size_t iHole;
         for (iHole = iInsert; iHole < lpoa->nAlerts; ++iHole)
            {
            if (lpoa->aAlerts[ iHole ].alert == alertINVALID)
               break;
            }
         if (iHole < nAlertsMAX)
            {
            for (size_t iTarget = iHole; iTarget > iInsert; --iTarget)
               {
               memcpy (&lpoa->aAlerts[ iTarget ], &lpoa->aAlerts[ iTarget-1 ], sizeof(ALERTINFO));
               }

            lpoa->nAlerts ++;
            lpoa->aAlerts[ iInsert ].alert = alertTIMEOUT;
            lpoa->aAlerts[ iInsert ].aiTIMEOUT.status = status;
            GetSystemTime (&lpoa->aAlerts[ iInsert ].aiTIMEOUT.stLastAttempt);

            fChanged = TRUE;
            }
         }

      if (fChanged)
         {
         PostNotification (evtAlertsChanged, lpi);
         }
      }
}
コード例 #12
0
ファイル: alert.cpp プロジェクト: bagdxk/openafs
BOOL Alert_Scout_CheckServer (LPSERVER lpServer)
{
   BOOL rc = TRUE;

   LPSERVER_PREF lpsp;
   if ((lpsp = (LPSERVER_PREF)lpServer->GetUserParam()) != NULL)
      {
      LPOBJECTALERTS lpoa;
      if ((lpoa = Alert_GetObjectAlerts (lpServer->GetIdentifier())) != NULL)
         {
         PostNotification (evtScoutBegin, lpServer->GetIdentifier());

         BOOL fChangedServerAlerts = FALSE;

         DWORD dwTickNextTestWhenStarted = lpoa->dwTickNextTest;

         // First look through the server's aggregates and filesets, to
         // find any which have usages over their warning threshholds.
         //
         HENUM heAggregate;
         for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&heAggregate); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&heAggregate))
            {
            BOOL fChangedAggregateAlerts = FALSE;
            LPIDENT lpiAggregate = lpAggregate->GetIdentifier();

            LPOBJECTALERTS lpoaAggregate;
            if ((lpoaAggregate = Alert_GetObjectAlerts (lpAggregate->GetIdentifier())) != NULL)
               {
               for (size_t iAlert = 0; iAlert < lpoaAggregate->nAlerts; )
                  {
                  if ( (lpoaAggregate->aAlerts[ iAlert ].alert == alertFULL) ||
                       (lpoaAggregate->aAlerts[ iAlert ].alert == alertOVERALLOC) ||
                       (lpoaAggregate->aAlerts[ iAlert ].alert == alertNO_SVRENT) )
                     {
                     fChangedAggregateAlerts = TRUE;
                     fChangedServerAlerts = TRUE;
                     Alert_Remove (lpAggregate->GetIdentifier(), iAlert);
                     }
                  else
                     ++iAlert;
                  }

               LPAGGREGATE_PREF lpap;
               if ((lpap = (LPAGGREGATE_PREF)lpAggregate->GetUserParam()) != NULL)
                  {
                  short wGhost = lpAggregate->GetGhostStatus();
                  if (lpsp->fWarnAggNoServ && !(wGhost & GHOST_HAS_SERVER_ENTRY))
                     {
                     ALERTINFO ai;
                     ai.alert = alertNO_SVRENT;
                     Alert_AddPrimary (lpAggregate->GetIdentifier(), &ai);
                     fChangedAggregateAlerts = TRUE;
                     fChangedServerAlerts = TRUE;
                     }

                  if (lpsp->fWarnAggAlloc && lpap->fWarnAggAlloc)
                     {
                     AGGREGATESTATUS as;
                     if (lpAggregate->GetStatus (&as, TRUE))
                        {
                        if (as.ckStorageAllocated > as.ckStorageTotal)
                           {
                           ALERTINFO ai;
                           ai.alert = alertOVERALLOC;
                           ai.aiOVERALLOC.ckAllocated = as.ckStorageAllocated;
                           ai.aiOVERALLOC.ckCapacity = as.ckStorageTotal;
                           Alert_AddPrimary (lpAggregate->GetIdentifier(), &ai);
                           fChangedAggregateAlerts = TRUE;
                           fChangedServerAlerts = TRUE;
                           }
                        }
                     }

                  short perWarnAggFull = lpap->perWarnAggFull;
                  if (perWarnAggFull == -1)
                     perWarnAggFull = lpsp->perWarnAggFull;
                  if (perWarnAggFull != 0)
                     {
                     AGGREGATESTATUS as;
                     if (lpAggregate->GetStatus (&as, TRUE))
                        {
                        if (as.ckStorageTotal != 0)
                           {
                           short perNow = (short)( (double)(as.ckStorageTotal - as.ckStorageFree) * 100.0 / (double)(as.ckStorageTotal) );

                           if (perNow > perWarnAggFull)
                              {
                              ALERTINFO ai;
                              ai.alert = alertFULL;
                              ai.aiFULL.perWarning = perWarnAggFull;
                              ai.aiFULL.ckWarning = (ULONG)( (double)perWarnAggFull * (double)(as.ckStorageTotal) / 100.0 );
                              Alert_AddPrimary (lpAggregate->GetIdentifier(), &ai);
                              fChangedAggregateAlerts = TRUE;
                              fChangedServerAlerts = TRUE;
                              }
                           }
                        }
                     }
                  }
               }

            HENUM heFileset;
            for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&heFileset); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&heFileset))
               {
               BOOL fChangedFilesetAlerts = FALSE;
               LPIDENT lpiFileset = lpFileset->GetIdentifier();

               LPOBJECTALERTS lpoaFileset;
               if ((lpoaFileset = Alert_GetObjectAlerts (lpFileset->GetIdentifier())) != NULL)
                  {
                  for (size_t iAlert = 0; iAlert < lpoaFileset->nAlerts; )
                     {
                     if ( (lpoaFileset->aAlerts[ iAlert ].alert == alertFULL) ||
                          (lpoaFileset->aAlerts[ iAlert ].alert == alertSTATE_NO_VNODE) ||
                          (lpoaFileset->aAlerts[ iAlert ].alert == alertSTATE_NO_SERVICE) ||
                          (lpoaFileset->aAlerts[ iAlert ].alert == alertSTATE_OFFLINE) ||
                          (lpoaFileset->aAlerts[ iAlert ].alert == alertNO_VLDBENT) ||
                          (lpoaFileset->aAlerts[ iAlert ].alert == alertNO_SVRENT) )
                        {
                        fChangedFilesetAlerts = TRUE;
                        fChangedServerAlerts = TRUE;
                        Alert_Remove (lpFileset->GetIdentifier(), iAlert);
                        }
                     else
                        ++iAlert;
                     }
                  }

               LPFILESET_PREF lpfp;
               if ((lpfp = (LPFILESET_PREF)lpFileset->GetUserParam()) != NULL)
                  {
                  FILESETSTATUS fs;
                  if (lpFileset->GetStatus (&fs, TRUE))
                     {
                     if (fs.State & fsNO_VNODE)
                        {
                        ALERTINFO ai;
                        ai.alert = alertSTATE_NO_VNODE;
                        ai.aiSTATE.State = fs.State;
                        Alert_AddPrimary (lpFileset->GetIdentifier(), &ai);
                        fChangedFilesetAlerts = TRUE;
                        fChangedServerAlerts = TRUE;
                        }
                     else if (fs.State & fsNO_SERVICE)
                        {
                        ALERTINFO ai;
                        ai.alert = alertSTATE_NO_SERVICE;
                        ai.aiSTATE.State = fs.State;
                        Alert_AddPrimary (lpFileset->GetIdentifier(), &ai);
                        fChangedFilesetAlerts = TRUE;
                        fChangedServerAlerts = TRUE;
                        }
                     else if (fs.State & fsOFFLINE)
                        {
                        ALERTINFO ai;
                        ai.alert = alertSTATE_OFFLINE;
                        ai.aiSTATE.State = fs.State;
                        Alert_AddPrimary (lpFileset->GetIdentifier(), &ai);
                        fChangedFilesetAlerts = TRUE;
                        fChangedServerAlerts = TRUE;
                        }

                     short perWarnSetFull = lpfp->perWarnSetFull;
                     if (perWarnSetFull == -1)
                        perWarnSetFull = lpsp->perWarnSetFull;
                     if (perWarnSetFull != 0)
                        {
                        if (fs.Type == ftREADWRITE)
                           {
                           if (fs.ckQuota != 0)
                              {
                              short perNow = (short)( (double)(fs.ckUsed) * 100.0 / (double)(fs.ckQuota) );

                              if (perNow > perWarnSetFull)
                                 {
                                 ALERTINFO ai;
                                 ai.alert = alertFULL;
                                 ai.aiFULL.perWarning = perWarnSetFull;
                                 ai.aiFULL.ckWarning = (ULONG)( (double)perWarnSetFull * (double)(fs.ckQuota) / 100.0 );
                                 Alert_AddPrimary (lpFileset->GetIdentifier(), &ai);
                                 fChangedFilesetAlerts = TRUE;
                                 fChangedServerAlerts = TRUE;
                                 }
                              }
                           }
                        }
                     }

                  short wGhost = lpFileset->GetGhostStatus();
                  if (lpsp->fWarnSetNoVLDB && !(wGhost & GHOST_HAS_VLDB_ENTRY))
                     {
                     ALERTINFO ai;
                     ai.alert = alertNO_VLDBENT;
                     Alert_AddPrimary (lpFileset->GetIdentifier(), &ai);
                     fChangedFilesetAlerts = TRUE;
                     fChangedServerAlerts = TRUE;
                     }
                  if (lpsp->fWarnSetNoServ && !(wGhost & GHOST_HAS_SERVER_ENTRY) && !(fs.Type == ftREPLICA))
                     {
                     ALERTINFO ai;
                     ai.alert = alertNO_SVRENT;
                     Alert_AddPrimary (lpFileset->GetIdentifier(), &ai);
                     fChangedFilesetAlerts = TRUE;
                     fChangedServerAlerts = TRUE;
                     }
                  }

               lpFileset->Close();
               if (fChangedFilesetAlerts)
                  {
                  PostNotification (evtAlertsChanged, lpiFileset);
                  }
               }

            lpAggregate->Close();
            if (fChangedAggregateAlerts)
               {
               PostNotification (evtAlertsChanged, lpiAggregate);
               }
            }

         // Next look through the server's servces to find any
         // which have stopped.
         //
         HENUM heService;
         for (LPSERVICE lpService = lpServer->ServiceFindFirst (&heService); lpService; lpService = lpServer->ServiceFindNext (&heService))
            {
            BOOL fChangedServiceAlerts = FALSE;
            LPIDENT lpiService = lpService->GetIdentifier();

            LPOBJECTALERTS lpoaService;
            if ((lpoaService = Alert_GetObjectAlerts (lpService->GetIdentifier())) != NULL)
               {
               for (size_t iAlert = 0; iAlert < lpoaService->nAlerts; )
                  {
                  if (lpoaService->aAlerts[ iAlert ].alert == alertSTOPPED)
                     {
                     fChangedServiceAlerts = TRUE;
                     fChangedServerAlerts = TRUE;
                     Alert_Remove (lpService->GetIdentifier(), iAlert);
                     }
                  else
                     ++iAlert;
                  }

               LPSERVICE_PREF lpcp;
               if ((lpcp = (LPSERVICE_PREF)lpService->GetUserParam()) != NULL)
                  {
                  if (lpcp->fWarnSvcStop && lpsp->fWarnSvcStop)
                     {
                     SERVICESTATUS ss;
                     if (lpService->GetStatus (&ss, TRUE))
                        {
                        if (ss.state != SERVICESTATE_RUNNING)
                           {
                           ALERTINFO ai;
                           ai.alert = alertSTOPPED;
                           memcpy (&ai.aiSTOPPED.stStopped,   &ss.timeLastStop, sizeof(SYSTEMTIME));
                           memcpy (&ai.aiSTOPPED.stLastError, &ss.timeLastFail, sizeof(SYSTEMTIME));
                           ai.aiSTOPPED.errLastError = ss.dwErrLast;
                           Alert_AddPrimary (lpService->GetIdentifier(), &ai);
                           fChangedServiceAlerts = TRUE;
                           fChangedServerAlerts = TRUE;
                           }
                        }
                     }
                  }
               }

            lpService->Close();
            if (fChangedServiceAlerts)
               {
               PostNotification (evtAlertsChanged, lpiService);
               }
            }

         if (rc && (dwTickNextTestWhenStarted == lpoa->dwTickNextTest))
            {
            Alert_Scout_SetUpToDate (lpoa);
            }

         if (fChangedServerAlerts)
            {
            PostNotification (evtAlertsChanged, lpServer->GetIdentifier());
            }

         PostNotification (evtScoutEnd, lpServer->GetIdentifier());
         }
      }

   return rc;
}