Exemple #1
0
void HostsTab_OnRemove (HWND hDlg)
{
   HWND hList = GetDlgItem (hDlg, IDC_LIST);
   HLISTITEM hItem = FastList_FindFirstSelected (hList);
   HLISTITEM hNext = FastList_FindNextSelected (hList, hItem);

   if (!hItem)
      {
      return;
      }
   else if (hNext)
      {
      if (Message (MB_ICONEXCLAMATION | MB_OKCANCEL, GetCautionTitle(), IDS_HOSTREM_MANY) != IDOK)
         return;
      }
   else // (!hNext)
      {
      PCELLDBLINE pLine = (PCELLDBLINE)FastList_GetItemParam (hList, hItem);
      CELLDBLINEINFO Info;
      CSDB_CrackLine (&Info, pLine->szLine);

      if (Message (MB_ICONEXCLAMATION | MB_OKCANCEL, GetCautionTitle(), IDS_HOSTREM_ONE, TEXT("%s"), Info.szCell) != IDOK)
         return;
      }

   for ( ; hItem; hItem = FastList_FindNextSelected (hList, hItem))
      {
      PCELLDBLINE pLine = (PCELLDBLINE)FastList_GetItemParam (hList, hItem);
      CSDB_RemoveCell (&g.Configuration.CellServDB, pLine);
      }

   HostsTab_FillList (hDlg);
   HostsTab_OnSelect (hDlg);
}
Exemple #2
0
BOOL GeneralTab_AskIfStopped (HWND hDlg)
{
   BOOL fStopService = FALSE;
   BOOL fStartService = FALSE;

   // If we changed things, ask if we should restart the service.
   // Otherwise, if it's stopped, ask the user if we should start the service.
   //
   DWORD CurrentState = Config_GetServiceState();
   if (g.fIsAdmin)
      {
      if ((CurrentState == SERVICE_RUNNING) && (g.fNeedRestart))
         {
         if (Message (MB_YESNO | MB_ICONQUESTION, IDS_RESTART_TITLE, IDS_RESTART_DESC) == IDYES)
            {
            fStopService = TRUE;
            fStartService = TRUE;
            }
         }
      if (CurrentState == SERVICE_STOPPED)
         {
         if (Message (MB_YESNO | MB_ICONQUESTION, GetCautionTitle(), IDS_OKSTOP_DESC) == IDYES)
            {
            fStartService = TRUE;
            }
         }
      }

   // If we need to, start or stop-n-restart the service
   //
   if (fStartService && fStopService)
      {
      GeneralTab_DoStartStop (hDlg, FALSE, TRUE); // Stop and restart the thing
      }
   else if (fStartService && !fStopService)
      {
      GeneralTab_DoStartStop (hDlg, TRUE, FALSE); // Just start it
      }

   if (fStartService)
      {
      while ( (l.fRestartIfStopped) ||
              (l.fWarnIfNotStopped) ||
              (l.fWarnIfStopped) )
         {
         MSG msg;
         if (!GetMessage (&msg, NULL, 0, 0))
            break;
         if (IsMemoryManagerMessage (&msg))
            continue;
         TranslateMessage (&msg);
         DispatchMessage (&msg);
         }
      }

   if (fStartService && !l.fServiceIsRunning)
      return FALSE;

   return TRUE;
}
Exemple #3
0
void GeneralTab_OnStartStop (HWND hDlg, BOOL fStart)
{
   BOOL fSuccess = FALSE;
   ULONG error = 0;

   // Don't let the user stop the service on a whim; warn him first
   //
   if (!fStart)
      {
      if (Message (MB_ICONEXCLAMATION | MB_OKCANCEL, GetCautionTitle(), IDS_STOP_DESC) != IDOK)
         return;
      }

   // To start the service, we'll need to successfully commit our new
   // configuration. To stop the service, we'll *try*, but it's not
   // fatal if something goes wrong.
   //
   if (!GeneralTab_OnApply (hDlg, TRUE, ((fStart) ? TRUE : FALSE)))
      {
      if (fStart)
         return;
      }

   // Okay, start the service
   //
   GeneralTab_DoStartStop (hDlg, fStart, FALSE);
}
Exemple #4
0
void AutoMapEdit_OnOK (HWND hDlg)
{
   PDRIVEMAP pMap = (PDRIVEMAP)GetWindowLongPtr (hDlg, DWLP_USER);

   int iItem = SendDlgItemMessage (hDlg, IDC_DRIVE, CB_GETCURSEL, 0, 0);
   int iDrive = SendDlgItemMessage (hDlg, IDC_DRIVE, CB_GETITEMDATA, iItem, 0);

   pMap->chDrive = chDRIVE_A + iDrive;
   GetDlgItemText (hDlg, IDC_PATH, pMap->szMapping, MAX_PATH);
   GetDlgItemText (hDlg, IDC_DESC, pMap->szSubmount, MAX_PATH);
   pMap->fPersistent = IsDlgButtonChecked (hDlg, IDC_PERSISTENT);

   if (pMap->szSubmount[0] && !IsValidSubmountName (pMap->szSubmount))
      {
      Message (MB_ICONHAND, GetErrorTitle(), IDS_BADSUB_DESC);
      return;
      }

    if ( (lstrncmpi (pMap->szMapping, cm_slash_mount_root, lstrlen(cm_slash_mount_root))) &&
         (lstrncmpi (pMap->szMapping, cm_back_slash_mount_root, lstrlen(cm_back_slash_mount_root))) )
    {
        Message (MB_ICONHAND, GetErrorTitle(), IDS_BADMAP_DESC);
        return;
    }

   // First get a proper submount
   if (pMap->szSubmount[0]) {
      TCHAR szNewSubmount[MAX_PATH];
      PathToSubmount (szNewSubmount, pMap->szMapping, pMap->szSubmount, 0);
      if (lstrcmp(szNewSubmount, pMap->szSubmount) != 0) {
         Message (MB_OK | MB_ICONASTERISK, GetCautionTitle(), IDS_NEWSUB_DESC);
         return;
      }
   } else { // If no submount was specified, then get a new one
      if (!PathToSubmount (pMap->szSubmount, pMap->szMapping, 0, 0)) {
         return;
      }
   }

   EndDialog (hDlg, IDOK);
}