--- /dev/null
+; Script generated by the Inno Setup Script Wizard.
+; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
+
+#define MyAppName "WinMute"
+#define MyAppVersion "2.0.0.0"
+#define MyAppPublisher "LX-Systems"
+#define MyAppURL "https://www.lx-s.de/winmute"
+#define MyAppExeName "WinMute.exe"
+
+[Setup]
+; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
+; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
+AppId={{D2E8F9EF-11E7-418B-B9B7-A35A69A30490}
+AppName={#MyAppName}
+AppVersion={#MyAppVersion}
+;AppVerName={#MyAppName} {#MyAppVersion}
+AppPublisher={#MyAppPublisher}
+AppPublisherURL={#MyAppURL}
+AppSupportURL={#MyAppURL}
+AppUpdatesURL={#MyAppURL}
+DefaultDirName={autopf}\{#MyAppName}
+DisableProgramGroupPage=yes
+LicenseFile=E:\Development\Code\WinMute\Dist\bin\license.txt
+InfoAfterFile=E:\Development\Code\WinMute\Dist\bin\readme.html
+; Uncomment the following line to run in non administrative install mode (install for current user only.)
+;PrivilegesRequired=lowest
+PrivilegesRequiredOverridesAllowed=dialog
+OutputDir=E:\Development\Code\WinMute\Build\Setup
+OutputBaseFilename=wm-setup
+SetupIconFile=E:\Development\Code\WinMute\WinMute\icons\app.ico
+Compression=lzma
+SolidCompression=yes
+WizardStyle=modern
+
+[Languages]
+Name: "english"; MessagesFile: "compiler:Default.isl"
+
+[Tasks]
+Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
+
+[Files]
+Source: "E:\Development\Code\WinMute\Dist\bin\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
+Source: "E:\Development\Code\WinMute\Dist\bin\changelog.txt"; DestDir: "{app}"; Flags: ignoreversion
+Source: "E:\Development\Code\WinMute\Dist\bin\license.txt"; DestDir: "{app}"; Flags: ignoreversion
+Source: "E:\Development\Code\WinMute\Dist\bin\liesmich.html"; DestDir: "{app}"; Flags: ignoreversion
+Source: "E:\Development\Code\WinMute\Dist\bin\readme.html"; DestDir: "{app}"; Flags: ignoreversion
+Source: "E:\Development\Code\WinMute\Dist\bin\ScreensaverNotify.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: "E:\Development\Code\WinMute\Dist\bin\ScreensaverNotify32.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: "E:\Development\Code\WinMute\Dist\bin\ScreensaverProxy32.exe"; DestDir: "{app}"; Flags: ignoreversion
+; NOTE: Don't use "Flags: ignoreversion" on any shared system files
+
+[Icons]
+Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
+Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
+
+[Run]
+Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
+
bool BluetoothDetector::LoadRadioNotifications()
{
bool success = false;
+ auto& log = WMLog::GetInstance();
notificationHandles_.clear();
BLUETOOTH_FIND_RADIO_PARAMS bfrp = { sizeof(BLUETOOTH_FIND_RADIO_PARAMS) };
HANDLE btHandle;
HBLUETOOTH_RADIO_FIND hRadiosFind = BluetoothFindFirstRadio(&bfrp, &btHandle);
if (hRadiosFind == nullptr) {
- PrintWindowsError(L"BluetoothFindFirstRadio");
+ log.WriteWindowsError(L"BluetoothFindFirstRadio", GetLastError());
return false;
}
CloseHandle(btHandle);
if (devNotify == NULL) {
- PrintWindowsError(L"RegisterDeviceNotification", GetLastError());
+ log.WriteWindowsError(L"RegisterDeviceNotification", GetLastError());
} else {
notificationHandles_.push_back(devNotify);
}
} while (BluetoothFindNextRadio(hRadiosFind, &btHandle));
DWORD dwLastError = GetLastError();
if (dwLastError != ERROR_NO_MORE_ITEMS) {
- PrintWindowsError(L"BluetoothFindNextRadio");
+ log.WriteWindowsError(L"BluetoothFindNextRadio", GetLastError());
UnloadRadioNotifications();
} else {
success = true;
return BluetoothStatus::Unknown;
}
+ // only react to audio devices and not (e. g.) game controllers
+ if ((inRangeInfo->deviceInfo.flags & BDIF_COD) &&
+ GET_COD_MAJOR(inRangeInfo->deviceInfo.classOfDevice) != COD_MAJOR_AUDIO &&
+ GET_COD_MAJOR(inRangeInfo->deviceInfo.classOfDevice) != COD_MAJOR_PHONE) {
+ return BluetoothStatus::Unknown;
+ }
+
+ auto& log = WMLog::GetInstance();
if (inRangeInfo->deviceInfo.flags & BDIF_CONNECTED) {
+ log.Write(L"Bluetooth Audio device \"%S\" connected.", inRangeInfo->deviceInfo.name);
return BluetoothStatus::Connected;
}
-
+ log.Write(L"Bluetooth Audio device \"%S\" disconnected.", inRangeInfo->deviceInfo.name);
return BluetoothStatus::Disconnected;
}
va_end(ap);
}
+
+void WMLog::WriteWindowsError(LPCWSTR lpszFunction, DWORD lastError)
+{
+ // Retrieve the system error message for the last-error code
+ if (lastError == -1) {
+ lastError = GetLastError();
+ }
+
+ LPVOID lpMsgBuf;
+ if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ nullptr, lastError,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ reinterpret_cast<LPTSTR>(&lpMsgBuf), 0, nullptr) != 0) {
+ size_t displayBufSize =
+ ((size_t)lstrlen(static_cast<LPCTSTR>(lpMsgBuf)) +
+ (size_t)lstrlen(static_cast<LPCTSTR>(lpszFunction))
+ + 40) * sizeof(TCHAR);
+ // Display the error message and exit the process
+ LPVOID lpDisplayBuf = reinterpret_cast<LPVOID>(
+ LocalAlloc(LMEM_ZEROINIT, displayBufSize));
+ if (lpDisplayBuf) {
+ StringCchPrintf((LPTSTR)lpDisplayBuf,
+ LocalSize(lpDisplayBuf),
+ _T("%s failed with error %u: %s"),
+ lpszFunction,
+ lastError,
+ reinterpret_cast<TCHAR*>(lpMsgBuf));
+ WriteMessage(static_cast<LPCTSTR>(lpMsgBuf));
+ LocalFree(lpDisplayBuf);
+ }
+ LocalFree(lpMsgBuf);
+ }
+}
static WMLog& GetInstance();
void Write(const TCHAR* fmt, ...);
+ void WriteWindowsError(LPCWSTR lpszFunction, DWORD errorCode = -1);
void SetEnabled(bool enable);
std::string GetLogFilePath();