1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-08 23:26:40 +02:00

Rename Tomahawk::ACL -> Tomahawk::ACLStatus

This commit is contained in:
Uwe L. Korn
2013-06-15 22:01:20 +02:00
parent 9e6263856d
commit eeab7332ad
12 changed files with 43 additions and 43 deletions

View File

@@ -66,7 +66,7 @@ QDataStream& operator>>( QDataStream &in, ACLRegistry::User &user )
} }
int aclIn; int aclIn;
in >> aclIn; in >> aclIn;
user.acl = (Tomahawk::ACL::Type)( aclIn ); user.acl = (Tomahawk::ACLStatus::Type)( aclIn );
} }
return in; return in;
} }
@@ -91,7 +91,7 @@ ACLRegistry::setInstance( ACLRegistry* instance )
ACLRegistry::ACLRegistry( QObject* parent ) ACLRegistry::ACLRegistry( QObject* parent )
: QObject( parent ) : QObject( parent )
{ {
qRegisterMetaType< Tomahawk::ACL::Type >( "Tomahawk::ACL::Type" ); qRegisterMetaType< Tomahawk::ACLStatus::Type >( "Tomahawk::ACLStatus::Type" );
qRegisterMetaType< ACLRegistry::User >( "ACLRegistry::User" ); qRegisterMetaType< ACLRegistry::User >( "ACLRegistry::User" );
qRegisterMetaTypeStreamOperators< ACLRegistry::User >( "ACLRegistry::User" ); qRegisterMetaTypeStreamOperators< ACLRegistry::User >( "ACLRegistry::User" );
} }

View File

@@ -49,20 +49,20 @@ public:
QString friendlyName; QString friendlyName;
QStringList knownDbids; QStringList knownDbids;
QStringList knownAccountIds; QStringList knownAccountIds;
Tomahawk::ACL::Type acl; Tomahawk::ACLStatus::Type acl;
User() User()
: uuid( QUuid::createUuid().toString() ) : uuid( QUuid::createUuid().toString() )
, friendlyName() , friendlyName()
, knownDbids() , knownDbids()
, knownAccountIds() , knownAccountIds()
, acl( Tomahawk::ACL::NotFound ) , acl( Tomahawk::ACLStatus::NotFound )
{} {}
~User() ~User()
{} {}
User( QString p_uuid, QString p_friendlyName, QStringList p_knownDbids, QStringList p_knownAccountIds, Tomahawk::ACL::Type p_acl ) User( QString p_uuid, QString p_friendlyName, QStringList p_knownDbids, QStringList p_knownAccountIds, Tomahawk::ACLStatus::Type p_acl )
: uuid( p_uuid ) : uuid( p_uuid )
, friendlyName( p_friendlyName ) , friendlyName( p_friendlyName )
, knownDbids( p_knownDbids ) , knownDbids( p_knownDbids )
@@ -83,7 +83,7 @@ public:
virtual ~ACLRegistry(); virtual ~ACLRegistry();
signals: signals:
void aclResult( QString nodeid, QString username, Tomahawk::ACL::Type peerStatus ); void aclResult( QString nodeid, QString username, Tomahawk::ACLStatus::Type peerStatus );
public slots: public slots:
/** /**
@@ -92,9 +92,9 @@ public slots:
* @param dbid DBID of peer * @param dbid DBID of peer
* @param globalType Global ACL to store if peer not found; if ACLRegistry::NotFound, does not store the peer Defaults to ACLRegistry::NotFound. * @param globalType Global ACL to store if peer not found; if ACLRegistry::NotFound, does not store the peer Defaults to ACLRegistry::NotFound.
* @param username If not empty, will store the given username along with the new ACL value. Defaults to QString(). * @param username If not empty, will store the given username along with the new ACL value. Defaults to QString().
* @return Tomahawk::ACL::Type * @return Tomahawk::ACLStatus::Type
**/ **/
virtual Tomahawk::ACL::Type isAuthorizedUser( const QString &dbid, const QString &username, Tomahawk::ACL::Type globalType = Tomahawk::ACL::NotFound, bool skipEmission = false ) = 0; virtual Tomahawk::ACLStatus::Type isAuthorizedUser( const QString &dbid, const QString &username, Tomahawk::ACLStatus::Type globalType = Tomahawk::ACLStatus::NotFound, bool skipEmission = false ) = 0;
virtual void wipeEntries(); virtual void wipeEntries();
protected: protected:

View File

@@ -80,7 +80,7 @@ namespace Tomahawk
typedef QString QID; //query id typedef QString QID; //query id
typedef QString RID; //result id typedef QString RID; //result id
namespace ACL { namespace ACLStatus {
enum Type { enum Type {
NotFound = 0, NotFound = 0,
Deny = 1, Deny = 1,
@@ -260,6 +260,6 @@ inline static QString uuid()
Q_DECLARE_METATYPE( QModelIndex ) Q_DECLARE_METATYPE( QModelIndex )
Q_DECLARE_METATYPE( QPersistentModelIndex ) Q_DECLARE_METATYPE( QPersistentModelIndex )
Q_DECLARE_METATYPE( QNetworkReply* ) Q_DECLARE_METATYPE( QNetworkReply* )
Q_DECLARE_METATYPE( Tomahawk::ACL::Type ) Q_DECLARE_METATYPE( Tomahawk::ACLStatus::Type )
#endif // TYPEDEFS_H #endif // TYPEDEFS_H

View File

@@ -146,9 +146,9 @@ ACLJobDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QSt
{ {
QMouseEvent* me = static_cast< QMouseEvent* >( event ); QMouseEvent* me = static_cast< QMouseEvent* >( event );
if ( m_savedAcceptRect.contains( me->pos() ) ) if ( m_savedAcceptRect.contains( me->pos() ) )
emit aclResult( Tomahawk::ACL::Stream ); emit aclResult( Tomahawk::ACLStatus::Stream );
else if ( m_savedDenyRect.contains( me->pos() ) ) else if ( m_savedDenyRect.contains( me->pos() ) )
emit aclResult( Tomahawk::ACL::Deny ); emit aclResult( Tomahawk::ACLStatus::Deny );
return true; return true;
} }
@@ -195,7 +195,7 @@ ACLJobDelegate::emitSizeHintChanged( const QModelIndex& index )
void void
ACLJobItem::aclResult( Tomahawk::ACL::Type result ) ACLJobItem::aclResult( Tomahawk::ACLStatus::Type result )
{ {
tLog() << Q_FUNC_INFO; tLog() << Q_FUNC_INFO;
m_user.acl = result; m_user.acl = result;

View File

@@ -43,7 +43,7 @@ public:
signals: signals:
void update( const QModelIndex& idx ); void update( const QModelIndex& idx );
void aclResult( Tomahawk::ACL::Type result ); void aclResult( Tomahawk::ACLStatus::Type result );
protected: protected:
virtual bool editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index ); virtual bool editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index );
@@ -84,7 +84,7 @@ signals:
void userDecision( ACLRegistry::User user ); void userDecision( ACLRegistry::User user );
public slots: public slots:
void aclResult( Tomahawk::ACL::Type result ); void aclResult( Tomahawk::ACLStatus::Type result );
private: private:
QStyledItemDelegate* m_delegate; QStyledItemDelegate* m_delegate;

View File

@@ -104,7 +104,7 @@ JobStatusView::customDelegateJobInserted( int row, JobStatusItem* item )
if ( delegate ) if ( delegate )
{ {
connect( delegate, SIGNAL( update( const QModelIndex& ) ), m_view, SLOT( update( const QModelIndex & ) ) ); connect( delegate, SIGNAL( update( const QModelIndex& ) ), m_view, SLOT( update( const QModelIndex & ) ) );
connect( delegate, SIGNAL( aclResult( Tomahawk::ACL::Type ) ), item, SLOT( aclResult( Tomahawk::ACL::Type ) ) ); connect( delegate, SIGNAL( aclResult( Tomahawk::ACLStatus::Type ) ), item, SLOT( aclResult( Tomahawk::ACLStatus::Type ) ) );
delegate->emitSizeHintChanged( m_model->index( row, 0 ) ); delegate->emitSizeHintChanged( m_model->index( row, 0 ) );
} }
else else

View File

@@ -317,10 +317,10 @@ Connection::checkACL()
} }
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Checking ACL for" << name(); tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Checking ACL for" << name();
connect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACL::Type ) ), connect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACLStatus::Type ) ),
this, SLOT( checkACLResult( QString, QString, Tomahawk::ACL::Type ) ), this, SLOT( checkACLResult( QString, QString, Tomahawk::ACLStatus::Type ) ),
Qt::QueuedConnection ); Qt::QueuedConnection );
QMetaObject::invokeMethod( ACLRegistry::instance(), "isAuthorizedUser", Qt::QueuedConnection, Q_ARG( QString, d_func()->nodeid ), Q_ARG( QString, bareName() ), Q_ARG( Tomahawk::ACL::Type, Tomahawk::ACL::NotFound ) ); QMetaObject::invokeMethod( ACLRegistry::instance(), "isAuthorizedUser", Qt::QueuedConnection, Q_ARG( QString, d_func()->nodeid ), Q_ARG( QString, bareName() ), Q_ARG( Tomahawk::ACLStatus::Type, Tomahawk::ACLStatus::NotFound ) );
} }
@@ -331,7 +331,7 @@ Connection::bareName() const
} }
void void
Connection::checkACLResult( const QString &nodeid, const QString &username, Tomahawk::ACL::Type peerStatus ) Connection::checkACLResult( const QString &nodeid, const QString &username, Tomahawk::ACLStatus::Type peerStatus )
{ {
if ( nodeid != d_func()->nodeid ) if ( nodeid != d_func()->nodeid )
{ {
@@ -344,9 +344,9 @@ Connection::checkACLResult( const QString &nodeid, const QString &username, Toma
return; return;
} }
disconnect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACL::Type ) ) ); disconnect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACLStatus::Type ) ) );
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << QString( "ACL status for user %1 is" ).arg( username ) << peerStatus; tDebug( LOGVERBOSE ) << Q_FUNC_INFO << QString( "ACL status for user %1 is" ).arg( username ) << peerStatus;
if ( peerStatus == Tomahawk::ACL::Stream ) if ( peerStatus == Tomahawk::ACLStatus::Stream )
{ {
QTimer::singleShot( 0, this, SLOT( doSetup() ) ); QTimer::singleShot( 0, this, SLOT( doSetup() ) );
return; return;

View File

@@ -116,7 +116,7 @@ private slots:
void readyRead(); void readyRead();
void doSetup(); void doSetup();
void checkACL(); void checkACL();
void checkACLResult( const QString &nodeid, const QString &username, Tomahawk::ACL::Type peerStatus ); void checkACLResult( const QString &nodeid, const QString &username, Tomahawk::ACLStatus::Type peerStatus );
void bytesWritten( qint64 ); void bytesWritten( qint64 );
void calcStats(); void calcStats();

View File

@@ -211,8 +211,8 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
break; break;
} }
connect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACL::Type ) ), connect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACLStatus::Type ) ),
this, SLOT( checkACLResult( QString, QString, Tomahawk::ACL::Type ) ), this, SLOT( checkACLResult( QString, QString, Tomahawk::ACLStatus::Type ) ),
Qt::QueuedConnection ); Qt::QueuedConnection );
return true; return true;
@@ -917,7 +917,7 @@ Servent::socketError( QAbstractSocket::SocketError e )
void void
Servent::checkACLResult( const QString& nodeid, const QString& username, Tomahawk::ACL::Type peerStatus ) Servent::checkACLResult( const QString& nodeid, const QString& username, Tomahawk::ACLStatus::Type peerStatus )
{ {
if ( !d_func()->queuedForACLResult.contains( username ) ) if ( !d_func()->queuedForACLResult.contains( username ) )
@@ -931,7 +931,7 @@ Servent::checkACLResult( const QString& nodeid, const QString& username, Tomahaw
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << QString( "ACL status for user %1 is" ).arg( username ) << peerStatus; tDebug( LOGVERBOSE ) << Q_FUNC_INFO << QString( "ACL status for user %1 is" ).arg( username ) << peerStatus;
QSet<Tomahawk::peerinfo_ptr> peerInfos = d_func()->queuedForACLResult.value( username ).value( nodeid ); QSet<Tomahawk::peerinfo_ptr> peerInfos = d_func()->queuedForACLResult.value( username ).value( nodeid );
if ( peerStatus == Tomahawk::ACL::Stream ) if ( peerStatus == Tomahawk::ACLStatus::Stream )
{ {
foreach ( Tomahawk::peerinfo_ptr peerInfo, peerInfos ) foreach ( Tomahawk::peerinfo_ptr peerInfo, peerInfos )
{ {

View File

@@ -168,7 +168,7 @@ private slots:
void deleteLazyOffer( const QString& key ); void deleteLazyOffer( const QString& key );
void readyRead(); void readyRead();
void socketError( QAbstractSocket::SocketError e ); void socketError( QAbstractSocket::SocketError e );
void checkACLResult( const QString &nodeid, const QString &username, Tomahawk::ACL::Type peerStatus ); void checkACLResult( const QString &nodeid, const QString &username, Tomahawk::ACLStatus::Type peerStatus );
Connection* claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer = QHostAddress::Any ); Connection* claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer = QHostAddress::Any );

View File

@@ -53,14 +53,14 @@ ACLRegistryImpl::~ACLRegistryImpl()
} }
Tomahawk::ACL::Type Tomahawk::ACLStatus::Type
ACLRegistryImpl::isAuthorizedUser( const QString& dbid, const QString &username, Tomahawk::ACL::Type globalType, bool skipEmission ) ACLRegistryImpl::isAuthorizedUser( const QString& dbid, const QString &username, Tomahawk::ACLStatus::Type globalType, bool skipEmission )
{ {
if ( QThread::currentThread() != TOMAHAWK_APPLICATION::instance()->thread() ) if ( QThread::currentThread() != TOMAHAWK_APPLICATION::instance()->thread() )
{ {
if ( !skipEmission ) if ( !skipEmission )
QMetaObject::invokeMethod( this, "isAuthorizedUser", Qt::QueuedConnection, Q_ARG( const QString&, dbid ), Q_ARG( const QString &, username ), Q_ARG( Tomahawk::ACL::Type, globalType ), Q_ARG( bool, skipEmission ) ); QMetaObject::invokeMethod( this, "isAuthorizedUser", Qt::QueuedConnection, Q_ARG( const QString&, dbid ), Q_ARG( const QString &, username ), Q_ARG( Tomahawk::ACLStatus::Type, globalType ), Q_ARG( bool, skipEmission ) );
return Tomahawk::ACL::NotFound; return Tomahawk::ACLStatus::NotFound;
} }
#ifndef ENABLE_HEADLESS #ifndef ENABLE_HEADLESS
@@ -77,8 +77,8 @@ ACLRegistryImpl::isAuthorizedUser( const QString& dbid, const QString &username,
if ( account->accountFriendlyName() == username ) if ( account->accountFriendlyName() == username )
{ {
if ( !skipEmission ) if ( !skipEmission )
emit aclResult( dbid, username, Tomahawk::ACL::Stream ); emit aclResult( dbid, username, Tomahawk::ACLStatus::Stream );
return Tomahawk::ACL::Stream; return Tomahawk::ACLStatus::Stream;
} }
} }
} }
@@ -119,24 +119,24 @@ ACLRegistryImpl::isAuthorizedUser( const QString& dbid, const QString &username,
} }
if ( skipEmission ) if ( skipEmission )
return Tomahawk::ACL::NotFound; return Tomahawk::ACLStatus::NotFound;
// User was not found, create a new user entry // User was not found, create a new user entry
ACLRegistry::User user; ACLRegistry::User user;
user.knownDbids.append( dbid ); user.knownDbids.append( dbid );
user.knownAccountIds.append( username ); user.knownAccountIds.append( username );
if ( globalType != Tomahawk::ACL::NotFound ) if ( globalType != Tomahawk::ACLStatus::NotFound )
user.acl = globalType; user.acl = globalType;
#ifdef ENABLE_HEADLESS #ifdef ENABLE_HEADLESS
user.acl = Tomahawk::ACL::Stream; user.acl = Tomahawk::ACLStatus::Stream;
#else #else
if ( !TomahawkUtils::headless() ) if ( !TomahawkUtils::headless() )
{ {
getUserDecision( user, username ); getUserDecision( user, username );
return Tomahawk::ACL::NotFound; return Tomahawk::ACLStatus::NotFound;
} }
else else
user.acl = Tomahawk::ACL::Stream; user.acl = Tomahawk::ACLStatus::Stream;
#endif #endif
m_cache.append( user ); m_cache.append( user );
save(); save();
@@ -200,8 +200,8 @@ ACLRegistryImpl::queueNextJob()
bool found = false; bool found = false;
foreach( QString dbid, user.knownDbids ) foreach( QString dbid, user.knownDbids )
{ {
Tomahawk::ACL::Type acl = isAuthorizedUser( dbid, job->username(), Tomahawk::ACL::NotFound, true ); Tomahawk::ACLStatus::Type acl = isAuthorizedUser( dbid, job->username(), Tomahawk::ACLStatus::NotFound, true );
if ( acl != Tomahawk::ACL::NotFound ) if ( acl != Tomahawk::ACLStatus::NotFound )
{ {
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Found existing acl entry for =" << user.knownAccountIds.first(); tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Found existing acl entry for =" << user.knownAccountIds.first();
found = true; found = true;

View File

@@ -51,9 +51,9 @@ public slots:
* @param dbid DBID of peer * @param dbid DBID of peer
* @param globalType Global ACL to store if peer not found; if ACLRegistry::NotFound, does not store the peer Defaults to ACLRegistry::NotFound. * @param globalType Global ACL to store if peer not found; if ACLRegistry::NotFound, does not store the peer Defaults to ACLRegistry::NotFound.
* @param username If not empty, will store the given username along with the new ACL value. Defaults to QString(). * @param username If not empty, will store the given username along with the new ACL value. Defaults to QString().
* @return Tomahawk::ACL::Type * @return Tomahawk::ACLStatus::Type
**/ **/
virtual Tomahawk::ACL::Type isAuthorizedUser( const QString &dbid, const QString &username, Tomahawk::ACL::Type globalType = Tomahawk::ACL::NotFound, bool skipEmission = false ); virtual Tomahawk::ACLStatus::Type isAuthorizedUser( const QString &dbid, const QString &username, Tomahawk::ACLStatus::Type globalType = Tomahawk::ACLStatus::NotFound, bool skipEmission = false );
virtual void wipeEntries(); virtual void wipeEntries();
protected: protected: