Merge remote branch 'origin/mingw-w64'

This commit is contained in:
John Maguire 2012-11-19 18:17:19 +01:00
commit 80d35ef128
15 changed files with 126 additions and 51 deletions

View File

@ -63,7 +63,6 @@ pkg_check_modules(CHROMAPRINT libchromaprint)
if (WIN32)
find_package(ZLIB REQUIRED)
find_library(MSWMDM_LIBRARIES mswmdm)
find_library(SAC_SHIM_LIBRARIES sac_shim)
find_library(QTSPARKLE_LIBRARIES qtsparkle)
endif (WIN32)
@ -162,9 +161,6 @@ endif(NOT GETTEXT_MSGFMT_EXECUTABLE)
# Optional bits
if(WIN32)
option(ENABLE_WIN32_CONSOLE "Show the windows console even outside Debug mode" OFF)
if(SAC_SHIM_LIBRARIES)
set(HAVE_SAC ON)
endif(SAC_SHIM_LIBRARIES)
endif(WIN32)
optional_component(BREAKPAD OFF "Crash reporting")

View File

@ -103,28 +103,35 @@ Section "Delete old files" oldfiles
; 1.1
Delete "$INSTDIR\libprotobuf-lite-7.dll"
; mingw-w64
Delete "$INSTDIR\avcodec-52.dll"
Delete "$INSTDIR\avformat-52.dll"
Delete "$INSTDIR\avutil-50.dll"
Delete "$INSTDIR\libcdio-12.dll"
Delete "$INSTDIR\libgcc_s_dw2-1.dll"
SectionEnd
Section "Clementine" Clementine
SetOutPath "$INSTDIR"
File "avcodec-52.dll"
File "avformat-52.dll"
File "avutil-50.dll"
File "avcodec-53.dll"
File "avformat-53.dll"
File "avutil-51.dll"
File "clementine.exe"
File "clementine-tagreader.exe"
File "clementine-spotifyblob.exe"
File "clementine.ico"
File "glew32.dll"
File "intl.dll"
File "libcdio-12.dll"
File "libcdio-14.dll"
File "libeay32.dll"
File "libexpat-1.dll"
File "libfaac.dll"
File "libfaad.dll"
File "libfftw3-3.dll"
File "libFLAC.dll"
File "libgcc_s_dw2-1.dll"
File "libgcc_s_sjlj-1.dll"
File "libgcrypt-11.dll"
File "libgdk_pixbuf-2.0-0.dll"
File "libgio-2.0-0.dll"
@ -168,6 +175,7 @@ Section "Clementine" Clementine
File "libsoup-2.4-1.dll"
File "libspeex-1.dll"
File "libspotify.dll"
File "libstdc++-6.dll"
File "libtag.dll"
File "libtasn1-3.dll"
File "libusbmuxd.dll"

View File

@ -3,6 +3,8 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11")
set(SOURCES
core/closure.cpp
core/encoding.cpp

View File

@ -1,6 +1,6 @@
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wall -Wno-sign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wall -Wno-sign-compare --std=c++11 -U__STRICT_ANSI__")
option(BUILD_WERROR "Build with -Werror" ON)
@ -990,7 +990,7 @@ optional_source(HAVE_LIBMTP
)
# Windows media lister
optional_source(HAVE_SAC
optional_source(WIN32
SOURCES
devices/wmdmdevice.cpp
devices/wmdmlister.cpp
@ -1199,11 +1199,6 @@ if (WIN32)
${QTSPARKLE_LIBRARIES}
qtwin
)
if (HAVE_SAC)
target_link_libraries(clementine_lib
${SAC_SHIM_LIBRARIES}
)
endif (HAVE_SAC)
endif (WIN32)
if (UNIX AND NOT APPLE)

View File

@ -16,13 +16,15 @@
***************************************************************************/
#include "analyzerbase.h"
#include "engines/enginebase.h"
#include <cmath> //interpolate()
#include <QEvent> //event()
#include <QPainter>
#include <QPaintEvent>
#include <QtDebug>
#include "engines/enginebase.h"
// INSTRUCTIONS Base2D
// 1. do anything that depends on height() in init(), Base2D will call it before you are shown

View File

@ -35,7 +35,6 @@
#cmakedefine HAVE_LIBMTP
#cmakedefine HAVE_MOODBAR
#cmakedefine HAVE_QCA
#cmakedefine HAVE_SAC
#cmakedefine HAVE_SPARKLE
#cmakedefine HAVE_SPOTIFY
#cmakedefine HAVE_SPOTIFY_DOWNLOADER

View File

@ -46,9 +46,7 @@
#include <id3v1genres.h>
#ifdef Q_OS_WIN32
# ifdef HAVE_SAC
# include <mswmdm.h>
# endif
# include <mswmdm.h>
# include <QUuid>
#endif // Q_OS_WIN32
@ -703,7 +701,7 @@ void Song::InitFromLastFM(const lastfm::Track& track) {
}
#endif
#if defined(Q_OS_WIN32) && defined(HAVE_SAC)
#if defined(Q_OS_WIN32)
static void AddWmdmItem(IWMDMMetaData* metadata, const wchar_t* name,
const QVariant& value) {
switch (value.type()) {

View File

@ -39,7 +39,7 @@ class QUrl;
struct LIBMTP_track_struct;
#endif
#if defined(Q_OS_WIN32) && defined(HAVE_SAC)
#if defined(Q_OS_WIN32)
struct IWMDMMetaData;
#endif
@ -120,7 +120,7 @@ class Song {
void ToMTP(LIBMTP_track_struct* track) const;
#endif
#if defined(Q_OS_WIN32) && defined(HAVE_SAC)
#if defined(Q_OS_WIN32)
void InitFromWmdm(IWMDMMetaData* metadata);
void ToWmdm(IWMDMMetaData* metadata) const;
#endif

View File

@ -39,10 +39,8 @@
# include "macdevicelister.h"
#endif
#ifdef Q_OS_WIN32
# ifdef HAVE_SAC
# include "wmdmlister.h"
# include "wmdmdevice.h"
# endif
# include "wmdmlister.h"
# include "wmdmdevice.h"
#endif
#ifdef HAVE_LIBGPOD
# include "gpoddevice.h"
@ -206,7 +204,7 @@ DeviceManager::DeviceManager(Application* app, QObject *parent)
#ifdef Q_OS_DARWIN
AddLister(new MacDeviceLister);
#endif
#if defined(Q_OS_WIN32) && defined(HAVE_SAC)
#if defined(Q_OS_WIN32)
AddLister(new WmdmLister);
AddDeviceClass<WmdmDevice>();
#endif

View File

@ -143,14 +143,6 @@ void WmdmLister::ShutDown() {
metaObject()->invokeMethod(this, "ReallyShutdown", Qt::BlockingQueuedConnection);
}
template <typename F>
qint64 GetSpaceValue(F f) {
DWORD low, high;
f(&low, &high);
return (qint64)high << 32 | (qint64)low;
}
WmdmLister::DeviceInfo WmdmLister::ReadDeviceInfo(IWMDMDevice2* device) {
qLog(Debug) << "Reading device info";
@ -424,13 +416,28 @@ void WmdmLister::DoUpdateDriveFreeSpace(const QString& id) {
emit DeviceChanged(id);
}
namespace {
qint64 GetSpaceValue(
IWMDMStorageGlobals* globals,
LONG (IWMDMStorageGlobals::*f)(DWORD*,DWORD*)) {
DWORD low, high;
((globals)->*(f))(&low, &high);
return (qint64)high << 32 | (qint64)low;
}
}
void WmdmLister::UpdateFreeSpace(DeviceInfo* info) {
IWMDMStorageGlobals* globals;
info->storage_->GetStorageGlobals(&globals);
info->total_bytes_ = GetSpaceValue(boost::bind(&IWMDMStorageGlobals::GetTotalSize, globals, _1, _2));
info->free_bytes_ = GetSpaceValue(boost::bind(&IWMDMStorageGlobals::GetTotalFree, globals, _1, _2));
info->free_bytes_ -= GetSpaceValue(boost::bind(&IWMDMStorageGlobals::GetTotalBad, globals, _1, _2));
DWORD low, high;
globals->GetTotalSize(&low, &high);
info->total_bytes_ = (qint64)high << 32 | (qint64)low;
globals->GetTotalFree(&low, &high);
info->free_bytes_ = (qint64)high << 32 | (qint64)low;
globals->Release();
}

View File

@ -21,18 +21,32 @@
#include <mswmdm.h>
#include <QtDebug>
#include <boost/scoped_array.hpp>
#include <QCoreApplication>
#include <QLibrary>
#include <QMutexLocker>
#include <QtDebug>
BYTE abPVK[] = {0x00};
BYTE abCert[] = {0x00};
bool WmdmThread::sIsLoaded = false;
decltype(&CSecureChannelClient_New) WmdmThread::_CSecureChannelClient_New;
decltype(&CSecureChannelClient_Free) WmdmThread::_CSecureChannelClient_Free;
decltype(&CSecureChannelClient_SetCertificate) WmdmThread::_CSecureChannelClient_SetCertificate;
decltype(&CSecureChannelClient_SetInterface) WmdmThread::_CSecureChannelClient_SetInterface;
decltype(&CSecureChannelClient_Authenticate) WmdmThread::_CSecureChannelClient_Authenticate;
WmdmThread::WmdmThread()
: device_manager_(NULL),
sac_(NULL)
{
if (!sIsLoaded) {
return;
}
// Initialise COM
CoInitialize(0);
@ -44,15 +58,15 @@ WmdmThread::WmdmThread()
return;
}
sac_ = CSecureChannelClient_New();
if (CSecureChannelClient_SetCertificate(
sac_ = _CSecureChannelClient_New();
if (_CSecureChannelClient_SetCertificate(
sac_, SAC_CERT_V1, abCert, sizeof(abCert), abPVK, sizeof(abPVK))) {
qLog(Warning) << "Error setting SAC certificate";
return;
}
CSecureChannelClient_SetInterface(sac_, auth);
if (CSecureChannelClient_Authenticate(sac_, SAC_PROTOCOL_V1)) {
_CSecureChannelClient_SetInterface(sac_, auth);
if (_CSecureChannelClient_Authenticate(sac_, SAC_PROTOCOL_V1)) {
qLog(Warning) << "Error authenticating with SAC";
return;
}
@ -72,13 +86,48 @@ WmdmThread::~WmdmThread() {
if (sac_) {
// SAC
CSecureChannelClient_Free(sac_);
_CSecureChannelClient_Free(sac_);
}
// Uninitialise COM
CoUninitialize();
}
namespace {
template <typename T>
T Resolve(QLibrary* library, const char* name) {
return reinterpret_cast<T>(library->resolve(name));
}
} // namespace
bool WmdmThread::StaticInit() {
if (!sIsLoaded) {
QLibrary library(QCoreApplication::applicationDirPath() + "/sac_shim.dll");
if (!library.load()) {
return false;
}
_CSecureChannelClient_New = Resolve<decltype(_CSecureChannelClient_New)>(
&library, "CSecureChannelClient_New");
_CSecureChannelClient_Free = Resolve<decltype(_CSecureChannelClient_Free)>(
&library, "CSecureChannelClient_Free");
_CSecureChannelClient_SetCertificate = Resolve<decltype(_CSecureChannelClient_SetCertificate)>(
&library, "CSecureChannelClient_SetCertificate");
_CSecureChannelClient_SetInterface = Resolve<decltype(_CSecureChannelClient_SetInterface)>(
&library, "CSecureChannelClient_SetInterface");
if (_CSecureChannelClient_New &&
_CSecureChannelClient_Free &&
_CSecureChannelClient_SetCertificate &&
_CSecureChannelClient_SetInterface) {
sIsLoaded = true;
return true;
}
}
return false;
}
IWMDMDevice* WmdmThread::GetDeviceByCanonicalName(const QString& device_name) {
ScopedWCharArray name(device_name);

View File

@ -18,6 +18,7 @@
#ifndef WMDMTHREAD_H
#define WMDMTHREAD_H
#include <QMutex>
#include <QtGlobal>
#include <sac_shim.h>
@ -36,11 +37,21 @@ public:
IWMDMDevice* GetDeviceByCanonicalName(const QString& device_name);
IWMDMStorage* GetRootStorage(const QString& device_name);
static bool StaticInit();
private:
Q_DISABLE_COPY(WmdmThread);
IWMDeviceManager2* device_manager_;
SacHandle sac_;
static decltype(&CSecureChannelClient_New) _CSecureChannelClient_New;
static decltype(&CSecureChannelClient_Free) _CSecureChannelClient_Free;
static decltype(&CSecureChannelClient_SetCertificate) _CSecureChannelClient_SetCertificate;
static decltype(&CSecureChannelClient_SetInterface) _CSecureChannelClient_SetInterface;
static decltype(&CSecureChannelClient_Authenticate) _CSecureChannelClient_Authenticate;
static bool sIsLoaded;
};
#endif // WMDMTHREAD_H

View File

@ -22,14 +22,17 @@
#ifndef AMAROK_ENGINEBASE_H
#define AMAROK_ENGINEBASE_H
#include <QUrl>
#include <QObject>
#include <QList>
#include <cstdint>
#include <sys/types.h>
#include <vector>
#include <boost/noncopyable.hpp>
#include <QList>
#include <QObject>
#include <QUrl>
#include "engine_fwd.h"
namespace Engine {

View File

@ -102,6 +102,7 @@ using boost::scoped_ptr;
#ifdef Q_OS_WIN32
# include <qtsparkle/Updater>
# include "devices/wmdmthread.h"
#endif
// Load sqlite plugin on windows and mac.
@ -441,6 +442,10 @@ int main(int argc, char *argv[]) {
mpris::Mpris mpris(&app);
#endif
if (!WmdmThread::StaticInit()) {
qLog(Warning) << "Failed to initialise SAC shim";
}
// Window
MainWindow w(&app, tray_icon.get(), &osd);
#ifdef Q_OS_DARWIN

View File

@ -96,6 +96,8 @@ void Windows7ThumbBar::HandleWinEvent(MSG* msg) {
taskbar_list_ = NULL;
}
// Copied from win7 SDK shobjidl.h
static const GUID CLSID_ITaskbarList ={ 0x56FDF344,0xFD6D,0x11d0,{0x95,0x8A,0x00,0x60,0x97,0xC9,0xA0,0x90}};
// Create the taskbar list
hr = CoCreateInstance(CLSID_ITaskbarList, NULL, CLSCTX_ALL,
IID_ITaskbarList3, (void**) &taskbar_list_);