Summary: | Katapult exporting malformed url to Amarok | ||
---|---|---|---|
Product: | [Unmaintained] katapult | Reporter: | Gareth Bowen <garethmbowen> |
Component: | general | Assignee: | Martin Meredith <mez> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | tgpfeiffer |
Priority: | VHI | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Ubuntu | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Gareth Bowen
2006-08-26 16:01:27 UTC
Confirmed on Kubuntu Dapper, Amarok 1.4.2, and Katapult 0.3.1.2 and last dev (BZR) version. For me, the problem appeared only with Amarok 1.4.2, with 1.4.1 it still worked fine. Yes, only with Amarok 1.4.2... Please do something in order to fix it! The problem appears also with Amarok 1.4.3 Yes, I also have this problem with 1.4.2 and 1.4.3 (of course not installed at the same time) It may be exporting a malformed URL - but thats because it gets a malformed URL FROM amarok - https://launchpad.net/products/katapult/+bug/60136 Using This is Amarok 1.4.3 and Katapult 0.3.1.3 Not only is there a dot at the beginning, some of the path appears to be missing for me. Actual track: /mnt/win_c/Documents and Settings/Stephen/My Documents/My Music/Finger 11 - Awake and Dreaming.mp3 Katapult track: ./Documents and Settings/Stephen/My Documents/My Music/Finger 11 - Awake and Dreaming.mp3 This is because Amarok's tables have changed, as a result of ATF I believe, Katapult needs to use the device mountpoint appended to the url, for example: neil@t40-n ~ $ dcop amarok collection query 'select lastmountpoint, url from devices join uniqueid on deviceid = id order by rand() limit 1' /home ./neil/mp3/Red Hot Chili Peppers - By the Way/Red Hot Chili Peppers - By the Way - 02 - Universally Speaking.mp3 Joining the two columns with a / will give you the correct path. Presumably older versions of Amarok stored the full path in the url, but that isn't the case anymore. Well, I had a look at the source and found what should be the offending piece of code, but I can't for the life of me figure out why none of my changes to the file are reflected after compiling and running. I threw some debug output into katapult/common/cachedcatalog.cpp just to make sure, and those changes were reflected, so I have no idea why the others weren't. However, if you look at katapult/plugins/catalogs/amarokcatalog/amarokcatalog.cpp:65 and change the sql there to this: SELECT a.name, t.title, t.url, i.path, album.name d.lastmountpoint FROM tags t JOIN devices d ON t.deviceid = d.id JOIN artist a ON t.artist = a.id JOIN album ON t.album = album.id LEFT JOIN statistics s ON t.url = s.url LEFT JOIN images i ON (a.name = i.artist AND album.name = i.album) WHERE t.album = album.id AND t.artist = a.id and then setURL() as d.lastmountpoint . "/" . t.url, it should work. The above sql also has the advantage of working with a MySQL backend as well as SQLite (Katapult currently doesn't work with a MySQL backend for Amarok). Fix made - testing - will commit to SVN soon SVN commit 600691 by mmeredith: Added PNGs for o2display Fixed up amarokcatalog to work with amarok >=1.4.2 BUG: 133030 M +216 -62 catalogs/amarokcatalog/amarokcatalog.cpp M +3 -1 catalogs/amarokcatalog/amarokcatalog.h AM display/o2display/doublebg.png AM display/o2display/singlebg.png --- trunk/extragear/utils/katapult/plugins/catalogs/amarokcatalog/amarokcatalog.cpp #600690:600691 @@ -1,6 +1,8 @@ /*************************************************************************** * Copyright (C) 2005 by Bastian Holst * * bastianholst@gmx.de * + * Copyright (C) 2006 by Martin Meredith * + * mez@thekatapult.org.uk * * * * 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 * @@ -45,6 +47,10 @@ { _minQueryLen = 3; ActionRegistry::self()->registerAction(new ActionPlaySong()); + _gotCollectionStatus = false; + _dynamicCollection = false; + checkCollectionType(); + } AmarokCatalog::~AmarokCatalog() { @@ -60,76 +66,184 @@ setBestMatch(Match()); setStatus(0); } else { - QStringList queryList; - //prepares SQL-queryQRegExp - QString sqlQuery("SELECT a.name, t.title, t.url, i.path, album.name FROM tags t, artist a, album LEFT JOIN statistics s ON t.url = s.url LEFT JOIN images i ON (a.name = i.artist AND album.name = i.album) WHERE t.album = album.id AND t.artist = a.id"); // AND + + if ( _gotCollectionStatus) + { + + if (!_dynamicCollection) + { + + // Stuff for Amarok < 1.4.2 + + QStringList queryList; + //prepares SQL-queryQRegExp + QString sqlQuery("SELECT a.name, t.title, t.url, i.path, album.name FROM tags t, artist a, album LEFT JOIN statistics s ON t.url = s.url LEFT JOIN images i ON (a.name = i.artist AND album.name = i.album) WHERE t.album = album.id AND t.artist = a.id"); // AND - queryList = QStringList::split ( QString(" "), QString(queryString).replace(QChar(':')," ").replace(QChar('\"'), " ").replace(QChar('\"'), "%") ); - for(QStringList::Iterator it = queryList.begin(); it != queryList.end(); ++it) { - sqlQuery.append(QString(" AND (t.title LIKE \"%%%1%%\"").arg(*it)); - sqlQuery.append(QString(" OR a.name LIKE \"%%%1%%\")").arg(*it)); - } - sqlQuery.append(" ORDER BY a.name, t.title, s.percentage DESC"); - - //sending SQL-query to amarok via dcop - QByteArray sqlQueryData, replyData; - QCString replyType; - QDataStream arg(sqlQueryData, IO_WriteOnly); - arg << sqlQuery; - if (!kapp->dcopClient()->call("amarok", "collection", "query(QString)", - sqlQueryData, replyType, replyData)) { - //qDebug("There was some error using DCOP. Perhaps amaroK doesn't run."); - newStatus = 0; - } else { - QDataStream reply(replyData, IO_ReadOnly); - if (replyType == "QStringList") { - QStringList sqlResult; - reply >> sqlResult; + queryList = QStringList::split ( QString(" "), QString(queryString).replace(QChar(':')," ").replace(QChar('\"'), " ").replace(QChar('\"'), "%") ); + for(QStringList::Iterator it = queryList.begin(); it != queryList.end(); ++it) { + sqlQuery.append(QString(" AND (t.title LIKE \"\%%1\%\"").arg(*it)); + sqlQuery.append(QString(" OR a.name LIKE \"\%%1\%\")").arg(*it)); + } + sqlQuery.append(" ORDER BY a.name, t.title, s.percentage DESC"); - if(sqlResult.isEmpty()) { + //sending SQL-query to ararok via dcop + QByteArray sqlQueryData, replyData; + QCString replyType; + QDataStream arg(sqlQueryData, IO_WriteOnly); + arg << sqlQuery; + if (!kapp->dcopClient()->call("amarok", "collection", "query(QString)", + sqlQueryData, replyType, replyData)) { newStatus = 0; } else { - reset(); - //Reads information from SQL-Query - _result.setArtist(sqlResult[0]); - _result.setName(sqlResult[1]); - _result.setURL(KURL(sqlResult[2])); - _result.setAlbum(sqlResult[4]); + QDataStream reply(replyData, IO_ReadOnly); + if (replyType == "QStringList") { + QStringList sqlResult; + reply >> sqlResult; - //_result.setIcon(QString()); - if ( !sqlResult[3].isEmpty() ) { - _result.setIcon(sqlResult[3]); + if(sqlResult.isEmpty()) { + newStatus = 0; + } else { + reset(); + //Reads information from SQL-Query + _result.setArtist(sqlResult[0]); + _result.setName(sqlResult[1]); + _result.setURL(KURL(sqlResult[2])); + _result.setAlbum(sqlResult[4]); + + //_result.setIcon(QString()); + if ( !sqlResult[3].isEmpty() ) { + _result.setIcon(sqlResult[3]); + } + + //counts the matched charecters + int i = queryString.find( ':' ); + if ( i != -1 ) { + if ( queryString[i+1] != ' ' ) + queryString.insert(i+1, ' '); + if ( queryString[i-1] != ' ' ) + queryString.insert(i, ' '); + } + queryList = QStringList::split ( " ", queryString ); + unsigned int matched = 0; + for(QStringList::Iterator it = queryList.begin(); it != queryList.end(); ++it) { + if(matched < (_result.text().find(*it, matched, false) + (*it).length())) + matched = _result.text().find(*it, matched, false) + (*it).length(); + } + setBestMatch(Match(&_result, 100*queryString.length()/_result.text().length(), matched)); + + //Checks if there are multiple results + if( !sqlResult[5].isEmpty() ) + newStatus = S_HasResults | S_Multiple; + else + newStatus = S_HasResults; + } + } else { + newStatus = 0; } + } + + } else { // Dynamic Collection + + // Do same as above here again but with dyn collection stuff + + QStringList queryList; + //prepares SQL-queryQRegExp + QString sqlQuery("SELECT a.name, t.title, t.deviceid, d.lastmountpoint, t.url, i.path, album.name FROM tags t LEFT JOIN statistics s ON t.url = s.url AND t.deviceid = s.deviceid LEFT JOIN artist a ON t.artist = a.id LEFT JOIN album ON t.album = album.id LEFT JOIN images i ON ( a.name = i.artist AND album.name = i.album) LEFT JOIN devices d ON t.deviceid = d.id WHERE 1"); + queryList = QStringList::split ( QString(" "), QString(queryString).replace(QChar(':')," ").replace(QChar('\"'), " ").replace(QChar('\"'), "%") ); + + for(QStringList::Iterator it = queryList.begin(); it != queryList.end(); ++it) { + + sqlQuery.append(QString(" AND (t.title LIKE \"\%%1\%\"").arg(*it)); + sqlQuery.append(QString(" OR a.name LIKE \"\%%1\%\")").arg(*it)); + } + sqlQuery.append(" ORDER BY a.name, t.title, s.percentage DESC"); + + //sending SQL-query to ararok via dcop + QByteArray sqlQueryData, replyData; + QCString replyType; + QDataStream arg(sqlQueryData, IO_WriteOnly); + arg << sqlQuery; + if (!kapp->dcopClient()->call("amarok", "collection", "query(QString)", + sqlQueryData, replyType, replyData)) { + newStatus = 0; + } else { + QDataStream reply(replyData, IO_ReadOnly); + if (replyType == "QStringList") { + QStringList sqlResult; + reply >> sqlResult; - //counts the matched charecters - int i = queryString.find( ':' ); - if ( i != -1 ) { - if ( queryString[i+1] != ' ' ) - queryString.insert(i+1, ' '); - if ( queryString[i-1] != ' ' ) - queryString.insert(i, ' '); + if(sqlResult.isEmpty()) { + newStatus = 0; + } else { + reset(); + //Reads information from SQL-Query + _result.setArtist(sqlResult[0]); + _result.setName(sqlResult[1]); + if (sqlResult[2]!="-1") { + KURL absolutePath; + absolutePath.setPath( sqlResult[3] ); + absolutePath.addPath( sqlResult[4] ); + absolutePath.cleanPath(); + + _result.setURL( absolutePath ); + } else { + KURL absolutePath; + absolutePath.setPath( "/" ); + absolutePath.addPath( sqlResult[4] ); + absolutePath.cleanPath(); + + _result.setURL( absolutePath ); + } + + _result.setAlbum(sqlResult[6]); + + //_result.setIcon(QString()); + if ( !sqlResult[3].isEmpty() ) { + _result.setIcon(sqlResult[5]); + } + + //counts the matched charecters + int i = queryString.find( ':' ); + if ( i != -1 ) { + if ( queryString[i+1] != ' ' ) + queryString.insert(i+1, ' '); + if ( queryString[i-1] != ' ' ) + queryString.insert(i, ' '); + } + queryList = QStringList::split ( " ", queryString ); + unsigned int matched = 0; + for(QStringList::Iterator it = queryList.begin(); it != queryList.end(); ++it) { + if(matched < (_result.text().find(*it, matched, false) + (*it).length())) + matched = _result.text().find(*it, matched, false) + (*it).length(); + } + setBestMatch(Match(&_result, 100*queryString.length()/_result.text().length(), matched)); + + //Checks if there are multiple results + if( !sqlResult[7].isEmpty() ) + newStatus = S_HasResults | S_Multiple; + else + newStatus = S_HasResults; + } + } else { + newStatus = 0; } - queryList = QStringList::split ( " ", queryString ); - unsigned int matched = 0; - for(QStringList::Iterator it = queryList.begin(); it != queryList.end(); ++it) { - if(matched < (_result.text().find(*it, matched, false) + (*it).length())) - matched = _result.text().find(*it, matched, false) + (*it).length(); - } - setBestMatch(Match(&_result, 100*queryString.length()/_result.text().length(), matched)); - - //Checks if there are multiple results - if( !sqlResult[5].isEmpty() ) - newStatus = S_HasResults | S_Multiple; - else - newStatus = S_HasResults; } - } else { - qDebug("DCOP: query returned an unexpected type of reply!"); - newStatus = 0; - } + + + } //end of >1.4.2 section + setStatus(newStatus); + + } else { //We haven't got the collection status + + checkCollectionType(); + reset(); + setBestMatch(Match()); + setStatus(0); } - setStatus(newStatus); - } + + + } //dont go after this while fixing + } void AmarokCatalog::reset() @@ -139,6 +253,48 @@ _result.setAlbum(QString::null); _result.setIcon(QString::null); } + +void AmarokCatalog::checkCollectionType() +{ + QString sqlQuery("SELECT COUNT(*) FROM admin WHERE noption = 'Database Devices Version'"); + + QByteArray sqlQueryData, replyData; + QCString replyType; + QDataStream arg(sqlQueryData, IO_WriteOnly); + arg << sqlQuery; + if (!kapp->dcopClient()->call("amarok", "collection", "query(QString)", sqlQueryData, replyType, replyData)) + { + _gotCollectionStatus = false; + + } + else + { + QDataStream reply(replyData, IO_ReadOnly); + if (replyType == "QStringList") + { + QStringList sqlResult; + reply >> sqlResult; + + if (sqlResult[0] == "1") + { + _dynamicCollection = true; + + } + else + { + _dynamicCollection = false; + + } + _gotCollectionStatus = true; + } + else + { + _gotCollectionStatus = false; + } + } +} + + /* void AmarokCatalog::initialize() { @@ -173,5 +329,3 @@ { config->writeEntry("MinQueryLen", _minQueryLen); } - -#include "amarokcatalog.moc" --- trunk/extragear/utils/katapult/plugins/catalogs/amarokcatalog/amarokcatalog.h #600690:600691 @@ -50,10 +50,12 @@ protected: void queryChanged(); void reset(); + void checkCollectionType(); private: unsigned int _minQueryLen; - + bool _dynamicCollection; + bool _gotCollectionStatus; Song _result; }; ** trunk/extragear/utils/katapult/plugins/display/o2display/doublebg.png #property svn:mime-type + application/octet-stream ** trunk/extragear/utils/katapult/plugins/display/o2display/singlebg.png #property svn:mime-type + application/octet-stream I reopend that unfixed bug: http://bugs.kde.org/show_bug.cgi?id=139206 |