diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a0e11984..8e7200410 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,9 +47,8 @@ pkg_check_modules(LIBMTP libmtp) if (WIN32) find_package(ZLIB REQUIRED) - find_library(PORTABLEDEVICEAPI_LIBRARIES PortableDeviceApi) - find_library(PORTABLEDEVICEGUIDS_LIBRARIES PortableDeviceGuids) - find_library(PORTABLEDEVICETYPES_LIBRARIES PortableDeviceTypes) + find_library(MSWMDM_LIBRARIES MSWMDM) + find_library(SAC_SHIM_LIBRARIES sac_shim) endif (WIN32) find_library(LASTFM_LIBRARIES lastfm) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 71af59c6d..bd9068923 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -534,10 +534,10 @@ if(LIBMTP_FOUND) list(APPEND HEADERS devices/mtploader.h) endif(LIBMTP_FOUND) -# Windows portable device lister +# Windows media lister IF(WIN32) - list(APPEND SOURCES devices/wpdlister.cpp) - list(APPEND HEADERS devices/wpdlister.h) + list(APPEND SOURCES devices/wmdmlister.cpp) + list(APPEND HEADERS devices/wmdmlister.h) ENDIF(WIN32) # Mac specific startup stuff @@ -573,8 +573,8 @@ list(APPEND OTHER_SOURCES devices/mtpdevice.h devices/mtploader.cpp devices/mtploader.h - devices/wpdlister.cpp - devices/wpdlister.h + devices/wmdmlister.cpp + devices/wmdmlister.h ui/macsystemtrayicon.h ui/macsystemtrayicon.mm widgets/osd_mac.mm @@ -672,10 +672,11 @@ if(HAVE_STATIC_SQLITE) endif(HAVE_STATIC_SQLITE) if (WIN32) - target_link_libraries(clementine_lib ${ZLIB_LIBRARIES}) - target_link_libraries(clementine_lib ${PORTABLEDEVICEAPI_LIBRARIES}) - target_link_libraries(clementine_lib ${PORTABLEDEVICEGUIDS_LIBRARIES}) - target_link_libraries(clementine_lib ${PORTABLEDEVICETYPES_LIBRARIES}) + target_link_libraries(clementine_lib + ${ZLIB_LIBRARIES} + ${MSWMDM_LIBRARIES} + ${SAC_SHIM_LIBRARIES} + ) endif (WIN32) add_dependencies(clementine_lib qtsingleapplication) diff --git a/src/devices/devicemanager.cpp b/src/devices/devicemanager.cpp index aea9643e8..d5888ff94 100644 --- a/src/devices/devicemanager.cpp +++ b/src/devices/devicemanager.cpp @@ -29,7 +29,7 @@ # include "macdevicelister.h" #endif #ifdef Q_OS_WIN32 -# include "wpdlister.h" +# include "wmdmlister.h" #endif #ifdef HAVE_LIBGPOD # include "gpoddevice.h" @@ -170,7 +170,7 @@ DeviceManager::DeviceManager(BackgroundThread* database, AddLister(new MacDeviceLister); #endif #ifdef Q_OS_WIN32 - AddLister(new WpdLister); + AddLister(new WmdmLister); #endif #ifdef HAVE_IMOBILEDEVICE AddLister(new iLister); diff --git a/src/devices/wmdmlister.cpp b/src/devices/wmdmlister.cpp new file mode 100644 index 000000000..f623b67df --- /dev/null +++ b/src/devices/wmdmlister.cpp @@ -0,0 +1,115 @@ +/* This file is part of Clementine. + + Clementine is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Clementine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Clementine. If not, see . +*/ + +#include "wmdmlister.h" + +#include +#include +#include +#include +#include + +#include +#include + +BYTE abPVK[] = {0x00}; +BYTE abCert[] = {0x00}; + +WmdmLister::WmdmLister() +{ +} + +void WmdmLister::Init() { + qDebug() << "Creating IPortableDeviceManager"; + + qDebug() << "CoInitialize says" << CoInitialize(0); + + IComponentAuthenticate* auth; + HRESULT result = CoCreateInstance( + CLSID_MediaDevMgr, NULL, CLSCTX_ALL, IID_IComponentAuthenticate, (void **)&auth); + qDebug() << "Auth" << result << auth; + + SacHandle sac = CSecureChannelClient_New(); + qDebug() << "SAC is" << sac; + + result = CSecureChannelClient_SetCertificate(sac, + SAC_CERT_V1, + abCert, sizeof(abCert), + abPVK, sizeof(abPVK)); + qDebug() << "SetCertificate" << result << abCert << sizeof(abCert); + + CSecureChannelClient_SetInterface(sac, auth); + + DWORD* prot; + DWORD prot_count; + result = auth->SACGetProtocols(&prot, &prot_count); + qDebug() << "SACGetProtocols" << result << prot_count; + qDebug() << "Prot is" << prot; + qDebug() << "Prot is" << prot[0]; + + result = CSecureChannelClient_Authenticate(sac, prot[0]); + qDebug() << "Authenticate" << result; + + CoTaskMemFree(prot); + + IWMDeviceManager* device_manager; + result = auth->QueryInterface(IID_IWMDeviceManager, (void**)device_manager); + qDebug() << "Manager" << result << device_manager; + + CoUninitialize(); +} + +QStringList WmdmLister::DeviceUniqueIDs() { + return QStringList(); +} + +QStringList WmdmLister::DeviceIcons(const QString& id) { + return QStringList(); +} + +QString WmdmLister::DeviceManufacturer(const QString& id) { + return QString(); +} + +QString WmdmLister::DeviceModel(const QString& id) { + return QString(); +} + +quint64 WmdmLister::DeviceCapacity(const QString& id) { + return 0; +} + +quint64 WmdmLister::DeviceFreeSpace(const QString& id) { + return 0; +} + +QVariantMap WmdmLister::DeviceHardwareInfo(const QString& id) { + return QVariantMap(); +} + +QString WmdmLister::MakeFriendlyName(const QString& id) { + return QString(); +} + +QList WmdmLister::MakeDeviceUrls(const QString& id) { + return QList(); +} + +void WmdmLister::UnmountDevice(const QString& id) { +} + +void WmdmLister::UpdateDeviceFreeSpace(const QString& id) { +} diff --git a/src/devices/wpdlister.h b/src/devices/wmdmlister.h similarity index 88% rename from src/devices/wpdlister.h rename to src/devices/wmdmlister.h index 533e26823..f5b678a25 100644 --- a/src/devices/wpdlister.h +++ b/src/devices/wmdmlister.h @@ -14,16 +14,19 @@ along with Clementine. If not, see . */ -#ifndef WPDLISTER_H -#define WPDLISTER_H +#ifndef WMDMLISTER_H +#define WMDMLISTER_H #include "devicelister.h" -class WpdLister : public DeviceLister { +class WmdmLister : public DeviceLister { Q_OBJECT public: - WpdLister(); + WmdmLister(); + + static uchar* kDRMCert; + static uchar* kDRMPrivateKey; virtual void Init(); @@ -40,7 +43,6 @@ public: public slots: virtual void UpdateDeviceFreeSpace(const QString& id); - }; -#endif // WPDLISTER_H +#endif // WMDMLISTER_H diff --git a/src/devices/wpdlister.cpp b/src/devices/wpdlister.cpp deleted file mode 100644 index e26ddcf24..000000000 --- a/src/devices/wpdlister.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* This file is part of Clementine. - - Clementine is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Clementine is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Clementine. If not, see . -*/ - -#include "wpdlister.h" - -// Vista, for the property system -#define WINVER 0x0501 - -#include - -// I have no idea where these are meant to be defined... -typedef struct _tagpropertykey { - GUID fmtid; - DWORD pid; -} PROPERTYKEY; -typedef const PROPERTYKEY& REFPROPERTYKEY; - -#include - -#include -#include - -WpdLister::WpdLister() { -} - -void WpdLister::Init() { - qDebug() << "Creating IPortableDeviceManager"; - - qDebug() << "CoInitialize says" << CoInitialize(0); - - IPortableDeviceManager* manager = NULL; - HRESULT ret = CoCreateInstance( - CLSID_PortableDeviceManager, NULL, CLSCTX_INPROC_SERVER, - IID_IPortableDeviceManager, (void**)&manager); - qDebug() << "Created" << ret << manager; - - CoUninitialize(); -} - -QStringList WpdLister::DeviceUniqueIDs() { - return QStringList(); -} - -QStringList WpdLister::DeviceIcons(const QString& id) { - return QStringList(); -} - -QString WpdLister::DeviceManufacturer(const QString& id) { - return QString(); -} - -QString WpdLister::DeviceModel(const QString& id) { - return QString(); -} - -quint64 WpdLister::DeviceCapacity(const QString& id) { - return 0; -} - -quint64 WpdLister::DeviceFreeSpace(const QString& id) { - return 0; -} - -QVariantMap WpdLister::DeviceHardwareInfo(const QString& id) { - return QVariantMap(); -} - -QString WpdLister::MakeFriendlyName(const QString& id) { - return QString(); -} - -QList WpdLister::MakeDeviceUrls(const QString& id) { - return QList(); -} - -void WpdLister::UnmountDevice(const QString& id) { -} - -void WpdLister::UpdateDeviceFreeSpace(const QString& id) { -}