Remove the plasmarunner plugin since it doesn't work any more. Fixes issue 3037

This commit is contained in:
David Sansome 2012-07-05 12:50:57 +01:00
parent c57f58862f
commit 5b3071e5f1
5 changed files with 0 additions and 448 deletions

View File

@ -199,7 +199,6 @@ option(ENABLE_LIBLASTFM "Use liblastfm for fetching song info, scrobbling and ra
option(ENABLE_BREAKPAD "Enable crash reporting" OFF)
option(ENABLE_SPOTIFY_BLOB "Build the spotify non-GPL binary" ON)
option(ENABLE_SPOTIFY "Enable spotify support" ON)
option(ENABLE_PLASMARUNNER "Enable plasma krunner global search" OFF)
option(ENABLE_MOODBAR "Enable moodbar" ON)
if(WIN32)
@ -421,17 +420,6 @@ if(HAVE_MOODBAR)
add_subdirectory(gst/moodbar)
endif()
# This goes after everything else because KDE fucks everything else up with its
# cmake includes.
find_package(KDE4 4.3.60)
if(KDE4_PLASMA_LIBS AND ENABLE_PLASMARUNNER)
set(HAVE_PLASMARUNNER ON)
endif(KDE4_PLASMA_LIBS AND ENABLE_PLASMARUNNER)
if(HAVE_PLASMARUNNER)
add_subdirectory(plasmarunner)
endif(HAVE_PLASMARUNNER)
# Uninstall support
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
@ -457,6 +445,5 @@ summary_add("Spotify support: core code" HAVE_SPOTIFY)
summary_add("Spotify support: non-GPL binary helper" HAVE_SPOTIFY_BLOB)
summary_add("Visualisations" ENABLE_VISUALISATIONS)
summary_add("Wiimote support" HAVE_WIIMOTEDEV)
summary_add("(KDE) Plasma global search" HAVE_PLASMARUNNER)
summary_add("(Mac OS X) Sparkle integration" HAVE_SPARKLE)
summary_show()

View File

@ -1,33 +0,0 @@
include(KDE4Defaults)
include(MacroLibrary)
add_definitions(${KDE4_DEFINITIONS})
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_BINARY_DIR}/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${KDE4_INCLUDES})
set(SOURCES
clementinerunner.cpp
../src/globalsearch/common.cpp
)
set(RESOURCES
../data/clementineplasmarunner.qrc
)
list(APPEND QT_DBUSXML2CPP_EXECUTABLE -i src/globalsearch/common.h)
qt4_add_dbus_interface(SOURCES
${CMAKE_SOURCE_DIR}/src/dbus/org.clementineplayer.GlobalSearch.xml
globalsearchinterface)
qt4_add_resources(QRC ${RESOURCES})
kde4_add_plugin(plasma_runner_clementine ${SOURCES} ${QRC})
target_link_libraries(plasma_runner_clementine ${KDE4_PLASMA_LIBS})
# Install the library and .desktop file
install(TARGETS plasma_runner_clementine DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES plasma-runner-clementine.desktop DESTINATION ${SERVICES_INSTALL_DIR})

View File

@ -1,302 +0,0 @@
/* This file is part of Clementine.
Copyright 2011, David Sansome <me@davidsansome.com>
Clementine 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 3 of the License, or
(at your option) any later version.
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "clementinerunner.h"
#include "globalsearchinterface.h"
#include <QApplication>
#include <QDBusConnection>
#include <QMutexLocker>
#include <QtDebug>
#include <unistd.h>
const char* ClementineRunner::kDbusService = "org.mpris.clementine";
const char* ClementineRunner::kDbusPath = "/GlobalSearch";
ClementineRunner::ClementineRunner(QObject* parent, const QVariantList& args)
: Plasma::AbstractRunner(parent, args),
interface_(NULL)
{
qDBusRegisterMetaType<GlobalSearchServiceResult>();
qDBusRegisterMetaType<GlobalSearchServiceResultList>();
Q_INIT_RESOURCE(clementineplasmarunner);
nocover_ = QIcon(":/clementineplasmarunner/nocover.png");
setIgnoredTypes(Plasma::RunnerContext::NetworkLocation |
Plasma::RunnerContext::FileSystem);
setSpeed(SlowSpeed);
setPriority(LowPriority);
setHasRunOptions(true);
Plasma::RunnerSyntax syntax = Plasma::RunnerSyntax("<query>", tr("Search music"));
syntax.addExampleQuery("foo fighters");
addSyntax(syntax);
QDBusConnection bus = QDBusConnection::sessionBus();
bus.connect(
kDbusService, kDbusPath,
OrgClementineplayerGlobalSearchInterface::staticInterfaceName(),
"SearchFinished", "i", this, SLOT(SearchFinished(int)));
bus.connect(
kDbusService, kDbusPath,
OrgClementineplayerGlobalSearchInterface::staticInterfaceName(),
"ResultsAvailable", "ia(ibsiiissssbi)",
this, SLOT(ResultsAvailable(int,GlobalSearchServiceResultList)));
bus.connect(
kDbusService, kDbusPath,
OrgClementineplayerGlobalSearchInterface::staticInterfaceName(),
"ArtLoaded", "iay", this, SLOT(ArtLoaded(int,QByteArray)));
}
void ClementineRunner::match(Plasma::RunnerContext& context) {
if (context.query().length() < 3)
return;
if (!interface_) {
interface_ = new OrgClementineplayerGlobalSearchInterface(
kDbusService, kDbusPath, QDBusConnection::sessionBus());
}
int id = 0;
PendingQuery query;
// Start the search
{
QMutexLocker l(&query.results_mutex_);
QMutexLocker l2(&pending_mutex_);
QDBusPendingReply<int> reply = interface_->StartSearch(context.query(), true);
reply.waitForFinished();
if (!reply.isValid()) {
qDebug() << reply.error();
return;
}
id = reply.value();
pending_queries_[id] = &query;
}
// Wait for results to arrive
forever {
query.results_semaphore_.acquire();
// If the user closed the query then stop early.
if (!context.isValid())
break;
// Take the next result on the list
GlobalSearchServiceResult result;
{
QMutexLocker l(&query.results_mutex_);
if (query.results_.isEmpty() && query.finished_)
break;
result = query.results_.takeFirst();
}
// Create a match for the result.
Plasma::QueryMatch match(this);
FillMatch(result, &match);
// Emit the match
context.addMatch(QString(), match);
}
// Remove the pending search
{
QMutexLocker l(&pending_mutex_);
pending_queries_.remove(id);
}
}
void ClementineRunner::FillMatch(const GlobalSearchServiceResult& result,
Plasma::QueryMatch* match) const {
QString text;
QString subtext;
switch (result.type_) {
case globalsearch::Type_Track:
case globalsearch::Type_Stream: {
text = result.title_;
if (!result.artist_.isEmpty()) {
subtext += result.artist_;
} else if (!result.album_artist_.isEmpty()) {
subtext += result.album_artist_;
}
if (!result.album_.isEmpty()) {
subtext += " - " + result.album_;
}
if (result.track_ > 0) {
subtext += " - " + tr("track %1").arg(result.track_);
}
break;
}
case globalsearch::Type_Album: {
if (!result.album_artist_.isEmpty())
text += result.album_artist_;
else if (result.is_compilation_)
text += tr("Various Artists");
else if (!result.artist_.isEmpty())
text += result.artist_;
else
text += tr("Unknown");
// Dash
text += " - ";
// Album
if (result.album_.isEmpty())
text += tr("Unknown");
else
text += result.album_;
if (result.album_size_ > 1)
subtext = tr("Album with %1 tracks").arg(result.album_size_);
break;
}
}
match->setType(Plasma::QueryMatch::CompletionMatch);
match->setText(text);
match->setSubtext(subtext);
match->setRelevance(ResultRelevance(result));
if (!result.image_.isNull()) {
match->setIcon(result.image_);
} else {
match->setIcon(nocover_);
}
}
void ClementineRunner::run(const Plasma::RunnerContext& context, const Plasma::QueryMatch& match) {
// TODO
qDebug() << __PRETTY_FUNCTION__;
}
qreal ClementineRunner::ResultRelevance(const GlobalSearchServiceResult& result) const {
// Plasma sorts results by a qreal that we provide. We have to do some dumb
// maths to create a qreal for the result such that it will produce the same
// sorting as you'd get in clementine.
// Clementine sorts by:
// provider
// match quality
// type
// title (for tracks and streams)
// artist/album (for albums)
qreal ret =
10000 * qreal(result.provider_order_) / 10.0 +
100 * qreal(globalsearch::Quality_None + 1 - result.match_quality_) +
10 * qreal(globalsearch::Type_Album + 1 - result.type_);
return ret;
}
void ClementineRunner::ResultsAvailable(int id, GlobalSearchServiceResultList results) {
Q_ASSERT(QThread::currentThread() == qApp->thread());
// Lock the mutex and add the results to the list.
QMutexLocker l(&pending_mutex_);
PendingMap::iterator it = pending_queries_.find(id);
if (it == pending_queries_.end())
return;
(*it)->provider_order_ ++;
QMutexLocker result_l(&(*it)->results_mutex_);
foreach (GlobalSearchServiceResult result, results) {
result.provider_order_ = (*it)->provider_order_;
if (result.art_on_the_way_) {
// Brace yourselves, art is coming.
(*it)->results_waiting_for_art_ << result;
} else {
(*it)->results_.append(results);
(*it)->results_semaphore_.release();
}
}
}
void ClementineRunner::SearchFinished(int id) {
Q_ASSERT(QThread::currentThread() == qApp->thread());
QMutexLocker l(&pending_mutex_);
PendingMap::iterator it = pending_queries_.find(id);
if (it == pending_queries_.end())
return;
(*it)->finished_signal_emitted_ = true;
if ((*it)->results_waiting_for_art_.isEmpty()) {
QMutexLocker result_l(&(*it)->results_mutex_);
(*it)->finished_ = true;
(*it)->results_semaphore_.release();
}
}
void ClementineRunner::ArtLoaded(int result_id, const QByteArray& image_data) {
Q_ASSERT(QThread::currentThread() == qApp->thread());
QMutexLocker l(&pending_mutex_);
// Find a query that has a result with this ID waiting for art
foreach (PendingQuery* query, pending_queries_.values()) {
GlobalSearchServiceResultList::iterator it;
for (it = query->results_waiting_for_art_.begin() ;
it != query->results_waiting_for_art_.end() ; ++it) {
if (it->result_id_ == result_id) {
break;
}
}
if (it == query->results_waiting_for_art_.end())
continue;
// The API is stupid so we have to create the QIcon here on the GUI thread.
if (!image_data.isEmpty()) {
QImage image;
if (image.loadFromData(image_data)) {
it->image_ = QIcon(QPixmap::fromImage(image));
}
}
// Add the art to this result and remove it from the waiting list
QMutexLocker result_l(&query->results_mutex_);
query->results_ << *it;
query->results_waiting_for_art_.erase(it);
query->finished_ =
query->finished_signal_emitted_ &&
query->results_waiting_for_art_.isEmpty();
query->results_semaphore_.release(query->finished_ ? 2 : 1);
break;
}
}
K_EXPORT_PLASMA_RUNNER(clementine, ClementineRunner)

View File

@ -1,83 +0,0 @@
/* This file is part of Clementine.
Copyright 2011, David Sansome <me@davidsansome.com>
Clementine 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 3 of the License, or
(at your option) any later version.
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CLEMENTINERUNNER_H
#define CLEMENTINERUNNER_H
#include "src/globalsearch/common.h"
#include <QSemaphore>
#include <Plasma/AbstractRunner>
class OrgClementineplayerGlobalSearchInterface;
class ClementineRunner : public Plasma::AbstractRunner {
Q_OBJECT
public:
ClementineRunner(QObject* parent, const QVariantList& args);
static const char* kDbusService;
static const char* kDbusPath;
void match(Plasma::RunnerContext& context);
void run(const Plasma::RunnerContext& context, const Plasma::QueryMatch& match);
private slots:
void ResultsAvailable(int id, GlobalSearchServiceResultList results);
void SearchFinished(int id);
void ArtLoaded(int result_id, const QByteArray& image_data);
private:
struct PendingQuery {
PendingQuery()
: provider_order_(0),
finished_signal_emitted_(false),
finished_(false)
{}
// The main thread is the only one to access these variables.
int provider_order_;
GlobalSearchServiceResultList results_waiting_for_art_;
bool finished_signal_emitted_;
// This list contains results that are finished and waiting to be processed
// by the match() thread. results_mutex_ locks results_ and
// results_semaphore_ is released once for each result.
GlobalSearchServiceResultList results_;
QMutex results_mutex_;
QSemaphore results_semaphore_;
bool finished_;
};
typedef QMap<int, PendingQuery*> PendingMap;
qreal ResultRelevance(const GlobalSearchServiceResult& result) const;
void FillMatch(const GlobalSearchServiceResult& result,
Plasma::QueryMatch* match) const;
private:
OrgClementineplayerGlobalSearchInterface* interface_;
QIcon nocover_;
// pending_mutex_ locks any access to the PendingMap.
QMutex pending_mutex_;
PendingMap pending_queries_;
};
#endif // CLEMENTINERUNNER_H

View File

@ -1,17 +0,0 @@
[Desktop Entry]
Name=Clementine
Icon=clementine
Comment=Clementine global music search
Type=Service
ServiceTypes=Plasma/Runner
X-KDE-Library=plasma_runner_clementine
X-KDE-PluginInfo-Author=David Sansome
X-KDE-PluginInfo-Email=me@davidsansome.com
X-KDE-PluginInfo-Name=clementine
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=http://www.clementine-player.org/
X-KDE-PluginInfo-Category=Audio
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true