static void on_remove_click(HWND dialog) { int sel = SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETCURSEL, 0, 0); struct dll *dll; if (sel == LB_ERR) return; dll = (struct dll *) SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETITEMDATA, sel, 0); SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_DELETESTRING, sel, 0); SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0); set_reg_key(config_key, keypath("DllOverrides"), dll->name, NULL); HeapFree(GetProcessHeap(), 0, dll->name); HeapFree(GetProcessHeap(), 0, dll); if (SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETCOUNT, 0, 0) > 0) SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_SETCURSEL, max(sel - 1, 0), 0); else { disable(IDC_DLLS_EDITDLL); disable(IDC_DLLS_REMOVEDLL); } set_controls_from_selection(dialog); }
void CGnomeSettingsStore::SaveSetting(const std::string &Key, const std::string &Value) { std::string keypath(GCONF_KEY_ROOT); keypath += Key; GError *the_error = NULL; gconf_client_set_string(the_gconf_client, keypath.c_str(), Value.c_str(), &the_error); }
static void on_add_click(HWND dialog) { static const char dotDll[] = ".dll"; char buffer[1024], *ptr; ZeroMemory(buffer, sizeof(buffer)); SendDlgItemMessageA(dialog, IDC_DLLCOMBO, WM_GETTEXT, sizeof(buffer), (LPARAM) buffer); if (lstrlenA(buffer) >= sizeof(dotDll)) { ptr = buffer + lstrlenA(buffer) - sizeof(dotDll) + 1; if (!lstrcmpiA(ptr, dotDll)) { WINE_TRACE("Stripping dll extension\n"); *ptr = '\0'; } } /* check if dll is in the builtin-only list */ if (!(ptr = strrchr( buffer, '\\' ))) { ptr = buffer; if (*ptr == '*') ptr++; } else ptr++; if (is_builtin_only( ptr )) { MSGBOXPARAMSA params; params.cbSize = sizeof(params); params.hwndOwner = dialog; params.hInstance = GetModuleHandleA( NULL ); params.lpszText = MAKEINTRESOURCEA( IDS_DLL_WARNING ); params.lpszCaption = MAKEINTRESOURCEA( IDS_DLL_WARNING_CAPTION ); params.dwStyle = MB_ICONWARNING | MB_YESNO; params.lpszIcon = NULL; params.dwContextHelpId = 0; params.lpfnMsgBoxCallback = NULL; params.dwLanguageId = 0; if (MessageBoxIndirectA( ¶ms ) != IDYES) return; } SendDlgItemMessageW(dialog, IDC_DLLCOMBO, WM_SETTEXT, 0, (LPARAM)emptyW); disable(IDC_DLLS_ADDDLL); SendMessageW(GetParent(dialog), DM_SETDEFID, IDOK, 0); WINE_TRACE("Adding %s as native, builtin\n", buffer); SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0); set_reg_key(config_key, keypath("DllOverrides"), buffer, "native,builtin"); load_library_settings(dialog); SendDlgItemMessageA(dialog, IDC_DLLS_LIST, LB_SELECTSTRING, 0, (LPARAM) buffer); set_controls_from_selection(dialog); }
bool CGnomeSettingsStore::LoadSetting(const std::string &Key, std::string *Value) { std::string keypath(GCONF_KEY_ROOT); keypath += Key; GError *the_error = NULL; GConfValue *got_value = gconf_client_get_without_default(the_gconf_client, keypath.c_str(), &the_error); if(got_value == NULL) { return false; } *Value = gconf_value_get_string(got_value); gconf_value_free(got_value); return true; }
static void set_dllmode(HWND dialog, DWORD id) { enum dllmode mode; struct dll *dll; int sel; const char *str; mode = id_to_mode(id); sel = SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETCURSEL, 0, 0); if (sel == -1) return; dll = (struct dll *) SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETITEMDATA, sel, 0); str = mode_to_string(mode); WINE_TRACE("Setting %s to %s\n", dll->name, str); SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0); set_reg_key(config_key, keypath("DllOverrides"), dll->name, str); load_library_settings(dialog); /* ... and refresh */ }
static void load_library_settings(HWND dialog) { char **overrides = enumerate_values(config_key, keypath("DllOverrides")); char **p; int sel, count = 0; sel = SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETCURSEL, 0, 0); WINE_TRACE("sel=%d\n", sel); clear_settings(dialog); if (!overrides || *overrides == NULL) { set_controls_from_selection(dialog); disable(IDC_DLLS_EDITDLL); disable(IDC_DLLS_REMOVEDLL); HeapFree(GetProcessHeap(), 0, overrides); return; } enable(IDC_DLLS_EDITDLL); enable(IDC_DLLS_REMOVEDLL); for (p = overrides; *p != NULL; p++) { int index; char *str, *value; const char *label; struct dll *dll; value = get_reg_key(config_key, keypath("DllOverrides"), *p, NULL); label = mode_to_label(string_to_mode(value)); str = HeapAlloc(GetProcessHeap(), 0, strlen(*p) + 2 + strlen(label) + 2); strcpy(str, *p); strcat(str, " ("); strcat(str, label); strcat(str, ")"); dll = HeapAlloc(GetProcessHeap(), 0, sizeof(struct dll)); dll->name = *p; dll->mode = string_to_mode(value); index = SendDlgItemMessageA(dialog, IDC_DLLS_LIST, LB_ADDSTRING, (WPARAM) -1, (LPARAM) str); SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_SETITEMDATA, index, (LPARAM) dll); HeapFree(GetProcessHeap(), 0, str); count++; } HeapFree(GetProcessHeap(), 0, overrides); /* restore the previous selection, if possible */ if (sel >= count - 1) sel = count - 1; else if (sel == -1) sel = 0; SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_SETCURSEL, sel, 0); set_controls_from_selection(dialog); }
INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_AUDIO_CONFIGURE: configureAudioDriver(hDlg); break; case IDC_AUDIO_TEST: if(!PlaySound(MAKEINTRESOURCE(IDW_TESTSOUND), NULL, SND_RESOURCE | SND_SYNC)) MessageBox(NULL, "Audio test failed!", "Error", MB_OK | MB_ICONERROR); break; case IDC_AUDIO_CONTROL_PANEL: MessageBox(NULL, "Launching audio control panel not implemented yet!", "Fixme", MB_OK | MB_ICONERROR); break; case IDC_DSOUND_HW_ACCEL: if (HIWORD(wParam) == CBN_SELCHANGE) { int selected_dsound_accel; int i, j = 0; SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); selected_dsound_accel = SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_GETCURSEL, 0, 0); for (i = 0; DSound_HW_Accels[i].settingStr; ++i) { if (DSound_HW_Accels[i].visible) { if (j == selected_dsound_accel) { set_reg_key(config_key, keypath("DirectSound"), "HardwareAcceleration", DSound_HW_Accels[i].settingStr); break; } j++; } } } break; case IDC_DSOUND_RATES: if (HIWORD(wParam) == CBN_SELCHANGE) { int selected_dsound_rate; SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); selected_dsound_rate = SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_GETCURSEL, 0, 0); set_reg_key(config_key, keypath("DirectSound"), "DefaultSampleRate", DSound_Rates[selected_dsound_rate]); } break; case IDC_DSOUND_BITS: if (HIWORD(wParam) == CBN_SELCHANGE) { int selected_dsound_bits; SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); selected_dsound_bits = SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_GETCURSEL, 0, 0); set_reg_key(config_key, keypath("DirectSound"), "DefaultBitsPerSample", DSound_Bits[selected_dsound_bits]); } break; } break; case WM_SHOWWINDOW: set_window_title(hDlg); break; case WM_NOTIFY: switch(((LPNMHDR)lParam)->code) { case PSN_KILLACTIVE: SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE); break; case PSN_APPLY: set_reg_key(config_key, "Drivers", "Audio", curAudioDriver); apply(); SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR); break; case PSN_SETACTIVE: break; case NM_CLICK: if (((LPNMHDR)lParam)->idFrom == IDC_AUDIO_TREE) { TVHITTESTINFO ht; DWORD dwPos = GetMessagePos(); HWND tree = ((LPNMHDR)lParam)->hwndFrom; ZeroMemory(&ht, sizeof(ht)); ht.pt.x = (short)LOWORD(dwPos); ht.pt.y = (short)HIWORD(dwPos); MapWindowPoints(HWND_DESKTOP, tree, &ht.pt, 1); SendMessageW( tree, TVM_HITTEST, 0, (LPARAM)&ht ); if (TVHT_ONITEMSTATEICON & ht.flags) { TVITEM tvItem; int index; ZeroMemory(&tvItem, sizeof(tvItem)); tvItem.hItem = ht.hItem; SendMessageW( tree, TVM_GETITEMW, 0, (LPARAM) &tvItem ); index = TreeView_GetItemState(tree, ht.hItem, TVIS_STATEIMAGEMASK); if (index == INDEXTOSTATEIMAGEMASK(1)) { TreeView_SetItemState(tree, ht.hItem, INDEXTOSTATEIMAGEMASK(2), TVIS_STATEIMAGEMASK); addDriver(loadedAudioDrv[tvItem.lParam & 0xff].szDriver); SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM) hDlg, 0); /* enable apply button */ } else if (index == INDEXTOSTATEIMAGEMASK(2)) { TreeView_SetItemState(tree, ht.hItem, INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK); removeDriver(loadedAudioDrv[tvItem.lParam & 0xff].szDriver); SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM) hDlg, 0); /* enable apply button */ } } } break; case NM_RCLICK: if (((LPNMHDR)lParam)->idFrom == IDC_AUDIO_TREE) { TVHITTESTINFO ht; DWORD dwPos = GetMessagePos(); HWND tree = ((LPNMHDR)lParam)->hwndFrom; POINT pt; ZeroMemory(&ht, sizeof(ht)); pt.x = (short)LOWORD(dwPos); pt.y = (short)HIWORD(dwPos); ht.pt = pt; MapWindowPoints(HWND_DESKTOP, tree, &ht.pt, 1); SendMessageW( tree, TVM_HITTEST, 0, (LPARAM)&ht ); if (TVHT_ONITEMLABEL & ht.flags) { TVITEM tvItem; ZeroMemory(&tvItem, sizeof(tvItem)); tvItem.hItem = ht.hItem; tvItem.mask = TVIF_PARAM; tvItem.lParam = -1; if (TreeView_GetItem(tree, &tvItem)) { if (tvItem.lParam & DRIVER_MASK) { if (hPopupMenus) { TrackPopupMenu(GetSubMenu(hPopupMenus, 0), TPM_RIGHTBUTTON, pt.x, pt.y, 0, tree, NULL); toConfigure = tvItem.lParam & ~DRIVER_MASK; } } else if (tvItem.lParam & DEVICE_MASK) { /* FIXME TBD */ } } } } } break; case WM_INITDIALOG: initAudioDlg(hDlg); break; } return FALSE; }
static void initAudioDlg (HWND hDlg) { int i, j, found; char* buf = NULL; WINE_TRACE("\n"); /* make a list of all drivers that can be loaded */ findAudioDrivers(); /* get current registry setting if available */ buf = get_reg_key(config_key, "Drivers", "Audio", NULL); /* check for first time install and set a default driver * select first available driver, and if that fails: none */ if (buf == NULL) { /* select first available driver */ if (*loadedAudioDrv->szDriver) selectDriver(hDlg, loadedAudioDrv->szDriver); } else /* make a local copy of the current registry setting */ strcpy(curAudioDriver, buf); WINE_TRACE("curAudioDriver = %s\n", curAudioDriver); /* check for drivers that can't be loaded */ checkRegistrySetting(hDlg); initAudioDeviceTree(hDlg); SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_RESETCONTENT, 0, 0); buf = get_reg_key(config_key, keypath("DirectSound"), "HardwareAcceleration", "Full"); j = found = 0; for (i = 0; 0 != DSound_HW_Accels[i].displayID; ++i) { WCHAR accelStr[64]; int match; match = (strcmp(buf, DSound_HW_Accels[i].settingStr) == 0); if (match) { DSound_HW_Accels[i].visible = 1; found = 1; } if (DSound_HW_Accels[i].visible) { LoadStringW (GetModuleHandle (NULL), DSound_HW_Accels[i].displayID, accelStr, sizeof(accelStr)/sizeof(accelStr[0])); SendDlgItemMessageW (hDlg, IDC_DSOUND_HW_ACCEL, CB_ADDSTRING, 0, (LPARAM)accelStr); if (match) SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_SETCURSEL, j, 0); j++; } } if (!found) { WINE_ERR("Invalid Direct Sound HW Accel read from registry (%s)\n", buf); } HeapFree(GetProcessHeap(), 0, buf); SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_RESETCONTENT, 0, 0); for (i = 0; NULL != DSound_Rates[i]; ++i) { SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_ADDSTRING, 0, (LPARAM) DSound_Rates[i]); } buf = get_reg_key(config_key, keypath("DirectSound"), "DefaultSampleRate", "44100"); for (i = 0; NULL != DSound_Rates[i]; ++i) { if (strcmp(buf, DSound_Rates[i]) == 0) { SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_SETCURSEL, i, 0); break ; } } SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_RESETCONTENT, 0, 0); for (i = 0; NULL != DSound_Bits[i]; ++i) { SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_ADDSTRING, 0, (LPARAM) DSound_Bits[i]); } buf = get_reg_key(config_key, keypath("DirectSound"), "DefaultBitsPerSample", "16"); for (i = 0; NULL != DSound_Bits[i]; ++i) { if (strcmp(buf, DSound_Bits[i]) == 0) { SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_SETCURSEL, i, 0); break ; } } HeapFree(GetProcessHeap(), 0, buf); }
bool QgsAuthPkiPathsEdit::validateConfig() { // required components QString certpath( lePkiPathsCert->text() ); QString keypath( lePkiPathsKey->text() ); bool certfound = QFile::exists( certpath ); bool keyfound = QFile::exists( keypath ); QgsAuthGuiUtils::fileFound( certpath.isEmpty() || certfound, lePkiPathsCert ); QgsAuthGuiUtils::fileFound( keypath.isEmpty() || keyfound, lePkiPathsKey ); if ( !certfound || !keyfound ) { writePkiMessage( lePkiPathsMsg, tr( "Missing components" ), Invalid ); return validityChange( false ); } // check for issue date validity, then notify status QSslCertificate cert; QFile file( certpath ); QFileInfo fileinfo( file ); QString ext( fileinfo.fileName().replace( fileinfo.completeBaseName(), "" ).toLower() ); if ( ext.isEmpty() ) { writePkiMessage( lePkiPathsMsg, tr( "Certificate file has no extension" ), Invalid ); return validityChange( false ); } QFile::OpenMode openflags( QIODevice::ReadOnly ); QSsl::EncodingFormat encformat( QSsl::Der ); if ( ext == ".pem" ) { openflags |= QIODevice::Text; encformat = QSsl::Pem; } if ( file.open( openflags ) ) { cert = QSslCertificate( file.readAll(), encformat ); file.close(); } else { writePkiMessage( lePkiPathsMsg, tr( "Failed to read certificate file" ), Invalid ); return validityChange( false ); } if ( cert.isNull() ) { writePkiMessage( lePkiPathsMsg, tr( "Failed to load certificate from file" ), Invalid ); return validityChange( false ); } bool certvalid = cert.isValid(); QDateTime startdate( cert.effectiveDate() ); QDateTime enddate( cert.expiryDate() ); writePkiMessage( lePkiPathsMsg, tr( "%1 thru %2" ).arg( startdate.toString(), enddate.toString() ), ( certvalid ? Valid : Invalid ) ); return validityChange( certvalid ); }