mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 03:10:12 +02:00
ugly hacks to make liblastfm compile on windows
This commit is contained in:
3
thirdparty/liblastfm2/src/CMakeLists.txt
vendored
3
thirdparty/liblastfm2/src/CMakeLists.txt
vendored
@@ -78,7 +78,7 @@ if(UNIX)
|
||||
endif(APPLE)
|
||||
endif(UNIX)
|
||||
if(WIN32)
|
||||
set(SOURCES ${SOURCES} ws/win/WNetworkConnectionMonitor_win.cpp)
|
||||
set(SOURCES ${SOURCES} ws/win/WNetworkConnectionMonitor_win.cpp ws/win/Pac.cpp ws/win/NdisEvents.cpp )
|
||||
set(MOC_HEADERS ${MOC_HEADERS} ws/win/WNetworkConnectionMonitor.h)
|
||||
endif(WIN32)
|
||||
|
||||
@@ -100,6 +100,7 @@ ENDIF()
|
||||
target_link_libraries(tomahawk_lastfm2
|
||||
${QT_LIBRARIES}
|
||||
${QT_QTDBUS_LIBRARY}
|
||||
|
||||
)
|
||||
|
||||
set_target_properties(tomahawk_lastfm2 PROPERTIES COMPILE_FLAGS "-DLASTFM_OHAI_QMAKE" )
|
||||
|
@@ -50,7 +50,7 @@ static struct NetworkAccessManagerInit
|
||||
// at two seconds, so that hangs startup
|
||||
if (!s.fAutoDetect && s.lpszProxy)
|
||||
{
|
||||
QUrl url( QString::fromUtf16(s.lpszProxy) );
|
||||
QUrl url( QString::fromUtf16((const unsigned short*)s.lpszProxy) );
|
||||
QNetworkProxy proxy( QNetworkProxy::HttpProxy );
|
||||
proxy.setHostName( url.host() );
|
||||
proxy.setPort( url.port() );
|
||||
|
17
thirdparty/liblastfm2/src/ws/win/ComSetup.h
vendored
17
thirdparty/liblastfm2/src/ws/win/ComSetup.h
vendored
@@ -23,9 +23,10 @@
|
||||
#endif
|
||||
|
||||
#include <objbase.h>
|
||||
#include <atlbase.h>
|
||||
#include <atlcom.h>
|
||||
|
||||
//#include <boost/range/atl.hpp>
|
||||
//#include <atlbase.h>
|
||||
//#include <atlcom.h>
|
||||
#include <winable.h>
|
||||
|
||||
/** @brief WsConnectionMonitor needs Com to work as early as possible so we do this
|
||||
* @author <doug@last.fm>
|
||||
@@ -37,7 +38,7 @@ public:
|
||||
{
|
||||
HRESULT hr = CoInitialize(0);
|
||||
m_bComInitialised = SUCCEEDED(hr);
|
||||
_ASSERT(m_bComInitialised);
|
||||
//_ASSERT(m_bComInitialised);
|
||||
if (m_bComInitialised) {
|
||||
setupSecurity();
|
||||
}
|
||||
@@ -45,10 +46,10 @@ public:
|
||||
|
||||
void setupSecurity()
|
||||
{
|
||||
CSecurityDescriptor sd;
|
||||
sd.InitializeFromThreadToken();
|
||||
HRESULT hr = CoInitializeSecurity(sd, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
|
||||
_ASSERT(SUCCEEDED(hr));
|
||||
//CSecurityDescriptor sd;
|
||||
//sd.InitializeFromThreadToken();
|
||||
//HRESULT hr = CoInitializeSecurity(sd, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
|
||||
//_ASSERT(SUCCEEDED(hr));
|
||||
}
|
||||
|
||||
~ComSetup()
|
||||
|
@@ -26,6 +26,7 @@
|
||||
*/
|
||||
struct IeSettings : WINHTTP_CURRENT_USER_IE_PROXY_CONFIG
|
||||
{
|
||||
#ifndef WIN32
|
||||
IeSettings()
|
||||
{
|
||||
if (!WinHttpGetIEProxyConfigForCurrentUser(this)) {
|
||||
@@ -33,6 +34,7 @@ struct IeSettings : WINHTTP_CURRENT_USER_IE_PROXY_CONFIG
|
||||
lpszAutoConfigUrl = lpszProxy = lpszProxyBypass = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
~IeSettings()
|
||||
{
|
||||
|
20
thirdparty/liblastfm2/src/ws/win/NdisEvents.cpp
vendored
20
thirdparty/liblastfm2/src/ws/win/NdisEvents.cpp
vendored
@@ -32,22 +32,24 @@ NdisEvents::NdisEvents()
|
||||
|
||||
NdisEvents::~NdisEvents()
|
||||
{
|
||||
#ifndef WIN32
|
||||
if (m_pSink)
|
||||
m_pSink->disconnect();
|
||||
if (m_pServices && m_pSink)
|
||||
m_pServices->CancelAsyncCall(m_pSink);
|
||||
#endif
|
||||
//if (m_pServices && m_pSink)
|
||||
//m_pServices->CancelAsyncCall(m_pSink);
|
||||
// and reference counting will take care of the WmiSink object
|
||||
}
|
||||
|
||||
HRESULT
|
||||
NdisEvents::registerForNdisEvents()
|
||||
{
|
||||
HRESULT hr = m_pLocator.CoCreateInstance(CLSID_WbemLocator);
|
||||
HRESULT hr = 0; //m_pLocator.CoCreateInstance(CLSID_WbemLocator);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
// Connect to the root\wmi namespace with the current user.
|
||||
hr = m_pLocator->ConnectServer(CComBSTR("ROOT\\WMI"), // strNetworkResource
|
||||
hr = 0; /*m_pLocator->ConnectServer(CComBSTR("ROOT\\WMI"), // strNetworkResource
|
||||
NULL, // strUser
|
||||
NULL, // strPassword
|
||||
NULL, // strLocale
|
||||
@@ -55,12 +57,12 @@ NdisEvents::registerForNdisEvents()
|
||||
CComBSTR(""), // strAuthority
|
||||
NULL, // pCtx
|
||||
&m_pServices
|
||||
);
|
||||
);*/
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
#ifndef WIN32
|
||||
m_pSink = new WmiSink(this);
|
||||
|
||||
#endif
|
||||
//////////////////////////
|
||||
|
||||
// other notifications we're not interested in right now include...
|
||||
@@ -75,12 +77,12 @@ NdisEvents::registerForNdisEvents()
|
||||
// MSNdis_StatusProtocolUnbind
|
||||
// MSNdis_StatusMediaSpecificIndication
|
||||
|
||||
CComBSTR wql("WQL");
|
||||
/*CComBSTR wql("WQL");
|
||||
CComBSTR query("SELECT * FROM MSNdis_StatusMediaDisconnect");
|
||||
hr = m_pServices->ExecNotificationQueryAsync(wql, query, 0, 0, m_pSink);
|
||||
|
||||
query = "SELECT * FROM MSNdis_StatusMediaConnect";
|
||||
hr = m_pServices->ExecNotificationQueryAsync(wql, query, 0, 0, m_pSink);
|
||||
hr = m_pServices->ExecNotificationQueryAsync(wql, query, 0, 0, m_pSink);*/
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
@@ -21,8 +21,8 @@
|
||||
#define NDIS_EVENTS_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <atlbase.h>
|
||||
#include <WbemCli.h>
|
||||
//#include <atlbase.h>
|
||||
//#include <WbemCli.h>
|
||||
|
||||
class NdisEvents
|
||||
{
|
||||
@@ -35,8 +35,8 @@ public:
|
||||
virtual void onConnectionDown(BSTR name) = 0;
|
||||
|
||||
private:
|
||||
CComPtr<IWbemLocator> m_pLocator;
|
||||
CComPtr<IWbemServices> m_pServices;
|
||||
//CComPtr<IWbemLocator> m_pLocator;
|
||||
//CComPtr<IWbemServices> m_pServices;
|
||||
class WmiSink *m_pSink;
|
||||
};
|
||||
|
||||
|
30
thirdparty/liblastfm2/src/ws/win/Pac.cpp
vendored
30
thirdparty/liblastfm2/src/ws/win/Pac.cpp
vendored
@@ -21,8 +21,9 @@
|
||||
#include <QNetworkRequest>
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
#include <atlbase.h>
|
||||
#include <atlconv.h>
|
||||
//#include <atlbase.h>
|
||||
//#include <atlconv.h>
|
||||
#include <winhttp.h>
|
||||
|
||||
|
||||
static bool
|
||||
@@ -73,8 +74,10 @@ lastfm::Pac::Pac()
|
||||
|
||||
lastfm::Pac::~Pac()
|
||||
{
|
||||
#ifndef WIN32
|
||||
if (m_hSession)
|
||||
WinHttpCloseHandle(m_hSession);
|
||||
#endif
|
||||
}
|
||||
|
||||
QNetworkProxy
|
||||
@@ -86,7 +89,7 @@ lastfm::Pac::resolve(const QNetworkRequest &request, const wchar_t* pacUrl)
|
||||
if (!m_hSession)
|
||||
{
|
||||
QByteArray user_agent = request.rawHeader("user-agent");
|
||||
m_hSession = WinHttpOpen(CA2W(user_agent), WINHTTP_ACCESS_TYPE_NO_PROXY, 0, 0, WINHTTP_FLAG_ASYNC);
|
||||
//m_hSession = WinHttpOpen(CA2W(user_agent), WINHTTP_ACCESS_TYPE_NO_PROXY, 0, 0, WINHTTP_FLAG_ASYNC);
|
||||
}
|
||||
if (m_hSession)
|
||||
{
|
||||
@@ -95,33 +98,36 @@ lastfm::Pac::resolve(const QNetworkRequest &request, const wchar_t* pacUrl)
|
||||
memset(&opts, 0, sizeof(opts));
|
||||
if (pacUrl)
|
||||
{
|
||||
opts.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
|
||||
opts.lpszAutoConfigUrl = pacUrl;
|
||||
//opts.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
|
||||
//opts.lpszAutoConfigUrl = pacUrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
opts.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
|
||||
opts.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DHCP | WINHTTP_AUTO_DETECT_TYPE_DNS_A;
|
||||
//opts.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
|
||||
//opts.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DHCP | WINHTTP_AUTO_DETECT_TYPE_DNS_A;
|
||||
}
|
||||
opts.fAutoLogonIfChallenged = TRUE;
|
||||
|
||||
if (WinHttpGetProxyForUrl(m_hSession, request.url().toString().utf16(), &opts, &info)) {
|
||||
#ifndef WIN32
|
||||
if (WinHttpGetProxyForUrl(m_hSession, (const WCHAR*)(request.url().toString().utf16()), &opts, &info)) {
|
||||
if (info.lpszProxy)
|
||||
{
|
||||
QList<QNetworkProxy> proxies = parsePacResult(QString::fromUtf16(info.lpszProxy));
|
||||
QList<QNetworkProxy> proxies = parsePacResult(QString::fromUtf16((const ushort*)info.lpszProxy));
|
||||
if (!proxies.empty())
|
||||
{
|
||||
out = proxies.at(0);
|
||||
}
|
||||
GlobalFree(info.lpszProxy);
|
||||
// pay attention! casting away constness
|
||||
GlobalFree((void*)info.lpszProxy);
|
||||
}
|
||||
if (info.lpszProxyBypass)
|
||||
{
|
||||
GlobalFree(info.lpszProxyBypass);
|
||||
// pay attention! casting away constness
|
||||
GlobalFree((void*)info.lpszProxyBypass);
|
||||
}
|
||||
} else {
|
||||
m_bFailed = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return out;
|
||||
|
2
thirdparty/liblastfm2/src/ws/win/WmiSink.h
vendored
2
thirdparty/liblastfm2/src/ws/win/WmiSink.h
vendored
@@ -20,7 +20,7 @@
|
||||
#ifndef WMISINK_WIN_H
|
||||
#define WMISINK_WIN_H
|
||||
|
||||
#include "WbemCli.h"
|
||||
#include "wbemcli.h"
|
||||
|
||||
// Sink object for WMI NDIS notifications
|
||||
class WmiSink : public IWbemObjectSink
|
||||
|
Reference in New Issue
Block a user