Update optional components to qt5

This commit is contained in:
Chocobozzz 2015-04-15 18:26:09 +02:00
parent 8b226c2171
commit 42aafd247a
31 changed files with 298 additions and 259 deletions

View File

@ -87,9 +87,9 @@ if (WIN32)
find_library(QTSPARKLE_LIBRARIES qtsparkle) find_library(QTSPARKLE_LIBRARIES qtsparkle)
endif (WIN32) endif (WIN32)
find_library(LASTFM_LIBRARIES lastfm) find_library(LASTFM5_LIBRARIES lastfm5)
find_path(LASTFM_INCLUDE_DIRS lastfm/ws.h) find_path(LASTFM5_INCLUDE_DIRS lastfm5/ws.h)
find_path(LASTFM1_INCLUDE_DIRS lastfm/Track.h) find_path(LASTFM51_INCLUDE_DIRS lastfm5/Track.h)
find_path(SPARSEHASH_INCLUDE_DIRS google/sparsetable) find_path(SPARSEHASH_INCLUDE_DIRS google/sparsetable)
@ -115,7 +115,7 @@ else()
set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
endif() endif()
if(LASTFM_INCLUDE_DIRS AND LASTFM1_INCLUDE_DIRS) if(LASTFM5_INCLUDE_DIRS AND LASTFM51_INCLUDE_DIRS)
set(HAVE_LIBLASTFM1 ON) set(HAVE_LIBLASTFM1 ON)
endif() endif()
@ -192,85 +192,85 @@ endif(WIN32)
optional_component(BREAKPAD OFF "Crash reporting") optional_component(BREAKPAD OFF "Crash reporting")
optional_component(GOOGLE_DRIVE OFF "Google Drive support" optional_component(GOOGLE_DRIVE ON "Google Drive support"
DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS
DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999"
) )
optional_component(DROPBOX OFF "Dropbox support" optional_component(DROPBOX ON "Dropbox support"
DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS
DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999"
) )
optional_component(SKYDRIVE OFF "Skydrive support" optional_component(SKYDRIVE ON "Skydrive support"
DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS
DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999"
) )
optional_component(BOX OFF "Box support" optional_component(BOX ON "Box support"
DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS
DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999"
) )
optional_component(VK OFF "Vk.com support") optional_component(VK ON "Vk.com support")
optional_component(SEAFILE OFF "Seafile support" optional_component(SEAFILE ON "Seafile support"
DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS
DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999" DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999"
) )
optional_component(AUDIOCD OFF "Devices: Audio CD support" optional_component(AUDIOCD ON "Devices: Audio CD support"
DEPENDS "libcdio" CDIO_FOUND DEPENDS "libcdio" CDIO_FOUND
) )
optional_component(LIBGPOD OFF "Devices: iPod classic support" optional_component(LIBGPOD ON "Devices: iPod classic support"
DEPENDS "libgpod" LIBGPOD_FOUND DEPENDS "libgpod" LIBGPOD_FOUND
) )
optional_component(GIO OFF "Devices: GIO device backend" optional_component(GIO ON "Devices: GIO device backend"
DEPENDS "libgio" GIO_FOUND DEPENDS "libgio" GIO_FOUND
DEPENDS "Linux or Windows" "NOT APPLE" DEPENDS "Linux or Windows" "NOT APPLE"
) )
optional_component(LIBMTP OFF "Devices: MTP support" optional_component(LIBMTP ON "Devices: MTP support"
DEPENDS "libmtp" LIBMTP_FOUND DEPENDS "libmtp" LIBMTP_FOUND
) )
optional_component(LIBLASTFM OFF "Last.fm support" optional_component(LIBLASTFM ON "Last.fm support"
DEPENDS "liblastfm" LASTFM_LIBRARIES LASTFM_INCLUDE_DIRS DEPENDS "liblastfm" LASTFM5_LIBRARIES LASTFM5_INCLUDE_DIRS
) )
optional_component(DBUS OFF "D-Bus support" optional_component(DBUS ON "D-Bus support"
DEPENDS "Linux" LINUX DEPENDS "Linux" LINUX
) )
optional_component(WIIMOTEDEV OFF "Wiimote support" optional_component(WIIMOTEDEV ON "Wiimote support"
DEPENDS "D-Bus support" HAVE_DBUS DEPENDS "D-Bus support" HAVE_DBUS
) )
optional_component(DEVICEKIT OFF "Devices: DeviceKit backend" optional_component(DEVICEKIT ON "Devices: DeviceKit backend"
DEPENDS "D-Bus support" HAVE_DBUS DEPENDS "D-Bus support" HAVE_DBUS
) )
optional_component(SPOTIFY_BLOB OFF "Spotify support: non-GPL binary helper" optional_component(SPOTIFY_BLOB ON "Spotify support: non-GPL binary helper"
DEPENDS "protobuf" PROTOBUF_FOUND PROTOBUF_PROTOC_EXECUTABLE DEPENDS "protobuf" PROTOBUF_FOUND PROTOBUF_PROTOC_EXECUTABLE
DEPENDS "libspotify" SPOTIFY_FOUND DEPENDS "libspotify" SPOTIFY_FOUND
) )
optional_component(MOODBAR OFF "Moodbar support" optional_component(MOODBAR ON "Moodbar support"
DEPENDS "fftw3" FFTW3_FOUND DEPENDS "fftw3" FFTW3_FOUND
) )
optional_component(SPARKLE OFF "Sparkle integration" optional_component(SPARKLE ON "Sparkle integration"
DEPENDS "Mac OS X" APPLE DEPENDS "Mac OS X" APPLE
DEPENDS "Sparkle" SPARKLE DEPENDS "Sparkle" SPARKLE
) )
optional_component(LIBPULSE OFF "Pulse audio integration" optional_component(LIBPULSE ON "Pulse audio integration"
DEPENDS "libpulse" LIBPULSE_FOUND DEPENDS "libpulse" LIBPULSE_FOUND
) )
optional_component(VISUALISATIONS OFF "Visualisations") optional_component(VISUALISATIONS ON "Visualisations")
if(NOT HAVE_SPOTIFY_BLOB AND NOT QCA_QT5_FOUND) if(NOT HAVE_SPOTIFY_BLOB AND NOT QCA_QT5_FOUND)
message(FATAL_ERROR "Either QCA-qt5 must be available or the non-GPL Spotify " message(FATAL_ERROR "Either QCA-qt5 must be available or the non-GPL Spotify "
@ -282,6 +282,7 @@ endif()
# Find DBus if it's enabled # Find DBus if it's enabled
if (HAVE_DBUS) if (HAVE_DBUS)
find_package(Qt5 COMPONENTS DBus) find_package(Qt5 COMPONENTS DBus)
get_target_property(QT_DBUSXML2CPP_EXECUTABLE Qt5::qdbusxml2cpp LOCATION)
endif () endif ()
if (HAVE_VK) if (HAVE_VK)
@ -291,7 +292,7 @@ if (HAVE_VK)
endif(HAVE_VK) endif(HAVE_VK)
# We can include the Qt definitions now # We can include the Qt definitions now
set(QT_LIBRARIES Qt5::Core Qt5::OpenGL Qt5::Sql Qt5::Network Qt5::Xml Qt5::Widgets Qt5::Concurrent Qt5::X11Extras) set(QT_LIBRARIES Qt5::Core Qt5::OpenGL Qt5::Sql Qt5::Network Qt5::Xml Qt5::Widgets Qt5::Concurrent Qt5::X11Extras Qt5::DBus)
# Remove GLU and GL from the link line - they're not really required # Remove GLU and GL from the link line - they're not really required
# and don't exist on my mingw toolchain # and don't exist on my mingw toolchain

View File

@ -44,7 +44,7 @@ find_package(OpenGL)
include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${OPENGL_INCLUDE_DIR})
if(HAVE_LIBLASTFM) if(HAVE_LIBLASTFM)
include_directories(${LASTFM_INCLUDE_DIRS}) include_directories(${LASTFM5_INCLUDE_DIRS})
endif(HAVE_LIBLASTFM) endif(HAVE_LIBLASTFM)
if(HAVE_BREAKPAD) if(HAVE_BREAKPAD)
@ -1223,9 +1223,6 @@ add_library(clementine_lib STATIC
${OTHER_UIC_SOURCES} ${OTHER_UIC_SOURCES}
) )
add_dependencies(clementine_lib pot)
target_link_libraries(clementine_lib target_link_libraries(clementine_lib
clementine-spotifyblob-messages clementine-spotifyblob-messages
libclementine-common libclementine-common
@ -1261,7 +1258,7 @@ if(ENABLE_VISUALISATIONS)
endif(ENABLE_VISUALISATIONS) endif(ENABLE_VISUALISATIONS)
if(HAVE_LIBLASTFM) if(HAVE_LIBLASTFM)
target_link_libraries(clementine_lib ${LASTFM_LIBRARIES}) target_link_libraries(clementine_lib ${LASTFM5_LIBRARIES})
endif(HAVE_LIBLASTFM) endif(HAVE_LIBLASTFM)
if(HAVE_LIBGPOD) if(HAVE_LIBGPOD)

View File

@ -51,7 +51,7 @@
<arg name="host" type="s" direction="in"/> <arg name="host" type="s" direction="in"/>
<arg name="port" type="q" direction="in"/> <arg name="port" type="q" direction="in"/>
<arg name="txt" type="aay" direction="in"/> <arg name="txt" type="aay" direction="in"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.In8" <annotation name="org.qtproject.QtDBus.QtTypeName.In8"
value="QList&lt;QByteArray&gt;" /> value="QList&lt;QByteArray&gt;" />
</method> </method>
@ -73,7 +73,7 @@
<arg name="type" type="s" direction="in"/> <arg name="type" type="s" direction="in"/>
<arg name="domain" type="s" direction="in"/> <arg name="domain" type="s" direction="in"/>
<arg name="txt" type="aay" direction="in"/> <arg name="txt" type="aay" direction="in"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.In6" <annotation name="org.qtproject.QtDBus.QtTypeName.In6"
value="QList&lt;QByteArray&gt;" /> value="QList&lt;QByteArray&gt;" />
</method> </method>

View File

@ -132,7 +132,7 @@
<arg name="address" type="s" direction="out"/> <arg name="address" type="s" direction="out"/>
<arg name="port" type="q" direction="out"/> <arg name="port" type="q" direction="out"/>
<arg name="txt" type="aay" direction="out"/> <arg name="txt" type="aay" direction="out"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out9" <annotation name="org.qtproject.QtDBus.QtTypeName.Out9"
value="QList&lt;QByteArray&gt;" /> value="QList&lt;QByteArray&gt;" />
<arg name="flags" type="u" direction="out"/> <arg name="flags" type="u" direction="out"/>
</method> </method>

View File

@ -26,7 +26,7 @@
<method name="GetStatus"> <method name="GetStatus">
<arg type="(iiii)" direction="out"/> <arg type="(iiii)" direction="out"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="DBusStatus"/> <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="DBusStatus"/>
</method> </method>
<method name="VolumeSet"> <method name="VolumeSet">
@ -47,7 +47,7 @@
<method name="GetMetadata"> <method name="GetMetadata">
<arg type="a{sv}" direction="out"/> <arg type="a{sv}" direction="out"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/> <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
</method> </method>
<method name="GetCaps"> <method name="GetCaps">
@ -56,12 +56,12 @@
<signal name="TrackChange"> <signal name="TrackChange">
<arg type="a{sv}"/> <arg type="a{sv}"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/> <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
</signal> </signal>
<signal name="StatusChange"> <signal name="StatusChange">
<arg type="(iiii)"/> <arg type="(iiii)"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="DBusStatus"/> <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="DBusStatus"/>
</signal> </signal>
<signal name="CapsChange"> <signal name="CapsChange">

View File

@ -13,7 +13,7 @@
<method name="MprisVersion"> <method name="MprisVersion">
<arg type="(qq)" direction="out"/> <arg type="(qq)" direction="out"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="Version"/> <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="Version"/>
</method> </method>
</interface> </interface>

View File

@ -7,7 +7,7 @@
<method name="GetMetadata"> <method name="GetMetadata">
<arg type="i" direction="in" /> <arg type="i" direction="in" />
<arg type="a{sv}" direction="out" /> <arg type="a{sv}" direction="out" />
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/> <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
</method> </method>
<method name="GetCurrentTrack"> <method name="GetCurrentTrack">

View File

@ -22,7 +22,7 @@
<arg name="body" type="s" direction="in"/> <arg name="body" type="s" direction="in"/>
<arg name="actions" type="as" direction="in"/> <arg name="actions" type="as" direction="in"/>
<arg name="hints" type="a{sv}" direction="in"/> <arg name="hints" type="a{sv}" direction="in"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.In6" value="QVariantMap"/> <annotation name="org.qtproject.QtDBus.QtTypeName.In6" value="QVariantMap"/>
<arg name="timeout" type="i" direction="in"/> <arg name="timeout" type="i" direction="in"/>
<arg name="return_id" type="u" direction="out"/> <arg name="return_id" type="u" direction="out"/>
</method> </method>

View File

@ -636,7 +636,7 @@
<method name="FilesystemListOpenFiles"> <method name="FilesystemListOpenFiles">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantList" /> <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantList" />
<arg name="processes" direction="out" type="a(uus)"> <arg name="processes" direction="out" type="a(uus)">
<doc:doc><doc:summary> <doc:doc><doc:summary>
An array of triples (<doc:tt>pid</doc:tt>, <doc:tt>uid</doc:tt>, command line for the process An array of triples (<doc:tt>pid</doc:tt>, <doc:tt>uid</doc:tt>, command line for the process
@ -1355,9 +1355,9 @@
<method name="DriveBenchmark"> <method name="DriveBenchmark">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantList" /> <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantList" />
<annotation name="com.trolltech.QtDBus.QtTypeName.Out1" value="QVariantList" /> <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantList" />
<annotation name="com.trolltech.QtDBus.QtTypeName.Out2" value="QVariantList" /> <annotation name="org.qtproject.QtDBus.QtTypeName.Out2" value="QVariantList" />
<arg name="do_write_benchmark" direction="in" type="b"> <arg name="do_write_benchmark" direction="in" type="b">
<doc:doc><doc:summary> <doc:doc><doc:summary>

View File

@ -1051,7 +1051,7 @@
<!-- TODO: maybe this should return a dictionary so we can grow it in the future? --> <!-- TODO: maybe this should return a dictionary so we can grow it in the future? -->
<property name="KnownFilesystems" type="a(ssbbbubbbbbbbb)" access="read"> <property name="KnownFilesystems" type="a(ssbbbubbbbbbbb)" access="read">
<annotation name="com.trolltech.QtDBus.QtTypeName" value="QVariantList"> <annotation name="org.qtproject.QtDBus.QtTypeName" value="QVariantList">
<doc:doc><doc:description><doc:para> <doc:doc><doc:description><doc:para>
An array of file systems known to the daemon and what features are supported. An array of file systems known to the daemon and what features are supported.
Each element in the array contains the following members: Each element in the array contains the following members:

View File

@ -27,7 +27,7 @@
<property name='Rate' type='d' access='readwrite'/> <property name='Rate' type='d' access='readwrite'/>
<property name='Shuffle' type='b' access='readwrite'/> <property name='Shuffle' type='b' access='readwrite'/>
<property name='Metadata' type='a{sv}' access='read'> <property name='Metadata' type='a{sv}' access='read'>
<annotation name="com.trolltech.QtDBus.QtTypeName" value="QVariantMap"/> <annotation name="org.qtproject.QtDBus.QtTypeName" value="QVariantMap"/>
</property> </property>
<property name='Volume' type='d' access='readwrite'/> <property name='Volume' type='d' access='readwrite'/>
<property name='Position' type='x' access='read'/> <property name='Position' type='x' access='read'/>

View File

@ -6,7 +6,7 @@
<property name='PlaylistCount' type='u' access='read' /> <property name='PlaylistCount' type='u' access='read' />
<property name='Orderings' type='as' access='read' /> <property name='Orderings' type='as' access='read' />
<property name='ActivePlaylist' type='(b(oss))' access='read'> <property name='ActivePlaylist' type='(b(oss))' access='read'>
<annotation name="com.trolltech.QtDBus.QtTypeName" value="MaybePlaylist"/> <annotation name="org.qtproject.QtDBus.QtTypeName" value="MaybePlaylist"/>
</property> </property>
<method name='ActivatePlaylist'> <method name='ActivatePlaylist'>
<arg direction='in' name='PlaylistId' type='o' /> <arg direction='in' name='PlaylistId' type='o' />
@ -17,12 +17,12 @@
<arg direction='in' name='Order' type='s' /> <arg direction='in' name='Order' type='s' />
<arg direction='in' name='ReverseOrder' type='b' /> <arg direction='in' name='ReverseOrder' type='b' />
<arg direction='out' name='Playlists' type='a(oss)' /> <arg direction='out' name='Playlists' type='a(oss)' />
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MprisPlaylistList"/> <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="MprisPlaylistList"/>
</method> </method>
<signal name='PlaylistChanged'> <signal name='PlaylistChanged'>
<arg name='Playlist' type='(oss)' /> <arg name='Playlist' type='(oss)' />
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="MprisPlaylist" /> <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="MprisPlaylist" />
</signal> </signal>
<annotation name="com.trolltech.QtDBus.QtTypeName" value="MaybePlaylist" /> <annotation name="org.qtproject.QtDBus.QtTypeName" value="MaybePlaylist" />
</interface> </interface>
</node> </node>

View File

@ -6,7 +6,7 @@
<method name='GetTracksMetadata'> <method name='GetTracksMetadata'>
<arg direction='in' name='TrackIds' type='ao'/> <arg direction='in' name='TrackIds' type='ao'/>
<arg direction='out' name='Metadata' type='aa{sv}'/> <arg direction='out' name='Metadata' type='aa{sv}'/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="TrackMetadata" /> <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="TrackMetadata" />
</method> </method>
<method name='AddTrack'> <method name='AddTrack'>
<arg direction='in' name='Uri' type='s'/> <arg direction='in' name='Uri' type='s'/>
@ -26,7 +26,7 @@
<signal name='TrackAdded'> <signal name='TrackAdded'>
<arg name='Metadata' type='a{sv}'/> <arg name='Metadata' type='a{sv}'/>
<arg name='AfterTrack' type='o'/> <arg name='AfterTrack' type='o'/>
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="TrackMetadata"/> <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="TrackMetadata"/>
</signal> </signal>
<signal name='TrackRemoved'> <signal name='TrackRemoved'>
<arg name='TrackId' type='o'/> <arg name='TrackId' type='o'/>
@ -34,7 +34,7 @@
<signal name='TrackMetadataChanged'> <signal name='TrackMetadataChanged'>
<arg name='TrackId' type='o'/> <arg name='TrackId' type='o'/>
<arg name='Metadata' type='a{sv}'/> <arg name='Metadata' type='a{sv}'/>
<annotation name="com.trolltech.QtDBus.QtTypeName.In1" value="TrackMetadata"/> <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="TrackMetadata"/>
</signal> </signal>
<property name='Tracks' type='ao' access='read'/> <property name='Tracks' type='ao' access='read'/>
<property name='CanEditTracks' type='b' access='read'/> <property name='CanEditTracks' type='b' access='read'/>

View File

@ -20,6 +20,7 @@
#include <QRegExp> #include <QRegExp>
#include <QtDebug> #include <QtDebug>
#include <QUrlQuery>
MtpConnection::MtpConnection(const QUrl& url) : device_(nullptr) { MtpConnection::MtpConnection(const QUrl& url) : device_(nullptr) {
QString hostname = url.host(); QString hostname = url.host();
@ -34,19 +35,20 @@ MtpConnection::MtpConnection(const QUrl& url) : device_(nullptr) {
const unsigned int bus_location = host_re.cap(1).toInt(); const unsigned int bus_location = host_re.cap(1).toInt();
const unsigned int device_num = host_re.cap(2).toInt(); const unsigned int device_num = host_re.cap(2).toInt();
if (url.hasQueryItem("vendor")) { QUrlQuery url_query(url);
if (url_query.hasQueryItem("vendor")) {
LIBMTP_raw_device_t* raw_device = LIBMTP_raw_device_t* raw_device =
(LIBMTP_raw_device_t*)malloc(sizeof(LIBMTP_raw_device_t)); (LIBMTP_raw_device_t*)malloc(sizeof(LIBMTP_raw_device_t));
raw_device->device_entry.vendor = raw_device->device_entry.vendor =
url.queryItemValue("vendor").toAscii().data(); url_query.queryItemValue("vendor").toLatin1().data();
raw_device->device_entry.product = raw_device->device_entry.product =
url.queryItemValue("product").toAscii().data(); url_query.queryItemValue("product").toLatin1().data();
raw_device->device_entry.vendor_id = raw_device->device_entry.vendor_id =
url.queryItemValue("vendor_id").toUShort(); url_query.queryItemValue("vendor_id").toUShort();
raw_device->device_entry.product_id = raw_device->device_entry.product_id =
url.queryItemValue("product_id").toUShort(); url_query.queryItemValue("product_id").toUShort();
raw_device->device_entry.device_flags = raw_device->device_entry.device_flags =
url.queryItemValue("quirks").toUInt(); url_query.queryItemValue("quirks").toUInt();
raw_device->bus_location = bus_location; raw_device->bus_location = bus_location;
raw_device->devnum = device_num; raw_device->devnum = device_num;

View File

@ -18,7 +18,10 @@
#include "boxservice.h" #include "boxservice.h"
#include <qjson/parser.h> #include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QUrlQuery>
#include "core/application.h" #include "core/application.h"
#include "core/player.h" #include "core/player.h"
@ -122,10 +125,9 @@ void BoxService::AddAuthorizationHeader(QNetworkRequest* request) const {
void BoxService::FetchUserInfoFinished(QNetworkReply* reply) { void BoxService::FetchUserInfoFinished(QNetworkReply* reply) {
reply->deleteLater(); reply->deleteLater();
QJson::Parser parser; QJsonObject json_response = QJsonDocument::fromJson(reply->readAll()).object();
QVariantMap response = parser.parse(reply).toMap();
QString name = response["name"].toString(); QString name = json_response["name"].toString();
if (!name.isEmpty()) { if (!name.isEmpty()) {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup); s.beginGroup(kSettingsGroup);
@ -160,7 +162,9 @@ void BoxService::UpdateFiles() {
void BoxService::InitialiseEventsCursor() { void BoxService::InitialiseEventsCursor() {
QUrl url(kEvents); QUrl url(kEvents);
url.addQueryItem("stream_position", "now"); QUrlQuery url_query;
url_query.addQueryItem("stream_position", "now");
url.setQuery(url_query);
QNetworkRequest request(url); QNetworkRequest request(url);
AddAuthorizationHeader(&request); AddAuthorizationHeader(&request);
QNetworkReply* reply = network_->get(request); QNetworkReply* reply = network_->get(request);
@ -170,12 +174,11 @@ void BoxService::InitialiseEventsCursor() {
void BoxService::InitialiseEventsFinished(QNetworkReply* reply) { void BoxService::InitialiseEventsFinished(QNetworkReply* reply) {
reply->deleteLater(); reply->deleteLater();
QJson::Parser parser; QJsonObject json_response = QJsonDocument::fromJson(reply->readAll()).object();
QVariantMap response = parser.parse(reply).toMap(); if (json_response.contains("next_stream_position")) {
if (response.contains("next_stream_position")) {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup); s.beginGroup(kSettingsGroup);
s.setValue("cursor", response["next_stream_position"]); s.setValue("cursor", json_response["next_stream_position"].toString());
} }
} }
@ -189,9 +192,11 @@ void BoxService::FetchRecursiveFolderItems(const int folder_id,
<< "modified_at" << "modified_at"
<< "name"; << "name";
QString fields_list = fields.join(","); QString fields_list = fields.join(",");
url.addQueryItem("fields", fields_list); QUrlQuery url_query (url);
url.addQueryItem("limit", "1000"); // Maximum according to API docs. url_query.addQueryItem("fields", fields_list);
url.addQueryItem("offset", QString::number(offset)); url_query.addQueryItem("limit", "1000"); // Maximum according to API docs.
url_query.addQueryItem("offset", QString::number(offset));
url.setQuery(url_query);
QNetworkRequest request(url); QNetworkRequest request(url);
AddAuthorizationHeader(&request); AddAuthorizationHeader(&request);
QNetworkReply* reply = network_->get(request); QNetworkReply* reply = network_->get(request);
@ -204,21 +209,18 @@ void BoxService::FetchFolderItemsFinished(QNetworkReply* reply,
const int folder_id) { const int folder_id) {
reply->deleteLater(); reply->deleteLater();
QByteArray data = reply->readAll(); QJsonObject json_response = QJsonDocument::fromJson(reply->readAll()).object();
QJson::Parser parser; QJsonArray entries = json_response["entries"].toArray();
QVariantMap response = parser.parse(data).toMap(); const int total_entries = json_response["total_count"].toInt();
const int offset = json_response["offset"].toInt();
QVariantList entries = response["entries"].toList();
const int total_entries = response["total_count"].toInt();
const int offset = response["offset"].toInt();
if (entries.size() + offset < total_entries) { if (entries.size() + offset < total_entries) {
// Fetch the next page if necessary. // Fetch the next page if necessary.
FetchRecursiveFolderItems(folder_id, offset + entries.size()); FetchRecursiveFolderItems(folder_id, offset + entries.size());
} }
for (const QVariant& e : entries) { for (const QJsonValue& e : entries) {
QVariantMap entry = e.toMap(); QJsonObject entry = e.toObject();
if (entry["type"].toString() == "folder") { if (entry["type"].toString() == "folder") {
FetchRecursiveFolderItems(entry["id"].toInt()); FetchRecursiveFolderItems(entry["id"].toInt());
} else { } else {
@ -227,16 +229,16 @@ void BoxService::FetchFolderItemsFinished(QNetworkReply* reply,
} }
} }
void BoxService::MaybeAddFileEntry(const QVariantMap& entry) { void BoxService::MaybeAddFileEntry(const QJsonObject &entry) {
QString mime_type = GuessMimeTypeForFile(entry["name"].toString()); QString mime_type = GuessMimeTypeForFile(entry["name"].toString());
QUrl url; QUrl url;
url.setScheme("box"); url.setScheme("box");
url.setPath(entry["id"].toString()); url.setPath("/" + entry["id"].toString());
Song song; Song song;
song.set_url(url); song.set_url(url);
song.set_ctime(entry["created_at"].toDateTime().toTime_t()); song.set_ctime(QDateTime::fromString(entry["created_at"].toString()).toTime_t());
song.set_mtime(entry["modified_at"].toDateTime().toTime_t()); song.set_mtime(QDateTime::fromString(entry["modified_at"].toString()).toTime_t());
song.set_filesize(entry["size"].toInt()); song.set_filesize(entry["size"].toInt());
song.set_title(entry["name"].toString()); song.set_title(entry["name"].toString());
@ -271,8 +273,10 @@ void BoxService::RedirectFollowed(QNetworkReply* reply, const Song& song,
void BoxService::UpdateFilesFromCursor(const QString& cursor) { void BoxService::UpdateFilesFromCursor(const QString& cursor) {
QUrl url(kEvents); QUrl url(kEvents);
url.addQueryItem("stream_position", cursor); QUrlQuery url_query;
url.addQueryItem("limit", "5000"); url_query.addQueryItem("stream_position", cursor);
url_query.addQueryItem("limit", "5000");
url.setQuery(url_query);
QNetworkRequest request(url); QNetworkRequest request(url);
AddAuthorizationHeader(&request); AddAuthorizationHeader(&request);
QNetworkReply* reply = network_->get(request); QNetworkReply* reply = network_->get(request);
@ -283,18 +287,17 @@ void BoxService::UpdateFilesFromCursor(const QString& cursor) {
void BoxService::FetchEventsFinished(QNetworkReply* reply) { void BoxService::FetchEventsFinished(QNetworkReply* reply) {
// TODO(John Maguire): Page through events. // TODO(John Maguire): Page through events.
reply->deleteLater(); reply->deleteLater();
QJson::Parser parser; QJsonObject json_response = QJsonDocument::fromJson(reply->readAll()).object();
QVariantMap response = parser.parse(reply).toMap();
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup); s.beginGroup(kSettingsGroup);
s.setValue("cursor", response["next_stream_position"]); s.setValue("cursor", json_response["next_stream_position"].toString());
QVariantList entries = response["entries"].toList(); QJsonArray entries = json_response["entries"].toArray();
for (const QVariant& e : entries) { for (const QJsonValue& e : entries) {
QVariantMap event = e.toMap(); QJsonObject event = e.toObject();
QString type = event["event_type"].toString(); QString type = event["event_type"].toString();
QVariantMap source = event["source"].toMap(); QJsonObject source = event["source"].toObject();
if (source["type"] == "file") { if (source["type"] == "file") {
if (type == "ITEM_UPLOAD") { if (type == "ITEM_UPLOAD") {
// Add file. // Add file.
@ -303,7 +306,7 @@ void BoxService::FetchEventsFinished(QNetworkReply* reply) {
// Delete file. // Delete file.
QUrl url; QUrl url;
url.setScheme("box"); url.setScheme("box");
url.setPath(source["id"].toString()); url.setPath("/" + source["id"].toString());
Song song = library_backend_->GetSongByUrl(url); Song song = library_backend_->GetSongByUrl(url);
if (song.is_valid()) { if (song.is_valid()) {
library_backend_->DeleteSongs(SongList() << song); library_backend_->DeleteSongs(SongList() << song);

View File

@ -64,7 +64,7 @@ class BoxService : public CloudFileService {
void UpdateFilesFromCursor(const QString& cursor); void UpdateFilesFromCursor(const QString& cursor);
QNetworkReply* FetchContentUrlForFile(const QString& file_id); QNetworkReply* FetchContentUrlForFile(const QString& file_id);
void InitialiseEventsCursor(); void InitialiseEventsCursor();
void MaybeAddFileEntry(const QVariantMap& entry); void MaybeAddFileEntry(const QJsonObject& entry);
void EnsureConnected(); void EnsureConnected();
QString access_token_; QString access_token_;

View File

@ -20,11 +20,12 @@
#include <time.h> #include <time.h>
#include <qjson/parser.h>
#include <QDesktopServices> #include <QDesktopServices>
#include <QStringList> #include <QStringList>
#include <QTcpSocket> #include <QTcpSocket>
#include <QUrlQuery>
#include <QJsonDocument>
#include <QJsonObject>
#include "core/closure.h" #include "core/closure.h"
#include "core/logging.h" #include "core/logging.h"
@ -98,8 +99,10 @@ void DropboxAuthenticator::Authorise() {
SLOT(RedirectArrived(LocalRedirectServer*)), server); SLOT(RedirectArrived(LocalRedirectServer*)), server);
QUrl url(kAuthoriseEndpoint); QUrl url(kAuthoriseEndpoint);
url.addQueryItem("oauth_token", token_); QUrlQuery url_query;
url.addQueryItem("oauth_callback", server->url().toString()); url_query.addQueryItem("oauth_token", token_);
url_query.addQueryItem("oauth_callback", server->url().toString());
url.setQuery(url_query);
QDesktopServices::openUrl(url); QDesktopServices::openUrl(url);
} }
@ -108,7 +111,7 @@ void DropboxAuthenticator::RedirectArrived(LocalRedirectServer* server) {
server->deleteLater(); server->deleteLater();
QUrl request_url = server->request_url(); QUrl request_url = server->request_url();
qLog(Debug) << Q_FUNC_INFO << request_url; qLog(Debug) << Q_FUNC_INFO << request_url;
uid_ = request_url.queryItemValue("uid"); uid_ = QUrlQuery(request_url).queryItemValue("uid");
RequestAccessToken(); RequestAccessToken();
} }
@ -126,7 +129,7 @@ void DropboxAuthenticator::RequestAccessToken() {
void DropboxAuthenticator::RequestAccessTokenFinished(QNetworkReply* reply) { void DropboxAuthenticator::RequestAccessTokenFinished(QNetworkReply* reply) {
reply->deleteLater(); reply->deleteLater();
QString result = QString::fromAscii(reply->readAll()); QString result = QString::fromLatin1(reply->readAll());
qLog(Debug) << result; qLog(Debug) << result;
QMap<QString, QString> params = ParseParamList(result); QMap<QString, QString> params = ParseParamList(result);
access_token_ = params["oauth_token"]; access_token_ = params["oauth_token"];
@ -174,8 +177,7 @@ void DropboxAuthenticator::RequestAccountInformation() {
void DropboxAuthenticator::RequestAccountInformationFinished( void DropboxAuthenticator::RequestAccountInformationFinished(
QNetworkReply* reply) { QNetworkReply* reply) {
reply->deleteLater(); reply->deleteLater();
QJson::Parser parser; QJsonDocument document = QJsonDocument::fromBinaryData(reply->readAll());
QVariantMap response = parser.parse(reply).toMap(); name_ = document.object()["display_name"].toString();
name_ = response["display_name"].toString();
emit Finished(); emit Finished();
} }

View File

@ -21,8 +21,10 @@
#include <QFileInfo> #include <QFileInfo>
#include <QTimer> #include <QTimer>
#include <QUrlQuery>
#include <qjson/parser.h> #include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include "core/application.h" #include "core/application.h"
#include "core/logging.h" #include "core/logging.h"
@ -103,9 +105,11 @@ void DropboxService::RequestFileList() {
s.beginGroup(kSettingsGroup); s.beginGroup(kSettingsGroup);
QUrl url = QUrl(QString(kDeltaEndpoint)); QUrl url = QUrl(QString(kDeltaEndpoint));
QUrlQuery url_query;
if (s.contains("cursor")) { if (s.contains("cursor")) {
url.addQueryItem("cursor", s.value("cursor").toString()); url_query.addQueryItem("cursor", s.value("cursor").toString());
} }
url.setQuery(url_query);
QNetworkRequest request(url); QNetworkRequest request(url);
request.setRawHeader("Authorization", GenerateAuthorisationHeader()); request.setRawHeader("Authorization", GenerateAuthorisationHeader());
@ -117,21 +121,22 @@ void DropboxService::RequestFileList() {
void DropboxService::RequestFileListFinished(QNetworkReply* reply) { void DropboxService::RequestFileListFinished(QNetworkReply* reply) {
reply->deleteLater(); reply->deleteLater();
QJson::Parser parser; QJsonDocument document = QJsonDocument::fromBinaryData(reply->readAll());
QVariantMap response = parser.parse(reply).toMap(); QJsonObject json_response = document.object();
if (response.contains("reset") && response["reset"].toBool()) {
if (json_response.contains("reset") && json_response["reset"].toBool()) {
qLog(Debug) << "Resetting Dropbox DB"; qLog(Debug) << "Resetting Dropbox DB";
library_backend_->DeleteAll(); library_backend_->DeleteAll();
} }
QSettings settings; QSettings settings;
settings.beginGroup(kSettingsGroup); settings.beginGroup(kSettingsGroup);
settings.setValue("cursor", response["cursor"].toString()); settings.setValue("cursor", json_response["cursor"].toString());
QVariantList contents = response["entries"].toList(); QJsonArray contents = json_response["entries"].toArray();
qLog(Debug) << "Delta found:" << contents.size(); qLog(Debug) << "Delta found:" << contents.size();
for (const QVariant& c : contents) { for (const QJsonValue& c : contents) {
QVariantList item = c.toList(); QJsonArray item = c.toArray();
QString path = item[0].toString(); QString path = item[0].toString();
QUrl url; QUrl url;
@ -148,7 +153,7 @@ void DropboxService::RequestFileListFinished(QNetworkReply* reply) {
continue; continue;
} }
QVariantMap metadata = item[1].toMap(); QJsonObject metadata = item[1].toObject();
if (metadata["is_dir"].toBool()) { if (metadata["is_dir"].toBool()) {
continue; continue;
} }
@ -168,7 +173,7 @@ void DropboxService::RequestFileListFinished(QNetworkReply* reply) {
} }
} }
if (response.contains("has_more") && response["has_more"].toBool()) { if (json_response.contains("has_more") && json_response["has_more"].toBool()) {
RequestFileList(); RequestFileList();
} else { } else {
// Long-poll wait for changes. // Long-poll wait for changes.
@ -181,9 +186,11 @@ void DropboxService::LongPollDelta() {
s.beginGroup(kSettingsGroup); s.beginGroup(kSettingsGroup);
QUrl request_url = QUrl(QString(kLongPollEndpoint)); QUrl request_url = QUrl(QString(kLongPollEndpoint));
QUrlQuery url_query;
if (s.contains("cursor")) { if (s.contains("cursor")) {
request_url.addQueryItem("cursor", s.value("cursor").toString()); url_query.addQueryItem("cursor", s.value("cursor").toString());
} }
request_url.setQuery(url_query);
QNetworkRequest request(request_url); QNetworkRequest request(request_url);
request.setRawHeader("Authorization", GenerateAuthorisationHeader()); request.setRawHeader("Authorization", GenerateAuthorisationHeader());
QNetworkReply* reply = network_->get(request); QNetworkReply* reply = network_->get(request);
@ -193,15 +200,14 @@ void DropboxService::LongPollDelta() {
void DropboxService::LongPollFinished(QNetworkReply* reply) { void DropboxService::LongPollFinished(QNetworkReply* reply) {
reply->deleteLater(); reply->deleteLater();
QJson::Parser parser; QJsonObject json_response = QJsonDocument::fromBinaryData(reply->readAll()).object();
QVariantMap response = parser.parse(reply).toMap(); if (json_response["changes"].toBool()) {
if (response["changes"].toBool()) {
// New changes, we should request deltas again. // New changes, we should request deltas again.
qLog(Debug) << "Detected new dropbox changes; fetching..."; qLog(Debug) << "Detected new dropbox changes; fetching...";
RequestFileList(); RequestFileList();
} else { } else {
bool ok = false; bool ok = false;
int backoff_secs = response["backoff"].toInt(&ok); int backoff_secs = json_response["backoff"].toString().toInt(&ok);
backoff_secs = ok ? backoff_secs : 0; backoff_secs = ok ? backoff_secs : 0;
QTimer::singleShot(backoff_secs * 1000, this, SLOT(LongPollDelta())); QTimer::singleShot(backoff_secs * 1000, this, SLOT(LongPollDelta()));
@ -219,8 +225,7 @@ QNetworkReply* DropboxService::FetchContentUrl(const QUrl& url) {
void DropboxService::FetchContentUrlFinished(QNetworkReply* reply, void DropboxService::FetchContentUrlFinished(QNetworkReply* reply,
const QVariantMap& data) { const QVariantMap& data) {
reply->deleteLater(); reply->deleteLater();
QJson::Parser parser; QJsonObject json_response = QJsonDocument::fromBinaryData(reply->readAll()).object();
QVariantMap response = parser.parse(reply).toMap();
QFileInfo info(data["path"].toString()); QFileInfo info(data["path"].toString());
QUrl url; QUrl url;
@ -236,7 +241,7 @@ void DropboxService::FetchContentUrlFinished(QNetworkReply* reply,
song.set_ctime(0); song.set_ctime(0);
MaybeAddFileToDatabase(song, data["mime_type"].toString(), MaybeAddFileToDatabase(song, data["mime_type"].toString(),
QUrl::fromEncoded(response["url"].toByteArray()), QUrl::fromEncoded(json_response["url"].toString().toLatin1()),
QString::null); QString::null);
} }
@ -244,7 +249,6 @@ QUrl DropboxService::GetStreamingUrlFromSongId(const QUrl& url) {
QNetworkReply* reply = FetchContentUrl(url); QNetworkReply* reply = FetchContentUrl(url);
WaitForSignal(reply, SIGNAL(finished())); WaitForSignal(reply, SIGNAL(finished()));
QJson::Parser parser; QJsonObject json_response = QJsonDocument::fromJson(reply->readAll()).object();
QVariantMap response = parser.parse(reply).toMap(); return QUrl::fromEncoded(json_response["url"].toString().toLatin1());
return QUrl::fromEncoded(response["url"].toByteArray());
} }

View File

@ -19,7 +19,12 @@
#include "googledriveclient.h" #include "googledriveclient.h"
#include <qjson/parser.h> #include <QUrlQuery>
#include <QJsonParseError>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
#include "internet/core/oauthenticator.h" #include "internet/core/oauthenticator.h"
#include "core/closure.h" #include "core/closure.h"
@ -114,16 +119,15 @@ void Client::FetchUserInfoFinished(ConnectResponse* response,
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 200) { if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 200) {
qLog(Warning) << "Failed to get user info" << reply->readAll(); qLog(Warning) << "Failed to get user info" << reply->readAll();
} else { } else {
QJson::Parser parser; QJsonParseError error;
bool ok = false; QJsonDocument document = QJsonDocument::fromJson(reply->readAll(), &error);
QVariantMap result = parser.parse(reply, &ok).toMap(); if (error.error != QJsonParseError::NoError) {
if (!ok) {
qLog(Error) << "Failed to parse user info reply"; qLog(Error) << "Failed to parse user info reply";
return; return;
} }
qLog(Debug) << result; qLog(Debug) << document;
response->user_email_ = result["email"].toString(); response->user_email_ = document.object()["email"].toString();
qLog(Debug) << response->user_email_; qLog(Debug) << response->user_email_;
} }
emit response->Finished(); emit response->Finished();
@ -157,16 +161,15 @@ GetFileResponse* Client::GetFile(const QString& file_id) {
void Client::GetFileFinished(GetFileResponse* response, QNetworkReply* reply) { void Client::GetFileFinished(GetFileResponse* response, QNetworkReply* reply) {
reply->deleteLater(); reply->deleteLater();
QJson::Parser parser; QJsonParseError error;
bool ok = false; QJsonDocument document = QJsonDocument::fromJson(reply->readAll(), &error);
QVariantMap result = parser.parse(reply, &ok).toMap(); if (error.error != QJsonParseError::NoError) {
if (!ok) {
qLog(Error) << "Failed to fetch file with ID" << response->file_id_; qLog(Error) << "Failed to fetch file with ID" << response->file_id_;
emit response->Finished(); emit response->Finished();
return; return;
} }
response->file_ = File(result); response->file_ = File(document.object().toVariantMap());
emit response->Finished(); emit response->Finished();
} }
@ -179,13 +182,16 @@ ListChangesResponse* Client::ListChanges(const QString& cursor) {
void Client::MakeListChangesRequest(ListChangesResponse* response, void Client::MakeListChangesRequest(ListChangesResponse* response,
const QString& page_token) { const QString& page_token) {
QUrl url(kGoogleDriveChanges); QUrl url(kGoogleDriveChanges);
QUrlQuery url_query;
if (!response->cursor().isEmpty()) { if (!response->cursor().isEmpty()) {
url.addQueryItem("startChangeId", response->cursor()); url_query.addQueryItem("startChangeId", response->cursor());
} }
if (!page_token.isEmpty()) { if (!page_token.isEmpty()) {
url.addQueryItem("pageToken", page_token); url_query.addQueryItem("pageToken", page_token);
} }
url.setQuery(url_query);
qLog(Debug) << "Requesting changes at:" << response->cursor() << page_token; qLog(Debug) << "Requesting changes at:" << response->cursor() << page_token;
QNetworkRequest request(url); QNetworkRequest request(url);
@ -201,33 +207,33 @@ void Client::ListChangesFinished(ListChangesResponse* response,
QNetworkReply* reply) { QNetworkReply* reply) {
reply->deleteLater(); reply->deleteLater();
QJson::Parser parser; QJsonParseError error;
bool ok = false; QJsonDocument document = QJsonDocument::fromJson(reply->readAll(), &error);
// TODO(John Maguire): Put this on a separate thread as the response could be large. // TODO(John Maguire): Put this on a separate thread as the response could be large.
QVariantMap result = parser.parse(reply, &ok).toMap(); if (error.error != QJsonParseError::NoError) {
if (!ok) {
qLog(Error) << "Failed to fetch changes" << response->cursor(); qLog(Error) << "Failed to fetch changes" << response->cursor();
emit response->Finished(); emit response->Finished();
return; return;
} }
if (result.contains("largestChangeId")) { QJsonObject json_result = document.object();
response->next_cursor_ = result["largestChangeId"].toString(); if (json_result.contains("largestChangeId")) {
response->next_cursor_ = json_result["largestChangeId"].toString();
} }
// Emit the FilesFound signal for the files in the response. // Emit the FilesFound signal for the files in the response.
FileList files; FileList files;
QList<QUrl> files_deleted; QList<QUrl> files_deleted;
for (const QVariant& v : result["items"].toList()) { for (const QJsonValue & v : json_result["items"].toArray()) {
QVariantMap change = v.toMap(); QJsonObject change = v.toObject();
if (change["deleted"].toBool() || if (change["deleted"].toBool() ||
change["file"].toMap()["labels"].toMap()["trashed"].toBool()) { change["file"].toObject()["labels"].toObject()["trashed"].toBool()) {
QUrl url; QUrl url;
url.setScheme("googledrive"); url.setScheme("googledrive");
url.setPath(change["fileId"].toString()); url.setPath("/" + change["fileId"].toString());
files_deleted << url; files_deleted << url;
} else { } else {
files << File(change["file"].toMap()); files << File(change["file"].toObject().toVariantMap());
} }
} }
@ -235,8 +241,8 @@ void Client::ListChangesFinished(ListChangesResponse* response,
emit response->FilesDeleted(files_deleted); emit response->FilesDeleted(files_deleted);
// Get the next page of results if there is one. // Get the next page of results if there is one.
if (result.contains("nextPageToken")) { if (json_result.contains("nextPageToken")) {
MakeListChangesRequest(response, result["nextPageToken"].toString()); MakeListChangesRequest(response, json_result["nextPageToken"].toString());
} else { } else {
emit response->Finished(); emit response->Finished();
} }

View File

@ -26,6 +26,7 @@
#include <QPushButton> #include <QPushButton>
#include <QScopedPointer> #include <QScopedPointer>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QUrlQuery>
#include "core/application.h" #include "core/application.h"
#include "core/closure.h" #include "core/closure.h"
@ -163,7 +164,7 @@ void GoogleDriveService::FilesFound(const QList<google_drive::File>& files) {
QUrl url; QUrl url;
url.setScheme("googledrive"); url.setScheme("googledrive");
url.setPath(file.id()); url.setPath("/" + file.id());
Song song; Song song;
// Add some extra tags from the Google Drive metadata. // Add some extra tags from the Google Drive metadata.
@ -204,7 +205,9 @@ QUrl GoogleDriveService::GetStreamingUrlFromSongId(const QString& id) {
loop.exec(); loop.exec();
QUrl url(response->file().download_url()); QUrl url(response->file().download_url());
url.addQueryItem("access_token", client_->access_token()); QUrlQuery url_query(url);
url_query.addQueryItem("access_token", client_->access_token());
url.setQuery(url_query);
return url; return url;
} }

View File

@ -24,21 +24,21 @@
#include "fixlastfm.h" #include "fixlastfm.h"
#ifdef HAVE_LIBLASTFM1 #ifdef HAVE_LIBLASTFM1
#include <lastfm/Audioscrobbler.h> #include <lastfm5/Audioscrobbler.h>
#include <lastfm/misc.h> #include <lastfm5/misc.h>
#include <lastfm/ScrobbleCache.h> #include <lastfm5/ScrobbleCache.h>
#include <lastfm/ScrobblePoint.h> #include <lastfm5/ScrobblePoint.h>
#include <lastfm/User.h> #include <lastfm5/User.h>
#include <lastfm/ws.h> #include <lastfm5/ws.h>
#include <lastfm/XmlQuery.h> #include <lastfm5/XmlQuery.h>
#else #else
#include <lastfm/Audioscrobbler> #include <lastfm5/Audioscrobbler>
#include <lastfm/misc.h> #include <lastfm5/misc.h>
#include <lastfm/ScrobbleCache> #include <lastfm5/ScrobbleCache>
#include <lastfm/ScrobblePoint> #include <lastfm5/ScrobblePoint>
#include <lastfm/User> #include <lastfm5/User>
#include <lastfm/ws.h> #include <lastfm5/ws.h>
#include <lastfm/XmlQuery> #include <lastfm5/XmlQuery>
#endif #endif
namespace lastfm { namespace lastfm {

View File

@ -213,7 +213,7 @@ void LastFMService::UpdateSubscriberStatusFinished(QNetworkReply* reply) {
QUrl LastFMService::FixupUrl(const QUrl& url) { QUrl LastFMService::FixupUrl(const QUrl& url) {
QUrl ret; QUrl ret;
ret.setEncodedUrl(url.toEncoded().replace( ret.setUrl(url.toEncoded().replace(
"USERNAME", QUrl::toPercentEncoding(lastfm::ws::Username))); "USERNAME", QUrl::toPercentEncoding(lastfm::ws::Username)));
return ret; return ret;
} }

View File

@ -22,8 +22,11 @@
#include <cmath> #include <cmath>
#include <qjson/parser.h>
#include <QTimer> #include <QTimer>
#include <QUrlQuery>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include "core/application.h" #include "core/application.h"
#include "core/player.h" #include "core/player.h"
@ -80,7 +83,7 @@ bool SeafileService::has_credentials() const {
void SeafileService::AddAuthorizationHeader(QNetworkRequest* request) const { void SeafileService::AddAuthorizationHeader(QNetworkRequest* request) const {
request->setRawHeader("Authorization", request->setRawHeader("Authorization",
QString("Token %1").arg(access_token_).toAscii()); QString("Token %1").arg(access_token_).toLatin1());
} }
void SeafileService::ForgetCredentials() { void SeafileService::ForgetCredentials() {
@ -98,13 +101,15 @@ void SeafileService::ForgetCredentials() {
bool SeafileService::GetToken(const QString& mail, const QString& password, bool SeafileService::GetToken(const QString& mail, const QString& password,
const QString& server) { const QString& server) {
QUrl url(server + kAuthTokenUrl); QUrl url(server + kAuthTokenUrl);
QUrlQuery url_query;
url_query.addQueryItem("username", mail);
url_query.addQueryItem("password", password);
QNetworkRequest request(url); QNetworkRequest request(url);
AddAuthorizationHeader(&request); AddAuthorizationHeader(&request);
url.addQueryItem("username", mail); QNetworkReply* reply = network_->post(request, url_query.toString().toLatin1());
url.addQueryItem("password", password);
QNetworkReply* reply = network_->post(request, url.encodedQuery());
WaitForSignal(reply, SIGNAL(finished())); WaitForSignal(reply, SIGNAL(finished()));
if (!CheckReply(&reply)) { if (!CheckReply(&reply)) {
@ -114,11 +119,10 @@ bool SeafileService::GetToken(const QString& mail, const QString& password,
reply->deleteLater(); reply->deleteLater();
QJson::Parser parser; QJsonObject json_response = QJsonDocument::fromJson(reply->readAll()).object();
QVariantMap response = parser.parse(reply->readAll()).toMap();
// Because the server responds "token" // Because the server responds "token"
access_token_ = response["token"].toString().replace("\"", ""); access_token_ = json_response["token"].toString().replace("\"", "");
if (access_token_.isEmpty()) { if (access_token_.isEmpty()) {
return false; return false;
@ -156,11 +160,11 @@ void SeafileService::GetLibrariesFinished(QNetworkReply* reply) {
// key : id, value : name // key : id, value : name
QMap<QString, QString> libraries; QMap<QString, QString> libraries;
QByteArray data = reply->readAll(); QByteArray data = reply->readAll();
QJson::Parser parser;
QList<QVariant> repos = parser.parse(data).toList();
for (int i = 0; i < repos.size(); ++i) { QJsonArray json_repos = QJsonDocument::fromJson(data).array();
QVariantMap repo = repos.at(i).toMap();
for (const QJsonValue & json_repo: json_repos) {
QJsonObject repo = json_repo.toObject();
QString repo_name = repo["name"].toString(), QString repo_name = repo["name"].toString(),
repo_id = repo["id"].toString(); repo_id = repo["id"].toString();
@ -246,7 +250,9 @@ void SeafileService::UpdateLibrariesInProgress(
QNetworkReply* SeafileService::PrepareFetchFolderItems(const QString& library, QNetworkReply* SeafileService::PrepareFetchFolderItems(const QString& library,
const QString& path) { const QString& path) {
QUrl url(server_ + QString(kFolderItemsUrl).arg(library)); QUrl url(server_ + QString(kFolderItemsUrl).arg(library));
url.addQueryItem("p", path); QUrlQuery url_query;
url_query.addQueryItem("p", path);
url.setQuery(url_query);
QNetworkRequest request(url); QNetworkRequest request(url);
AddAuthorizationHeader(&request); AddAuthorizationHeader(&request);
@ -277,12 +283,11 @@ void SeafileService::FetchAndCheckFolderItemsFinished(
QByteArray data = reply->readAll(); QByteArray data = reply->readAll();
QJson::Parser parser; QJsonArray json_entries = QJsonDocument::fromJson(data).array();
QList<QVariant> variant_entries = parser.parse(data).toList();
SeafileTree::Entries entries; SeafileTree::Entries entries;
for (const QVariant& e : variant_entries) { for (const QJsonValue& e : json_entries) {
QVariantMap entry = e.toMap(); QJsonObject entry = e.toObject();
SeafileTree::Entry::Type entry_type = SeafileTree::Entry::Type entry_type =
SeafileTree::Entry::StringToType(entry["type"].toString()); SeafileTree::Entry::StringToType(entry["type"].toString());
QString entry_name = entry["name"].toString(); QString entry_name = entry["name"].toString();
@ -322,14 +327,13 @@ void SeafileService::AddRecursivelyFolderItemsFinished(QNetworkReply* reply,
reply->deleteLater(); reply->deleteLater();
QByteArray data = reply->readAll(); QByteArray data = reply->readAll();
QJson::Parser parser; QJsonArray json_entries = QJsonDocument::fromJson(data).array();
QList<QVariant> entries = parser.parse(data).toList();
for (const QVariant& e : entries) { for (const QJsonValue& e : json_entries) {
QVariantMap entry_map = e.toMap(); QJsonObject json_entry = e.toObject();
SeafileTree::Entry::Type entry_type = SeafileTree::Entry::Type entry_type =
SeafileTree::Entry::StringToType(entry_map["type"].toString()); SeafileTree::Entry::StringToType(json_entry["type"].toString());
QString entry_name = entry_map["name"].toString(); QString entry_name = json_entry["name"].toString();
// We just want libraries/directories and files which could be songs. // We just want libraries/directories and files which could be songs.
if (entry_type == SeafileTree::Entry::NONE) { if (entry_type == SeafileTree::Entry::NONE) {
@ -339,7 +343,7 @@ void SeafileService::AddRecursivelyFolderItemsFinished(QNetworkReply* reply,
continue; continue;
} }
SeafileTree::Entry entry(entry_name, entry_map["id"].toString(), SeafileTree::Entry entry(entry_name, json_entry["id"].toString(),
entry_type); entry_type);
// If AddEntry was not successful we stop // If AddEntry was not successful we stop
@ -360,7 +364,9 @@ void SeafileService::AddRecursivelyFolderItemsFinished(QNetworkReply* reply,
QNetworkReply* SeafileService::PrepareFetchContentForFile( QNetworkReply* SeafileService::PrepareFetchContentForFile(
const QString& library, const QString& filepath) { const QString& library, const QString& filepath) {
QUrl content_url(server_ + QString(kFileContentUrl).arg(library)); QUrl content_url(server_ + QString(kFileContentUrl).arg(library));
content_url.addQueryItem("p", filepath); QUrlQuery content_url_query;
content_url_query.addQueryItem("p", filepath);
content_url.setQuery(content_url_query);
QNetworkRequest request(content_url); QNetworkRequest request(content_url);
AddAuthorizationHeader(&request); AddAuthorizationHeader(&request);
@ -397,23 +403,22 @@ void SeafileService::MaybeAddFileEntryInProgress(QNetworkReply* reply,
QByteArray data = reply->readAll(); QByteArray data = reply->readAll();
QJson::Parser parser; QJsonObject json_entry_detail = QJsonDocument::fromJson(data).object();
QVariantMap entry_detail_map = parser.parse(data).toMap();
QUrl url; QUrl url;
url.setScheme("seafile"); url.setScheme("seafile");
url.setPath("/" + library + path + entry_detail_map["name"].toString()); url.setPath("/" + library + path + json_entry_detail["name"].toString());
Song song; Song song;
song.set_url(url); song.set_url(url);
song.set_ctime(0); song.set_ctime(0);
song.set_mtime(entry_detail_map["mtime"].toInt()); song.set_mtime(json_entry_detail["mtime"].toInt());
song.set_filesize(entry_detail_map["size"].toInt()); song.set_filesize(json_entry_detail["size"].toInt());
song.set_title(entry_detail_map["name"].toString()); song.set_title(json_entry_detail["name"].toString());
// Get the download url of the entry // Get the download url of the entry
reply = PrepareFetchContentUrlForFile( reply = PrepareFetchContentUrlForFile(
library, path + entry_detail_map["name"].toString()); library, path + json_entry_detail["name"].toString());
NewClosure( NewClosure(
reply, SIGNAL(finished()), this, reply, SIGNAL(finished()), this,
SLOT(FetchContentUrlForFileFinished(QNetworkReply*, Song, QString)), SLOT(FetchContentUrlForFileFinished(QNetworkReply*, Song, QString)),
@ -423,7 +428,9 @@ void SeafileService::MaybeAddFileEntryInProgress(QNetworkReply* reply,
QNetworkReply* SeafileService::PrepareFetchContentUrlForFile( QNetworkReply* SeafileService::PrepareFetchContentUrlForFile(
const QString& library, const QString& filepath) { const QString& library, const QString& filepath) {
QUrl content_url(server_ + QString(kFileUrl).arg(library)); QUrl content_url(server_ + QString(kFileUrl).arg(library));
content_url.addQueryItem("p", filepath); QUrlQuery content_url_query;
content_url_query.addQueryItem("p", filepath);
content_url.setQuery(content_url_query);
QNetworkRequest request(content_url); QNetworkRequest request(content_url);
AddAuthorizationHeader(&request); AddAuthorizationHeader(&request);
@ -589,7 +596,7 @@ bool SeafileService::CheckReply(QNetworkReply** reply, int tries) {
// Unknown, 404 ... // Unknown, 404 ...
(*reply)->deleteLater(); (*reply)->deleteLater();
qLog(Warning) << "Error for reply : " << status_code_variant.toInt(); qLog(Warning) << "Error with the reply : " << status_code_variant.toInt();
return false; return false;
} }

View File

@ -19,9 +19,12 @@
#include "skydriveservice.h" #include "skydriveservice.h"
#include <memory> #include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QUrlQuery>
#include <qjson/parser.h> #include <memory>
#include "core/application.h" #include "core/application.h"
#include "core/player.h" #include "core/player.h"
@ -107,10 +110,9 @@ void SkydriveService::AddAuthorizationHeader(QNetworkRequest* request) {
void SkydriveService::FetchUserInfoFinished(QNetworkReply* reply) { void SkydriveService::FetchUserInfoFinished(QNetworkReply* reply) {
reply->deleteLater(); reply->deleteLater();
QJson::Parser parser; QJsonObject json_response = QJsonDocument::fromBinaryData(reply->readAll()).object();
QVariantMap response = parser.parse(reply).toMap();
QString name = response["name"].toString(); QString name = json_response["name"].toString();
if (!name.isEmpty()) { if (!name.isEmpty()) {
QSettings s; QSettings s;
s.beginGroup(kSettingsGroup); s.beginGroup(kSettingsGroup);
@ -124,7 +126,9 @@ void SkydriveService::FetchUserInfoFinished(QNetworkReply* reply) {
void SkydriveService::ListFiles(const QString& folder) { void SkydriveService::ListFiles(const QString& folder) {
QUrl url(QString(kSkydriveBase) + folder + "/files"); QUrl url(QString(kSkydriveBase) + folder + "/files");
url.addQueryItem("filter", "audio,folders"); QUrlQuery url_query;
url_query.addQueryItem("filter", "audio,folders");
url.setQuery(url_query);
QNetworkRequest request(url); QNetworkRequest request(url);
AddAuthorizationHeader(&request); AddAuthorizationHeader(&request);
@ -135,27 +139,26 @@ void SkydriveService::ListFiles(const QString& folder) {
void SkydriveService::ListFilesFinished(QNetworkReply* reply) { void SkydriveService::ListFilesFinished(QNetworkReply* reply) {
reply->deleteLater(); reply->deleteLater();
QJson::Parser parser; QJsonObject json_response = QJsonDocument::fromBinaryData(reply->readAll()).object();
QVariantMap response = parser.parse(reply).toMap();
QVariantList files = response["data"].toList(); QJsonArray files = json_response["data"].toArray();
for (const QVariant& f : files) { for (const QJsonValue& f : files) {
QVariantMap file = f.toMap(); QJsonObject file = f.toObject();
if (file["type"].toString() == "audio") { if (file["type"].toString() == "audio") {
QString mime_type = GuessMimeTypeForFile(file["name"].toString()); QString mime_type = GuessMimeTypeForFile(file["name"].toString());
QUrl url; QUrl url;
url.setScheme("skydrive"); url.setScheme("skydrive");
url.setPath(file["id"].toString()); url.setPath("/" + file["id"].toString());
Song song; Song song;
song.set_url(url); song.set_url(url);
song.set_ctime(file["created_time"].toDateTime().toTime_t()); song.set_ctime(QDateTime::fromString(file["created_time"].toString()).toTime_t());
song.set_mtime(file["updated_time"].toDateTime().toTime_t()); song.set_mtime(QDateTime::fromString(file["updated_time"].toString()).toTime_t());
song.set_comment(file["description"].toString()); song.set_comment(file["description"].toString());
song.set_filesize(file["size"].toInt()); song.set_filesize(file["size"].toInt());
song.set_title(file["name"].toString()); song.set_title(file["name"].toString());
QUrl download_url = file["source"].toUrl(); QUrl download_url(file["source"].toString());
// HTTPS appears to be broken somehow between Qt & Skydrive downloads. // HTTPS appears to be broken somehow between Qt & Skydrive downloads.
// Fortunately, just changing the scheme to HTTP works. // Fortunately, just changing the scheme to HTTP works.
download_url.setScheme("http"); download_url.setScheme("http");
@ -175,9 +178,8 @@ QUrl SkydriveService::GetStreamingUrlFromSongId(const QString& file_id) {
std::unique_ptr<QNetworkReply> reply(network_->get(request)); std::unique_ptr<QNetworkReply> reply(network_->get(request));
WaitForSignal(reply.get(), SIGNAL(finished())); WaitForSignal(reply.get(), SIGNAL(finished()));
QJson::Parser parser; QJsonObject json_response = QJsonDocument::fromBinaryData(reply.get()->readAll()).object();
QVariantMap response = parser.parse(reply.get()).toMap(); return QUrl(json_response["source"].toString());
return response["source"].toUrl();
} }
void SkydriveService::EnsureConnected() { void SkydriveService::EnsureConnected() {

View File

@ -21,8 +21,10 @@
#include <QDateTime> #include <QDateTime>
#include <QDesktopServices> #include <QDesktopServices>
#include <QUrlQuery>
#include <qjson/parser.h> #include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
#include "core/closure.h" #include "core/closure.h"
#include "core/logging.h" #include "core/logging.h"
@ -95,18 +97,22 @@ bool VkConnection::hasAccount() {
QNetworkRequest VkConnection::makeRequest(const QString& method, QNetworkRequest VkConnection::makeRequest(const QString& method,
const QVariantMap& args) { const QVariantMap& args) {
QUrl url = kApiUrl; QUrl url = kApiUrl;
url.setPath(url.path() % QLatin1Literal("/") % method); url.setPath(url.path() + "/" + method);
QUrlQuery url_query;
for (auto it = args.constBegin(); it != args.constEnd(); ++it) { for (auto it = args.constBegin(); it != args.constEnd(); ++it) {
url.addEncodedQueryItem(QUrl::toPercentEncoding(it.key()), url_query.addQueryItem(QUrl::toPercentEncoding(it.key()),
QUrl::toPercentEncoding(it.value().toString())); QUrl::toPercentEncoding(it.value().toString()));
} }
url.addEncodedQueryItem("access_token", access_token_); url_query.addQueryItem("access_token", access_token_);
url.setQuery(url_query);
return QNetworkRequest(url); return QNetworkRequest(url);
} }
void VkConnection::decorateRequest(QNetworkRequest& request) { void VkConnection::decorateRequest(QNetworkRequest& request) {
QUrl url = request.url(); QUrl url = request.url();
url.addEncodedQueryItem("access_token", access_token_); QUrlQuery url_query(url);
url_query.addQueryItem("access_token", access_token_);
url.setQuery(url_query);
request.setUrl(url); request.setUrl(url);
} }
@ -115,11 +121,13 @@ void VkConnection::requestAccessToken() {
server->Listen(); server->Listen();
QUrl url = kVkOAuthEndpoint; QUrl url = kVkOAuthEndpoint;
url.addQueryItem("client_id", kAppID); QUrlQuery url_query;
url.addQueryItem("scope", url_query.addQueryItem("client_id", kAppID);
url_query.addQueryItem("scope",
Vreen::flagsToStrList(kScopes, kScopeNames).join(",")); Vreen::flagsToStrList(kScopes, kScopeNames).join(","));
url.addQueryItem("redirect_uri", server->url().toString()); url_query.addQueryItem("redirect_uri", server->url().toString());
url.addQueryItem("response_type", "code"); url_query.addQueryItem("response_type", "code");
url.setQuery(url_query);
qLog(Debug) << "Try to login to Vk.com" << url; qLog(Debug) << "Try to login to Vk.com" << url;
@ -130,13 +138,16 @@ void VkConnection::requestAccessToken() {
} }
void VkConnection::codeRecived(LocalRedirectServer* server, QUrl redirect_uri) { void VkConnection::codeRecived(LocalRedirectServer* server, QUrl redirect_uri) {
if (server->request_url().hasQueryItem("code")) { QUrlQuery url_query_server(server->request_url());
code_ = server->request_url().queryItemValue("code").toUtf8(); if (url_query_server.hasQueryItem("code")) {
code_ = url_query_server.queryItemValue("code").toUtf8();
QUrl url = kVkOAuthTokenEndpoint; QUrl url = kVkOAuthTokenEndpoint;
url.addQueryItem("client_id", kAppID); QUrlQuery url_query;
url.addQueryItem("client_secret", kAppSecret); url_query.addQueryItem("client_id", kAppID);
url.addQueryItem("code", QString::fromUtf8(code_)); url_query.addQueryItem("client_secret", kAppSecret);
url.addQueryItem("redirect_uri", redirect_uri.toString()); url_query.addQueryItem("code", QString::fromUtf8(code_));
url_query.addQueryItem("redirect_uri", redirect_uri.toString());
url.setQuery(url_query);
qLog(Debug) << "Getting access token" << url; qLog(Debug) << "Getting access token" << url;
QNetworkRequest request(url); QNetworkRequest request(url);
@ -159,21 +170,22 @@ void VkConnection::accessTokenRecived(QNetworkReply* reply) {
return; return;
} }
QJson::Parser parser;
bool ok = false;
QByteArray reply_data = reply->readAll(); QByteArray reply_data = reply->readAll();
QVariantMap result = parser.parse(reply_data, &ok).toMap(); QJsonParseError error;
if (!ok) { QJsonDocument document = QJsonDocument::fromJson(reply_data, &error);
if (error.error != QJsonParseError::NoError) {
qLog(Error) << "Failed to parse oauth reply" << reply_data; qLog(Error) << "Failed to parse oauth reply" << reply_data;
emit setConnectionState(Vreen::Client::StateOffline); emit setConnectionState(Vreen::Client::StateOffline);
clear(); clear();
return; return;
} }
qLog(Debug) << result;
access_token_ = result["access_token"].toByteArray(); QJsonObject json_result = document.object();
expires_in_ = result["expires_in"].toUInt(); qLog(Debug) << json_result;
uid_ = result["user_id"].toInt();
access_token_ = json_result["access_token"].toString().toLatin1();
expires_in_ = json_result["expires_in"].toString().toUInt();
uid_ = json_result["user_id"].toInt();
if (expires_in_) { if (expires_in_) {
expires_in_ += QDateTime::currentDateTime().toTime_t(); expires_in_ += QDateTime::currentDateTime().toTime_t();

View File

@ -130,7 +130,7 @@ void VkMusicCache::DownloadNext() {
void VkMusicCache::DownloadProgress(qint64 bytesReceived, qint64 bytesTotal) { void VkMusicCache::DownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
if (bytesTotal) { if (bytesTotal) {
int progress = qRound(100 * bytesReceived / bytesTotal); int progress = qRound(100. * bytesReceived / bytesTotal);
app_->task_manager()->SetTaskProgress(task_id, progress, 100); app_->task_manager()->SetTaskProgress(task_id, progress, 100);
} }
} }

View File

@ -57,7 +57,7 @@ bool MoodbarPipeline::IsAvailable() {
GstElement* MoodbarPipeline::CreateElement(const QString& factory_name) { GstElement* MoodbarPipeline::CreateElement(const QString& factory_name) {
GstElement* ret = GstElement* ret =
gst_element_factory_make(factory_name.toAscii().constData(), nullptr); gst_element_factory_make(factory_name.toLatin1().constData(), nullptr);
if (ret) { if (ret) {
gst_bin_add(GST_BIN(pipeline_), ret); gst_bin_add(GST_BIN(pipeline_), ret);

View File

@ -75,11 +75,11 @@ RipCD::RipCD(QWidget* parent)
ui_->setupUi(this); ui_->setupUi(this);
// Set column widths in the QTableWidget. // Set column widths in the QTableWidget.
ui_->tableWidget->horizontalHeader()->setResizeMode( ui_->tableWidget->horizontalHeader()->setSectionResizeMode(
kCheckboxColumn, QHeaderView::ResizeToContents); kCheckboxColumn, QHeaderView::ResizeToContents);
ui_->tableWidget->horizontalHeader()->setResizeMode( ui_->tableWidget->horizontalHeader()->setSectionResizeMode(
kTrackNumberColumn, QHeaderView::ResizeToContents); kTrackNumberColumn, QHeaderView::ResizeToContents);
ui_->tableWidget->horizontalHeader()->setResizeMode(kTrackTitleColumn, ui_->tableWidget->horizontalHeader()->setSectionResizeMode(kTrackTitleColumn,
QHeaderView::Stretch); QHeaderView::Stretch);
// Add a rip button // Add a rip button

View File

@ -66,7 +66,7 @@ QDBusArgument& operator<<(QDBusArgument& arg, const QImage& image) {
int channels = i.isGrayscale() ? 1 : (i.hasAlphaChannel() ? 4 : 3); int channels = i.isGrayscale() ? 1 : (i.hasAlphaChannel() ? 4 : 3);
arg << i.depth() / channels; arg << i.depth() / channels;
arg << channels; arg << channels;
arg << QByteArray(reinterpret_cast<const char*>(i.bits()), i.numBytes()); arg << QByteArray(reinterpret_cast<const char*>(i.bits()), i.byteCount());
arg.endStructure(); arg.endStructure();
return arg; return arg;
} }

View File

@ -26,7 +26,7 @@
WiimoteSettingsPage::WiimoteSettingsPage(SettingsDialog* dialog) WiimoteSettingsPage::WiimoteSettingsPage(SettingsDialog* dialog)
: SettingsPage(dialog), ui_(new Ui_WiimoteSettingsPage) { : SettingsPage(dialog), ui_(new Ui_WiimoteSettingsPage) {
ui_->setupUi(this); ui_->setupUi(this);
ui_->list->header()->setResizeMode(QHeaderView::ResizeToContents); ui_->list->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
setWindowIcon(QIcon(":/icons/32x32/wiimotedev.png")); setWindowIcon(QIcon(":/icons/32x32/wiimotedev.png"));
text_buttons_.insert(WIIMOTE_BTN_1, "Wiiremote 1"); text_buttons_.insert(WIIMOTE_BTN_1, "Wiiremote 1");

View File

@ -74,14 +74,14 @@ qt5_wrap_cpp(TESTUTILS-SOURCES-MOC ${TESTUTILS-MOC-HEADERS})
add_library(test_utils STATIC EXCLUDE_FROM_ALL ${TESTUTILS-SOURCES} ${TESTUTILS-SOURCES-MOC}) add_library(test_utils STATIC EXCLUDE_FROM_ALL ${TESTUTILS-SOURCES} ${TESTUTILS-SOURCES-MOC})
target_link_libraries(test_utils ${GMOCK_LIBRARIES} ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY}) target_link_libraries(test_utils ${GMOCK_LIBRARIES} ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY})
add_custom_target(test add_custom_target(clementine_test
echo "Running tests" echo "Running Clementine tests"
WORKING_DIRECTORY ${CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CURRENT_BINARY_DIR}
) )
add_custom_target(build_tests add_custom_target(build_tests
WORKING_DIRECTORY ${CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CURRENT_BINARY_DIR}
) )
add_dependencies(test build_tests) add_dependencies(clementine_test build_tests)
qt5_add_resources(TEST-RESOURCE-SOURCES data/testdata.qrc) qt5_add_resources(TEST-RESOURCE-SOURCES data/testdata.qrc)
@ -112,7 +112,7 @@ macro(add_test_file test_source gui_required)
set_target_properties(${TEST_NAME} PROPERTIES COMPILE_FLAGS "-Wno-bool-conversions") set_target_properties(${TEST_NAME} PROPERTIES COMPILE_FLAGS "-Wno-bool-conversions")
endif (SUPPORTS_NOBOOL) endif (SUPPORTS_NOBOOL)
add_custom_command(TARGET test POST_BUILD add_custom_command(TARGET clementine_test POST_BUILD
COMMAND ./${TEST_NAME}${CMAKE_EXECUTABLE_SUFFIX}) COMMAND ./${TEST_NAME}${CMAKE_EXECUTABLE_SUFFIX})
add_dependencies(build_tests ${TEST_NAME}) add_dependencies(build_tests ${TEST_NAME})
endmacro (add_test_file) endmacro (add_test_file)