From fab36b2262e75e6952069491012232e3cc877d76 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 9 Mar 2012 18:23:48 -0500 Subject: [PATCH 01/15] Use new QTweetLib 0.5 API for PIN values so leading zeros are respected Conflicts: src/accounts/twitter/tomahawkoauthtwitter.h --- src/sip/twitter/tomahawkoauthtwitter.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sip/twitter/tomahawkoauthtwitter.cpp b/src/sip/twitter/tomahawkoauthtwitter.cpp index 35cd98a9e..c70f66986 100644 --- a/src/sip/twitter/tomahawkoauthtwitter.cpp +++ b/src/sip/twitter/tomahawkoauthtwitter.cpp @@ -12,15 +12,15 @@ TomahawkOAuthTwitter::TomahawkOAuthTwitter( QNetworkAccessManager *nam, QObject* } -int +const QString TomahawkOAuthTwitter::authorizationWidget() { bool ok; - int i = QInputDialog::getInt(0, tr( "Twitter PIN" ), tr( "After authenticating on Twitter's web site,\nenter the displayed PIN number here:" ), 0, 0, 2147483647, 1, &ok); - if (ok) - return i; + const QString str = QInputDialog::getText(0, tr( "Twitter PIN" ), tr( "After authenticating on Twitter's web site,\nenter the displayed PIN number here:" ), QLineEdit::Normal, QString(), &ok); + if ( ok && !str.isEmpty() ) + return str; - return 0; + return QString(); } void From 240517b0cd95ffe658983f8c53b47182bd8afe6b Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Sun, 11 Mar 2012 18:46:00 +0100 Subject: [PATCH 02/15] Bump the required QTweetLib version --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 8ada27b9c..e554d3555 100644 --- a/README +++ b/README @@ -41,7 +41,7 @@ Dependencies Attica 0.2.0 - ftp://ftp.kde.org/pub/kde/stable/attica/ QuaZip 0.4.3 - http://quazip.sourceforge.net/ Jreen 1.0.1 - https://github.com/euroelessar/jreen - QTweetLib 0.3.0 - https://github.com/minimoog/QTweetLib + QTweetLib 0.5.0 - https://github.com/minimoog/QTweetLib Third party libraries that we ship with our source: From 18e366991199f50c22c4c910e2e621cb0979dce6 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 9 Mar 2012 17:41:38 -0500 Subject: [PATCH 03/15] Fix XMPP proxy. Make no proxy hosts static so changing it works across all threads; make a duplication method so jreen doesn't scopepointer us to death on shutdown; pass in proxyfactory to jreen. Conflicts: src/settingsdialog.cpp src/sip/jabber/jabber.cpp --- src/libtomahawk/utils/tomahawkutils.cpp | 46 +++++++++++++++++-------- src/libtomahawk/utils/tomahawkutils.h | 2 +- src/proxydialog.ui | 3 +- src/settingsdialog.cpp | 21 +++++------ src/settingsdialog.h | 4 +-- src/sip/jabber/jabber.cpp | 1 + src/tomahawkapp.cpp | 1 - 7 files changed, 46 insertions(+), 32 deletions(-) diff --git a/src/libtomahawk/utils/tomahawkutils.cpp b/src/libtomahawk/utils/tomahawkutils.cpp index d706c3232..be219786f 100644 --- a/src/libtomahawk/utils/tomahawkutils.cpp +++ b/src/libtomahawk/utils/tomahawkutils.cpp @@ -301,10 +301,11 @@ extensionToMimetype( const QString& extension ) return s_ext2mime.value( extension, "unknown" ); } +static QMutex s_noProxyHostsMutex; +static QStringList s_noProxyHosts; NetworkProxyFactory::NetworkProxyFactory( const NetworkProxyFactory& other ) { - m_noProxyHosts = QStringList( other.m_noProxyHosts ); m_proxy = QNetworkProxy( other.m_proxy ); } @@ -312,13 +313,17 @@ NetworkProxyFactory::NetworkProxyFactory( const NetworkProxyFactory& other ) QList< QNetworkProxy > NetworkProxyFactory::queryProxy( const QNetworkProxyQuery& query ) { + tDebug() << Q_FUNC_INFO << "query hostname is " << query.peerHostName(); QList< QNetworkProxy > proxies; QString hostname = query.peerHostName(); - if ( m_proxy.hostName().isEmpty() || hostname.isEmpty() || m_noProxyHosts.contains( hostname ) || TomahawkSettings::instance()->proxyType() == QNetworkProxy::NoProxy ) + s_noProxyHostsMutex.lock(); + if ( s_noProxyHosts.contains( hostname ) ) + proxies << QNetworkProxy::NoProxy << systemProxyForQuery( query ); + else if ( m_proxy.hostName().isEmpty() || hostname.isEmpty() || TomahawkSettings::instance()->proxyType() == QNetworkProxy::NoProxy ) proxies << systemProxyForQuery( query ); else proxies << m_proxy << systemProxyForQuery( query ); - + s_noProxyHostsMutex.unlock(); return proxies; } @@ -335,7 +340,9 @@ NetworkProxyFactory::setNoProxyHosts( const QStringList& hosts ) //TODO: wildcard support } tDebug() << Q_FUNC_INFO << "New no-proxy hosts:" << newList; - m_noProxyHosts = newList; + s_noProxyHostsMutex.lock(); + s_noProxyHosts = newList; + s_noProxyHostsMutex.unlock(); } @@ -357,7 +364,6 @@ NetworkProxyFactory::operator=( const NetworkProxyFactory& rhs ) if ( this != &rhs ) { m_proxy = QNetworkProxy( rhs.m_proxy ); - m_noProxyHosts = QStringList( rhs.m_noProxyHosts ); } return *this; @@ -367,7 +373,7 @@ NetworkProxyFactory::operator=( const NetworkProxyFactory& rhs ) bool NetworkProxyFactory::operator==( const NetworkProxyFactory& other ) const { tDebug() << Q_FUNC_INFO; - if ( m_noProxyHosts != other.m_noProxyHosts || m_proxy != other.m_proxy ) + if ( m_proxy != other.m_proxy ) return false; return true; @@ -378,25 +384,29 @@ static QMap< QThread*, NetworkProxyFactory* > s_threadProxyFactoryHash; static QMutex s_namAccessMutex; NetworkProxyFactory* -proxyFactory( bool noMutexLocker ) +proxyFactory( bool makeClone, bool noMutexLocker ) { // Don't lock if being called from nam() tDebug() << Q_FUNC_INFO; QMutex otherMutex; QMutexLocker locker( noMutexLocker ? &otherMutex : &s_namAccessMutex ); - if ( s_threadProxyFactoryHash.contains( QThread::currentThread() ) ) - return s_threadProxyFactoryHash[ QThread::currentThread() ]; + if ( !makeClone ) + { + if ( s_threadProxyFactoryHash.contains( QThread::currentThread() ) ) + return s_threadProxyFactoryHash[ QThread::currentThread() ]; - if ( !s_threadProxyFactoryHash.contains( TOMAHAWK_APPLICATION::instance()->thread() ) ) - return 0; + if ( !s_threadProxyFactoryHash.contains( TOMAHAWK_APPLICATION::instance()->thread() ) ) + return 0; + } // create a new proxy factory for this thread TomahawkUtils::NetworkProxyFactory *mainProxyFactory = s_threadProxyFactoryHash[ TOMAHAWK_APPLICATION::instance()->thread() ]; TomahawkUtils::NetworkProxyFactory *newProxyFactory = new TomahawkUtils::NetworkProxyFactory(); *newProxyFactory = *mainProxyFactory; - s_threadProxyFactoryHash[ QThread::currentThread() ] = newProxyFactory; + if ( !makeClone ) + s_threadProxyFactoryHash[ QThread::currentThread() ] = newProxyFactory; return newProxyFactory; } @@ -455,7 +465,7 @@ nam() newNam->setConfiguration( QNetworkConfiguration( mainNam->configuration() ) ); newNam->setNetworkAccessible( mainNam->networkAccessible() ); - newNam->setProxyFactory( proxyFactory( true ) ); + newNam->setProxyFactory( proxyFactory( false, true ) ); s_threadNamHash[ QThread::currentThread() ] = newNam; @@ -485,9 +495,15 @@ setNam( QNetworkAccessManager* nam, bool noMutexLocker ) QNetworkProxy proxy( s->proxyType(), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() ); proxyFactory->setProxy( proxy ); //FIXME: Jreen is broke without this - QNetworkProxy::setApplicationProxy( proxy ); - if ( !s->proxyNoProxyHosts().isEmpty() ) + //QNetworkProxy::setApplicationProxy( proxy ); + s_noProxyHostsMutex.lock(); + if ( !s->proxyNoProxyHosts().isEmpty() && s_noProxyHosts.isEmpty() ) + { + s_noProxyHostsMutex.unlock(); proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ',', QString::SkipEmptyParts ) ); + } + else + s_noProxyHostsMutex.unlock(); } nam->setProxyFactory( proxyFactory ); diff --git a/src/libtomahawk/utils/tomahawkutils.h b/src/libtomahawk/utils/tomahawkutils.h index f3133e112..c244bff63 100644 --- a/src/libtomahawk/utils/tomahawkutils.h +++ b/src/libtomahawk/utils/tomahawkutils.h @@ -92,7 +92,7 @@ namespace TomahawkUtils DLLEXPORT QString extensionToMimetype( const QString& extension ); DLLEXPORT bool newerVersion( const QString& oldVersion, const QString& newVersion ); - DLLEXPORT NetworkProxyFactory* proxyFactory( bool noMutexLocker = false ); + DLLEXPORT NetworkProxyFactory* proxyFactory( bool makeClone = false, bool noMutexLocker = false ); DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory, bool noMutexLocker = false ); DLLEXPORT QNetworkAccessManager* nam(); DLLEXPORT void setNam( QNetworkAccessManager* nam, bool noMutexLocker = false ); diff --git a/src/proxydialog.ui b/src/proxydialog.ui index 4b30ca1ca..321fcb09c 100644 --- a/src/proxydialog.ui +++ b/src/proxydialog.ui @@ -139,7 +139,8 @@ - No Proxy Hosts: + No Proxy Hosts: +(Overrides system proxy) diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 850701b86..57f3a735e 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -22,13 +22,13 @@ #include "utils/tomahawkutilsgui.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #ifdef LIBLASTFM_FOUND #include @@ -859,7 +859,6 @@ ProxyDialog::ProxyDialog( QWidget *parent ) ui->userLineEdit->setEnabled( false ); ui->passwordLineEdit->setEnabled( false ); ui->checkBoxUseProxyForDns->setEnabled( false ); - ui->noHostLineEdit->setEnabled( false ); } connect( ui->typeBox, SIGNAL( currentIndexChanged( int ) ), SLOT( proxyTypeChangedSlot( int ) ) ); @@ -876,7 +875,6 @@ ProxyDialog::proxyTypeChangedSlot( int index ) ui->userLineEdit->setEnabled( false ); ui->passwordLineEdit->setEnabled( false ); ui->checkBoxUseProxyForDns->setEnabled( false ); - ui->noHostLineEdit->setEnabled( false ); } else { @@ -885,7 +883,6 @@ ProxyDialog::proxyTypeChangedSlot( int index ) ui->userLineEdit->setEnabled( true ); ui->passwordLineEdit->setEnabled( true ); ui->checkBoxUseProxyForDns->setEnabled( true ); - ui->noHostLineEdit->setEnabled( true ); } } @@ -923,8 +920,8 @@ ProxyDialog::saveSettings() proxyFactory->setProxy( QNetworkProxy( type, s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() ) ); if ( !ui->noHostLineEdit->text().isEmpty() ) { - tDebug() << Q_FUNC_INFO << "hosts line edit is " << ui->noHostLineEdit->text(); - tDebug() << Q_FUNC_INFO << "split hosts line edit is " << ui->noHostLineEdit->text().split( ' ', QString::SkipEmptyParts ); + tDebug() << Q_FUNC_INFO << "noproxy line edit is " << ui->noHostLineEdit->text(); + tDebug() << Q_FUNC_INFO << "split noproxy line edit is " << ui->noHostLineEdit->text().split( ' ', QString::SkipEmptyParts ); proxyFactory->setNoProxyHosts( ui->noHostLineEdit->text().split( ' ', QString::SkipEmptyParts ) ); } } diff --git a/src/settingsdialog.h b/src/settingsdialog.h index ef2bdb90e..4c80b127b 100644 --- a/src/settingsdialog.h +++ b/src/settingsdialog.h @@ -19,8 +19,8 @@ #ifndef SETTINGSDIALOG_H #define SETTINGSDIALOG_H -#include -#include +#include +#include #include "config.h" diff --git a/src/sip/jabber/jabber.cpp b/src/sip/jabber/jabber.cpp index fa3295a4f..0473c9c17 100644 --- a/src/sip/jabber/jabber.cpp +++ b/src/sip/jabber/jabber.cpp @@ -102,6 +102,7 @@ JabberPlugin::JabberPlugin( const QString& pluginId ) // general client setup m_client = new Jreen::Client( jid, m_currentPassword ); + m_client->setProxyFactory( TomahawkUtils::proxyFactory( true ) ); setupClientHelper(); m_client->registerPayload(new TomahawkSipMessageFactory); diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index 145a55f8a..d15440343 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include "artist.h" #include "album.h" From 6c6411561b6b1ec8adbf8dbd2e8655b389224620 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 14 Mar 2012 16:20:24 -0400 Subject: [PATCH 04/15] Bump dependencies --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index e554d3555..5cd733079 100644 --- a/README +++ b/README @@ -40,7 +40,7 @@ Dependencies Attica 0.2.0 - ftp://ftp.kde.org/pub/kde/stable/attica/ QuaZip 0.4.3 - http://quazip.sourceforge.net/ - Jreen 1.0.1 - https://github.com/euroelessar/jreen + Jreen 1.0.3 - https://github.com/euroelessar/jreen QTweetLib 0.5.0 - https://github.com/minimoog/QTweetLib Third party libraries that we ship with our source: From 042ccbe73088b88eb1d0e692cc3851a589919c4d Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 14 Mar 2012 16:31:20 -0400 Subject: [PATCH 05/15] Fix merge issue --- src/sip/twitter/tomahawkoauthtwitter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sip/twitter/tomahawkoauthtwitter.h b/src/sip/twitter/tomahawkoauthtwitter.h index 6b1a75465..a1cd53304 100644 --- a/src/sip/twitter/tomahawkoauthtwitter.h +++ b/src/sip/twitter/tomahawkoauthtwitter.h @@ -16,7 +16,7 @@ public: ~TomahawkOAuthTwitter() {} protected: - virtual int authorizationWidget(); + virtual const QString authorizationWidget(); private slots: void error(); From 6342e6a9f8c09ce2012d7d11f241c69b6d116f08 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 15 Mar 2012 08:42:05 +0100 Subject: [PATCH 06/15] * Fixed TWK-758: Sorting playlist by album position. --- src/libtomahawk/playlist/trackproxymodel.cpp | 22 +++++++++--- src/libtomahawk/playlist/treeproxymodel.cpp | 35 ++++++++++++-------- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/libtomahawk/playlist/trackproxymodel.cpp b/src/libtomahawk/playlist/trackproxymodel.cpp index 6b42a6051..b9e8b4629 100644 --- a/src/libtomahawk/playlist/trackproxymodel.cpp +++ b/src/libtomahawk/playlist/trackproxymodel.cpp @@ -69,7 +69,7 @@ TrackProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParen return false; const Tomahawk::query_ptr& q = pi->query(); - if( q.isNull() ) // uh oh? filter out invalid queries i guess + if ( q.isNull() ) // uh oh? filter out invalid queries i guess return false; Tomahawk::result_ptr r; @@ -190,7 +190,7 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c album1 = r->album()->name(); track1 = r->track(); albumpos1 = r->albumpos(); - discnumber1 = r->discnumber(); + discnumber1 = qMax( 1, (int)r->discnumber() ); bitrate1 = r->bitrate(); mtime1 = r->modificationTime(); id1 = r->trackId(); @@ -203,7 +203,7 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c album2 = r->album()->name(); track2 = r->track(); albumpos2 = r->albumpos(); - discnumber2 = r->discnumber(); + discnumber2 = qMax( 1, (int)r->discnumber() ); bitrate2 = r->bitrate(); mtime2 = r->modificationTime(); id2 = r->trackId(); @@ -223,7 +223,7 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c { if ( album1 == album2 ) { - if( discnumber1 == discnumber2 ) + if ( discnumber1 == discnumber2 ) { if ( albumpos1 == albumpos2 ) return id1 < id2; @@ -243,7 +243,7 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c { if ( album1 == album2 ) { - if( discnumber1 == discnumber2 ) + if ( discnumber1 == discnumber2 ) { if ( albumpos1 == albumpos2 ) return id1 < id2; @@ -277,6 +277,18 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c return size1 < size2; } + else if ( left.column() == TrackModel::AlbumPos ) // sort by album pos + { + if ( discnumber1 != discnumber2 ) + { + return discnumber1 < discnumber2; + } + else + { + if ( albumpos1 != albumpos2 ) + return albumpos1 < albumpos2; + } + } const QString& lefts = sourceModel()->data( left ).toString(); const QString& rights = sourceModel()->data( right ).toString(); diff --git a/src/libtomahawk/playlist/treeproxymodel.cpp b/src/libtomahawk/playlist/treeproxymodel.cpp index e9494f32e..ff2e3e9c9 100644 --- a/src/libtomahawk/playlist/treeproxymodel.cpp +++ b/src/libtomahawk/playlist/treeproxymodel.cpp @@ -301,28 +301,35 @@ TreeProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) co albumpos2 = p2->query()->albumpos(); discnumber2 = p2->query()->discnumber(); } + if ( !p1->result().isNull() ) + { + if ( albumpos1 == 0 ) + albumpos1 = p1->result()->albumpos(); + if ( discnumber1 == 0 ) + discnumber1 = p1->result()->discnumber(); + } + if ( !p2->result().isNull() ) + { + if ( albumpos2 == 0 ) + albumpos2 = p2->result()->albumpos(); + if ( discnumber2 == 0 ) + discnumber2 = p2->result()->discnumber(); + } + discnumber1 = qMax( 1, (int)discnumber1 ); + discnumber2 = qMax( 1, (int)discnumber2 ); - if ( albumpos1 == 0 && !p1->result().isNull() ) - albumpos1 = p1->result()->albumpos(); - if ( discnumber1 == 0 && !p1->result().isNull() ) - discnumber1 = p1->result()->discnumber(); - - if ( albumpos2 == 0 && !p2->result().isNull() ) - albumpos2 = p2->result()->albumpos(); - if ( discnumber2 == 0 && !p2->result().isNull() ) - discnumber2 = p2->result()->discnumber(); - - const QString& lefts = textForItem( p1 ); - const QString& rights = textForItem( p2 ); - - if( discnumber1 != discnumber2 ) + if ( discnumber1 != discnumber2 ) + { return discnumber1 < discnumber2; + } else { if ( albumpos1 != albumpos2 ) return albumpos1 < albumpos2; } + const QString& lefts = textForItem( p1 ); + const QString& rights = textForItem( p2 ); if ( lefts == rights ) return (qint64)&p1 < (qint64)&p2; From 66836ae0bd2bcdfbf04a4110ced4e064e71bb8cb Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 15 Mar 2012 09:04:16 +0100 Subject: [PATCH 07/15] * Something is wonky about CLucene scoring. Rely on our internal scoring. --- src/libtomahawk/database/fuzzyindex.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libtomahawk/database/fuzzyindex.cpp b/src/libtomahawk/database/fuzzyindex.cpp index f9cf8802c..b7597c9c7 100644 --- a/src/libtomahawk/database/fuzzyindex.cpp +++ b/src/libtomahawk/database/fuzzyindex.cpp @@ -227,7 +227,7 @@ FuzzyIndex::search( const Tomahawk::query_ptr& query ) fqry = _CLNEW FuzzyQuery( term ); qry->add( fqry, true, BooleanClause::MUST ); - minScore = 0.05; + minScore = 0.00; } Hits* hits = m_luceneSearcher->search( qry ); From 27147a0140d004001df08293e76d3e4d5342c18f Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Mon, 19 Mar 2012 21:25:38 -0400 Subject: [PATCH 08/15] Guard against null sharedptr that shouldn't be null anyway -.- --- src/libtomahawk/result.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libtomahawk/result.cpp b/src/libtomahawk/result.cpp index fb03c7aaf..33ca4e86d 100644 --- a/src/libtomahawk/result.cpp +++ b/src/libtomahawk/result.cpp @@ -170,7 +170,7 @@ Result::toVariant() const QString Result::toString() const { - return QString( "Result(%1 %2\t%3 - %4 %5" ).arg( id() ).arg( score() ).arg( artist()->name() ).arg( track() ).arg( url() ); + return QString( "Result(%1 %2\t%3 - %4 %5" ).arg( id() ).arg( score() ).arg( artist().isNull() ? QString() : artist()->name() ).arg( track() ).arg( url() ); } From e1b086e3a45c0bdd36e55882d70a1d28b1270b15 Mon Sep 17 00:00:00 2001 From: mack-t Date: Sun, 18 Mar 2012 16:12:19 -0400 Subject: [PATCH 09/15] Add albumpos, discnumber and score information from tomahawk resolver (cherry picked from commit 21eeab61d8e871f9d1b1dbb7540c274e6e8781d8) --- src/libtomahawk/resolvers/qtscriptresolver.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libtomahawk/resolvers/qtscriptresolver.cpp b/src/libtomahawk/resolvers/qtscriptresolver.cpp index d518c15f2..92d9e4506 100644 --- a/src/libtomahawk/resolvers/qtscriptresolver.cpp +++ b/src/libtomahawk/resolvers/qtscriptresolver.cpp @@ -392,10 +392,13 @@ QtScriptResolver::parseResultVariantList( const QVariantList& reslist ) rp->setArtist( ap ); rp->setAlbum( Tomahawk::Album::get( ap, m.value( "album" ).toString(), false ) ); rp->setTrack( m.value( "track" ).toString() ); + rp->setAlbumPos( m.value( "albumpos" ).toUInt() ); rp->setBitrate( m.value( "bitrate" ).toUInt() ); rp->setSize( m.value( "size" ).toUInt() ); rp->setRID( uuid() ); rp->setFriendlySource( name() ); + rp->setScore( m.value( "score" ).toFloat() ); + rp->setDiscNumber( m.value( "discnumber" ).toUInt() ); if ( m.contains( "year" ) ) { From 6e929986cb2ea218e7e7f785bc69b68b3f5801db Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 9 Mar 2012 14:13:43 -0500 Subject: [PATCH 10/15] A bit of extra safety (cherry picked from commit 2a58d53145e066d307029757866d34c3cde2543a) --- src/libtomahawk/query.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libtomahawk/query.cpp b/src/libtomahawk/query.cpp index 1393a3260..113ad7b8c 100644 --- a/src/libtomahawk/query.cpp +++ b/src/libtomahawk/query.cpp @@ -106,6 +106,7 @@ Query::~Query() { QMutexLocker lock( &m_mutex ); m_ownRef.clear(); + m_results.clear(); } From e828dadec82a9f798d53c644e5140c9054574e5d Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Thu, 15 Mar 2012 19:00:14 -0400 Subject: [PATCH 11/15] All QSharedPointers used in different threads need deleteLater as custom deleter. This is some of them. (cherry picked from commit e3f5605c4e04bd3e5dc55ccafeb2e6fb150cb1e5) --- src/libtomahawk/album.cpp | 2 +- src/libtomahawk/artist.cpp | 2 +- src/libtomahawk/database/databasecollection.cpp | 4 ++-- src/libtomahawk/database/databasecommand_loadallplaylists.cpp | 2 +- src/libtomahawk/playlist.cpp | 2 +- src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp | 2 +- src/libtomahawk/query.cpp | 4 ++-- src/libtomahawk/result.cpp | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libtomahawk/album.cpp b/src/libtomahawk/album.cpp index fbf362427..00fe82aa0 100644 --- a/src/libtomahawk/album.cpp +++ b/src/libtomahawk/album.cpp @@ -61,7 +61,7 @@ Album::get( unsigned int id, const QString& name, const Tomahawk::artist_ptr& ar return s_albums.value( id ); } - album_ptr a = album_ptr( new Album( id, name, artist ) ); + album_ptr a = album_ptr( new Album( id, name, artist ), &QObject::deleteLater ); if ( id > 0 ) s_albums.insert( id, a ); diff --git a/src/libtomahawk/artist.cpp b/src/libtomahawk/artist.cpp index cdefc2505..9eea97d13 100644 --- a/src/libtomahawk/artist.cpp +++ b/src/libtomahawk/artist.cpp @@ -61,7 +61,7 @@ Artist::get( unsigned int id, const QString& name ) return s_artists.value( id ); } - artist_ptr a = artist_ptr( new Artist( id, name ) ); + artist_ptr a = artist_ptr( new Artist( id, name ), &QObject::deleteLater ); if ( id > 0 ) s_artists.insert( id, a ); diff --git a/src/libtomahawk/database/databasecollection.cpp b/src/libtomahawk/database/databasecollection.cpp index 9baed7f31..801897a69 100644 --- a/src/libtomahawk/database/databasecollection.cpp +++ b/src/libtomahawk/database/databasecollection.cpp @@ -142,7 +142,7 @@ DatabaseCollection::autoPlaylistCreated( const source_ptr& source, const QVarian static_cast(data[6].toInt()), // dynamic mode data[7].toBool(), //shared data[8].toInt(), //lastmod - data[9].toString() ) ); //GUID + data[9].toString() ), &QObject::deleteLater ); //GUID addAutoPlaylist( p ); } @@ -160,7 +160,7 @@ DatabaseCollection::stationCreated( const source_ptr& source, const QVariantList static_cast(data[6].toInt()), // dynamic mode data[7].toBool(), //shared data[8].toInt(), //lastmod - data[9].toString() ) ); //GUID + data[9].toString() ), &QObject::deleteLater ); //GUID addStation( p ); } diff --git a/src/libtomahawk/database/databasecommand_loadallplaylists.cpp b/src/libtomahawk/database/databasecommand_loadallplaylists.cpp index 90f8cac7c..c40ac4872 100644 --- a/src/libtomahawk/database/databasecommand_loadallplaylists.cpp +++ b/src/libtomahawk/database/databasecommand_loadallplaylists.cpp @@ -71,7 +71,7 @@ DatabaseCommand_LoadAllPlaylists::exec( DatabaseImpl* dbi ) query.value(5).toBool(), //shared query.value(4).toInt(), //lastmod query.value(0).toString() //GUID - ) ); + ), &QObject::deleteLater ); plists.append( p ); } diff --git a/src/libtomahawk/playlist.cpp b/src/libtomahawk/playlist.cpp index f093c24f1..04cc0d6f6 100644 --- a/src/libtomahawk/playlist.cpp +++ b/src/libtomahawk/playlist.cpp @@ -185,7 +185,7 @@ Playlist::create( const source_ptr& author, entries << p; } - playlist_ptr playlist( new Playlist( author, guid, title, info, creator, shared, entries ) ); + playlist_ptr playlist( new Playlist( author, guid, title, info, creator, shared, entries ), &QObject::deleteLater ); // save to DB in the background // Watch for the created() signal if you need to be sure it's written. diff --git a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp index 02c70eccf..602b7b7dd 100644 --- a/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp +++ b/src/libtomahawk/playlist/dynamic/DynamicPlaylist.cpp @@ -152,7 +152,7 @@ DynamicPlaylist::create( const Tomahawk::source_ptr& author, bool autoLoad ) { - dynplaylist_ptr dynplaylist = Tomahawk::dynplaylist_ptr( new DynamicPlaylist( author, guid, title, info, creator, type, mode, shared, autoLoad ) ); + dynplaylist_ptr dynplaylist = Tomahawk::dynplaylist_ptr( new DynamicPlaylist( author, guid, title, info, creator, type, mode, shared, autoLoad ), &QObject::deleteLater ); DatabaseCommand_CreateDynamicPlaylist* cmd = new DatabaseCommand_CreateDynamicPlaylist( author, dynplaylist, autoLoad ); connect( cmd, SIGNAL(finished()), dynplaylist.data(), SIGNAL(created()) ); diff --git a/src/libtomahawk/query.cpp b/src/libtomahawk/query.cpp index 113ad7b8c..a914098b5 100644 --- a/src/libtomahawk/query.cpp +++ b/src/libtomahawk/query.cpp @@ -44,7 +44,7 @@ Query::get( const QString& artist, const QString& track, const QString& album, c if ( qid.isEmpty() ) autoResolve = false; - query_ptr q = query_ptr( new Query( artist, track, album, qid, autoResolve ) ); + query_ptr q = query_ptr( new Query( artist, track, album, qid, autoResolve ), &QObject::deleteLater ); q->setWeakRef( q.toWeakRef() ); if ( autoResolve ) @@ -58,7 +58,7 @@ query_ptr Query::get( const QString& query, const QID& qid ) { - query_ptr q = query_ptr( new Query( query, qid ) ); + query_ptr q = query_ptr( new Query( query, qid ), &QObject::deleteLater ); q->setWeakRef( q.toWeakRef() ); if ( !qid.isEmpty() ) diff --git a/src/libtomahawk/result.cpp b/src/libtomahawk/result.cpp index 33ca4e86d..06dd7a472 100644 --- a/src/libtomahawk/result.cpp +++ b/src/libtomahawk/result.cpp @@ -43,7 +43,7 @@ Result::get( const QString& url ) return s_results.value( url ); } - result_ptr r = result_ptr( new Result( url ) ); + result_ptr r = result_ptr( new Result( url ), &QObject::deleteLater ); s_results.insert( url, r ); return r; From 753e1b3c903d199d390c8f14bf9aa11c810b5d5e Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Tue, 20 Mar 2012 11:28:45 -0400 Subject: [PATCH 12/15] aFix crash in dragging artist, don't assume AlbumModel only contains albums as it's hacked to also contain artists. (cherry picked from commit 68d541d2e8dc847c40f6782c65beb4e15ff6aa72) --- src/libtomahawk/playlist/albummodel.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/libtomahawk/playlist/albummodel.cpp b/src/libtomahawk/playlist/albummodel.cpp index 08cc3f653..c20ec6b8f 100644 --- a/src/libtomahawk/playlist/albummodel.cpp +++ b/src/libtomahawk/playlist/albummodel.cpp @@ -178,6 +178,7 @@ AlbumModel::mimeData( const QModelIndexList &indexes ) const QByteArray queryData; QDataStream queryStream( &queryData, QIODevice::WriteOnly ); + bool isAlbumData = true; foreach ( const QModelIndex& i, indexes ) { if ( i.column() > 0 ) @@ -185,16 +186,25 @@ AlbumModel::mimeData( const QModelIndexList &indexes ) const QModelIndex idx = index( i.row(), 0, i.parent() ); AlbumItem* item = itemFromIndex( idx ); - if ( item ) + if ( item && !item->album().isNull() ) { const album_ptr& album = item->album(); queryStream << album->artist()->name(); queryStream << album->name(); + + isAlbumData = true; + } + else if ( item && !item->artist().isNull() ) + { + const artist_ptr& artist = item->artist(); + queryStream << artist->name(); + + isAlbumData = false; } } - QMimeData* mimeData = new QMimeData(); - mimeData->setData( "application/tomahawk.metadata.album", queryData ); + QMimeData* mimeData = new QMimeData; + mimeData->setData( isAlbumData ? "application/tomahawk.metadata.album" : "application/tomahawk.metadata.artist", queryData ); return mimeData; } @@ -431,7 +441,7 @@ AlbumModel::findItem( const artist_ptr& artist ) const return item; } } - + return 0; } @@ -447,6 +457,6 @@ AlbumModel::findItem( const album_ptr& album ) const return item; } } - + return 0; } From 68f03dbd136eedb2bed44dbbec4583955e0aaefa Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Tue, 27 Mar 2012 10:30:37 -0400 Subject: [PATCH 13/15] autoupdate fixes: init on creation, and every 10 not 100 mins (cherry picked from commit ff04ab3b922fdf44d18751546b371ffa7ed1c941) --- src/libtomahawk/playlist/PlaylistUpdaterInterface.cpp | 2 ++ src/libtomahawk/utils/xspfloader.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/playlist/PlaylistUpdaterInterface.cpp b/src/libtomahawk/playlist/PlaylistUpdaterInterface.cpp index c057ceb59..da7e2f75d 100644 --- a/src/libtomahawk/playlist/PlaylistUpdaterInterface.cpp +++ b/src/libtomahawk/playlist/PlaylistUpdaterInterface.cpp @@ -64,6 +64,8 @@ PlaylistUpdaterInterface::PlaylistUpdaterInterface( const playlist_ptr& pl ) connect( m_timer, SIGNAL( timeout() ), this, SLOT( updateNow() ) ); QTimer::singleShot( 0, this, SLOT( doSave() ) ); + + setAutoUpdate( m_autoUpdate ); } PlaylistUpdaterInterface::PlaylistUpdaterInterface( const playlist_ptr& pl, int interval, bool autoUpdate ) diff --git a/src/libtomahawk/utils/xspfloader.cpp b/src/libtomahawk/utils/xspfloader.cpp index 29fdbfe67..c5118875d 100644 --- a/src/libtomahawk/utils/xspfloader.cpp +++ b/src/libtomahawk/utils/xspfloader.cpp @@ -262,7 +262,7 @@ XSPFLoader::gotBody() // 10 minute default---for now, no way to change it connect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( playlistCreated() ) ); - new Tomahawk::XspfUpdater( m_playlist, 6000000, m_autoUpdate, m_url.toString() ); + new Tomahawk::XspfUpdater( m_playlist, 600000, m_autoUpdate, m_url.toString() ); emit ok( m_playlist ); } else{ From eec8b76de092eba093088a5779396f542fa04d19 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Tue, 27 Mar 2012 11:26:33 -0400 Subject: [PATCH 14/15] fix xspf auto-updating (cherry picked from commit c54ca787693cd3a3e0340dfcb08032a09d6059cf) --- src/libtomahawk/playlist/XspfUpdater.cpp | 10 +++------- src/libtomahawk/playlist/XspfUpdater.h | 3 ++- src/libtomahawk/utils/xspfloader.cpp | 7 +++++-- src/libtomahawk/utils/xspfloader.h | 3 ++- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/libtomahawk/playlist/XspfUpdater.cpp b/src/libtomahawk/playlist/XspfUpdater.cpp index a9d794334..2eb1d7a1e 100644 --- a/src/libtomahawk/playlist/XspfUpdater.cpp +++ b/src/libtomahawk/playlist/XspfUpdater.cpp @@ -58,28 +58,24 @@ XspfUpdater::updateNow() XSPFLoader* l = new XSPFLoader( false, false ); l->setAutoResolveTracks( false ); l->load( m_url ); - connect( l, SIGNAL( ok ( Tomahawk::playlist_ptr ) ), this, SLOT( playlistLoaded() ) ); + connect( l, SIGNAL( tracks( QList ) ), this, SLOT( playlistLoaded( QList ) ) ); } void -XspfUpdater::playlistLoaded() +XspfUpdater::playlistLoaded( const QList& newEntries ) { - XSPFLoader* loader = qobject_cast( sender() ); - Q_ASSERT( loader ); - QList< query_ptr > tracks; foreach ( const plentry_ptr ple, playlist()->entries() ) tracks << ple->query(); bool changed = false; - QList< query_ptr > mergedTracks = TomahawkUtils::mergePlaylistChanges( tracks, loader->entries(), changed ); + QList< query_ptr > mergedTracks = TomahawkUtils::mergePlaylistChanges( tracks, newEntries, changed ); if ( !changed ) return; QList el = playlist()->entriesFromQueries( mergedTracks, true ); playlist()->createNewRevision( uuid(), playlist()->currentrevision(), el ); - } void diff --git a/src/libtomahawk/playlist/XspfUpdater.h b/src/libtomahawk/playlist/XspfUpdater.h index c5254d79a..227c9ab4a 100644 --- a/src/libtomahawk/playlist/XspfUpdater.h +++ b/src/libtomahawk/playlist/XspfUpdater.h @@ -37,6 +37,7 @@ public: virtual ~XspfUpdater(); virtual QString type() const { return "xspf"; } + public slots: void updateNow(); @@ -46,7 +47,7 @@ protected: virtual void removeFromSettings(const QString& group) const; private slots: - void playlistLoaded(); + void playlistLoaded( const QList & ); private: QString m_url; diff --git a/src/libtomahawk/utils/xspfloader.cpp b/src/libtomahawk/utils/xspfloader.cpp index c5118875d..9fd0c7369 100644 --- a/src/libtomahawk/utils/xspfloader.cpp +++ b/src/libtomahawk/utils/xspfloader.cpp @@ -60,6 +60,7 @@ XSPFLoader::XSPFLoader( bool autoCreate, bool autoUpdate, QObject *parent ) , m_autoCreate( autoCreate ) , m_autoUpdate( autoUpdate ) , m_autoResolve( true ) + , m_autoDelete( true ) , m_NS("http://xspf.org/ns/0/") { qRegisterMetaType< XSPFErrorCode >("XSPFErrorCode"); @@ -265,12 +266,14 @@ XSPFLoader::gotBody() new Tomahawk::XspfUpdater( m_playlist, 600000, m_autoUpdate, m_url.toString() ); emit ok( m_playlist ); } - else{ + else + { if( !m_entries.isEmpty() ) emit tracks( m_entries ); } - deleteLater(); + if ( m_autoDelete ) + deleteLater(); } diff --git a/src/libtomahawk/utils/xspfloader.h b/src/libtomahawk/utils/xspfloader.h index eee77de96..e4e912618 100644 --- a/src/libtomahawk/utils/xspfloader.h +++ b/src/libtomahawk/utils/xspfloader.h @@ -48,6 +48,7 @@ public: void setOverrideTitle( const QString& newTitle ); void setAutoResolveTracks( bool autoResolve ) { m_autoResolve = autoResolve; } + void setAutoDelete( bool autoDelete ) { m_autoDelete = autoDelete; } static QString errorToString( XSPFErrorCode error ); @@ -69,7 +70,7 @@ private: void reportError(); void gotBody(); - bool m_autoCreate, m_autoUpdate, m_autoResolve; + bool m_autoCreate, m_autoUpdate, m_autoResolve, m_autoDelete; QString m_NS,m_overrideTitle; QList< Tomahawk::query_ptr > m_entries; QString m_title, m_info, m_creator; From fff8fbfe802fec6af32de251a615b95e9c4b9ef2 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Wed, 28 Mar 2012 17:23:27 +0200 Subject: [PATCH 15/15] win: fix qca2 usage/grooveshark --- src/libtomahawk/playlist.h | 2 +- src/libtomahawk/viewmanager.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libtomahawk/playlist.h b/src/libtomahawk/playlist.h index 5cc6c70cf..4ba6faa71 100644 --- a/src/libtomahawk/playlist.h +++ b/src/libtomahawk/playlist.h @@ -182,7 +182,7 @@ public: QList entriesFromQueries( const QList& queries, bool clearFirst = false ); - void setUpdater( PlaylistUpdaterInterface* interface ) { m_updater = interface; } + void setUpdater( PlaylistUpdaterInterface* pluinterface ) { m_updater = pluinterface; } PlaylistUpdaterInterface* updater() const { return m_updater; } Tomahawk::playlistinterface_ptr playlistInterface(); diff --git a/src/libtomahawk/viewmanager.h b/src/libtomahawk/viewmanager.h index 4dc2148b8..1320fd1bb 100644 --- a/src/libtomahawk/viewmanager.h +++ b/src/libtomahawk/viewmanager.h @@ -84,7 +84,7 @@ public: Tomahawk::playlistinterface_ptr currentPlaylistInterface() const; Tomahawk::ViewPage* currentPage() const; - Tomahawk::ViewPage* pageForInterface( Tomahawk::playlistinterface_ptr interface ) const; + Tomahawk::ViewPage* pageForInterface( Tomahawk::playlistinterface_ptr plInterface ) const; Tomahawk::ViewPage* show( Tomahawk::ViewPage* page ); @@ -185,9 +185,9 @@ private: void saveCurrentPlaylistSettings(); void loadCurrentPlaylistSettings(); - Tomahawk::playlist_ptr playlistForInterface( Tomahawk::playlistinterface_ptr interface ) const; - Tomahawk::dynplaylist_ptr dynamicPlaylistForInterface( Tomahawk::playlistinterface_ptr interface ) const; - Tomahawk::collection_ptr collectionForInterface( Tomahawk::playlistinterface_ptr interface ) const; + Tomahawk::playlist_ptr playlistForInterface( Tomahawk::playlistinterface_ptr plInterface ) const; + Tomahawk::dynplaylist_ptr dynamicPlaylistForInterface( Tomahawk::playlistinterface_ptr plInterface ) const; + Tomahawk::collection_ptr collectionForInterface( Tomahawk::playlistinterface_ptr plInterface ) const; QWidget* m_widget; InfoBar* m_infobar;