summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-05-19 15:09:28 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-03 13:45:24 +0200
commit3cc82656121c4bae8f96e16e0b364116d58f45ff (patch)
tree047ebd5fc27fdd88250be15f330fab32c75bf201
parenteaf069902111533f0e675ab32279bb57a5916169 (diff)
downloadqttools-3cc82656121c4bae8f96e16e0b364116d58f45ff.tar.gz
CoreCon: Support API Versioning, and add Version 12 (WP8.1) support
While intrusive, versioned headers and a templated backend allows apps like winrtrunner and qtd3dservice to access multiple versions of CoreCon, allowing for simultaneous support of Windows Phone 8 and Windows Phone 8.1 devices. This also allows for simple addition of future versions, should there be a need. Applications using these headers should use the versioned API instead of the original ccapi.h. This has been fixed in winrtrunner and qtd3dservice. Task-number: QTBUG-37771 Change-Id: I70cad98a2bf7f232dfd92f1c068cf0e1a8eadf88 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
-rw-r--r--src/qtd3dservice/xaphandler.cpp12
-rw-r--r--src/shared/corecon/ccapi.h271
-rw-r--r--src/shared/corecon/ccapi_11.h63
-rw-r--r--src/shared/corecon/ccapi_12.h63
-rw-r--r--src/shared/corecon/corecon.cpp398
-rw-r--r--src/shared/corecon/corecon.h13
-rw-r--r--src/shared/corecon/corecon.pri2
-rw-r--r--src/winrtrunner/xapengine.cpp8
8 files changed, 596 insertions, 234 deletions
diff --git a/src/qtd3dservice/xaphandler.cpp b/src/qtd3dservice/xaphandler.cpp
index 1820eb76f..37d512a50 100644
--- a/src/qtd3dservice/xaphandler.cpp
+++ b/src/qtd3dservice/xaphandler.cpp
@@ -50,9 +50,9 @@
#include <wrl.h>
using namespace Microsoft::WRL;
-#include <ccapi.h>
+#include <ccapi_11.h>
#include <corecon.h>
-Q_GLOBAL_STATIC(CoreConServer, coreConServer)
+Q_GLOBAL_STATIC_WITH_ARGS(CoreConServer, coreConServer, (11))
#define bstr(s) _bstr_t((const wchar_t *)s.utf16())
@@ -136,8 +136,8 @@ extern int xapAppNames(int deviceIndex, QSet<QString> &apps)
HRESULT hr;
_bstr_t connectionName;
ComPtr<ICcConnection> connection;
- hr = coreConServer->handle()->GetConnection(
- device->handle(), 5000, NULL, connectionName.GetAddress(), &connection);
+ hr = static_cast<ICcServer *>(coreConServer->handle())->GetConnection(
+ static_cast<ICcDevice *>(device->handle()), 5000, NULL, connectionName.GetAddress(), &connection);
if (FAILED(hr)) {
qCWarning(lcD3DService) << "Unable to initialize connection:"
<< coreConServer->formatError(hr);
@@ -227,8 +227,8 @@ extern int handleXapDevice(int deviceIndex, const QString &app, const QString &l
HRESULT hr;
_bstr_t connectionName;
ComPtr<ICcConnection> connection;
- hr = coreConServer->handle()->GetConnection(
- device->handle(), 5000, NULL, connectionName.GetAddress(), &connection);
+ hr = static_cast<ICcServer *>(coreConServer->handle())->GetConnection(
+ static_cast<ICcDevice *>(device->handle()), 5000, NULL, connectionName.GetAddress(), &connection);
if (FAILED(hr)) {
qCWarning(lcD3DService) << "Unable to initialize connection:"
<< coreConServer->formatError(hr);
diff --git a/src/shared/corecon/ccapi.h b/src/shared/corecon/ccapi.h
index e4d35c889..48da15914 100644
--- a/src/shared/corecon/ccapi.h
+++ b/src/shared/corecon/ccapi.h
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#ifndef CCAPI_H
-#define CCAPI_H
+#ifndef CCAPI_VERSIONED_H
+#define CCAPI_VERSIONED_H
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Core Connectivity API (Experimental)
@@ -62,34 +62,77 @@
#include <windows.h>
+#ifndef CORECON_VER
+static_assert(false, "You must define the CoreCon version with CORECON_VER.");
+#endif
+
+#if CORECON_VER==11
+
+static const CLSID CLSID_ConMan_11 = { 0x349AB2E8, 0x71B6, 0x4069, 0xAD, 0x9C, 0x11, 0x70, 0x84, 0x9D, 0xA6, 0x4C };
+
// Undefined
-struct ICcFormFactorContainer;
-struct ICcOSImage;
-struct ICcOSImageContainer;
-struct ICcPackageContainer;
-struct ICcProjectContainer;
-struct ICcServiceCategoryContainer;
-struct ICcServiceCB;
-struct ICcServiceInfo;
-struct ICcTransportStream;
-struct ICcTypeToArchitectureMap;
+struct ICcFormFactorContainer_11;
+struct ICcOSImage_11;
+struct ICcOSImageContainer_11;
+struct ICcPackageContainer_11;
+struct ICcProjectContainer_11;
+struct ICcServiceCategoryContainer_11;
+struct ICcServiceCB_11;
+struct ICcServiceInfo_11;
+struct ICcTransportStream_11;
+struct ICcTypeToArchitectureMap_11;
// Defined
-struct ICcConnection;
-struct ICcCollection;
-struct ICcConnection3;
-struct ICcDatastore;
-struct ICcDevice;
-struct ICcDeviceContainer;
-struct ICcObject;
-struct ICcObjectContainer;
-struct ICcPlatform;
-struct ICcPlatformContainer;
-struct ICcProperty;
-struct ICcPropertyContainer;
-struct ICcServer;
-
-static const CLSID CLSID_ConMan = { 0x349AB2E8, 0x71B6, 0x4069, 0xAD, 0x9C, 0x11, 0x70, 0x84, 0x9D, 0xA6, 0x4C };
+struct ICcConnection_11;
+struct ICcCollection_11;
+struct ICcConnection3_11;
+struct ICcDatastore_11;
+struct ICcDevice_11;
+struct ICcDeviceContainer_11;
+struct ICcObject_11;
+struct ICcObjectContainer_11;
+struct ICcPlatform_11;
+struct ICcPlatformContainer_11;
+struct ICcProperty_11;
+struct ICcPropertyContainer_11;
+struct ICcServer_11;
+
+#elif CORECON_VER==12
+
+static const CLSID CLSID_ConMan_12 = { 0x2D0A16C9, 0x53D9, 0x42C1, 0xBC, 0xC2, 0x8D, 0x2A, 0x13, 0x5E, 0x21, 0x63 };
+
+// Undefined
+struct ICcFormFactorContainer_12;
+struct ICcOSImage_12;
+struct ICcOSImageContainer_12;
+struct ICcPackageContainer_12;
+struct ICcProjectContainer_12;
+struct ICcServiceCategoryContainer_12;
+struct ICcServiceCB_12;
+struct ICcServiceInfo_12;
+struct ICcTransportStream_12;
+struct ICcTypeToArchitectureMap_12;
+
+// Defined
+struct ICcConnection_12;
+struct ICcCollection_12;
+struct ICcConnection3_12;
+struct ICcDatastore_12;
+struct ICcDevice_12;
+struct ICcDeviceContainer_12;
+struct ICcObject_12;
+struct ICcObjectContainer_12;
+struct ICcPlatform_12;
+struct ICcPlatformContainer_12;
+struct ICcProperty_12;
+struct ICcPropertyContainer_12;
+struct ICcServer_12;
+
+#endif
+
+
+#ifndef CCAPI_H
+#define CCAPI_H
typedef struct tagFileInfo{
LONG m_FileAttribues;
@@ -133,14 +176,28 @@ typedef struct tagPlatformInfo{
DWORD m_InstructionSet;
} SystemInfo;
-struct __declspec(uuid("{7A4AA9D3-0F9E-4CD4-8D52-62B6C0653752}")) ICcCollection : public IDispatch
+#endif // CCAPI_H
+
+#if CORECON_VER==11
+struct __declspec(uuid("{7A4AA9D3-0F9E-4CD4-8D52-62B6C0653752}")) ICcCollection_11 : public IDispatch
+#elif CORECON_VER==12
+struct __declspec(uuid("{9A83560F-377D-419F-B572-AEC3C1A44671}")) ICcCollection_12 : public IDispatch
+#endif
{
virtual HRESULT __stdcall get_Count(long *count) = 0;
- virtual HRESULT __stdcall get_Item(long index, ICcObject **object) = 0;
+#if CORECON_VER==11
+ virtual HRESULT __stdcall get_Item(long index, ICcObject_11 **object) = 0;
+#elif CORECON_VER==12
+ virtual HRESULT __stdcall get_Item(long index, ICcObject_12 **object) = 0;
+#endif
virtual HRESULT __stdcall get_NewEnum(IUnknown **val) = 0;
};
-struct __declspec(uuid("{CEF4C928-326F-49A9-B7E7-8FE7588B74B5}")) ICcConnection : public IDispatch
+#if CORECON_VER==11
+struct __declspec(uuid("{CEF4C928-326F-49A9-B7E7-8FE7588B74B5}")) ICcConnection_11 : public IDispatch
+#elif CORECON_VER==12
+struct __declspec(uuid("{906D8E75-8AE6-46B5-B4B6-43B83D9A0948}")) ICcConnection_12 : public IDispatch
+#endif
{
virtual HRESULT __stdcall DeviceId(BSTR *deviceId) = 0;
virtual HRESULT __stdcall GetSystemInfo(SystemInfo *systemInfo) = 0;
@@ -165,12 +222,20 @@ struct __declspec(uuid("{CEF4C928-326F-49A9-B7E7-8FE7588B74B5}")) ICcConnection
virtual HRESULT __stdcall ConnectDevice() = 0;
virtual HRESULT __stdcall DisconnectDevice() = 0;
virtual HRESULT __stdcall SearchFileSystem(BSTR criteria, BSTR startingDirectory, SAFEARRAY/*<BSTR>*/ *results) = 0;
- virtual HRESULT __stdcall CreateStream(BSTR streamId, DWORD timeout, ICcServiceCB *callback, DWORD *cookieId, ICcTransportStream **stream) = 0;
+#if CORECON_VER==11
+ virtual HRESULT __stdcall CreateStream(BSTR streamId, DWORD timeout, ICcServiceCB_11 *callback, DWORD *cookieId, ICcTransportStream_11 **stream) = 0;
+#elif CORECON_VER==12
+ virtual HRESULT __stdcall CreateStream(BSTR streamId, DWORD timeout, ICcServiceCB_12 *callback, DWORD *cookieId, ICcTransportStream_12 **stream) = 0;
+#endif
virtual HRESULT __stdcall EnumerateProcesses(SAFEARRAY/*<BSTR>*/ **processes, SAFEARRAY/*<DWORD>*/ **processIds) = 0;
virtual HRESULT __stdcall CloseProcessHandle(DWORD processHandle) = 0;
};
-struct __declspec(uuid("{F4B43EA3-3106-4D3D-94E3-084D4136C40C}")) ICcConnection3 : public IUnknown
+#if CORECON_VER==11
+struct __declspec(uuid("{F4B43EA3-3106-4D3D-94E3-084D4136C40C}")) ICcConnection3_11 : public IUnknown
+#elif CORECON_VER==12
+struct __declspec(uuid("{B158FE65-7DCC-4809-9054-A7B52FD43DE3}")) ICcConnection3_12 : public IUnknown
+#endif
{
virtual HRESULT __stdcall GetInstalledApplicationCount(int *count) = 0; // E_NOTIMPL
virtual HRESULT __stdcall GetInstalledApplicationIDs(SAFEARRAY/*<BSTR>*/ **productIds, SAFEARRAY/*<BSTR>*/ **instanceIds) = 0;
@@ -191,89 +256,171 @@ struct __declspec(uuid("{F4B43EA3-3106-4D3D-94E3-084D4136C40C}")) ICcConnection3
virtual HRESULT __stdcall ActivateDevice() = 0;
};
-struct __declspec(uuid("{5F25394E-D9B6-4F8E-A0DF-325610A35BFA}")) ICcConnection4 : public IUnknown
+#if CORECON_VER==11
+struct __declspec(uuid("{5F25394E-D9B6-4F8E-A0DF-325610A35BFA}")) ICcConnection4_11 : public IUnknown
+#elif CORECON_VER==12
+struct __declspec(uuid("{68CBC76F-ADF6-4586-B495-E34771B8EAC2}")) ICcConnection4_12 : public IUnknown
+#endif
{
virtual HRESULT __stdcall GetDirectoryListing(BSTR deviceDirPath, SAFEARRAY/*<BSTR>*/ **listing) = 0;
virtual HRESULT __stdcall GetApplicationType(BSTR productId, DWORD *type) = 0;
virtual HRESULT __stdcall GetEndPoints(int localPort, BSTR localIp, BSTR remoteIp, int remotePort) = 0;
};
-struct __declspec(uuid("{EDB0A0CA-F0F8-4EBF-9D31-43E182569A5A}")) ICcDatastore : public IDispatch
+#if CORECON_VER==11
+struct __declspec(uuid("{EDB0A0CA-F0F8-4EBF-9D31-43E182569A5A}")) ICcDatastore_11 : public IDispatch
+#elif CORECON_VER==12
+struct __declspec(uuid("{2E6AF7C6-CBAB-4E6E-B78A-90A04A2CE523}")) ICcDatastore_12 : public IDispatch
+#endif
{
virtual HRESULT __stdcall Save() = 0;
virtual HRESULT __stdcall RegisterRefreshEvent(BSTR eventName) = 0;
virtual HRESULT __stdcall UnregisterRefreshEvent() = 0;
- virtual HRESULT __stdcall get_DeviceContainer(ICcDeviceContainer **dc) = 0;
- virtual HRESULT __stdcall get_OSImageContainer(ICcOSImageContainer **oc) = 0;
- virtual HRESULT __stdcall get_PackageContainer(ICcPackageContainer **pc) = 0;
- virtual HRESULT __stdcall get_PlatformContainer(ICcPlatformContainer **pc) = 0;
- virtual HRESULT __stdcall get_PropertyContainer(ICcPropertyContainer **pc) = 0;
- virtual HRESULT __stdcall get_ServiceCategoryContainer(ICcServiceCategoryContainer **scc) = 0;
+#if CORECON_VER==11
+ virtual HRESULT __stdcall get_DeviceContainer(ICcDeviceContainer_11 **dc) = 0;
+ virtual HRESULT __stdcall get_OSImageContainer(ICcOSImageContainer_11 **oc) = 0;
+ virtual HRESULT __stdcall get_PackageContainer(ICcPackageContainer_11 **pc) = 0;
+ virtual HRESULT __stdcall get_PlatformContainer(ICcPlatformContainer_11 **pc) = 0;
+ virtual HRESULT __stdcall get_PropertyContainer(ICcPropertyContainer_11 **pc) = 0;
+ virtual HRESULT __stdcall get_ServiceCategoryContainer(ICcServiceCategoryContainer_11 **scc) = 0;
+#elif CORECON_VER==12
+ virtual HRESULT __stdcall get_DeviceContainer(ICcDeviceContainer_12 **dc) = 0;
+ virtual HRESULT __stdcall get_OSImageContainer(ICcOSImageContainer_12 **oc) = 0;
+ virtual HRESULT __stdcall get_PackageContainer(ICcPackageContainer_12 **pc) = 0;
+ virtual HRESULT __stdcall get_PlatformContainer(ICcPlatformContainer_12 **pc) = 0;
+ virtual HRESULT __stdcall get_PropertyContainer(ICcPropertyContainer_12 **pc) = 0;
+ virtual HRESULT __stdcall get_ServiceCategoryContainer(ICcServiceCategoryContainer_12 **scc) = 0;
+#endif
virtual HRESULT __stdcall get_Version(BSTR *version) = 0;
};
-struct __declspec(uuid("{971BF639-8C53-4057-B635-375D7BCDFF3E}")) ICcDevice : public IDispatch
+#if CORECON_VER==11
+struct __declspec(uuid("{971BF639-8C53-4057-B635-375D7BCDFF3E}")) ICcDevice_11 : public IDispatch
+#elif CORECON_VER==12
+struct __declspec(uuid("{22773666-28CC-4AD6-9F07-E06BE40EEDB3}")) ICcDevice_12 : public IDispatch
+#endif
{
virtual HRESULT __stdcall ClearOSImage() = 0;
virtual HRESULT __stdcall ClearServiceMap(BSTR serviceCatetoryId) = 0;
- virtual HRESULT __stdcall GetOSImage(ICcOSImage **image) = 0;
- virtual HRESULT __stdcall GetServiceMap(BSTR serviceCategoryId, ICcServiceInfo **serviceInfo) = 0;
+#if CORECON_VER==11
+ virtual HRESULT __stdcall GetOSImage(ICcOSImage_11 **image) = 0;
+ virtual HRESULT __stdcall GetServiceMap(BSTR serviceCategoryId, ICcServiceInfo_11 **serviceInfo) = 0;
+#elif CORECON_VER==12
+ virtual HRESULT __stdcall GetOSImage(ICcOSImage_12 **image) = 0;
+ virtual HRESULT __stdcall GetServiceMap(BSTR serviceCategoryId, ICcServiceInfo_12 **serviceInfo) = 0;
+#endif
virtual HRESULT __stdcall SetOSImage(BSTR osImage) = 0;
virtual HRESULT __stdcall SetServiceMap(BSTR serviceCategoryId, BSTR serviceInfoId) = 0;
};
-struct __declspec(uuid("{88152DD3-5ECB-47A2-8F15-610C4C390122}")) ICcDeviceContainer : public IDispatch
+#if CORECON_VER==11
+struct __declspec(uuid("{88152DD3-5ECB-47A2-8F15-610C4C390122}")) ICcDeviceContainer_11 : public IDispatch
+#elif CORECON_VER==12
+struct __declspec(uuid("{D747386E-3EAB-4E04-8DD5-7037D192A06D}")) ICcDeviceContainer_12 : public IDispatch
+#endif
{
};
-struct __declspec(uuid("{B669EC21-E8FC-42E4-AEC5-8F0EF3673AB8}")) ICcObject : public IDispatch
+#if CORECON_VER==11
+struct __declspec(uuid("{B669EC21-E8FC-42E4-AEC5-8F0EF3673AB8}")) ICcObject_11 : public IDispatch
+#elif CORECON_VER==12
+struct __declspec(uuid("{F84BC223-B877-43A2-BE9C-68CFB0020732}")) ICcObject_12 : public IDispatch
+#endif
{
virtual HRESULT __stdcall get_Name(BSTR *name) = 0;
virtual HRESULT __stdcall put_Name(BSTR name) = 0;
virtual HRESULT __stdcall get_ID(BSTR *id) = 0;
virtual HRESULT __stdcall get_IsProtected(VARIANT_BOOL *isProtected) = 0;
- virtual HRESULT __stdcall get_PropertyContainer(ICcPropertyContainer **pc) = 0;
+#if CORECON_VER==11
+ virtual HRESULT __stdcall get_PropertyContainer(ICcPropertyContainer_11 **pc) = 0;
+#elif CORECON_VER==12
+ virtual HRESULT __stdcall get_PropertyContainer(ICcPropertyContainer_12 **pc) = 0;
+#endif
};
-struct __declspec(uuid("{1C0048A9-A73F-41B3-BD75-467D615CB9E5}")) ICcObjectContainer : public IDispatch
+#if CORECON_VER==11
+struct __declspec(uuid("{1C0048A9-A73F-41B3-BD75-467D615CB9E5}")) ICcObjectContainer_11 : public IDispatch
+#elif CORECON_VER==12
+struct __declspec(uuid("{ADEFAC99-D191-46A1-B42F-58B22755C293}")) ICcObjectContainer_12 : public IDispatch
+#endif
{
- virtual HRESULT __stdcall FindObject(BSTR nameOrId, ICcObject **object) = 0;
- virtual HRESULT __stdcall EnumerateObjects(ICcCollection **collection) = 0;
- virtual HRESULT __stdcall AddObject(BSTR name, BSTR id, ICcObject **object) = 0;
+#if CORECON_VER==11
+ virtual HRESULT __stdcall FindObject(BSTR nameOrId, ICcObject_11 **object) = 0;
+ virtual HRESULT __stdcall EnumerateObjects(ICcCollection_11 **collection) = 0;
+ virtual HRESULT __stdcall AddObject(BSTR name, BSTR id, ICcObject_11 **object) = 0;
+#elif CORECON_VER==12
+ virtual HRESULT __stdcall FindObject(BSTR nameOrId, ICcObject_12 **object) = 0;
+ virtual HRESULT __stdcall EnumerateObjects(ICcCollection_12 **collection) = 0;
+ virtual HRESULT __stdcall AddObject(BSTR name, BSTR id, ICcObject_12 **object) = 0;
+#endif
virtual HRESULT __stdcall DeleteObject(BSTR nameOrId) = 0;
};
-struct __declspec(uuid("{2E12E75A-1625-44B6-B527-7A1E7ED61577}")) ICcPlatform : public IDispatch
+#if CORECON_VER==11
+struct __declspec(uuid("{2E12E75A-1625-44B6-B527-7A1E7ED61577}")) ICcPlatform_11 : public IDispatch
+#elif CORECON_VER==12
+struct __declspec(uuid("{9124335F-7D55-443D-A86C-4DBC245A1051}")) ICcPlatform_12 : public IDispatch
+#endif
{
- virtual HRESULT __stdcall get_ProjectContainer(ICcProjectContainer **container) = 0;
- virtual HRESULT __stdcall get_DeviceContainer(ICcDeviceContainer **container) = 0;
- virtual HRESULT __stdcall get_FormFactorContainer(ICcFormFactorContainer **container) = 0;
- virtual HRESULT __stdcall get_TypeToArchitectureMap(ICcTypeToArchitectureMap **map) = 0;
+#if CORECON_VER==11
+ virtual HRESULT __stdcall get_ProjectContainer(ICcProjectContainer_11 **container) = 0;
+ virtual HRESULT __stdcall get_DeviceContainer(ICcDeviceContainer_11 **container) = 0;
+ virtual HRESULT __stdcall get_FormFactorContainer(ICcFormFactorContainer_11 **container) = 0;
+ virtual HRESULT __stdcall get_TypeToArchitectureMap(ICcTypeToArchitectureMap_11 **map) = 0;
+#elif CORECON_VER==12
+ virtual HRESULT __stdcall get_ProjectContainer(ICcProjectContainer_12 **container) = 0;
+ virtual HRESULT __stdcall get_DeviceContainer(ICcDeviceContainer_12 **container) = 0;
+ virtual HRESULT __stdcall get_FormFactorContainer(ICcFormFactorContainer_12 **container) = 0;
+ virtual HRESULT __stdcall get_TypeToArchitectureMap(ICcTypeToArchitectureMap_12 **map) = 0;
+#endif
};
-struct __declspec(uuid("{C434B7DA-ABAA-428A-944A-3AF1A7419A92}")) ICcPlatformContainer : public IDispatch
+#if CORECON_VER==11
+struct __declspec(uuid("{C434B7DA-ABAA-428A-944A-3AF1A7419A92}")) ICcPlatformContainer_11 : public IDispatch
+#elif CORECON_VER==12
+struct __declspec(uuid("{2D405E9C-BBA4-406B-9E9F-A4E41CAC520C}")) ICcPlatformContainer_12 : public IDispatch
+#endif
{
};
-struct __declspec(uuid("{A918FF41-F287-488D-BE16-99DBF54E331D}")) ICcProperty : public IDispatch
+#if CORECON_VER==11
+struct __declspec(uuid("{A918FF41-F287-488D-BE16-99DBF54E331D}")) ICcProperty_11 : public IDispatch
+#elif CORECON_VER==12
+struct __declspec(uuid("{750F503B-6686-4715-81EB-9E23EA0FC424}")) ICcProperty_12 : public IDispatch
+#endif
{
virtual HRESULT __stdcall get_Value(BSTR *val) = 0;
virtual HRESULT __stdcall set_Value(BSTR val) = 0;
virtual HRESULT __stdcall AddPropertyContainer() = 0;
};
-struct __declspec(uuid("{9636B4A4-633C-4542-A809-9E96ABF01FA5}")) ICcPropertyContainer : public IDispatch
+#if CORECON_VER==11
+struct __declspec(uuid("{9636B4A4-633C-4542-A809-9E96ABF01FA5}")) ICcPropertyContainer_11 : public IDispatch
+#elif CORECON_VER==12
+struct __declspec(uuid("{E92A5704-87B2-4059-81A2-C5C54424CF38}")) ICcPropertyContainer_12 : public IDispatch
+#endif
{
};
-struct __declspec(uuid("{F19FF2DB-0A4E-4148-ABE3-47EE7E31194F}")) ICcServer : public IDispatch
+#if CORECON_VER==11
+struct __declspec(uuid("{F19FF2DB-0A4E-4148-ABE3-47EE7E31194F}")) ICcServer_11 : public IDispatch
+#elif CORECON_VER==12
+struct __declspec(uuid("{D0D076C5-5C71-4947-A056-94E8E760DFFE}")) ICcServer_12 : public IDispatch
+#endif
{
virtual HRESULT __stdcall get_Locale(DWORD *locale) = 0;
virtual HRESULT __stdcall put_Locale(DWORD *locale) = 0;
- virtual HRESULT __stdcall GetDatastore(DWORD locale, ICcDatastore **datastore) = 0;
- virtual HRESULT __stdcall GetConnection(ICcDevice *device, DWORD timeout, ICcServiceCB *callback, BSTR *connectionId, ICcConnection **connection) = 0;
+#if CORECON_VER==11
+ virtual HRESULT __stdcall GetDatastore(DWORD locale, ICcDatastore_11 **datastore) = 0;
+ virtual HRESULT __stdcall GetConnection(ICcDevice_11 *device, DWORD timeout, ICcServiceCB_11 *callback, BSTR *connectionId, ICcConnection_11 **connection) = 0;
virtual HRESULT __stdcall EnumerateConnections(DWORD sizeActual, DWORD *sizeReturned, BSTR *connections, VARIANT_BOOL *moreEntries) = 0;
- virtual HRESULT __stdcall GetConnectionFromId(BSTR connectionId, ICcConnection **connection) = 0;
+ virtual HRESULT __stdcall GetConnectionFromId(BSTR connectionId, ICcConnection_11 **connection) = 0;
+#elif CORECON_VER==12
+ virtual HRESULT __stdcall GetDatastore(DWORD locale, ICcDatastore_12 **datastore) = 0;
+ virtual HRESULT __stdcall GetConnection(ICcDevice_12 *device, DWORD timeout, ICcServiceCB_12 *callback, BSTR *connectionId, ICcConnection_12 **connection) = 0;
+ virtual HRESULT __stdcall EnumerateConnections(DWORD sizeActual, DWORD *sizeReturned, BSTR *connections, VARIANT_BOOL *moreEntries) = 0;
+ virtual HRESULT __stdcall GetConnectionFromId(BSTR connectionId, ICcConnection_12 **connection) = 0;
+#endif
};
#endif
diff --git a/src/shared/corecon/ccapi_11.h b/src/shared/corecon/ccapi_11.h
new file mode 100644
index 000000000..c9c2cadf8
--- /dev/null
+++ b/src/shared/corecon/ccapi_11.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CCAPI_11_H
+#define CCAPI_11_H
+
+#define CORECON_VER 11
+#include "ccapi.h"
+
+#define CLSID_ConMan CLSID_ConMan_11;
+typedef ICcCollection_11 ICcCollection;
+typedef ICcConnection_11 ICcConnection;
+typedef ICcConnection3_11 ICcConnection3;
+typedef ICcConnection4_11 ICcConnection4;
+typedef ICcDatastore_11 ICcDatastore;
+typedef ICcDevice_11 ICcDevice;
+typedef ICcDeviceContainer_11 ICcDeviceContainer;
+typedef ICcObject_11 ICcObject;
+typedef ICcObjectContainer_11 ICcObjectContainer;
+typedef ICcPlatform_11 ICcPlatform;
+typedef ICcPlatformContainer_11 ICcPlatformContainer;
+typedef ICcProperty_11 ICcProperty;
+typedef ICcPropertyContainer_11 ICcPropertyContainer;
+typedef ICcServer_11 ICcServer;
+
+#endif // CCAPI_11_H
diff --git a/src/shared/corecon/ccapi_12.h b/src/shared/corecon/ccapi_12.h
new file mode 100644
index 000000000..d0917bf6f
--- /dev/null
+++ b/src/shared/corecon/ccapi_12.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CCAPI_12_H
+#define CCAPI_12_H
+
+#define CORECON_VER 12
+#include "ccapi.h"
+
+#define CLSID_ConMan CLSID_ConMan_12;
+typedef ICcCollection_12 ICcCollection;
+typedef ICcConnection_12 ICcConnection;
+typedef ICcConnection3_12 ICcConnection3;
+typedef ICcConnection4_12 ICcConnection4;
+typedef ICcDatastore_12 ICcDatastore;
+typedef ICcDevice_12 ICcDevice;
+typedef ICcDeviceContainer_12 ICcDeviceContainer;
+typedef ICcObject_12 ICcObject;
+typedef ICcObjectContainer_12 ICcObjectContainer;
+typedef ICcPlatform_12 ICcPlatform;
+typedef ICcPlatformContainer_12 ICcPlatformContainer;
+typedef ICcProperty_12 ICcProperty;
+typedef ICcPropertyContainer_12 ICcPropertyContainer;
+typedef ICcServer_12 ICcServer;
+
+#endif // CCAPI_12_H
diff --git a/src/shared/corecon/corecon.cpp b/src/shared/corecon/corecon.cpp
index 683e219b5..7220ac393 100644
--- a/src/shared/corecon/corecon.cpp
+++ b/src/shared/corecon/corecon.cpp
@@ -38,9 +38,27 @@
**
****************************************************************************/
-#include "ccapi.h"
#include "corecon.h"
+// Force all versions of CoreCon in scope
+#ifdef CCAPI_VERSIONED_H
+#undef CCAPI_VERSIONED_H
+#endif
+#ifdef CORECON_VER
+#undef CORECON_VER
+#endif
+#define CORECON_VER 11
+#include "ccapi.h"
+
+#ifdef CCAPI_VERSIONED_H
+#undef CCAPI_VERSIONED_H
+#endif
+#ifdef CORECON_VER
+#undef CORECON_VER
+#endif
+#define CORECON_VER 12
+#include "ccapi.h"
+
#include <QtCore/QString>
#include <QtCore/QMutex>
#include <QtCore/QMutexLocker>
@@ -55,10 +73,10 @@ Q_LOGGING_CATEGORY(lcCoreCon, "qt.corecon")
#define wchar(str) reinterpret_cast<LPCWSTR>(str.utf16())
-template <typename T>
-static inline HRESULT collectionFor(const ComPtr<T> &container, ComPtr<ICcCollection> &collection)
+template <typename ObjectContainerType, typename ContainerType, typename CollectionType>
+static inline HRESULT collectionFor(const ComPtr<ContainerType> &container, ComPtr<CollectionType> &collection)
{
- ComPtr<ICcObjectContainer> objectContainer;
+ ComPtr<ObjectContainerType> objectContainer;
HRESULT hr = container.As(&objectContainer);
if (FAILED(hr))
return hr;
@@ -72,12 +90,28 @@ public:
QString name;
QString id;
bool isEmulator;
- ComPtr<ICcDevice> handle;
+ int version;
+
+protected:
+ CoreConDevicePrivate(int version) : version(version) { }
+};
+
+template <typename DeviceType>
+class CoreConDevicePrivateVersioned : public CoreConDevicePrivate
+{
+public:
+ CoreConDevicePrivateVersioned(int version) : CoreConDevicePrivate(version) { }
+ ComPtr<DeviceType> handle;
};
-CoreConDevice::CoreConDevice()
- : d_ptr(new CoreConDevicePrivate)
+CoreConDevice::CoreConDevice(int version)
{
+ if (version == 11)
+ d_ptr.reset(new CoreConDevicePrivateVersioned<ICcDevice_11>(version));
+ else if (version == 12)
+ d_ptr.reset(new CoreConDevicePrivateVersioned<ICcDevice_12>(version));
+ else
+ qCCritical(lcCoreCon) << "Invalid CoreCon version specified:" << version;
}
CoreConDevice::~CoreConDevice()
@@ -102,10 +136,14 @@ bool CoreConDevice::isEmulator() const
return d->isEmulator;
}
-ICcDevice *CoreConDevice::handle() const
+Qt::HANDLE CoreConDevice::handle() const
{
Q_D(const CoreConDevice);
- return d->handle.Get();
+ if (d->version == 11)
+ return static_cast<const CoreConDevicePrivateVersioned<ICcDevice_11> *>(d)->handle.Get();
+ if (d->version == 12)
+ return static_cast<const CoreConDevicePrivateVersioned<ICcDevice_12> *>(d)->handle.Get();
+ return 0;
}
class ComInitializer
@@ -128,14 +166,8 @@ protected:
class CoreConServerPrivate : private ComInitializer
{
public:
- CoreConServerPrivate(CoreConServer *server) : langModule(0)
+ CoreConServerPrivate(int version) : version(version), langModule(0)
{
- HRESULT hr = CoCreateInstance(CLSID_ConMan, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&handle));
- if (FAILED(hr))
- qCWarning(lcCoreCon) << "Failed to initialize connection server." << server->formatError(hr);
-
- // The language module is available as long as the above succeeded
- langModule = GetModuleHandle(L"conmanui");
}
~CoreConServerPrivate()
{
@@ -143,208 +175,268 @@ public:
devices.clear();
}
- ComPtr<ICcServer> handle;
+ virtual bool initialize() = 0;
+
+ int version;
QList<CoreConDevice *> devices;
HMODULE langModule;
-};
-
-CoreConServer::CoreConServer()
- : d_ptr(new CoreConServerPrivate(this))
-{
- initialize();
-}
-
-CoreConServer::~CoreConServer()
-{
-}
-
-ICcServer *CoreConServer::handle() const
-{
- Q_D(const CoreConServer);
- return d->handle.Get();
-}
-QList<CoreConDevice *> CoreConServer::devices() const
-{
- Q_D(const CoreConServer);
- return d->devices;
-}
-
-bool CoreConServer::initialize()
-{
- Q_D(CoreConServer);
- if (!d || !d->handle)
- return false;
-
- if (!d->devices.isEmpty())
- return true;
-
- ComPtr<ICcDatastore> dataStore;
- HRESULT hr = d->handle->GetDatastore(GetUserDefaultLCID(), &dataStore);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the data store. HRESULT: 0x%x", hr);
- return false;
+ template <typename T>
+ static CoreConDevicePrivateVersioned<T> *deviceHandle(CoreConDevice *device)
+ {
+ return static_cast<CoreConDevicePrivateVersioned<T> *>(device->d_ptr.data());
}
+};
- ComPtr<ICcPlatformContainer> platformContainer;
- hr = dataStore->get_PlatformContainer(&platformContainer);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the platform container. HRESULT: 0x%x", hr);
- return false;
- }
+template <typename ServerType, typename DataStoreType, typename PlatformType,
+ typename PlatformContainerType, typename CollectionType, typename DeviceType, typename DeviceContainerType,
+ typename ObjectType, typename ObjectContainerType, typename PropertyType, typename PropertyContainerType>
+class CoreConServerPrivateVersioned : public CoreConServerPrivate
+{
+public:
+ CoreConServerPrivateVersioned(CoreConServer *server, int version)
+ : CoreConServerPrivate(version)
+ {
+ HRESULT hr = E_FAIL;
+ if (version == 11)
+ hr = CoCreateInstance(CLSID_ConMan_11, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&handle));
+ else if (version == 12)
+ hr = CoCreateInstance(CLSID_ConMan_12, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&handle));
+ else
+ qCCritical(lcCoreCon) << "Invalid CoreCon version specified:" << version;
- ComPtr<ICcCollection> platformCollection;
- hr = collectionFor(platformContainer, platformCollection);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the platform collection. HRESULT: 0x%x", hr);
- return false;
- }
+ if (FAILED(hr))
+ qCWarning(lcCoreCon) << "Failed to initialize connection server." << server->formatError(hr);
- long platformCount;
- hr = platformCollection->get_Count(&platformCount);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the platform object count. HRESULT: 0x%x", hr);
- return false;
+ // The language module is available as long as the above succeeded
+ langModule = GetModuleHandle(L"conmanui");
}
- for (long platformIndex = 0; platformIndex < platformCount; ++platformIndex) {
- ComPtr<ICcObject> platformObject;
- hr = platformCollection->get_Item(platformIndex, &platformObject);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "\1: %d", platformIndex);
- continue;
- }
- ComPtr<ICcPlatform> platform;
- hr = platformObject.As(&platform);
+ bool initialize()
+ {
+ ComPtr<DataStoreType> dataStore;
+ HRESULT hr = handle->GetDatastore(GetUserDefaultLCID(), &dataStore);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "\1: %d", platformIndex);
- continue;
+ qCDebug(lcCoreCon, "Failed to obtain the data store. HRESULT: 0x%x", hr);
+ return false;
}
- ComPtr<ICcDeviceContainer> deviceContainer;
- hr = platform->get_DeviceContainer(&deviceContainer);
+ ComPtr<PlatformContainerType> platformContainer;
+ hr = dataStore->get_PlatformContainer(&platformContainer);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the device container.. 0x%x", hr);
- continue;
+ qCDebug(lcCoreCon, "Failed to obtain the platform container. HRESULT: 0x%x", hr);
+ return false;
}
- ComPtr<ICcCollection> deviceCollection;
- hr = collectionFor(deviceContainer, deviceCollection);
+ ComPtr<CollectionType> platformCollection;
+ hr = collectionFor<ObjectContainerType>(platformContainer, platformCollection);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the device object collection.. 0x%x", hr);
- continue;
+ qCDebug(lcCoreCon, "Failed to obtain the platform collection. HRESULT: 0x%x", hr);
+ return false;
}
- long deviceCount;
- hr = deviceCollection->get_Count(&deviceCount);
+ long platformCount;
+ hr = platformCollection->get_Count(&platformCount);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the device object count.. 0x%x", hr);
- continue;
+ qCDebug(lcCoreCon, "Failed to obtain the platform object count. HRESULT: 0x%x", hr);
+ return false;
}
- for (long deviceIndex = 0; deviceIndex < deviceCount; ++deviceIndex) {
- QScopedPointer<CoreConDevice> device(new CoreConDevice);
-
- ComPtr<ICcObject> deviceObject;
- hr = deviceCollection->get_Item(deviceIndex, &deviceObject);
+ for (long platformIndex = 0; platformIndex < platformCount; ++platformIndex) {
+ ComPtr<ObjectType> platformObject;
+ hr = platformCollection->get_Item(platformIndex, &platformObject);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain the device object at index: %d", deviceIndex);
+ qCDebug(lcCoreCon, "\1: %d", platformIndex);
continue;
}
- hr = deviceObject.As(&device->d_ptr->handle);
+ ComPtr<PlatformType> platform;
+ hr = platformObject.As(&platform);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to confirm a device from the object at index: %d", deviceIndex);
+ qCDebug(lcCoreCon, "\1: %d", platformIndex);
continue;
}
- _bstr_t deviceId;
- hr = deviceObject->get_ID(deviceId.GetAddress());
+ ComPtr<DeviceContainerType> deviceContainer;
+ hr = platform->get_DeviceContainer(&deviceContainer);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain device id at index: %d", deviceIndex);
+ qCDebug(lcCoreCon, "Failed to obtain the device container.. 0x%x", hr);
continue;
}
- device->d_ptr->id = QString::fromWCharArray(deviceId);
- _bstr_t deviceName;
- hr = deviceObject->get_Name(deviceName.GetAddress());
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain device name at index: %d", deviceIndex);
- continue;
- }
- device->d_ptr->name = QString::fromWCharArray(deviceName);
- ComPtr<ICcPropertyContainer> propertyContainer;
- hr = deviceObject->get_PropertyContainer(&propertyContainer);
+ ComPtr<CollectionType> deviceCollection;
+ hr = collectionFor<ObjectContainerType>(deviceContainer, deviceCollection);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain a property container at index: %d", deviceIndex);
+ qCDebug(lcCoreCon, "Failed to obtain the device object collection.. 0x%x", hr);
continue;
}
- ComPtr<ICcCollection> propertyCollection;
- hr = collectionFor(propertyContainer, propertyCollection);
+ long deviceCount;
+ hr = deviceCollection->get_Count(&deviceCount);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain property collection of device at index: %d", deviceIndex);
+ qCDebug(lcCoreCon, "Failed to obtain the device object count.. 0x%x", hr);
continue;
}
+ for (long deviceIndex = 0; deviceIndex < deviceCount; ++deviceIndex) {
+ QScopedPointer<CoreConDevice> device(new CoreConDevice(version));
- bool isPseudoDevice = false;
- long propertyCount;
- hr = propertyCollection->get_Count(&propertyCount);
- if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain property count of device at index: %d", deviceIndex);
- continue;
- }
+ ComPtr<ObjectType> deviceObject;
+ hr = deviceCollection->get_Item(deviceIndex, &deviceObject);
+ if (FAILED(hr)) {
+ qCDebug(lcCoreCon, "Failed to obtain the device object at index: %d", deviceIndex);
+ continue;
+ }
+
+ hr = deviceObject.As(&deviceHandle<DeviceType>(device.data())->handle);
+ if (FAILED(hr)) {
+ qCDebug(lcCoreCon, "Failed to confirm a device from the object at index: %d", deviceIndex);
+ continue;
+ }
+
+ _bstr_t deviceId;
+ hr = deviceObject->get_ID(deviceId.GetAddress());
+ if (FAILED(hr)) {
+ qCDebug(lcCoreCon, "Failed to obtain device id at index: %d", deviceIndex);
+ continue;
+ }
+ deviceHandle<DeviceType>(device.data())->id = QString::fromWCharArray(deviceId);
+ _bstr_t deviceName;
+ hr = deviceObject->get_Name(deviceName.GetAddress());
+ if (FAILED(hr)) {
+ qCDebug(lcCoreCon, "Failed to obtain device name at index: %d", deviceIndex);
+ continue;
+ }
+ deviceHandle<DeviceType>(device.data())->name = QString::fromWCharArray(deviceName);
- for (long propertyIndex = 0; propertyIndex < propertyCount; ++propertyIndex) {
- ComPtr<ICcObject> propertyObject;
- hr = propertyCollection->get_Item(propertyIndex, &propertyObject);
+ ComPtr<PropertyContainerType> propertyContainer;
+ hr = deviceObject->get_PropertyContainer(&propertyContainer);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain property at index: %d", propertyIndex);
+ qCDebug(lcCoreCon, "Failed to obtain a property container at index: %d", deviceIndex);
continue;
}
- _bstr_t id;
- hr = propertyObject->get_ID(id.GetAddress());
+ ComPtr<CollectionType> propertyCollection;
+ hr = collectionFor<ObjectContainerType>(propertyContainer, propertyCollection);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to obtain property id at index: %d", propertyIndex);
+ qCDebug(lcCoreCon, "Failed to obtain property collection of device at index: %d", deviceIndex);
continue;
}
- ComPtr<ICcProperty> property;
- hr = propertyObject.As(&property);
+ bool isPseudoDevice = false;
+ long propertyCount;
+ hr = propertyCollection->get_Count(&propertyCount);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to cast the property object at index: %d", propertyIndex);
+ qCDebug(lcCoreCon, "Failed to obtain property count of device at index: %d", deviceIndex);
continue;
}
- if (id == _bstr_t(L"IsPseudoDevice")) {
- _bstr_t value;
- hr = property->get_Value(value.GetAddress());
+ for (long propertyIndex = 0; propertyIndex < propertyCount; ++propertyIndex) {
+ ComPtr<ObjectType> propertyObject;
+ hr = propertyCollection->get_Item(propertyIndex, &propertyObject);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to cast the property value at index: %d", propertyIndex);
+ qCDebug(lcCoreCon, "Failed to obtain property at index: %d", propertyIndex);
continue;
}
- if (value == _bstr_t(L"true")) {
- isPseudoDevice = true;
- break; // No need to look at this device further
+
+ _bstr_t id;
+ hr = propertyObject->get_ID(id.GetAddress());
+ if (FAILED(hr)) {
+ qCDebug(lcCoreCon, "Failed to obtain property id at index: %d", propertyIndex);
+ continue;
}
- }
- if (id == _bstr_t(L"Emulator")) {
- _bstr_t value;
- hr = property->get_Value(value.GetAddress());
+ ComPtr<PropertyType> property;
+ hr = propertyObject.As(&property);
if (FAILED(hr)) {
- qCDebug(lcCoreCon, "Failed to cast the property value at index: %d", propertyIndex);
+ qCDebug(lcCoreCon, "Failed to cast the property object at index: %d", propertyIndex);
continue;
}
- device->d_ptr->isEmulator = value == _bstr_t(L"true");
+
+ if (id == _bstr_t(L"IsPseudoDevice")) {
+ _bstr_t value;
+ hr = property->get_Value(value.GetAddress());
+ if (FAILED(hr)) {
+ qCDebug(lcCoreCon, "Failed to cast the property value at index: %d", propertyIndex);
+ continue;
+ }
+ if (value == _bstr_t(L"true")) {
+ isPseudoDevice = true;
+ break; // No need to look at this device further
+ }
+ }
+
+ if (id == _bstr_t(L"Emulator")) {
+ _bstr_t value;
+ hr = property->get_Value(value.GetAddress());
+ if (FAILED(hr)) {
+ qCDebug(lcCoreCon, "Failed to cast the property value at index: %d", propertyIndex);
+ continue;
+ }
+ deviceHandle<DeviceType>(device.data())->isEmulator = value == _bstr_t(L"true");
+ }
}
- }
- if (!isPseudoDevice)
- d->devices.append(device.take());
+ if (!isPseudoDevice)
+ devices.append(device.take());
+ }
}
+ return true;
}
- return true;
+
+ ComPtr<ServerType> handle;
+};
+
+typedef CoreConServerPrivateVersioned<ICcServer_11, ICcDatastore_11, ICcPlatform_11,
+ ICcPlatformContainer_11, ICcCollection_11, ICcDevice_11, ICcDeviceContainer_11,
+ ICcObject_11, ICcObjectContainer_11,
+ ICcProperty_11, ICcPropertyContainer_11> CoreConServerPrivate_11;
+
+typedef CoreConServerPrivateVersioned<ICcServer_12, ICcDatastore_12, ICcPlatform_12,
+ ICcPlatformContainer_12, ICcCollection_12, ICcDevice_12, ICcDeviceContainer_12,
+ ICcObject_12, ICcObjectContainer_12,
+ ICcProperty_12, ICcPropertyContainer_12> CoreConServerPrivate_12;
+
+CoreConServer::CoreConServer(int version)
+{
+ if (version == 11)
+ d_ptr.reset(new CoreConServerPrivate_11(this, version));
+ else if (version == 12)
+ d_ptr.reset(new CoreConServerPrivate_12(this, version));
+ else
+ qCCritical(lcCoreCon) << "Invalid CoreCon version specified:" << version;
+
+ initialize();
+}
+
+CoreConServer::~CoreConServer()
+{
+}
+
+Qt::HANDLE CoreConServer::handle() const
+{
+ Q_D(const CoreConServer);
+ if (d->version == 11)
+ return static_cast<const CoreConServerPrivate_11 *>(d)->handle.Get();
+ if (d->version == 12)
+ return static_cast<const CoreConServerPrivate_12 *>(d)->handle.Get();
+ return 0;
+}
+
+QList<CoreConDevice *> CoreConServer::devices() const
+{
+ Q_D(const CoreConServer);
+ return d->devices;
+}
+
+bool CoreConServer::initialize()
+{
+ Q_D(CoreConServer);
+ if (!d || !handle())
+ return false;
+
+ if (!d->devices.isEmpty())
+ return true;
+
+ return d->initialize();
}
QString CoreConServer::formatError(HRESULT hr) const
diff --git a/src/shared/corecon/corecon.h b/src/shared/corecon/corecon.h
index a769977be..690b5c56a 100644
--- a/src/shared/corecon/corecon.h
+++ b/src/shared/corecon/corecon.h
@@ -46,35 +46,32 @@
#include <QtCore/QScopedPointer>
#include <QtCore/QLoggingCategory>
-struct ICcDevice;
-struct ICcServer;
-
QT_USE_NAMESPACE
class CoreConDevicePrivate;
class CoreConDevice
{
public:
- explicit CoreConDevice();
+ explicit CoreConDevice(int version);
~CoreConDevice();
QString name() const;
QString id() const;
bool isEmulator() const;
- ICcDevice *handle() const;
+ Qt::HANDLE handle() const;
private:
QScopedPointer<CoreConDevicePrivate> d_ptr;
Q_DECLARE_PRIVATE(CoreConDevice)
-friend class CoreConServer;
+friend class CoreConServerPrivate;
};
class CoreConServerPrivate;
class CoreConServer
{
public:
- CoreConServer();
+ explicit CoreConServer(int version);
~CoreConServer();
bool initialize();
- ICcServer *handle() const;
+ Qt::HANDLE handle() const;
QList<CoreConDevice *> devices() const;
QString formatError(HRESULT hr) const;
private:
diff --git a/src/shared/corecon/corecon.pri b/src/shared/corecon/corecon.pri
index 58ba4e1d5..4d4abfd45 100644
--- a/src/shared/corecon/corecon.pri
+++ b/src/shared/corecon/corecon.pri
@@ -1,5 +1,5 @@
win32-msvc2012|win32-msvc2013 {
INCLUDEPATH += $$PWD
- HEADERS += $$PWD/ccapi.h $$PWD/corecon.h
+ HEADERS += $$PWD/ccapi.h $$PWD/ccapi_11.h $$PWD/ccapi_12.h $$PWD/corecon.h
SOURCES += $$PWD/corecon.cpp
}
diff --git a/src/winrtrunner/xapengine.cpp b/src/winrtrunner/xapengine.cpp
index 9ea018faa..19651cd26 100644
--- a/src/winrtrunner/xapengine.cpp
+++ b/src/winrtrunner/xapengine.cpp
@@ -59,9 +59,9 @@ using namespace Microsoft::WRL;
QT_USE_NAMESPACE
-#include <ccapi.h>
+#include <ccapi_11.h>
#include <corecon.h>
-Q_GLOBAL_STATIC(CoreConServer, coreConServer)
+Q_GLOBAL_STATIC_WITH_ARGS(CoreConServer, coreConServer, (11))
#define wchar(str) reinterpret_cast<LPCWSTR>(str.utf16())
@@ -250,8 +250,8 @@ bool XapEngine::connect()
HRESULT hr;
if (!d->connection) {
_bstr_t connectionName;
- hr = coreConServer->handle()->GetConnection(
- d->device->handle(), 5000, NULL, connectionName.GetAddress(), &d->connection);
+ hr = static_cast<ICcServer *>(coreConServer->handle())->GetConnection(
+ static_cast<ICcDevice *>(d->device->handle()), 5000, NULL, connectionName.GetAddress(), &d->connection);
if (FAILED(hr)) {
qCWarning(lcWinRtRunner) << "Unable to connect to device." << coreConServer->formatError(hr);
return false;