mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-22 15:58:45 +01:00
Merge libmygpo-qt from HEAD (fd4e40a2a3c69d5b4ba94e483ddcbbf3541b5767) plus https://github.com/gpodder/libmygpo-qt/pull/8 to make it use HTTPS for API requests
This commit is contained in:
parent
1cf5e28030
commit
50539ab46b
8
3rdparty/libmygpo-qt/AddRemoveResult.cpp
vendored
8
3rdparty/libmygpo-qt/AddRemoveResult.cpp
vendored
@ -20,11 +20,11 @@
|
||||
* USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include <parser.h>
|
||||
|
||||
#include "AddRemoveResult.h"
|
||||
#include "AddRemoveResult_p.h"
|
||||
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
AddRemoveResultPrivate::AddRemoveResultPrivate( AddRemoveResult* qq, QNetworkReply* reply ) : q( qq ), m_reply( reply ), m_error( QNetworkReply::NoError )
|
||||
@ -64,7 +64,6 @@ QList< QPair< QUrl, QUrl > > AddRemoveResultPrivate::updateUrlsList() const
|
||||
|
||||
bool AddRemoveResultPrivate::parse( const QVariant& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
if( !data.canConvert( QVariant::Map ) )
|
||||
return false;
|
||||
QVariantMap resultMap = data.toMap();
|
||||
@ -78,9 +77,8 @@ bool AddRemoveResultPrivate::parse( const QVariant& data )
|
||||
|
||||
bool AddRemoveResultPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
||||
|
2
3rdparty/libmygpo-qt/ApiRequest.cpp
vendored
2
3rdparty/libmygpo-qt/ApiRequest.cpp
vendored
@ -1,6 +1,6 @@
|
||||
/***************************************************************************
|
||||
* This file is part of libmygpo-qt *
|
||||
* Copyright (c) 2010 - 2013 Stefan Derkits <stefan@derkits.at> *
|
||||
* Copyright (c) 2010 - 2014 Stefan Derkits <stefan@derkits.at> *
|
||||
* Copyright (c) 2010 - 2011 Christian Wagner <christian.wagner86@gmx.at> *
|
||||
* Copyright (c) 2010 - 2011 Felix Winter <ixos01@gmail.com> *
|
||||
* *
|
||||
|
12
3rdparty/libmygpo-qt/ApiRequest.h
vendored
12
3rdparty/libmygpo-qt/ApiRequest.h
vendored
@ -1,6 +1,6 @@
|
||||
/***************************************************************************
|
||||
* This file is part of libmygpo-qt *
|
||||
* Copyright (c) 2010 - 2013 Stefan Derkits <stefan@derkits.at> *
|
||||
* Copyright (c) 2010 - 2014 Stefan Derkits <stefan@derkits.at> *
|
||||
* Copyright (c) 2010 - 2011 Christian Wagner <christian.wagner86@gmx.at> *
|
||||
* Copyright (c) 2010 - 2011 Felix Winter <ixos01@gmail.com> *
|
||||
* *
|
||||
@ -84,7 +84,7 @@ public:
|
||||
*/
|
||||
QNetworkReply* suggestionsOpml( uint count );
|
||||
|
||||
QNetworkReply* downloadSubscriptionsOpml( const QString& username, const QString& device );
|
||||
QNetworkReply* downloadSubscriptionsOpml( const QString& username, const QString& device = QString() );
|
||||
|
||||
/**
|
||||
* Returns the TXT Result for the Simple API Call "Downloading Podcast Toplists"
|
||||
@ -111,7 +111,7 @@ public:
|
||||
*/
|
||||
QNetworkReply* suggestionsTxt( uint count );
|
||||
|
||||
QNetworkReply* downloadSubscriptionsTxt( const QString& username, const QString& device );
|
||||
QNetworkReply* downloadSubscriptionsTxt( const QString& username, const QString& device = QString() );
|
||||
|
||||
/**
|
||||
* Returns the TXT Result for the Simple API Call "Downloading Podcast Toplists"
|
||||
@ -153,9 +153,9 @@ public:
|
||||
*
|
||||
*/
|
||||
PodcastListPtr suggestions( uint count );
|
||||
|
||||
QNetworkReply* downloadSubscriptionsJson( const QString& username, const QString& device );
|
||||
|
||||
|
||||
QNetworkReply* downloadSubscriptionsJson( const QString& username, const QString& device = QString() );
|
||||
|
||||
//ADVANCED API
|
||||
|
||||
/**
|
||||
|
3
3rdparty/libmygpo-qt/CMakeLists.txt
vendored
3
3rdparty/libmygpo-qt/CMakeLists.txt
vendored
@ -1,7 +1,7 @@
|
||||
# Extra bits for Clementine.
|
||||
set( MYGPO_QT_VERSION_MAJOR "1" )
|
||||
set( MYGPO_QT_VERSION_MINOR "0" )
|
||||
set( MYGPO_QT_VERSION_PATCH "7" )
|
||||
set( MYGPO_QT_VERSION_PATCH "9" )
|
||||
configure_file( Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/Version.h )
|
||||
include_directories("${QJSON_INCLUDEDIR}/qjson")
|
||||
|
||||
@ -27,6 +27,7 @@ set ( LIBMYGPO_QT_SRC
|
||||
DeviceUpdates.cpp
|
||||
DeviceList.cpp
|
||||
Device.cpp
|
||||
qjsonwrapper/Json.cpp
|
||||
)
|
||||
|
||||
set ( LIBMYGPO_QT_MOC_H
|
||||
|
2
3rdparty/libmygpo-qt/Config.cpp
vendored
2
3rdparty/libmygpo-qt/Config.cpp
vendored
@ -29,7 +29,7 @@ using namespace mygpo;
|
||||
|
||||
Config* Config::s_instance = 0;
|
||||
|
||||
ConfigPrivate::ConfigPrivate( Config* qq ) : q( qq ), m_mygpoBaseUrl( QUrl( QLatin1String( "http://gpodder.net" ) ) ), m_userAgentPrefix( QString() )
|
||||
ConfigPrivate::ConfigPrivate( Config* qq ) : q( qq ), m_mygpoBaseUrl( QUrl( QLatin1String( "https://gpodder.net" ) ) ), m_userAgentPrefix( QString() )
|
||||
{
|
||||
|
||||
}
|
||||
|
5
3rdparty/libmygpo-qt/DeviceList.cpp
vendored
5
3rdparty/libmygpo-qt/DeviceList.cpp
vendored
@ -22,7 +22,7 @@
|
||||
|
||||
#include "DeviceList_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
@ -73,9 +73,8 @@ bool DeviceListPrivate::parse( const QVariant& data )
|
||||
|
||||
bool DeviceListPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
||||
|
7
3rdparty/libmygpo-qt/DeviceSyncResult.cpp
vendored
7
3rdparty/libmygpo-qt/DeviceSyncResult.cpp
vendored
@ -20,7 +20,7 @@
|
||||
|
||||
#include "DeviceSyncResult_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
@ -85,9 +85,8 @@ bool DeviceSyncResultPrivate::parse( const QVariant& data )
|
||||
|
||||
bool DeviceSyncResultPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
||||
@ -108,7 +107,7 @@ void DeviceSyncResultPrivate::parseData()
|
||||
emit q->parseError();
|
||||
}
|
||||
}
|
||||
m_reply->deleteLater();
|
||||
m_reply->deleteLater();
|
||||
}
|
||||
|
||||
void DeviceSyncResultPrivate::error( QNetworkReply::NetworkError error )
|
||||
|
5
3rdparty/libmygpo-qt/DeviceUpdates.cpp
vendored
5
3rdparty/libmygpo-qt/DeviceUpdates.cpp
vendored
@ -22,7 +22,7 @@
|
||||
|
||||
#include "DeviceUpdates_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
@ -102,9 +102,8 @@ bool DeviceUpdatesPrivate::parse( const QVariant& data )
|
||||
|
||||
bool DeviceUpdatesPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
||||
|
5
3rdparty/libmygpo-qt/Episode.cpp
vendored
5
3rdparty/libmygpo-qt/Episode.cpp
vendored
@ -22,7 +22,7 @@
|
||||
|
||||
#include "Episode_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
@ -115,9 +115,8 @@ bool EpisodePrivate::parse ( const QVariant& data )
|
||||
|
||||
bool EpisodePrivate::parse ( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse ( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if ( ok )
|
||||
{
|
||||
if ( !parse ( variant ) ) return false;
|
||||
|
5
3rdparty/libmygpo-qt/EpisodeAction.cpp
vendored
5
3rdparty/libmygpo-qt/EpisodeAction.cpp
vendored
@ -22,7 +22,7 @@
|
||||
|
||||
#include "EpisodeAction_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
@ -163,9 +163,8 @@ bool EpisodeActionPrivate::parseActionType( const QString& data )
|
||||
|
||||
bool EpisodeActionPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
if( !parse( variant ) ) return false;
|
||||
|
5
3rdparty/libmygpo-qt/EpisodeActionList.cpp
vendored
5
3rdparty/libmygpo-qt/EpisodeActionList.cpp
vendored
@ -22,7 +22,7 @@
|
||||
|
||||
#include "EpisodeActionList_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
@ -88,9 +88,8 @@ bool EpisodeActionListPrivate::parse( const QVariant& data )
|
||||
|
||||
bool EpisodeActionListPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
||||
|
5
3rdparty/libmygpo-qt/EpisodeList.cpp
vendored
5
3rdparty/libmygpo-qt/EpisodeList.cpp
vendored
@ -22,7 +22,7 @@
|
||||
|
||||
#include "EpisodeList_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
@ -71,9 +71,8 @@ bool EpisodeListPrivate::parse( const QVariant& data )
|
||||
|
||||
bool EpisodeListPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
||||
|
20
3rdparty/libmygpo-qt/JsonCreator.cpp
vendored
20
3rdparty/libmygpo-qt/JsonCreator.cpp
vendored
@ -20,47 +20,44 @@
|
||||
* USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include <QVariant>
|
||||
//#include <QVariant>
|
||||
#include <QList>
|
||||
#include <QUrl>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <serializer.h>
|
||||
|
||||
#include "JsonCreator.h"
|
||||
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
static qulonglong c_maxlonglong = (2^64)-1;
|
||||
|
||||
QByteArray JsonCreator::addRemoveSubsToJSON( const QList< QUrl >& add, const QList< QUrl >& remove )
|
||||
{
|
||||
QJson::Serializer serializer;
|
||||
QVariantMap jsonData;
|
||||
QVariant addVar( urlListToQVariantList( add ) );
|
||||
QVariant removeVar( urlListToQVariantList( remove ) );
|
||||
jsonData.insert( QString( QLatin1String( "add" ) ), addVar );
|
||||
jsonData.insert( QString( QLatin1String( "remove" ) ), removeVar );
|
||||
QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) );
|
||||
QByteArray jsonByteArray = QJsonWrapper::toJson( QVariant( jsonData ) );
|
||||
return jsonByteArray;
|
||||
}
|
||||
|
||||
QByteArray JsonCreator::saveSettingsToJSON( const QMap< QString, QVariant >& set, const QList< QString >& remove )
|
||||
{
|
||||
QJson::Serializer serializer;
|
||||
QVariantMap jsonData;
|
||||
//QVariant setVar(stringMapToQVariantMap(set));
|
||||
QVariant removeVar( stringListToQVariantList( remove ) );
|
||||
jsonData.insert( QString( QLatin1String( "set" ) ), set );
|
||||
jsonData.insert( QString( QLatin1String( "remove" ) ), removeVar );
|
||||
QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) );
|
||||
QByteArray jsonByteArray = QJsonWrapper::toJson( QVariant( jsonData ) );
|
||||
return jsonByteArray;
|
||||
}
|
||||
|
||||
QByteArray JsonCreator::episodeActionListToJSON( const QList<EpisodeActionPtr>& episodeActions )
|
||||
{
|
||||
QJson::Serializer serializer;
|
||||
QVariantList jsonData;
|
||||
|
||||
foreach( const EpisodeActionPtr episodeAction, episodeActions )
|
||||
@ -68,19 +65,18 @@ QByteArray JsonCreator::episodeActionListToJSON( const QList<EpisodeActionPtr>&
|
||||
jsonData.append( episodeActionToQVariantMap( episodeAction ) );
|
||||
}
|
||||
|
||||
QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) );
|
||||
QByteArray jsonByteArray = QJsonWrapper::toJson( QVariant( jsonData ) );
|
||||
return jsonByteArray;
|
||||
}
|
||||
|
||||
QByteArray JsonCreator::renameDeviceStringToJSON( const QString& caption, const QString& type )
|
||||
{
|
||||
QJson::Serializer serializer;
|
||||
QVariantMap jsonData;
|
||||
QVariant captionVar( caption );
|
||||
QVariant typeVar( type );
|
||||
jsonData.insert( QString( QLatin1String( "caption" ) ), captionVar );
|
||||
jsonData.insert( QString( QLatin1String( "type" ) ), typeVar );
|
||||
QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) );
|
||||
QByteArray jsonByteArray = QJsonWrapper::toJson( QVariant( jsonData ) );
|
||||
return jsonByteArray;
|
||||
|
||||
}
|
||||
@ -130,7 +126,7 @@ QByteArray JsonCreator::deviceSynchronizationListsToJSON(const QList< QStringLis
|
||||
jsonStr.append(syncVar);
|
||||
jsonStr.append(QLatin1String(" ,\"stop-synchronize\" : "));
|
||||
jsonStr.append(stopVar);
|
||||
jsonStr.append(QLatin1String(" }\n"));
|
||||
jsonStr.append(QLatin1String(" }"));
|
||||
return jsonStr.toLocal8Bit();
|
||||
}
|
||||
|
||||
|
7
3rdparty/libmygpo-qt/Podcast.cpp
vendored
7
3rdparty/libmygpo-qt/Podcast.cpp
vendored
@ -22,7 +22,7 @@
|
||||
|
||||
#include "Podcast_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
@ -181,9 +181,8 @@ bool PodcastPrivate::parse( const QVariant& data )
|
||||
|
||||
bool PodcastPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if ( ok )
|
||||
{
|
||||
if ( !parse( variant ) ) return false;
|
||||
@ -197,8 +196,6 @@ bool PodcastPrivate::parse( const QByteArray& data )
|
||||
|
||||
void PodcastPrivate::parseData()
|
||||
{
|
||||
//parsen und signal senden
|
||||
QJson::Parser parser;
|
||||
if ( parse( m_reply->readAll( ) ) )
|
||||
{
|
||||
emit q->finished();
|
||||
|
5
3rdparty/libmygpo-qt/PodcastList.cpp
vendored
5
3rdparty/libmygpo-qt/PodcastList.cpp
vendored
@ -22,7 +22,7 @@
|
||||
|
||||
#include "PodcastList_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
@ -71,9 +71,8 @@ bool PodcastListPrivate::parse( const QVariant& data )
|
||||
|
||||
bool PodcastListPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
||||
|
2
3rdparty/libmygpo-qt/RequestHandler.cpp
vendored
2
3rdparty/libmygpo-qt/RequestHandler.cpp
vendored
@ -77,5 +77,5 @@ void RequestHandler::addAuthData( QNetworkRequest& request )
|
||||
|
||||
void RequestHandler::addUserAgent( QNetworkRequest &request )
|
||||
{
|
||||
request.setRawHeader("User-Agent", Config::instance()->userAgent().toAscii() );
|
||||
request.setRawHeader("User-Agent", Config::instance()->userAgent().toLatin1() );
|
||||
}
|
||||
|
6
3rdparty/libmygpo-qt/Settings.cpp
vendored
6
3rdparty/libmygpo-qt/Settings.cpp
vendored
@ -22,7 +22,7 @@
|
||||
|
||||
#include "Settings_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
@ -49,9 +49,8 @@ bool SettingsPrivate::parse( const QVariant& data )
|
||||
|
||||
bool SettingsPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
||||
@ -63,7 +62,6 @@ void SettingsPrivate::parseData()
|
||||
{
|
||||
if( m_reply->error() == QNetworkReply::NoError )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
if( parse( m_reply->readAll() ) )
|
||||
{
|
||||
emit q->finished();
|
||||
|
5
3rdparty/libmygpo-qt/TagList.cpp
vendored
5
3rdparty/libmygpo-qt/TagList.cpp
vendored
@ -22,7 +22,7 @@
|
||||
|
||||
#include "TagList_p.h"
|
||||
|
||||
#include <parser.h>
|
||||
#include "qjsonwrapper/Json.h"
|
||||
|
||||
using namespace mygpo;
|
||||
|
||||
@ -70,9 +70,8 @@ bool TagListPrivate::parse( const QVariant& data )
|
||||
|
||||
bool TagListPrivate::parse( const QByteArray& data )
|
||||
{
|
||||
QJson::Parser parser;
|
||||
bool ok;
|
||||
QVariant variant = parser.parse( data, &ok );
|
||||
QVariant variant = QJsonWrapper::parseJson( data, &ok );
|
||||
if( ok )
|
||||
{
|
||||
ok = ( parse( variant ) );
|
||||
|
3
3rdparty/libmygpo-qt/UrlBuilder.cpp
vendored
3
3rdparty/libmygpo-qt/UrlBuilder.cpp
vendored
@ -74,7 +74,8 @@ QString UrlBuilder::getPodcastSearchUrl( const QString& query, Format f )
|
||||
|
||||
QString UrlBuilder::getSubscriptionsUrl( const QString& username, const QString& device, UrlBuilder::Format f)
|
||||
{
|
||||
return s_server % QLatin1String( "/subscriptions/" ) % username % QLatin1String( "/" ) % device % getFormatExtension( f );
|
||||
QString deviceString = device.isNull() ? QString(QLatin1String("")) : (QLatin1String( "/" ) % device);
|
||||
return s_server % QLatin1String( "/subscriptions/" ) % username % deviceString % getFormatExtension( f );
|
||||
}
|
||||
|
||||
QString UrlBuilder::getTopTagsUrl( uint i )
|
||||
|
123
3rdparty/libmygpo-qt/qjsonwrapper/Json.cpp
vendored
Normal file
123
3rdparty/libmygpo-qt/qjsonwrapper/Json.cpp
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
/* Copyright 2014, Uwe L. Korn <uwelk@xhochy.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "Json.h"
|
||||
|
||||
// Qt version specific includes
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
#include <QJsonDocument>
|
||||
#include <QMetaProperty>
|
||||
#else
|
||||
#include <qjson/parser.h>
|
||||
#include <qjson/qobjecthelper.h>
|
||||
#include <qjson/serializer.h>
|
||||
#endif
|
||||
|
||||
namespace QJsonWrapper
|
||||
{
|
||||
|
||||
QVariantMap
|
||||
qobject2qvariant( const QObject* object )
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
QVariantMap map;
|
||||
if ( object == NULL )
|
||||
{
|
||||
return map;
|
||||
}
|
||||
|
||||
const QMetaObject* metaObject = object->metaObject();
|
||||
for ( int i = 0; i < metaObject->propertyCount(); ++i )
|
||||
{
|
||||
QMetaProperty metaproperty = metaObject->property( i );
|
||||
if ( metaproperty.isReadable() )
|
||||
{
|
||||
map[ QLatin1String( metaproperty.name() ) ] = object->property( metaproperty.name() );
|
||||
}
|
||||
}
|
||||
return map;
|
||||
#else
|
||||
return QJson::QObjectHelper::qobject2qvariant( object );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qvariant2qobject( const QVariantMap& variant, QObject* object )
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
for ( QVariantMap::const_iterator iter = variant.begin(); iter != variant.end(); ++iter )
|
||||
{
|
||||
QVariant property = object->property( iter.key().toLatin1() );
|
||||
Q_ASSERT( property.isValid() );
|
||||
if ( property.isValid() )
|
||||
{
|
||||
QVariant value = iter.value();
|
||||
if ( value.canConvert( property.type() ) )
|
||||
{
|
||||
value.convert( property.type() );
|
||||
object->setProperty( iter.key().toLatin1(), value );
|
||||
} else if ( QString( QLatin1String("QVariant") ).compare( QLatin1String( property.typeName() ) ) == 0 ) {
|
||||
object->setProperty( iter.key().toLatin1(), value );
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
QJson::QObjectHelper::qvariant2qobject( variant, object );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QVariant
|
||||
parseJson( const QByteArray& jsonData, bool* ok )
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
QJsonParseError error;
|
||||
QJsonDocument doc = QJsonDocument::fromJson( jsonData, &error );
|
||||
if ( ok != NULL )
|
||||
{
|
||||
*ok = ( error.error == QJsonParseError::NoError );
|
||||
}
|
||||
return doc.toVariant();
|
||||
#else
|
||||
QJson::Parser p;
|
||||
return p.parse( jsonData, ok );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QByteArray
|
||||
toJson( const QVariant &variant, bool* ok )
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
|
||||
QJsonDocument doc = QJsonDocument::fromVariant( variant );
|
||||
if ( ok != NULL )
|
||||
{
|
||||
*ok = !doc.isNull();
|
||||
}
|
||||
return doc.toJson( QJsonDocument::Compact );
|
||||
#else
|
||||
QJson::Serializer serializer;
|
||||
return serializer.serialize( variant, ok );
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
36
3rdparty/libmygpo-qt/qjsonwrapper/Json.h
vendored
Normal file
36
3rdparty/libmygpo-qt/qjsonwrapper/Json.h
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/* Copyright 2014, Uwe L. Korn <uwelk@xhochy.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef QJSONWRAPPER_JSON_H
|
||||
#define QJSONWRAPPER_JSON_H
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
namespace QJsonWrapper
|
||||
{
|
||||
QVariantMap qobject2qvariant( const QObject* object );
|
||||
void qvariant2qobject( const QVariantMap& variant, QObject* object );
|
||||
QVariant parseJson( const QByteArray& jsonData, bool* ok = 0 );
|
||||
QByteArray toJson( const QVariant &variant, bool* ok = 0 );
|
||||
}
|
||||
|
||||
#endif // QJSONWRAPPER_JSON_H
|
@ -69,7 +69,7 @@ pkg_check_modules(GSTREAMER_BASE REQUIRED gstreamer-base-1.0)
|
||||
pkg_check_modules(GSTREAMER_TAG REQUIRED gstreamer-tag-1.0)
|
||||
pkg_check_modules(LIBGPOD libgpod-1.0>=0.7.92)
|
||||
pkg_check_modules(LIBMTP libmtp>=1.0)
|
||||
pkg_check_modules(LIBMYGPO_QT libmygpo-qt>=1.0.7)
|
||||
pkg_check_modules(LIBMYGPO_QT libmygpo-qt>=1.0.9)
|
||||
pkg_check_modules(LIBPULSE libpulse)
|
||||
pkg_check_modules(LIBXML libxml-2.0)
|
||||
pkg_check_modules(QJSON REQUIRED QJson)
|
||||
|
Loading…
Reference in New Issue
Block a user