[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdeplasma-addons] /: Port potd (picture of the day) dataengine to KF5.
From:       Weng Xuetian <wengxt () gmail ! com>
Date:       2016-11-15 19:19:48
Message-ID: E1c6jGm-0008P8-3u () code ! kde ! org
[Download RAW message or body]

Git commit 30c8cd5bb57dab0e4d49dc76354f912aef02fc7e by Weng Xuetian.
Committed on 15/11/2016 at 19:19.
Pushed by xuetianweng into branch 'master'.

Port potd (picture of the day) dataengine to KF5.

Summary:
Osei site was discontinued, replace it with its successor which is also from
NOAA. Also fix flickr, wikipedia, national geography provider, which are
broken becauses of changes from providers. Use KPluginLoader to load plugin
instead of KServiceTypeTrader.

Test Plan: Manually with plasmaengineexplorer

Reviewers: #plasma, mart

Reviewed By: mart

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D3183

M  +1    -1    CMakeLists.txt
M  +1    -1    dataengines/CMakeLists.txt
M  +46   -33   dataengines/potd/CMakeLists.txt
M  +2    -2    dataengines/potd/PoTD-list.txt
M  +7    -5    dataengines/potd/apodprovider.cpp
M  +6    -4    dataengines/potd/cachedprovider.cpp
M  +7    -5    dataengines/potd/epodprovider.cpp
M  +18   -9    dataengines/potd/flickrprovider.cpp
M  +1    -0    dataengines/potd/flickrprovider.h
M  +15   -9    dataengines/potd/natgeoprovider.cpp
C  +33   -28   dataengines/potd/noaaprovider.cpp [from: \
dataengines/potd/natgeoprovider.cpp - 057% similarity] A  +10   -0    \
dataengines/potd/noaaprovider.desktop R  +12   -12   dataengines/potd/noaaprovider.h \
[from: dataengines/potd/oseiprovider.h - 072% similarity] D  +0    -89   \
dataengines/potd/oseiprovider.cpp D  +0    -100  \
dataengines/potd/oseiprovider.desktop D  +0    -41   \
dataengines/potd/plasma_potd_export.h M  +29   -16   dataengines/potd/potd.cpp
M  +3    -5    dataengines/potd/potd.h
M  +1    -5    dataengines/potd/potdprovider.h
M  +8    -5    dataengines/potd/wcpotdprovider.cpp
M  +1    -0    wallpapers/CMakeLists.txt

http://commits.kde.org/kdeplasma-addons/30c8cd5bb57dab0e4d49dc76354f912aef02fc7e

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 60c743f..8d8a555 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,7 +23,7 @@ set(KF5_MIN_VERSION 5.8.0)
 find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Gui DBus Quick Qml \
Widgets X11Extras)  
 find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
-    Activities Config ConfigWidgets CoreAddons I18n KIO KCMUtils Plasma Runner \
Service UnitConversion KDELibs4Support NewStuff Kross) +    Activities Config \
ConfigWidgets CoreAddons I18n KIO KCMUtils Plasma Runner Service UnitConversion \
KDELibs4Support NewStuff Kross WebKit)  
 find_package(LibTaskManager CONFIG REQUIRED)
 
diff --git a/dataengines/CMakeLists.txt b/dataengines/CMakeLists.txt
index b568ee2..52f4782 100644
--- a/dataengines/CMakeLists.txt
+++ b/dataengines/CMakeLists.txt
@@ -4,6 +4,6 @@
 #       add_subdirectory(microblog)
 # endif(QCA2_FOUND AND QJSON_FOUND AND QTOAUTH_FOUND)
 #
-# add_subdirectory(potd)
+add_subdirectory(potd)
 add_subdirectory(konsoleprofiles)
 # add_subdirectory(konqprofiles)
diff --git a/dataengines/potd/CMakeLists.txt b/dataengines/potd/CMakeLists.txt
index c5ade79..b13db87 100644
--- a/dataengines/potd/CMakeLists.txt
+++ b/dataengines/potd/CMakeLists.txt
@@ -3,10 +3,15 @@ set(potd_engine_SRCS
 	potd.cpp
 )
 
-kde4_add_plugin(plasma_engine_potd ${potd_engine_SRCS} )
-target_link_libraries(plasma_engine_potd plasmapotdprovidercore ${KDE4_KDEUI_LIBS} \
${KDE4_PLASMA_LIBS} ) +add_library(plasma_engine_potd MODULE ${potd_engine_SRCS} )
+target_link_libraries(plasma_engine_potd plasmapotdprovidercore
+    KF5::Plasma
+    KF5::KIOCore
+)
+
+kcoreaddons_desktop_to_json(plasma_engine_potd plasma-dataengine-potd.desktop \
SERVICE_TYPES plasma-dataengine.desktop)  
-install(TARGETS plasma_engine_potd DESTINATION ${PLUGIN_INSTALL_DIR} )
+install(TARGETS plasma_engine_potd DESTINATION \
${PLUGIN_INSTALL_DIR}/plasma/dataengine )  install(FILES \
plasma-dataengine-potd.desktop DESTINATION ${SERVICES_INSTALL_DIR} )  
 
@@ -14,15 +19,15 @@ install(FILES plasma-dataengine-potd.desktop DESTINATION \
${SERVICES_INSTALL_DIR}  
 set(potd_provider_core_SRCS
 	potdprovider.cpp
+	${CMAKE_CURRENT_BINARY_DIR}/plasma_potd_export.h
 )
 
-kde4_add_library( plasmapotdprovidercore SHARED ${potd_provider_core_SRCS} )
-target_link_libraries( plasmapotdprovidercore ${KDE4_KDEUI_LIBS} )
+add_library( plasmapotdprovidercore SHARED ${potd_provider_core_SRCS} )
+target_link_libraries( plasmapotdprovidercore Qt5::Gui KF5::CoreAddons )
 set_target_properties( plasmapotdprovidercore PROPERTIES VERSION 1.0.0 SOVERSION 1 )
+generate_export_header(plasmapotdprovidercore BASE_NAME PLASMA_POTD EXPORT_FILE_NAME \
plasma_potd_export.h)  
 install( TARGETS plasmapotdprovidercore ${INSTALL_TARGETS_DEFAULT_ARGS} )
-install( FILES plasma_potdprovider.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )
-
 
 ########### plugins ###############
 
@@ -30,56 +35,64 @@ set( potd_flickr_provider_SRCS
 	flickrprovider.cpp
 )
 
-kde4_add_plugin( plasma_potd_flickrprovider ${potd_flickr_provider_SRCS} )
-target_link_libraries( plasma_potd_flickrprovider plasmapotdprovidercore \
                ${KDE4_KIO_LIBS}  ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY})
-install( TARGETS plasma_potd_flickrprovider DESTINATION ${PLUGIN_INSTALL_DIR} )
-install( FILES flickrprovider.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+add_library( plasma_potd_flickrprovider MODULE ${potd_flickr_provider_SRCS} )
+target_link_libraries( plasma_potd_flickrprovider plasmapotdprovidercore \
KF5::KIOCore KF5::CoreAddons)  
+kcoreaddons_desktop_to_json(plasma_potd_flickrprovider flickrprovider.desktop \
SERVICE_TYPES ${CMAKE_CURRENT_SOURCE_DIR}/plasma_potdprovider.desktop) +
+install( TARGETS plasma_potd_flickrprovider DESTINATION ${PLUGIN_INSTALL_DIR}/potd )
 
 set( potd_apod_provider_SRCS
 	apodprovider.cpp
 )
 
-kde4_add_plugin( plasma_potd_apodprovider ${potd_apod_provider_SRCS} )
-target_link_libraries( plasma_potd_apodprovider plasmapotdprovidercore \
                ${KDE4_KIO_LIBS} ${QT_QTGUI_LIBRARY} ${KDE4_KDECORE_LIBS})
-install( TARGETS plasma_potd_apodprovider DESTINATION ${PLUGIN_INSTALL_DIR} )
-install( FILES apodprovider.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+add_library( plasma_potd_apodprovider MODULE ${potd_apod_provider_SRCS} )
+target_link_libraries( plasma_potd_apodprovider plasmapotdprovidercore KF5::KIOCore)
+
+kcoreaddons_desktop_to_json(plasma_potd_apodprovider apodprovider.desktop \
SERVICE_TYPES ${CMAKE_CURRENT_SOURCE_DIR}/plasma_potdprovider.desktop) +
+install( TARGETS plasma_potd_apodprovider DESTINATION ${PLUGIN_INSTALL_DIR}/potd )
 
 set( potd_natgeo_provider_SRCS
 	natgeoprovider.cpp
 )
 
-kde4_add_plugin( plasma_potd_natgeoprovider ${potd_natgeo_provider_SRCS} )
-target_link_libraries( plasma_potd_natgeoprovider plasmapotdprovidercore \
                ${KDE4_KIO_LIBS} ${QT_QTGUI_LIBRARY} ${KDE4_KDECORE_LIBS} \
                ${KDE4_KDEWEBKIT_LIBRARY})
-install( TARGETS plasma_potd_natgeoprovider DESTINATION ${PLUGIN_INSTALL_DIR} )
-install( FILES natgeoprovider.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+add_library( plasma_potd_natgeoprovider MODULE ${potd_natgeo_provider_SRCS} )
+target_link_libraries( plasma_potd_natgeoprovider plasmapotdprovidercore \
KF5::KIOCore KF5::WebKit)  
+kcoreaddons_desktop_to_json(plasma_potd_natgeoprovider natgeoprovider.desktop \
SERVICE_TYPES ${CMAKE_CURRENT_SOURCE_DIR}/plasma_potdprovider.desktop) +
+install( TARGETS plasma_potd_natgeoprovider DESTINATION ${PLUGIN_INSTALL_DIR}/potd )
 
 set( potd_epod_provider_SRCS
 	epodprovider.cpp
 )
 
-kde4_add_plugin( plasma_potd_epodprovider ${potd_epod_provider_SRCS} )
-target_link_libraries( plasma_potd_epodprovider plasmapotdprovidercore \
                ${KDE4_KIO_LIBS} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY})
-install( TARGETS plasma_potd_epodprovider DESTINATION ${PLUGIN_INSTALL_DIR} )
-install( FILES epodprovider.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+add_library( plasma_potd_epodprovider MODULE ${potd_epod_provider_SRCS} )
+target_link_libraries( plasma_potd_epodprovider plasmapotdprovidercore KF5::KIOCore)
+
+kcoreaddons_desktop_to_json(plasma_potd_epodprovider epodprovider.desktop \
SERVICE_TYPES ${CMAKE_CURRENT_SOURCE_DIR}/plasma_potdprovider.desktop)  
+install( TARGETS plasma_potd_epodprovider DESTINATION ${PLUGIN_INSTALL_DIR}/potd )
 
-set( potd_osei_provider_SRCS
-	oseiprovider.cpp
+set( potd_noaa_provider_SRCS
+	noaaprovider.cpp
 )
 
-kde4_add_plugin( plasma_potd_oseiprovider ${potd_osei_provider_SRCS} )
-target_link_libraries( plasma_potd_oseiprovider plasmapotdprovidercore \
                ${KDE4_KIO_LIBS} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} )
-install( TARGETS plasma_potd_oseiprovider DESTINATION ${PLUGIN_INSTALL_DIR} )
-install( FILES oseiprovider.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+add_library( plasma_potd_noaaprovider MODULE ${potd_noaa_provider_SRCS} )
+target_link_libraries( plasma_potd_noaaprovider plasmapotdprovidercore KF5::KIOCore \
KF5::WebKit) +
+kcoreaddons_desktop_to_json(plasma_potd_noaaprovider noaaprovider.desktop \
SERVICE_TYPES ${CMAKE_CURRENT_SOURCE_DIR}/plasma_potdprovider.desktop)  
+install( TARGETS plasma_potd_noaaprovider DESTINATION ${PLUGIN_INSTALL_DIR}/potd )
 
 set( potd_wcpotd_provider_SRCS
 	wcpotdprovider.cpp
 )
 
-kde4_add_plugin( plasma_potd_wcpotdprovider ${potd_wcpotd_provider_SRCS} )
-target_link_libraries( plasma_potd_wcpotdprovider plasmapotdprovidercore \
                ${KDE4_KIO_LIBS} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} )
-install( TARGETS plasma_potd_wcpotdprovider DESTINATION ${PLUGIN_INSTALL_DIR} )
-install( FILES wcpotdprovider.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+add_library( plasma_potd_wcpotdprovider MODULE ${potd_wcpotd_provider_SRCS} )
+target_link_libraries( plasma_potd_wcpotdprovider plasmapotdprovidercore \
KF5::KIOCore ) +
+kcoreaddons_desktop_to_json(plasma_potd_wcpotdprovider wcpotdprovider.desktop \
SERVICE_TYPES ${CMAKE_CURRENT_SOURCE_DIR}/plasma_potdprovider.desktop) +
+install( TARGETS plasma_potd_wcpotdprovider DESTINATION ${PLUGIN_INSTALL_DIR}/potd )
diff --git a/dataengines/potd/PoTD-list.txt b/dataengines/potd/PoTD-list.txt
index 0b2f7b1..53b0fe0 100644
--- a/dataengines/potd/PoTD-list.txt
+++ b/dataengines/potd/PoTD-list.txt
@@ -17,9 +17,9 @@ http://www.ubcbotanicalgarden.org/potd/
 http://epod.usra.edu/
 RSS feed http://interglacial.com/rss/epod.rss
 
-* OSEI (Operational Significant Event Imagery) 
+* NOAA
 Image Of the Day -------------------------------------  DONE
-http://www.osei.noaa.gov/OSEIiod.html
+http://www.nnvl.noaa.gov/imageoftheday.php
 
 * WCPoTD Wikimedia Commons Picture of The Day ---------- almost DONE (need to add \
the Credits URL below the pic)  http://tools.wikimedia.de/~daniel/potd/potd.php
diff --git a/dataengines/potd/apodprovider.cpp b/dataengines/potd/apodprovider.cpp
index 8271613..fdca54a 100644
--- a/dataengines/potd/apodprovider.cpp
+++ b/dataengines/potd/apodprovider.cpp
@@ -23,11 +23,9 @@
 #include <QtCore/QRegExp>
 #include <QtGui/QImage>
 
-#include <KDebug>
+#include <QDebug>
 #include <kio/job.h>
 
-POTDPROVIDER_EXPORT_PLUGIN( ApodProvider, "ApodProvider", "" )
-
 class ApodProvider::Private
 {
   public:
@@ -59,7 +57,7 @@ void ApodProvider::Private::pageRequestFinished( KJob *_job )
     exp.setMinimal( true );
     if ( exp.indexIn( data ) != -1 ) {
         const QString sub = exp.cap(1);
-        KUrl url( QString( QLatin1String( "http://antwrp.gsfc.nasa.gov/apod/%1" ) \
).arg( sub ) ); +        QUrl url( QString( QLatin1String( \
                "http://antwrp.gsfc.nasa.gov/apod/%1" ) ).arg( sub ) );
         KIO::StoredTransferJob *imageJob = KIO::storedGet( url, KIO::NoReload, \
                KIO::HideProgressInfo );
         mParent->connect( imageJob, SIGNAL(finished(KJob*)), \
SLOT(imageRequestFinished(KJob*)) );  } else {
@@ -82,7 +80,7 @@ void ApodProvider::Private::imageRequestFinished( KJob *_job )
 ApodProvider::ApodProvider( QObject *parent, const QVariantList &args )
     : PotdProvider( parent, args ), d( new Private( this ) )
 {
-    KUrl url( QLatin1String( "http://antwrp.gsfc.nasa.gov/apod/" ) );
+    QUrl url( QLatin1String( "http://antwrp.gsfc.nasa.gov/apod/" ) );
     KIO::StoredTransferJob *job = KIO::storedGet( url, KIO::NoReload, \
                KIO::HideProgressInfo );
     connect( job, SIGNAL(finished(KJob*)), SLOT(pageRequestFinished(KJob*)) );
 }
@@ -97,3 +95,7 @@ QImage ApodProvider::image() const
     return d->mImage;
 }
 
+K_PLUGIN_FACTORY_WITH_JSON(ApodProviderFactory, "apodprovider.json", \
registerPlugin<ApodProvider>();) +
+#include "moc_apodprovider.cpp"
+#include "apodprovider.moc"
diff --git a/dataengines/potd/cachedprovider.cpp \
b/dataengines/potd/cachedprovider.cpp index 869c4c9..520c53e 100644
--- a/dataengines/potd/cachedprovider.cpp
+++ b/dataengines/potd/cachedprovider.cpp
@@ -23,11 +23,11 @@
 #include <QtCore/QFileInfo>
 #include <QtCore/QTimer>
 #include <QtCore/QThreadPool>
+#include <QStandardPaths>
+#include <QDir>
 #include <QtGui/QImage>
 
-#include <KDebug>
-
-#include <kstandarddirs.h>
+#include <QDebug>
 
 LoadImageThread::LoadImageThread(const QString &filePath)
     : m_filePath(filePath)
@@ -56,7 +56,9 @@ void SaveImageThread::run()
 
 QString CachedProvider::identifierToPath( const QString &identifier )
 {
-    const QString dataDir = KStandardDirs::locateLocal( "cache", \
QLatin1String("plasma_engine_podt/") ); +    const QString dataDir = \
QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + \
QLatin1String("/plasma_engine_potd/"); +    QDir d;
+    d.mkpath(dataDir);
     return QString( dataDir + identifier );
 }
 
diff --git a/dataengines/potd/epodprovider.cpp b/dataengines/potd/epodprovider.cpp
index b3f44fd..6343ec9 100644
--- a/dataengines/potd/epodprovider.cpp
+++ b/dataengines/potd/epodprovider.cpp
@@ -23,11 +23,9 @@
 #include <QtCore/QRegExp>
 #include <QtGui/QImage>
 
-#include <KDebug>
+#include <QDebug>
 #include <kio/job.h>
 
-POTDPROVIDER_EXPORT_PLUGIN( EpodProvider, "EpodProvider", "" )
-
 class EpodProvider::Private
 {
   public:
@@ -60,7 +58,7 @@ void EpodProvider::Private::pageRequestFinished(KJob *_job)
 
     int pos = exp.indexIn( data ) + pattern.length();
     const QString sub = data.mid( pos-4, pattern.length()+6);
-    KUrl url( QString(QLatin1String( "http://epod.usra.edu/.a/%1-pi" )) .arg(sub)  \
); +    QUrl url( QString(QLatin1String( "http://epod.usra.edu/.a/%1-pi" )) .arg(sub) \
                );
     KIO::StoredTransferJob *imageJob = KIO::storedGet( url, KIO::NoReload, \
                KIO::HideProgressInfo );
     QObject::connect(imageJob, SIGNAL(finished(KJob*)), mParent, \
SLOT(imageRequestFinished(KJob*)) );  }
@@ -81,7 +79,7 @@ void EpodProvider::Private::imageRequestFinished( KJob *_job)
 EpodProvider::EpodProvider( QObject *parent, const QVariantList &args )
     : PotdProvider( parent, args ), d( new Private( this ) )
 {
-    KUrl url( QLatin1String( "http://epod.usra.edu/blog/" ) );
+    QUrl url( QLatin1String( "http://epod.usra.edu/blog/" ) );
     KIO::StoredTransferJob *job = KIO::storedGet( url, KIO::NoReload, \
KIO::HideProgressInfo );  
     connect( job, SIGNAL(finished(KJob*)), SLOT(pageRequestFinished(KJob*)) );
@@ -97,3 +95,7 @@ QImage EpodProvider::image() const
     return d->mImage;
 }
 
+K_PLUGIN_FACTORY_WITH_JSON(EpodProviderFactory, "epodprovider.json", \
registerPlugin<EpodProvider>();) +
+#include "moc_epodprovider.cpp"
+#include "epodprovider.moc"
diff --git a/dataengines/potd/flickrprovider.cpp \
b/dataengines/potd/flickrprovider.cpp index c7eb249..6a05fa1 100644
--- a/dataengines/potd/flickrprovider.cpp
+++ b/dataengines/potd/flickrprovider.cpp
@@ -25,10 +25,10 @@
 #include <QtGui/QImage>
 #include <QXmlStreamReader>
 
-#include <KDebug>
+#include <QDebug>
 #include <kio/job.h>
 
-POTDPROVIDER_EXPORT_PLUGIN( FlickrProvider, "FlickrProvider", "" )
+#define FLICKR_API_KEY "11829a470557ad8e10b02e80afacb3af"
 
 class FlickrProvider::Private
 {
@@ -58,7 +58,7 @@ void FlickrProvider::Private::pageRequestFinished( KJob *_job )
     KIO::StoredTransferJob *job = static_cast<KIO::StoredTransferJob *>( _job );
     if (job->error()) {
         emit mParent->error( mParent );
-        kDebug() << "pageRequestFinished error";
+        qDebug() << "pageRequestFinished error";
         return;
     }
 
@@ -80,7 +80,10 @@ void FlickrProvider::Private::pageRequestFinished( KJob *_job )
                     /* To be sure, decrement the date to two days earlier... @TODO \
*/  mActualDate = mActualDate.addDays(-2);
 
-                            KUrl url( QLatin1String( \
"http://api.flickr.com/services/rest/?api_key=a902f4e74cf1e7bce231742d8ffb46b4&method=flickr.interestingness.getList&date=" \
) + mActualDate.toString( Qt::ISODate) ); +                            QUrl \
url(QLatin1String( "https://api.flickr.com/services/rest/")); +                       \
url.addQueryItem("api_key", FLICKR_API_KEY); +                            \
url.addQueryItem("method", "flickr.interestingness.getList"); +                       \
                url.addQueryItem("date", mActualDate.toString(Qt::ISODate));
                             KIO::StoredTransferJob *pageJob = KIO::storedGet(url, \
                KIO::NoReload, KIO::HideProgressInfo);
                             mParent->connect( pageJob, SIGNAL(finished(KJob*)), \
SLOT(pageRequestFinished(KJob*)) );  return;
@@ -103,11 +106,11 @@ void FlickrProvider::Private::pageRequestFinished( KJob *_job )
     }
 
     if (m_photoList.begin() != m_photoList.end()) {
-        KUrl url( m_photoList.at(qrand() % m_photoList.size()) );
+        QUrl url( m_photoList.at(qrand() % m_photoList.size()) );
             KIO::StoredTransferJob *imageJob = KIO::storedGet(url, KIO::NoReload, \
                KIO::HideProgressInfo);
             mParent->connect( imageJob, SIGNAL(finished(KJob*)), \
SLOT(imageRequestFinished(KJob*)) );  } else {
-        kDebug() << "empty list";
+        qDebug() << "empty list";
     }
 }
 
@@ -127,9 +130,11 @@ FlickrProvider::FlickrProvider( QObject *parent, const \
QVariantList &args )  : PotdProvider( parent, args ), d( new Private( this ) )
 {
     d->mActualDate = date();
-    KUrl url(QLatin1String(
-                "http://api.flickr.com/services/rest/?api_key=a902f4e74cf1e7bce231742d8ffb46b4&method=flickr.interestingness.getList&date="
                
-                ) + date().toString( Qt::ISODate ) );
+
+    QUrl url(QLatin1String( "https://api.flickr.com/services/rest/"));
+    url.addQueryItem("api_key", FLICKR_API_KEY);
+    url.addQueryItem("method", "flickr.interestingness.getList");
+    url.addQueryItem("date", date().toString( Qt::ISODate ) );
     KIO::StoredTransferJob *job = KIO::storedGet( url, KIO::NoReload, \
                KIO::HideProgressInfo );
     connect( job, SIGNAL(finished(KJob*)), SLOT(pageRequestFinished(KJob*)) );
 }
@@ -144,3 +149,7 @@ QImage FlickrProvider::image() const
     return d->mImage;
 }
 
+K_PLUGIN_FACTORY_WITH_JSON(FlickrProviderFactory, "flickrprovider.json", \
registerPlugin<FlickrProvider>();) +
+#include "moc_flickrprovider.cpp"
+#include "flickrprovider.moc"
diff --git a/dataengines/potd/flickrprovider.h b/dataengines/potd/flickrprovider.h
index 25c8561..cdd8521 100644
--- a/dataengines/potd/flickrprovider.h
+++ b/dataengines/potd/flickrprovider.h
@@ -23,6 +23,7 @@
 #define FLICKRPROVIDER_H
 
 #include "potdprovider.h"
+#include <kio/job.h>
 
 /**
 * This class grabs a random image from the flickr
diff --git a/dataengines/potd/natgeoprovider.cpp \
b/dataengines/potd/natgeoprovider.cpp index 364d533..090cad2 100644
--- a/dataengines/potd/natgeoprovider.cpp
+++ b/dataengines/potd/natgeoprovider.cpp
@@ -24,7 +24,7 @@
 #include <QtCore/QRegExp>
 #include <QtGui/QImage>
 
-#include <KDebug>
+#include <QDebug>
 #include <KIO/Job>
 
 #include <KWebPage>
@@ -32,8 +32,6 @@
 #include <QWebElement>
 #include <QWebElementCollection>
 
-POTDPROVIDER_EXPORT_PLUGIN( NatGeoProvider, "NatGeoProvider", "" )
-
 class NatGeoProvider::Private
 {
   public:
@@ -45,7 +43,6 @@ class NatGeoProvider::Private
 
     void pageRequestFinished( bool ok );
     void imageRequestFinished( KJob* );
-    void parsePage();
 
     NatGeoProvider *mParent;
     QImage mImage;
@@ -59,20 +56,25 @@ void NatGeoProvider::Private::pageRequestFinished( bool ok )
         return;
     }
 
-    QWebElementCollection links = mPage->mainFrame()->documentElement().findAll( \
QLatin1String( "div.download_link a" ) ); +    QWebElementCollection links = \
mPage->mainFrame()->findAllElements( QLatin1String( "meta" ) );  if ( links.count() < \
1 ) {  emit mParent->error( mParent );
         return;
     }
 
-    const QString url = links.at(0).attribute( QLatin1String( "href" ) );
+    QString url;
+    for (int i = 0, e = links.count(); i < e; i++) {
+        if (links.at(i).attribute(QLatin1String("property")) == "og:image") {
+            url = links.at(i).attribute(QLatin1String("content"));
+            break;
+        }
+    }
     if (url.isEmpty()) {
         emit mParent->error( mParent );
         return;
     }
 
-
-    KIO::StoredTransferJob *imageJob = KIO::storedGet( url, KIO::NoReload, \
KIO::HideProgressInfo ); +    KIO::StoredTransferJob *imageJob = KIO::storedGet( \
                QUrl(url), KIO::NoReload, KIO::HideProgressInfo );
     mParent->connect( imageJob, SIGNAL(finished(KJob*)), \
SLOT(imageRequestFinished(KJob*)) );  }
 
@@ -91,7 +93,7 @@ void NatGeoProvider::Private::imageRequestFinished( KJob *_job )
 NatGeoProvider::NatGeoProvider( QObject *parent, const QVariantList &args )
     : PotdProvider( parent, args ), d( new Private( this ) )
 {
-    const QUrl url( QLatin1String( \
"http://photography.nationalgeographic.com/photography/photo-of-the-day" ) ); +    \
const QUrl url( QLatin1String( \
                "https://www.nationalgeographic.com/photography/photo-of-the-day" ) \
                );
     connect( d->mPage, SIGNAL(loadFinished(bool)), this, \
SLOT(pageRequestFinished(bool)) );  d->mPage->mainFrame()->setUrl( url );
 }
@@ -106,3 +108,7 @@ QImage NatGeoProvider::image() const
     return d->mImage;
 }
 
+K_PLUGIN_FACTORY_WITH_JSON(NatGeoProviderFactory, "natgeoprovider.json", \
registerPlugin<NatGeoProvider>();) +
+#include "natgeoprovider.moc"
+#include "moc_natgeoprovider.moc"
diff --git a/dataengines/potd/natgeoprovider.cpp b/dataengines/potd/noaaprovider.cpp
similarity index 57%
copy from dataengines/potd/natgeoprovider.cpp
copy to dataengines/potd/noaaprovider.cpp
index 364d533..3886695 100644
--- a/dataengines/potd/natgeoprovider.cpp
+++ b/dataengines/potd/noaaprovider.cpp
@@ -1,7 +1,6 @@
 /*
- *   Copyright 2007 Tobias Koenig <tokoe@kde.org>
- *   Copyright 2008 Anne-Marie Mahfouf <annma@kde.org>
- *   Copyright 2013 Aaron Seigo <aseigo@kde.org>
+ *   Copyright (C) 2007 Tobias Koenig <tokoe@kde.org>
+ *   Copyright  2008 by Anne-Marie Mahfouf <annma@kde.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
@@ -19,90 +18,96 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
-#include "natgeoprovider.h"
+#include "noaaprovider.h"
 
 #include <QtCore/QRegExp>
 #include <QtGui/QImage>
 
-#include <KDebug>
-#include <KIO/Job>
-
+#include <QDebug>
+#include <kio/job.h>
 #include <KWebPage>
 #include <QWebFrame>
-#include <QWebElement>
 #include <QWebElementCollection>
 
-POTDPROVIDER_EXPORT_PLUGIN( NatGeoProvider, "NatGeoProvider", "" )
-
-class NatGeoProvider::Private
+class NOAAProvider::Private
 {
   public:
-    Private( NatGeoProvider *parent )
+    Private( NOAAProvider *parent )
       : mParent( parent ),
         mPage( new KWebPage( parent, KWebPage::KIOIntegration ) )
     {
     }
 
-    void pageRequestFinished( bool ok );
+    void pageRequestFinished( bool );
     void imageRequestFinished( KJob* );
     void parsePage();
 
-    NatGeoProvider *mParent;
+    NOAAProvider *mParent;
     QImage mImage;
     KWebPage *mPage;
 };
 
-void NatGeoProvider::Private::pageRequestFinished( bool ok )
+void NOAAProvider::Private::pageRequestFinished( bool ok )
 {
     if ( !ok ) {
-        emit mParent->error( mParent );
-        return;
+	emit mParent->error( mParent );
+	return;
     }
 
-    QWebElementCollection links = mPage->mainFrame()->documentElement().findAll( \
QLatin1String( "div.download_link a" ) ); +    QWebElementCollection links = \
mPage->mainFrame()->findAllElements( QLatin1String( "script" ) );  if ( links.count() \
< 1 ) {  emit mParent->error( mParent );
         return;
     }
 
-    const QString url = links.at(0).attribute( QLatin1String( "href" ) );
+    QString url;
+    for (int i = 0, e = links.count(); i < e; i++) {
+        const auto text = links.at(i).toPlainText();
+        if (text.startsWith("_curPic = ")) {
+            url = "http://www.nnvl.noaa.gov/" + text.mid(10);
+            break;
+        }
+    }
     if (url.isEmpty()) {
         emit mParent->error( mParent );
         return;
     }
 
-
-    KIO::StoredTransferJob *imageJob = KIO::storedGet( url, KIO::NoReload, \
KIO::HideProgressInfo ); +    KIO::StoredTransferJob *imageJob = KIO::storedGet( \
                QUrl(url), KIO::NoReload, KIO::HideProgressInfo );
     mParent->connect( imageJob, SIGNAL(finished(KJob*)), \
SLOT(imageRequestFinished(KJob*)) );  }
 
-void NatGeoProvider::Private::imageRequestFinished( KJob *_job )
+void NOAAProvider::Private::imageRequestFinished( KJob *_job )
 {
     KIO::StoredTransferJob *job = static_cast<KIO::StoredTransferJob *>( _job );
     if ( job->error() ) {
-        emit mParent->error( mParent );
-        return;
+	emit mParent->error( mParent );
+	return;
     }
 
     mImage = QImage::fromData( job->data() );
     emit mParent->finished( mParent );
 }
 
-NatGeoProvider::NatGeoProvider( QObject *parent, const QVariantList &args )
+NOAAProvider::NOAAProvider( QObject *parent, const QVariantList &args )
     : PotdProvider( parent, args ), d( new Private( this ) )
 {
-    const QUrl url( QLatin1String( \
"http://photography.nationalgeographic.com/photography/photo-of-the-day" ) ); +    \
                QUrl url( QLatin1String( "http://www.nnvl.noaa.gov/imageoftheday.php" \
                ) );
     connect( d->mPage, SIGNAL(loadFinished(bool)), this, \
SLOT(pageRequestFinished(bool)) );  d->mPage->mainFrame()->setUrl( url );
 }
 
-NatGeoProvider::~NatGeoProvider()
+NOAAProvider::~NOAAProvider()
 {
     delete d;
 }
 
-QImage NatGeoProvider::image() const
+QImage NOAAProvider::image() const
 {
     return d->mImage;
 }
 
+K_PLUGIN_FACTORY_WITH_JSON(NOAAProviderFactory, "noaaprovider.json", \
registerPlugin<NOAAProvider>();) +
+#include "moc_noaaprovider.cpp"
+#include "noaaprovider.moc"
diff --git a/dataengines/potd/noaaprovider.desktop \
b/dataengines/potd/noaaprovider.desktop new file mode 100644
index 0000000..aa40142
--- /dev/null
+++ b/dataengines/potd/noaaprovider.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Type=Service
+X-KDE-ServiceTypes=PlasmaPoTD/Plugin
+X-KDE-Library=plasma_potd_noaaprovider
+X-KDE-PlasmaPoTDProvider-SuffixType=Date
+X-KDE-PlasmaPoTDProvider-Identifier=noaa
+Icon=
+
+Name=NOAA Environmental Visualization Laboratory Picture of the Day
+Comment=NOAA Provider
diff --git a/dataengines/potd/oseiprovider.h b/dataengines/potd/noaaprovider.h
similarity index 72%
rename from dataengines/potd/oseiprovider.h
rename to dataengines/potd/noaaprovider.h
index 384a76c..23e19b9 100644
--- a/dataengines/potd/oseiprovider.h
+++ b/dataengines/potd/noaaprovider.h
@@ -1,6 +1,7 @@
 /*
  *   Copyright (C) 2007 Tobias Koenig <tokoe@kde.org>
- *   Copyright  2008 by Anne-Marie Mahfouf <annma@kde.org>                 
+ *   Copyright  2008 by Anne-Marie Mahfouf <annma@kde.org>
+ *   Copyright 2016 Weng Xuetian <wengxt@gmail.com>
  *
  *   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  
@@ -18,34 +19,33 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
-#ifndef OSEIPROVIDER_H
-#define OSEIPROVIDER_H
+#ifndef NOAAPROVIDER_H
+#define NOAAPROVIDER_H
 
 #include "potdprovider.h"
 
 /**
- * This class provides the image for OSEI 
- * "Operational Significant Event Imagery"
+ * This class provides the image for NOAA Environmental Visualization Laboratory
  * Picture Of the Day
- * located at http://www.osei.noaa.gov/OSEIiod.html.
+ * located at http://www.nnvl.noaa.gov/imageoftheday.php.
  */
-class OseiProvider : public PotdProvider
+class NOAAProvider : public PotdProvider
 {
     Q_OBJECT
 
     public:
         /**
-         * Creates a new OSEI provider.
+         * Creates a new NOAA provider.
          *
          * @param date The date for which the image shall be fetched.
          * @param parent The parent object.
          */
-        OseiProvider( QObject *parent, const QVariantList &args );
+        NOAAProvider( QObject *parent, const QVariantList &args );
 
         /**
-         * Destroys the OSEI provider.
+         * Destroys the NOAA provider.
          */
-        ~OseiProvider();
+        ~NOAAProvider();
 
         /**
          * Returns the requested image.
@@ -59,7 +59,7 @@ class OseiProvider : public PotdProvider
       class Private;
       Private* const d;
 
-      Q_PRIVATE_SLOT( d, void pageRequestFinished( KJob* ) )
+      Q_PRIVATE_SLOT( d, void pageRequestFinished( bool ) )
       Q_PRIVATE_SLOT( d, void imageRequestFinished( KJob* ) )
 };
 
diff --git a/dataengines/potd/oseiprovider.cpp b/dataengines/potd/oseiprovider.cpp
deleted file mode 100644
index 6205597..0000000
--- a/dataengines/potd/oseiprovider.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- *   Copyright (C) 2007 Tobias Koenig <tokoe@kde.org>
- *   Copyright  2008 by Anne-Marie Mahfouf <annma@kde.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 2 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 Library General Public
- *   License along with this program; if not, write to the
- *   Free Software Foundation, Inc.,
- *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-#include "oseiprovider.h"
-
-#include <QtCore/QRegExp>
-#include <QtGui/QImage>
-
-#include <KDebug>
-#include <kio/job.h>
-
-POTDPROVIDER_EXPORT_PLUGIN( OseiProvider, "OseiProvider", "" )
-
-class OseiProvider::Private
-{
-  public:
-    Private( OseiProvider *parent )
-      : mParent( parent )
-    {
-    }
-
-    void pageRequestFinished( KJob* );
-    void imageRequestFinished( KJob* );
-    void parsePage();
-
-    OseiProvider *mParent;
-    QImage mImage;
-};
-
-void OseiProvider::Private::pageRequestFinished( KJob *_job )
-{
-    KIO::StoredTransferJob *job = static_cast<KIO::StoredTransferJob *>( _job );
-    if ( job->error() ) {
-	emit mParent->error( mParent );
-	return;
-    }
-    // TODO check if this location is always the one for the picture with the same \
                name
-    KUrl url( QLatin1String( "http://www.osei.noaa.gov/IOD/OSEIiod.jpg" ) );
-    KIO::StoredTransferJob *imageJob = KIO::storedGet( url, KIO::NoReload, \
                KIO::HideProgressInfo );
-    mParent->connect( imageJob, SIGNAL(finished(KJob*)), \
                SLOT(imageRequestFinished(KJob*)) );
-}
-
-void OseiProvider::Private::imageRequestFinished( KJob *_job )
-{
-    KIO::StoredTransferJob *job = static_cast<KIO::StoredTransferJob *>( _job );
-    if ( job->error() ) {
-	emit mParent->error( mParent );
-	return;
-    }
-
-    mImage = QImage::fromData( job->data() );
-    emit mParent->finished( mParent );
-}
-
-OseiProvider::OseiProvider( QObject *parent, const QVariantList &args )
-    : PotdProvider( parent, args ), d( new Private( this ) )
-{
-    KUrl url( QLatin1String( "http://www.osei.noaa.gov/OSEIiod.html" ) );
-    KIO::StoredTransferJob *job = KIO::storedGet( url, KIO::NoReload, \
                KIO::HideProgressInfo );
-    connect( job, SIGNAL(finished(KJob*)), SLOT(pageRequestFinished(KJob*)) );
-}
-
-OseiProvider::~OseiProvider()
-{
-    delete d;
-}
-
-QImage OseiProvider::image() const
-{
-    return d->mImage;
-}
-
diff --git a/dataengines/potd/oseiprovider.desktop \
b/dataengines/potd/oseiprovider.desktop deleted file mode 100644
index 4a10c8f..0000000
--- a/dataengines/potd/oseiprovider.desktop
+++ /dev/null
@@ -1,100 +0,0 @@
-[Desktop Entry]
-Type=Service
-X-KDE-ServiceTypes=PlasmaPoTD/Plugin
-X-KDE-Library=plasma_potd_oseiprovider
-X-KDE-PlasmaPoTDProvider-SuffixType=Date
-X-KDE-PlasmaPoTDProvider-Identifier=osei
-Icon=
-
-Name=Operational Significant Event Imagery Picture of the Day
-Name[bs]=Slika dana operacijskog značajnog Događaja
-Name[ca]=Imatge operacional d'esdeveniment rellevant del dia
-Name[ca@valencia]=Imatge operacional d'esdeveniment rellevant del dia
-Name[cs]=Obrázek dne z Operational Significant Event Imagery
-Name[da]=Dagens billede fra Operational Significant Event Imagery
-Name[de]=Bild des Tages der Operational Significant Event Imagery
-Name[el]=Operational Significant Event Imagery φωτογραφία της \
                ημέρας
-Name[en_GB]=Operational Significant Event Imagery Picture of the Day
-Name[es]=Imagen de OSEI (acontecimientos significativos) del día
-Name[et]=Tähtsündmuse päevapilt
-Name[fi]=Operational Significant Event Imagery – päivän kuva
-Name[fr]=Image opérationnelle d'un évènement significatif du jour
-Name[ga]=Grianghraf an Lae ó OSEI
-Name[gl]=Imaxe do día de Operational Significant Event Imagery
-Name[hr]=Slika dana na Operational Significant Event Imagery
-Name[hu]=A nap képe az Operational Significant Event Imagery-n
-Name[it]=Operational Significant Event Imagery Picture of the Day
-Name[kk]=Operational Significant Event Imagery (Osei) "Тәулік суреті"
-Name[km]=រូប​ភាព​សមើល​ស្រមៃព្រឹត្ត \
ការណ៍ដ៏មាន​សារៈសំខាន់​នៃប្រតិបត្តិ​ការណ៍នៃថ្ងៃ
                
-Name[ko]=오늘의 중요한 사건 그림
-Name[lt]=Dienos paveikslėlis apie reikšmingą įvykį
-Name[lv]=Operational Significant Event Imagery dienas attēls
-Name[mr]=ऑपरेशनल सिग्निफिकंट \
                इव्हेन्ट इमेजरी दिवसाचे \
                चित्र
-Name[nb]=Dagens bilde om betydelige miljøhendelser
-Name[nds]=Operational Significant Event Imagery (OSEI)-Bild för Vundaag
-Name[nl]=Afbeelding van de dag uit de operationele belangrijke \
                gebeurtenissen-bedenksels
-Name[nn]=Dagens viktige miljøhending-bilete
-Name[pl]=Obraz dnia Operational Significant Event Imagery
-Name[pt]=Imagem do Dia para Eventos Operacionais Significativos
-Name[pt_BR]=Imagem do dia para eventos operacionais significativos
-Name[ru]=Значимые события: Изображение Дня
-Name[sk]=Obrázok dňa z Operational Significant Event Imagery
-Name[sl]=Slika dneva z Operational Significant Event Imagery
-Name[sr]=ОСЕИ‑јева слика дана
-Name[sr@ijekavian]=ОСЕИ‑јева слика дана
-Name[sr@ijekavianlatin]=OSEI‑jeva slika dana
-Name[sr@latin]=OSEI‑jeva slika dana
-Name[sv]=Dagens bild av operationellt signifikant händelse
-Name[tr]=Anlamlı İşlemsel Olayla İlgili Günün Resmi
-Name[uk]=Зображення дня Operational Significant Event Imagery
-Name[x-test]=xxOperational Significant Event Imagery Picture of the Dayxx
-Name[zh_CN]=每日一图(人类环境重大事件图集)
-Name[zh_TW]=本日 Operational Significant Event Imagery 圖片
-Comment=Osei Provider
-Comment[ar]=المزود Osei
-Comment[bs]=Osei dobavljač
-Comment[ca]=Proveïdor Osei
-Comment[ca@valencia]=Proveïdor Osei
-Comment[cs]=Poskytovatel Osei
-Comment[da]=Osei-udbyder.
-Comment[de]=Osei-Anbieter
-Comment[el]= άροχος Osei
-Comment[en_GB]=Osei Provider
-Comment[es]=Proveedor de Osei
-Comment[et]=Osei pakkuja
-Comment[fi]=Osei-tarjoaja
-Comment[fr]=Fournisseur    OSEI   
-Comment[ga]=Soláthraí OSEI
-Comment[gl]=Fornecedor de Osei
-Comment[hr]=Pružatelj Oseia
-Comment[hu]=Apod-szolgáltató
-Comment[is]=Osei þjónusta
-Comment[it]=Fornitore Osei
-Comment[ja]=Osei のプロバイダ
-Comment[kk]=Osei таратушысы
-Comment[km]=ក្រុម ៊ុន​ផ្ដល់ Osei
-Comment[ko]=OSEI 공급자
-Comment[lt]=Osei tiekėjas
-Comment[lv]=Osei piegādātājs
-Comment[mr]=ओसेइ पुरवि ाकर्ता
-Comment[nb]=Osei-leverandør
-Comment[nds]=Osei-Anbeder
-Comment[nl]=Osei-provider
-Comment[nn]=Osei-tilbydar
-Comment[pl]=Usługodawca Osei
-Comment[pt]=Fornecedor do Osei
-Comment[pt_BR]=Fornecedor Osei
-Comment[ro]=Furnizor Osei
-Comment[ru]=Источник данных Osei
-Comment[sk]=Poskytovateľ Osei
-Comment[sl]=Ponudnik Osei
-Comment[sr]=Добављач ОСЕИ‑ја
-Comment[sr@ijekavian]=Добављач ОСЕИ‑ја
-Comment[sr@ijekavianlatin]=Dobavljač OSEI‑ja
-Comment[sr@latin]=Dobavljač OSEI‑ja
-Comment[sv]=Tillhandahåll från Osei
-Comment[tr]=Osei Sağlayıcı
-Comment[uk]=Постачальник даних Osei
-Comment[x-test]=xxOsei Providerxx
-Comment[zh_CN]=Osei 提供方
-Comment[zh_TW]=Osei 提供者
diff --git a/dataengines/potd/plasma_potd_export.h \
b/dataengines/potd/plasma_potd_export.h deleted file mode 100644
index d850463..0000000
--- a/dataengines/potd/plasma_potd_export.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *   Copyright (C) 2007 Tobias Koenig <tokoe@kde.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 2 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 Library General Public
- *   License along with this program; if not, write to the
- *   Free Software Foundation, Inc.,
- *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-#ifndef PLASMA_POTD_EXPORT_H
-#define PLASMA_POTD_EXPORT_H
-
-/* needed for KDE_EXPORT macros */
-#include <kdemacros.h>
-
-#if defined Q_OS_WIN
-#ifndef PLASMA_POTD_EXPORT
-# ifdef MAKE_PLASMAPOTDPROVIDERCORE_LIB
-#  define PLASMA_POTD_EXPORT KDE_EXPORT
-# else
-#  define PLASMA_POTD_EXPORT KDE_IMPORT
-# endif
-#endif
-
-#else /* UNIX*/
-
-/* export statements for unix */
-#define PLASMA_POTD_EXPORT KDE_EXPORT
-#endif
-
-#endif
diff --git a/dataengines/potd/potd.cpp b/dataengines/potd/potd.cpp
index 4e6dd14..77cb323 100644
--- a/dataengines/potd/potd.cpp
+++ b/dataengines/potd/potd.cpp
@@ -25,13 +25,13 @@
 #include <QtCore/QTimer>
 #include <QtCore/QThreadPool>
 
-#include <KDebug>
-#include <KServiceTypeTrader>
+#include <QDebug>
+#include <KPluginLoader>
+#include <KPluginMetaData>
 
 #include <Plasma/DataContainer>
 
 #include "cachedprovider.h"
-#include "kstandarddirs.h"
 
 PotdEngine::PotdEngine( QObject* parent, const QVariantList& args )
     : Plasma::DataEngine( parent, args )
@@ -45,20 +45,23 @@ PotdEngine::PotdEngine( QObject* parent, const QVariantList& args \
)  // every 2 seconds (!)
     m_checkDatesTimer->setInterval( 10 * 60 * 1000 ); // check every 10 minutes
     m_checkDatesTimer->start();
-}
 
-PotdEngine::~PotdEngine()
-{
+    const QVector<KPluginMetaData> plugins = \
KPluginLoader::findPlugins(QStringLiteral("potd"), [](const KPluginMetaData & md) { + \
return md.serviceTypes().contains(QStringLiteral("PlasmaPoTD/Plugin")); +    });
+
+    for (const auto &metadata : plugins) {
+        QString provider = metadata.value(QLatin1String( \
"X-KDE-PlasmaPoTDProvider-Identifier" )); +        if (provider.isEmpty()) {
+            continue;
+        }
+        mFactories.insert(provider, metadata);
+        setData( QLatin1String( "Providers" ), provider, metadata.name() );
+    }
 }
 
-void PotdEngine::init()
+PotdEngine::~PotdEngine()
 {
-    KService::List services = KServiceTypeTrader::self()->query(QLatin1String( \
                "PlasmaPoTD/Plugin" ));
-    Q_FOREACH ( const KService::Ptr &service, services ) {
-        QString provider = service->property(QLatin1String( \
                "X-KDE-PlasmaPoTDProvider-Identifier" ), \
                QVariant::String).toString();
-        mFactories.insert(provider, service);
-        setData( QLatin1String( "Providers" ), provider, service->name() );
-    }
 }
 
 bool PotdEngine::updateSourceEvent( const QString &identifier )
@@ -84,9 +87,13 @@ bool PotdEngine::updateSource( const QString &identifier, bool \
loadCachedAlways  }
 
     const QStringList parts = identifier.split( QLatin1Char( ':' ), \
QString::SkipEmptyParts ); +    if (parts.empty()) {
+        qDebug() << "invalid identifier";
+        return false;
+    }
     const QString providerName = parts[ 0 ];
     if ( !mFactories.contains( providerName ) ) {
-        kDebug() << "invalid provider: " << parts[ 0 ];
+        qDebug() << "invalid provider: " << parts[ 0 ];
         return false;
     }
 
@@ -95,14 +102,18 @@ bool PotdEngine::updateSource( const QString &identifier, bool \
loadCachedAlways  if ( parts.count() > 1 ) {
         const QDate date = QDate::fromString( parts[ 1 ], Qt::ISODate );
         if ( !date.isValid() ) {
-            kDebug() << "invalid date:" << parts[1];
+            qDebug() << "invalid date:" << parts[1];
             return false;
         }
 
         args << date;
     }
 
-    PotdProvider *provider = qobject_cast<PotdProvider*>( mFactories[ providerName \
]->createInstance<QObject>( this, args ) ); +    auto factory = \
KPluginLoader(mFactories[ providerName ].fileName()).factory(); +    PotdProvider \
*provider = nullptr; +    if (factory) {
+        provider = factory->create<PotdProvider>(this, args);
+    }
     if (provider) {
         connect( provider, SIGNAL(finished(PotdProvider*)), this, \
                SLOT(finished(PotdProvider*)) );
         connect( provider, SIGNAL(error(PotdProvider*)), this, \
SLOT(error(PotdProvider*)) ); @@ -183,4 +194,6 @@ void PotdEngine::checkDayChanged()
     }
 }
 
+K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(potdengine, PotdEngine, \
"plasma-dataengine-potd.json")  
+#include "potd.moc"
diff --git a/dataengines/potd/potd.h b/dataengines/potd/potd.h
index 3ff774c..46325bc 100644
--- a/dataengines/potd/potd.h
+++ b/dataengines/potd/potd.h
@@ -20,7 +20,8 @@
 #ifndef POTD_DATAENGINE_H
 #define POTD_DATAENGINE_H
 
-#include "plasma/dataengine.h"
+#include <Plasma/DataEngine>
+#include <KPluginMetaData>
 
 class PotdProvider;
 
@@ -44,7 +45,6 @@ class PotdEngine : public Plasma::DataEngine
         ~PotdEngine();
 
     protected:
-        void init();
         bool sourceRequestEvent( const QString &identifier );
 
     protected Q_SLOTS:
@@ -59,11 +59,9 @@ class PotdEngine : public Plasma::DataEngine
     private:
         bool updateSource( const QString &identifier, bool loadCachedAlways );
 
-        QMap<QString, KService::Ptr> mFactories;
+        QMap<QString, KPluginMetaData> mFactories;
         QTimer *m_checkDatesTimer;
         bool m_canDiscardCache;
 };
 
-K_EXPORT_PLASMA_DATAENGINE(potd, PotdEngine)
-
 #endif
diff --git a/dataengines/potd/potdprovider.h b/dataengines/potd/potdprovider.h
index 3f4d308..6578c45 100644
--- a/dataengines/potd/potdprovider.h
+++ b/dataengines/potd/potdprovider.h
@@ -23,16 +23,12 @@
 #include <QtCore/QObject>
 #include <QtCore/QDate>
 
-#include <kpluginfactory.h>
+#include <KPluginFactory>
 
 #include "plasma_potd_export.h"
 
 class QImage;
 
-#define POTDPROVIDER_EXPORT_PLUGIN( classname, componentName, catalogName ) \
-    K_PLUGIN_FACTORY( classname ## Factory, registerPlugin< classname >(); ) \
-    K_EXPORT_PLUGIN( classname ## Factory( componentName, catalogName ) )
-
 /**
  * This class is an interface for PoTD providers.
  */
diff --git a/dataengines/potd/wcpotdprovider.cpp \
b/dataengines/potd/wcpotdprovider.cpp index c38afcc..63258f8 100644
--- a/dataengines/potd/wcpotdprovider.cpp
+++ b/dataengines/potd/wcpotdprovider.cpp
@@ -1,6 +1,7 @@
 /*
  *   Copyright (C) 2007 Tobias Koenig <tokoe@kde.org>
  *   Copyright  2008 by Anne-Marie Mahfouf <annma@kde.org>
+ *   Copyright 2016 Weng Xuetian <wengxt@gmail.com>
  *
  *   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
@@ -23,11 +24,9 @@
 #include <QtCore/QRegExp>
 #include <QtGui/QImage>
 
-#include <KDebug>
+#include <QDebug>
 #include <kio/job.h>
 
-POTDPROVIDER_EXPORT_PLUGIN( WcpotdProvider, "WcpotdProvider", "" )
-
 class WcpotdProvider::Private
 {
   public:
@@ -52,7 +51,7 @@ void WcpotdProvider::Private::pageRequestFinished( KJob *_job )
 	return;
     }
 
-    KUrl picUrl( QLatin1String( \
"http://tools.wikimedia.de/~daniel/potd/potd.php/commons/800x600" ) );  \
KIO::StoredTransferJob *imageJob = KIO::storedGet( picUrl, KIO::NoReload, \
KIO::HideProgressInfo ); +    QUrl picUrl( QLatin1String( \
"https://tools.wmflabs.org/potd-feed/potd.php/commons/full" ) );  \
KIO::StoredTransferJob *imageJob = KIO::storedGet( picUrl, KIO::NoReload, \
                KIO::HideProgressInfo );
     mParent->connect( imageJob, SIGNAL(finished(KJob*)), \
SLOT(imageRequestFinished(KJob*)) );  }
 
@@ -71,7 +70,7 @@ void WcpotdProvider::Private::imageRequestFinished( KJob *_job )
 WcpotdProvider::WcpotdProvider( QObject *parent, const QVariantList &args )
     : PotdProvider( parent, args ), d( new Private( this ) )
 {
-    KUrl url( QLatin1String( \
"http://tools.wikimedia.de/~daniel/potd/potd.php/commons/800x600" )); +    QUrl url( \
QLatin1String( "https://tools.wmflabs.org/potd-feed/potd.php/commons/full" ));  
     KIO::StoredTransferJob *job = KIO::storedGet( url, KIO::NoReload, \
                KIO::HideProgressInfo );
     connect( job, SIGNAL(finished(KJob*)), SLOT(pageRequestFinished(KJob*)) );
@@ -87,3 +86,7 @@ QImage WcpotdProvider::image() const
     return d->mImage;
 }
 
+K_PLUGIN_FACTORY_WITH_JSON(WcpotdProviderFactory, "wcpotdprovider.json", \
registerPlugin<WcpotdProvider>();) +
+#include "wcpotdprovider.moc"
+#include "moc_wcpotdprovider.cpp"
diff --git a/wallpapers/CMakeLists.txt b/wallpapers/CMakeLists.txt
index efcb68a..98ebfdd 100644
--- a/wallpapers/CMakeLists.txt
+++ b/wallpapers/CMakeLists.txt
@@ -4,3 +4,4 @@
 # plasma_install_package(animals org.kde.animals wallpapers wallpaper)
 plasma_install_package(haenau org.kde.haenau wallpapers wallpaper)
 plasma_install_package(hunyango org.kde.hunyango wallpapers wallpaper)
+plasma_install_package(potd org.kde.potd wallpapers wallpaper)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic