mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-24 01:39:42 +01:00
POST and jspf handling
This commit is contained in:
parent
a48fff23c2
commit
24ec94ed96
@ -148,32 +148,35 @@ void
|
||||
GlobalActionManager::getShortLink( const playlist_ptr& pl )
|
||||
{
|
||||
QVariantMap m;
|
||||
m[ "title" ] = playlist->title();
|
||||
m[ "title" ] = pl->title();
|
||||
m[ "creator" ] = pl->author().isNull() ? "" : pl->author()->friendlyName();
|
||||
QVariantList tracks;
|
||||
foreach( const plentry_ptr& pl, playlist->entries() )
|
||||
foreach( const plentry_ptr& pl, pl->entries() )
|
||||
{
|
||||
if ( pl->query().isNull() )
|
||||
continue;
|
||||
|
||||
QVariantMap track;
|
||||
track[ "title" ] = pl->query()->track();
|
||||
track[ "artist" ] = pl->query()->artist();
|
||||
track[ "creator" ] = pl->query()->artist();
|
||||
track[ "album" ] = pl->query()->album();
|
||||
|
||||
tracks << track;
|
||||
}
|
||||
m[ "tracks" ] = tracks;
|
||||
m[ "track" ] = tracks;
|
||||
|
||||
QJson::Parser p;
|
||||
QByteArray msg = p.parse( m );
|
||||
QVariantMap jspf;
|
||||
jspf["playlist"] = m;
|
||||
|
||||
QJson::Serializer s;
|
||||
QByteArray msg = s.serialize( jspf );
|
||||
qDebug() << "POSTING DATA:" << msg;
|
||||
|
||||
const QUrl url( QString( "%1/playlist").arg( hostname() ) );
|
||||
const QUrl url( QString( "%1/playlist/").arg( hostname() ) );
|
||||
QNetworkRequest req( url );
|
||||
req.setHeader( QNetworkRequest::ContentTypeHeader, QLatin1String( "application/x-www-form-urlencoded" ) );
|
||||
QNetworkReply *reply = TomahawkUtils::nam()->get( request );
|
||||
if ( callbackObj.isValid() )
|
||||
reply->setProperty( "callbackobj", callbackObj );
|
||||
QNetworkReply *reply = TomahawkUtils::nam()->post( req, msg );
|
||||
|
||||
connect( reply, SIGNAL( finished() ), SLOT( shortenLinkRequestFinished() ) );
|
||||
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), SLOT( shortenLinkRequestError( QNetworkReply::NetworkError ) ) );
|
||||
}
|
||||
@ -375,18 +378,29 @@ GlobalActionManager::handlePlaylistCommand( const QUrl& url )
|
||||
|
||||
if ( parts[ 0 ] == "import" )
|
||||
{
|
||||
if ( !url.hasQueryItem( "xspf" ) )
|
||||
if ( !url.hasQueryItem( "xspf" ) && !url.hasQueryItem( "jspf") )
|
||||
{
|
||||
tDebug() << "No xspf to load...";
|
||||
tDebug() << "No xspf or jspf to load...";
|
||||
return false;
|
||||
}
|
||||
QUrl xspf = QUrl::fromUserInput( url.queryItemValue( "xspf" ) );
|
||||
QString title = url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString();
|
||||
XSPFLoader* l= new XSPFLoader( true, this );
|
||||
l->setOverrideTitle( title );
|
||||
l->load( xspf );
|
||||
connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) );
|
||||
|
||||
if ( url.hasQueryItem( "xspf") )
|
||||
{
|
||||
QUrl xspf = QUrl::fromUserInput( url.queryItemValue( "xspf" ) );
|
||||
QString title = url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString();
|
||||
XSPFLoader* l= new XSPFLoader( true, this );
|
||||
l->setOverrideTitle( title );
|
||||
l->load( xspf );
|
||||
connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) );
|
||||
}
|
||||
else if ( url.hasQueryItem( "jspf" ) )
|
||||
{
|
||||
QUrl jspf = QUrl::fromUserInput( url.queryItemValue( "jspf" ) );
|
||||
QString title = url.hasQueryItem( "title" ) ? url.queryItemValue( "title" ) : QString();
|
||||
JSPFLoader* l= new JSPFLoader( true, this );
|
||||
l->setOverrideTitle( title );
|
||||
l->load( jspf );
|
||||
connect( l, SIGNAL( ok( Tomahawk::playlist_ptr ) ), this, SLOT( playlistCreatedToShow( Tomahawk::playlist_ptr) ) );
|
||||
}
|
||||
}
|
||||
else if ( parts [ 0 ] == "new" )
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void shortenLink( const QUrl& url, const QVariant &callbackObj = QVariant() );
|
||||
void getShortLink( const playlist_ptr& playlist );
|
||||
void getShortLink( const Tomahawk::playlist_ptr& playlist );
|
||||
|
||||
bool parseTomahawkLink( const QString& link );
|
||||
void waitingForResolved( bool );
|
||||
|
@ -361,7 +361,7 @@ SourceTreeView::copyPlaylistLink()
|
||||
PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
|
||||
playlist_ptr playlist = item->playlist();
|
||||
|
||||
GlobalActionManager::instance()->getShortLink( playlist );
|
||||
// GlobalActionManager::instance()->getShortLink( playlist );
|
||||
|
||||
// QString suggestedFilename = TomahawkSettings::instance()->playlistDefaultPath() + "/" + playlist->title();
|
||||
// QString filename = QFileDialog::getSaveFileName( TomahawkUtils::tomahawkWindow(), tr( "Save XSPF" ),
|
||||
|
Loading…
x
Reference in New Issue
Block a user