From ab641c88e044985b8cf3d12f2fca43504ee6caed Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 27 Apr 2012 19:04:03 -0400 Subject: [PATCH] Clean up from working branch, disable playlist links until ready. --- src/libtomahawk/GlobalActionManager.cpp | 11 +++++----- src/sourcetree/SourceTreeView.cpp | 29 +++++++++++++------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/libtomahawk/GlobalActionManager.cpp b/src/libtomahawk/GlobalActionManager.cpp index 244db8822..d7c6cfbe2 100644 --- a/src/libtomahawk/GlobalActionManager.cpp +++ b/src/libtomahawk/GlobalActionManager.cpp @@ -2,7 +2,7 @@ Copyright (C) 2011 Leo Franchi Copyright (C) 2011, Jeff Mitchell Copyright (C) 2011-2012, Christian Muehlhaeuser - + 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 @@ -170,8 +170,8 @@ GlobalActionManager::getShortLink( const playlist_ptr& pl ) QJson::Serializer s; QByteArray msg = s.serialize( jspf ); - qDebug() << "POSTING DATA:" << msg; + // No built-in Qt facilities for doing a FORM POST. So we build the payload ourselves... const QByteArray boundary = "----------------------------2434992cccab"; QByteArray data(QByteArray("--" + boundary + "\r\n")); data += "Content-Disposition: form-data; name=\"data\"; filename=\"playlist.jspf\"\r\n"; @@ -180,9 +180,8 @@ GlobalActionManager::getShortLink( const playlist_ptr& pl ) data += "\r\n\r\n"; data += "--" + boundary + "--\r\n\r\n"; - const QUrl url( QString( "%1/playlist/").arg( hostname() ) ); + const QUrl url( QString( "%1/p/").arg( hostname() ) ); QNetworkRequest req( url ); - qDebug() << "POSTING TO:" << url.toString(); req.setHeader( QNetworkRequest::ContentTypeHeader, QString( "multipart/form-data; boundary=%1" ).arg( QString::fromLatin1( boundary ) ) ); QNetworkReply *reply = TomahawkUtils::nam()->post( req, data ); @@ -1073,7 +1072,7 @@ GlobalActionManager::shortenLinkRequestFinished() QVariant callbackObj; if ( reply->property( "callbackobj" ).isValid() ) callbackObj = reply->property( "callbackobj" ); - + // Check for the redirect attribute, as this should be the shortened link QVariant urlVariant = reply->attribute( QNetworkRequest::RedirectionTargetAttribute ); @@ -1233,7 +1232,7 @@ GlobalActionManager::waitingForResolved( bool /* success */ ) QString GlobalActionManager::hostname() const { - return QString( "http://stage.toma.hk" ); + return QString( "http://toma.hk" ); } diff --git a/src/sourcetree/SourceTreeView.cpp b/src/sourcetree/SourceTreeView.cpp index 2d1e4c880..3e43c36b6 100644 --- a/src/sourcetree/SourceTreeView.cpp +++ b/src/sourcetree/SourceTreeView.cpp @@ -226,8 +226,8 @@ SourceTreeView::setupMenus() } - // if ( type == SourcesModel::StaticPlaylist ) - // copyPlaylistAction->setText( tr( "&Export Playlist" ) ); + if ( type == SourcesModel::StaticPlaylist ) + copyPlaylistAction->setText( tr( "&Export Playlist" ) ); connect( loadPlaylistAction, SIGNAL( triggered() ), SLOT( loadPlaylist() ) ); connect( renamePlaylistAction, SIGNAL( triggered() ), SLOT( renamePlaylist() ) ); @@ -358,20 +358,21 @@ SourceTreeView::copyPlaylistLink() else if ( type == SourcesModel::StaticPlaylist ) { - PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex ); - playlist_ptr playlist = item->playlist(); + // Disable toma.hk playlist mode until ready + // GlobalActionManager::instance()->getShortLink( playlist ); - GlobalActionManager::instance()->getShortLink( playlist ); + PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex ); + playlist_ptr playlist = item->playlist(); -// QString suggestedFilename = TomahawkSettings::instance()->playlistDefaultPath() + "/" + playlist->title(); -// QString filename = QFileDialog::getSaveFileName( TomahawkUtils::tomahawkWindow(), tr( "Save XSPF" ), -// suggestedFilename, tr( "Playlists (*.xspf)" ) ); -// if ( !filename.isEmpty() ) -// { -// QFileInfo playlistAbsoluteFilePath = filename; -// TomahawkSettings::instance()->setPlaylistDefaultPath( playlistAbsoluteFilePath.absolutePath() ); -// GlobalActionManager::instance()->savePlaylistToFile( playlist, filename ); -// } + QString suggestedFilename = TomahawkSettings::instance()->playlistDefaultPath() + "/" + playlist->title(); + QString filename = QFileDialog::getSaveFileName( TomahawkUtils::tomahawkWindow(), tr( "Save XSPF" ), + suggestedFilename, tr( "Playlists (*.xspf)" ) ); + if ( !filename.isEmpty() ) + { + QFileInfo playlistAbsoluteFilePath = filename; + TomahawkSettings::instance()->setPlaylistDefaultPath( playlistAbsoluteFilePath.absolutePath() ); + GlobalActionManager::instance()->savePlaylistToFile( playlist, filename ); + } } }