Пример #1
0
void
FrameworkView::PerformURILoadOrSearch(HString& aString)
{
  LogFunction();

  if (WindowsIsStringEmpty(aString.Get())) {
    WinUtils::Log("Emptry string passed to PerformURILoadOrSearch");
    return;
  }

  // If we have a URI then devert to load the URI directly
  ComPtr<IUriRuntimeClass> uri;
  MetroUtils::CreateUri(aString.Get(), uri);
  if (uri) {
    PerformURILoad(aString);
  } else {
    PerformSearch(aString);
  }
}
Пример #2
0
void
FrameworkView::FileActivated(ComPtr<IFileActivatedEventArgs>& aArgs, bool aStartup)
{
  if (!aArgs)
    return;

  ComPtr<IVectorView<ABI::Windows::Storage::IStorageItem*>> list;
  AssertHRESULT(aArgs->get_Files(list.GetAddressOf()));
  ComPtr<ABI::Windows::Storage::IStorageItem> item;
  AssertHRESULT(list->GetAt(0, item.GetAddressOf()));
  HString filePath;
  AssertHRESULT(item->get_Path(filePath.GetAddressOf()));

  if (aStartup) {
    WindowsDuplicateString(filePath.Get(), &sActivationURI);
  } else {
    PerformURILoad(filePath);
  }
}
Пример #3
0
void
FrameworkView::ProcessActivationArgs(IActivatedEventArgs* aArgs, bool aStartup)
{
  ActivationKind kind;
  if (!aArgs || FAILED(aArgs->get_Kind(&kind)))
    return;
  ComPtr<IActivatedEventArgs> args(aArgs);
  if (kind == ActivationKind::ActivationKind_Protocol) {
    WinUtils::Log("Activation argument kind: Protocol");
    ComPtr<IProtocolActivatedEventArgs> protoArgs;
    AssertHRESULT(args.As(&protoArgs));
    ComPtr<IUriRuntimeClass> uri;
    AssertHRESULT(protoArgs->get_Uri(uri.GetAddressOf()));
    if (!uri)
      return;

    HString data;
    AssertHRESULT(uri->get_AbsoluteUri(data.GetAddressOf()));
    if (WindowsIsStringEmpty(data.Get()))
      return;

    if (aStartup) {
      WindowsDuplicateString(data.Get(), &sActivationURI);
    } else {
      PerformURILoad(data);
    }
  } else if (kind == ActivationKind::ActivationKind_Search) {
    WinUtils::Log("Activation argument kind: Search");
    ComPtr<ISearchActivatedEventArgs> searchArgs;
    args.As(&searchArgs);
    SearchActivated(searchArgs, aStartup);
  } else if (kind == ActivationKind::ActivationKind_File) {
    WinUtils::Log("Activation argument kind: File");
    ComPtr<IFileActivatedEventArgs> fileArgs;
    args.As(&fileArgs);
    FileActivated(fileArgs, aStartup);
  } else if (kind == ActivationKind::ActivationKind_Launch) {
    WinUtils::Log("Activation argument kind: Launch");
    ComPtr<ILaunchActivatedEventArgs> launchArgs;
    args.As(&launchArgs);
    LaunchActivated(launchArgs, aStartup);
  }
}
Пример #4
0
void
FrameworkView::SearchActivated(ComPtr<ISearchActivatedEventArgs>& aArgs, bool aStartup)
{
  if (!aArgs)
    return;

  HString data;
  AssertHRESULT(aArgs->get_QueryText(data.GetAddressOf()));
  if (WindowsIsStringEmpty(data.Get()))
    return;

  unsigned int length;
  WinUtils::LogW(L"SearchActivated text=%s", data.GetRawBuffer(&length));
  if (aStartup) {
    WindowsDuplicateString(data.Get(), &sActivationURI);
  } else {
    PerformURILoadOrSearch(data);
  }
}
    HRESULT onDeviceRemoved(IDeviceWatcher *, IDeviceInformationUpdate *device)
    {
        HRESULT hr;
        HString id;
        hr = device->get_Id(id.GetAddressOf());
        Q_ASSERT_SUCCEEDED(hr);

        HString name;
        hr = device->get_Id(name.GetAddressOf());
        Q_ASSERT_SUCCEEDED(hr);
        quint32 nameLength;
        const wchar_t *nameString = name.GetRawBuffer(&nameLength);
        const int index = deviceIndex.take(QString::fromWCharArray(nameString, nameLength));
        if (index >= 0)
            devices.remove(index);

        foreach (QWinRTVideoDeviceSelectorControl *watcher, watchers)
            emit watcher->devicesChanged();

        return S_OK;
    }
Пример #6
0
void
FrameworkView::AddSetting(ISettingsPaneCommandsRequestedEventArgs* aArgs,
                          uint32_t aId, HString& aSettingName)
{
  HRESULT hr;

  ComPtr<ABI::Windows::UI::ApplicationSettings::ISettingsPaneCommandsRequest> request;
  AssertHRESULT(aArgs->get_Request(request.GetAddressOf()));

  // ApplicationCommands - vector that holds SettingsCommand to be invoked
  ComPtr<IVector<ABI::Windows::UI::ApplicationSettings::SettingsCommand*>> list;
  AssertHRESULT(request->get_ApplicationCommands(list.GetAddressOf()));

  ComPtr<IUICommand> command;
  ComPtr<ISettingsCommandFactory> factory;
  hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ApplicationSettings_SettingsCommand).Get(),
                            factory.GetAddressOf());
  AssertHRESULT(hr);

  // Create the IInspectable string property that identifies this command
  ComPtr<IInspectable> prop;
  ComPtr<IPropertyValueStatics> propStatics;
  hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Foundation_PropertyValue).Get(),
                            propStatics.GetAddressOf());
  AssertHRESULT(hr);
  hr = propStatics->CreateUInt32(aId, prop.GetAddressOf());
  AssertHRESULT(hr);

  // Create the command
  hr = factory->CreateSettingsCommand(prop.Get(), aSettingName.Get(),
    Callback<ABI::Windows::UI::Popups::IUICommandInvokedHandler>(
      this, &FrameworkView::OnSettingsCommandInvoked).Get(), command.GetAddressOf());
  AssertHRESULT(hr);

  // Add it to the list
  hr = list->Append(command.Get());
  AssertHRESULT(hr);
}
Пример #7
0
QString QHostInfo::localHostName()
{
    ComPtr<INetworkInformationStatics> statics;
    GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_Connectivity_NetworkInformation).Get(), &statics);

    ComPtr<IVectorView<HostName *>> hostNames;
    statics->GetHostNames(&hostNames);
    if (!hostNames)
        return QString();

    unsigned int size;
    hostNames->get_Size(&size);
    if (size == 0)
        return QString();

    for (unsigned int i = 0; i < size; ++i) {
        ComPtr<IHostName> hostName;
        hostNames->GetAt(i, &hostName);
        HostNameType type;
        hostName->get_Type(&type);
        if (type != HostNameType_DomainName)
            continue;

        HString name;
        hostName->get_CanonicalName(name.GetAddressOf());
        UINT32 length;
        PCWSTR rawString = name.GetRawBuffer(&length);
        return QString::fromWCharArray(rawString, length);
    }
    ComPtr<IHostName> firstHost;
    hostNames->GetAt(0, &firstHost);

    HString name;
    firstHost->get_CanonicalName(name.GetAddressOf());
    UINT32 length;
    PCWSTR rawString = name.GetRawBuffer(&length);
    return QString::fromWCharArray(rawString, length);
}
Пример #8
0
LRESULT MyProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	static BOOL bActiveApp = FALSE;

	switch (message)
	{
			case UWM_TOPBAR_BACK:
			{
				//UI_TranslateMsg(message, wParam, lParam, false);
					BTDEBUGINFO(L"IPC_ID_MANAGE:UWM_TOPBAR_BACK");
					HWND hServerWnd = CEIPC_GetHWND(IPC_ID_MANAGE);
					if (NULL != hServerWnd)
					{
						::PostMessage(hServerWnd, UWM_TOPBAR_HOME, 0, 0);
					}	
			}
			break;
			case VWM_SERVER_CHANGE_MODE: // wParam: START_BT_DLG_AUDIO 4 iParam 0后台 1前台
				{
					HCBTConnectionssettingDlg* pObj = static_cast<HCBTConnectionssettingDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCONNECTSETTING));
					eDIALOGTYPE eType = KCBTDialogManager::Instance()->GetCurrentDlgType();
					sBTCommandData*pData =  CBTCommand::Instance()->GetBTCommandData();
					BTDEBUGINFO(L"IPC_ID_MANAGE:VWM_SERVER_CHANGE_MODE,wparam = %d,lParam = %d",wParam,lParam);
					if(pData != NULL && pObj != NULL)
					{
						HUINT nState = 0;
						nState = pData->BTHFPData.nHFPState; 
						if(nState != 3 && nState != 4 && nState != 5 && nState != 6)
						{
							bool bConnect = pObj->GetBTConnectstate();
							if(bConnect)
							{
								switch (wParam)
								{
								   case START_BT_DLG_NULL:
									{
										pObj->OnBTDial(NULL);
									}
									break;
								   case START_BT_DLG_DIAL:
									   {
										   if(lParam == 1 && eType == eDIALOGT_BTDIAL)
										   {
											   HWND hServerWnd = CEIPC_GetHWND(IPC_ID_MANAGE);
											   if (NULL != hServerWnd)
											   {
												   ::PostMessage(hServerWnd, UWM_BACK_SRC, 0, 0);
												   BTDEBUGINFO(L"hServerWnd:UWM_BACK_SRC");
											   }
										   }
										   else
										   {
											   pObj->OnBTDial(NULL);
										   }
										   BTDEBUGINFO(L"OnBTDial");
									   }
									   break;
								   case START_BT_DLG_PHONE_BOOK:
									   {
										   pObj->OnAddressBook(NULL);
									   }
									   break;
								   case START_BT_DLG_HISTORY:
									   {
										   pObj->OnCallRecords(NULL);
									   }
									   break;
								   case START_BT_DLG_AUDIO:
									   {
										 //  pObj->OnBTMusic(NULL);
										   KCBTDialogManager::Instance()->ShowDlg(eDIALOGT_BTMUSIC);
										//   pObj->PlayMusicEx();
									   }
									   break;
								   case START_BT_DLG_CONNECT:
									   {
										   pObj->OnConnectionSetting(NULL);
									   }
									   break;
								   case START_BT_DLG_MIRRORLINK:
									   {
											KCBTDialogManager::Instance()->ShowDlg(eDIALOGT_BTHMI);
											CBTHmiDlg* pBtHmiDlg = (CBTHmiDlg*)(KCBTDialogManager::Instance()->GetBTHMIDlg());
											if(pBtHmiDlg != NULL)
											{
												pBtHmiDlg->ShowHMIVidio();
												s_bCheck = TRUE;
											}
									   }
									   break;
								   default:
									   {
											pObj->OnConnectionSetting(NULL);
									   }
									   break;
								}
							}
							else
							{
								if(wParam == START_BT_DLG_MIRRORLINK)
								{
									KCBTDialogManager::Instance()->ShowDlg(eDIALOGT_BTHMI);
									CBTHmiDlg* pBtHmiDlg = (CBTHmiDlg*)(KCBTDialogManager::Instance()->GetBTHMIDlg());
									if(pBtHmiDlg != NULL)
									{
										pBtHmiDlg->ShowHMIVidio();
										s_bCheck = TRUE;
									}
								}
								else
								{
									//pObj->OnConnectionSetting(NULL);
									if(lParam == 1 && eType == eDIALOGT_BTCONNECTSETTING)
									{
										HWND hServerWnd = CEIPC_GetHWND(IPC_ID_MANAGE);
										if (NULL != hServerWnd)
										{
											::PostMessage(hServerWnd, UWM_BACK_SRC, 0, 0);
											BTDEBUGINFO(L"hServerWnd:UWM_BACK_SRC");
										}
									}
									KCBTDialogManager::Instance()->ShowDlg(eDIALOGT_BTCONNECTSETTING);
								}
							}
						}   
					}
				}
				break;
			case VWM_SERVER_BACKCAMERA_STATUS:
				{
					CBTHmiDlg* pBtHMIDlg = (CBTHmiDlg*)(KCBTDialogManager::Instance()->GetBTHMIDlg());
					BTDEBUGINFO(L"IPC_ID_MANAGE:VWM_SERVER_BACKCAMERA_STATUS,wparam = %d",wParam);
					HINT nSingel = HINT(wParam);
					switch (nSingel)
					{
						case 1:
						{
							if(pBtHMIDlg != NULL)
							{
								//pBtHMIDlg->CloseCheckHandle();
							    pBtHMIDlg->CloseHMIVidio();			
							//	KCBTDialogManager::Instance()->HideBTHMIdlg();
							}
						}
						break;
						case 0:
						{
							eDIALOGTYPE eType= KCBTDialogManager::Instance()->GetCurrentDlgType();
							BTDEBUGINFO(L"GetCurrentDlgType() ==%d",eType);
							if(pBtHMIDlg != NULL && eType == eDIALOGT_BTHMI)
							{
								KCBTDialogManager::Instance()->ShowDlg(eDIALOGT_BTHMI);
							}
						}
						break;
					}
				}
				break;
			case WM_USER:
			{
				UI_TranslateMsg(message, wParam, lParam, false);
			}
			break;
			case VWM_SERVER_KET_BTN:
			//UI_TranslateMsg(message,wParam,lParam,true);
			{
				BTDEBUGINFO(L"IPC_ID_MANAGE:VWM_SERVER_KET_BTN,wparam = %d,iparam = %d",wParam,lParam);
				sBTCommandData*pData =  CBTCommand::Instance()->GetBTCommandData();
				if(pData != NULL)
				{
					HUINT nState = 0;
					nState = pData->BTHFPData.nHFPState; 
					if(nState != 3 && nState != 4 && nState != 5 && nState != 6)
					{
						switch(lParam)
						{
						case eKEY_DOWN:
							{
								HCBTMusicDlg* pObj = static_cast<HCBTMusicDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTMUSIC));
								if(pObj != NULL)
								{
									pObj->OnForward(NULL);
								}
							}
							break;
						case eKEY_UP:
							{
								HCBTMusicDlg* pObj = static_cast<HCBTMusicDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTMUSIC));
								if(pObj != NULL)
								{
									pObj->OnBack(NULL);
								}
							}
							break;
					//	case KEY_ST_SW_MUTE:
						//	{
								/*HCBTMusicDlg* pObj = static_cast<HCBTMusicDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTMUSIC));
								if(pObj != NULL)
								{
									pObj->OnPlayMute(pObj,NULL);
								}*/
						//	}
							break;
						default:
							{

							}
							break;
						}	
					}
					else if(nState == 3 || nState == 4 || nState == 5 || nState == 6)
					{
						switch (lParam)
						{
						case eKEY_OFF_HOOK://电话接听
							{
								HCBTDialDlg* pObj = static_cast<HCBTDialDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTDIAL));
								if(pObj != NULL)
								{
									pObj->OnDialNumCall(pObj,NULL);
								}
							}
							break;
						case eKEY_ON_HOOK://电话挂断
							{
								HCBTDialDlg* pObj = static_cast<HCBTDialDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTDIAL));
								if(pObj != NULL)
								{
									pObj->OnDialNumHangUp(pObj,NULL);
								}
							}
							break;
						}
					}
				}	   	
			}
			break;
			case VWM_SETUP_CHANGE_THEME:    // 主题切换
			{
				g_SetupSetting.cThemeMode = wParam;
				::PostMessage(CEIPC_GetHWND(IPC_ID_MANAGE),VWM_SERVER_CHANGE_THEME_OK,NULL,NULL);
				SetCurThemeMode(g_SetupSetting.cThemeMode);
				BTDEBUGINFO(L"IPC_ID_MANAGE:VWM_SETUP_CHANGE_THEME");
				KCBTDialogManager::Instance()->ChangeThemeForAllDlg();
			
			}
			break;
			case  VWM_SETUP_CHANGE_BT_SETING:
			{
				BTSETTING Setting;
				KCLastMemory::GetInstance()->GetBTMemory(Setting);
				CBTCommand*p =  CBTCommand::Instance( );
				BTDEBUGINFO(L"IPC_ID_MANAGE:VWM_SETUP_CHANGE_BT_SETING");
				HCBTConnectionssettingDlg* pObj = static_cast<HCBTConnectionssettingDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCONNECTSETTING));
				if(p != NULL && pObj != NULL)
				{
					if(Setting.uBtOnOff == 0 && (p->GetBTSetting()).uBtOnOff == 1)
					{
						pObj->StartCloseBT();
						//p->CloseBT();
					}
					else if(Setting.uBtOnOff == 1 && (p->GetBTSetting()).uBtOnOff == 0)
					{
						p->OpenBT(1,115200);
					}
					p->SetBTSetting(Setting);
				}
			}
			break;
			case  UWM_SERVER_CLOSE_VEDIO:
				{

					eDIALOGTYPE eType= KCBTDialogManager::Instance()->GetCurrentDlgType();
					switch (wParam)
					{
						case 0:
						{
							
							CBTHmiDlg* pBtHmiDlg = (CBTHmiDlg*)(KCBTDialogManager::Instance()->GetBTHMIDlg());
							if(pBtHmiDlg != NULL && s_bCheck)
							{
								s_bCheck = false;
								//pBtHmiDlg->CloseHMIVidio();
								//pBtHmiDlg->CloseCheckHandle();
								KCBTDialogManager::Instance()->HideBTHMIdlg();
							}
						}
						break;
						case 1:
						{
							   CBTHmiDlg* pBtHmiDlg = (CBTHmiDlg*)(KCBTDialogManager::Instance()->GetBTHMIDlg());
							   if(pBtHmiDlg != NULL  && !s_bCheck)
							   {
								   //pBtHmiDlg->CloseHMIVidio();
								   //pBtHmiDlg->CloseCheckHandle();
								   if(eType == eDIALOGT_BTHMI)
								   {
                                          pBtHmiDlg->ShowHMIVidio();
								   }
								   s_bCheck = TRUE;
							   }
								
						}
						break;
					}
					
					BTDEBUGINFO(L"IPC_ID_MANAGE:UWM_SERVER_CLOSE_VEDIO,WPARAM = %d",wParam);
					//KCBTDialogManager::Instance()->HideBTHMIdlg();
				}
				break;
			case 	VWM_SERVER_RESUME_AV:
				{
					HCBTMusicDlg* pObj = static_cast<HCBTMusicDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTMUSIC));
                    eDIALOGTYPE eCur = KCBTDialogManager::Instance()->GetCurrentDlgType();
					BTDEBUGINFO(L"IPC_ID_MANAGE:VWM_SERVER_RESUME_AV,lParam = %d",lParam);
					printf("IPC_ID_MANAGE:VWM_SERVER_RESUME_AV,lParam = %d\r\n",lParam);
					if(pObj != NULL && eCur != eDIALOGT_BTHMI)
					{
						switch (lParam)
						{
							case 0:
							{
								  pObj->PlayMusic();
								//pObj->PlayMusicEx();
							}
							break;
							case 1:
							{
								pObj->StopMusic();
								//pObj->StopMusicEx();
							}
						}
					}
				}
				break;
				case VWM_SERVER_LANG_SW:	// 通知进行语言切换wParam:0-中文 1-英文 lParam :无意义
				{
					BTDEBUGINFO(L"VWM_SERVER_LANG_SW,wparam = %d",wParam);
					switch (wParam)
					{
						case 0:
						{
							CBTCommand::Instance()->SetLangue(0);
							KCBTDialogManager::Instance()->ChangeLangeForAllDlg(0);
						}
						break;
						case 1:
						{
							CBTCommand::Instance()->SetLangue(1);
							KCBTDialogManager::Instance()->ChangeLangeForAllDlg(1);
						}
						break;
						default:
						{

						}
						break;
					}
				}
				break;
				case IPC_U_SERVER_POWER_OFF:
					{
						BTDEBUGINFO(L"IPC_U_SERVER_POWER_OFF");
						CBTCommand::Instance()->DisCurrentConnectDevice();
						::PostMessage(g_hBTWnd,WM_QUIT,0,NULL);
					}
					break;
			//case IPC_U_SYS_CLOSE_PROCESS:
			//	{
			//		// 发送退出进程的消息
			//		BTDEBUGINFO(_T("[IPCEventProc] PostMessage(WM_QUIT) \n"));
			//		::PostMessage(g_hWnd1,WM_QUIT,NULL,NULL);
			//	}
			//	break;
				case VWM_TO_BT_RESET:
					{
						if(g_hBTReset != NULL)
						{
							//ResetEvent(g_hBTReset);
						}
						BTDEBUGINFO(L"++++++VWM_TO_BT_RESET++++++\r\n");
						HCBTConnectionssettingDlg* pObj = static_cast<HCBTConnectionssettingDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCONNECTSETTING));
						if(pObj != NULL)
						{
							pObj->ClearDeviceRecord();
							Sleep(500);

						}
					}
					break;
				case VWM_TO_BT_A2DP_DISCONNECT://蓝牙断A2DP  wparam: 2 A2DP断开   1 A2DP静音  0 A2DP连接 
					{
                       wprintf(L"VWM_TO_BT_A2DP_DISCONNECT,wparam = %d,lparam = %d\r\n",wParam,lParam);
						BTDEBUGINFO(L"VWM_TO_BT_A2DP_DISCONNECT,wparam = %d,lparam = %d",wParam,lParam);
						HCBTMusicDlg* pObj = static_cast<HCBTMusicDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTMUSIC));
						if(pObj != NULL)
						{
							switch(wParam)
							{
								case 0:
								{
									KillTimer(g_hBTWnd,TIME_ID_A2DP);
								//	pObj->ConnectA2DP(1);
									if(s_nACCInMusic != 1)
									{
										pObj->PlayMusicEx();
										s_nACCInMusic= 3;
									}
									else
									{
										SetTimer(g_hBTWnd,TIME_ID_FIRST_PLAY,3000,FirstPlayBTMusic);
										printf("SetTimer++++++++++FirstPlayBTMusic++++\r\n");
										s_nACCInMusic = 2;
									}
									
									//pObj->MusicMute(false);
                                  //  pObj->MusicMuteEx(false);
									s_bA2DPConn = true;
									s_bMute = FALSE;
									SetTimer(g_hBTWnd,TIME_ID_A2DP,3000,A2DPMannageTimer);
								}
								break;
								case 1:
								{
									KillTimer(g_hBTWnd,TIME_ID_A2DP);
									pObj->StopMusic();
									//pObj->ConnectA2DP(1);
									s_bA2DPConn = true;
									//pObj->MusicMute(true);
									//pObj->MusicMuteEx(true);
									s_bMute = true;
									SetTimer(g_hBTWnd,TIME_ID_A2DP,3000,A2DPMannageTimer);
								}
								break;
								case 2:
								{
									KillTimer(g_hBTWnd,TIME_ID_A2DP);
									pObj->StopMusic();
									//pObj->ConnectA2DP(0);
									s_bA2DPConn = false;
									//pObj->MusicMute(true);
									SetTimer(g_hBTWnd,TIME_ID_A2DP,3000,A2DPMannageTimer);
								}
								break;
							}
						} 
					}
					break;
		case (WM_USER + 1)://添加设备列表名称
		{
			BTDEBUGINFO(L"设备列表更新");
			HCBTConnectionssettingDlg* pObj = static_cast<HCBTConnectionssettingDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCONNECTSETTING));
//			bool bHdmi = KCBTDialogManager::Instance()->IsBTHMIDlgShow();
			if(pObj != NULL)
			{
				//pObj->SetNoticeShowHide();
				pObj->AddPairedDevice();
			}	
		}
		break;
		case (WM_USER + 2)://通讯录添加记录
		{
			BTDEBUGINFO(L"通讯录更新");
			HCBTAddressBookDlg* pObj = static_cast<HCBTAddressBookDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTADDRESSBOOK));
			HCBTCallRecordsDlg* pObjR = static_cast<HCBTCallRecordsDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCALLRECORDS));
			if(pObj != NULL && pObjR != NULL)
			{
				pObj->AddAddressBookItem();
				pObjR->OnAllRecords(NULL);
			}	
		}
		break;
		case (WM_USER + 3)://更新蓝牙音乐信息
		{
			BTDEBUGINFO(L"蓝牙音乐信息更新");
			HCBTMusicDlg* pObj = static_cast<HCBTMusicDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTMUSIC));
			if(pObj != NULL)
			{
				pObj->UpDataMediaInfo();
			}		
		}
		break;
		case  (WM_USER + 4)://更新蓝牙音乐播放状态
		{
			BTDEBUGINFO(L"蓝牙音乐播放状态更新,wparam = %d",wParam);
			HCBTMusicDlg* pObj = static_cast<HCBTMusicDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTMUSIC));
	
			if(pObj != NULL)
			{
				pObj->UpDataPlayState(static_cast<eBTMUSICRUNNINGSTATUS>(wParam));
			}
#if TESTDAILPROBLEM
			pObj1->UpdataTestHFP();
#else
#endif
		}
		break;
		case (WM_USER + 5)://HFP状态更新
		{
	//		sBTCommandData*pData =  CBTCommand::Instance()->GetBTCommandData();	
#if BTLOGSTATE
			HINT nState = static_cast<HINT>(wParam);
			g_Logfile1<<GetTickCount()<<"           "<<" nHFP = "<<nState<<endl;
#else
#endif 
			
			HCBTMusicDlg* pMusic = static_cast<HCBTMusicDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTMUSIC));
			HCBTDialDlg* pObj = static_cast<HCBTDialDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTDIAL));
			HCBTCallRecordsDlg* pObjRecords = static_cast<HCBTCallRecordsDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCALLRECORDS));
			HCBTAddressBookDlg* pObjBook = static_cast<HCBTAddressBookDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTADDRESSBOOK));
			//bool bBTHMISgow = KCBTDialogManager::Instance()->IsBTHMIDlgShow();
			HCBTConnectionssettingDlg* pObjc = static_cast<HCBTConnectionssettingDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCONNECTSETTING));
#if TESTDAILPROBLEM
			pObj->UpdataTestHFP();
#else
#endif
			if(pObj != NULL)
			{
				HINT nparam = static_cast<HINT>(wParam);
				pObj->UpdataTextShow(nparam);//拨号键盘显示信息更新
				BTDEBUGINFO(L"HFP状态更新,HFP = %d",nparam);
				pObj->UpDataKeyBoard(static_cast<HINT>(wParam));//拨号键盘状态更新	
				pObj->UpdataBTBottomState(nparam);
				pObjc->UpdataByHFPState(nparam);//更新蓝牙连接状态,更新图标
				if(nparam == 2)
				{
					//KillTimer(g_hBTWnd,TIME_ID_MUTE);
					//SetTimer(g_hBTWnd,TIME_ID_MUTE,3000,A2DPMuteMannageTimer);
					pObjc->StopDeadTimer();
				
					
				}
				DWORD dwRet = 0;

				if((g_PreHfpState == 3 || g_PreHfpState == 4 || g_PreHfpState == 5 || g_PreHfpState == 6) && wParam == 0 )
				{
					//::PostMessage(CEIPC_GetHWND(IPC_ID_MANAGE),VWM_BT_HFP_STATE,7,NULL);
					::SendMessageTimeout(CEIPC_GetHWND(IPC_ID_MANAGE),VWM_BT_HFP_STATE,7,NULL,SMTO_NORMAL,500,&dwRet);
					BTDEBUGINFO(L"IPC_ID_MANAGE::VWM_BT_HFP_STATE= 7");
				}
				if(wParam != 1)
				{
					if(wParam != 7)
					{
						::PostMessage(CEIPC_GetHWND(IPC_ID_MANAGE),VWM_BT_HFP_STATE,wParam,NULL);
					}
					else
					{
                       ::SendMessageTimeout(CEIPC_GetHWND(IPC_ID_MANAGE),VWM_BT_HFP_STATE,7,NULL,SMTO_NORMAL,500,&dwRet);
					}
					g_PreHfpState = (int)wParam;
					BTDEBUGINFO(L"IPC_ID_MANAGE::VWM_BT_HFP_STATE= %d",wParam);
				}
				if(nparam == 7)
				{
					pObj->SetDailingState(true);
					KCBTDialogManager::Instance()->ShowPreDlg();//通话结束返回上一个界面
					pObj->ClearKeyBoardNum();
					pObj->SetDailingState(false);
				}
				if(nparam == 0)
				{
						KillTimer(g_hBTWnd,TIME_ID_MUTE);
						if(pObjBook != NULL && pObjRecords != NULL && pObj != NULL && pMusic != NULL) 
						{
							/*pObjRecords->DeleteAllItems();
							pObjRecords->UpDataRecords(false);*/
							pObjRecords->ClearRecordsData();
							pObjBook->ClearBookData();
							pObj->ClearKeyBoardNum();
							pMusic->ClearMusicInfo();
						}
						CBTCommand::Instance()->ClearBookData();
						CBTCommand::Instance()->ClearMyPhoneData();
				}

				if(s_nDlg == 4 && nparam == 2)
				{
					s_nACCInMusic = 1;
					if(s_Show != SW_HIDE)
					{
						pMusic->OnBTMusic(NULL);
					}
					else
					{
						KCBTDialogManager::Instance()->ShowDlg(eDIALOGT_BTMUSIC);
						SetTimer(g_hBTWnd,TIME_ID_FIRST_PLAY,3000,FirstPlayBTMusic);
						s_nACCInMusic = 2;
					}

					//pMusic->PlayMusicEx();
					//SetTimer(g_hBTWnd,TIME_ID_FIRST_PLAY,3000,FirstPlayBTMusic);
					BTDEBUGINFO(L"last mem to music");
					s_nDlg = 0;
					//KCBTDialogManager::Instance()->ShowDlg(eDIALOGT_BTMUSIC);
				}
				/*switch (nparam)
				{
					 case 0:
					{
						 pObjc->UpDataIconUnconnect();
					 }
					 case 1:
					 {
						 pObjc->SetBTConected(false);
						 pObj->OnConnectionSetting(NULL);
					 }
				    break;
					 case 5:
					 {
						 pObj->StartCountCallDuration();
						 pObjc->SetBTConected(true);
					 }
					 break;
					 case 2:
					 case 3:
					 case 4:
					 {
							pObj->StopCountCallDuration();
					 }
					 case 6:
					{
					    pObjc->SetBTConected(true);
					}
					break;
					default:
					break;
				}
				pObjc->UpdataBTBottomState();*/
			}
		}
		break;
		case (WM_USER + 6)://更新下载记录条数
		{
			BTDEBUGINFO(L"更新下载记录数目");
			HCBTAddressBookDlg* pObj = static_cast<HCBTAddressBookDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTADDRESSBOOK));
			if(pObj != NULL)
			{
				pObj->SetNotice(static_cast<ePBAPCSTATE>(wParam));
			}
		}
		break;
		case (WM_USER + 7)://电话本和通话记录下载结束
		{
				BTDEBUGINFO(L"电话本通讯录下载结束更新状态");
				HCBTCallRecordsDlg *pObc = static_cast<HCBTCallRecordsDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCALLRECORDS));
				HCBTAddressBookDlg* pObj = static_cast<HCBTAddressBookDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTADDRESSBOOK));
				if(pObj != NULL)
				{
					pObj->SetNoticeShow(false);
				}
				if(pObc != NULL)
				{
					pObc->UpDataRecords(true);
				}
		}
		break;
		case (WM_USER + 8):
		{
			HCBTConnectionssettingDlg* pObj = static_cast<HCBTConnectionssettingDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCONNECTSETTING));
			if(pObj != NULL)
			{
				//pObj->SetNoticeShow((HUINT)wParam);
			}
		}
		break;
		case (WM_USER + 9)://获得当前连接设备信息
		{
			BTDEBUGINFO(L"当前连接设备信息");
			HCBTAddressBookDlg *pObc = static_cast<HCBTAddressBookDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTADDRESSBOOK));
			HCBTConnectionssettingDlg* pObj = static_cast<HCBTConnectionssettingDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCONNECTSETTING));
			if(pObj != NULL)
			{
				if(pObj->IsPairPageShow())
				{
					pObj->OnEnterPairPage(NULL);
				}
				//pObj->SetNoticeSuccess();
				pObj->SetBTConected(true);
				pObj->UpdataBTBottomState();
				pObc->StartDown();
				pObc->StartDownBookData();
			}
		}
		break;
		case (WM_USER + 10)://来电,去电号码显示
		{
			BTDEBUGINFO(L"来电去电号码显示");
			HCBTDialDlg* pObj = static_cast<HCBTDialDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTDIAL));
			sContact *pContact = (sContact*)wParam;
			if(pObj != NULL && pContact != NULL)
			{
				//pObj->UpDataKeyBoardNum();
				pObj->UpDataKeyBoardNum(pContact);
				if(pContact !=NULL)
				{
					delete pContact;
				}
				KCBTDialogManager::Instance()->JumpToDlg(eDIALOGT_BTDIAL);
			}
		}
		break;
		case (WM_USER + 11):
		{
			//HCBTConnectionssettingDlg* pObj = static_cast<HCBTConnectionssettingDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCONNECTSETTING));
			//if(pObj != NULL)
			//{
			//	pObj->SetBTConected(false);
			//	pObj->OnConnectionSetting(NULL);
			//	pObj->UpdataBTBottomState();
			////pObj->UpDataKeyBoard(static_cast<HINT>(wParam));
			//}
		}
	    break;
		case (WM_USER + 12)://下载电话本和通话记录中
			{
				BTDEBUGINFO(L"下载电话本和通话记录中");
				HCBTAddressBookDlg* pObj = static_cast<HCBTAddressBookDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTADDRESSBOOK));
				HCBTCallRecordsDlg *pObc = static_cast<HCBTCallRecordsDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCALLRECORDS));
				if(pObj != NULL)
				{
					pObj->ClearBookDataEx();
					//pObj->OnDowingTimer(NULL);
				}
				if(pObc != NULL)
				{
					pObc->UpDataRecords(false);
					pObc->ClearRecordsData();
				}
			}
			break;
		case (WM_USER + 13):// 关闭蓝牙信息
			{
				BTDEBUGINFO(L"关闭蓝牙信息");
				HCBTConnectionssettingDlg* pObj = static_cast<HCBTConnectionssettingDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCONNECTSETTING));
				if(pObj != NULL)
				{
					pObj->StartCloseBT();
				}
			}
			break;
		case (WM_USER + 14):// 打开蓝牙信息
			{
				BTDEBUGINFO(L"打开蓝牙信息");
				CBTCommand *p = CBTCommand::Instance();
				if(p != NULL)
				{
					p->OpenBT(1,115200);
				}
			}
			break;
#if AUTOUPDATACALLHISTORY
		case (WM_USER + 15)://更新通话记录按钮图标
		{
			BTDEBUGINFO(L"更新通话记录按钮图标");
			HCBTCallRecordsDlg *pObc = static_cast<HCBTCallRecordsDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCALLRECORDS));
			if(pObc != NULL)
			{
				pObc->UpDataRecords(true);
			}
		}
       break;	
#else
#endif
		case(WM_USER + 16)://spp状态变化
			{
				/*BTDEBUGINFO(L"SPP状态变化,nSPPState = %d",wParam);
				HUINT nSPPState = HUINT(wParam);
				CBTHmiDlg* pBtHMIDlg = (CBTHmiDlg*)(KCBTDialogManager::Instance()->GetBTHMIDlg());
				if(pBtHMIDlg != NULL)
				{
					switch (nSPPState)
					{
						case 0:
						{
							pBtHMIDlg->SetSPPConnected(false);
						}
						break;
						case 2:
						{
							pBtHMIDlg->SetSPPConnected(true);
						}
						break;
						default:
						break;
					}	
				}*/
			}
			break;
		case(WM_USER + 17)://HID状态变化
			{
				/*BTDEBUGINFO(L"更新HID状态变化,wparam = %d",wParam);
				HUINT nHIDState = HUINT(wParam);
				CBTHmiDlg* pBtHMIDlg = (CBTHmiDlg*)(KCBTDialogManager::Instance()->GetBTHMIDlg());
				if(pBtHMIDlg != NULL)
				{
					switch (nHIDState)
					{
						case 0:
						{
							pBtHMIDlg->SetHIDConnected(false);
						}
						break;
						case 2:
						{
							pBtHMIDlg->SetHIDConnected(true);
						}
						break;
					default:
					break;
				}	
			}*/
		}
			break;
		case(WM_USER + 18)://坐标归零
			{
				BTDEBUGINFO(L"坐标归零");
				CBTHmiDlg* pBtHMIDlg = (CBTHmiDlg*)(KCBTDialogManager::Instance()->GetBTHMIDlg());
				if(pBtHMIDlg != NULL)
				{
					pBtHMIDlg->BackToZero(NULL);
				}
			}
			break;
#ifdef  AUTOUPDATACALLHISTORY
			case WM_USER + 19://新增电话记录更新,0全部 1未接 2 拨出 3已接
			{
				BTDEBUGINFO(L"新增电话记录更新,0全部 1未接 2 拨出 3已接");
				HCBTCallRecordsDlg *pObc = static_cast<HCBTCallRecordsDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCALLRECORDS));
				if(pObc != NULL)
				{
					pObc->UpDataRecords(true);
					pObc->AutoUpDataRecords();
				}
			}
			break;
#else
#endif
			case WM_USER + 20:
			{
			    HCBTDialDlg* pObj = static_cast<HCBTDialDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTDIAL));
				if(pObj != NULL)
				{
					switch (wParam)
					{
					case 0:
						{
							//BTDEBUGINFO(L"声音切换至手机");
							pObj->ChangeVoicePoisition(0);
						}
						break;
					case 1:
						{
							//BTDEBUGINFO(L"声音切换至车机");
							pObj->ChangeVoicePoisition(1);
						}
						break;
					}
				}
			}
			break;
			case WM_USER + 21:
				{
					s_nDlg = 0;

					/////
					/*HCBTDialDlg* pObj = static_cast<HCBTDialDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTDIAL));
					if(pObj != NULL)
					{
						pObj->SetVoiceToPhone();
					}
					HCBTMusicDlg* pObjMusic = static_cast<HCBTMusicDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTMUSIC));
					if(pObjMusic != NULL)
					{
						pObjMusic->StopMusic();
					}
					Sleep(3);
					CBTCommand::Instance()->DisCurrentConnectDevice();
					::PostMessage(g_hBTWnd,WM_QUIT,0,NULL);
					wprintf(L"IPC_U_SERVER_POWER_OFF :BT quit\r\n");*/
				}
				break;
			case WM_USER + 23://手机端取消下载 0:电话本取消下载  1:全部通话记录取消下载
				{
				//	HCBTCallRecordsDlg* pObjRecords = static_cast<HCBTCallRecordsDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCALLRECORDS));
					HCBTAddressBookDlg* pObjBook = static_cast<HCBTAddressBookDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTADDRESSBOOK));
					if(pObjBook != NULL)
					{
						pObjBook->CancelByPhone();
					}
				}
				break;
			case WM_USER + 24://更新下载通讯录数据  Wparam:5 通讯录 6 来电  7 已拨电话 8 未接电话  9 所有通话记录  Iparam:记录数目
				{
					//wprintf(L"Updata Down Num:Type = %d,Num = %d\r\n",wParam,lParam);
					BTDEBUGINFO(L"Updata Down Num:Type = %d,Num = %d\r\n",wParam,lParam);
					HCBTAddressBookDlg* pObjBook = static_cast<HCBTAddressBookDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTADDRESSBOOK));
					if(pObjBook != NULL)
					{
						pObjBook->UpDateDownLoad(wParam,lParam);
					}
				}
				break;
			case WM_USER + 25://启动拨号恢复定时器
				{
					BTDEBUGINFO(L"______StartCallTimer______");
					  HCBTDialDlg* pObj = static_cast<HCBTDialDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTDIAL));
					  if(pObj != NULL)
					  {
							pObj->StartCallTimer();
					  }
				}
				break;
			case WM_USER + 26:
				{
#if TestBTVISION
					HCBTMusicDlg* pMusic = static_cast<HCBTMusicDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTMUSIC));
					if(pMusic != NULL)
					{
						pMusic->UpdateVision();
						//pMusic->UpdateBtName();
					}
#endif	
				}
				break;
			case WM_USER+27:
				{
					BTDEBUGINFO(L"UpdateDevName");
#if SETBTNAME_MAC
			HCBTConnectionssettingDlg* pObj = static_cast<HCBTConnectionssettingDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCONNECTSETTING));
			if(pObj != NULL)
			{
				pObj->UpdateDevName();
			}
#endif
				}
				break;
		case WM_USER + 50://蓝牙发送队列添加数据数据
			{
				BTDEBUGINFO(L"蓝牙发送队列添加数据数据:Type = %d,pblock = %d",wParam,lParam);
				CBTCommand::Instance()->SendBTCommandBlock((BTPacketDataType_t)wParam,(Block*)lParam);
			}
			break;
		case WM_USER + 222:
			{

			}
			break;
#if TESTRESTARTPROTEM
		case WM_USER +51:
		{
			HCBTConnectionssettingDlg* pObj = static_cast<HCBTConnectionssettingDlg*>(KCBTDialogManager::Instance()->GetDlg(eDIALOGT_BTCONNECTSETTING));
			if(pObj != NULL)
			{
				switch (wParam)//0更新启动次数 1清除启动次数
				{
				case 0:
					{
						pObj->UpdataRestTime(g_nRestTime);
					}
					break;
				case 1:
					{
						if(DeleteFile(appPath.c_str()))
						{
							printf("Remove sucess\r\n");
							g_nRestTime = 0;
						}
					}
					break;
				}
			}
		}
		break;
#endif
		default:
		{
			UI_TranslateMsg(message, wParam, lParam, true);
		}
		break;
	}
	return DefWindowProcW(hWnd, message, wParam, lParam);
}
Пример #9
0
//主程序
HINT APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, HINT nCmdShow)
{
	DWORD nCostTime = GetTickCount();
	CBTCommand *pComand=CBTCommand::Instance(); 
	if(pComand != NULL)
	{
		pComand->LowBTPower();
	}
	wprintf(L"[wWinMain] Begin\r\n");
	//g_Mutex =::CreateMutex(NULL, TRUE, APP_CLASSNAME_TEST1);
	INSTANCE_START
	HINT nParam = 0;
	_stscanf_s(GetCommandLine(),_T("%d"),&nParam);
	nCmdShow = PARAM_SHOW_CMD(nParam);
	s_Show = nCmdShow;
	BTDEBUGINFO(L"nCmdShow = %d",nCmdShow);
	HINT nDlg = PARAM_BT_DLG_CMD(nParam);
	BTDEBUGINFO(L"nDlg = %d",nDlg);
	s_nDlg = nDlg;
//	HINT nDlgType =	PARAM_BT_DLG_CMD(nParam);	
	// HMI 初始化
	if( !UIDevInit(
		SCREEN_WIDTH, SCREEN_HEIGHT,
		hInstance,
		const_cast<HCHAR*>(STR_PROCESSNAME_BT),
		const_cast<HCHAR*>(STR_PROCESSNAME_BT),
		0,
		g_hBTWnd) )
	{
		return 0;
	}
	::ShowWindow(g_hBTWnd, nCmdShow);
	SetOwnerProc(MyProc);   //注册回调
	// 注册IPC
	//移到后面
	CEIPC_Regist(IPC_ID_BT, g_hBTWnd, RecvIPCEvent);
	//	切换字体
	GetRESingleton()->ReLoadFont(FONT_MSYH_TTF);
	GetRESingleton()->ReLoadFont(FONT_QUARTZ_REGULAR_TTF);
	InitPopupSurface(GetHMIPath(_T("")).c_str());
	KCBTDialogManager* pObj =  KCBTDialogManager::Instance();

	
	btSource::Instance()->GetBtSource(GetHMIPath(_T("")).c_str());
	if(pComand != NULL)
	{
		pComand->SetMyhWnd(g_hBTWnd);
		pComand->OnInit(1,115200);
		nCostTime = GetTickCount() - nCostTime;
		BTDEBUGINFO(L"%s,CostTime1 = %d",__FUNCTIONW__,nCostTime);
		nCostTime = GetTickCount();
	}
	if(pObj != NULL)
	{
	   pObj->CreateAllBTDlg();
		pComand->SendGetBTInfo();
		pObj->ShowDlg(eDIALOGT_BTCONNECTSETTING);
	
		nCostTime = GetTickCount() - nCostTime;
		BTDEBUGINFO(L"%s,CostTime2 = %d",__FUNCTIONW__,nCostTime);
		nCostTime = GetTickCount();
		//pObj->ShowBTHMIDlg();
	}	 
	// 获取配置信息
	if( NULL != KCLastMemory::GetInstance() )
	{
		// 读取SETUP配置文件
		KCLastMemory::GetInstance()->GetSetupMemory(g_SetupSetting);
	}
	else
	{
		KCLastMemory::GetSetupMemoryDefault(g_SetupSetting);
	}
	//::ShowWindow(g_hBTWnd, nCmdShow);
	::UpdateWindow(g_hBTWnd);
	//CEIPC_Regist(IPC_ID_BT, g_hBTWnd, RecvIPCEvent);
	//s_nDlg = 4;
	if(s_nDlg == 4)
	{
		BTDEBUGINFO(L"s_nDlg == 4");
		UINT nrett = SetTimer(g_hBTWnd,15,10000,SetDlg);
		if(nrett == 0)
		{
			BTDEBUGINFO(L"SetTimer error: %d",GetLastError());
		}
	}
	nCostTime = GetTickCount() - nCostTime;
	BTDEBUGINFO(L"%s,CostTime3 = %d",__FUNCTIONW__,nCostTime);
	HCHAR		szPath[MAX_PATH] = {0};
	::GetModuleFileName(NULL, szPath, MAX_PATH);
	appPath += szPath;
	HINT nPos = (HINT)appPath.rfind(_T('\\'));
	if(nPos == -1)
	{
		wprintf(L"[HCSourceBase::GetExePath] exe path error ");
		return false;
	}
	appPath = appPath.substr(0, nPos+1);
#if BTLOGSTATE
	appPath += L"..\\Config\\BTLog.txt";
	g_Logfile1.open(appPath.c_str(),ios::app);
#else
#endif
#if TESTRESTARTPROTEM
	 char buffer[256] = {0};
	 char buffer1[256] = {0};
	 char Num[20] ={0};
	  ifstream examplefile1;
	  int i1,j1;
	  i1= j1 = 0;
	  int nn = 0;
	appPath += L"..\\Config\\BTPro.txt";
	examplefile1.open(appPath.c_str());
	if(!examplefile1)
	{
		printf("File Not Exsit\r\n");
		g_nRestTime = 1;
	}
	else
	{
		while (! examplefile1.eof() ) 
		{
			memset(buffer,0,sizeof(buffer));
			examplefile1.getline(buffer,100);
			if(buffer[0] == 'T')
			{
				memset(buffer1,0,sizeof(buffer1));
				memcpy(buffer1,buffer,100);
			}
			//nn++;
		//cout<<"====="<<nn<<endl;
		}
		while (buffer1[i1] != '^')
		{
			i1++;
				cout<<"i= "<<i1<<endl;
		}
		j1 = i1 + 1;
		while (buffer1[j1] != '^')
		{
			j1++;
			cout<<"j = "<<j1<<endl;
		}
		if(i1 < j1 && i1 > 0 && (j1-i1)  < 10)
		{
			memcpy(Num,buffer1+i1+1,j1-i1-1);
		}
		g_nRestTime = atoi(Num) + 1;
		cout << "666++++"<<g_nRestTime<<endl;
		examplefile1.close();
	}
	g_Profile1.open(appPath.c_str(),ios::app);
	char Temm[200] = {0};
	//sprintf(Temm,"Totol^%d^^^^%d\n",g_nRestTime,GetTickCount());
	//g_Profile1.write(Temm);
	g_Profile1<<"Total^"<<g_nRestTime<<"^^^^"<<GetTickCount()<<endl;
	//g_Profile1<<"Total^"<<g_nRestTime<<"^^^^"<<GetTickCount()<<endl;
	g_Profile1.close();
#endif
	//消息循环
	MSG msg;
	UINT nretTime = SetTimer(g_hBTWnd,10,1000,CheckHDMISignal);
	if(nretTime == 0)
	{
		BTDEBUGINFO(L"SetTimer error: %d",GetLastError());
	}
	DWORD dwClickDownTime = GetTickCount();
	while(GetMessage(&msg, NULL, 0, 0))
	{
		eDIALOGTYPE  eDlgType = KCBTDialogManager::Instance()->GetCurrentDlgType();
		if(GetTickCount() - dwClickDownTime >= 800 && msg.message == WM_LBUTTONDOWN && ((eDlgType == eDIALOGT_BTADDRESSBOOK) || (eDlgType == eDIALOGT_BTCALLRECORDS)))
		{
			dwClickDownTime = GetTickCount();
		}
		else if(msg.message == WM_LBUTTONDOWN && GetTickCount() - dwClickDownTime < 800 && ((eDlgType == eDIALOGT_BTADDRESSBOOK) || (eDlgType == eDIALOGT_BTCALLRECORDS)))
		{
            continue;
		}
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	CEIPC_UnRegist();
	CBTCommand::DeleteInstance();
	KCBTDialogManager::Instance()->DeleteInstance();
	btSource::Instance()->DeleteInstance();
	//UnInitPopupSurface();
	//释放
	UIDevRelease();
	KillTimer(g_hBTWnd,10);
	KillTimer(g_hBTWnd,15);
	HWND hServerWnd = ::FindWindow(STR_PROCESSNAME_MANAGE, STR_PROCESSNAME_MANAGE);
	HWND hBtUpateWnd = ::FindWindow(L"BTAPP.exe", L"BTAPP.exe");
	if(hBtUpateWnd != NULL)
	{
			::PostMessage(hBtUpateWnd, WM_USER + 1000, 0, NULL);
			
	}
	//printf("+++++++++++++VWM_SERVER_SRC_CLOSE+++++IPC_ID_BT++++++\r\n");
	if (hServerWnd)
	{
		::PostMessage(hServerWnd, VWM_SERVER_SRC_CLOSE, IPC_ID_BT, NULL);
	}

	return 0;
}
Пример #10
0
std::vector<AudioEngine::RendererDetail> AudioEngine::GetRendererDetails()
{
    std::vector<RendererDetail> list;

#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP

    LPCWSTR id = GetDefaultAudioRenderId( Default );
    if ( !id )
        return list;

    RendererDetail device;
    device.deviceId = id;
    device.description = L"Default";

    CoTaskMemFree( (LPVOID)id );

#elif defined(_XBOX_ONE)

    using namespace Microsoft::WRL;
    using namespace Microsoft::WRL::Wrappers;
    using namespace ABI::Windows::Media::Devices;

    Microsoft::WRL::ComPtr<IMediaDeviceStatics> mdStatics;
    HRESULT hr = ABI::Windows::Foundation::GetActivationFactory( HStringReference(RuntimeClass_Windows_Media_Devices_MediaDevice).Get(), &mdStatics );
    ThrowIfFailed( hr );

    HString id;
    hr = mdStatics->GetDefaultAudioRenderId( AudioDeviceRole_Default, id.GetAddressOf() );
    ThrowIfFailed( hr );

    RendererDetail device;
    device.deviceId = id.GetRawBuffer( nullptr );
    device.description = L"Default";
    list.emplace_back( device );

#elif (_WIN32_WINNT >= _WIN32_WINNT_WIN8)

#if defined(__cplusplus_winrt)

    // Enumerating with WinRT using C++/CX (Windows Store apps)
    using Windows::Devices::Enumeration::DeviceClass;
    using Windows::Devices::Enumeration::DeviceInformation;
    using Windows::Devices::Enumeration::DeviceInformationCollection;

    auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
    while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
        ;

    DeviceInformationCollection^ devices = operation->GetResults();

    for (unsigned i = 0; i < devices->Size; ++i)
    {
        using Windows::Devices::Enumeration::DeviceInformation;

        DeviceInformation^ d = devices->GetAt(i);

        RendererDetail device;
        device.deviceId = d->Id->Data();
        device.description = d->Name->Data();
        list.emplace_back(device);
    }
#else

    // Enumerating with WinRT using WRL (Win32 desktop app for Windows 8.x)
    using namespace Microsoft::WRL;
    using namespace Microsoft::WRL::Wrappers;
    using namespace ABI::Windows::Foundation;
    using namespace ABI::Windows::Foundation::Collections;
    using namespace ABI::Windows::Devices::Enumeration;

    RoInitializeWrapper initialize(RO_INIT_MULTITHREADED);
    HRESULT hr = initialize;
    ThrowIfFailed( hr );

    Microsoft::WRL::ComPtr<IDeviceInformationStatics> diFactory;
    hr = ABI::Windows::Foundation::GetActivationFactory( HStringReference(RuntimeClass_Windows_Devices_Enumeration_DeviceInformation).Get(), &diFactory );
    ThrowIfFailed( hr );

    Event findCompleted( CreateEventEx( nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, WRITE_OWNER | EVENT_ALL_ACCESS ) );
    if ( !findCompleted.IsValid() )
        throw std::exception( "CreateEventEx" );

    auto callback = Callback<IAsyncOperationCompletedHandler<DeviceInformationCollection*>>(
        [&findCompleted,list]( IAsyncOperation<DeviceInformationCollection*>* aDevices, AsyncStatus status ) -> HRESULT
    {
        UNREFERENCED_PARAMETER(aDevices);
        UNREFERENCED_PARAMETER(status);
        SetEvent( findCompleted.Get() );
        return S_OK;
    });

    ComPtr<IAsyncOperation<DeviceInformationCollection*>> operation;
    hr = diFactory->FindAllAsyncDeviceClass( DeviceClass_AudioRender, operation.GetAddressOf() );
    ThrowIfFailed( hr );

    operation->put_Completed( callback.Get() );

    (void)WaitForSingleObjectEx( findCompleted.Get(), INFINITE, FALSE );

    ComPtr<IVectorView<DeviceInformation*>> devices;
    operation->GetResults( devices.GetAddressOf() );

    unsigned int count = 0;
    hr = devices->get_Size( &count );
    ThrowIfFailed( hr );

    if ( !count )
        return list;

    for( unsigned int j = 0; j < count; ++j )
    {
        ComPtr<IDeviceInformation> deviceInfo;
        hr = devices->GetAt( j, deviceInfo.GetAddressOf() );
        if ( SUCCEEDED(hr) )
        {
            HString id;
            deviceInfo->get_Id( id.GetAddressOf() );

            HString name;
            deviceInfo->get_Name( name.GetAddressOf() );

            RendererDetail device;
            device.deviceId = id.GetRawBuffer( nullptr );
            device.description = name.GetRawBuffer( nullptr );
            list.emplace_back( device );
        }
    }

#endif 

#else // _WIN32_WINNT < _WIN32_WINNT_WIN8

    // Enumerating with XAudio 2.7
    ComPtr<IXAudio2> pXAudio2;

    HRESULT hr = XAudio2Create( pXAudio2.GetAddressOf() );
    if ( FAILED(hr) )
    {
        DebugTrace( "ERROR: XAudio 2.7 not found (have you called CoInitialize?)\n");
        throw std::exception( "XAudio2Create" );
    }

    UINT32 count = 0;
    hr = pXAudio2->GetDeviceCount( &count );
    ThrowIfFailed(hr);

    if ( !count )
        return list;

    list.reserve( count );

    for( UINT32 j = 0; j < count; ++j )
    {
        XAUDIO2_DEVICE_DETAILS details;
        hr = pXAudio2->GetDeviceDetails( j, &details );
        if ( SUCCEEDED(hr) )
        {
            RendererDetail device;
            device.deviceId = details.DeviceID;
            device.description = details.DisplayName;
            list.emplace_back( device );
        }
    }

#endif

    return list;
}
Пример #11
0
QVariant QSystemLocalePrivate::uiLanguages()
{
    if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) {
        typedef BOOL (WINAPI *GetUserPreferredUILanguagesFunc) (
                    DWORD dwFlags,
                    PULONG pulNumLanguages,
                    PWSTR pwszLanguagesBuffer,
                    PULONG pcchLanguagesBuffer);
        static GetUserPreferredUILanguagesFunc GetUserPreferredUILanguages_ptr = 0;
#ifndef Q_OS_WINRT
        if (!GetUserPreferredUILanguages_ptr) {
            QSystemLibrary lib(QLatin1String("kernel32"));
            if (lib.load())
                GetUserPreferredUILanguages_ptr = (GetUserPreferredUILanguagesFunc)lib.resolve("GetUserPreferredUILanguages");
        }
#endif // !Q_OS_WINRT
        if (GetUserPreferredUILanguages_ptr) {
            unsigned long cnt = 0;
            QVarLengthArray<wchar_t, 64> buf(64);
            unsigned long size = buf.size();
            if (!GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size)) {
                size = 0;
                if (GetLastError() == ERROR_INSUFFICIENT_BUFFER &&
                    GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, NULL, &size)) {
                    buf.resize(size);
                    if (!GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size))
                        return QStringList();
                }
            }
            QStringList result;
            result.reserve(cnt);
            const wchar_t *str = buf.constData();
            for (; cnt > 0; --cnt) {
                QString s = QString::fromWCharArray(str);
                if (s.isEmpty())
                    break; // something is wrong
                result.append(s);
                str += s.size()+1;
            }
            return result;
        }
    }

#ifndef Q_OS_WINRT
    // old Windows before Vista
    return QStringList(QString::fromLatin1(winLangCodeToIsoName(GetUserDefaultUILanguage())));
#else // !Q_OS_WINRT
    QStringList result;
    ComPtr<ABI::Windows::Globalization::IApplicationLanguagesStatics> appLanguagesStatics;
    if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Globalization_ApplicationLanguages).Get(), &appLanguagesStatics))) {
        qWarning("Could not obtain ApplicationLanguagesStatic");
        return QStringList();
    }

    ComPtr<ABI::Windows::Foundation::Collections::IVectorView<HSTRING> > languageList;
    // Languages is a ranked list of "long names" (e.g. en-US) of preferred languages, which matches
    // languages from the manifest with languages from the user's system.
    HRESULT hr = appLanguagesStatics->get_Languages(&languageList);
    Q_ASSERT_SUCCEEDED(hr);
    unsigned int size;
    hr = languageList->get_Size(&size);
    Q_ASSERT_SUCCEEDED(hr);
    result.reserve(size);
    for (unsigned int i = 0; i < size; ++i) {
        HString language;
        hr = languageList->GetAt(i, language.GetAddressOf());
        Q_ASSERT_SUCCEEDED(hr);
        UINT32 length;
        PCWSTR rawString = language.GetRawBuffer(&length);
        result << QString::fromWCharArray(rawString, length);
    }

    // ManifestLanguages covers all languages given in the manifest and uses short names (like "en").
    hr = appLanguagesStatics->get_ManifestLanguages(&languageList);
    Q_ASSERT_SUCCEEDED(hr);
    hr = languageList->get_Size(&size);
    Q_ASSERT_SUCCEEDED(hr);
    for (unsigned int i = 0; i < size; ++i) {
        HString language;
        hr = languageList->GetAt(i, language.GetAddressOf());
        Q_ASSERT_SUCCEEDED(hr);
        UINT32 length;
        PCWSTR rawString = language.GetRawBuffer(&length);
        const QString qLanguage = QString::fromWCharArray(rawString, length);
        bool found = false;
        // Since ApplicationLanguages:::Languages uses long names, we compare the "pre-dash" part of
        // the language and filter it out, if it is already covered by a more specialized form.
        foreach (const QString &lang, result) {
            int dashIndex = lang.indexOf('-');
            // There will not be any long name after the first short name was found, so we can stop.
            if (dashIndex == -1)
                break;

            if (lang.leftRef(dashIndex) == qLanguage) {
                found = true;
                break;
            }
        }
        if (!found)
            result << qLanguage;
    }
static inline QString qt_QStringFromHString(const HString &string)
{
    UINT32 length;
    PCWSTR rawString = string.GetRawBuffer(&length);
    return QString::fromWCharArray(rawString, length);
}
Пример #13
0
// Draws the scene.
void Game::Render()
{
    // Don't try to render anything before the first Update.
    if (m_timer.GetFrameCount() == 0)
    {
        return;
    }

    // Prepare the command list to render a new frame.
    m_deviceResources->Prepare();
    Clear();

    auto commandList = m_deviceResources->GetCommandList();
    PIXBeginEvent(commandList, PIX_COLOR_DEFAULT, L"Render");

    // Set the descriptor heaps
    ID3D12DescriptorHeap* heaps[] = { m_resourceDescriptors->Heap(), m_states->Heap() };
    commandList->SetDescriptorHeaps(_countof(heaps), heaps);

    auto t = static_cast<float>(m_timer.GetTotalSeconds());

    // Cube 1
    XMMATRIX world = XMMatrixRotationY(t) * XMMatrixTranslation(1.5f, -2.1f, (dist / 2.f) + dist * sin(t));
    m_effect->SetWorld(world);
    m_effect->SetTexture(m_resourceDescriptors->GetGpuHandle(Descriptors::Earth), m_states->LinearClamp());
    m_effect->Apply(commandList);
    m_cube->Draw(commandList);

    // Cube 2
    world = XMMatrixRotationY(-t) * XMMatrixTranslation(1.5f, 0, (dist / 2.f) + dist * sin(t));
    m_effect->SetWorld(world);
    m_effect->SetTexture(m_resourceDescriptors->GetGpuHandle(Descriptors::Windows95_sRGB), m_states->LinearClamp());
    m_effect->Apply(commandList);
    m_cube->Draw(commandList);

    // Cube 3
    world = XMMatrixRotationY(t) * XMMatrixTranslation(1.5f, 2.1f, (dist / 2.f) + dist * sin(t));
    m_effect->SetWorld(world);
    m_effect->SetTexture(m_resourceDescriptors->GetGpuHandle(Descriptors::Windows95), m_states->LinearClamp());
    m_effect->Apply(commandList);
    m_cube->Draw(commandList);

    // Cube 4
    world = XMMatrixRotationY(-t) * XMMatrixTranslation(-1.5f, -2.1f, (dist / 2.f) + dist * sin(t));
    m_effect->SetWorld(world);
    m_effect->SetTexture(m_resourceDescriptors->GetGpuHandle(Descriptors::Earth_Imm), m_states->LinearClamp());
    m_effect->Apply(commandList);
    m_cube->Draw(commandList);

    // Cube 5
    world = XMMatrixRotationY(t) * XMMatrixTranslation(-1.5f, 0, (dist / 2.f) + dist * sin(t));
    m_effect->SetWorld(world);
    m_effect->SetTexture(m_resourceDescriptors->GetGpuHandle(Descriptors::DirectXLogo_BC1), m_states->LinearClamp());
    m_effect->Apply(commandList);
    m_cube->Draw(commandList);

    // Cube 6
    world = XMMatrixRotationY(-t) * XMMatrixTranslation(-1.5f, 2.1f, (dist / 2.f) + dist * sin(t));
    m_effect->SetWorld(world);
    m_effect->SetTexture(m_resourceDescriptors->GetGpuHandle(Descriptors::DirectXLogo), m_states->LinearClamp());
    m_effect->Apply(commandList);
    m_cube->Draw(commandList);

    PIXEndEvent(commandList);

    if (m_frame == 10)
    {
        m_screenshot = m_deviceResources->GetRenderTarget();
    }

    // Show the new frame.
    PIXBeginEvent(m_deviceResources->GetCommandQueue(), PIX_COLOR_DEFAULT, L"Present");
    m_deviceResources->Present();
    m_graphicsMemory->Commit(m_deviceResources->GetCommandQueue());
    PIXEndEvent(m_deviceResources->GetCommandQueue());

    if (m_screenshot)
    {
        // We take the shot here to cope with lost device

        OutputDebugStringA("******** SCREENSHOT TEST BEGIN *************\n");

        bool success = true;

#if defined(_XBOX_ONE) && defined(_TITLE)
        const wchar_t sspath[MAX_PATH] = L"T:\\";
#elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
        wchar_t sspath[MAX_PATH] = {};

        using namespace Microsoft::WRL;
        using namespace Microsoft::WRL::Wrappers;
        using namespace ABI::Windows::Foundation;

        ComPtr<ABI::Windows::Storage::IApplicationDataStatics> appStatics;
        DX::ThrowIfFailed(GetActivationFactory(HStringReference(RuntimeClass_Windows_Storage_ApplicationData).Get(), appStatics.GetAddressOf()));

        ComPtr<ABI::Windows::Storage::IApplicationData> appData;
        DX::ThrowIfFailed(appStatics->get_Current(appData.GetAddressOf()));

        // Temporary folder
        {
            ComPtr<ABI::Windows::Storage::IStorageFolder> folder;
            DX::ThrowIfFailed(appData->get_TemporaryFolder(folder.GetAddressOf()));

            ComPtr<ABI::Windows::Storage::IStorageItem> item;
            DX::ThrowIfFailed(folder.As(&item));

            HString folderName;
            DX::ThrowIfFailed(item->get_Path(folderName.GetAddressOf()));

            unsigned int len;
            PCWSTR szPath = folderName.GetRawBuffer(&len);
            if (wcscpy_s(sspath, MAX_PATH, szPath) > 0
                || wcscat_s(sspath, L"\\") > 0)
            {
                throw std::exception("TemporaryFolder");
            }
        }
#else
        const wchar_t sspath[MAX_PATH] = L".";
#endif

        OutputDebugStringA("Output path: ");
        OutputDebugStringW(sspath);
        OutputDebugStringA("\n");

        wchar_t sspng[MAX_PATH] = {};
        wchar_t ssjpg[MAX_PATH] = {};
        wchar_t ssbmp[MAX_PATH] = {};
        wchar_t sstif[MAX_PATH] = {};
        wchar_t ssdds[MAX_PATH] = {};

        swprintf_s(sspng, L"%ls\\SCREENSHOT.PNG", sspath);
        swprintf_s(ssjpg, L"%ls\\SCREENSHOT.JPG", sspath);
        swprintf_s(ssbmp, L"%ls\\SCREENSHOT.BMP", sspath);
        swprintf_s(sstif, L"%ls\\SCREENSHOT.TIF", sspath);
        swprintf_s(ssdds, L"%ls\\SCREENSHOT.DDS", sspath);

        DeleteFileW(sspng);
        DeleteFileW(ssjpg);
        DeleteFileW(ssbmp);
        DeleteFileW(sstif);
        DeleteFileW(ssdds);

        HRESULT hr = SaveWICTextureToFile(m_deviceResources->GetCommandQueue(), m_screenshot.Get(),
            GUID_ContainerFormatPng, sspng,
            D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_PRESENT, &GUID_WICPixelFormat32bppBGRA);

        if (FAILED(hr))
        {
            char buff[128] = {};
            sprintf_s(buff, "ERROR: SaveWICTextureToFile (PNG) failed %08X\n", hr);
            OutputDebugStringA(buff);
            success = false;
        }
        else if (GetFileAttributesW(sspng) != INVALID_FILE_ATTRIBUTES)
        {
            OutputDebugStringA("Wrote SCREENSHOT.PNG\n");
        }
        else
        {
            OutputDebugStringA("ERROR: Missing SCREENSHOT.PNG!\n");
            success = false;
        }

        hr = SaveWICTextureToFile(m_deviceResources->GetCommandQueue(), m_screenshot.Get(),
            GUID_ContainerFormatJpeg, ssjpg,
            D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_PRESENT);

        if (FAILED(hr))
        {
            char buff[128] = {};
            sprintf_s(buff, "ERROR: SaveWICTextureToFile (JPG) failed %08X\n", hr);
            OutputDebugStringA(buff);
            success = false;
        }
        else if (GetFileAttributesW(ssjpg) != INVALID_FILE_ATTRIBUTES)
        {
            OutputDebugStringA("Wrote SCREENSHOT.JPG\n");
        }
        else
        {
            OutputDebugStringA("ERROR: Missing SCREENSHOT.JPG!\n");
            success = false;
        }

        hr = SaveWICTextureToFile(m_deviceResources->GetCommandQueue(), m_screenshot.Get(),
            GUID_ContainerFormatBmp, ssbmp,
            D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_PRESENT,
            &GUID_WICPixelFormat16bppBGR565);

        if (FAILED(hr))
        {
            char buff[128] = {};
            sprintf_s(buff, "ERROR: SaveWICTextureToFile (BMP) failed %08X\n", hr);
            OutputDebugStringA(buff);
            success = false;
        }
        else if (GetFileAttributesW(ssbmp) != INVALID_FILE_ATTRIBUTES)
        {
            OutputDebugStringA("Wrote SCREENSHOT.BMP\n");
        }
        else
        {
            OutputDebugStringA("ERROR: Missing SCREENSHOT.BMP!\n");
            success = false;
        }

        hr = SaveWICTextureToFile(m_deviceResources->GetCommandQueue(), m_screenshot.Get(),
            GUID_ContainerFormatTiff, sstif,
            D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_PRESENT,
            nullptr,
            [&](IPropertyBag2* props)
        {
            PROPBAG2 options[2] = { 0, 0 };
            options[0].pstrName = const_cast<wchar_t*>(L"CompressionQuality");
            options[1].pstrName = const_cast<wchar_t*>(L"TiffCompressionMethod");

            VARIANT varValues[2];
            varValues[0].vt = VT_R4;
            varValues[0].fltVal = 0.75f;

            varValues[1].vt = VT_UI1;
            varValues[1].bVal = WICTiffCompressionNone;

            (void)props->Write(2, options, varValues);
        });

        if (FAILED(hr))
        {
            char buff[128] = {};
            sprintf_s(buff, "ERROR: SaveWICTextureToFile (TIFF) failed %08X\n", hr);
            OutputDebugStringA(buff);
            success = false;
        }
        else if (GetFileAttributesW(sstif) != INVALID_FILE_ATTRIBUTES)
        {
            OutputDebugStringA("Wrote SCREENSHOT.TIF\n");
        }
        else
        {
            OutputDebugStringA("ERROR: Missing SCREENSHOT.TIF!\n");
            success = false;
        }

        hr = SaveDDSTextureToFile(m_deviceResources->GetCommandQueue(), m_screenshot.Get(), ssdds,
            D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_PRESENT);

        if (FAILED(hr))
        {
            char buff[128] = {};
            sprintf_s(buff, "ERROR: SaveWICTextureToFile (DDS) failed %08X\n", hr);
            OutputDebugStringA(buff);
            success = false;
        }
        else if (GetFileAttributesW(ssdds) != INVALID_FILE_ATTRIBUTES)
        {
            OutputDebugStringA("Wrote SCREENSHOT.DDS\n");
        }
        else
        {
            OutputDebugStringA("ERROR: Missing SCREENSHOT.DDS!\n");
            success = false;
        }

        // TODO - pass in D3D12_HEAP_TYPE_READBACK resource

        // ScreenGrab of an MSAA resource is tested elsewhere

        OutputDebugStringA(success ? "Passed\n" : "Failed\n");
        OutputDebugStringA("********* SCREENSHOT TEST END **************\n");
        m_screenshot.Reset();
    }
}
static QList<QNetworkInterfacePrivate *> interfaceListing()
{
    QList<QNetworkInterfacePrivate *> interfaces;

    QList<HostNameInfo> hostList;

    ComPtr<INetworkInformationStatics> hostNameStatics;
    GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_Connectivity_NetworkInformation).Get(), &hostNameStatics);

    ComPtr<IVectorView<HostName *>> hostNames;
    hostNameStatics->GetHostNames(&hostNames);
    if (!hostNames)
        return interfaces;

    unsigned int hostNameCount;
    hostNames->get_Size(&hostNameCount);
    for (unsigned i = 0; i < hostNameCount; ++i) {
        HostNameInfo hostInfo;
        ComPtr<IHostName> hostName;
        hostNames->GetAt(i, &hostName);

        HostNameType type;
        hostName->get_Type(&type);
        if (type == HostNameType_DomainName)
            continue;

        ComPtr<IIPInformation> ipInformation;
        hostName->get_IPInformation(&ipInformation);
        ComPtr<INetworkAdapter> currentAdapter;
        ipInformation->get_NetworkAdapter(&currentAdapter);

        currentAdapter->get_NetworkAdapterId(&hostInfo.adapterId);

        ComPtr<IReference<unsigned char>> prefixLengthReference;
        ipInformation->get_PrefixLength(&prefixLengthReference);

        prefixLengthReference->get_Value(&hostInfo.prefixLength);

        // invalid prefixes
        if ((type == HostNameType_Ipv4 && hostInfo.prefixLength > 32)
                || (type == HostNameType_Ipv6 && hostInfo.prefixLength > 128))
            continue;

        HString name;
        hostName->get_CanonicalName(name.GetAddressOf());
        UINT32 length;
        PCWSTR rawString = name.GetRawBuffer(&length);
        hostInfo.address = QString::fromWCharArray(rawString, length);

        hostList << hostInfo;
    }

    INetworkInformationStatics *networkInfoStatics;
    GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_Connectivity_NetworkInformation).Get(), &networkInfoStatics);
    ComPtr<IVectorView<ConnectionProfile *>> connectionProfiles;
    networkInfoStatics->GetConnectionProfiles(&connectionProfiles);
    if (!connectionProfiles)
        return interfaces;

    unsigned int size;
    connectionProfiles->get_Size(&size);
    for (unsigned int i = 0; i < size; ++i) {
        QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate;
        interfaces << iface;

        ComPtr<IConnectionProfile> profile;
        connectionProfiles->GetAt(i, &profile);

        NetworkConnectivityLevel connectivityLevel;
        profile->GetNetworkConnectivityLevel(&connectivityLevel);
        if (connectivityLevel != NetworkConnectivityLevel_None)
            iface->flags = QNetworkInterface::IsUp | QNetworkInterface::IsRunning;

        ComPtr<INetworkAdapter> adapter;
        profile->get_NetworkAdapter(&adapter);
        UINT32 type;
        adapter->get_IanaInterfaceType(&type);
        if (type == 23)
            iface->flags |= QNetworkInterface::IsPointToPoint;
        GUID id;
        adapter->get_NetworkAdapterId(&id);
        OLECHAR adapterName[39]={0};
        StringFromGUID2(id, adapterName, 39);
        iface->name = QString::fromWCharArray(adapterName);

        // According to http://stackoverflow.com/questions/12936193/how-unique-is-the-ethernet-network-adapter-id-in-winrt-it-is-derived-from-the-m
        // obtaining the MAC address using WinRT API is impossible
        // iface->hardwareAddress = ?

        for (int i = 0; i < hostList.length(); ++i) {
            const HostNameInfo hostInfo = hostList.at(i);
            if (id != hostInfo.adapterId)
                continue;

            QNetworkAddressEntry entry;
            entry.setIp(QHostAddress(hostInfo.address));
            entry.setPrefixLength(hostInfo.prefixLength);
            iface->addressEntries << entry;

            hostList.takeAt(i);
            --i;
        }
    }
    return interfaces;
}
bool QNativeSocketEnginePrivate::fetchConnectionParameters()
{
    localPort = 0;
    localAddress.clear();
    peerPort = 0;
    peerAddress.clear();

    if (socketType == QAbstractSocket::TcpSocket) {
        ComPtr<IHostName> hostName;
        HString tmpHString;
        ComPtr<IStreamSocketInformation> info;
        if (FAILED(tcpSocket()->get_Information(&info))) {
            qWarning("QNativeSocketEnginePrivate::fetchConnectionParameters: Could not obtain socket info");
            return false;
        }
        info->get_LocalAddress(&hostName);
        if (hostName) {
            hostName->get_CanonicalName(tmpHString.GetAddressOf());
            localAddress.setAddress(qt_QStringFromHString(tmpHString));
            info->get_LocalPort(tmpHString.GetAddressOf());
            localPort = qt_QStringFromHString(tmpHString).toInt();
        }
        if (!localPort && tcpListener) {
            ComPtr<IStreamSocketListenerInformation> listenerInfo = 0;
            tcpListener->get_Information(&listenerInfo);
            listenerInfo->get_LocalPort(tmpHString.GetAddressOf());
            localPort = qt_QStringFromHString(tmpHString).toInt();
            localAddress == QHostAddress::Any;
        }
        info->get_RemoteAddress(&hostName);
        if (hostName) {
            hostName->get_CanonicalName(tmpHString.GetAddressOf());
            peerAddress.setAddress(qt_QStringFromHString(tmpHString));
            info->get_RemotePort(tmpHString.GetAddressOf());
            peerPort = qt_QStringFromHString(tmpHString).toInt();
        }
    } else if (socketType == QAbstractSocket::UdpSocket) {
        ComPtr<IHostName> hostName;
        HString tmpHString;
        ComPtr<IDatagramSocketInformation> info;
        if (FAILED(udpSocket()->get_Information(&info))) {
            qWarning("QNativeSocketEnginePrivate::fetchConnectionParameters: Could not obtain socket information");
            return false;
        }
        info->get_LocalAddress(&hostName);
        if (hostName) {
            hostName->get_CanonicalName(tmpHString.GetAddressOf());
            localAddress.setAddress(qt_QStringFromHString(tmpHString));
            info->get_LocalPort(tmpHString.GetAddressOf());
            localPort = qt_QStringFromHString(tmpHString).toInt();
        }

        info->get_RemoteAddress(&hostName);
        if (hostName) {
            hostName->get_CanonicalName(tmpHString.GetAddressOf());
            peerAddress.setAddress(qt_QStringFromHString(tmpHString));
            info->get_RemotePort(tmpHString.GetAddressOf());
            peerPort = qt_QStringFromHString(tmpHString).toInt();
        }
    }
    return true;
}
Пример #16
0
HRESULT MetroUtils::CreateUri(HString& aHString, ComPtr<IUriRuntimeClass>& aUriOut)
{
  return MetroUtils::CreateUri(aHString.Get(), aUriOut);
}
Пример #17
0
HRESULT
FrameworkView::OnDataShareRequested(IDataTransferManager* aDTM,
                                    IDataRequestedEventArgs* aArg)
{
  // Only share pages that contain a title and a URI
  nsCOMPtr<nsIMetroUIUtils> metroUIUtils = do_CreateInstance("@mozilla.org/metro-ui-utils;1");
  if (!metroUIUtils)
      return E_FAIL;

  nsString url, title;
  nsresult rv = metroUIUtils->GetCurrentPageURI(url);
  nsresult rv2 = metroUIUtils->GetCurrentPageTitle(title);
  if (NS_FAILED(rv) || NS_FAILED(rv2)) {
    return E_FAIL;
  }

  // Get the package to share
  HRESULT hr;
  ComPtr<IDataRequest> request;
  AssertRetHRESULT(hr = aArg->get_Request(request.GetAddressOf()), hr);
  ComPtr<IDataPackage> dataPackage;
  AssertRetHRESULT(hr = request->get_Data(dataPackage.GetAddressOf()), hr);
  ComPtr<IDataPackagePropertySet> props;
  AssertRetHRESULT(hr = dataPackage->get_Properties(props.GetAddressOf()), hr);

  // Only add a URI to the package when there is no selected content.
  // This is because most programs treat URIs as highest priority to generate
  // their own preview, but we only want the selected content to show up.
  bool hasSelectedContent = false;
  metroUIUtils->GetHasSelectedContent(&hasSelectedContent);
  if (!hasSelectedContent) {
    ComPtr<IUriRuntimeClass> uri;
    AssertRetHRESULT(hr = MetroUtils::CreateUri(HStringReference(url.BeginReading()).Get(), uri), hr);

    // If there is no selection, then we don't support sharing for sites that
    // are not HTTP, HTTPS, FTP, and FILE.
    HString schemeHString;
    uri->get_SchemeName(schemeHString.GetAddressOf());
    unsigned int length;
    LPCWSTR scheme = schemeHString.GetRawBuffer(&length);
    if (!scheme || wcscmp(scheme, L"http") && wcscmp(scheme, L"https") &&
        wcscmp(scheme, L"ftp") && wcscmp(scheme, L"file")) {
      return S_OK;
    }

    AssertRetHRESULT(hr = dataPackage->SetUri(uri.Get()), hr);
  }

  // Add whatever content metroUIUtils wants us to for the text sharing
  nsString shareText;
  if (NS_SUCCEEDED(metroUIUtils->GetShareText(shareText)) && shareText.Length()) {
    AssertRetHRESULT(hr = dataPackage->SetText(HStringReference(shareText.BeginReading()).Get()) ,hr);
  }

  // Add whatever content metroUIUtils wants us to for the HTML sharing
  nsString shareHTML;
  if (NS_SUCCEEDED(metroUIUtils->GetShareHTML(shareHTML)) && shareHTML.Length()) {
    // The sharing format needs some special headers, so pass it through Windows
    ComPtr<IHtmlFormatHelperStatics> htmlFormatHelper;
    hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_DataTransfer_HtmlFormatHelper).Get(),
                              htmlFormatHelper.GetAddressOf());
    AssertRetHRESULT(hr, hr);
    HSTRING fixedHTML;
    htmlFormatHelper->CreateHtmlFormat(HStringReference(shareHTML.BeginReading()).Get(), &fixedHTML);

    // And now add the fixed HTML to the data package
    AssertRetHRESULT(hr = dataPackage->SetHtmlFormat(fixedHTML), hr);
  }

  // Obtain the brand name
  nsCOMPtr<nsIStringBundleService> bundleService = 
    do_GetService(NS_STRINGBUNDLE_CONTRACTID);
  NS_ENSURE_TRUE(bundleService, E_FAIL);
  nsCOMPtr<nsIStringBundle> brandBundle;
  nsString brandName;
  bundleService->CreateBundle("chrome://branding/locale/brand.properties",
    getter_AddRefs(brandBundle));
  NS_ENSURE_TRUE(brandBundle, E_FAIL);
  if(brandBundle) {
    brandBundle->GetStringFromName(MOZ_UTF16("brandFullName"),
                                   getter_Copies(brandName));
  }

  // Set these properties at the end.  Otherwise users can get a
  // "There was a problem with the data package" error when there
  // is simply nothing to share.
  props->put_ApplicationName(HStringReference(brandName.BeginReading()).Get());
  if (title.Length()) {
    props->put_Title(HStringReference(title.BeginReading()).Get());
  } else {
    props->put_Title(HStringReference(brandName.BeginReading()).Get());
  }
  props->put_Description(HStringReference(url.BeginReading()).Get());

  return S_OK;
}
Пример #18
0
QT_BEGIN_NAMESPACE

//#define QHOSTINFO_DEBUG

QHostInfo QHostInfoAgent::fromName(const QString &hostName)
{
    QHostInfo results;

    QHostAddress address;
    if (address.setAddress(hostName)) {
        // Reverse lookup
        // TODO: is there a replacement for getnameinfo for winrt?
        Q_UNIMPLEMENTED();
        return results;
    }

    QByteArray aceHostname = QUrl::toAce(hostName);
    results.setHostName(hostName);
    if (aceHostname.isEmpty()) {
        results.setError(QHostInfo::HostNotFound);
        results.setErrorString(hostName.isEmpty() ? tr("No host name given") : tr("Invalid hostname"));
        return results;
    }

    ComPtr<IHostNameFactory> hostnameFactory;
    HRESULT hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_HostName).Get(),
                                        IID_PPV_ARGS(&hostnameFactory));
    Q_ASSERT_X(SUCCEEDED(hr), Q_FUNC_INFO, qPrintable(qt_error_string(hr)));

    ComPtr<IHostName> host;
    HStringReference hostNameRef((const wchar_t*)hostName.utf16());
    hostnameFactory->CreateHostName(hostNameRef.Get(), &host);

    ComPtr<IDatagramSocketStatics> datagramSocketStatics;
    GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_Sockets_DatagramSocket).Get(), &datagramSocketStatics);

    ComPtr<IAsyncOperation<IVectorView<EndpointPair *> *>> op;
    datagramSocketStatics->GetEndpointPairsAsync(host.Get(),
                                                 HString::MakeReference(L"0").Get(),
                                                 &op);

    ComPtr<IVectorView<EndpointPair *>> endpointPairs;
    hr = op->GetResults(&endpointPairs);
    int waitCount = 0;
    while (hr == E_ILLEGAL_METHOD_CALL) {
        WaitForSingleObjectEx(GetCurrentThread(), 50, FALSE);
        hr = op->GetResults(&endpointPairs);
        if (++waitCount > 1200) // Wait for 1 minute max
            return results;
    }

    if (!endpointPairs)
        return results;

    unsigned int size;
    endpointPairs->get_Size(&size);
    QList<QHostAddress> addresses;
    for (unsigned int i = 0; i < size; ++i) {
        ComPtr<IEndpointPair> endpointpair;
        endpointPairs->GetAt(i, &endpointpair);
        ComPtr<IHostName> remoteHost;
        endpointpair->get_RemoteHostName(&remoteHost);
        if (!remoteHost)
            continue;
        HostNameType type;
        remoteHost->get_Type(&type);
        if (type == HostNameType_DomainName)
            continue;

        HString name;
        remoteHost->get_CanonicalName(name.GetAddressOf());
        UINT32 length;
        PCWSTR rawString = name.GetRawBuffer(&length);
        QHostAddress addr;
        addr.setAddress(QString::fromWCharArray(rawString, length));
        if (!addresses.contains(addr))
            addresses.append(addr);
    }
    results.setAddresses(addresses);

    return results;
}
Пример #19
0
QT_BEGIN_NAMESPACE

void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, const QHostAddress &nameserver, QDnsLookupReply *reply)
{
    // TODO: Add nameserver support for winRT
    if (!nameserver.isNull())
        qWarning() << "Ignoring nameserver as its currently not supported on WinRT";

    // TODO: is there any way to do "proper" dns lookup?
    if (requestType != QDnsLookup::A && requestType != QDnsLookup::AAAA
            && requestType != QDnsLookup::ANY) {
        reply->error = QDnsLookup::InvalidRequestError;
        reply->errorString = QLatin1String("WinRT only supports IPv4 and IPv6 requests");
        return;
    }

    QString aceHostname = QUrl::fromAce(requestName);
    if (aceHostname.isEmpty()) {
        reply->error = QDnsLookup::InvalidRequestError;
        reply->errorString = requestName.isEmpty() ? tr("No hostname given") : tr("Invalid hostname");
        return;
    }

    ComPtr<IHostNameFactory> hostnameFactory;
    HRESULT hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_HostName).Get(),
                                        IID_PPV_ARGS(&hostnameFactory));
    if (FAILED(hr)) {
        reply->error = QDnsLookup::ResolverError;
        reply->errorString = QLatin1String("Could not obtain hostname factory");
        return;
    }
    ComPtr<IHostName> host;
    HStringReference hostNameRef((const wchar_t*)aceHostname.utf16());
    hostnameFactory->CreateHostName(hostNameRef.Get(), &host);

    ComPtr<IDatagramSocketStatics> datagramSocketStatics;
    GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_Sockets_DatagramSocket).Get(), &datagramSocketStatics);

    ComPtr<IAsyncOperation<IVectorView<EndpointPair *> *>> op;
    datagramSocketStatics->GetEndpointPairsAsync(host.Get(),
                                                 HString::MakeReference(L"0").Get(),
                                                 &op);

    ComPtr<IVectorView<EndpointPair *>> endpointPairs;
    hr = op->GetResults(&endpointPairs);
    int waitCount = 0;
    while (hr == E_ILLEGAL_METHOD_CALL) {
        WaitForSingleObjectEx(GetCurrentThread(), 50, FALSE);
        hr = op->GetResults(&endpointPairs);
        if (++waitCount > 1200) // Wait for 1 minute max
            return;
    }

    if (!endpointPairs)
        return;

    unsigned int size;
    endpointPairs->get_Size(&size);
    // endpoint pairs might contain duplicates so we temporarily store addresses in a QSet
    QSet<QHostAddress> addresses;
    for (unsigned int i = 0; i < size; ++i) {
        ComPtr<IEndpointPair> endpointpair;
        endpointPairs->GetAt(i, &endpointpair);
        ComPtr<IHostName> remoteHost;
        endpointpair->get_RemoteHostName(&remoteHost);
        HostNameType type;
        remoteHost->get_Type(&type);
        if (type == HostNameType_Bluetooth || type == HostNameType_DomainName
                || (requestType != QDnsLookup::ANY
                && ((type == HostNameType_Ipv4 && requestType == QDnsLookup::AAAA)
                || (type == HostNameType_Ipv6 && requestType == QDnsLookup::A))))
            continue;

        HString name;
        remoteHost->get_CanonicalName(name.GetAddressOf());
        UINT32 length;
        PCWSTR rawString = name.GetRawBuffer(&length);
        addresses.insert(QHostAddress(QString::fromWCharArray(rawString, length)));
    }
    foreach (const QHostAddress &address, addresses) {
        QDnsHostAddressRecord record;
        record.d->name = aceHostname;
        record.d->value = address;
        reply->hostAddressRecords.append(record);
    }
static bool blacklisted(const wchar_t (&blackListName)[n], const HString &deviceModel)
{
    quint32 deviceNameLength;
    const wchar_t *deviceName = deviceModel.GetRawBuffer(&deviceNameLength);
    return n - 1 <= deviceNameLength && !wmemcmp(blackListName, deviceName, n - 1);
}