[winecfg 6] Remove central config struct, remove DRIVE_DESC usage, code cleanups

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch temporarily drops drive editing ability, I need to do some
rewriting of it to make it transactional (for instance, Add New Drive
should fill out sensible defaults, THEN let the user edit it, rather
than force the user to make all the choices themselves).

ChangeLog:
- Removed the central configuration structure, all changes are committed instantly now
- Updated the drive handling code so it loads direct from the registry
- Removed DRIVE_DESC, drives are keyed by drive letter now
- Documented drive_available_mask
- Simplified the code somewhat


Only in programs/winecfg: config.log
diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/drive.c programs/winecfg/drive.c
--- ../head/programs/winecfg/drive.c	2003-09-05 22:51:06.000000000 +0100
+++ programs/winecfg/drive.c	2003-09-05 22:53:15.000000000 +0100
@@ -36,44 +36,119 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
 
-/*******************************************************************/
-/*  the configuration properties affected by this code             */
-/*******************************************************************/
-static BOOL initialized = FALSE;
+static BOOL updatingUI = FALSE;
+static char editWindowLetter; /* drive letter of the drive we are currently editing */
 
-void initDriveDlg (HWND hDlg)
-{
-    int i;
 
-    /* Clear the listbox */
-    SendMessageA(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_RESETCONTENT, 0, 0);
-    for (i = 0; i < config.driveCount; i++) {
-	int itemIndex;
-	DRIVE_DESC *drive = DPA_GetPtr(config.pDrives, i);
-	char *title = malloc(MAX_NAME_LENGTH);
-	
-	WINE_TRACE("Iterating, item %d of %d, drive=%p\n", i, config.driveCount, drive);
-	assert(drive);
+/* returns NULL on failure. caller is responsible for freeing result */
+char *getDriveValue(char letter, char *valueName) {
+  HKEY hkDrive = 0;
+  char *subKeyName;
+  char *result = NULL;
+  HRESULT hr;
+  DWORD bufferSize;
+  
+  WINE_TRACE("letter=%c, valueName=%s\n", letter, valueName);
 
-	WINE_TRACE("Adding %s (%s) to the listbox\n", drive->szName, drive->szLabel);
+  subKeyName = malloc(strlen("Drive X"));
+  sprintf(subKeyName, "Drive %c", letter);
 
-	/* the first SendMessage call adds the string and returns the index, the second associates that index with it */
-	snprintf(title, MAX_NAME_LENGTH, "Drive %s (%s)", drive->szName, drive->szLabel);
-	itemIndex = SendMessageA(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_ADDSTRING ,(WPARAM) -1, (LPARAM) title);
-	SendMessageA(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_SETITEMDATA, itemIndex, (LPARAM) itemIndex);
-	free(title);
-    }
-    
-    initialized = TRUE;
-}
+  hr = RegOpenKeyEx(configKey, subKeyName, 0, KEY_READ, &hkDrive);
+  if (hr != ERROR_SUCCESS) goto end;
 
+  hr = RegQueryValueEx(hkDrive, valueName, NULL, NULL, NULL, &bufferSize);
+  if (hr != ERROR_SUCCESS) goto end;
 
-void saveDriveDlgSettings (HWND hDlg)
-{
-
+  result = malloc(bufferSize);
+  hr = RegQueryValueEx(hkDrive, valueName, NULL, NULL, result, &bufferSize);
+  if (hr != ERROR_SUCCESS) goto end;
+  
+end:
+  if (hkDrive) RegCloseKey(hkDrive);
+  free(subKeyName);
+  return result;
 }
 
+void initDriveDlg (HWND hDlg)
+{
+  int i;
+  char *subKeyName = malloc(MAX_NAME_LENGTH);
+  int driveCount = 0;
+  DWORD sizeOfSubKeyName;
+
+  WINE_TRACE("\n");
+
+  updatingUI = TRUE;
+
+  /* Clear the listbox */
+  SendMessageA(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_RESETCONTENT, 0, 0);
+  for (i = 0;
+       RegEnumKeyExA(configKey, i, subKeyName, &sizeOfSubKeyName, NULL, NULL, NULL, NULL ) != ERROR_NO_MORE_ITEMS;
+       ++i, sizeOfSubKeyName = 50) {
+    
+    HKEY hkDrive;
+    char returnBuffer[MAX_NAME_LENGTH];
+    DWORD sizeOfReturnBuffer = sizeof(returnBuffer);
+    LONG r;
+
+    if (!strncmp("Drive ", subKeyName, 5)) {
+      char driveLetter = '\0';
+      char *label;
+      char *title;
+      int titleLen;
+      const char *itemLabel = "Drive %s (%s)";
+      int itemIndex;
+      
+      if (RegOpenKeyExA (configKey, subKeyName, 0, KEY_READ, &hkDrive) != ERROR_SUCCESS)        {
+        WINE_ERR("unable to open drive registry key");
+        RegCloseKey(configKey);
+        return;
+      }
+      
+      /* extract the drive letter, force to upper case */
+      driveLetter = subKeyName[strlen(subKeyName)-1];
+      if(driveLetter) driveLetter = toupper(driveLetter);
+      
+      ZeroMemory(returnBuffer, sizeof(*returnBuffer));
+      sizeOfReturnBuffer = sizeof(returnBuffer);
+      r = RegQueryValueExA(hkDrive, "Label", NULL, NULL, returnBuffer, &sizeOfReturnBuffer);
+      if (r == ERROR_SUCCESS) {
+        label = malloc(sizeOfReturnBuffer);
+        strncpy(label, returnBuffer, sizeOfReturnBuffer);
+      } else {
+        WINE_WARN("label not loaded: %ld\n", r);
+        label = NULL;
+      }
 
+      /* We now know the label and drive letter, so we can add to the list. The list items will have the letter associated
+       * with them, which acts as the key. We can then use that letter to get/set the properties of the drive. */
+      WINE_TRACE("Adding %c (%s) to the listbox\n", driveLetter, label);
+      
+      if (!label) label = "no label";
+      titleLen = strlen(itemLabel) - 1 + strlen(label) - 2 + 1;
+      title = malloc(titleLen);
+      /* the %s in the item label will be replaced by the drive letter, so -1, then
+	 -2 for the second %s which will be expanded to the label, finally + 1 for terminating #0 */
+      snprintf(title, titleLen, "Drive %c (%s)", driveLetter, label);
+      
+      /* the first SendMessage call adds the string and returns the index, the second associates that index with it */
+      itemIndex = SendMessageA(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_ADDSTRING ,(WPARAM) -1, (LPARAM) title);
+      SendMessageA(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_SETITEMDATA, itemIndex, (LPARAM) driveLetter);
+      
+      free(title);
+      free(label);
+
+      driveCount++;
+	
+    }
+  }
+  
+  WINE_TRACE("loaded %d drives\n", driveCount);
+  
+  free(subKeyName);  
+  updatingUI = FALSE;
+  return;
+}
 
 /******************************************************************************/
 /*  The Drive Editing Dialog                                                  */
@@ -98,29 +173,11 @@
   {"msdos", "MS-DOS 8 character file names"},
   {"unix", "UNIX file names"}
 };
+ 
 #define DRIVE_FS_DEFAULT 0
 
-long drive_available_mask(DRIVE_DESC *pCurrentDrive)
-{
-  int i;
-  DRIVE_DESC *pDrive;
-  long result = 0;
-  
-  for( i=0; i < config.pDrives->nItemCount; ++i) {
-    pDrive = (DRIVE_DESC *) DPA_GetPtr( config.pDrives, i );
-    if(pDrive) {
-      result |= DRIVE_MASK_BIT(pDrive->szName[0]);
-    }
-  }
-  
-  result = ~result; /*flag unused, not used*/
-  result |= DRIVE_MASK_BIT(pCurrentDrive->szName[0]);
-  WINE_TRACE( "finished drive letter loop with %ld\n", result );
-
-  return result;
-}
 
-void fill_drive_droplist(long mask, DRIVE_DESC *pCurrentDrive, HWND hDlg)
+void fill_drive_droplist(long mask, char currentLetter, HWND hDlg)
 {
   int i;
   int selection;
@@ -133,7 +190,7 @@
       sName[0] = 'A' + i;
       SendDlgItemMessage( hDlg, IDC_COMBO_LETTER, CB_ADDSTRING, 0, (LPARAM) sName );
       
-      if( toupper(pCurrentDrive->szName[0]) == 'A' + i ) {
+      if( toupper(currentLetter) == 'A' + i ) {
 	selection = count;
       }
       
@@ -152,7 +209,6 @@
   SendDlgItemMessage( hDlg, IDC_COMBO_LETTER, CB_SETCURSEL, selection, 0 );
 }
 
-
 /* if bEnable is 1 then we are editing a CDROM, so can enable all controls, otherwise we want to disable
  * "detect from device" and "serial number", but still allow the user to manually set the path. The UI
  * for this could be somewhat better -mike
@@ -167,263 +223,227 @@
   EnableWindow( GetDlgItem( hDlg, IDC_STATIC_LABEL ), bEnable );
 }
 
-
-INT_PTR CALLBACK DriveEditDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+/* This function produces a mask for each drive letter that isn't currently used. Each bit of the long result
+ * represents a letter, with A being the least significant bit, and Z being the most significant.
+ *
+ * To calculate this, we loop over each letter, and see if we can get a drive entry for it. If so, we
+ * set the appropriate bit. At the end, we flip each bit, to give the desired result.
+ *
+ * The letter parameter is always marked as being available. This is so the edit dialog can display the
+ * currently used drive letter alongside the available ones.
+ */
+long drive_available_mask(char letter)
 {
-  int i;
-  int selection;
+  long result = 0;
+  char curLetter;
+  char *slop;
+  
+  WINE_TRACE("\n");
+ 
+  for (curLetter = 'A'; curLetter < 'Z'; curLetter++) {
+    slop = getDriveValue(curLetter, "Path");
+    if (slop != NULL) {
+      result |= DRIVE_MASK_BIT(curLetter);
+      free(slop);
+    }
+  }
+  
+  result = ~result; 
+  result |= DRIVE_MASK_BIT(letter);
+  
+  WINE_TRACE( "finished drive letter loop with %lx\n", result );
+  return result;
+}
 
-  switch (uMsg)  {
-    case WM_INITDIALOG: {
-	DRIVE_DESC* pDrive = (DRIVE_DESC *)lParam;
-	
-	SetProp(hDlg, "PDRIVE", pDrive);
 
-	/* Fill in the list boxes */
-	/* Drive letters */
-	fill_drive_droplist( drive_available_mask( pDrive ), pDrive, hDlg );
-
-	/* drive type*/
-	for( i=0, selection=-1; i < sizeof(type_pairs)/sizeof(code_desc_pair); i++) {
-	  SendDlgItemMessage(hDlg, IDC_COMBO_TYPE, CB_ADDSTRING, 0,
-			     (LPARAM) type_pairs[i].sDesc);
-	  if(strcasecmp(type_pairs[i].sCode, pDrive->szType) == 0){
-	    selection = i;
-	  }
-	}
-	
-	if( selection == -1 ) {
-	  selection = DRIVE_TYPE_DEFAULT;
-	}
-	SendDlgItemMessage(hDlg, IDC_COMBO_TYPE, CB_SETCURSEL, selection, 0);
+void refreshDriveEditDialog(HWND hDlg) {
+  char *path;
+  char *type;
+  char *fs;
+  char *serial;
+  char *label;
+  char *device;
+  int i, selection;
 
-	/* FileSystem name handling */
-	for( i=0, selection=-1; i < sizeof(fs_pairs)/sizeof(code_desc_pair); i++) {
-	  SendDlgItemMessage(hDlg, IDC_COMBO_NAMES, CB_ADDSTRING, 0,
-			     (LPARAM) fs_pairs[i].sDesc);
-	  if(strcasecmp(fs_pairs[i].sCode, pDrive->szFS) == 0){
-	    selection = i;
-	  }
-	}
-	
-	if( selection == -1 ) {
-	  selection = DRIVE_FS_DEFAULT;
-	}
-	SendDlgItemMessage(hDlg, IDC_COMBO_NAMES, CB_SETCURSEL, selection, 0);
+  updatingUI = TRUE;
+  
+  /* Drive letters */
+  fill_drive_droplist( drive_available_mask( editWindowLetter ), editWindowLetter, hDlg );
 
-       
-	/* removeable media properties */
-	SendDlgItemMessage(hDlg, IDC_EDIT_SERIAL, WM_SETTEXT, 0,(LPARAM)pDrive->szSerial);
-	SendDlgItemMessage(hDlg, IDC_EDIT_LABEL, WM_SETTEXT, 0,(LPARAM)pDrive->szLabel);
-	SendDlgItemMessage(hDlg, IDC_EDIT_DEVICE, WM_SETTEXT, 0,(LPARAM)pDrive->szDevice);
-	if( strcmp("cdrom", pDrive->szType) == 0 ||
-	    strcmp("floppy", pDrive->szType) == 0) {
-	  if( (strlen( pDrive->szDevice ) == 0) &&
-	      ((strlen( pDrive->szSerial ) > 0) || (strlen( pDrive->szLabel ) > 0)) ) {
-	    selection = IDC_RADIO_ASSIGN;
-	  }
-	  else {
-	    selection = IDC_RADIO_AUTODETECT;
-	  }
-	
-	  enable_labelserial_box( hDlg, 1 );
-	}
-	else {
-	  enable_labelserial_box( hDlg, 0 );
-	  selection = IDC_RADIO_ASSIGN;
-	}
-	
-	CheckRadioButton( hDlg, IDC_RADIO_AUTODETECT, IDC_RADIO_ASSIGN, selection );
-	SendDlgItemMessage(hDlg, IDC_EDIT_PATH, WM_SETTEXT, 0,(LPARAM)pDrive->szPath);
-	break;
+  /* path */
+  path = getDriveValue(editWindowLetter, "Path");
+  if (path) {
+    SetWindowText(GetDlgItem(hDlg, IDC_EDIT_PATH), path);
+  } else WINE_WARN("no Path field?\n");
+  
+  /* drive type */
+  type = getDriveValue(editWindowLetter, "Type");
+  if (type) {
+    for(i = 0, selection = -1; i < sizeof(type_pairs)/sizeof(code_desc_pair); i++) {
+      SendDlgItemMessage(hDlg, IDC_COMBO_TYPE, CB_ADDSTRING, 0,
+			 (LPARAM) type_pairs[i].sDesc);
+      if(strcasecmp(type_pairs[i].sCode, type) == 0){
+	selection = i;
       }
+    }
+  
+    if( selection == -1 ) selection = DRIVE_TYPE_DEFAULT;
+    SendDlgItemMessage(hDlg, IDC_COMBO_TYPE, CB_SETCURSEL, selection, 0);
+  } else WINE_WARN("no Type field?\n");
 
-    case WM_COMMAND:
-      switch (LOWORD(wParam))
-	{
-	case IDC_COMBO_TYPE:
-	  switch( HIWORD(wParam)) 
-	    {
-	    case CBN_SELCHANGE:
-	      selection = SendDlgItemMessage( hDlg, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0);
-	      if( selection == 2 || selection == 3 ) { /* cdrom or floppy */
-		enable_labelserial_box( hDlg, 1 );
-	      }
-	      else {
-		enable_labelserial_box( hDlg, 0 );
-	      }
-	      break;
-	    }
-	  break;
+  
+  /* FileSystem name handling */
+  fs = getDriveValue(editWindowLetter, "FileSystem");
+  if (fs) {
+    for( i=0, selection=-1; i < sizeof(fs_pairs)/sizeof(code_desc_pair); i++) {
+      SendDlgItemMessage(hDlg, IDC_COMBO_NAMES, CB_ADDSTRING, 0,
+			 (LPARAM) fs_pairs[i].sDesc);
+      if(strcasecmp(fs_pairs[i].sCode, fs) == 0){
+	selection = i;
+      }
+    }
+  
+    if( selection == -1 ) selection = DRIVE_FS_DEFAULT;
+    SendDlgItemMessage(hDlg, IDC_COMBO_NAMES, CB_SETCURSEL, selection, 0);
+  } else WINE_WARN("no FileSystem field?\n");
+
+
+  /* removeable media properties */
+  serial = getDriveValue(editWindowLetter, "Serial");
+  if (serial) {
+    SendDlgItemMessage(hDlg, IDC_EDIT_SERIAL, WM_SETTEXT, 0,(LPARAM)serial);
+  } else WINE_WARN("no Serial field?\n");
+
+  label = getDriveValue(editWindowLetter, "Label");
+  if (label) {
+    SendDlgItemMessage(hDlg, IDC_EDIT_LABEL, WM_SETTEXT, 0,(LPARAM)label);
+  } else WINE_WARN("no Label field?\n");
+
+  device = getDriveValue(editWindowLetter, "Device");
+  if (device) {
+    SendDlgItemMessage(hDlg, IDC_EDIT_DEVICE, WM_SETTEXT, 0,(LPARAM)device);
+  } else WINE_WARN("no Device field?\n");
+
+  if( strcmp("cdrom", type) == 0 ||
+      strcmp("floppy", type) == 0) {
+    if( (strlen( device ) == 0) &&
+	((strlen( serial ) > 0) || (strlen( label ) > 0)) ) {
+      selection = IDC_RADIO_ASSIGN;
+    }
+    else {
+      selection = IDC_RADIO_AUTODETECT;
+    }
+    
+    enable_labelserial_box( hDlg, 1 );
+  }
+  else {
+    enable_labelserial_box( hDlg, 0 );
+    selection = IDC_RADIO_ASSIGN;
+  }
 
-	case ID_BUTTON_OK:
-	  {
-	    DRIVE_DESC *pDrive = GetProp(hDlg, "PDRIVE");
-	    char buffer[MAX_NAME_LENGTH];
-	    
-	    /* fixme: do it in a cleanup */
-	    RemoveProp(hDlg, "PDRIVE");
+  CheckRadioButton( hDlg, IDC_RADIO_AUTODETECT, IDC_RADIO_ASSIGN, selection );
+  SendDlgItemMessage(hDlg, IDC_EDIT_PATH, WM_SETTEXT, 0,(LPARAM)path);
+  
+  if (path) free(path);
+  if (type) free(type);
+  if (fs) free(fs);
+  if (serial) free(serial);
+  if (label) free(label);
+  if (device) free(device);
+  
+  updatingUI = FALSE;
+  
+  return;
+}
 
-	    ZeroMemory(&buffer[0], MAX_NAME_LENGTH);
-	    GetWindowText(GetDlgItem(hDlg, IDC_EDIT_PATH), buffer, MAX_NAME_LENGTH);
-	    if (strlen(buffer) > 0) {
-	      strncpy(pDrive->szPath, buffer, MAX_NAME_LENGTH);
-	      
-	      /* only fill in the other values if we have a path */
-	      selection = SendDlgItemMessage( hDlg, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0);
-	      strncpy(pDrive->szType, type_pairs[selection].sCode, MAX_NAME_LENGTH);
-	      
-	      selection = SendDlgItemMessage( hDlg, IDC_COMBO_NAMES, CB_GETCURSEL, 0, 0);
-	      strncpy(pDrive->szFS, fs_pairs[selection].sCode, MAX_NAME_LENGTH);
-	      
-	      selection = SendDlgItemMessage( hDlg, IDC_COMBO_LETTER, CB_GETCURSEL, 0, 0);
-	      SendDlgItemMessage( hDlg, IDC_COMBO_LETTER, CB_GETLBTEXT, selection, (WPARAM)buffer);
-	      strncpy(pDrive->szName, buffer, MAX_NAME_LENGTH);
-	      pDrive->szName[1] = 0; /* truncate to only the letter */
-
-	      if( strncmp( pDrive->szType, "cdrom", MAX_NAME_LENGTH ) == 0) {
-		if( IsDlgButtonChecked( hDlg, IDC_RADIO_ASSIGN ) == BST_CHECKED ) {
-		  GetWindowText(GetDlgItem(hDlg, IDC_EDIT_LABEL), buffer, 
-				MAX_NAME_LENGTH);
-		  strncpy(pDrive->szLabel, buffer, MAX_NAME_LENGTH);
-		  GetWindowText(GetDlgItem(hDlg, IDC_EDIT_SERIAL), buffer, 
-				MAX_NAME_LENGTH);
-		  strncpy(pDrive->szSerial, buffer, MAX_NAME_LENGTH);
-		  pDrive->szDevice[0] = 0;
-		}
-		else {
-		  GetWindowText(GetDlgItem(hDlg, IDC_EDIT_DEVICE), buffer, 
-				MAX_NAME_LENGTH);
-		  strncpy(pDrive->szDevice, buffer, MAX_NAME_LENGTH);
-		  pDrive->szLabel[0] = 0;
-		  pDrive->szSerial[0] = 0;
-		}
-	      }
-	      else {
-		GetWindowText(GetDlgItem(hDlg, IDC_EDIT_LABEL), pDrive->szLabel, MAX_NAME_LENGTH);
-		GetWindowText(GetDlgItem(hDlg, IDC_EDIT_SERIAL), pDrive->szSerial, MAX_NAME_LENGTH);
-		GetWindowText(GetDlgItem(hDlg, IDC_EDIT_DEVICE), pDrive->szDevice, MAX_NAME_LENGTH);
-	      }
-	      EndDialog(hDlg, wParam);
-	    }
-	    else { /* missing a path */
-	      MessageBox( hDlg, "Please enter a valid path", "ERROR", MB_OK );
+INT_PTR CALLBACK DriveEditDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+  int selection;
+
+  switch (uMsg)  {
+      case WM_INITDIALOG: {
+	editWindowLetter = (char) lParam;
+	refreshDriveEditDialog(hDlg);
+      }
+
+    case WM_COMMAND:
+      switch (LOWORD(wParam)) {
+	  case IDC_COMBO_TYPE:
+	    switch( HIWORD(wParam)) {
+		case CBN_SELCHANGE:
+		  selection = SendDlgItemMessage( hDlg, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0);
+		  if( selection == 2 || selection == 3 ) { /* cdrom or floppy */
+		    enable_labelserial_box( hDlg, 1 );
+		  }
+		  else {
+		    enable_labelserial_box( hDlg, 0 );
+		  }
+		  break;
 	    }
-	    return TRUE;
+	    break;
 	    
-	  }
-
+	  case ID_BUTTON_OK: break;
 	  
 	  /* Fall through. */
 	  
-	case ID_BUTTON_CANCEL:
-	  /* fixme: do it in a cleanup */
-	  RemoveProp(hDlg, "PDRIVE");
-	  EndDialog(hDlg, wParam);
-	  return TRUE;
-	}
-    }
+	  case ID_BUTTON_CANCEL:
+	    EndDialog(hDlg, wParam);
+	    return TRUE;
+      }
+  }
   return FALSE;
 }
 
 
-/***************************************************************************/
-/*  The Actual Property Sheet Page                                         */
-/***************************************************************************/
-
 INT_PTR CALLBACK
 DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
   int selection = -1;
 
-  switch (uMsg)
-    {
-    case WM_INITDIALOG:
-      break;
-      
-    case WM_COMMAND:
-      switch (LOWORD(wParam))
-	{
-	case IDC_LIST_DRIVES:
-	  switch( HIWORD( wParam ) )
-	    {
-	    case LBN_DBLCLK:
-	      selection = -1;
+  switch (uMsg) {
+      case WM_COMMAND:
+	switch (LOWORD(wParam)) {
+	    case IDC_LIST_DRIVES:
+	      switch(HIWORD( wParam )) {
+		  case LBN_DBLCLK:
+		    selection = -1;
+		    break;
+	      }
+
+	    case IDC_BUTTON_ADD:
+	      /* temporarily disabled, awaiting rewrite for transactional design (need to fill in defaults smartly, wizard?) */
 	      break;
-	    }
-	case IDC_BUTTON_ADD:
-	  if (HIWORD(wParam)==BN_CLICKED) {
-	    DRIVE_DESC* pDrive = malloc(sizeof(DRIVE_DESC));
-	    
-	    /* adding a new drive */
-	    ZeroMemory(pDrive, sizeof(*pDrive));
-	    DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_DRIVE_EDIT2),
-			   NULL, (DLGPROC) DriveEditDlgProc, (LPARAM) pDrive );
-	    /* if pDrive is blank, free the memory, otherwise, add the pointer to HDPA and add to listbox */
-	    if (!(pDrive->szName[0]))
-	      free(pDrive);
-	    else {
-	      char DRIVE_NAME[7];
-	      int pos;
-	      
-	      ZeroMemory(DRIVE_NAME,sizeof(DRIVE_NAME));
-	      strcat(DRIVE_NAME, "Drive \0");
-	      strncat(DRIVE_NAME, pDrive->szName, 1);
-	      pos = SendMessageA(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_ADDSTRING ,(WPARAM) -1, (LPARAM) DRIVE_NAME);
-	      SendMessageA(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_SETITEMDATA, pos, (LPARAM) pos);
-	      DPA_InsertPtr(config.pDrives, pos, pDrive);
-	    }
-	  }
-	  break;
-	case IDC_BUTTON_EDIT:
-	  if (HIWORD(wParam)==BN_CLICKED) {
-	    int nItem = SendMessage(GetDlgItem(hDlg, IDC_LIST_DRIVES),  LB_GETCURSEL, 0, 0);
-	    int i = SendMessage(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_GETITEMDATA, nItem, 0);
-	    DRIVE_DESC* pDrive = DPA_GetPtr(config.pDrives, i);
-	    
-	    if (pDrive != NULL) {
-	      DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_DRIVE_EDIT2),
-			     NULL, (DLGPROC) DriveEditDlgProc, (LPARAM) pDrive );
-	      SetProp(hDlg, "PDRIVE", pDrive);
-	      WINE_TRACE("refreshing main dialog\n");
-	      initDriveDlg(hDlg);
-	    }
-	  }
-	  break;
-	case IDC_BUTTON_REMOVE:
-	  if (HIWORD(wParam)==BN_CLICKED) {
-	    int nItem = SendMessage(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_GETCURSEL, 0, 0);
-	    SendMessage(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_DELETESTRING, (WPARAM) nItem, (LPARAM) 0 );
-	    free(DPA_GetPtr(config.pDrives, nItem));
-	  }
-
-	default:
-	  /** SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); */
-	  break;
-	}
-      break;
 
-    case WM_NOTIFY:
-      switch(((LPNMHDR)lParam)->code)
-	{
-	case PSN_KILLACTIVE: {
-	  /* validate user info.  Lets just assume everything is okay for now */
-	  SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
+	    case IDC_BUTTON_REMOVE:
+	      /* temporarily disabled, awaiting rewrite */
+	      break;
+	      
+	    case IDC_BUTTON_EDIT:
+	      if (HIWORD(wParam) == BN_CLICKED) {
+		int nItem = SendMessage(GetDlgItem(hDlg, IDC_LIST_DRIVES),  LB_GETCURSEL, 0, 0);
+		char letter = SendMessage(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_GETITEMDATA, nItem, 0);
+		
+		DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_DRIVE_EDIT2), NULL, (DLGPROC) DriveEditDlgProc, (LPARAM) letter);
+	      }
+	      break;
+	      
 	}
-	case PSN_APPLY: {
-	  /* should probably check everything is really all rosy :) */
-	  saveDriveDlgSettings (hDlg);
-	  SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
+	break;
+	
+      case WM_NOTIFY: switch(((LPNMHDR)lParam)->code) {
+	    case PSN_KILLACTIVE:
+	      SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
+	      break;
+	    case PSN_APPLY:
+	      SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
+	      break;
+	    case PSN_SETACTIVE:
+	      initDriveDlg (hDlg);
+	      break;
 	}
-	case PSN_SETACTIVE: {
-	  if (!initialized)
-	    initDriveDlg (hDlg);
+	break;
 
-	}
-	}
+  }
 
-    default:
-      break;
-    }
   return FALSE;
 }
Only in programs/winecfg: drive.c.old
Only in programs/winecfg: drive-mappings
diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/main.c programs/winecfg/main.c
--- ../head/programs/winecfg/main.c	2003-09-05 22:51:06.000000000 +0100
+++ programs/winecfg/main.c	2003-09-05 20:18:14.000000000 +0100
@@ -36,8 +36,6 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
 
-WINECFG_DESC config;
-
 void CALLBACK
 PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
 {
Only in programs/winecfg: programs
diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/properties.h programs/winecfg/properties.h
--- ../head/programs/winecfg/properties.h	2003-09-05 18:17:19.000000000 +0100
+++ programs/winecfg/properties.h	2003-09-05 22:51:23.000000000 +0100
@@ -56,17 +56,6 @@
 
 typedef struct
 {
-    char szName[MAX_NAME_LENGTH];
-    char szPath[MAX_NAME_LENGTH];
-    char szType[MAX_NAME_LENGTH];
-    char szFS[MAX_NAME_LENGTH];
-    char szLabel[MAX_NAME_LENGTH];
-    char szDevice[MAX_NAME_LENGTH];
-    char szSerial[MAX_NAME_LENGTH];
-} DRIVE_DESC;
-
-typedef struct
-{
     char   szX11Display[MAX_NAME_LENGTH];
     int    nSysColors;
     int    nPrivateMap;
diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/winecfg.c programs/winecfg/winecfg.c
--- ../head/programs/winecfg/winecfg.c	2003-09-05 22:51:06.000000000 +0100
+++ programs/winecfg/winecfg.c	2003-09-05 21:43:57.000000000 +0100
@@ -179,157 +179,6 @@
 }
 
 
-/*****************************************************************************
- * Name       : loadConfig
- * Description: Loads and populates a configuration structure
- * Parameters : pCfg
- * Returns    : 0 on success, -1 otherwise
- *
- */
-int loadConfig (WINECFG_DESC* pCfg)
-{
-    const DLL_DESC *pDllDefaults;
-    char buffer[MAX_PATH];
-    char subKeyName[51];
-    DWORD res, i, sizeOfSubKeyName = 50;
-
-    WINE_TRACE("\n");
-
-    return_if_fail( initialize() == 0 , 1 );
-
-    /* System Paths */
-/*  getConfigValue(configKey, "Wine", "Windows", pCfg->szWinDir, MAX_PATH, "c:\\Windows");
-    getConfigValue(configKey, "Wine", "System", pCfg->szWinSysDir, MAX_PATH, "c:\\Windows\\System");
-    getConfigValue(configKey, "Wine", "Temp", pCfg->szWinTmpDir, MAX_PATH, "c:\\Windows\\Temp");
-    getConfigValue(configKey, "Wine", "Profile", pCfg->szWinProfDir, MAX_PATH, "c:\\Windows\\Profiles\\Administrator");
-    getConfigValue(configKey, "Wine", "Path", pCfg->szWinPath, MAX_PATH, "c:\\Windows;c:\\Windows\\System");
-*/
-    /* Graphics driver */
-/*  getConfigValue(configKey, "Wine", "GraphicsDriver", pCfg->szGraphDriver, MAX_NAME_LENGTH, "x11drv");
- */    
-    /*
-     * DLL defaults for all applications is built using
-     * the default DLL structure
-     */
-/*    for (pDllDefaults = getDLLDefaults (); *pDllDefaults->szName; pDllDefaults++)
-    {
-        DLL_DESC *pDll = malloc(sizeof(DLL_DESC));
-	memcpy (pDll, pDllDefaults, sizeof(DLL_DESC));
-        DPA_InsertPtr(pCfg->pDlls, INT_MAX, pDll);
-    }
-*/
-
-    pCfg->sX11Drv.nTextCP = 0;
-    pCfg->sX11Drv.nXVideoPort = 43;
-    pCfg->sX11Drv.nDepth = 16;
-    pCfg->sX11Drv.nManaged = 1;
-    pCfg->sX11Drv.nDesktopSizeX = 640;
-    pCfg->sX11Drv.nDesktopSizeY = 480;
-    pCfg->sX11Drv.nDGA = 1;
-    pCfg->sX11Drv.nXVidMode = 1;
-    pCfg->sX11Drv.nTakeFocus = 1;
-    pCfg->sX11Drv.nDXGrab = 0;
-    pCfg->sX11Drv.nDoubleBuffered = 0;
-    pCfg->sX11Drv.nSynchronous = 1;
-
-
-    /*
-     * Drive mappings
-     */
-/*  pCfg->pDrives = DPA_Create(26);
-    for (i = 0;
-	 RegEnumKeyExA(configKey, i, subKeyName, &sizeOfSubKeyName, NULL, NULL, NULL, NULL ) != ERROR_NO_MORE_ITEMS;
-         ++i, sizeOfSubKeyName=50) {
-	HKEY hkDrive;
-	DWORD returnType;
-	char returnBuffer[MAX_NAME_LENGTH];
-	DWORD sizeOfReturnBuffer = sizeof(returnBuffer);
-	LONG r;
-
-	if (!strncmp("Drive ", subKeyName, 5)) {
-	    DRIVE_DESC *pDrive = malloc(sizeof(DRIVE_DESC));
-
-	    WINE_TRACE("Loading %s\n", subKeyName);
-	    
-	    ZeroMemory(pDrive, sizeof(*pDrive));
-	    sizeOfReturnBuffer = sizeof(returnBuffer);
-	    if (RegOpenKeyExA (configKey, subKeyName, 0, KEY_READ, &hkDrive) != ERROR_SUCCESS)	{
-		WINE_ERR("unable to open drive registry key");
-		RegCloseKey(configKey);
-		return 1;
-	    }
-	   
-	    strncpy(pDrive->szName, &subKeyName[strlen(subKeyName)-1],1);
-	    if(pDrive->szName) {
-		pDrive->szName[0] = toupper(pDrive->szName[0]);
-	    }
-	    
-	    ZeroMemory(returnBuffer, sizeof(*returnBuffer));
-	    sizeOfReturnBuffer = sizeof(returnBuffer);
-	    r = RegQueryValueExA(hkDrive, "Label", NULL, &returnType, returnBuffer, &sizeOfReturnBuffer);
-	    if (r == ERROR_SUCCESS) {
-		strncpy(pDrive->szLabel, returnBuffer, sizeOfReturnBuffer);
-	    } else {
-		WINE_WARN("pDrive->szLabel not loaded: %ld\n", r);
-	    }
-	    
-	    ZeroMemory(returnBuffer, sizeof(*returnBuffer));
-	    sizeOfReturnBuffer = sizeof(returnBuffer);
-	    r = RegQueryValueExA(hkDrive, "Serial", NULL, &returnType, returnBuffer, &sizeOfReturnBuffer);
-	    if (r == ERROR_SUCCESS) {
-		strncpy(pDrive->szSerial, returnBuffer, sizeOfReturnBuffer);
-	    } else {
-		WINE_WARN("pDrive->szSerial not loaded: %ld\n", r);
-	    }
-	    
-	    
-	    ZeroMemory(returnBuffer, sizeof(*returnBuffer));
-	    sizeOfReturnBuffer = sizeof(returnBuffer);
-	    r = RegQueryValueExA(hkDrive, "Type", NULL, &returnType, returnBuffer, &sizeOfReturnBuffer);
-	    if (r == ERROR_SUCCESS) {
-		strncpy(pDrive->szType, returnBuffer, sizeOfReturnBuffer);
-	    } else {
-		WINE_WARN("pDrive->szType not loaded: %ld", r);
-	    }
-	    
-	    ZeroMemory(returnBuffer, sizeof(*returnBuffer));
-	    sizeOfReturnBuffer = sizeof(returnBuffer);
-	    if (RegQueryValueExA(hkDrive, "Path", NULL, &returnType, returnBuffer, &sizeOfReturnBuffer) == ERROR_SUCCESS) {
-		strncpy(pDrive->szPath, returnBuffer, sizeOfReturnBuffer);
-	    } else {
-		WINE_WARN("pDrive->szPath not loaded: %ld\n", GetLastError());
-	    }
-	    
-	    ZeroMemory(returnBuffer, sizeof(*returnBuffer));
-	    sizeOfReturnBuffer = sizeof(returnBuffer);
-	    if (RegQueryValueExA(hkDrive, "FileSystem", NULL, &returnType, returnBuffer, &sizeOfReturnBuffer) == ERROR_SUCCESS) {
-		strncpy(pDrive->szFS, returnBuffer, sizeOfReturnBuffer);
-	    } else {
-		WINE_WARN("pDrive->szFS not loaded: %ld\n", GetLastError());
-	    }
-
-	    ZeroMemory(returnBuffer, sizeof(*returnBuffer));
-	    sizeOfReturnBuffer = sizeof(returnBuffer);
-	    if (RegQueryValueExA(hkDrive, "Device", NULL, &returnType, returnBuffer, &sizeOfReturnBuffer) == ERROR_SUCCESS) {
-		strncpy(pDrive->szDevice, returnBuffer, sizeOfReturnBuffer);
-	    } else {
-		WINE_WARN("pDrive->szDevice not found: %ld\n", GetLastError());
-	    }
-
-	    if (DPA_InsertPtr(pCfg->pDrives, pCfg->driveCount, pDrive) == -1)
-		WINE_ERR("Failed to insert pDrive into DPA\n");
-	    else
-		pCfg->driveCount++;
-	    
-	}
-    }
-    WINE_TRACE("loaded %d drives\n", pCfg->driveCount);
- */
-    return 0;
-}
-
-
-
 /* ========================================================================= */
 /* Transaction management code */
 
diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/winecfg.h programs/winecfg/winecfg.h
--- ../head/programs/winecfg/winecfg.h	2003-09-05 22:51:06.000000000 +0100
+++ programs/winecfg/winecfg.h	2003-09-05 22:53:57.000000000 +0100
@@ -72,48 +72,7 @@
 
 /* Initializes the transaction system */
 int initialize();
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct structWineCfg
-{
-    char   szWinVer[MAX_VERSION_LENGTH];
-    char   szWinLook[MAX_VERSION_LENGTH];
-    char   szDOSVer[MAX_VERSION_LENGTH];
-
-    char   szWinDir[MAX_PATH];
-    char   szWinSysDir[MAX_PATH];
-    char   szWinPath[MAX_PATH];
-    char   szWinTmpDir[MAX_PATH];
-    char   szWinProfDir[MAX_PATH];
-
-    char   szGraphDriver[MAX_NAME_LENGTH];
-
-    HDPA   pDlls;
-    HDPA   pApps;
-    HDPA   pDrives;
-
-    int    driveCount;
-
-    X11DRV_DESC sX11Drv;
-} WINECFG_DESC;
-
-extern WINECFG_DESC config;
-
-WINECFG_DESC *allocConfig(void);
-int freeConfig(WINECFG_DESC *pCfg);
-
-int loadConfig(WINECFG_DESC *pCfg);
-int saveConfig(const WINECFG_DESC *pCfg);
+extern HKEY configKey;
 
 int setConfigValue (char *subkey, char *valueName, const char *value);
 char *getConfigValue (char *subkey, char *valueName, char *defaultResult);




[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux