From 82de6a8ecfef6b7d835ebaadc7ddf0b6de0a41c4 Mon Sep 17 00:00:00 2001 From: Bhushan Shah Date: Wed, 4 Sep 2013 19:39:01 +0530 Subject: [PATCH] Port customDataContainersEngine example --- examples/dataengines/CMakeLists.txt | 2 +- .../dataengines/customDataContainers/CMakeLists.txt | 10 ++++++++-- .../customDataContainersEngine.cpp | 11 +++++++---- .../customDataContainers/httpContainer.cpp | 2 +- .../dataengines/customDataContainers/httpContainer.h | 6 ++++-- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/examples/dataengines/CMakeLists.txt b/examples/dataengines/CMakeLists.txt index 11b41162b..bbcf1510b 100644 --- a/examples/dataengines/CMakeLists.txt +++ b/examples/dataengines/CMakeLists.txt @@ -1,3 +1,3 @@ add_subdirectory(simpleEngine) add_subdirectory(sourcesOnRequest) -#add_subdirectory(customDataContainers) \ No newline at end of file +add_subdirectory(customDataContainers) \ No newline at end of file diff --git a/examples/dataengines/customDataContainers/CMakeLists.txt b/examples/dataengines/customDataContainers/CMakeLists.txt index 22b0ebdfb..b64967436 100644 --- a/examples/dataengines/customDataContainers/CMakeLists.txt +++ b/examples/dataengines/customDataContainers/CMakeLists.txt @@ -3,8 +3,14 @@ set(customDataContainers_SRCS httpContainer.cpp ) -kde4_add_plugin(plasma_dataengine_example_customDataContainers ${customDataContainers_SRCS}) -target_link_libraries(plasma_dataengine_example_customDataContainers ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS}) +kservice_desktop_to_json(plasma-dataengine-example-customDataContainers.desktop) + +plasma_add_plugin(plasma_dataengine_example_customDataContainers ${customDataContainers_SRCS}) +target_link_libraries(plasma_dataengine_example_customDataContainers + plasma + ${KService_LIBRARIES} + ${KDE4_KIO_LIBS} +) install(TARGETS plasma_dataengine_example_customDataContainers DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES plasma-dataengine-example-customDataContainers.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/examples/dataengines/customDataContainers/customDataContainersEngine.cpp b/examples/dataengines/customDataContainers/customDataContainersEngine.cpp index c77bc6185..42b20b72b 100644 --- a/examples/dataengines/customDataContainers/customDataContainersEngine.cpp +++ b/examples/dataengines/customDataContainers/customDataContainersEngine.cpp @@ -23,6 +23,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +#include + #include "customDataContainersEngine.h" #include "httpContainer.h" @@ -44,9 +47,9 @@ bool DataContainersEngine::sourceRequestEvent(const QString &source) { // This engine will fetch webpages over http. First thing we do is check // the source to make sure it is indeed an http URL. - KUrl url(source); - kDebug() << "goin to fetch" << source << url << url.protocol(); - if (!url.protocol().startsWith("http", Qt::CaseInsensitive)) { + QUrl url(source); + qDebug() << "goin to fetch" << source << url << url.scheme(); + if (!url.scheme().startsWith("http", Qt::CaseInsensitive)) { return false; } @@ -80,7 +83,7 @@ bool DataContainersEngine::updateSourceEvent(const QString &source) } // export the plugin; use the plugin name and the class name -K_EXPORT_PLASMA_DATAENGINE(org.kde.examples.customDataContainers, DataContainersEngine) +K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(org.kde.examples.customDataContainers, DataContainersEngine, "plasma-dataengine-example-customDataContainers.json") // include the moc file so the build system makes it for us #include "customDataContainersEngine.moc" diff --git a/examples/dataengines/customDataContainers/httpContainer.cpp b/examples/dataengines/customDataContainers/httpContainer.cpp index 98f26e444..5c5cba655 100644 --- a/examples/dataengines/customDataContainers/httpContainer.cpp +++ b/examples/dataengines/customDataContainers/httpContainer.cpp @@ -28,7 +28,7 @@ #include #include -HttpContainer::HttpContainer(const KUrl &url, QObject *parent) +HttpContainer::HttpContainer(const QUrl &url, QObject *parent) : Plasma::DataContainer(parent), m_url(url) { diff --git a/examples/dataengines/customDataContainers/httpContainer.h b/examples/dataengines/customDataContainers/httpContainer.h index d8a05d79c..24e5db72c 100644 --- a/examples/dataengines/customDataContainers/httpContainer.h +++ b/examples/dataengines/customDataContainers/httpContainer.h @@ -26,6 +26,8 @@ #ifndef HTTPCONTAINER_H #define HTTPCONTAINER_H +#include + #include namespace KIO @@ -38,7 +40,7 @@ class HttpContainer : public Plasma::DataContainer Q_OBJECT public: - HttpContainer(const KUrl &url, QObject *parent = 0); + HttpContainer(const QUrl &url, QObject *parent = 0); void fetchUrl(bool reload = true); @@ -47,7 +49,7 @@ private Q_SLOTS: void fetchFinished(KJob *); private: - const KUrl m_url; + const QUrl m_url; QWeakPointer m_job; QByteArray m_data; };