diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 093ef4154119942ea28b5cf5a79c5e731365ad29..003e1a1ebf608d46e7490b6f25a4410ebb3d98a3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,17 +1,21 @@ set( simplecastengine_SRCS simplecastengine.cpp + minimediaplayer.cpp + simplecastservice.cpp ) -add_library( plasma_dataengine_simplecastengine ${simplecastengine_SRCS} ) +add_library(plasma_engine_simplecast ${simplecastengine_SRCS}) +set_target_properties(plasma_engine_simplecast PROPERTIES PREFIX "") -kcoreaddons_desktop_to_json(plasma_dataengine_simplecastengine plasma_dataengine_simplecastengine.desktop) +kcoreaddons_desktop_to_json(plasma_engine_simplecast plasma-dataengine-simplecast.desktop) -target_link_libraries( plasma_dataengine_simplecastengine +target_link_libraries( plasma_engine_simplecast Qt5::Core KF5::Plasma KF5::Service KF5::I18n ) -install(TARGETS plasma_dataengine_simplecastengine DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/dataengine) -install( PROGRAMS org.eyecreate.simplecastengine.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) +install(TARGETS plasma_engine_simplecast DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/dataengine) +install(FILES simplecastcontrol.operations DESTINATION ${PLASMA_DATA_INSTALL_DIR}/services) +install(FILES plasma-dataengine-simplecast.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) diff --git a/src/minimediaplayer.cpp b/src/minimediaplayer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1bfebcbf21a0c1aa876d594b4ca91e1f6fcf4f7f --- /dev/null +++ b/src/minimediaplayer.cpp @@ -0,0 +1,33 @@ +/* + * Simple Media Player that runs off a playlist. + * Copyright (C) 2019 Kevin Whitaker + * + * 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 . + */ + +#include "minimediaplayer.h" + +MiniMediaPlayer::MiniMediaPlayer(QObject *parent) : QObject(parent) +{ +} + +QMediaPlaylist* MiniMediaPlayer::playlist() const +{ + return m_playlist; +} + +QMediaPlayer* MiniMediaPlayer::player() const +{ + return m_player; +} diff --git a/src/minimediaplayer.h b/src/minimediaplayer.h new file mode 100644 index 0000000000000000000000000000000000000000..a761218c1ccdcf338128fe39527b011dedc34a17 --- /dev/null +++ b/src/minimediaplayer.h @@ -0,0 +1,56 @@ +/* + * Simple Media Player that runs off a playlist. + * Copyright (C) 2019 Kevin Whitaker + * + * 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 . + */ + +#ifndef MINIMEDIAPLAYER_H +#define MINIMEDIAPLAYER_H + +#include +#include +#include + +/** + * @todo write docs + */ +class MiniMediaPlayer : public QObject +{ + Q_OBJECT + Q_PROPERTY(QMediaPlaylist playlist READ playlist) + Q_PROPERTY(QMediaPlayer player READ player) + +public: + /** + * @todo write docs + */ + MiniMediaPlayer(QObject *parent = 0); + + /** + * @return the playlist + */ + QMediaPlaylist *playlist() const; + + /** + * @return the player + */ + QMediaPlayer *player() const; + +private: + QMediaPlaylist *m_playlist; + QMediaPlayer *m_player; +}; + +#endif // MINIMEDIAPLAYER_H diff --git a/src/plasma_dataengine_simplecastengine.desktop b/src/plasma-dataengine-simplecast.desktop similarity index 75% rename from src/plasma_dataengine_simplecastengine.desktop rename to src/plasma-dataengine-simplecast.desktop index 947f8b6b24dfe156c863433faf94e75a406eb176..81d4d8dd171deb0d9492dda0ae5f2dff4b074f0e 100644 --- a/src/plasma_dataengine_simplecastengine.desktop +++ b/src/plasma-dataengine-simplecast.desktop @@ -1,17 +1,18 @@ [Desktop Entry] -Name=Simple Cast Engine +Name=Simple Cast Comment=Data Engine that handles listing, queueing, and playing media URLs from other devices. Type=Service +Icon=document-share X-KDE-ServiceTypes=Plasma/DataEngine -X-KDE-Library=plasma_dataengine_simplecast -X-Plasma-EngineName=simplecast +X-KDE-Library=plasma_engine_simplecast +X-Plasma-EngineName=org.eyecreate.simplecast X-KDE-PluginInfo-Author=Kevin Whitaker X-KDE-PluginInfo-Email=eyecreate@eyecreate.org X-KDE-PluginInfo-Name=simplecast X-KDE-PluginInfo-Version=0.1 X-KDE-PluginInfo-Website=http://plasma.kde.org/ -X-KDE-PluginInfo-Category=Examples +X-KDE-PluginInfo-Category= X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=LGPL X-KDE-PluginInfo-EnabledByDefault=true diff --git a/src/simplecastcontrol.operations b/src/simplecastcontrol.operations new file mode 100644 index 0000000000000000000000000000000000000000..1976b302f71d2ac9727134bb1cce77325e6532b5 --- /dev/null +++ b/src/simplecastcontrol.operations @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + diff --git a/src/simplecastengine.cpp b/src/simplecastengine.cpp index 4b604d6a2ad945a00523d96931e17749603416aa..3cff0a705f8ef6de87d80d7d99dd5a225fed66d8 100644 --- a/src/simplecastengine.cpp +++ b/src/simplecastengine.cpp @@ -19,6 +19,7 @@ */ #include "simplecastengine.h" +#include "simplecastservice.h" SimpleCastEngine::SimpleCastEngine(QObject *parent, const QVariantList &args) : Plasma::DataEngine(parent,args) @@ -29,16 +30,35 @@ SimpleCastEngine::SimpleCastEngine(QObject *parent, const QVariantList &args) bool SimpleCastEngine::sourceRequestEvent(const QString& source) { - return updateSourceEvent(source);//TODO + setData(source, "you found me"); + return true; + //return updateSourceEvent(source);//TODO } bool SimpleCastEngine::updateSourceEvent(const QString& source) { + //Source for current playlist(contains title and url) + //Source for current track time and length, and playing state + setData(source, "you found me again"); return true;//TODO } +QStringList SimpleCastEngine::sources() const +{ + return QStringList() << "Playlist" << "CurrentState"; +} + +Plasma::Service * SimpleCastEngine::serviceForSource(const QString& source) +{ + if(source == "CurrentState") + { + return new SimpleCastService(source, this); + } + return Plasma::DataEngine::serviceForSource(source); +} + -K_EXPORT_PLASMA_DATAENGINE(simplecast, SimpleCastEngine) +K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(org.eyecreate.simplecast, SimpleCastEngine,"plasma-dataengine-simplecast.json") #include "simplecastengine.moc" diff --git a/src/simplecastengine.h b/src/simplecastengine.h index 64573688fba6168005d8d1798dcf219f71d25171..23a5d629bc7785687dd6d4c09948a1817512611e 100644 --- a/src/simplecastengine.h +++ b/src/simplecastengine.h @@ -23,16 +23,19 @@ #include +#include class SimpleCastEngine : public Plasma::DataEngine { Q_OBJECT public: SimpleCastEngine(QObject *parent, const QVariantList &args); + QStringList sources() const override; + Plasma::Service *serviceForSource(const QString &source) override; protected: - bool sourceRequestEvent(const QString &source); - bool updateSourceEvent(const QString &source); + bool sourceRequestEvent(const QString &source) override; + bool updateSourceEvent(const QString &source) override; }; diff --git a/src/simplecastservice.cpp b/src/simplecastservice.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9fb123c667717b384aeb829d21aad1dbff1f813e --- /dev/null +++ b/src/simplecastservice.cpp @@ -0,0 +1,38 @@ +/* + * + * Copyright (C) 2019 + * + * 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 . + */ + +#include "simplecastservice.h" + +SimpleCastService::SimpleCastService(const QString &destination, QObject *parent) : Plasma::Service(parent) +{ + setName("simplecastcontrol"); +} + +SimpleCastService::~SimpleCastService() +{ +} + + +Plasma::ServiceJob* SimpleCastService::createJob(const QString& operation, QVariantMap& parameters) +{ + return NULL; //TODO +} + +//K_EXPORT_PLASMA_SERVICE(org.eyecreate.simplecast, SimpleCastService) + +#include "simplecastservice.moc" diff --git a/src/simplecastservice.h b/src/simplecastservice.h new file mode 100644 index 0000000000000000000000000000000000000000..056366002f82decc9c2fdf12252e16364d3e4e93 --- /dev/null +++ b/src/simplecastservice.h @@ -0,0 +1,45 @@ +/* + * + * Copyright (C) 2019 + * + * 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 . + */ + +#ifndef SIMPLECASTSERVICE_H +#define SIMPLECASTSERVICE_H + +#include + +/** + * @todo write docs + */ +class SimpleCastService : public Plasma::Service +{ + Q_OBJECT +public: + SimpleCastService(const QString &destination, QObject *parent = 0); + ~SimpleCastService(); +protected: + /** + * @todo write docs + * + * @param operation TODO + * @param parameters TODO + * @return TODO + */ + Plasma::ServiceJob* createJob(const QString& operation, QVariantMap& parameters) override; + +}; + +#endif // SIMPLECASTSERVICE_H