mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Move BinaryInstallerHelper into its own file
This commit is contained in:
@@ -34,75 +34,13 @@
|
|||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "accounts/ResolverAccount.h"
|
#include "accounts/ResolverAccount.h"
|
||||||
#include "accounts/AccountManager.h"
|
#include "accounts/AccountManager.h"
|
||||||
|
#include "utils/BinaryInstallerHelper.h"
|
||||||
|
|
||||||
using namespace Attica;
|
using namespace Attica;
|
||||||
|
|
||||||
AtticaManager* AtticaManager::s_instance = 0;
|
AtticaManager* AtticaManager::s_instance = 0;
|
||||||
|
|
||||||
|
|
||||||
class BinaryInstallerHelper : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit BinaryInstallerHelper( const QString& resolverId, bool createAccount, AtticaManager* manager)
|
|
||||||
: QObject( manager )
|
|
||||||
, m_manager( QWeakPointer< AtticaManager >( manager ) )
|
|
||||||
, m_resolverId( resolverId )
|
|
||||||
, m_createAccount( createAccount )
|
|
||||||
{
|
|
||||||
Q_ASSERT( !m_resolverId.isEmpty() );
|
|
||||||
Q_ASSERT( !m_manager.isNull() );
|
|
||||||
|
|
||||||
setProperty( "resolverid", m_resolverId );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~BinaryInstallerHelper() {}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void installSucceeded( const QString& path )
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO << "install of binary resolver succeeded, enabling: " << path;
|
|
||||||
|
|
||||||
if ( m_manager.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( m_createAccount )
|
|
||||||
{
|
|
||||||
Tomahawk::Accounts::Account* acct = Tomahawk::Accounts::AccountManager::instance()->accountFromPath( path );
|
|
||||||
|
|
||||||
Tomahawk::Accounts::AccountManager::instance()->addAccount( acct );
|
|
||||||
TomahawkSettings::instance()->addAccount( acct->accountId() );
|
|
||||||
Tomahawk::Accounts::AccountManager::instance()->enableAccount( acct );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_manager.data()->m_resolverStates[ m_resolverId ].scriptPath = path;
|
|
||||||
m_manager.data()->m_resolverStates[ m_resolverId ].state = AtticaManager::Installed;
|
|
||||||
|
|
||||||
TomahawkSettingsGui::instanceGui()->setAtticaResolverStates( m_manager.data()->m_resolverStates );
|
|
||||||
emit m_manager.data()->resolverInstalled( m_resolverId );
|
|
||||||
emit m_manager.data()->resolverStateChanged( m_resolverId );
|
|
||||||
|
|
||||||
deleteLater();
|
|
||||||
}
|
|
||||||
void installFailed()
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO << "install failed";
|
|
||||||
|
|
||||||
if ( m_manager.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_manager.data()->resolverInstallationFailed( m_resolverId );
|
|
||||||
|
|
||||||
deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_resolverId;
|
|
||||||
bool m_createAccount;
|
|
||||||
QWeakPointer<AtticaManager> m_manager;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
AtticaManager::AtticaManager( QObject* parent )
|
AtticaManager::AtticaManager( QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, m_resolverJobsLoaded( 0 )
|
, m_resolverJobsLoaded( 0 )
|
||||||
@@ -714,5 +652,3 @@ AtticaManager::doResolverRemove( const QString& id ) const
|
|||||||
|
|
||||||
TomahawkUtils::removeDirectory( resolverDir.absolutePath() );
|
TomahawkUtils::removeDirectory( resolverDir.absolutePath() );
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "AtticaManager.moc"
|
|
||||||
|
@@ -123,6 +123,7 @@ set( libGuiSources
|
|||||||
utils/PixmapDelegateFader.cpp
|
utils/PixmapDelegateFader.cpp
|
||||||
utils/SmartPointerList.h
|
utils/SmartPointerList.h
|
||||||
utils/AnimatedSpinner.cpp
|
utils/AnimatedSpinner.cpp
|
||||||
|
utils/BinaryInstallerHelper.cpp
|
||||||
|
|
||||||
widgets/AnimatedCounterLabel.cpp
|
widgets/AnimatedCounterLabel.cpp
|
||||||
widgets/CheckDirTree.cpp
|
widgets/CheckDirTree.cpp
|
||||||
|
73
src/libtomahawk/utils/BinaryInstallerHelper.cpp
Normal file
73
src/libtomahawk/utils/BinaryInstallerHelper.cpp
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2012 Leo Franchi <lfranchi@kde.org>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "BinaryInstallerHelper.h"
|
||||||
|
|
||||||
|
#include "accounts/AccountManager.h"
|
||||||
|
#include "TomahawkSettingsGui.h"
|
||||||
|
|
||||||
|
BinaryInstallerHelper::BinaryInstallerHelper( const QString& resolverId, bool createAccount, AtticaManager* manager )
|
||||||
|
: QObject( manager )
|
||||||
|
, m_manager( QWeakPointer< AtticaManager >( manager ) )
|
||||||
|
, m_resolverId( resolverId )
|
||||||
|
, m_createAccount( createAccount )
|
||||||
|
{
|
||||||
|
Q_ASSERT( !m_resolverId.isEmpty() );
|
||||||
|
Q_ASSERT( !m_manager.isNull() );
|
||||||
|
|
||||||
|
setProperty( "resolverid", m_resolverId );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BinaryInstallerHelper::installSucceeded( const QString& path )
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << "install of binary resolver succeeded, enabling: " << path;
|
||||||
|
|
||||||
|
if ( m_manager.isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( m_createAccount )
|
||||||
|
{
|
||||||
|
Tomahawk::Accounts::Account* acct = Tomahawk::Accounts::AccountManager::instance()->accountFromPath( path );
|
||||||
|
|
||||||
|
Tomahawk::Accounts::AccountManager::instance()->addAccount( acct );
|
||||||
|
TomahawkSettings::instance()->addAccount( acct->accountId() );
|
||||||
|
Tomahawk::Accounts::AccountManager::instance()->enableAccount( acct );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_manager.data()->m_resolverStates[ m_resolverId ].scriptPath = path;
|
||||||
|
m_manager.data()->m_resolverStates[ m_resolverId ].state = AtticaManager::Installed;
|
||||||
|
|
||||||
|
TomahawkSettingsGui::instanceGui()->setAtticaResolverStates( m_manager.data()->m_resolverStates );
|
||||||
|
emit m_manager.data()->resolverInstalled( m_resolverId );
|
||||||
|
emit m_manager.data()->resolverStateChanged( m_resolverId );
|
||||||
|
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
void BinaryInstallerHelper::installFailed()
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << "install failed";
|
||||||
|
|
||||||
|
if ( m_manager.isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_manager.data()->resolverInstallationFailed( m_resolverId );
|
||||||
|
|
||||||
|
deleteLater();
|
||||||
|
}
|
43
src/libtomahawk/utils/BinaryInstallerHelper.h
Normal file
43
src/libtomahawk/utils/BinaryInstallerHelper.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2012 Leo Franchi <lfranchi@kde.org>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef BINARY_INSTALLER_HELPER
|
||||||
|
#define BINARY_INSTALLER_HELPER
|
||||||
|
|
||||||
|
#include "AtticaManager.h"
|
||||||
|
|
||||||
|
#include <QWeakPointer>
|
||||||
|
|
||||||
|
class BinaryInstallerHelper : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit BinaryInstallerHelper( const QString& resolverId, bool createAccount, AtticaManager* manager );
|
||||||
|
|
||||||
|
virtual ~BinaryInstallerHelper() {}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void installSucceeded( const QString& path );
|
||||||
|
void installFailed();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_resolverId;
|
||||||
|
bool m_createAccount;
|
||||||
|
QWeakPointer<AtticaManager> m_manager;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user