/usr/include/libtomahawk/accounts/Account.h is in libtomahawk-dev 0.8.4+dfsg1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2013, Teo Mrnjavac <teo@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 ACCOUNT_H
#define ACCOUNT_H
#include "Typedefs.h"
#include "DllMacro.h"
#include <QObject>
#include <QVariantMap>
#include <QWidget>
#include <QIcon>
#include <QString>
#include <QUuid>
#include <QMutex>
class SipPlugin;
class AccountConfigWidget;
namespace Tomahawk
{
namespace Accounts
{
class ConfigStorage;
enum AccountType
{
NoType = 0x00,
InfoType = 0x01,
SipType = 0x02,
ResolverType = 0x04,
StatusPushType = 0x08
};
DLLEXPORT QString accountTypeToString( AccountType type );
Q_DECLARE_FLAGS( AccountTypes, AccountType )
inline QString generateId( const QString& factoryId )
{
QString uniq = QUuid::createUuid().toString().mid( 1, 8 );
return factoryId + "_" + uniq;
}
class DLLEXPORT Account : public QObject
{
Q_OBJECT
public:
struct Configuration
{
QString accountFriendlyName;
bool enabled;
QVariantHash configuration;
QVariantMap acl;
QStringList types;
QVariantMap credentials;
};
enum AuthErrorCode { AuthError, ConnectionError };
enum ConnectionState { Disconnected, Connecting, Connected, Disconnecting };
explicit Account( const QString& accountId );
virtual ~Account();
QString accountServiceName() const { QMutexLocker locker( &m_mutex ); return m_accountServiceName; } // e.g. "Twitter", "Last.fm"
QString accountFriendlyName() const { QMutexLocker locker( &m_mutex ); return m_cfg.accountFriendlyName; } // e.g. screen name on the service, JID, etc.
bool enabled() const { QMutexLocker locker( &m_mutex ); return m_cfg.enabled; }
QString accountId() const { QMutexLocker locker( &m_mutex ); return m_accountId; }
QVariantHash configuration() const { QMutexLocker locker( &m_mutex ); return m_cfg.configuration; }
/**
* Configuration widgets can have a "dataError( bool )" signal to enable/disable the OK button in their wrapper dialogs.
*/
virtual AccountConfigWidget* configurationWidget() = 0;
virtual QWidget* aboutWidget() { return 0; }
virtual QWidget* aclWidget() = 0;
virtual QPixmap icon() const = 0;
virtual QString description() const { return QString(); }
virtual QString author() const { return QString(); }
virtual QString version() const { return QString(); }
virtual void saveConfig() {} // called when the widget has been edited. save values from config widget, call sync() to write to disk account generic settings
QVariantMap credentials() const { QMutexLocker locker( &m_mutex ); return m_cfg.credentials; }
QVariantMap acl() const { QMutexLocker locker( &m_mutex ); return m_cfg.acl; }
virtual ConnectionState connectionState() const = 0;
virtual bool isAuthenticated() const = 0;
virtual QString errorMessage() const { QMutexLocker locker( &m_mutex ); return m_cachedError; }
virtual Tomahawk::InfoSystem::InfoPluginPtr infoPlugin() = 0;
virtual SipPlugin* sipPlugin( bool create = true ) = 0;
// Some accounts cannot be enabled if authentication fails. Return true after failing to authenticate
// if this is the case, and the account will not be enabled
virtual bool preventEnabling() const { return false; }
AccountTypes types() const;
void setAccountServiceName( const QString &serviceName ) { QMutexLocker locker( &m_mutex ); m_accountServiceName = serviceName; }
void setAccountFriendlyName( const QString &friendlyName ) { QMutexLocker locker( &m_mutex ); m_cfg.accountFriendlyName = friendlyName; }
void setEnabled( bool enabled ) { QMutexLocker locker( &m_mutex ); m_cfg.enabled = enabled; }
void setAccountId( const QString &accountId ) { QMutexLocker locker( &m_mutex ); m_accountId = accountId; }
void setCredentials( const QVariantMap &credentialHash ) { QMutexLocker locker( &m_mutex ); m_cfg.credentials = credentialHash; }
void setConfiguration( const QVariantHash &configuration ) { QMutexLocker locker( &m_mutex ); m_cfg.configuration = configuration; }
void setAcl( const QVariantMap &acl ) { QMutexLocker locker( &m_mutex ); m_cfg.acl = acl; }
void setTypes( AccountTypes types );
void sync() { QMutexLocker locker( &m_mutex ); syncConfig(); }
/**
* Removes all the settings held in the config file for this account instance
*
* Re-implement if you have saved additional files or config settings outside the built-in ones
*/
virtual void removeFromConfig();
public slots:
virtual void authenticate() = 0;
virtual void deauthenticate() = 0;
signals:
void error( int errorId, const QString& errorStr );
void connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState state );
void configurationChanged();
protected:
virtual void loadFromConfig( const QString &accountId );
virtual void syncConfig();
private slots:
void onConnectionStateChanged( Tomahawk::Accounts::Account::ConnectionState );
void onError( int, const QString& );
private:
QString m_accountServiceName;
QString m_cachedError;
QString m_accountId;
mutable QMutex m_mutex;
Account::Configuration m_cfg;
};
class DLLEXPORT AccountFactory : public QObject
{
Q_OBJECT
public:
AccountFactory() {}
virtual ~AccountFactory() {}
// display name for plugin
virtual QString prettyName() const = 0;
// internal name
virtual QString factoryId() const = 0;
// description to be shown when user views a list of account types
virtual QString description() const = 0;
// if the user can create multiple
virtual bool isUnique() const { return false; }
virtual QPixmap icon() const { return QPixmap(); }
virtual bool allowUserCreation() const { return true; }
// What are the supported types for accounts this factory creates?
virtual AccountTypes types() const = 0;
virtual Account* createAccount( const QString& accountId = QString() ) = 0;
/// If this resolver type accepts this path on disk (For general and special resolver accounts)
virtual bool acceptsPath( const QString& ) const { return false; }
virtual Account* createFromPath( const QString& ) { return 0; }
};
};
};
Q_DECLARE_INTERFACE( Tomahawk::Accounts::AccountFactory, "tomahawk.AccountFactory/1.0" )
Q_DECLARE_METATYPE( Tomahawk::Accounts::Account* )
Q_DECLARE_METATYPE( QList< Tomahawk::Accounts::Account* > )
Q_DECLARE_METATYPE( Tomahawk::Accounts::AccountTypes )
#endif
|