Newer
Older
* Copyright (C) 2019 Kevin Whitaker <eyecreate@eyecreate.org>
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "simplecastservice.h"
#include <Plasma/ServiceJob>
class SimpleCastJob : public Plasma::ServiceJob
{
Q_OBJECT
public:
SimpleCastJob(const QString& destination, const QString& operation, MiniMediaPlayer *player, const QVariantMap& parameters, QObject* parent = 0) : Plasma::ServiceJob(destination,operation,parameters,parent),player(player) {}
virtual void start() override
{
const auto operation = operationName();
const auto paramaters = parameters();
if(operation == "changePlayState")
{
if(paramaters.contains("playing"))
{
setResult(player->playPauseTrack(paramaters["playing"].toBool()));
}
}
else if(operation == "skipToNextTrack")
{
setResult(player->nextTrack());
}
else if(operation == "addURLToPlaylist")
{
if(paramaters.contains("URL"))
{
Kevin Whitaker
committed
player->addURLToPlaylist(paramaters["URL"].toUrl());
emitResult();
}
}
}
private:
MiniMediaPlayer *player;
};
SimpleCastService::SimpleCastService(const QString &destination,MiniMediaPlayer *player, QObject *parent) : Plasma::Service(parent), player(player)
{
setName("simplecastcontrol");
}
SimpleCastService::~SimpleCastService()
{
}
Plasma::ServiceJob* SimpleCastService::createJob(const QString& operation, QVariantMap& parameters)
{
return new SimpleCastJob(destination(),operation,player,parameters,this);
}
//K_EXPORT_PLASMA_SERVICE(org.eyecreate.simplecast, SimpleCastService)
#include "simplecastservice.moc"