Beispiel #1
0
void Config_FixGatewayDrives (void)
{
   // Zip through the user's network drives and reconnect
   // them as necessary.
   //
   for (TCHAR chDrive = chDRIVE_A; chDrive <= chDRIVE_Z; ++chDrive)
      {
      TCHAR szSubmount[ MAX_PATH ];
      if (!GetDriveSubmount (chDrive, szSubmount))
         continue;

      // We've got a mapping into AFS!  Remove it, rather forcefully.
      //
      TCHAR szDrive[] = "@:";
      szDrive[0] = chDrive;
      WNetCancelConnection (szDrive, TRUE);
      }

   // Now recreate our drive mappings, based on the user's already-
   // specified preferences.
   //
   DRIVEMAPLIST List;
   QueryDriveMapList (&List);

   for (size_t ii = 0; ii < 26; ++ii)
      {
      if (!List.aDriveMap[ii].szMapping[0])
         continue;
      ActivateDriveMap (List.aDriveMap[ii].chDrive, List.aDriveMap[ii].szMapping, List.aDriveMap[ii].szSubmount, List.aDriveMap[ii].fPersistent);
      }
}
Beispiel #2
0
void WizMounting_OnFinish (HWND hDlg)
{
   FreeDriveMapList (&l.List);
   QueryDriveMapList (&l.List);

   size_t cInactive = 0;
   for (size_t iDrive = 0; iDrive < 26; ++iDrive)
      {
      if (!l.List.aDriveMap[iDrive].szMapping[0])
         continue;
      if (l.List.aDriveMap[iDrive].fActive)
         continue;
      ++cInactive;
      }

   if (!cInactive)
      {
      g.pWizard->SetState (STEP_FINISH);
      }
   else
      {
      ShowWindow (GetDlgItem (hDlg, IDC_MAP_TRY), SW_HIDE);
      ShowWindow (GetDlgItem (hDlg, IDC_MAP_FAIL), SW_SHOW);
      EnableWindow (GetDlgItem (GetParent (hDlg), IDHELP), TRUE);
      }
}
Beispiel #3
0
void WizMount_OnInitDialog (HWND hDlg)
{
   QueryDriveMapList (&l.List);

   size_t cMap = 0;
   for (size_t iDrive = 0; iDrive < 26; ++iDrive)
      {
      if (l.List.aDriveMap[iDrive].szMapping[0])
         ++cMap;
      }

   if (cMap)
      {
      g.pWizard->SetState (STEP_MOUNTING);
      return;
      }

   // Fill in the combo box
   //
   DWORD dwDrives = GetLogicalDrives() | 0x07; // Always pretend A,B,C: are used

   int iItemSel = -1;
   HWND hCombo = GetDlgItem (hDlg, IDC_MAP_LETTER);
   SendMessage (hCombo, WM_SETREDRAW, FALSE, 0);

   for (int ii = 0; ii < 26; ++ii)
      {
      if (!(dwDrives & (1<<ii)))
         {
         TCHAR szText[ cchRESOURCE ];
         GetString (szText, IDS_MAP_LETTER);

         LPTSTR pch;
         if ((pch = (LPTSTR)lstrchr (szText, TEXT('*'))) != NULL)
            *pch = TEXT('A') + ii;

         int iItem = SendMessage (hCombo, CB_ADDSTRING, 0, (LPARAM)szText);
         SendMessage (hCombo, CB_SETITEMDATA, iItem, ii);
         if (iItemSel == -1)
            iItemSel = iItem;
         }
      }

   SendMessage (hCombo, WM_SETREDRAW, TRUE, 0);
   SendMessage (hCombo, CB_SETCURSEL, iItemSel, 0);

   SetDlgItemText (hDlg, IDC_MAP_PATH, cm_slash_mount_root);

   CheckDlgButton (hDlg, IDC_NOMAP, FALSE);
   CheckDlgButton (hDlg, IDC_YESMAP, TRUE);
}
Beispiel #4
0
BOOL DoMapShare()
{
    DRIVEMAPLIST List;
    DWORD rc=28;
    BOOL bMappedAll=FALSE;

   // Initialize the data structure
    DEBUG_EVENT0("AFS DoMapShare");
    QueryDriveMapList (&List);
    DoUnMapShare(TRUE);
    // All connections have been removed
    // Lets restore them after making the connection from the random name

    TCHAR szMachine[ MAX_PATH],szPath[MAX_PATH];
    memset(szMachine, '\0', sizeof(szMachine));
    GetClientNetbiosName(szMachine);
    sprintf(szPath,"\\\\%s\\all",szMachine);

    // Lets connect all submounts that weren't connectd
    DWORD cbUser=MAXRANDOMNAMELEN-1;
    CHAR szUser[MAXRANDOMNAMELEN];
    CHAR * pUser = NULL;
    if (WNetGetUser(szPath,(LPSTR)szUser,&cbUser)==NO_ERROR) {
	if ((pUser=strchr(szUser,'\\'))!=NULL)
            pUser++;
    }

    for (DWORD i=0;i<List.cSubmounts;i++)
    {
	if (List.aSubmounts[i].szSubmount[0])
	{
	    DWORD res=MountDOSDrive(0,List.aSubmounts[i].szSubmount,FALSE,pUser);
	    if (lstrcmpi("all",List.aSubmounts[i].szSubmount)==0)
		bMappedAll=TRUE;
	}
    }
    if (!bMappedAll)	//make sure all is mapped also
    {
        DWORD res=MountDOSDrive(0,"all",FALSE,pUser);
        if (res==ERROR_SESSION_CREDENTIAL_CONFLICT)
        {
            DisMountDOSDrive("all");
            MountDOSDrive(0,"all",FALSE,pUser);
        }
    }
    for (TCHAR chDrive = chDRIVE_A; chDrive <= chDRIVE_Z; ++chDrive)
    {
	if (List.aDriveMap[chDrive-chDRIVE_A].fActive ||
	     ForceMapActive(chDrive))
	{
            TCHAR szSubmount[ MAX_PATH ];
            if (List.aDriveMap[chDrive-chDRIVE_A].szSubmount[0])
                lstrcpy(szSubmount,List.aDriveMap[chDrive-chDRIVE_A].szSubmount);
            else if (!PathToSubmount (szSubmount, List.aDriveMap[chDrive-chDRIVE_A].szMapping, NULL, NULL))
                continue;

            BOOL fPersistent = List.aDriveMap[chDrive-chDRIVE_A].fPersistent;
	    DWORD res=MountDOSDrive(chDrive
				     ,szSubmount
				     ,fPersistent,pUser);
	}
    }
    return TRUE;
}