Author: janderwald
Date: Mon Mar 9 14:51:28 2009
New Revision: 39915
URL:
http://svn.reactos.org/svn/reactos?rev=39915&view=rev
Log:
- Register default sound schemes when an new audio adapter is installed
- Pass the full filename to PlaySound as the sound might not be in standard location
Modified:
trunk/reactos/dll/cpl/mmsys/mmsys.c
trunk/reactos/dll/cpl/mmsys/resource.h
trunk/reactos/dll/cpl/mmsys/sounds.c
Modified: trunk/reactos/dll/cpl/mmsys/mmsys.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/mmsys/mmsys.c?rev=…
==============================================================================
--- trunk/reactos/dll/cpl/mmsys/mmsys.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/mmsys/mmsys.c [iso-8859-1] Mon Mar 9 14:51:28 2009
@@ -30,6 +30,62 @@
HWPD_MAX = HWPD_LARGELIST
} HWPAGE_DISPLAYMODE, *PHWPAGE_DISPLAYMODE;
+typedef struct
+{
+ LPWSTR LabelName;
+ LPWSTR DefaultName;
+ UINT LocalizedResId;
+ LPWSTR FileName;
+}EVENT_LABEL_ITEM;
+
+typedef struct
+{
+ LPWSTR LabelName;
+ LPWSTR DefaultName;
+ UINT IconId;
+}SYSTEM_SCHEME_ITEM;
+
+static EVENT_LABEL_ITEM EventLabels[] =
+{
+ {
+ L"WindowsLogon",
+ L"ReactOS Logon",
+ IDS_REACTOS_LOGON,
+ L"ReactOS_Logon.wav"
+ },
+ {
+ L"WindowsLogoff",
+ L"ReactOS Logoff",
+ IDS_REACTOS_LOGOFF,
+ L"ReactOS_Logoff.wav"
+ },
+ {
+ NULL,
+ NULL,
+ 0,
+ NULL
+ }
+};
+
+static SYSTEM_SCHEME_ITEM SystemSchemes[] =
+{
+ {
+ L".Default",
+ L"ReactOS Standard",
+ IDS_REACTOS_DEFAULT_SCHEME
+ },
+ {
+ L".None",
+ L"No Sounds",
+ -1
+ },
+ {
+ NULL,
+ NULL
+ }
+};
+
+
HWND WINAPI
DeviceCreateHardwarePageEx(HWND hWndParent,
LPGUID lpGuids,
@@ -155,6 +211,127 @@
{
DPRINT1("ShowFullControlPanel() stubs\n");
}
+
+VOID
+InstallSystemSoundLabels(HKEY hKey)
+{
+ UINT i = 0;
+ HKEY hSubKey;
+ WCHAR Buffer[40];
+
+ do
+ {
+ if (RegCreateKeyExW(hKey, EventLabels[i].LabelName, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubKey, NULL) == ERROR_SUCCESS)
+ {
+ RegSetValueExW(hSubKey, NULL, 0, REG_SZ, (LPBYTE)EventLabels[i].DefaultName,
(wcslen(EventLabels[i].DefaultName)+1) * sizeof(WCHAR));
+ swprintf(Buffer, L"(a)mmsys.cpl,-%u",-%u",
EventLabels[i].LocalizedResId);
+ RegSetValueExW(hSubKey, L"DispFileName", 0, REG_SZ, (LPBYTE)Buffer,
(wcslen(Buffer)+1) * sizeof(WCHAR));
+
+ RegCloseKey(hSubKey);
+ }
+ i++;
+ }while(EventLabels[i].LabelName);
+}
+
+VOID
+InstallSystemSoundSchemeNames(HKEY hKey)
+{
+ UINT i = 0;
+ HKEY hSubKey;
+
+ do
+ {
+ if (RegCreateKeyExW(hKey, SystemSchemes[i].LabelName, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubKey, NULL) == ERROR_SUCCESS)
+ {
+ RegSetValueExW(hSubKey, NULL, 0, REG_SZ,
(LPBYTE)SystemSchemes[i].DefaultName, (wcslen(SystemSchemes[i].DefaultName)+1) *
sizeof(WCHAR));
+ RegCloseKey(hSubKey);
+ }
+ i++;
+ }while(SystemSchemes[i].LabelName);
+}
+
+VOID
+InstallDefaultSystemSoundScheme(HKEY hRootKey)
+{
+ HKEY hKey, hSubKey;
+ WCHAR Path[MAX_PATH];
+ UINT i = 0;
+
+ if (RegCreateKeyExW(hRootKey, L".Default", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL) != ERROR_SUCCESS)
+ return;
+
+ RegSetValueExW(hKey, NULL, 0, REG_SZ, (LPBYTE)SystemSchemes[0].DefaultName,
(wcslen(SystemSchemes[0].DefaultName)+1) * sizeof(WCHAR));
+ swprintf(Path, L"(a)mmsys.cpl,-%u",-%u", SystemSchemes[0].IconId);
+ RegSetValueExW(hKey, L"DispFileName", 0, REG_SZ, (LPBYTE)Path,
(wcslen(Path)+1) * sizeof(WCHAR));
+
+ do
+ {
+ if (RegCreateKeyExW(hKey, EventLabels[i].LabelName, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubKey, NULL) == ERROR_SUCCESS)
+ {
+ HKEY hScheme;
+
+ swprintf(Path, L"%%SystemRoot%%\\media\\%s",
EventLabels[i].FileName);
+ if (RegCreateKeyExW(hSubKey, L".Current", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hScheme, NULL) == ERROR_SUCCESS)
+ {
+ RegSetValueExW(hScheme, NULL, 0, REG_SZ, (LPBYTE)Path, (wcslen(Path)+1) *
sizeof(WCHAR));
+ RegCloseKey(hScheme);
+ }
+
+ if (RegCreateKeyExW(hSubKey, L".Default", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hScheme, NULL) == ERROR_SUCCESS)
+ {
+ RegSetValueExW(hScheme, NULL, 0, REG_SZ, (LPBYTE)Path, (wcslen(Path)+1) *
sizeof(WCHAR));
+ RegCloseKey(hScheme);
+ }
+ RegCloseKey(hSubKey);
+ }
+ i++;
+ }while(EventLabels[i].LabelName);
+
+ RegCloseKey(hKey);
+}
+
+
+VOID
+InstallSystemSoundScheme()
+{
+ HKEY hKey, hSubKey;
+ DWORD dwDisposition;
+
+ if (RegCreateKeyExW(HKEY_CURRENT_USER, L"AppEvents", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL) != ERROR_SUCCESS)
+ return;
+
+ if (RegCreateKeyExW(hKey, L"EventLabels", 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &hSubKey, NULL) == ERROR_SUCCESS)
+ {
+ InstallSystemSoundLabels(hSubKey);
+ RegCloseKey(hSubKey);
+ }
+
+ if (RegCreateKeyExW(hKey, L"Schemes", 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &hSubKey, &dwDisposition) == ERROR_SUCCESS)
+ {
+ HKEY hNames;
+
+ if (RegCreateKeyExW(hSubKey, L"Names", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hNames, NULL) == ERROR_SUCCESS)
+ {
+ InstallSystemSoundSchemeNames(hNames);
+ RegCloseKey(hNames);
+ }
+
+ if (RegCreateKeyExW(hSubKey, L"Apps", 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &hNames, NULL) == ERROR_SUCCESS)
+ {
+ InstallDefaultSystemSoundScheme(hNames);
+ RegCloseKey(hNames);
+ if (dwDisposition & REG_CREATED_NEW_KEY)
+ {
+ RegSetValueExW(hSubKey, NULL, 0, REG_SZ, (LPBYTE)L".Default",
(wcslen(L".Default")+1) * sizeof(WCHAR)); //FIXME
+ }
+ }
+
+ RegCloseKey(hSubKey);
+ }
+
+ RegCloseKey(hKey);
+}
+
DWORD
MMSYS_InstallDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pspDevInfoData)
@@ -263,6 +440,7 @@
}
RegCloseKey(hKey);
}
+ InstallSystemSoundScheme();
return ERROR_DI_DO_DEFAULT;
Modified: trunk/reactos/dll/cpl/mmsys/resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/mmsys/resource.h?r…
==============================================================================
--- trunk/reactos/dll/cpl/mmsys/resource.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/mmsys/resource.h [iso-8859-1] Mon Mar 9 14:51:28 2009
@@ -66,6 +66,11 @@
#define IDC_SPEAKIMG 4625
#define IDC_MUTE_ICON 4626
+#define IDS_REACTOS_LOGON 5853
+#define IDS_REACTOS_LOGOFF 5852
+#define IDS_REACTOS_DEFAULT_SCHEME 5856
+
+
/* Strings */
#define IDS_CPLNAME 1000
#define IDS_CPLDESCRIPTION 1001
Modified: trunk/reactos/dll/cpl/mmsys/sounds.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/mmsys/sounds.c?rev…
==============================================================================
--- trunk/reactos/dll/cpl/mmsys/sounds.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/mmsys/sounds.c [iso-8859-1] Mon Mar 9 14:51:28 2009
@@ -826,15 +826,17 @@
case IDC_PLAY_SOUND:
{
LRESULT lIndex;
- TCHAR szValue[MAX_PATH];
-
lIndex = SendDlgItemMessage(hwndDlg, IDC_SOUND_LIST, CB_GETCURSEL,
(WPARAM)0, (LPARAM)0);
if (lIndex == CB_ERR)
{
break;
}
- SendDlgItemMessage(hwndDlg, IDC_SOUND_LIST, CB_GETLBTEXT,
(WPARAM)lIndex, (LPARAM)szValue);
- PlaySound(szValue, NULL, SND_FILENAME);
+
+ lIndex = SendDlgItemMessage(hwndDlg, IDC_SOUND_LIST, CB_GETITEMDATA,
(WPARAM)lIndex, (LPARAM)0);
+ if (lIndex != CB_ERR)
+ {
+ PlaySound((TCHAR*)lIndex, NULL, SND_FILENAME);
+ }
break;
}
case IDC_SOUND_SCHEME: