From ce11d3aec3a671fdafb929c18edc949f9dc160c7 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Sat, 15 Jun 2013 20:52:43 +0200 Subject: [PATCH] Tomahawk::ACL -> Tomahawk::ACL::Type --- src/libtomahawk/AclRegistry.cpp | 4 ++-- src/libtomahawk/AclRegistry.h | 12 +++++------ src/libtomahawk/Typedefs.h | 16 ++++++++------ src/libtomahawk/jobview/AclJobItem.cpp | 6 +++--- src/libtomahawk/jobview/AclJobItem.h | 4 ++-- src/libtomahawk/jobview/JobStatusView.cpp | 2 +- src/libtomahawk/network/Connection.cpp | 12 ++++++----- src/libtomahawk/network/Connection.h | 2 +- src/libtomahawk/network/Servent.cpp | 8 ++++--- src/libtomahawk/network/Servent.h | 2 +- src/tomahawk/AclRegistryImpl.cpp | 26 +++++++++++------------ src/tomahawk/AclRegistryImpl.h | 4 ++-- 12 files changed, 52 insertions(+), 46 deletions(-) diff --git a/src/libtomahawk/AclRegistry.cpp b/src/libtomahawk/AclRegistry.cpp index 8c69e02b2..6c6486feb 100644 --- a/src/libtomahawk/AclRegistry.cpp +++ b/src/libtomahawk/AclRegistry.cpp @@ -66,7 +66,7 @@ QDataStream& operator>>( QDataStream &in, ACLRegistry::User &user ) } int aclIn; in >> aclIn; - user.acl = (Tomahawk::ACL)( aclIn ); + user.acl = (Tomahawk::ACL::Type)( aclIn ); } return in; } @@ -91,7 +91,7 @@ ACLRegistry::setInstance( ACLRegistry* instance ) ACLRegistry::ACLRegistry( QObject* parent ) : QObject( parent ) { - qRegisterMetaType< Tomahawk::ACL >( "Tomahawk::ACL" ); + qRegisterMetaType< Tomahawk::ACL::Type >( "Tomahawk::ACL::Type" ); qRegisterMetaType< ACLRegistry::User >( "ACLRegistry::User" ); qRegisterMetaTypeStreamOperators< ACLRegistry::User >( "ACLRegistry::User" ); } diff --git a/src/libtomahawk/AclRegistry.h b/src/libtomahawk/AclRegistry.h index a31dce5dd..80aee719a 100644 --- a/src/libtomahawk/AclRegistry.h +++ b/src/libtomahawk/AclRegistry.h @@ -49,20 +49,20 @@ public: QString friendlyName; QStringList knownDbids; QStringList knownAccountIds; - Tomahawk::ACL acl; + Tomahawk::ACL::Type acl; User() : uuid( QUuid::createUuid().toString() ) , friendlyName() , knownDbids() , knownAccountIds() - , acl( Tomahawk::NotFound ) + , acl( Tomahawk::ACL::NotFound ) {} ~User() {} - User( QString p_uuid, QString p_friendlyName, QStringList p_knownDbids, QStringList p_knownAccountIds, Tomahawk::ACL p_acl ) + User( QString p_uuid, QString p_friendlyName, QStringList p_knownDbids, QStringList p_knownAccountIds, Tomahawk::ACL::Type p_acl ) : uuid( p_uuid ) , friendlyName( p_friendlyName ) , knownDbids( p_knownDbids ) @@ -83,7 +83,7 @@ public: virtual ~ACLRegistry(); signals: - void aclResult( QString nodeid, QString username, Tomahawk::ACL peerStatus ); + void aclResult( QString nodeid, QString username, Tomahawk::ACL::Type peerStatus ); public slots: /** @@ -92,9 +92,9 @@ public slots: * @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 username If not empty, will store the given username along with the new ACL value. Defaults to QString(). - * @return Tomahawk::ACL + * @return Tomahawk::ACL::Type **/ - virtual Tomahawk::ACL isAuthorizedUser( const QString &dbid, const QString &username, Tomahawk::ACL globalType = Tomahawk::NotFound, bool skipEmission = false ) = 0; + virtual Tomahawk::ACL::Type isAuthorizedUser( const QString &dbid, const QString &username, Tomahawk::ACL::Type globalType = Tomahawk::ACL::NotFound, bool skipEmission = false ) = 0; virtual void wipeEntries(); protected: diff --git a/src/libtomahawk/Typedefs.h b/src/libtomahawk/Typedefs.h index 9c38318d6..94d2fa1d0 100644 --- a/src/libtomahawk/Typedefs.h +++ b/src/libtomahawk/Typedefs.h @@ -80,12 +80,14 @@ namespace Tomahawk typedef QString QID; //query id typedef QString RID; //result id - enum ACL { - NotFound = 0, - Deny = 1, - Read = 2, - Stream = 3 - }; + namespace ACL { + enum Type { + NotFound = 0, + Deny = 1, + Read = 2, + Stream = 3 + }; + } enum GeneratorMode { @@ -258,6 +260,6 @@ inline static QString uuid() Q_DECLARE_METATYPE( QModelIndex ) Q_DECLARE_METATYPE( QPersistentModelIndex ) Q_DECLARE_METATYPE( QNetworkReply* ) -Q_DECLARE_METATYPE( Tomahawk::ACL ) +Q_DECLARE_METATYPE( Tomahawk::ACL::Type ) #endif // TYPEDEFS_H diff --git a/src/libtomahawk/jobview/AclJobItem.cpp b/src/libtomahawk/jobview/AclJobItem.cpp index 5078df126..48be2ab18 100644 --- a/src/libtomahawk/jobview/AclJobItem.cpp +++ b/src/libtomahawk/jobview/AclJobItem.cpp @@ -146,9 +146,9 @@ ACLJobDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QSt { QMouseEvent* me = static_cast< QMouseEvent* >( event ); if ( m_savedAcceptRect.contains( me->pos() ) ) - emit aclResult( Tomahawk::Stream ); + emit aclResult( Tomahawk::ACL::Stream ); else if ( m_savedDenyRect.contains( me->pos() ) ) - emit aclResult( Tomahawk::Deny ); + emit aclResult( Tomahawk::ACL::Deny ); return true; } @@ -195,7 +195,7 @@ ACLJobDelegate::emitSizeHintChanged( const QModelIndex& index ) void -ACLJobItem::aclResult( Tomahawk::ACL result ) +ACLJobItem::aclResult( Tomahawk::ACL::Type result ) { tLog() << Q_FUNC_INFO; m_user.acl = result; diff --git a/src/libtomahawk/jobview/AclJobItem.h b/src/libtomahawk/jobview/AclJobItem.h index 22fb32d99..d1476fbc0 100644 --- a/src/libtomahawk/jobview/AclJobItem.h +++ b/src/libtomahawk/jobview/AclJobItem.h @@ -43,7 +43,7 @@ public: signals: void update( const QModelIndex& idx ); - void aclResult( Tomahawk::ACL result ); + void aclResult( Tomahawk::ACL::Type result ); protected: virtual bool editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index ); @@ -84,7 +84,7 @@ signals: void userDecision( ACLRegistry::User user ); public slots: - void aclResult( Tomahawk::ACL result ); + void aclResult( Tomahawk::ACL::Type result ); private: QStyledItemDelegate* m_delegate; diff --git a/src/libtomahawk/jobview/JobStatusView.cpp b/src/libtomahawk/jobview/JobStatusView.cpp index 8c15d3bed..afead13f8 100644 --- a/src/libtomahawk/jobview/JobStatusView.cpp +++ b/src/libtomahawk/jobview/JobStatusView.cpp @@ -104,7 +104,7 @@ JobStatusView::customDelegateJobInserted( int row, JobStatusItem* item ) if ( delegate ) { connect( delegate, SIGNAL( update( const QModelIndex& ) ), m_view, SLOT( update( const QModelIndex & ) ) ); - connect( delegate, SIGNAL( aclResult( Tomahawk::ACL ) ), item, SLOT( aclResult( Tomahawk::ACL ) ) ); + connect( delegate, SIGNAL( aclResult( Tomahawk::ACL::Type ) ), item, SLOT( aclResult( Tomahawk::ACL::Type ) ) ); delegate->emitSizeHintChanged( m_model->index( row, 0 ) ); } else diff --git a/src/libtomahawk/network/Connection.cpp b/src/libtomahawk/network/Connection.cpp index f1bdbb9e2..21d4d15ae 100644 --- a/src/libtomahawk/network/Connection.cpp +++ b/src/libtomahawk/network/Connection.cpp @@ -310,8 +310,10 @@ Connection::checkACL() } tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Checking ACL for" << name(); - connect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACL ) ), this, SLOT( checkACLResult( QString, QString, Tomahawk::ACL ) ), Qt::QueuedConnection ); - QMetaObject::invokeMethod( ACLRegistry::instance(), "isAuthorizedUser", Qt::QueuedConnection, Q_ARG( QString, d_func()->nodeid ), Q_ARG( QString, bareName() ), Q_ARG( Tomahawk::ACL, Tomahawk::NotFound ) ); + connect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACL::Type ) ), + this, SLOT( checkACLResult( QString, QString, Tomahawk::ACL::Type ) ), + 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 ) ); } @@ -322,7 +324,7 @@ Connection::bareName() const } void -Connection::checkACLResult( const QString &nodeid, const QString &username, Tomahawk::ACL peerStatus ) +Connection::checkACLResult( const QString &nodeid, const QString &username, Tomahawk::ACL::Type peerStatus ) { if ( nodeid != d_func()->nodeid ) { @@ -335,9 +337,9 @@ Connection::checkACLResult( const QString &nodeid, const QString &username, Toma return; } - disconnect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACL ) ) ); + disconnect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACL::Type ) ) ); tDebug( LOGVERBOSE ) << Q_FUNC_INFO << QString( "ACL status for user %1 is" ).arg( username ) << peerStatus; - if ( peerStatus == Tomahawk::Stream ) + if ( peerStatus == Tomahawk::ACL::Stream ) { QTimer::singleShot( 0, this, SLOT( doSetup() ) ); return; diff --git a/src/libtomahawk/network/Connection.h b/src/libtomahawk/network/Connection.h index e890208ea..6047224b9 100644 --- a/src/libtomahawk/network/Connection.h +++ b/src/libtomahawk/network/Connection.h @@ -116,7 +116,7 @@ private slots: void readyRead(); void doSetup(); void checkACL(); - void checkACLResult( const QString &nodeid, const QString &username, Tomahawk::ACL peerStatus ); + void checkACLResult( const QString &nodeid, const QString &username, Tomahawk::ACL::Type peerStatus ); void bytesWritten( qint64 ); void calcStats(); diff --git a/src/libtomahawk/network/Servent.cpp b/src/libtomahawk/network/Servent.cpp index b8632b43f..47b1c4336 100644 --- a/src/libtomahawk/network/Servent.cpp +++ b/src/libtomahawk/network/Servent.cpp @@ -211,7 +211,9 @@ Servent::startListening( QHostAddress ha, bool upnp, int port ) break; } - connect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACL ) ), this, SLOT( checkACLResult( QString, QString, Tomahawk::ACL ) ), Qt::QueuedConnection ); + connect( ACLRegistry::instance(), SIGNAL( aclResult( QString, QString, Tomahawk::ACL::Type ) ), + this, SLOT( checkACLResult( QString, QString, Tomahawk::ACL::Type ) ), + Qt::QueuedConnection ); return true; } @@ -915,7 +917,7 @@ Servent::socketError( QAbstractSocket::SocketError e ) void -Servent::checkACLResult( const QString& nodeid, const QString& username, Tomahawk::ACL peerStatus ) +Servent::checkACLResult( const QString& nodeid, const QString& username, Tomahawk::ACL::Type peerStatus ) { if ( !d_func()->queuedForACLResult.contains( username ) ) @@ -929,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; QSet peerInfos = d_func()->queuedForACLResult.value( username ).value( nodeid ); - if ( peerStatus == Tomahawk::Stream ) + if ( peerStatus == Tomahawk::ACL::Stream ) { foreach ( Tomahawk::peerinfo_ptr peerInfo, peerInfos ) { diff --git a/src/libtomahawk/network/Servent.h b/src/libtomahawk/network/Servent.h index 47612968e..53e20c415 100644 --- a/src/libtomahawk/network/Servent.h +++ b/src/libtomahawk/network/Servent.h @@ -168,7 +168,7 @@ private slots: void deleteLazyOffer( const QString& key ); void readyRead(); void socketError( QAbstractSocket::SocketError e ); - void checkACLResult( const QString &nodeid, const QString &username, Tomahawk::ACL peerStatus ); + void checkACLResult( const QString &nodeid, const QString &username, Tomahawk::ACL::Type peerStatus ); Connection* claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer = QHostAddress::Any ); diff --git a/src/tomahawk/AclRegistryImpl.cpp b/src/tomahawk/AclRegistryImpl.cpp index 5e6422d39..6dfd09bd5 100644 --- a/src/tomahawk/AclRegistryImpl.cpp +++ b/src/tomahawk/AclRegistryImpl.cpp @@ -53,14 +53,14 @@ ACLRegistryImpl::~ACLRegistryImpl() } -Tomahawk::ACL -ACLRegistryImpl::isAuthorizedUser( const QString& dbid, const QString &username, Tomahawk::ACL globalType, bool skipEmission ) +Tomahawk::ACL::Type +ACLRegistryImpl::isAuthorizedUser( const QString& dbid, const QString &username, Tomahawk::ACL::Type globalType, bool skipEmission ) { if ( QThread::currentThread() != TOMAHAWK_APPLICATION::instance()->thread() ) { if ( !skipEmission ) - QMetaObject::invokeMethod( this, "isAuthorizedUser", Qt::QueuedConnection, Q_ARG( const QString&, dbid ), Q_ARG( const QString &, username ), Q_ARG( Tomahawk::ACL, globalType ), Q_ARG( bool, skipEmission ) ); - return Tomahawk::NotFound; + 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 ) ); + return Tomahawk::ACL::NotFound; } #ifndef ENABLE_HEADLESS @@ -77,8 +77,8 @@ ACLRegistryImpl::isAuthorizedUser( const QString& dbid, const QString &username, if ( account->accountFriendlyName() == username ) { if ( !skipEmission ) - emit aclResult( dbid, username, Tomahawk::Stream ); - return Tomahawk::Stream; + emit aclResult( dbid, username, Tomahawk::ACL::Stream ); + return Tomahawk::ACL::Stream; } } } @@ -119,24 +119,24 @@ ACLRegistryImpl::isAuthorizedUser( const QString& dbid, const QString &username, } if ( skipEmission ) - return Tomahawk::NotFound; + return Tomahawk::ACL::NotFound; // User was not found, create a new user entry ACLRegistry::User user; user.knownDbids.append( dbid ); user.knownAccountIds.append( username ); - if ( globalType != Tomahawk::NotFound ) + if ( globalType != Tomahawk::ACL::NotFound ) user.acl = globalType; #ifdef ENABLE_HEADLESS - user.acl = Tomahawk::Stream; + user.acl = Tomahawk::ACL::Stream; #else if ( !TomahawkUtils::headless() ) { getUserDecision( user, username ); - return Tomahawk::NotFound; + return Tomahawk::ACL::NotFound; } else - user.acl = Tomahawk::Stream; + user.acl = Tomahawk::ACL::Stream; #endif m_cache.append( user ); save(); @@ -200,8 +200,8 @@ ACLRegistryImpl::queueNextJob() bool found = false; foreach( QString dbid, user.knownDbids ) { - Tomahawk::ACL acl = isAuthorizedUser( dbid, job->username(), Tomahawk::NotFound, true ); - if ( acl != Tomahawk::NotFound ) + Tomahawk::ACL::Type acl = isAuthorizedUser( dbid, job->username(), Tomahawk::ACL::NotFound, true ); + if ( acl != Tomahawk::ACL::NotFound ) { tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Found existing acl entry for =" << user.knownAccountIds.first(); found = true; diff --git a/src/tomahawk/AclRegistryImpl.h b/src/tomahawk/AclRegistryImpl.h index 414c0d73f..fae57c210 100644 --- a/src/tomahawk/AclRegistryImpl.h +++ b/src/tomahawk/AclRegistryImpl.h @@ -51,9 +51,9 @@ public slots: * @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 username If not empty, will store the given username along with the new ACL value. Defaults to QString(). - * @return Tomahawk::ACL + * @return Tomahawk::ACL::Type **/ - virtual Tomahawk::ACL isAuthorizedUser( const QString &dbid, const QString &username, Tomahawk::ACL globalType = Tomahawk::NotFound, bool skipEmission = false ); + virtual Tomahawk::ACL::Type isAuthorizedUser( const QString &dbid, const QString &username, Tomahawk::ACL::Type globalType = Tomahawk::ACL::NotFound, bool skipEmission = false ); virtual void wipeEntries(); protected: