1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-04 21:27:58 +02:00

Merge branch 'master' into privatelistening

This commit is contained in:
Jeff Mitchell
2011-11-07 14:54:30 -05:00
53 changed files with 255 additions and 551 deletions

View File

@@ -1,58 +1,53 @@
Version 0.3.0: Version 0.3.0:
* Fixed bug where we would download http:// tracks twice.
* Make artist names in the album view clickable. * Make artist names in the album view clickable.
* Don't start playing if a tomahawk:// link was clicked while Tomahawk * Don't start playing if a tomahawk:// link was clicked while Tomahawk
is paused. is paused.
* Make artist name clickable in header of Album pages. * Make artist name clickable in header of Album pages.
* Fixed adding social actions such as loved tracks from other sources. * Added a drop shadow to cover images, and put placeholder in jewel case.
* Added a drop shadow to cover images, and put CD placeholder in jewel
case.
* Added shuffle and repeat support to tree view. * Added shuffle and repeat support to tree view.
* Draw a speaker next to the currently playing playlist. * Draw a speaker next to the currently playing playlist.
* Refresh station previews whenever a filter is changed. * Refresh station previews whenever a filter is changed.
* Support and show official releases on album and track pages. * Support and show official releases on album and track pages.
* Filter out duplicates from station previews and upcoming tracks. * Filter out duplicates from station previews and upcoming tracks.
* Resolve lists top-down.
* Added YouTube resolver. * Added YouTube resolver.
* Fixed bug where going offline then online would not re-connect to many * Fixed bug where going offline then online would not re-connect to many
peers. peers.
* Added support for auto-updating live xspf playlists. * Added support for auto-updating live XSPF playlists.
* Don't show an age of 41 for tracks that have no age information. * Don't show an age of 41 years for tracks that have no age information.
* Show config UI for resolvers that have them as so on as you add the resolver. * Show config UI for resolvers that have them as soon as you add them.
* Add support for Echo Nest Personal Catalogs and User Radio. Synchronize * Add support for Echo Nest Personal Catalogs and User Radio. Synchronize
your catalog with The Echo Nest and enable personal recommendations your catalog with The Echo Nest and enable personal recommendations
from you and your friends. from you and your friends.
* Added support for Grooveshark resolver (requires Grooveshark Anywhere). * Added support for Grooveshark resolver (requires Grooveshark Anywhere).
* Fixed re-resolving when resolvers or sources go offline. * Fixed re-resolving when resolvers or sources go off- / online.
* Correctly sort recently played tracks on the Dashboard. * Correctly sort recently played tracks on the Dashboard.
* Show a Lion full-screen toggle button if running on Lion. * Show a Lion full-screen toggle button if running on Lion.
* Display list of who is currently listening along to you. * Show a list of users who are currently listening along to you.
* Show headphone icon in source item to allow users to listen along; paint * Show headphone icon in source item to allow users to listen along; paint
headphones red on a source if the user is listening along to it. headphones red on a source if you are currently listening along to it.
* Added new job status view in the bottom of the source list that displays * Added new job status view in the bottom of the source list that displays
current jobs such as resolving, parsing playlists, and loading from current jobs such as resolving, parsing playlists, and loading from
database. database.
* Parse and convert a Spotify playlist url when dropped anywhere on the * Parse and convert a Spotify playlist url when dropped anywhere on the
sidebar sidebar.
* Convert resolvers to use asynchronous calls to avoid blocking Tomahawk's * Convert resolvers to use asynchronous calls to avoid blocking Tomahawk's
UI, greatly increasing responsiveness of Tomahawk while resolving. UI, greatly increasing responsiveness of Tomahawk while resolving.
* Fixed no playlists overlay not disappearing when playlists were added. * Fixed no playlists overlay not disappearing when playlists were added.
* Add support for parsing itunes track, artist and album links. * Add support for parsing itunes track, artist and album links.
* Fixed crash when syncing playlists with peers. * Fixed crash when syncing playlists with peers.
* Add support for browsing, downloading and rating resolvers * Add support for browsing, downloading and rating resolvers from within
from inside Tomahawk directly. Tomahawk directly.
* Support multi-folder selection and scanning. * Support multi-folder selection and scanning.
* Actually remove deleted files from the collection.
* Fixed handling of special characters in tomahawk:// links * Fixed handling of special characters in tomahawk:// links
* Improve sidebar performance by caching pixmaps and shrinking them. * Improve sidebar performance by caching pixmaps and shrinking them.
* Send updated playlists to peers when tracks are moved/copied. * Send updated playlists to peers when tracks are moved/copied.
* Remove splitter handles in sidebar * Remove splitter handles in sidebar.
* Fixed Tomahawk preventing system shutdown / logut. * Fixed Tomahawk preventing system shutdown / logout.
* Ignore leading 'The' when sorting artists. * Ignore leading 'The' when sorting artists.
* Added Charts page, which shows various sources' top hits & artists. * Added Charts page, which shows various sources' top hits & artists.
* The Collection tree-views can now be filtered. * The Collection tree-views can now be filtered.
* Fixed crash when pressing enter in an empty playlist. * Fixed crash when pressing enter in an empty playlist.
* Moved the song queue below to the left, below the sidebar. * Moved the song queue to the bottom of the sidebar.
* Added Footnotes, a contextual view that you can slide it. * Added Footnotes, a contextual view that you can slide it.
* Show recently added playlists in dashboard rather than recently opened * Show recently added playlists in dashboard rather than recently opened
playlists. playlists.

View File

@@ -13,8 +13,8 @@ QT4_WRAP_UI( crashreporter_UI_HEADERS ${crashreporter_UI} )
QT4_ADD_RESOURCES( crashreporter_RC_RCC ${crashreporter_RC} ) QT4_ADD_RESOURCES( crashreporter_RC_RCC ${crashreporter_RC} )
INCLUDE( ${QT_USE_FILE} ) INCLUDE( ${QT_USE_FILE} )
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src ../../libtomahawk )
ADD_DEFINITIONS( ${QT_DEFINITIONS} ) ADD_DEFINITIONS( ${QT_DEFINITIONS} )
ADD_EXECUTABLE( CrashReporter ${crashreporter_SOURCES} ${crashreporter_HEADERS_MOC} ${crashreporter_UI_HEADERS} ${crashreporter_RC_RCC} ) ADD_EXECUTABLE( CrashReporter ${crashreporter_SOURCES} ${crashreporter_HEADERS_MOC} ${crashreporter_UI_HEADERS} ${crashreporter_RC_RCC} )
TARGET_LINK_LIBRARIES( CrashReporter ${QT_LIBRARIES} ) TARGET_LINK_LIBRARIES( CrashReporter ${QT_LIBRARIES} tomahawklib )

View File

@@ -25,6 +25,9 @@
#include <QDateTime> #include <QDateTime>
#include <QHttp> #include <QHttp>
#include "utils/tomahawkutils.h"
#define LOGFILE TomahawkUtils::appLogDir().filePath( "Tomahawk.log" ).toLocal8Bit()
#define RESPATH ":/data/" #define RESPATH ":/data/"
@@ -40,7 +43,6 @@ CrashReporter::CrashReporter( const QStringList& args )
ui.progressLabel->setPalette( Qt::gray ); ui.progressLabel->setPalette( Qt::gray );
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
// macify++
QFont f = ui.bottomLabel->font(); QFont f = ui.bottomLabel->font();
f.setPointSize( 10 ); f.setPointSize( 10 );
ui.bottomLabel->setFont( f ); ui.bottomLabel->setFont( f );
@@ -55,12 +57,14 @@ CrashReporter::CrashReporter( const QStringList& args )
ui.bottomLabel->setIndent( 1 ); ui.bottomLabel->setIndent( 1 );
// adjust the spacer since we adjusted the spacing above // adjust the spacer since we adjusted the spacing above
for (int x = 0; x < ui.vboxLayout->count(); ++x) for ( int x = 0; x < ui.vboxLayout->count(); ++x )
if (QSpacerItem* spacer = ui.vboxLayout->itemAt( x )->spacerItem()) {
if ( QSpacerItem* spacer = ui.vboxLayout->itemAt( x )->spacerItem() )
{ {
spacer->changeSize( 6, 2, QSizePolicy::Minimum, QSizePolicy::Fixed ); spacer->changeSize( 6, 2, QSizePolicy::Minimum, QSizePolicy::Fixed );
break; break;
} }
}
#endif //Q_WS_MAC #endif //Q_WS_MAC
m_http = new QHttp( "oops.tomahawk-player.org", 80, this ); m_http = new QHttp( "oops.tomahawk-player.org", 80, this );
@@ -72,9 +76,9 @@ CrashReporter::CrashReporter( const QStringList& args )
m_minidump = m_dir + '/' + args.value( 2 ) + ".dmp"; m_minidump = m_dir + '/' + args.value( 2 ) + ".dmp";
m_product_name = args.value( 3 ); m_product_name = args.value( 3 );
QTimer::singleShot( 0, this, SLOT(send()) );
setFixedSize( sizeHint() ); setFixedSize( sizeHint() );
QTimer::singleShot( 0, this, SLOT( send() ) );
} }
@@ -94,7 +98,7 @@ CrashReporter::send()
// socorro expects a 10 digit build id // socorro expects a 10 digit build id
QRegExp rx( "(\\d+\\.\\d+\\.\\d+).(\\d+)" ); QRegExp rx( "(\\d+\\.\\d+\\.\\d+).(\\d+)" );
rx.exactMatch( "0.2.99" ); rx.exactMatch( TomahawkUtils::appFriendlyVersion() );
QString const version = rx.cap( 1 ); QString const version = rx.cap( 1 );
QString const buildId = rx.cap( 2 ).leftJustified( 10, '0' ); QString const buildId = rx.cap( 2 ).leftJustified( 10, '0' );
@@ -103,7 +107,7 @@ CrashReporter::send()
QList<Pair> pairs; QList<Pair> pairs;
pairs << Pair( "BuildID", buildId.toUtf8() ) pairs << Pair( "BuildID", buildId.toUtf8() )
<< Pair( "ProductName", m_product_name.toUtf8() ) << Pair( "ProductName", m_product_name.toUtf8() )
<< Pair( "Version", version.toUtf8() ) << Pair( "Version", TomahawkUtils::appFriendlyVersion().toLocal8Bit() )
<< Pair( "Vendor", "Tomahawk" ) << Pair( "Vendor", "Tomahawk" )
<< Pair( "timestamp", QByteArray::number( QDateTime::currentDateTime().toTime_t() ) ); << Pair( "timestamp", QByteArray::number( QDateTime::currentDateTime().toTime_t() ) );
@@ -126,14 +130,13 @@ CrashReporter::send()
// add logfile // add logfile
body += "--thkboundary\r\n"; body += "--thkboundary\r\n";
body += "Content-Disposition: form-data; name=\"upload_file_containerlog\"; filename=\"container.log\"\r\n"; body += "Content-Disposition: form-data; name=\"upload_file_tomahawklog\"; filename=\"Tomahawk.log\"\r\n";
body += "Content-Type: application/x-gzip\r\n"; body += "Content-Type: application/x-gzip\r\n";
body += "\r\n"; body += "\r\n";
// body += qCompress( contents( "Tomahawk.log" ) ); body += qCompress( contents( LOGFILE ) );
body += "\r\n"; body += "\r\n";
body += "--thkboundary--\r\n"; body += "--thkboundary--\r\n";
//////
QHttpRequestHeader header( "POST", "/addreport.php" ); QHttpRequestHeader header( "POST", "/addreport.php" );
header.setContentType( "multipart/form-data; boundary=thkboundary" ); header.setContentType( "multipart/form-data; boundary=thkboundary" );
header.setValue( "HOST", "oops.tomahawk-player.org" ); header.setValue( "HOST", "oops.tomahawk-player.org" );
@@ -179,5 +182,5 @@ CrashReporter::onFail( int error, const QString& errorString )
{ {
ui.button->setText( tr( "Close" ) ); ui.button->setText( tr( "Close" ) );
ui.progressLabel->setText( tr( "Failed to send crash info." ) ); ui.progressLabel->setText( tr( "Failed to send crash info." ) );
qDebug() << "Error: " << error << errorString; qDebug() << "Error:" << error << errorString;
} }

View File

@@ -69,7 +69,7 @@ set( libSources
database/databasecommand_deletefiles.cpp database/databasecommand_deletefiles.cpp
database/databasecommand_dirmtimes.cpp database/databasecommand_dirmtimes.cpp
database/databasecommand_filemtimes.cpp database/databasecommand_filemtimes.cpp
database/databasecommand_loadfile.cpp database/databasecommand_loadfiles.cpp
database/databasecommand_logplayback.cpp database/databasecommand_logplayback.cpp
database/databasecommand_addsource.cpp database/databasecommand_addsource.cpp
database/databasecommand_sourceoffline.cpp database/databasecommand_sourceoffline.cpp
@@ -298,7 +298,7 @@ set( libHeaders
database/databasecommand_deletefiles.h database/databasecommand_deletefiles.h
database/databasecommand_dirmtimes.h database/databasecommand_dirmtimes.h
database/databasecommand_filemtimes.h database/databasecommand_filemtimes.h
database/databasecommand_loadfile.h database/databasecommand_loadfiles.h
database/databasecommand_logplayback.h database/databasecommand_logplayback.h
database/databasecommand_addsource.h database/databasecommand_addsource.h
database/databasecommand_sourceoffline.h database/databasecommand_sourceoffline.h

View File

@@ -22,6 +22,7 @@
#include "database/database.h" #include "database/database.h"
#include "database/databasecommand_genericselect.h" #include "database/databasecommand_genericselect.h"
#include "database/databasecommand_setcollectionattributes.h" #include "database/databasecommand_setcollectionattributes.h"
#include "database/databasecommand_loadfiles.h"
#include "tomahawksettings.h" #include "tomahawksettings.h"
#include "sourcelist.h" #include "sourcelist.h"
#include "query.h" #include "query.h"
@@ -41,8 +42,8 @@ EchonestCatalogSynchronizer::EchonestCatalogSynchronizer( QObject *parent )
qRegisterMetaType<QList<QStringList> >("QList<QStringList>"); qRegisterMetaType<QList<QStringList> >("QList<QStringList>");
connect( TomahawkSettings::instance(), SIGNAL( changed() ), this, SLOT( checkSettingsChanged() ) ); connect( TomahawkSettings::instance(), SIGNAL( changed() ), this, SLOT( checkSettingsChanged() ) );
connect( SourceList::instance()->getLocal()->collection().data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksAdded( QList<Tomahawk::query_ptr> ) ), Qt::QueuedConnection ); connect( SourceList::instance()->getLocal()->collection().data(), SIGNAL( tracksAdded( QList<unsigned int> ) ), this, SLOT( tracksAdded( QList<unsigned int> ) ), Qt::QueuedConnection );
connect( SourceList::instance()->getLocal()->collection().data(), SIGNAL( tracksRemoved( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksRemoved( QList<Tomahawk::query_ptr> ) ), Qt::QueuedConnection ); connect( SourceList::instance()->getLocal()->collection().data(), SIGNAL( tracksRemoved( QList<unsigned int> ) ), this, SLOT( tracksRemoved( QList<unsigned int> ) ), Qt::QueuedConnection );
const QByteArray artist = TomahawkSettings::instance()->value( "collection/artistCatalog" ).toByteArray(); const QByteArray artist = TomahawkSettings::instance()->value( "collection/artistCatalog" ).toByteArray();
const QByteArray song = TomahawkSettings::instance()->value( "collection/songCatalog" ).toByteArray(); const QByteArray song = TomahawkSettings::instance()->value( "collection/songCatalog" ).toByteArray();
@@ -81,7 +82,7 @@ EchonestCatalogSynchronizer::checkSettingsChanged()
} else if ( !TomahawkSettings::instance()->enableEchonestCatalogs() && m_syncing ) } else if ( !TomahawkSettings::instance()->enableEchonestCatalogs() && m_syncing )
{ {
tDebug() << "FOund echonest change, doing catalog deletes!"; tDebug() << "Found echonest change, doing catalog deletes!";
// delete all track nums and catalog ids from our peers // delete all track nums and catalog ids from our peers
{ {
DatabaseCommand_SetTrackAttributes* cmd = new DatabaseCommand_SetTrackAttributes( DatabaseCommand_SetTrackAttributes::EchonestCatalogId ); DatabaseCommand_SetTrackAttributes* cmd = new DatabaseCommand_SetTrackAttributes( DatabaseCommand_SetTrackAttributes::EchonestCatalogId );
@@ -123,7 +124,9 @@ EchonestCatalogSynchronizer::catalogDeleted()
// If we didn't throw, no errors, so clear our config // If we didn't throw, no errors, so clear our config
TomahawkSettings::instance()->setValue( toDel, QString() ); TomahawkSettings::instance()->setValue( toDel, QString() );
} catch ( const Echonest::ParseError& e ) } catch ( const Echonest::ParseError& e )
{} {
tLog() << "Error in libechonest parsing catalog delete:" << e.what();
}
} }
@@ -293,60 +296,60 @@ EchonestCatalogSynchronizer::checkTicket()
} }
void void
EchonestCatalogSynchronizer::tracksAdded( const QList< query_ptr >& tracks ) EchonestCatalogSynchronizer::tracksAdded( const QList< unsigned int >& tracks )
{ {
if ( !m_syncing || m_songCatalog.id().isEmpty() || tracks.isEmpty() ) if ( !m_syncing || m_songCatalog.id().isEmpty() || tracks.isEmpty() )
return; return;
qDebug() << Q_FUNC_INFO << "Got tracks added from db, fetching metadata" << tracks;
// Get the result_ptrs from the tracks
DatabaseCommand_LoadFiles* cmd = new DatabaseCommand_LoadFiles( tracks );
connect( cmd, SIGNAL( results( QList<Tomahawk::result_ptr> ) ), this, SLOT( loadedResults( QList<Tomahawk::result_ptr> ) ) );
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
}
void
EchonestCatalogSynchronizer::loadedResults( const QList<result_ptr>& results )
{
QList< QStringList > rawTracks; QList< QStringList > rawTracks;
foreach( const query_ptr& track, tracks ) qDebug() << Q_FUNC_INFO << "Got track metadata..." << results.size();
foreach( const result_ptr& result, results )
{ {
// DatabaseCommand_AddFiles sets the track id on the result if ( result.isNull() )
int id = -1;
if ( track->results().size() == 1 )
id = track->results().first()->dbid();
else
{
tLog() << Q_FUNC_INFO << "No dbid for track we got in tracksAdded()!";
continue; continue;
}
rawTracks << ( QStringList() << QString::number( id ) << track->track() << track->artist() << track->album() ); qDebug() << "Metadata for item:" << result->fileId();
const QString artist = result->artist().isNull() ? QString() : result->artist()->name();
const QString album = result->album().isNull() ? QString() : result->album()->name();
rawTracks << ( QStringList() << QString::number( result->fileId() ) << result->track() << artist << album );
} }
rawTracksAdd( rawTracks ); rawTracksAdd( rawTracks );
} }
void void
EchonestCatalogSynchronizer::tracksRemoved( const QList< query_ptr >& tracks ) EchonestCatalogSynchronizer::tracksRemoved( const QList< unsigned int >& trackIds )
{ {
if ( !m_syncing || m_songCatalog.id().isEmpty() || tracks.isEmpty() ) if ( !m_syncing || m_songCatalog.id().isEmpty() || trackIds.isEmpty() )
return; return;
Echonest::CatalogUpdateEntries entries; Echonest::CatalogUpdateEntries entries;
entries.reserve( tracks.size() ); entries.reserve( trackIds.size() );
foreach ( const query_ptr& q, tracks ) foreach ( unsigned int id, trackIds )
{ {
QByteArray itemId; tDebug() << "Deleting item with id:" << id;
if ( q->results().size() > 0 )
{
// Should always be the case, should have the local result from the db that we are deleting!
itemId = QString::number( q->results().first()->dbid() ).toLatin1();
}
else
{
tLog() << "Got deleted query_ptr with no local result! Wtf!" << q->track() << q->artist() << q->results();
continue;
}
tDebug() << "Deleting item with id:" << itemId;
Echonest::CatalogUpdateEntry e( Echonest::CatalogTypes::Delete ); Echonest::CatalogUpdateEntry e( Echonest::CatalogTypes::Delete );
e.setItemId( itemId ); e.setItemId( QString::number( id ).toLatin1() );
entries.append( e ); entries.append( e );
} }
m_songCatalog.update( entries ); QNetworkReply* reply = m_songCatalog.update( entries );
connect( reply, SIGNAL( finished() ), this, SLOT( songUpdateFinished() ) );
} }
QByteArray QByteArray

View File

@@ -54,8 +54,10 @@ signals:
private slots: private slots:
void checkSettingsChanged(); void checkSettingsChanged();
void tracksAdded( const QList<Tomahawk::query_ptr>& ); void tracksAdded( const QList<unsigned int>& );
void tracksRemoved( const QList<Tomahawk::query_ptr>& ); void tracksRemoved( const QList<unsigned int>& );
void loadedResults( const QList<Tomahawk::result_ptr>& results );
// Echonest slots // Echonest slots
void songCreateFinished(); void songCreateFinished();

View File

@@ -68,7 +68,6 @@ Collection::addPlaylist( const Tomahawk::playlist_ptr& p )
QList<playlist_ptr> toadd; QList<playlist_ptr> toadd;
toadd << p; toadd << p;
// qDebug() << "Inserted playlist with guid:" << p->guid();
m_playlists.insert( p->guid(), p ); m_playlists.insert( p->guid(), p );
/* qDebug() << Q_FUNC_INFO << "Collection name" << name() /* qDebug() << Q_FUNC_INFO << "Collection name" << name()
@@ -83,7 +82,6 @@ Collection::addAutoPlaylist( const Tomahawk::dynplaylist_ptr& p )
{ {
QList<dynplaylist_ptr> toadd; QList<dynplaylist_ptr> toadd;
toadd << p; toadd << p;
// qDebug() << "Inserted dynamic playlist with guid:" << p->guid();
m_autoplaylists.insert( p->guid(), p ); m_autoplaylists.insert( p->guid(), p );
/* qDebug() << Q_FUNC_INFO << "Collection name" << name() /* qDebug() << Q_FUNC_INFO << "Collection name" << name()
@@ -98,7 +96,6 @@ Collection::addStation( const dynplaylist_ptr& s )
{ {
QList<dynplaylist_ptr> toadd; QList<dynplaylist_ptr> toadd;
toadd << s; toadd << s;
// qDebug() << "Inserted station with guid:" << s->guid();
m_stations.insert( s->guid(), s ); m_stations.insert( s->guid(), s );
/* qDebug() << Q_FUNC_INFO << "Collection name" << name() /* qDebug() << Q_FUNC_INFO << "Collection name" << name()
@@ -167,7 +164,6 @@ Collection::autoPlaylist( const QString& guid )
dynplaylist_ptr dynplaylist_ptr
Collection::station( const QString& guid ) Collection::station( const QString& guid )
{ {
return m_stations.value( guid, dynplaylist_ptr() ); return m_stations.value( guid, dynplaylist_ptr() );
} }
@@ -175,7 +171,6 @@ Collection::station( const QString& guid )
void void
Collection::setPlaylists( const QList<Tomahawk::playlist_ptr>& plists ) Collection::setPlaylists( const QList<Tomahawk::playlist_ptr>& plists )
{ {
// qDebug() << Q_FUNC_INFO << plists.count();
foreach ( const playlist_ptr& p, plists ) foreach ( const playlist_ptr& p, plists )
{ {
// qDebug() << "Batch inserting playlist:" << p->guid(); // qDebug() << "Batch inserting playlist:" << p->guid();
@@ -190,8 +185,6 @@ Collection::setPlaylists( const QList<Tomahawk::playlist_ptr>& plists )
void void
Collection::setAutoPlaylists( const QList< Tomahawk::dynplaylist_ptr >& plists ) Collection::setAutoPlaylists( const QList< Tomahawk::dynplaylist_ptr >& plists )
{ {
// qDebug() << Q_FUNC_INFO << plists.count();
foreach ( const dynplaylist_ptr& p, plists ) foreach ( const dynplaylist_ptr& p, plists )
{ {
// qDebug() << "Batch inserting dynamic playlist:" << p->guid(); // qDebug() << "Batch inserting dynamic playlist:" << p->guid();
@@ -204,8 +197,6 @@ Collection::setAutoPlaylists( const QList< Tomahawk::dynplaylist_ptr >& plists )
void void
Collection::setStations( const QList< dynplaylist_ptr >& stations ) Collection::setStations( const QList< dynplaylist_ptr >& stations )
{ {
// qDebug() << Q_FUNC_INFO << stations.count();
foreach ( const dynplaylist_ptr& s, stations ) foreach ( const dynplaylist_ptr& s, stations )
{ {
// qDebug() << "Batch inserting station:" << s->guid(); // qDebug() << "Batch inserting station:" << s->guid();
@@ -216,56 +207,29 @@ Collection::setStations( const QList< dynplaylist_ptr >& stations )
void void
Collection::setTracks( const QList<Tomahawk::query_ptr>& tracks ) Collection::setTracks( const QList<unsigned int>& ids )
{ {
// qDebug() << Q_FUNC_INFO << tracks.count() << name(); qDebug() << Q_FUNC_INFO << ids.count() << name();
emit tracksAdded( tracks ); emit tracksAdded( ids );
emit changed(); emit changed();
} }
void void
Collection::delTracks( const QStringList& files ) Collection::delTracks( const QList<unsigned int>& ids )
{ {
qDebug() << Q_FUNC_INFO << files.count() << name(); qDebug() << Q_FUNC_INFO << ids.count() << name();
emit tracksRemoved( ids );
emit changed(); emit changed();
/* QList<Tomahawk::query_ptr> tracks;
int i = 0;
foreach ( const query_ptr& query, m_tracks )
{
foreach ( const QString& file, files )
{
bool found = false;
foreach ( const result_ptr& result, query->results() )
{
if ( file == result->url() )
{
// qDebug() << Q_FUNC_INFO << "Found deleted result:" << file;
tracks << query;
m_tracks.removeAt( i );
i--;
found = true;
break;
}
}
if ( found )
break;
}
i++;
}
tDebug() << "Emitting tracks removed:" << tracks.size();
emit tracksRemoved( tracks );*/
} }
void void
Collection::moveAutoToStation( const QString& guid ) Collection::moveAutoToStation( const QString& guid )
{ {
if( m_autoplaylists.contains( guid ) ) if ( m_autoplaylists.contains( guid ) )
m_stations.insert( guid, m_autoplaylists.take( guid ) ); m_stations.insert( guid, m_autoplaylists.take( guid ) );
} }
@@ -273,6 +237,6 @@ Collection::moveAutoToStation( const QString& guid )
void void
Collection::moveStationToAuto( const QString& guid ) Collection::moveStationToAuto( const QString& guid )
{ {
if( m_stations.contains( guid ) ) if ( m_stations.contains( guid ) )
m_autoplaylists.insert( guid, m_stations.take( guid ) ); m_autoplaylists.insert( guid, m_stations.take( guid ) );
} }

View File

@@ -35,7 +35,6 @@
#include "functimeout.h" #include "functimeout.h"
#include "playlist.h" #include "playlist.h"
#include "playlist/dynamic/DynamicPlaylist.h" #include "playlist/dynamic/DynamicPlaylist.h"
#include "query.h"
#include "dllmacro.h" #include "dllmacro.h"
@@ -79,8 +78,8 @@ public:
unsigned int lastmodified() const { return m_lastmodified; } unsigned int lastmodified() const { return m_lastmodified; }
signals: signals:
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks ); void tracksAdded( const QList<unsigned int>& fileids );
void tracksRemoved( const QList<Tomahawk::query_ptr>& tracks ); void tracksRemoved( const QList<unsigned int>& fileids );
void playlistsAdded( const QList<Tomahawk::playlist_ptr>& ); void playlistsAdded( const QList<Tomahawk::playlist_ptr>& );
void playlistsDeleted( const QList<Tomahawk::playlist_ptr>& ); void playlistsDeleted( const QList<Tomahawk::playlist_ptr>& );
@@ -101,8 +100,8 @@ public slots:
void setAutoPlaylists( const QList< Tomahawk::dynplaylist_ptr >& autoplists ); void setAutoPlaylists( const QList< Tomahawk::dynplaylist_ptr >& autoplists );
void setStations( const QList< Tomahawk::dynplaylist_ptr >& stations ); void setStations( const QList< Tomahawk::dynplaylist_ptr >& stations );
void setTracks( const QList<Tomahawk::query_ptr>& tracks ); void setTracks( const QList<unsigned int>& fileids );
void delTracks( const QStringList& files ); void delTracks( const QList<unsigned int>& fileids );
protected: protected:
QString m_name; QString m_name;

View File

@@ -56,7 +56,6 @@ DatabaseCommand_AddFiles::files() const
void void
DatabaseCommand_AddFiles::postCommitHook() DatabaseCommand_AddFiles::postCommitHook()
{ {
qDebug() << Q_FUNC_INFO;
if ( source().isNull() || source()->collection().isNull() ) if ( source().isNull() || source()->collection().isNull() )
{ {
qDebug() << "Source has gone offline, not emitting to GUI."; qDebug() << "Source has gone offline, not emitting to GUI.";
@@ -67,13 +66,13 @@ DatabaseCommand_AddFiles::postCommitHook()
// collection browser will update/fade in etc. // collection browser will update/fade in etc.
Collection* coll = source()->collection().data(); Collection* coll = source()->collection().data();
connect( this, SIGNAL( notify( QList<Tomahawk::query_ptr> ) ), connect( this, SIGNAL( notify( QList<unsigned int> ) ),
coll, SLOT( setTracks( QList<Tomahawk::query_ptr> ) ), coll, SLOT( setTracks( QList<unsigned int> ) ),
Qt::QueuedConnection ); Qt::QueuedConnection );
emit notify( m_queries ); emit notify( m_ids );
if( source()->isLocal() ) if ( source()->isLocal() )
{ {
Servent::instance()->triggerDBSync(); Servent::instance()->triggerDBSync();
@@ -185,7 +184,7 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi )
query_trackattr.bindValue( 2, year ); query_trackattr.bindValue( 2, year );
query_trackattr.exec(); query_trackattr.exec();
QVariantMap attr; /* QVariantMap attr;
Tomahawk::query_ptr query = Tomahawk::Query::get( artist, track, album ); Tomahawk::query_ptr query = Tomahawk::Query::get( artist, track, album );
attr["releaseyear"] = m.value( "year" ); attr["releaseyear"] = m.value( "year" );
@@ -210,12 +209,13 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi )
results << result; results << result;
query->addResults( results ); query->addResults( results );
m_queries << query; m_queries << query;*/
m_ids << fileid;
added++; added++;
} }
qDebug() << "Inserted" << added << "tracks to database"; qDebug() << "Inserted" << added << "tracks to database";
// TODO building the index could be a separate job, outside this transaction
if ( added ) if ( added )
source()->updateIndexWhenSynced(); source()->updateIndexWhenSynced();

View File

@@ -1,5 +1,5 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@@ -55,11 +55,11 @@ public:
signals: signals:
void done( const QList<QVariant>&, const Tomahawk::collection_ptr& ); void done( const QList<QVariant>&, const Tomahawk::collection_ptr& );
void notify( const QList<Tomahawk::query_ptr>& ); void notify( const QList<unsigned int>& ids );
private: private:
QVariantList m_files; QVariantList m_files;
QList<Tomahawk::query_ptr> m_queries; QList<unsigned int> m_ids;
}; };
#endif // DATABASECOMMAND_ADDFILES_H #endif // DATABASECOMMAND_ADDFILES_H

View File

@@ -120,7 +120,7 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
Tomahawk::artist_ptr artistptr = Tomahawk::Artist::get( query.value( 12 ).toUInt(), artist ); Tomahawk::artist_ptr artistptr = Tomahawk::Artist::get( query.value( 12 ).toUInt(), artist );
Tomahawk::album_ptr albumptr = Tomahawk::Album::get( query.value( 13 ).toUInt(), album, artistptr ); Tomahawk::album_ptr albumptr = Tomahawk::Album::get( query.value( 13 ).toUInt(), album, artistptr );
result->setId( query.value( 14 ).toUInt() ); result->setTrackId( query.value( 14 ).toUInt() );
result->setArtist( artistptr ); result->setArtist( artistptr );
result->setAlbum( albumptr ); result->setAlbum( albumptr );
result->setTrack( query.value( 3 ).toString() ); result->setTrack( query.value( 3 ).toString() );
@@ -137,7 +137,7 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
QVariantMap attr; QVariantMap attr;
attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" ); attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" );
attrQuery.bindValue( 0, result->dbid() ); attrQuery.bindValue( 0, result->trackId() );
attrQuery.exec(); attrQuery.exec();
while ( attrQuery.next() ) while ( attrQuery.next() )
{ {

View File

@@ -45,11 +45,14 @@ DatabaseCommand_DeleteFiles::postCommitHook()
// collection browser will update/fade in etc. // collection browser will update/fade in etc.
Collection* coll = source()->collection().data(); Collection* coll = source()->collection().data();
connect( this, SIGNAL( notify( QStringList ) ), connect( this, SIGNAL( notify( QList<unsigned int> ) ),
coll, SLOT( delTracks( QStringList ) ), Qt::QueuedConnection ); coll, SLOT( delTracks( QList<unsigned int> ) ), Qt::QueuedConnection );
tDebug() << "Notifying of deleted tracks: " << m_files.size() << " from source " << source()->id(); tDebug() << "Notifying of deleted tracks:" << m_ids.size() << "from source" << source()->id();
emit notify( m_files ); QList<unsigned int> ids;
foreach ( QVariant id, m_ids )
ids << id.toUInt();
emit notify( ids );
if( source()->isLocal() ) if( source()->isLocal() )
Servent::instance()->triggerDBSync(); Servent::instance()->triggerDBSync();
@@ -59,7 +62,6 @@ DatabaseCommand_DeleteFiles::postCommitHook()
void void
DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi ) DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
{ {
// qDebug() << Q_FUNC_INFO;
Q_ASSERT( !source().isNull() ); Q_ASSERT( !source().isNull() );
QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id(); QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id();
@@ -68,7 +70,6 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
if ( source()->isLocal() ) if ( source()->isLocal() )
{ {
tDebug() << Q_FUNC_INFO << " source is local";
if ( m_dir.path() != QString( "." ) ) if ( m_dir.path() != QString( "." ) )
{ {
tDebug() << "Deleting" << m_dir.path() << "from db for localsource" << srcid; tDebug() << "Deleting" << m_dir.path() << "from db for localsource" << srcid;
@@ -95,7 +96,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
} }
else if ( !m_ids.isEmpty() ) else if ( !m_ids.isEmpty() )
{ {
tDebug() << Q_FUNC_INFO << " deleting given ids"; tDebug() << Q_FUNC_INFO << "deleting given ids";
TomahawkSqlQuery dirquery = dbi->newquery(); TomahawkSqlQuery dirquery = dbi->newquery();
QString idstring; QString idstring;
@@ -104,23 +105,19 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
idstring.chop( 2 ); //remove the trailing ", " idstring.chop( 2 ); //remove the trailing ", "
dirquery.prepare( QString( "SELECT id, url FROM file WHERE source IS NULL AND id IN ( %1 )" ).arg( idstring ) ); dirquery.prepare( QString( "SELECT id, url FROM file WHERE source IS NULL AND id IN ( %1 )" ).arg( idstring ) );
dirquery.exec(); dirquery.exec();
while ( dirquery.next() ) while ( dirquery.next() )
{ {
//tDebug() << Q_FUNC_INFO << " found dirquery value 0: " << dirquery.value( 0 ).toString() << " and value 1: " << dirquery.value( 1 ).toString();
m_files << dirquery.value( 1 ).toString(); m_files << dirquery.value( 1 ).toString();
} }
//tDebug() << Q_FUNC_INFO << " executed query was: " << dirquery.executedQuery();
//tDebug() << Q_FUNC_INFO << " files selected for delete: " << m_files;
} }
else if ( m_deleteAll ) else if ( m_deleteAll )
{ {
TomahawkSqlQuery dirquery = dbi->newquery(); TomahawkSqlQuery dirquery = dbi->newquery();
dirquery.prepare( QString( "SELECT id, url FROM file WHERE source IS NULL" ) ); dirquery.prepare( QString( "SELECT id, url FROM file WHERE source IS NULL" ) );
dirquery.exec(); dirquery.exec();
while ( dirquery.next() ) while ( dirquery.next() )
{ {
@@ -134,10 +131,10 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
if ( m_deleteAll ) if ( m_deleteAll )
{ {
TomahawkSqlQuery dirquery = dbi->newquery(); TomahawkSqlQuery dirquery = dbi->newquery();
dirquery.prepare( QString( "SELECT url FROM file WHERE source = %1" ).arg( source()->id() ) ); dirquery.prepare( QString( "SELECT url FROM file WHERE source = %1" ).arg( source()->id() ) );
dirquery.exec(); dirquery.exec();
while ( dirquery.next() ) while ( dirquery.next() )
m_ids << dirquery.value( 0 ).toString(); m_ids << dirquery.value( 0 ).toString();
} }
@@ -151,43 +148,28 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
if ( !m_ids.isEmpty() ) if ( !m_ids.isEmpty() )
{ {
delquery.prepare( QString( "DELETE FROM file WHERE source %1" ) delquery.prepare( QString( "DELETE FROM file WHERE source %1" )
.arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) ) ); .arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) ) );
if( !delquery.exec() ) delquery.exec();
{
qDebug() << "Failed to delete file:"
<< delquery.lastError().databaseText()
<< delquery.lastError().driverText()
<< delquery.boundValues();
}
} }
} }
else if ( !m_ids.isEmpty() ) else if ( !m_ids.isEmpty() )
{ {
tDebug() << Q_FUNC_INFO << " executing delete";
delquery.prepare( QString( "DELETE FROM file WHERE source %1 AND %2 IN ( ? )" ) delquery.prepare( QString( "DELETE FROM file WHERE source %1 AND %2 IN ( ? )" )
.arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) ) .arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) )
.arg( source()->isLocal() ? "id" : "url" ) ); .arg( source()->isLocal() ? "id" : "url" ) );
QString idstring; QString idstring;
foreach( const QVariant& id, m_ids ) foreach( const QVariant& id, m_ids )
idstring.append( id.toString() + ", " ); idstring.append( id.toString() + ", " );
idstring.chop( 2 ); //remove the trailing ", " idstring.chop( 2 ); //remove the trailing ", "
delquery.prepare( QString( "DELETE FROM file WHERE source %1 AND %2 IN ( %3 )" ) delquery.prepare( QString( "DELETE FROM file WHERE source %1 AND %2 IN ( %3 )" )
.arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) ) .arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) )
.arg( source()->isLocal() ? "id" : "url" ) .arg( source()->isLocal() ? "id" : "url" )
.arg( idstring ) ); .arg( idstring ) );
if( !delquery.exec() )
{
qDebug() << "Failed to delete file:"
<< delquery.lastError().databaseText()
<< delquery.lastError().driverText()
<< delquery.boundValues();
}
//tDebug() << Q_FUNC_INFO << " executed query was: " << delquery.executedQuery(); delquery.exec();
} }
emit done( m_files, source()->collection() ); emit done( m_files, source()->collection() );

View File

@@ -74,7 +74,7 @@ public:
signals: signals:
void done( const QStringList&, const Tomahawk::collection_ptr& ); void done( const QStringList&, const Tomahawk::collection_ptr& );
void notify( const QStringList& ); void notify( const QList<unsigned int>& ids );
private: private:
QStringList m_files; QStringList m_files;

View File

@@ -16,34 +16,43 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "databasecommand_loadfile.h" #include "databasecommand_loadfiles.h"
#include "databaseimpl.h" #include "databaseimpl.h"
#include "collection.h" #include "collection.h"
#include "utils/logger.h" #include "utils/logger.h"
DatabaseCommand_LoadFile::DatabaseCommand_LoadFile( const QString& id, QObject* parent ) DatabaseCommand_LoadFiles::DatabaseCommand_LoadFiles( unsigned int id, QObject* parent )
: DatabaseCommand( parent ) : DatabaseCommand( parent )
, m_id( id ) , m_single( true )
{
m_ids << id;
}
DatabaseCommand_LoadFiles::DatabaseCommand_LoadFiles( const QList<unsigned int>& ids, QObject* parent )
: DatabaseCommand( parent )
, m_single( false )
, m_ids( ids )
{ {
} }
void void
DatabaseCommand_LoadFile::exec( DatabaseImpl* dbi ) DatabaseCommand_LoadFiles::exec( DatabaseImpl* dbi )
{ {
Tomahawk::result_ptr r; QList<Tomahawk::result_ptr> resultList;
// file ids internally are really ints, at least for now: // file ids internally are really ints, at least for now:
bool ok; foreach ( unsigned int id, m_ids )
do
{ {
unsigned int fid = m_id.toInt( &ok ); qDebug() << "Loading file from db with id:" << id;
if( !ok ) resultList << dbi->file( id );
break; }
r = dbi->file( fid ); Q_ASSERT( !m_single || resultList.size() <= 1 );
} while( false );
emit result( r ); if ( m_single && !resultList.isEmpty() )
emit result( resultList.first() );
else
emit results( resultList );
} }

View File

@@ -16,32 +16,42 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef DATABASECOMMAND_LOADFILE_H #ifndef DATABASECOMMAND_LOADFILES_H
#define DATABASECOMMAND_LOADFILE_H #define DATABASECOMMAND_LOADFILES_H
#include <QObject> #include <QObject>
#include <QVariantMap> #include <QVariantMap>
#include <QStringList>
#include <QMap> #include <QMap>
#include "databasecommand.h" #include "databasecommand.h"
#include "result.h" #include "result.h"
#include "dllmacro.h" #include "dllmacro.h"
class DLLEXPORT DatabaseCommand_LoadFile : public DatabaseCommand /**
Loads a result_ptr from the database from a track dbid.
If use use the QStringList constructor, isten to results() instead of result()
*/
class DLLEXPORT DatabaseCommand_LoadFiles : public DatabaseCommand
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DatabaseCommand_LoadFile( const QString& id, QObject* parent = 0 ); explicit DatabaseCommand_LoadFiles( unsigned int id, QObject* parent = 0 );
explicit DatabaseCommand_LoadFiles( const QList<unsigned int>& ids, QObject* parent = 0 );
virtual void exec( DatabaseImpl* ); virtual void exec( DatabaseImpl* );
virtual bool doesMutates() const { return false; } virtual bool doesMutates() const { return false; }
virtual QString commandname() const { return "loadfile"; } virtual QString commandname() const { return "loadfiles"; }
signals: signals:
void result( const Tomahawk::result_ptr& result ); void result( const Tomahawk::result_ptr& result );
void results( const QList<Tomahawk::result_ptr>& results );
private: private:
QString m_id; bool m_single;
QList<unsigned int> m_ids;
}; };
#endif // DATABASECOMMAND_LOADFILE_H #endif // DATABASECOMMAND_LOADFILE_H

View File

@@ -156,14 +156,14 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
result->setTrack( files_query.value( 12 ).toString() ); result->setTrack( files_query.value( 12 ).toString() );
result->setRID( uuid() ); result->setRID( uuid() );
result->setAlbumPos( files_query.value( 14 ).toUInt() ); result->setAlbumPos( files_query.value( 14 ).toUInt() );
result->setId( files_query.value( 9 ).toUInt() ); result->setTrackId( files_query.value( 9 ).toUInt() );
result->setYear( files_query.value( 17 ).toUInt() ); result->setYear( files_query.value( 17 ).toUInt() );
TomahawkSqlQuery attrQuery = lib->newquery(); TomahawkSqlQuery attrQuery = lib->newquery();
QVariantMap attr; QVariantMap attr;
attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" ); attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" );
attrQuery.bindValue( 0, result->dbid() ); attrQuery.bindValue( 0, result->trackId() );
attrQuery.exec(); attrQuery.exec();
while ( attrQuery.next() ) while ( attrQuery.next() )
{ {
@@ -268,12 +268,12 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
result->setTrack( files_query.value( 12 ).toString() ); result->setTrack( files_query.value( 12 ).toString() );
result->setRID( uuid() ); result->setRID( uuid() );
result->setAlbumPos( files_query.value( 14 ).toUInt() ); result->setAlbumPos( files_query.value( 14 ).toUInt() );
result->setId( files_query.value( 9 ).toUInt() ); result->setTrackId( files_query.value( 9 ).toUInt() );
result->setYear( files_query.value( 17 ).toUInt() ); result->setYear( files_query.value( 17 ).toUInt() );
for ( int k = 0; k < tracks.count(); k++ ) for ( int k = 0; k < tracks.count(); k++ )
{ {
if ( tracks.at( k ).first == (int)result->dbid() ) if ( tracks.at( k ).first == (int)result->trackId() )
{ {
result->setScore( tracks.at( k ).second ); result->setScore( tracks.at( k ).second );
break; break;
@@ -284,7 +284,7 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
QVariantMap attr; QVariantMap attr;
attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" ); attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" );
attrQuery.bindValue( 0, result->dbid() ); attrQuery.bindValue( 0, result->trackId() );
attrQuery.exec(); attrQuery.exec();
while ( attrQuery.next() ) while ( attrQuery.next() )
{ {

View File

@@ -249,9 +249,10 @@ DatabaseImpl::file( int fid )
r->setArtist( artist ); r->setArtist( artist );
r->setAlbum( album ); r->setAlbum( album );
r->setTrack( query.value( 12 ).toString() ); r->setTrack( query.value( 12 ).toString() );
r->setId( query.value( 9 ).toUInt() ); r->setTrackId( query.value( 9 ).toUInt() );
r->setCollection( s->collection() ); r->setCollection( s->collection() );
r->setScore( 1.0 ); r->setScore( 1.0 );
r->setFileId( fid );
} }
return r; return r;
@@ -608,7 +609,7 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
res->setTrack( query.value( 12 ).toString() ); res->setTrack( query.value( 12 ).toString() );
res->setAlbumPos( query.value( 14 ).toUInt() ); res->setAlbumPos( query.value( 14 ).toUInt() );
res->setRID( uuid() ); res->setRID( uuid() );
res->setId( query.value( 9 ).toUInt() ); res->setTrackId( query.value( 9 ).toUInt() );
res->setCollection( s->collection() ); res->setCollection( s->collection() );
res->setYear( query.value( 17 ).toUInt() ); res->setYear( query.value( 17 ).toUInt() );
} }

View File

@@ -52,17 +52,6 @@ RoviPlugin::~RoviPlugin()
} }
void
RoviPlugin::namChangedSlot( QNetworkAccessManager* nam )
{
if ( !nam )
return;
m_nam = nam;
}
void void
RoviPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) RoviPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
@@ -194,7 +183,7 @@ RoviPlugin::makeRequest( QUrl url )
url.addEncodedQueryItem( "sig", generateSig() ); url.addEncodedQueryItem( "sig", generateSig() );
qDebug() << "Rovi request url:" << url.toString(); qDebug() << "Rovi request url:" << url.toString();
return m_nam->get( QNetworkRequest( url ) ); return TomahawkUtils::nam()->get( QNetworkRequest( url ) );
} }

View File

@@ -39,7 +39,6 @@ public:
virtual ~RoviPlugin(); virtual ~RoviPlugin();
protected: protected:
virtual void namChangedSlot( QNetworkAccessManager* nam );
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );
virtual void pushInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant ) virtual void pushInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant )
@@ -54,8 +53,6 @@ private:
QNetworkReply* makeRequest( QUrl url ); QNetworkReply* makeRequest( QUrl url );
QByteArray generateSig() const; QByteArray generateSig() const;
QNetworkAccessManager* m_nam;
QByteArray m_apiKey; QByteArray m_apiKey;
QByteArray m_secret; QByteArray m_secret;
}; };

View File

@@ -52,6 +52,22 @@ ChartsPlugin::ChartsPlugin()
m_chartResources << "billboard" << "itunes" << "rdio" << "wearehunted"; m_chartResources << "billboard" << "itunes" << "rdio" << "wearehunted";
m_supportedGetTypes << InfoChart << InfoChartCapabilities; m_supportedGetTypes << InfoChart << InfoChartCapabilities;
/// Then get each chart from resource
/// We want to prepopulate the breadcrumb to fetch them before they are asked for
if ( !m_chartResources.isEmpty() && m_allChartsMap.isEmpty() )
{
tDebug() << "ChartsPlugin: InfoChart fetching possible resources";
foreach ( QVariant resource, m_chartResources )
{
QUrl url = QUrl( QString( CHART_URL "source/%1" ).arg(resource.toString() ) );
QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
tDebug() << "fetching:" << url;
connect( reply, SIGNAL( finished() ), SLOT( chartTypes() ) );
m_chartsFetchJobs++;
}
}
} }
@@ -61,38 +77,6 @@ ChartsPlugin::~ChartsPlugin()
} }
void
ChartsPlugin::namChangedSlot( QNetworkAccessManager *nam )
{
tDebug() << "ChartsPlugin: namChangedSLot";
qDebug() << Q_FUNC_INFO;
if( !nam )
return;
m_nam = QWeakPointer< QNetworkAccessManager >( nam );
/// Then get each chart from resource
/// We want to prepopulate the breadcrumb to fetch them before they are asked for
if ( !m_chartResources.isEmpty() && m_nam && m_allChartsMap.isEmpty() )
{
tDebug() << "ChartsPlugin: InfoChart fetching possible resources";
foreach ( QVariant resource, m_chartResources )
{
QUrl url = QUrl( QString( CHART_URL "source/%1" ).arg(resource.toString() ) );
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) );
tDebug() << "fetching:" << url;
connect( reply, SIGNAL( finished() ), SLOT( chartTypes() ) );
m_chartsFetchJobs++;
}
}
}
void void
ChartsPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData ) ChartsPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
@@ -202,14 +186,6 @@ ChartsPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData requ
void void
ChartsPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) ChartsPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
if ( !m_nam.data() )
{
tLog() << "Have a null QNAM, uh oh";
emit info( requestData, QVariant() );
return;
}
switch ( requestData.type ) switch ( requestData.type )
{ {
case InfoChart: case InfoChart:
@@ -218,7 +194,7 @@ ChartsPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSy
QUrl url = QUrl( QString( CHART_URL "source/%1/chart/%2" ).arg( criteria["chart_source"] ).arg( criteria["chart_id"] ) ); QUrl url = QUrl( QString( CHART_URL "source/%1/chart/%2" ).arg( criteria["chart_source"] ).arg( criteria["chart_id"] ) );
qDebug() << Q_FUNC_INFO << "Getting chart url" << url; qDebug() << Q_FUNC_INFO << "Getting chart url" << url;
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) ); QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) ); reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) ); connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) );

View File

@@ -53,7 +53,6 @@ public:
public slots: public slots:
void chartReturned(); void chartReturned();
void chartTypes(); void chartTypes();
void namChangedSlot( QNetworkAccessManager *nam );
protected slots: protected slots:
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );

View File

@@ -37,35 +37,12 @@ EchoNestPlugin::EchoNestPlugin()
m_supportedGetTypes << Tomahawk::InfoSystem::InfoArtistBiography << Tomahawk::InfoSystem::InfoArtistFamiliarity << Tomahawk::InfoSystem::InfoArtistHotttness << Tomahawk::InfoSystem::InfoArtistTerms << Tomahawk::InfoSystem::InfoMiscTopTerms; m_supportedGetTypes << Tomahawk::InfoSystem::InfoArtistBiography << Tomahawk::InfoSystem::InfoArtistFamiliarity << Tomahawk::InfoSystem::InfoArtistHotttness << Tomahawk::InfoSystem::InfoArtistTerms << Tomahawk::InfoSystem::InfoMiscTopTerms;
} }
EchoNestPlugin::~EchoNestPlugin() EchoNestPlugin::~EchoNestPlugin()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
} }
void
EchoNestPlugin::namChangedSlot( QNetworkAccessManager *nam )
{
qDebug() << Q_FUNC_INFO;
if( !nam )
return;
QNetworkAccessManager* currNam = Echonest::Config::instance()->nam();
TomahawkUtils::NetworkProxyFactory* oldProxyFactory = dynamic_cast< TomahawkUtils::NetworkProxyFactory* >( nam->proxyFactory() );
if ( !oldProxyFactory )
{
qDebug() << "Could not get old proxyFactory!";
return;
}
currNam->setConfiguration( nam->configuration() );
currNam->setNetworkAccessible( nam->networkAccessible() );
TomahawkUtils::NetworkProxyFactory* newProxyFactory = new TomahawkUtils::NetworkProxyFactory();
newProxyFactory->setNoProxyHosts( oldProxyFactory->noProxyHosts() );
QNetworkProxy newProxy( oldProxyFactory->proxy() );
newProxyFactory->setProxy( newProxy );
currNam->setProxyFactory( newProxyFactory );
}
void void
EchoNestPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) EchoNestPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
@@ -92,6 +69,7 @@ EchoNestPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
} }
} }
void void
EchoNestPlugin::getSongProfile( const Tomahawk::InfoSystem::InfoRequestData &requestData, const QString &item ) EchoNestPlugin::getSongProfile( const Tomahawk::InfoSystem::InfoRequestData &requestData, const QString &item )
{ {
@@ -109,6 +87,7 @@ EchoNestPlugin::getSongProfile( const Tomahawk::InfoSystem::InfoRequestData &req
// connect(reply, SIGNAL(finished()), SLOT(getArtistBiographySlot())); // connect(reply, SIGNAL(finished()), SLOT(getArtistBiographySlot()));
} }
void void
EchoNestPlugin::getArtistBiography( const Tomahawk::InfoSystem::InfoRequestData &requestData ) EchoNestPlugin::getArtistBiography( const Tomahawk::InfoSystem::InfoRequestData &requestData )
{ {
@@ -122,6 +101,7 @@ EchoNestPlugin::getArtistBiography( const Tomahawk::InfoSystem::InfoRequestData
connect( reply, SIGNAL( finished() ), SLOT( getArtistBiographySlot() ) ); connect( reply, SIGNAL( finished() ), SLOT( getArtistBiographySlot() ) );
} }
void void
EchoNestPlugin::getArtistFamiliarity( const Tomahawk::InfoSystem::InfoRequestData &requestData ) EchoNestPlugin::getArtistFamiliarity( const Tomahawk::InfoSystem::InfoRequestData &requestData )
{ {
@@ -136,6 +116,7 @@ EchoNestPlugin::getArtistFamiliarity( const Tomahawk::InfoSystem::InfoRequestDat
connect( reply, SIGNAL( finished() ), SLOT( getArtistFamiliaritySlot() ) ); connect( reply, SIGNAL( finished() ), SLOT( getArtistFamiliaritySlot() ) );
} }
void void
EchoNestPlugin::getArtistHotttnesss( const Tomahawk::InfoSystem::InfoRequestData &requestData ) EchoNestPlugin::getArtistHotttnesss( const Tomahawk::InfoSystem::InfoRequestData &requestData )
{ {
@@ -149,6 +130,7 @@ EchoNestPlugin::getArtistHotttnesss( const Tomahawk::InfoSystem::InfoRequestData
connect( reply, SIGNAL( finished() ), SLOT( getArtistHotttnesssSlot() ) ); connect( reply, SIGNAL( finished() ), SLOT( getArtistHotttnesssSlot() ) );
} }
void void
EchoNestPlugin::getArtistTerms( const Tomahawk::InfoSystem::InfoRequestData &requestData ) EchoNestPlugin::getArtistTerms( const Tomahawk::InfoSystem::InfoRequestData &requestData )
{ {
@@ -162,6 +144,7 @@ EchoNestPlugin::getArtistTerms( const Tomahawk::InfoSystem::InfoRequestData &req
connect( reply, SIGNAL( finished() ), SLOT( getArtistTermsSlot() ) ); connect( reply, SIGNAL( finished() ), SLOT( getArtistTermsSlot() ) );
} }
void void
EchoNestPlugin::getMiscTopTerms( const Tomahawk::InfoSystem::InfoRequestData &requestData ) EchoNestPlugin::getMiscTopTerms( const Tomahawk::InfoSystem::InfoRequestData &requestData )
{ {
@@ -194,6 +177,7 @@ EchoNestPlugin::getArtistBiographySlot()
reply->deleteLater(); reply->deleteLater();
} }
void void
EchoNestPlugin::getArtistFamiliaritySlot() EchoNestPlugin::getArtistFamiliaritySlot()
{ {
@@ -205,6 +189,7 @@ EchoNestPlugin::getArtistFamiliaritySlot()
reply->deleteLater(); reply->deleteLater();
} }
void void
EchoNestPlugin::getArtistHotttnesssSlot() EchoNestPlugin::getArtistHotttnesssSlot()
{ {
@@ -216,6 +201,7 @@ EchoNestPlugin::getArtistHotttnesssSlot()
reply->deleteLater(); reply->deleteLater();
} }
void void
EchoNestPlugin::getArtistTermsSlot() EchoNestPlugin::getArtistTermsSlot()
{ {
@@ -234,6 +220,7 @@ EchoNestPlugin::getArtistTermsSlot()
reply->deleteLater(); reply->deleteLater();
} }
void void
EchoNestPlugin::getMiscTopSlot() EchoNestPlugin::getMiscTopSlot()
{ {
@@ -251,6 +238,7 @@ EchoNestPlugin::getMiscTopSlot()
reply->deleteLater(); reply->deleteLater();
} }
bool bool
EchoNestPlugin::isValidArtistData( const Tomahawk::InfoSystem::InfoRequestData &requestData ) EchoNestPlugin::isValidArtistData( const Tomahawk::InfoSystem::InfoRequestData &requestData )
{ {
@@ -268,6 +256,7 @@ EchoNestPlugin::isValidArtistData( const Tomahawk::InfoSystem::InfoRequestData &
return true; return true;
} }
bool bool
EchoNestPlugin::isValidTrackData( const Tomahawk::InfoSystem::InfoRequestData &requestData ) EchoNestPlugin::isValidTrackData( const Tomahawk::InfoSystem::InfoRequestData &requestData )
{ {
@@ -290,6 +279,7 @@ EchoNestPlugin::isValidTrackData( const Tomahawk::InfoSystem::InfoRequestData &r
return true; return true;
} }
Artist Artist
EchoNestPlugin::artistFromReply( QNetworkReply* reply ) EchoNestPlugin::artistFromReply( QNetworkReply* reply )
{ {

View File

@@ -61,9 +61,6 @@ protected slots:
Q_UNUSED( requestData ); Q_UNUSED( requestData );
} }
public slots:
void namChangedSlot( QNetworkAccessManager *nam );
private: private:
void getSongProfile( const Tomahawk::InfoSystem::InfoRequestData &requestData, const QString &item = QString() ); void getSongProfile( const Tomahawk::InfoSystem::InfoRequestData &requestData, const QString &item = QString() );
void getArtistBiography( const Tomahawk::InfoSystem::InfoRequestData &requestData ); void getArtistBiography( const Tomahawk::InfoSystem::InfoRequestData &requestData );

View File

@@ -102,20 +102,6 @@ hypemPlugin::~hypemPlugin()
} }
void
hypemPlugin::namChangedSlot( QNetworkAccessManager *nam )
{
tDebug() << "hypemPlugin: namChangedSLot";
qDebug() << Q_FUNC_INFO;
if( !nam )
return;
m_nam = QWeakPointer< QNetworkAccessManager >( nam );
}
void void
hypemPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData ) hypemPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
@@ -207,14 +193,6 @@ hypemPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData reque
void void
hypemPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) hypemPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
if ( !m_nam.data() )
{
tLog() << "Have a null QNAM, uh oh";
emit info( requestData, QVariant() );
return;
}
switch ( requestData.type ) switch ( requestData.type )
{ {
case InfoChart: case InfoChart:
@@ -224,7 +202,7 @@ hypemPlugin::notInCacheSlot( QHash<QString, QString> criteria, Tomahawk::InfoSys
QUrl url = QUrl( QString( HYPEM_URL "%1/%2" ).arg( criteria["chart_id"].toLower() ).arg(HYPEM_END_URL) ); QUrl url = QUrl( QString( HYPEM_URL "%1/%2" ).arg( criteria["chart_id"].toLower() ).arg(HYPEM_END_URL) );
qDebug() << Q_FUNC_INFO << "Getting chart url" << url; qDebug() << Q_FUNC_INFO << "Getting chart url" << url;
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) ); QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) ); reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) ); connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) );
return; return;

View File

@@ -53,7 +53,6 @@ public:
public slots: public slots:
void chartReturned(); void chartReturned();
void chartTypes(); void chartTypes();
void namChangedSlot( QNetworkAccessManager *nam );
protected slots: protected slots:
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
@@ -82,8 +81,6 @@ private:
QList< InfoRequestData > m_cachedRequests; QList< InfoRequestData > m_cachedRequests;
QHash< QString, QString > m_cachedCountries; QHash< QString, QString > m_cachedCountries;
QWeakPointer< QNetworkAccessManager > m_nam;
}; };
} }

View File

@@ -94,34 +94,6 @@ LastFmPlugin::~LastFmPlugin()
} }
void
LastFmPlugin::namChangedSlot( QNetworkAccessManager *nam )
{
if ( !nam )
return;
TomahawkUtils::NetworkProxyFactory* oldProxyFactory = dynamic_cast< TomahawkUtils::NetworkProxyFactory* >( nam->proxyFactory() );
if ( !oldProxyFactory )
{
tLog() << Q_FUNC_INFO << "Could not get old proxyFactory!";
return;
}
//WARNING: there's a chance liblastfm2 will clobber the application proxy factory it if it constructs a nam due to the below call
//but it is unsafe to re-set it here
QNetworkAccessManager* currNam = lastfm::nam();
currNam->setConfiguration( nam->configuration() );
currNam->setNetworkAccessible( nam->networkAccessible() );
TomahawkUtils::NetworkProxyFactory* newProxyFactory = new TomahawkUtils::NetworkProxyFactory();
newProxyFactory->setNoProxyHosts( oldProxyFactory->noProxyHosts() );
QNetworkProxy newProxy( oldProxyFactory->proxy() );
newProxyFactory->setProxy( newProxy );
currNam->setProxyFactory( newProxyFactory );
settingsChanged(); // to get the scrobbler set up
}
void void
LastFmPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData ) LastFmPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {

View File

@@ -53,8 +53,6 @@ public slots:
void topTracksReturned(); void topTracksReturned();
void chartReturned(); void chartReturned();
void namChangedSlot( QNetworkAccessManager *nam );
protected slots: protected slots:
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData );

View File

@@ -41,15 +41,6 @@ MusicBrainzPlugin::~MusicBrainzPlugin()
} }
void
MusicBrainzPlugin::namChangedSlot( QNetworkAccessManager *nam )
{
if ( !nam )
return;
m_nam = QWeakPointer< QNetworkAccessManager >( nam );
}
void void
MusicBrainzPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) MusicBrainzPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
@@ -107,7 +98,7 @@ MusicBrainzPlugin::notInCacheSlot( InfoStringHash criteria, InfoRequestData requ
QString requestString( "http://musicbrainz.org/ws/2/artist" ); QString requestString( "http://musicbrainz.org/ws/2/artist" );
QUrl url( requestString ); QUrl url( requestString );
url.addQueryItem( "query", criteria["artist"] ); url.addQueryItem( "query", criteria["artist"] );
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) ); QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) ); reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( artistSearchSlot() ) ); connect( reply, SIGNAL( finished() ), SLOT( artistSearchSlot() ) );
@@ -119,7 +110,7 @@ MusicBrainzPlugin::notInCacheSlot( InfoStringHash criteria, InfoRequestData requ
QString requestString( "http://musicbrainz.org/ws/2/artist" ); QString requestString( "http://musicbrainz.org/ws/2/artist" );
QUrl url( requestString ); QUrl url( requestString );
url.addQueryItem( "query", criteria["artist"] ); url.addQueryItem( "query", criteria["artist"] );
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) ); QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) ); reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( albumSearchSlot() ) ); connect( reply, SIGNAL( finished() ), SLOT( albumSearchSlot() ) );
@@ -182,7 +173,7 @@ MusicBrainzPlugin::artistSearchSlot()
QUrl url( requestString ); QUrl url( requestString );
url.addQueryItem( "artist", artist_id ); url.addQueryItem( "artist", artist_id );
QNetworkReply* newReply = m_nam.data()->get( QNetworkRequest( url ) ); QNetworkReply* newReply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
newReply->setProperty( "requestData", oldReply->property( "requestData" ) ); newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( albumFoundSlot() ) ); connect( newReply, SIGNAL( finished() ), SLOT( albumFoundSlot() ) );
} }
@@ -209,7 +200,7 @@ MusicBrainzPlugin::albumSearchSlot()
QUrl url( requestString ); QUrl url( requestString );
url.addQueryItem( "artist", artist_id ); url.addQueryItem( "artist", artist_id );
QNetworkReply* newReply = m_nam.data()->get( QNetworkRequest( url ) ); QNetworkReply* newReply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
newReply->setProperty( "requestData", oldReply->property( "requestData" ) ); newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( tracksSearchSlot() ) ); connect( newReply, SIGNAL( finished() ), SLOT( tracksSearchSlot() ) );
} }
@@ -252,7 +243,7 @@ MusicBrainzPlugin::tracksSearchSlot()
QString requestString = QString( "http://musicbrainz.org/ws/2/release/%1?inc=recordings" ).arg( release_id ); QString requestString = QString( "http://musicbrainz.org/ws/2/release/%1?inc=recordings" ).arg( release_id );
QUrl url( requestString ); QUrl url( requestString );
QNetworkReply* newReply = m_nam.data()->get( QNetworkRequest( url ) ); QNetworkReply* newReply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
newReply->setProperty( "requestData", oldReply->property( "requestData" ) ); newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( tracksFoundSlot() ) ); connect( newReply, SIGNAL( finished() ), SLOT( tracksFoundSlot() ) );
} }

View File

@@ -38,9 +38,6 @@ public:
MusicBrainzPlugin(); MusicBrainzPlugin();
virtual ~MusicBrainzPlugin(); virtual ~MusicBrainzPlugin();
public slots:
void namChangedSlot( QNetworkAccessManager *nam );
protected slots: protected slots:
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
virtual void notInCacheSlot( InfoStringHash criteria, InfoRequestData requestData ); virtual void notInCacheSlot( InfoStringHash criteria, InfoRequestData requestData );
@@ -63,8 +60,6 @@ private slots:
private: private:
bool isValidTrackData( Tomahawk::InfoSystem::InfoRequestData requestData ); bool isValidTrackData( Tomahawk::InfoSystem::InfoRequestData requestData );
QWeakPointer< QNetworkAccessManager > m_nam;
}; };
} }

View File

@@ -42,21 +42,11 @@ MusixMatchPlugin::~MusixMatchPlugin()
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
} }
void
MusixMatchPlugin::namChangedSlot( QNetworkAccessManager *nam )
{
qDebug() << Q_FUNC_INFO;
if( !nam )
return;
m_nam = QWeakPointer< QNetworkAccessManager >( nam );
}
void void
MusixMatchPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) MusixMatchPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if( !isValidTrackData( requestData ) || !requestData.input.canConvert< QVariantMap >() || m_nam.isNull() || requestData.type != Tomahawk::InfoSystem::InfoTrackLyrics ) if( !isValidTrackData( requestData ) || !requestData.input.canConvert< QVariantMap >() || requestData.type != Tomahawk::InfoSystem::InfoTrackLyrics )
return; return;
QVariantMap hash = requestData.input.value< QVariantMap >(); QVariantMap hash = requestData.input.value< QVariantMap >();
QString artist = hash["artistName"].toString(); QString artist = hash["artistName"].toString();
@@ -72,7 +62,7 @@ MusixMatchPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
url.addQueryItem( "apikey", m_apiKey ); url.addQueryItem( "apikey", m_apiKey );
url.addQueryItem( "q_artist", artist ); url.addQueryItem( "q_artist", artist );
url.addQueryItem( "q_track", track ); url.addQueryItem( "q_track", track );
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) ); QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) ); reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( trackSearchSlot() ) ); connect( reply, SIGNAL( finished() ), SLOT( trackSearchSlot() ) );
@@ -126,7 +116,7 @@ MusixMatchPlugin::trackSearchSlot()
QUrl url( requestString ); QUrl url( requestString );
url.addQueryItem( "apikey", m_apiKey ); url.addQueryItem( "apikey", m_apiKey );
url.addQueryItem( "track_id", track_id ); url.addQueryItem( "track_id", track_id );
QNetworkReply* newReply = m_nam.data()->get( QNetworkRequest( url ) ); QNetworkReply* newReply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
newReply->setProperty( "requestData", oldReply->property( "requestData" ) ); newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( trackLyricsSlot() ) ); connect( newReply, SIGNAL( finished() ), SLOT( trackLyricsSlot() ) );
} }

View File

@@ -42,8 +42,6 @@ public slots:
void trackSearchSlot(); void trackSearchSlot();
void trackLyricsSlot(); void trackLyricsSlot();
void namChangedSlot( QNetworkAccessManager *nam );
protected slots: protected slots:
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
@@ -64,8 +62,6 @@ private:
bool isValidTrackData( Tomahawk::InfoSystem::InfoRequestData requestData ); bool isValidTrackData( Tomahawk::InfoSystem::InfoRequestData requestData );
QString m_apiKey; QString m_apiKey;
QWeakPointer< QNetworkAccessManager > m_nam;
}; };
} }

View File

@@ -47,26 +47,7 @@ SpotifyPlugin::SpotifyPlugin()
m_supportedGetTypes << InfoChart << InfoChartCapabilities; m_supportedGetTypes << InfoChart << InfoChartCapabilities;
} // we never need to re-fetch
SpotifyPlugin::~SpotifyPlugin()
{
qDebug() << Q_FUNC_INFO;
}
void
SpotifyPlugin::namChangedSlot( QNetworkAccessManager *nam )
{
tDebug() << "SpotifyPlugin: namChangedSLot";
qDebug() << Q_FUNC_INFO;
if( !nam )
return;
m_nam = QWeakPointer< QNetworkAccessManager >( nam );
// we never need to re-fetch
if ( !m_allChartsMap.isEmpty() ) if ( !m_allChartsMap.isEmpty() )
return; return;
@@ -74,7 +55,7 @@ SpotifyPlugin::namChangedSlot( QNetworkAccessManager *nam )
tDebug() << "SpotifyPlugin: InfoChart fetching possible resources"; tDebug() << "SpotifyPlugin: InfoChart fetching possible resources";
QUrl url = QUrl( QString( SPOTIFY_API_URL "toplist/charts" ) ); QUrl url = QUrl( QString( SPOTIFY_API_URL "toplist/charts" ) );
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) ); QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
tDebug() << Q_FUNC_INFO << "fetching:" << url; tDebug() << Q_FUNC_INFO << "fetching:" << url;
connect( reply, SIGNAL( finished() ), SLOT( chartTypes() ) ); connect( reply, SIGNAL( finished() ), SLOT( chartTypes() ) );
m_chartsFetchJobs++; m_chartsFetchJobs++;
@@ -82,6 +63,12 @@ SpotifyPlugin::namChangedSlot( QNetworkAccessManager *nam )
} }
SpotifyPlugin::~SpotifyPlugin()
{
qDebug() << Q_FUNC_INFO;
}
void void
SpotifyPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData ) SpotifyPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
@@ -164,14 +151,6 @@ SpotifyPlugin::fetchChartCapabilities( Tomahawk::InfoSystem::InfoRequestData req
void void
SpotifyPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) SpotifyPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
if ( !m_nam.data() )
{
tLog() << Q_FUNC_INFO << "Have a null QNAM, uh oh";
emit info( requestData, QVariant() );
return;
}
switch ( requestData.type ) switch ( requestData.type )
{ {
@@ -181,7 +160,7 @@ SpotifyPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, To
QUrl url = QUrl( QString( SPOTIFY_API_URL "toplist/%1/" ).arg( criteria["chart_id"] ) ); QUrl url = QUrl( QString( SPOTIFY_API_URL "toplist/%1/" ).arg( criteria["chart_id"] ) );
qDebug() << Q_FUNC_INFO << "Getting chart url" << url; qDebug() << Q_FUNC_INFO << "Getting chart url" << url;
QNetworkReply* reply = m_nam.data()->get( QNetworkRequest( url ) ); QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) ); reply->setProperty( "requestData", QVariant::fromValue< Tomahawk::InfoSystem::InfoRequestData >( requestData ) );
connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) ); connect( reply, SIGNAL( finished() ), SLOT( chartReturned() ) );
return; return;

View File

@@ -53,7 +53,6 @@ public:
public slots: public slots:
void chartReturned(); void chartReturned();
void chartTypes(); void chartTypes();
void namChangedSlot( QNetworkAccessManager *nam );
protected slots: protected slots:
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
@@ -70,7 +69,6 @@ private:
QVariantMap m_allChartsMap; QVariantMap m_allChartsMap;
uint m_chartsFetchJobs; uint m_chartsFetchJobs;
QList< InfoRequestData > m_cachedRequests; QList< InfoRequestData > m_cachedRequests;
QWeakPointer< QNetworkAccessManager > m_nam;
}; };
} }

View File

@@ -160,11 +160,6 @@ AdiumPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVar
m_pauseTimer->stop(); m_pauseTimer->stop();
} }
void
AdiumPlugin::namChangedSlot( QNetworkAccessManager* nam )
{
Q_UNUSED( nam )
}
/** Audio state slots */ /** Audio state slots */
void void

View File

@@ -49,8 +49,6 @@ protected slots:
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input ); void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input );
public slots: public slots:
void namChangedSlot( QNetworkAccessManager* nam );
virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
Q_UNUSED( criteria ); Q_UNUSED( criteria );

View File

@@ -35,8 +35,6 @@ public:
FdoNotifyPlugin(); FdoNotifyPlugin();
virtual ~FdoNotifyPlugin(); virtual ~FdoNotifyPlugin();
virtual void namChangedSlot( QNetworkAccessManager* ) {}
protected slots: protected slots:
virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
{ {

View File

@@ -117,8 +117,6 @@ public:
void setVolume( double value ); void setVolume( double value );
public slots: public slots:
void namChangedSlot( QNetworkAccessManager* /*nam*/ ) {} // unused
virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) virtual void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{ {
Q_UNUSED( criteria ); Q_UNUSED( criteria );

View File

@@ -72,8 +72,6 @@ InfoSystem::InfoSystem( QObject *parent )
QMetaObject::invokeMethod( m_worker.data(), "init", Qt::QueuedConnection, Q_ARG( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache >, m_cache ) ); QMetaObject::invokeMethod( m_worker.data(), "init", Qt::QueuedConnection, Q_ARG( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache >, m_cache ) );
connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( newNam() ) );
connect( m_cache.data(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), connect( m_cache.data(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
m_worker.data(), SLOT( infoSlot( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection ); m_worker.data(), SLOT( infoSlot( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );
@@ -115,14 +113,6 @@ InfoSystem::~InfoSystem()
} }
void
InfoSystem::newNam() const
{
qDebug() << Q_FUNC_INFO;
QMetaObject::invokeMethod( m_worker.data(), "newNam", Qt::QueuedConnection );
}
void void
InfoSystem::getInfo( const InfoRequestData &requestData ) InfoSystem::getInfo( const InfoRequestData &requestData )
{ {

View File

@@ -185,8 +185,6 @@ protected slots:
virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data ) = 0; virtual void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant data ) = 0;
virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) = 0; virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) = 0;
virtual void namChangedSlot( QNetworkAccessManager *nam ) = 0;
protected: protected:
InfoType m_type; InfoType m_type;
QSet< InfoType > m_supportedGetTypes; QSet< InfoType > m_supportedGetTypes;
@@ -251,9 +249,6 @@ signals:
void finished( QString target ); void finished( QString target );
void finished( QString target, Tomahawk::InfoSystem::InfoType type ); void finished( QString target, Tomahawk::InfoSystem::InfoType type );
public slots:
void newNam() const;
private: private:
QWeakPointer< InfoSystemCache > m_cache; QWeakPointer< InfoSystemCache > m_cache;
QWeakPointer< InfoSystemWorker > m_worker; QWeakPointer< InfoSystemWorker > m_worker;

View File

@@ -141,15 +141,7 @@ InfoSystemWorker::init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache> cac
cache.data(), cache.data(),
SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ) SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) )
); );
connect(
this,
SIGNAL( namChanged( QNetworkAccessManager* ) ),
plugin.data(),
SLOT( namChangedSlot( QNetworkAccessManager* ) )
);
} }
QMetaObject::invokeMethod( this, "newNam" );
} }
@@ -348,73 +340,6 @@ InfoSystemWorker::checkTimeoutsTimerFired()
} }
QNetworkAccessManager*
InfoSystemWorker::nam() const
{
if ( m_nam.isNull() )
return 0;
return m_nam.data();
}
void
InfoSystemWorker::newNam()
{
QNetworkAccessManager *oldNam = TomahawkUtils::nam();
if ( oldNam && oldNam->thread() == thread() )
{
if ( m_nam.data() != oldNam )
{
m_nam = QWeakPointer< QNetworkAccessManager >( oldNam );
emit namChanged( m_nam.data() );
}
return;
}
if
(
oldNam &&
!m_nam.isNull() &&
oldNam->configuration() == m_nam.data()->configuration() &&
oldNam->networkAccessible() == m_nam.data()->networkAccessible()
)
{
TomahawkUtils::NetworkProxyFactory fac1 = *( dynamic_cast< TomahawkUtils::NetworkProxyFactory * >( oldNam->proxyFactory() ) );
TomahawkUtils::NetworkProxyFactory fac2 = *( dynamic_cast< TomahawkUtils::NetworkProxyFactory * >( m_nam.data()->proxyFactory() ) );
if ( fac1 == fac2 )
return;
}
QNetworkAccessManager* newNam;
#ifdef LIBLASTFM_FOUND
newNam = new lastfm::NetworkAccessManager( this );
#else
newNam = new QNetworkAccessManager( this );
#endif
if ( !m_nam.isNull() )
delete m_nam.data();
if ( !oldNam )
oldNam = new QNetworkAccessManager();
TomahawkUtils::NetworkProxyFactory* oldProxyFactory = TomahawkUtils::proxyFactory();
if ( !oldProxyFactory )
oldProxyFactory = new TomahawkUtils::NetworkProxyFactory();
newNam->setConfiguration( oldNam->configuration() );
newNam->setNetworkAccessible( oldNam->networkAccessible() );
TomahawkUtils::NetworkProxyFactory* newProxyFactory = new TomahawkUtils::NetworkProxyFactory();
newProxyFactory->setNoProxyHosts( oldProxyFactory->noProxyHosts() );
newProxyFactory->setProxy( oldProxyFactory->proxy() );
newNam->setProxyFactory( newProxyFactory );
m_nam = QWeakPointer< QNetworkAccessManager >( newNam );
emit namChanged( m_nam.data() );
//FIXME: Currently leaking nam/proxyfactory above -- how to change in a thread-safe way?
}
} //namespace InfoSystem } //namespace InfoSystem
} //namespace Tomahawk } //namespace Tomahawk

View File

@@ -54,8 +54,6 @@ signals:
void finished( QString target ); void finished( QString target );
void finished( QString target, Tomahawk::InfoSystem::InfoType type ); void finished( QString target, Tomahawk::InfoSystem::InfoType type );
void namChanged( QNetworkAccessManager* );
public slots: public slots:
void init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > cache ); void init( QWeakPointer< Tomahawk::InfoSystem::InfoSystemCache > cache );
void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
@@ -63,8 +61,6 @@ public slots:
void infoSlot( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output ); void infoSlot( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void newNam();
private slots: private slots:
void checkTimeoutsTimerFired(); void checkTimeoutsTimerFired();
@@ -84,8 +80,6 @@ private:
QMap< InfoType, QList< InfoPluginPtr > > m_infoGetMap; QMap< InfoType, QList< InfoPluginPtr > > m_infoGetMap;
QMap< InfoType, QList< InfoPluginPtr > > m_infoPushMap; QMap< InfoType, QList< InfoPluginPtr > > m_infoPushMap;
QWeakPointer< QNetworkAccessManager> m_nam;
QTimer m_checkTimeoutsTimer; QTimer m_checkTimeoutsTimer;
}; };

View File

@@ -25,7 +25,7 @@
#include "bufferiodevice.h" #include "bufferiodevice.h"
#include "network/controlconnection.h" #include "network/controlconnection.h"
#include "network/servent.h" #include "network/servent.h"
#include "database/databasecommand_loadfile.h" #include "database/databasecommand_loadfiles.h"
#include "database/database.h" #include "database/database.h"
#include "sourcelist.h" #include "sourcelist.h"
#include "utils/logger.h" #include "utils/logger.h"
@@ -158,7 +158,7 @@ StreamConnection::setup()
qDebug() << "in TX mode, fid:" << m_fid; qDebug() << "in TX mode, fid:" << m_fid;
DatabaseCommand_LoadFile* cmd = new DatabaseCommand_LoadFile( m_fid ); DatabaseCommand_LoadFiles* cmd = new DatabaseCommand_LoadFiles( m_fid.toUInt() );
connect( cmd, SIGNAL( result( Tomahawk::result_ptr ) ), SLOT( startSending( Tomahawk::result_ptr ) ) ); connect( cmd, SIGNAL( result( Tomahawk::result_ptr ) ), SLOT( startSending( Tomahawk::result_ptr ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) ); Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
} }

View File

@@ -331,7 +331,7 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
albumpos1 = r->albumpos(); albumpos1 = r->albumpos();
bitrate1 = r->bitrate(); bitrate1 = r->bitrate();
mtime1 = r->modificationTime(); mtime1 = r->modificationTime();
id1 = r->dbid(); id1 = r->trackId();
size1 = r->size(); size1 = r->size();
} }
if ( q2->numResults() ) if ( q2->numResults() )
@@ -343,7 +343,7 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
albumpos2 = r->albumpos(); albumpos2 = r->albumpos();
bitrate2 = r->bitrate(); bitrate2 = r->bitrate();
mtime2 = r->modificationTime(); mtime2 = r->modificationTime();
id2 = r->dbid(); id2 = r->trackId();
size2 = r->size(); size2 = r->size();
} }

View File

@@ -559,7 +559,7 @@ TreeModel::addAllCollections()
QList<Tomahawk::source_ptr> sources = SourceList::instance()->sources(); QList<Tomahawk::source_ptr> sources = SourceList::instance()->sources();
foreach ( const source_ptr& source, sources ) foreach ( const source_ptr& source, sources )
{ {
connect( source->collection().data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ) ); connect( source->collection().data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ), Qt::UniqueConnection );
} }
m_title = tr( "All Artists" ); m_title = tr( "All Artists" );
@@ -668,7 +668,7 @@ TreeModel::addCollection( const collection_ptr& collection )
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) ); Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
connect( collection.data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ) ); connect( collection.data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ), Qt::UniqueConnection );
if ( !collection->source()->avatar().isNull() ) if ( !collection->source()->avatar().isNull() )
setIcon( collection->source()->avatar() ); setIcon( collection->source()->avatar() );
@@ -708,7 +708,7 @@ TreeModel::addFilteredCollection( const collection_ptr& collection, unsigned int
void void
TreeModel::onSourceAdded( const Tomahawk::source_ptr& source ) TreeModel::onSourceAdded( const Tomahawk::source_ptr& source )
{ {
connect( source->collection().data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ) ); connect( source->collection().data(), SIGNAL( changed() ), SLOT( onCollectionChanged() ), Qt::UniqueConnection );
} }

View File

@@ -24,7 +24,6 @@
#include "database/databasecommand_resolve.h" #include "database/databasecommand_resolve.h"
#include "database/databasecommand_alltracks.h" #include "database/databasecommand_alltracks.h"
#include "database/databasecommand_addfiles.h" #include "database/databasecommand_addfiles.h"
#include "database/databasecommand_loadfile.h"
#include "database/databasecommand_loadsocialactions.h" #include "database/databasecommand_loadsocialactions.h"
#include "utils/logger.h" #include "utils/logger.h"
@@ -61,7 +60,8 @@ Result::Result( const QString& url )
, m_modtime( 0 ) , m_modtime( 0 )
, m_year( 0 ) , m_year( 0 )
, m_score( 0 ) , m_score( 0 )
, m_id( 0 ) , m_trackId( 0 )
, m_fileId( 0 )
{ {
} }

View File

@@ -83,7 +83,8 @@ public:
QList< Tomahawk::SocialAction > allSocialActions(); QList< Tomahawk::SocialAction > allSocialActions();
void setScore( float score ) { m_score = score; } void setScore( float score ) { m_score = score; }
void setId( unsigned int id ) { m_id = id; } void setTrackId( unsigned int id ) { m_trackId = id; }
void setFileId( unsigned int id ) { m_fileId = id; }
void setRID( RID id ) { m_rid = id; } void setRID( RID id ) { m_rid = id; }
void setCollection( const Tomahawk::collection_ptr& collection ); void setCollection( const Tomahawk::collection_ptr& collection );
void setFriendlySource( const QString& s ) { m_friendlySource = s; } void setFriendlySource( const QString& s ) { m_friendlySource = s; }
@@ -104,7 +105,8 @@ public:
QVariantMap attributes() const { return m_attributes; } QVariantMap attributes() const { return m_attributes; }
void setAttributes( const QVariantMap& map ) { m_attributes = map; updateAttributes(); } void setAttributes( const QVariantMap& map ) { m_attributes = map; updateAttributes(); }
unsigned int dbid() const { return m_id; } unsigned int trackId() const { return m_trackId; }
unsigned int fileId() const { return m_fileId; }
public slots: public slots:
void onSocialActionsLoaded(); void onSocialActionsLoaded();
@@ -148,7 +150,7 @@ private:
QVariantMap m_attributes; QVariantMap m_attributes;
unsigned int m_id; unsigned int m_trackId, m_fileId;
QHash< QString, QVariant > m_currentSocialActions; QHash< QString, QVariant > m_currentSocialActions;
QList< SocialAction > m_allSocialActions; QList< SocialAction > m_allSocialActions;

View File

@@ -489,32 +489,35 @@ TomahawkSettings::setVerboseNotifications( bool notifications )
setValue( "ui/notifications/verbose", notifications ); setValue( "ui/notifications/verbose", notifications );
} }
bool bool
TomahawkSettings::showOfflineSources() const TomahawkSettings::showOfflineSources() const
{ {
return value( "collection/sources/showoffline", false ).toBool(); return value( "collection/sources/showoffline", false ).toBool();
} }
void void
TomahawkSettings::setShowOfflineSources( bool show ) TomahawkSettings::setShowOfflineSources( bool show )
{ {
setValue( "collection/sources/showoffline", show ); setValue( "collection/sources/showoffline", show );
} }
bool bool
TomahawkSettings::enableEchonestCatalogs() const TomahawkSettings::enableEchonestCatalogs() const
{ {
return value( "collection/enable_catalogs", false ).toBool(); return value( "collection/enable_catalogs", false ).toBool();
} }
void void
TomahawkSettings::setEnableEchonestCatalogs( bool enable ) TomahawkSettings::setEnableEchonestCatalogs( bool enable )
{ {
setValue( "collection/enable_catalogs", enable ); setValue( "collection/enable_catalogs", enable );
emit changed();
} }
QByteArray QByteArray
TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const
{ {

View File

@@ -31,7 +31,7 @@
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
#define LOGFILE TomahawkUtils::appLogDir().filePath( "Tomahawk.log" ).toLocal8Bit() #define LOGFILE TomahawkUtils::appLogDir().filePath( "Tomahawk.log" ).toLocal8Bit()
#define LOGFILE_SIZE 1024 * 512 #define LOGFILE_SIZE 1024 * 256
#define RELEASE_LEVEL_THRESHOLD 0 #define RELEASE_LEVEL_THRESHOLD 0
#define DEBUG_LEVEL_THRESHOLD LOGEXTRA #define DEBUG_LEVEL_THRESHOLD LOGEXTRA

View File

@@ -539,7 +539,7 @@ setProxyFactory( NetworkProxyFactory* factory )
s_proxyFactory = factory; s_proxyFactory = factory;
NetworkProxyFactory::setApplicationProxyFactory( s_proxyFactory ); NetworkProxyFactory::setApplicationProxyFactory( s_proxyFactory );
//nam takes ownership so set a copy, not the global one //nam takes ownership so set a copy, not the global one
if ( s_nam ) if ( !s_nam.isNull() )
{ {
TomahawkUtils::NetworkProxyFactory* newProxyFactory = new TomahawkUtils::NetworkProxyFactory(); TomahawkUtils::NetworkProxyFactory* newProxyFactory = new TomahawkUtils::NetworkProxyFactory();
newProxyFactory->setNoProxyHosts( factory->noProxyHosts() ); newProxyFactory->setNoProxyHosts( factory->noProxyHosts() );

View File

@@ -415,21 +415,9 @@ SettingsDialog::testLastFmLogin()
query[ "username" ] = ui->lineEditLastfmUsername->text().toLower(); query[ "username" ] = ui->lineEditLastfmUsername->text().toLower();
query[ "authToken" ] = authToken; query[ "authToken" ] = authToken;
TomahawkUtils::NetworkProxyFactory* oldProxyFactory = TomahawkUtils::proxyFactory(); // ensure they have up-to-date settings
QNetworkAccessManager* nam = TomahawkUtils::nam(); lastfm::setNetworkAccessManager( TomahawkUtils::nam() );
//WARNING: there's a chance liblastfm2 will clobber the application proxy factory it if it constructs a nam due to the below call
//but it is unsafe to re-set it here
QNetworkAccessManager* currNam = lastfm::nam();
currNam->setConfiguration( nam->configuration() );
currNam->setNetworkAccessible( nam->networkAccessible() );
TomahawkUtils::NetworkProxyFactory* newProxyFactory = new TomahawkUtils::NetworkProxyFactory();
newProxyFactory->setNoProxyHosts( oldProxyFactory->noProxyHosts() );
QNetworkProxy newProxy( oldProxyFactory->proxy() );
newProxyFactory->setProxy( newProxy );
currNam->setProxyFactory( newProxyFactory );
QNetworkReply* authJob = lastfm::ws::post( query ); QNetworkReply* authJob = lastfm::ws::post( query );
connect( authJob, SIGNAL( finished() ), SLOT( onLastFmFinished() ) ); connect( authJob, SIGNAL( finished() ), SLOT( onLastFmFinished() ) );

View File

@@ -156,18 +156,18 @@ TomahawkApp::init()
QFontMetrics fm( f ); QFontMetrics fm( f );
TomahawkUtils::setHeaderHeight( fm.height() + 8 ); TomahawkUtils::setHeaderHeight( fm.height() + 8 );
registerMetaTypes();
new TomahawkSettings( this ); new TomahawkSettings( this );
TomahawkSettings* s = TomahawkSettings::instance(); TomahawkSettings* s = TomahawkSettings::instance();
new ActionCollection( this ); new ActionCollection( this );
tDebug( LOGINFO ) << "Setting NAM."; tDebug( LOGINFO ) << "Setting NAM.";
#ifdef LIBLASTFM_FOUND #ifndef LIBLASTFM_FOUND
TomahawkUtils::setNam( lastfm::nam() );
#else
TomahawkUtils::setNam( new QNetworkAccessManager() ); TomahawkUtils::setNam( new QNetworkAccessManager() );
#else
TomahawkUtils::setNam( lastfm::nam() );
//Ensure that liblastfm2 won't delete the nam out from under us, even though they created it
lastfm::setNetworkAccessManager( TomahawkUtils::nam() );
#endif #endif
TomahawkUtils::NetworkProxyFactory* proxyFactory = new TomahawkUtils::NetworkProxyFactory(); TomahawkUtils::NetworkProxyFactory* proxyFactory = new TomahawkUtils::NetworkProxyFactory();
@@ -183,6 +183,7 @@ TomahawkApp::init()
proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ',', QString::SkipEmptyParts ) ); proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ',', QString::SkipEmptyParts ) );
TomahawkUtils::setProxyFactory( proxyFactory ); TomahawkUtils::setProxyFactory( proxyFactory );
m_audioEngine = QWeakPointer<AudioEngine>( new AudioEngine ); m_audioEngine = QWeakPointer<AudioEngine>( new AudioEngine );
m_scanManager = QWeakPointer<ScanManager>( new ScanManager( this ) ); m_scanManager = QWeakPointer<ScanManager>( new ScanManager( this ) );
@@ -362,11 +363,12 @@ void
TomahawkApp::registerMetaTypes() TomahawkApp::registerMetaTypes()
{ {
qRegisterMetaType< QSharedPointer<DatabaseCommand> >("QSharedPointer<DatabaseCommand>"); qRegisterMetaType< QSharedPointer<DatabaseCommand> >("QSharedPointer<DatabaseCommand>");
qRegisterMetaType< QList<QVariantMap> >("QList<QVariantMap>");
qRegisterMetaType< DBSyncConnection::State >("DBSyncConnection::State"); qRegisterMetaType< DBSyncConnection::State >("DBSyncConnection::State");
qRegisterMetaType< msg_ptr >("msg_ptr"); qRegisterMetaType< msg_ptr >("msg_ptr");
qRegisterMetaType< QList<dbop_ptr> >("QList<dbop_ptr>"); qRegisterMetaType< QList<dbop_ptr> >("QList<dbop_ptr>");
qRegisterMetaType< QList<QVariantMap> >("QList<QVariantMap>");
qRegisterMetaType< QList<QString> >("QList<QString>"); qRegisterMetaType< QList<QString> >("QList<QString>");
qRegisterMetaType< QList<uint> >("QList<uint>");
qRegisterMetaType< Connection* >("Connection*"); qRegisterMetaType< Connection* >("Connection*");
qRegisterMetaType< QAbstractSocket::SocketError >("QAbstractSocket::SocketError"); qRegisterMetaType< QAbstractSocket::SocketError >("QAbstractSocket::SocketError");
qRegisterMetaType< QTcpSocket* >("QTcpSocket*"); qRegisterMetaType< QTcpSocket* >("QTcpSocket*");
@@ -505,6 +507,7 @@ TomahawkApp::initServent()
} }
} }
void void
TomahawkApp::initSIP() TomahawkApp::initSIP()
{ {
@@ -521,6 +524,7 @@ TomahawkApp::initSIP()
} }
} }
void void
TomahawkApp::spotifyApiCheckFinished() TomahawkApp::spotifyApiCheckFinished()
{ {
@@ -546,7 +550,6 @@ TomahawkApp::activate()
bool bool
TomahawkApp::loadUrl( const QString& url ) TomahawkApp::loadUrl( const QString& url )
{ {
activate();
if ( url.startsWith( "tomahawk://" ) ) if ( url.startsWith( "tomahawk://" ) )
return GlobalActionManager::instance()->parseTomahawkLink( url ); return GlobalActionManager::instance()->parseTomahawkLink( url );
else if ( url.contains( "open.spotify.com" ) || url.contains( "spotify:track" ) ) else if ( url.contains( "open.spotify.com" ) || url.contains( "spotify:track" ) )
@@ -564,7 +567,8 @@ TomahawkApp::loadUrl( const QString& url )
l->load( QUrl::fromUserInput( url ) ); l->load( QUrl::fromUserInput( url ) );
return true; return true;
} else if ( info.suffix() == "jspf" ) }
else if ( info.suffix() == "jspf" )
{ {
JSPFLoader* l = new JSPFLoader( true, this ); JSPFLoader* l = new JSPFLoader( true, this );
tDebug( LOGINFO ) << "Loading j-spiff:" << url; tDebug( LOGINFO ) << "Loading j-spiff:" << url;
@@ -583,10 +587,9 @@ TomahawkApp::instanceStarted( KDSingleApplicationGuard::Instance instance )
{ {
tDebug( LOGINFO ) << "Instance started!" << instance.pid << instance.arguments; tDebug( LOGINFO ) << "Instance started!" << instance.pid << instance.arguments;
activate();
if ( instance.arguments.size() < 2 ) if ( instance.arguments.size() < 2 )
{
return; return;
}
QString arg1 = instance.arguments[ 1 ]; QString arg1 = instance.arguments[ 1 ];
loadUrl( arg1 ); loadUrl( arg1 );

View File

@@ -137,7 +137,7 @@ private:
}; };
Q_DECLARE_METATYPE( QPersistentModelIndex ) Q_DECLARE_METATYPE( QPersistentModelIndex )
Q_DECLARE_METATYPE(PairList) Q_DECLARE_METATYPE( PairList )
#endif // TOMAHAWKAPP_H #endif // TOMAHAWKAPP_H

View File

@@ -160,7 +160,12 @@ lastfm::setNetworkAccessManager( QNetworkAccessManager* nam )
oldNam = threadNamHash[thread]; oldNam = threadNamHash[thread];
if ( oldNam == nam ) if ( oldNam == nam )
{
// If we're being passed back our own NAM, assume they want to
// ensure that we don't delete it out from under them
ourNamSet.remove( thread );
return; return;
}
threadNamHash[thread] = nam; threadNamHash[thread] = nam;
ourNamSet.remove( thread ); ourNamSet.remove( thread );