1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2012 Leo Franchi <lfranchi@kde.org>
5
* Tomahawk is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* Tomahawk is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
19
#include "BinaryInstallerHelper.h"
21
#include "accounts/AccountManager.h"
22
#include "TomahawkSettingsGui.h"
23
#include <QTemporaryFile>
25
BinaryInstallerHelper::BinaryInstallerHelper( QTemporaryFile* tempFile, const QString& resolverId, bool createAccount, AtticaManager* manager )
27
, m_tempFile( tempFile )
28
, m_resolverId( resolverId )
29
, m_createAccount( createAccount )
30
, m_manager( QWeakPointer< AtticaManager >( manager ) )
32
Q_ASSERT( m_tempFile );
33
Q_ASSERT( !m_resolverId.isEmpty() );
34
Q_ASSERT( !m_manager.isNull() );
36
setProperty( "resolverid", m_resolverId );
40
BinaryInstallerHelper::~BinaryInstallerHelper()
42
Q_ASSERT( m_tempFile );
48
BinaryInstallerHelper::installSucceeded( const QString& path )
50
qDebug() << Q_FUNC_INFO << "install of binary resolver succeeded, enabling: " << path;
52
if ( m_manager.isNull() )
55
if ( m_createAccount )
57
Tomahawk::Accounts::Account* acct = Tomahawk::Accounts::AccountManager::instance()->accountFromPath( path );
59
Tomahawk::Accounts::AccountManager::instance()->addAccount( acct );
60
TomahawkSettings::instance()->addAccount( acct->accountId() );
61
Tomahawk::Accounts::AccountManager::instance()->enableAccount( acct );
64
m_manager.data()->m_resolverStates[ m_resolverId ].scriptPath = path;
65
m_manager.data()->m_resolverStates[ m_resolverId ].state = AtticaManager::Installed;
67
TomahawkSettingsGui::instanceGui()->setAtticaResolverStates( m_manager.data()->m_resolverStates );
68
emit m_manager.data()->resolverInstalled( m_resolverId );
69
emit m_manager.data()->resolverStateChanged( m_resolverId );
73
void BinaryInstallerHelper::installFailed()
75
qDebug() << Q_FUNC_INFO << "install failed";
77
if ( m_manager.isNull() )
80
m_manager.data()->resolverInstallationFailed( m_resolverId );