mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 09:04:33 +02:00
Emit a failed signal if there's no internet, so things that depend on AtticaManager move forward
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#include "accounts/ResolverAccount.h"
|
#include "accounts/ResolverAccount.h"
|
||||||
#include "accounts/AccountManager.h"
|
#include "accounts/AccountManager.h"
|
||||||
#include "utils/BinaryInstallerHelper.h"
|
#include "utils/BinaryInstallerHelper.h"
|
||||||
|
#include "utils/Closure.h"
|
||||||
|
|
||||||
using namespace Attica;
|
using namespace Attica;
|
||||||
|
|
||||||
@@ -48,7 +49,11 @@ AtticaManager::AtticaManager( QObject* parent )
|
|||||||
connect( &m_manager, SIGNAL( providerAdded( Attica::Provider ) ), this, SLOT( providerAdded( Attica::Provider ) ) );
|
connect( &m_manager, SIGNAL( providerAdded( Attica::Provider ) ), this, SLOT( providerAdded( Attica::Provider ) ) );
|
||||||
|
|
||||||
// resolvers
|
// resolvers
|
||||||
m_manager.addProviderFile( QUrl( "http://bakery.tomahawk-player.org/resolvers/providers.xml" ) );
|
// m_manager.addProviderFile( QUrl( "http://bakery.tomahawk-player.org/resolvers/providers.xml" ) );
|
||||||
|
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( QUrl( "http://bakery.tomahawk-player.org/resolvers/providers.xml" ) ) );
|
||||||
|
NewClosure( reply, SIGNAL( finished() ), this, SLOT( providerFetched( QNetworkReply* ) ), reply );
|
||||||
|
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( providerError( QNetworkReply::NetworkError ) ) );
|
||||||
|
|
||||||
// m_manager.addProviderFile( QUrl( "http://lycophron/resolvers/providers.xml" ) );
|
// m_manager.addProviderFile( QUrl( "http://lycophron/resolvers/providers.xml" ) );
|
||||||
|
|
||||||
qRegisterMetaType< Attica::Content >( "Attica::Content" );
|
qRegisterMetaType< Attica::Content >( "Attica::Content" );
|
||||||
@@ -243,6 +248,25 @@ AtticaManager::resolverData(const QString &atticaId) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AtticaManager::providerError( QNetworkReply::NetworkError err )
|
||||||
|
{
|
||||||
|
// So those who care know
|
||||||
|
emit resolversLoaded( Content::List() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AtticaManager::providerFetched( QNetworkReply* reply )
|
||||||
|
{
|
||||||
|
Q_ASSERT( reply );
|
||||||
|
if ( !reply )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_manager.addProviderFromXml( reply->readAll() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AtticaManager::providerAdded( const Provider& provider )
|
AtticaManager::providerAdded( const Provider& provider )
|
||||||
{
|
{
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
#include "accounts/Account.h"
|
#include "accounts/Account.h"
|
||||||
@@ -124,7 +125,10 @@ signals:
|
|||||||
void resolverInstallationFailed( const QString& resolverId );
|
void resolverInstallationFailed( const QString& resolverId );
|
||||||
|
|
||||||
void startedInstalling( const QString& resolverId );
|
void startedInstalling( const QString& resolverId );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void providerFetched( QNetworkReply* reply );
|
||||||
|
void providerError( QNetworkReply::NetworkError );
|
||||||
void providerAdded( const Attica::Provider& );
|
void providerAdded( const Attica::Provider& );
|
||||||
void categoriesReturned( Attica::BaseJob* );
|
void categoriesReturned( Attica::BaseJob* );
|
||||||
void resolversList( Attica::BaseJob* );
|
void resolversList( Attica::BaseJob* );
|
||||||
@@ -139,7 +143,6 @@ private slots:
|
|||||||
void syncServerData();
|
void syncServerData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString extractPayload( const QString& filename, const QString& resolverId ) const;
|
|
||||||
void doResolverRemove( const QString& id ) const;
|
void doResolverRemove( const QString& id ) const;
|
||||||
void doInstallResolver( const Attica::Content& resolver, bool autoCreate, Tomahawk::Accounts::AtticaResolverAccount* handler );
|
void doInstallResolver( const Attica::Content& resolver, bool autoCreate, Tomahawk::Accounts::AtticaResolverAccount* handler );
|
||||||
|
|
||||||
@@ -171,5 +174,5 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( Attica::Content );
|
Q_DECLARE_METATYPE( Attica::Content );
|
||||||
|
Q_DECLARE_METATYPE( QNetworkReply* );
|
||||||
#endif // ATTICAMANAGER_H
|
#endif // ATTICAMANAGER_H
|
||||||
|
Reference in New Issue
Block a user