📄 phoneext.cpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
#include <windows.h>
#include "btagpub.h"
#define ZONE_PHONEUI DEBUGZONE(6)
#define ZONE_WARN DEBUGZONE(14)
#define ZONE_ERROR DEBUGZONE(15)
#ifndef PREFAST_ASSERT
#define PREFAST_ASSERT(x) ASSERT(x)
#endif
// This function is called to initialize the AG
DWORD BthAGPhoneExtInit(void)
{
return ERROR_SUCCESS;
}
// This function is called to deinitialize the AG
void BthAGPhoneExtDeinit(void)
{
}
// This function provides informational events related to the phone
void BthAGPhoneExtEvent(DWORD dwEvent, DWORD dwParam, VOID* pvParam2)
{
switch (dwEvent) {
case AG_PHONE_EVENT_VOICE_RECOG:
DEBUGMSG(ZONE_PHONEUI, (L"BTAGSVC: *** Audio Gateway voice recognition has been updated to: %d ***\n", dwParam));
break;
case AG_PHONE_EVENT_SPEAKER_VOLUME:
DEBUGMSG(ZONE_PHONEUI, (L"BTAGSVC: *** Audio Gateway speaker volume has been updated to: %d ***\n", dwParam));
break;
case AG_PHONE_EVENT_MIC_VOLUME:
DEBUGMSG(ZONE_PHONEUI, (L"BTAGSVC: *** Audio Gateway mic volume has been updated to: %d ***\n", dwParam));
break;
case AG_PHONE_EVENT_BT_CTRL:
DEBUGMSG(ZONE_PHONEUI, (L"BTAGSVC: *** Audio Gateway Bluetooth control connection has been updated to: %d ***\n", dwParam));
break;
case AG_PHONE_EVENT_BT_AUDIO:
DEBUGMSG(ZONE_PHONEUI, (L"BTAGSVC: *** Audio Gateway Bluetooth audio connection has been updated to: %d ***\n", dwParam));
break;
default:
DEBUGMSG(ZONE_PHONEUI, (L"BTAGSVC: Unknown PhoneExt event: %d param:%d.\n", dwEvent, dwParam));
}
}
// This function returns TRUE if the call should be taken by Bluetooth AG
BOOL BthAGOverrideCallOut(BOOL fHandsfree)
{
HKEY hk;
DWORD dwErr = RegOpenKeyEx(HKEY_LOCAL_MACHINE, RK_AUDIO_GATEWAY, 0, 0, &hk);
if (dwErr == ERROR_SUCCESS) {
DWORD cdwBytes = sizeof(DWORD);
DWORD dwData = 0;
dwErr = RegQueryValueEx(hk, _T("OutgoingCallOption"), 0, NULL, (PBYTE)&dwData, &cdwBytes);
if (dwErr == ERROR_SUCCESS) {
if (dwData == 1) {
// Take in headset
RegCloseKey(hk);
return TRUE;
}
else if (dwData == 2) {
// Take in handset
RegCloseKey(hk);
return FALSE;
}
}
}
RegCloseKey(hk);
return (IDNO == MessageBox(NULL, L"Switch audio back to phone?", L"Bluetooth Headset", MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND));
}
// This function returns TRUE if the call should be taken by Bluetooth AG
BOOL BthAGOverrideCallIn(BOOL fHandsfree)
{
return TRUE;
}
// This function associates a phone number with a name (pszName is a buffer of size MAX_DISPLAY_NAME)
BOOL BthAGGetNameByPhoneNumber(LPCSTR pszNumber, LPWSTR pwszName)
{
return FALSE;
}
// This function is called to get speed dial info for the specified hands-free memory index
BOOL BthAGGetSpeedDial(unsigned short usIndex, LPWSTR pwszNumber)
{
return FALSE;
}
// This function is called to get the last dialed number on the phone (pszNumber is a buffer of size MAX_PHONE_NUMBER)
BOOL BthAGGetLastDialed(LPWSTR pwszNumber)
{
return FALSE;
}
// This function registers callbacks for the state of the cell service. The callback pfn must be called once immediately
// to set the initial service state and then only when there is a change in service state.
DWORD BthAGSetServiceCallback(PFN_PhoneExtServiceCallback pfn)
{
PREFAST_ASSERT(pfn);
pfn(TRUE); // We have cell service
return ERROR_SUCCESS;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -