From 55be3010e5240909dc58411da9442406e3c5df19 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Sun, 1 May 2011 21:58:36 -0400 Subject: [PATCH 01/30] work on new welcome widget --- src/libtomahawk/CMakeLists.txt | 2 + src/libtomahawk/playlist.h | 2 + src/libtomahawk/tomahawksettings.cpp | 8 +++ src/libtomahawk/tomahawksettings.h | 2 + src/libtomahawk/widgets/welcomewidget.cpp | 75 +++++------------------ src/libtomahawk/widgets/welcomewidget.h | 26 +------- 6 files changed, 32 insertions(+), 83 deletions(-) diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index c15c598b2..54b726ee7 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -158,6 +158,7 @@ set( libSources widgets/newplaylistwidget.cpp widgets/welcomewidget.cpp + widgets/welcomeplaylistmodel.cpp widgets/overlaywidget.cpp widgets/infowidgets/sourceinfowidget.cpp @@ -316,6 +317,7 @@ set( libHeaders widgets/newplaylistwidget.h widgets/welcomewidget.h + widgets/welcomeplaylistmodel.h widgets/overlaywidget.h widgets/infowidgets/sourceinfowidget.h diff --git a/src/libtomahawk/playlist.h b/src/libtomahawk/playlist.h index e905517b2..6c23fe808 100644 --- a/src/libtomahawk/playlist.h +++ b/src/libtomahawk/playlist.h @@ -262,4 +262,6 @@ private: }; +Q_DECLARE_METATYPE( QSharedPointer< Tomahawk::Playlist > ) + #endif // PLAYLIST_H diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index 365508e6c..9e89383ac 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -294,6 +294,12 @@ TomahawkSettings::recentlyPlayedPlaylists() const return playlists; } +QStringList +TomahawkSettings::recentlyPlayedPlaylistGuids() const +{ + return value( "playlists/recentlyPlayed" ).toStringList(); +} + void TomahawkSettings::appendRecentlyPlayedPlaylist( const Tomahawk::playlist_ptr& playlist ) @@ -304,6 +310,8 @@ TomahawkSettings::appendRecentlyPlayedPlaylist( const Tomahawk::playlist_ptr& pl playlist_guids.append( playlist->guid() ); setValue( "playlists/recentlyPlayed", playlist_guids ); + + emit recentlyPlayedPlaylistAdded( playlist ); } QString diff --git a/src/libtomahawk/tomahawksettings.h b/src/libtomahawk/tomahawksettings.h index 032578b17..c9a91391c 100644 --- a/src/libtomahawk/tomahawksettings.h +++ b/src/libtomahawk/tomahawksettings.h @@ -66,6 +66,7 @@ public: void setPlaylistColumnSizes( const QString& playlistid, const QByteArray& state ); QList recentlyPlayedPlaylists() const; + QStringList recentlyPlayedPlaylistGuids() const; void appendRecentlyPlayedPlaylist( const Tomahawk::playlist_ptr& playlist ); void setBookmarkPlaylist( const QString& guid ); @@ -182,6 +183,7 @@ public: signals: void changed(); + void recentlyPlayedPlaylistAdded( const Tomahawk::playlist_ptr& playlist ); private: static TomahawkSettings* s_instance; diff --git a/src/libtomahawk/widgets/welcomewidget.cpp b/src/libtomahawk/widgets/welcomewidget.cpp index c27123944..1c9cbe8c9 100644 --- a/src/libtomahawk/widgets/welcomewidget.cpp +++ b/src/libtomahawk/widgets/welcomewidget.cpp @@ -31,6 +31,7 @@ #include "tomahawksettings.h" #include +#include "welcomeplaylistmodel.h" #define HISTORY_TRACK_ITEMS 50 #define HISTORY_PLAYLIST_ITEMS 10 @@ -44,6 +45,7 @@ WelcomeWidget::WelcomeWidget( QWidget* parent ) ui->setupUi( this ); ui->playlistWidget->setItemDelegate( new PlaylistDelegate() ); + ui->playlistWidget->setModel( new WelcomePlaylistModel( this ) ); ui->playlistWidget->overlay()->resize( 380, 86 ); ui->tracksView->overlay()->setEnabled( false ); @@ -56,7 +58,7 @@ WelcomeWidget::WelcomeWidget( QWidget* parent ) connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) ); - connect( ui->playlistWidget, SIGNAL( itemActivated( QListWidgetItem* ) ), SLOT( onPlaylistActivated( QListWidgetItem* ) ) ); + connect( ui->playlistWidget, SIGNAL( activated( QModelIndex ) ), SLOT( onPlaylistActivated( QModelIndex ) ) ); connect( AudioEngine::instance() ,SIGNAL( playlistChanged( PlaylistInterface* ) ), this, SLOT( updatePlaylists() ), Qt::QueuedConnection ); } @@ -70,10 +72,10 @@ WelcomeWidget::~WelcomeWidget() void WelcomeWidget::updatePlaylists() { - ui->playlistWidget->clear(); - - QList playlists = TomahawkSettings::instance()->recentlyPlayedPlaylists(); +// ui->playlistWidget->clear(); +// QList playlists = TomahawkSettings::instance()->recentlyPlayedPlaylists(); +/* foreach( const Tomahawk::playlist_ptr& playlist, playlists ) { connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( refresh() ) ); @@ -81,9 +83,10 @@ WelcomeWidget::updatePlaylists() PlaylistWidgetItem* item = new PlaylistWidgetItem( playlist ); ui->playlistWidget->addItem( item ); item->setData( Qt::DisplayRole, playlist->title() ); - } + }*/ - if ( !playlists.count() ) + int num = ui->playlistWidget->model()->rowCount( QModelIndex() ); + if ( num == 0 ) { ui->playlistWidget->overlay()->setText( tr( "You have not played any playlists yet." ) ); ui->playlistWidget->overlay()->show(); @@ -92,19 +95,9 @@ WelcomeWidget::updatePlaylists() ui->playlistWidget->overlay()->hide(); } -void -WelcomeWidget::refresh() -{ - ui->playlistWidget->update(); -} - - void WelcomeWidget::onSourceAdded( const Tomahawk::source_ptr& source ) { - connect( source->collection().data(), SIGNAL( playlistsAdded( QList ) ), SLOT( updatePlaylists() ) ); - connect( source->collection().data(), SIGNAL( playlistsDeleted( QList ) ), SLOT( updatePlaylists() ) ); - connect( source.data(), SIGNAL( playbackFinished( Tomahawk::query_ptr ) ), SLOT( onPlaybackFinished( Tomahawk::query_ptr ) ) ); } @@ -132,15 +125,15 @@ WelcomeWidget::onPlaybackFinished( const Tomahawk::query_ptr& query ) void -WelcomeWidget::onPlaylistActivated( QListWidgetItem* item ) +WelcomeWidget::onPlaylistActivated( const QModelIndex& item ) { qDebug() << Q_FUNC_INFO; - PlaylistWidgetItem* pwi = dynamic_cast(item); - if( Tomahawk::dynplaylist_ptr dynplaylist = pwi->playlist().dynamicCast< Tomahawk::DynamicPlaylist >() ) + Tomahawk::playlist_ptr pl = item.data( WelcomePlaylistModel::PlaylistRole ).value< Tomahawk::playlist_ptr >(); + if( Tomahawk::dynplaylist_ptr dynplaylist = pl.dynamicCast< Tomahawk::DynamicPlaylist >() ) ViewManager::instance()->show( dynplaylist ); else - ViewManager::instance()->show( pwi->playlist() ); + ViewManager::instance()->show( pl ); } @@ -159,42 +152,6 @@ WelcomeWidget::changeEvent( QEvent* e ) } } - -QVariant -PlaylistWidgetItem::data( int role ) const -{ - if ( role == ArtistRole ) - { - if ( m_artists.isEmpty() ) - { - QStringList artists; - - foreach( const Tomahawk::plentry_ptr& entry, m_playlist->entries() ) - { - if ( !artists.contains( entry->query()->artist() ) ) - artists << entry->query()->artist(); - } - - m_artists = artists.join( ", " ); - } - - return m_artists; - } - - if ( role == TrackCountRole ) - { - return m_playlist->entries().count(); - } - - if ( role == Qt::DisplayRole ) - { - return m_playlist->title(); - } - - return QListWidgetItem::data( role ); -} - - QSize PlaylistDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const { @@ -228,9 +185,9 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, painter->drawPixmap( option.rect.adjusted( 10, 13, -option.rect.width() + 48, -13 ), m_playlistIcon ); - painter->drawText( option.rect.adjusted( 56, 26, -100, -8 ), index.data( PlaylistWidgetItem::ArtistRole ).toString() ); + painter->drawText( option.rect.adjusted( 56, 26, -100, -8 ), index.data( WelcomePlaylistModel::ArtistRole ).toString() ); - QString trackCount = tr( "%1 tracks" ).arg( index.data( PlaylistWidgetItem::TrackCountRole ).toString() ); + QString trackCount = tr( "%1 tracks" ).arg( index.data( WelcomePlaylistModel::TrackCountRole ).toString() ); painter->drawText( option.rect.adjusted( option.rect.width() - 96, 2, 0, -2 ), trackCount, to ); painter->setFont( boldFont ); @@ -241,7 +198,7 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, PlaylistWidget::PlaylistWidget( QWidget* parent ) - : QListWidget( parent ) + : QListView( parent ) { m_overlay = new OverlayWidget( this ); } diff --git a/src/libtomahawk/widgets/welcomewidget.h b/src/libtomahawk/widgets/welcomewidget.h index 0cd366864..c8695ccd0 100644 --- a/src/libtomahawk/widgets/welcomewidget.h +++ b/src/libtomahawk/widgets/welcomewidget.h @@ -59,28 +59,7 @@ private: QPixmap m_playlistIcon; }; - -class DLLEXPORT PlaylistWidgetItem : public QListWidgetItem -{ -public: - enum ItemRoles - { ArtistRole = Qt::UserRole, TrackCountRole }; - - PlaylistWidgetItem( const Tomahawk::playlist_ptr& playlist ) : QListWidgetItem() { m_playlist = playlist; } - ~PlaylistWidgetItem() {} - - virtual QVariant data( int role ) const; - - Tomahawk::playlist_ptr playlist() const { return m_playlist; } - -private: - Tomahawk::playlist_ptr m_playlist; - - mutable QString m_artists; -}; - - -class DLLEXPORT PlaylistWidget : public QListWidget +class DLLEXPORT PlaylistWidget : public QListView { public: PlaylistWidget( QWidget* parent = 0 ); @@ -118,11 +97,10 @@ signals: public slots: void updatePlaylists(); - void refresh(); private slots: void onSourceAdded( const Tomahawk::source_ptr& source ); - void onPlaylistActivated( QListWidgetItem* item ); + void onPlaylistActivated( const QModelIndex& ); void onPlaybackFinished( const Tomahawk::query_ptr& query ); void checkQueries(); From 68a3df17c4041ae1f84949f266392369a7333cc4 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Sun, 1 May 2011 21:58:47 -0400 Subject: [PATCH 02/30] change around some commands --- src/globalactionmanager.cpp | 101 ++++++++++++++++++++++++++++-------- src/globalactionmanager.h | 1 + 2 files changed, 80 insertions(+), 22 deletions(-) diff --git a/src/globalactionmanager.cpp b/src/globalactionmanager.cpp index 2f9d64279..040bf24bc 100644 --- a/src/globalactionmanager.cpp +++ b/src/globalactionmanager.cpp @@ -88,6 +88,8 @@ GlobalActionManager::parseTomahawkLink( const QString& url ) return handleSearchCommand( u ); } else if( cmdType == "play" ) { return handlePlayCommand( u ); + } else if( cmdType == "bookmark" ) { + return handleBookmarkCommand( u ); } else { qDebug() << "Tomahawk link not supported, command not known!" << cmdType << u.path(); return false; @@ -167,24 +169,49 @@ GlobalActionManager::handleQueueCommand( const QUrl& url ) if( parts[ 0 ] == "add" ) { if( parts.size() > 1 && parts[ 1 ] == "track" ) { QPair< QString, QString > pair; - foreach( pair, url.queryItems() ) { - if( pair.first != "url" ) - continue; - QUrl track = QUrl::fromUserInput( pair.second ); - //FIXME: isLocalFile is Qt 4.8 - if( track.toString().startsWith( "file://" ) ) { // it's local, so we see if it's in the DB and load it if so - // TODO - } else { // give it a web result hint - // TODO actually read the tags - QFileInfo info( track.path() ); - Tomahawk::query_ptr q = Tomahawk::Query::get( QString(), info.baseName(), QString() ); - q->setResultHint( track.toString() ); - Tomahawk::Pipeline::instance()->resolve( q, true ); - ViewManager::instance()->queue()->model()->append( q ); - ViewManager::instance()->showQueue(); + QString title, artist, album, urlStr; + foreach( pair, url.queryItems() ) { + if( pair.first == "track" ) + title = pair.second; + else if( pair.first == "artist" ) + artist = pair.second; + else if( pair.first == "album" ) + album = pair.second; + else if( pair.first == "url" ) + urlStr = pair.second; + } + if( !title.isEmpty() || !artist.isEmpty() || !album.isEmpty() ) { // an individual; query to add to queue + Tomahawk::query_ptr q = Tomahawk::Query::get( artist, title, album ); + if( !urlStr.isEmpty() ) + q->setResultHint( urlStr ); + Tomahawk::Pipeline::instance()->resolve( q, true ); + + if( !AudioEngine::instance()->isPlaying() ) { + connect( q.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( waitingForResolved( bool ) ) ); + m_waitingToPlay = q; } return true; + + } else { // a list of urls to add to the queue + foreach( pair, url.queryItems() ) { + if( pair.first != "url" ) + continue; + QUrl track = QUrl::fromUserInput( pair.second ); + //FIXME: isLocalFile is Qt 4.8 + if( track.toString().startsWith( "file://" ) ) { // it's local, so we see if it's in the DB and load it if so + // TODO + } else { // give it a web result hint + QFileInfo info( track.path() ); + Tomahawk::query_ptr q = Tomahawk::Query::get( QString(), info.baseName(), QString() ); + q->setResultHint( track.toString() ); + Tomahawk::Pipeline::instance()->resolve( q, true ); + + ViewManager::instance()->queue()->model()->append( q ); + ViewManager::instance()->showQueue(); + } + return true; + } } } else { qDebug() << "Only queue/add/track is support at the moment, got:" << parts; @@ -264,6 +291,41 @@ GlobalActionManager::handlePlayCommand( const QUrl& url ) return false; } + if( parts[ 0 ] == "track" ) { + QPair< QString, QString > pair; + QString title, artist, album, urlStr; + foreach( pair, url.queryItems() ) { + if( pair.first == "track" ) + title = pair.second; + else if( pair.first == "artist" ) + artist = pair.second; + else if( pair.first == "album" ) + album = pair.second; + else if( pair.first == "url" ) + urlStr = pair.second; + } + Tomahawk::query_ptr q = Tomahawk::Query::get( artist, title, album ); + if( !urlStr.isEmpty() ) + q->setResultHint( urlStr ); + Tomahawk::Pipeline::instance()->resolve( q, true ); + + m_waitingToPlay = q; + connect( q.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( waitingForResolved( bool ) ) ); + + return true; + } + + return false; +} + +bool GlobalActionManager::handleBookmarkCommand(const QUrl& url) +{ + QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command + if( parts.isEmpty() ) { + qDebug() << "No specific bookmark command:" << url.toString(); + return false; + } + if( parts[ 0 ] == "track" ) { QPair< QString, QString > pair; QString title, artist, album, urlStr; @@ -299,6 +361,8 @@ GlobalActionManager::handlePlayCommand( const QUrl& url ) return false; } + + void GlobalActionManager::bookmarkPlaylistCreated( const Tomahawk::playlist_ptr& pl ) { @@ -326,13 +390,6 @@ GlobalActionManager::doBookmark( const Tomahawk::playlist_ptr& pl, const Tomahaw m_toShow = pl; - // if nothing is playing, lets start this - // TODO - if( !AudioEngine::instance()->isPlaying() ) { - connect( q.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( waitingForResolved( bool ) ) ); - m_waitingToPlay = q; - } - m_waitingToBookmark.clear(); } diff --git a/src/globalactionmanager.h b/src/globalactionmanager.h index d4b94af37..95430cd7e 100644 --- a/src/globalactionmanager.h +++ b/src/globalactionmanager.h @@ -50,6 +50,7 @@ private: bool handleStationCommand(const QUrl& url ); bool handleSearchCommand(const QUrl& url ); bool handlePlayCommand(const QUrl& url ); + bool handleBookmarkCommand(const QUrl& url ); Tomahawk::playlist_ptr m_toShow; Tomahawk::query_ptr m_waitingToBookmark; From 9ed8caf2777a1dea36810bd5e5a1d84ac7dfc1a8 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 2 May 2011 10:14:59 -0400 Subject: [PATCH 03/30] Use liblastfm NAC in infosystemworker too, if available --- src/libtomahawk/infosystem/infosystemworker.cpp | 10 +++++++++- src/tomahawkapp.cpp | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libtomahawk/infosystem/infosystemworker.cpp b/src/libtomahawk/infosystem/infosystemworker.cpp index c70cbe019..4b376a932 100644 --- a/src/libtomahawk/infosystem/infosystemworker.cpp +++ b/src/libtomahawk/infosystem/infosystemworker.cpp @@ -27,6 +27,8 @@ #include "infoplugins/musixmatchplugin.h" #include "infoplugins/lastfmplugin.h" +#include "lastfm/NetworkAccessManager" + namespace Tomahawk { @@ -165,7 +167,13 @@ void InfoSystemWorker::newNam() { qDebug() << Q_FUNC_INFO; - QNetworkAccessManager *newNam = new QNetworkAccessManager(); + + QNetworkAccessManager* newNam; +#ifdef LIBLASTFM_FOUND + newNam = new lastfm::NetworkAccessManager( this ); +#else + newNam = new QNetworkAccessManager( this ); +#endif if ( m_nam ) { delete m_nam; diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index b826711c2..5d9a91e23 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -224,10 +224,10 @@ TomahawkApp::init() qDebug() << "Setting NAM."; TomahawkUtils::setNam( lastfm::nam() ); - #else +#else qDebug() << "Setting NAM."; TomahawkUtils::setNam( new QNetworkAccessManager() ); - #endif +#endif // Set up proxy //FIXME: This overrides the lastfm proxy above? From 92f23bc20bb8f270ac84699d3082f891051a0b7a Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Mon, 2 May 2011 14:40:35 +0200 Subject: [PATCH 04/30] sipjreen: regressions--: subscription handling UPDATE JREEN to make it work! --- src/sip/jreen/jabber.cpp | 102 +++++++++++++++++++++++++++++++++++++-- src/sip/jreen/jabber.h | 7 ++- thirdparty/jreen | 2 +- 3 files changed, 106 insertions(+), 5 deletions(-) diff --git a/src/sip/jreen/jabber.cpp b/src/sip/jreen/jabber.cpp index 10a769774..4d8c165fe 100644 --- a/src/sip/jreen/jabber.cpp +++ b/src/sip/jreen/jabber.cpp @@ -68,6 +68,9 @@ JabberPlugin::JabberPlugin() // add VCardUpdate extension to own presence m_client->presence().addExtension( new Jreen::VCardUpdate() ); + // initaliaze the roster + m_roster = new Jreen::SimpleRoster( m_client ); + // initialize the AvatarManager m_avatarManager = new AvatarManager( m_client ); @@ -91,9 +94,14 @@ JabberPlugin::JabberPlugin() connect(m_client, SIGNAL(serverFeaturesReceived(QSet)), SLOT(onConnect())); connect(m_client, SIGNAL(disconnected(Jreen::Client::DisconnectReason)), SLOT(onDisconnect(Jreen::Client::DisconnectReason))); connect(m_client, SIGNAL(newMessage(Jreen::Message)), SLOT(onNewMessage(Jreen::Message))); - connect(m_client, SIGNAL(newPresence(Jreen::Presence)), SLOT(onNewPresence(Jreen::Presence))); + connect(m_client, SIGNAL(newIQ(Jreen::IQ)), SLOT(onNewIq(Jreen::IQ))); + connect(m_roster, SIGNAL(presenceReceived(Jreen::RosterItem::Ptr,Jreen::Presence)), + SLOT(onPresenceReceived(Jreen::RosterItem::Ptr,Jreen::Presence))); + connect(m_roster, SIGNAL(subscriptionReceived(Jreen::RosterItem::Ptr,Jreen::Presence)), + SLOT(onSubscriptionReceived(Jreen::RosterItem::Ptr,Jreen::Presence))); + connect(m_avatarManager, SIGNAL(newAvatar(QString)), SLOT(onNewAvatar(QString))); } @@ -201,7 +209,6 @@ JabberPlugin::onConnect() m_client->setPingInterval(1000); // load roster - m_roster = new Jreen::SimpleRoster( m_client ); m_roster->load(); //FIXME: this implementation is totally broken atm, so it's disabled to avoid harm :P @@ -497,8 +504,10 @@ void JabberPlugin::onNewMessage(const Jreen::Message& message) } -void JabberPlugin::onNewPresence( const Jreen::Presence& presence) +void JabberPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr &item, const Jreen::Presence& presence ) { + Q_UNUSED(item); + Jreen::JID jid = presence.from(); QString fulljid( jid.full() ); @@ -540,6 +549,93 @@ void JabberPlugin::onNewPresence( const Jreen::Presence& presence) } } +void JabberPlugin::onSubscriptionReceived(const Jreen::RosterItem::Ptr& item, const Jreen::Presence& presence) +{ + qDebug() << Q_FUNC_INFO << "presence type: " << presence.subtype(); + if(item) + qDebug() << Q_FUNC_INFO << presence.from().full() << "subs" << item->subscription() << "ask" << item->ask(); + else + qDebug() << Q_FUNC_INFO << "item empty"; + + // don't do anything if the contact is already subscribed to us + if( presence.subtype() != Jreen::Presence::Subscribe || + ( + item && (item->subscription() == Jreen::RosterItem::From || item->subscription() == Jreen::RosterItem::Both) + ) + ) + { + return; + } + + // check if the requester is already on the roster + if(item && + ( + item->subscription() == Jreen::RosterItem::To || + ( item->subscription() == Jreen::RosterItem::None && !item->ask().isEmpty() ) + ) + ) + { + qDebug() << Q_FUNC_INFO << presence.from().bare() << "already on the roster so we assume ack'ing subscription request is okay..."; + m_roster->allowSubscription(presence.from(), true); + + return; + } + + qDebug() << Q_FUNC_INFO << presence.from().bare() << "open subscription request box"; + + // preparing the confirm box for the user + QMessageBox *confirmBox = new QMessageBox( + QMessageBox::Question, + tr( "Authorize User" ), + QString( tr( "Do you want to grant %1 access to your Collection?" ) ).arg(presence.from().bare()), + QMessageBox::Yes | QMessageBox::No, + 0 + ); + + // add confirmBox to m_subscriptionConfirmBoxes + m_subscriptionConfirmBoxes.insert( presence.from(), confirmBox ); + + // display the box and wait for the answer + confirmBox->open( this, SLOT( onSubscriptionRequestConfirmed( int ) ) ); +} + +void +JabberPlugin::onSubscriptionRequestConfirmed( int result ) +{ + qDebug() << Q_FUNC_INFO << result; + + QList< QMessageBox* > confirmBoxes = m_subscriptionConfirmBoxes.values(); + Jreen::JID jid; + + foreach( QMessageBox* currentBox, confirmBoxes ) + { + if( currentBox == sender() ) + { + jid = m_subscriptionConfirmBoxes.key( currentBox ); + } + } + + qDebug() << Q_FUNC_INFO << "box confirmed for" << jid.bare(); + + // we got an answer, deleting the box + m_subscriptionConfirmBoxes.remove( jid ); + sender()->deleteLater(); + + QMessageBox::StandardButton allowSubscription = static_cast( result ); + + if ( allowSubscription == QMessageBox::Yes ) + { + qDebug() << Q_FUNC_INFO << jid.bare() << "accepted by user, adding to roster"; + addContact(jid, ""); + } + else + { + qDebug() << Q_FUNC_INFO << jid.bare() << "declined by user"; + } + + m_roster->allowSubscription( jid, allowSubscription == QMessageBox::Yes ); +} + void JabberPlugin::onNewIq(const Jreen::IQ& iq, int context) { if( context == RequestDisco ) diff --git a/src/sip/jreen/jabber.h b/src/sip/jreen/jabber.h index 17d4cc31b..faa73c179 100644 --- a/src/sip/jreen/jabber.h +++ b/src/sip/jreen/jabber.h @@ -38,6 +38,7 @@ #include #include +#include #define MYNAME "SIPJREEN" #define TOMAHAWK_FEATURE QLatin1String( "tomahawk:sip:v1" ) @@ -79,7 +80,10 @@ private slots: void onDisconnect(Jreen::Client::DisconnectReason reason); void onAuthError(int code, const QString &msg); - void onNewPresence( const Jreen::Presence& presence ); + void onPresenceReceived( const Jreen::RosterItem::Ptr &item, const Jreen::Presence& presence ); + void onSubscriptionReceived( const Jreen::RosterItem::Ptr &item, const Jreen::Presence& presence ); + void onSubscriptionRequestConfirmed( int result ); + void onNewMessage( const Jreen::Message& message ); void onError( const Jreen::Connection::SocketError& e ) { @@ -112,6 +116,7 @@ private: Jreen::MUCRoom *m_room; Jreen::SimpleRoster *m_roster; QHash m_peers; + QHash m_subscriptionConfirmBoxes; enum IqContext { NoContext, RequestDisco, RequestedDisco, SipMessageSent, RequestedVCard }; QStringList m_legacy_peers; AvatarManager *m_avatarManager; diff --git a/thirdparty/jreen b/thirdparty/jreen index ed1680de0..8f995f246 160000 --- a/thirdparty/jreen +++ b/thirdparty/jreen @@ -1 +1 @@ -Subproject commit ed1680de066ec7a414117f94e92a9f1b9b40fb24 +Subproject commit 8f995f246637f533feb7124744e113034a32b505 From 81065243f4a19f0fadb7aaf357870567a6acf7cf Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Mon, 2 May 2011 22:11:47 +0200 Subject: [PATCH 05/30] sipjreen: regressions--: handle server and port settings correctly --- src/sip/jreen/jabber.cpp | 29 ++++++++++++++++++++++++----- src/sip/jreen/jabber.h | 1 + 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/sip/jreen/jabber.cpp b/src/sip/jreen/jabber.cpp index 4d8c165fe..1f418e8e7 100644 --- a/src/sip/jreen/jabber.cpp +++ b/src/sip/jreen/jabber.cpp @@ -61,6 +61,8 @@ JabberPlugin::JabberPlugin() // general client setup m_client = new Jreen::Client( jid, m_currentPassword ); + setupClientHelper(); + m_client->registerStanzaExtension(new TomahawkSipMessageFactory); m_currentResource = QString::fromAscii( "tomahawk%1" ).arg( QString::number( qrand() % 10000 ) ); m_client->setResource( m_currentResource ); @@ -439,17 +441,34 @@ JabberPlugin::checkSettings() m_currentServer = TomahawkSettings::instance()->jabberServer(); m_currentPort = TomahawkSettings::instance()->jabberPort(); - Jreen::JID jid = Jreen::JID( accountName() ); - m_client->setJID( jid ); - m_client->setPassword( m_currentPassword ); - m_client->setServer( m_currentServer ); - m_client->setPort( m_currentPort ); + setupClientHelper(); qDebug() << Q_FUNC_INFO << "Updated settings"; connectPlugin( false ); } } +void JabberPlugin::setupClientHelper() +{ + Jreen::JID jid = Jreen::JID( m_currentUsername ); + + m_client->setJID( jid ); + m_client->setPassword( m_currentPassword ); + + if( !m_currentServer.isEmpty() ) + { + // set explicit server details + m_client->setServer( m_currentServer ); + m_client->setPort( m_currentPort ); + } + else + { + // let jreen find out server and port via jdns + m_client->setServer( jid.domain() ); + m_client->setPort( -1 ); + } +} + void JabberPlugin::addMenuHelper() { if( !m_menu ) diff --git a/src/sip/jreen/jabber.h b/src/sip/jreen/jabber.h index faa73c179..67e3722d6 100644 --- a/src/sip/jreen/jabber.h +++ b/src/sip/jreen/jabber.h @@ -93,6 +93,7 @@ private slots: void onNewAvatar( const QString &jid ); private: + void setupClientHelper(); void addMenuHelper(); void removeMenuHelper(); From 58692f424dad37a49034f19c9cd86c517bb67b62 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 2 May 2011 16:27:34 -0400 Subject: [PATCH 06/30] Fix condition where duplicate connections could happen from twitter --- src/sip/twitter/twitter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sip/twitter/twitter.cpp b/src/sip/twitter/twitter.cpp index 643f11fcd..d2eaa93a5 100644 --- a/src/sip/twitter/twitter.cpp +++ b/src/sip/twitter/twitter.cpp @@ -270,6 +270,7 @@ TwitterPlugin::connectTimerFired() { peerData["lastseen"] = QDateTime::currentMSecsSinceEpoch(); m_cachedPeers[screenName] = peerData; + continue; } if ( QDateTime::currentMSecsSinceEpoch() - peerData["lastseen"].toLongLong() > 1209600000 ) // 2 weeks From 40d3b87af56d56bd9d76dfe8d79e4630fb7a6348 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Mon, 2 May 2011 18:22:16 -0400 Subject: [PATCH 07/30] make welcomewidget and recently played playlist behave --- src/libtomahawk/viewmanager.cpp | 23 ++++++++++++++++++++--- src/libtomahawk/viewmanager.h | 2 ++ src/libtomahawk/widgets/welcomewidget.cpp | 6 +++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/libtomahawk/viewmanager.cpp b/src/libtomahawk/viewmanager.cpp index fa55d13d8..e6abf3250 100644 --- a/src/libtomahawk/viewmanager.cpp +++ b/src/libtomahawk/viewmanager.cpp @@ -121,6 +121,8 @@ ViewManager::ViewManager( QObject* parent ) m_widget->layout()->setMargin( 0 ); m_widget->layout()->setSpacing( 0 ); + connect( AudioEngine::instance(), SIGNAL( playlistChanged( PlaylistInterface* ) ), this, SLOT( playlistInterfaceChanged( PlaylistInterface* ) ) ); + connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) ); connect( m_topbar, SIGNAL( filterTextChanged( QString ) ), @@ -180,7 +182,7 @@ ViewManager::show( const Tomahawk::playlist_ptr& playlist ) } setPage( view ); - TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist ); + emit numSourcesChanged( SourceList::instance()->count() ); return view; @@ -206,7 +208,6 @@ ViewManager::show( const Tomahawk::dynplaylist_ptr& playlist ) else m_queueView->show(); - TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist ); emit numSourcesChanged( SourceList::instance()->count() ); return m_dynamicWidgets.value( playlist ); @@ -421,6 +422,22 @@ ViewManager::showSuperCollection() return shown; } +void +ViewManager::playlistInterfaceChanged( PlaylistInterface* interface ) +{ + playlist_ptr pl = playlistForInterface( interface ); + if ( !pl.isNull() ) + { + TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( pl ); + } else + { + pl = dynamicPlaylistForInterface( interface ); + if ( !pl.isNull() ) + TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( pl ); + } +} + + Tomahawk::ViewPage* ViewManager::showWelcomePage() { @@ -599,7 +616,7 @@ ViewManager::setPage( ViewPage* page, bool trackHistory ) qDebug() << "View page shown:" << page->title(); emit viewPageActivated( page ); - if ( !AudioEngine::instance()->isPlaying() ) + if ( !AudioEngine::instance()->playlist() ) AudioEngine::instance()->setPlaylist( currentPlaylistInterface() ); // UGH! diff --git a/src/libtomahawk/viewmanager.h b/src/libtomahawk/viewmanager.h index 65b4f6fa3..9ac8bc63d 100644 --- a/src/libtomahawk/viewmanager.h +++ b/src/libtomahawk/viewmanager.h @@ -145,6 +145,8 @@ public slots: void setRepeatMode( PlaylistInterface::RepeatMode mode ); void setShuffled( bool enabled ); + void playlistInterfaceChanged( PlaylistInterface* ); + // called by the playlist creation dbcmds void createPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents ); void createDynamicPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents ); diff --git a/src/libtomahawk/widgets/welcomewidget.cpp b/src/libtomahawk/widgets/welcomewidget.cpp index 1c9cbe8c9..e2b8012eb 100644 --- a/src/libtomahawk/widgets/welcomewidget.cpp +++ b/src/libtomahawk/widgets/welcomewidget.cpp @@ -45,10 +45,14 @@ WelcomeWidget::WelcomeWidget( QWidget* parent ) ui->setupUi( this ); ui->playlistWidget->setItemDelegate( new PlaylistDelegate() ); - ui->playlistWidget->setModel( new WelcomePlaylistModel( this ) ); + WelcomePlaylistModel* model = new WelcomePlaylistModel( this ); + ui->playlistWidget->setModel( model ); ui->playlistWidget->overlay()->resize( 380, 86 ); ui->tracksView->overlay()->setEnabled( false ); + connect( model,SIGNAL( emptinessChanged( bool) ), this, SLOT( updatePlaylists() ) ); + + m_tracksModel = new PlaylistModel( ui->tracksView ); ui->tracksView->setPlaylistModel( m_tracksModel ); m_tracksModel->loadHistory( Tomahawk::source_ptr(), HISTORY_TRACK_ITEMS ); From 1bde1fe1bbff1410465428ffa95593085315f7c9 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Mon, 2 May 2011 18:22:25 -0400 Subject: [PATCH 08/30] fix indenting --- src/sourcetree/items/collectionitem.cpp | 34 ++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/sourcetree/items/collectionitem.cpp b/src/sourcetree/items/collectionitem.cpp index f478b0a56..b3a468f34 100644 --- a/src/sourcetree/items/collectionitem.cpp +++ b/src/sourcetree/items/collectionitem.cpp @@ -55,26 +55,26 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons // load auto playlists and stations! - connect( source.data(), SIGNAL( stats( QVariantMap ) ), this, SIGNAL( updated() ) ); - connect( source.data(), SIGNAL( playbackStarted( Tomahawk::query_ptr ) ), this, SIGNAL( updated() ) ); - connect( source.data(), SIGNAL( stateChanged() ), this, SIGNAL( updated() ) ); - connect( source.data(), SIGNAL( offline() ), this, SIGNAL( updated() ) ); - connect( source.data(), SIGNAL( online() ), this, SIGNAL( updated() ) ); + connect( source.data(), SIGNAL( stats( QVariantMap ) ), this, SIGNAL( updated() ) ); + connect( source.data(), SIGNAL( playbackStarted( Tomahawk::query_ptr ) ), this, SIGNAL( updated() ) ); + connect( source.data(), SIGNAL( stateChanged() ), this, SIGNAL( updated() ) ); + connect( source.data(), SIGNAL( offline() ), this, SIGNAL( updated() ) ); + connect( source.data(), SIGNAL( online() ), this, SIGNAL( updated() ) ); - connect( source->collection().data(), SIGNAL( playlistsAdded( QList ) ), - SLOT( onPlaylistsAdded( QList ) ), Qt::QueuedConnection ); - connect( source->collection().data(), SIGNAL( playlistsDeleted( QList ) ), - SLOT( onPlaylistsDeleted( QList ) ), Qt::QueuedConnection ); + connect( source->collection().data(), SIGNAL( playlistsAdded( QList ) ), + SLOT( onPlaylistsAdded( QList ) ), Qt::QueuedConnection ); + connect( source->collection().data(), SIGNAL( playlistsDeleted( QList ) ), + SLOT( onPlaylistsDeleted( QList ) ), Qt::QueuedConnection ); - connect( source->collection().data(), SIGNAL( autoPlaylistsAdded( QList< Tomahawk::dynplaylist_ptr > ) ), - SLOT( onAutoPlaylistsAdded( QList ) ), Qt::QueuedConnection ); - connect( source->collection().data(), SIGNAL( autoPlaylistsDeleted( QList ) ), - SLOT( onAutoPlaylistsDeleted( QList ) ), Qt::QueuedConnection ); + connect( source->collection().data(), SIGNAL( autoPlaylistsAdded( QList< Tomahawk::dynplaylist_ptr > ) ), + SLOT( onAutoPlaylistsAdded( QList ) ), Qt::QueuedConnection ); + connect( source->collection().data(), SIGNAL( autoPlaylistsDeleted( QList ) ), + SLOT( onAutoPlaylistsDeleted( QList ) ), Qt::QueuedConnection ); - connect( source->collection().data(), SIGNAL( stationsAdded( QList ) ), - SLOT( onStationsAdded( QList ) ), Qt::QueuedConnection ); - connect( source->collection().data(), SIGNAL( stationsDeleted( QList ) ), - SLOT( onStationsDeleted( QList ) ), Qt::QueuedConnection ); + connect( source->collection().data(), SIGNAL( stationsAdded( QList ) ), + SLOT( onStationsAdded( QList ) ), Qt::QueuedConnection ); + connect( source->collection().data(), SIGNAL( stationsDeleted( QList ) ), + SLOT( onStationsDeleted( QList ) ), Qt::QueuedConnection ); } Tomahawk::source_ptr From bbbd1a48bbc54d3f4a172ce07f6e315403b13a64 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Mon, 2 May 2011 18:22:40 -0400 Subject: [PATCH 09/30] add new welcomeplaylistmodel --- .../widgets/welcomeplaylistmodel.cpp | 157 ++++++++++++++++++ .../widgets/welcomeplaylistmodel.h | 56 +++++++ 2 files changed, 213 insertions(+) create mode 100644 src/libtomahawk/widgets/welcomeplaylistmodel.cpp create mode 100644 src/libtomahawk/widgets/welcomeplaylistmodel.h diff --git a/src/libtomahawk/widgets/welcomeplaylistmodel.cpp b/src/libtomahawk/widgets/welcomeplaylistmodel.cpp new file mode 100644 index 000000000..6068831e8 --- /dev/null +++ b/src/libtomahawk/widgets/welcomeplaylistmodel.cpp @@ -0,0 +1,157 @@ +/* + + Copyright (C) 2011 Leo Franchi + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + + +#include "welcomeplaylistmodel.h" +#include +#include