From kde-commits Tue Nov 15 19:19:48 2016 From: Weng Xuetian Date: Tue, 15 Nov 2016 19:19:48 +0000 To: kde-commits Subject: [kdeplasma-addons] /: Port potd (picture of the day) dataengine to KF5. Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=147923759902127 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/na= tgeoprovider.cpp - 057% similarity] A +10 -0 dataengines/potd/noaaprovider.desktop R +12 -12 dataengines/potd/noaaprovider.h [from: dataengines/potd/osei= provider.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/30c8cd5bb57dab0e4d49dc76354f912aef0= 2fc7e 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 Quic= k Qml Widgets X11Extras) = find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS - Activities Config ConfigWidgets CoreAddons I18n KIO KCMUtils Plasma Ru= nner Service UnitConversion KDELibs4Support NewStuff Kross) + Activities Config ConfigWidgets CoreAddons I18n KIO KCMUtils Plasma Ru= nner 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_KDE= UI_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.desk= top SERVICE_TYPES plasma-dataengine.desktop) = -install(TARGETS plasma_engine_potd DESTINATION ${PLUGIN_INSTALL_DIR} ) +install(TARGETS plasma_engine_potd DESTINATION ${PLUGIN_INSTALL_DIR}/plasm= a/dataengine ) install(FILES plasma-dataengine-potd.desktop DESTINATION ${SERVICES_INSTAL= L_DIR} ) = = @@ -14,15 +19,15 @@ install(FILES plasma-dataengine-potd.desktop DESTINATIO= N ${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 SOV= ERSION 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_INST= ALL_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_D= IR} ) -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 K= F5::KIOCore KF5::CoreAddons) = +kcoreaddons_desktop_to_json(plasma_potd_flickrprovider flickrprovider.desk= top SERVICE_TYPES ${CMAKE_CURRENT_SOURCE_DIR}/plasma_potdprovider.desktop) + +install( TARGETS plasma_potd_flickrprovider DESTINATION ${PLUGIN_INSTALL_D= IR}/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 ${K= DE4_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_L= IBRARY}) -install( TARGETS plasma_potd_natgeoprovider DESTINATION ${PLUGIN_INSTALL_D= IR} ) -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 K= F5::KIOCore KF5::WebKit) = +kcoreaddons_desktop_to_json(plasma_potd_natgeoprovider natgeoprovider.desk= top SERVICE_TYPES ${CMAKE_CURRENT_SOURCE_DIR}/plasma_potdprovider.desktop) + +install( TARGETS plasma_potd_natgeoprovider DESTINATION ${PLUGIN_INSTALL_D= IR}/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 ${K= DE4_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 ${K= DE4_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_D= IR} ) -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 K= F5::KIOCore ) + +kcoreaddons_desktop_to_json(plasma_potd_wcpotdprovider wcpotdprovider.desk= top SERVICE_TYPES ${CMAKE_CURRENT_SOURCE_DIR}/plasma_potdprovider.desktop) + +install( TARGETS plasma_potd_wcpotdprovider DESTINATION ${PLUGIN_INSTALL_D= IR}/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/apodprovi= der.cpp index 8271613..fdca54a 100644 --- a/dataengines/potd/apodprovider.cpp +++ b/dataengines/potd/apodprovider.cpp @@ -23,11 +23,9 @@ #include #include = -#include +#include #include = -POTDPROVIDER_EXPORT_PLUGIN( ApodProvider, "ApodProvider", "" ) - class ApodProvider::Private { public: @@ -59,7 +57,7 @@ void ApodProvider::Private::pageRequestFinished( KJob *_j= ob ) exp.setMinimal( true ); if ( exp.indexIn( data ) !=3D -1 ) { const QString sub =3D exp.cap(1); - KUrl url( QString( QLatin1String( "http://antwrp.gsfc.nasa.gov/apo= d/%1" ) ).arg( sub ) ); + QUrl url( QString( QLatin1String( "http://antwrp.gsfc.nasa.gov/apo= d/%1" ) ).arg( sub ) ); KIO::StoredTransferJob *imageJob =3D KIO::storedGet( url, KIO::NoR= eload, KIO::HideProgressInfo ); mParent->connect( imageJob, SIGNAL(finished(KJob*)), SLOT(imageReq= uestFinished(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 =3D KIO::storedGet( url, KIO::NoReload, KI= O::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", regis= terPlugin();) + +#include "moc_apodprovider.cpp" +#include "apodprovider.moc" diff --git a/dataengines/potd/cachedprovider.cpp b/dataengines/potd/cachedp= rovider.cpp index 869c4c9..520c53e 100644 --- a/dataengines/potd/cachedprovider.cpp +++ b/dataengines/potd/cachedprovider.cpp @@ -23,11 +23,11 @@ #include #include #include +#include +#include #include = -#include - -#include +#include = LoadImageThread::LoadImageThread(const QString &filePath) : m_filePath(filePath) @@ -56,7 +56,9 @@ void SaveImageThread::run() = QString CachedProvider::identifierToPath( const QString &identifier ) { - const QString dataDir =3D KStandardDirs::locateLocal( "cache", QLatin1= String("plasma_engine_podt/") ); + const QString dataDir =3D QStandardPaths::writableLocation(QStandardPa= ths::CacheLocation) + QLatin1String("/plasma_engine_potd/"); + QDir d; + d.mkpath(dataDir); return QString( dataDir + identifier ); } = diff --git a/dataengines/potd/epodprovider.cpp b/dataengines/potd/epodprovi= der.cpp index b3f44fd..6343ec9 100644 --- a/dataengines/potd/epodprovider.cpp +++ b/dataengines/potd/epodprovider.cpp @@ -23,11 +23,9 @@ #include #include = -#include +#include #include = -POTDPROVIDER_EXPORT_PLUGIN( EpodProvider, "EpodProvider", "" ) - class EpodProvider::Private { public: @@ -60,7 +58,7 @@ void EpodProvider::Private::pageRequestFinished(KJob *_jo= b) = int pos =3D exp.indexIn( data ) + pattern.length(); const QString sub =3D data.mid( pos-4, pattern.length()+6); - KUrl url( QString(QLatin1String( "http://epod.usra.edu/.a/%1-pi" )) .a= rg(sub) ); + QUrl url( QString(QLatin1String( "http://epod.usra.edu/.a/%1-pi" )) .a= rg(sub) ); KIO::StoredTransferJob *imageJob =3D KIO::storedGet( url, KIO::NoReloa= d, KIO::HideProgressInfo ); QObject::connect(imageJob, SIGNAL(finished(KJob*)), mParent, SLOT(imag= eRequestFinished(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 =3D KIO::storedGet( url, KIO::NoReload, KI= O::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", regis= terPlugin();) + +#include "moc_epodprovider.cpp" +#include "epodprovider.moc" diff --git a/dataengines/potd/flickrprovider.cpp b/dataengines/potd/flickrp= rovider.cpp index c7eb249..6a05fa1 100644 --- a/dataengines/potd/flickrprovider.cpp +++ b/dataengines/potd/flickrprovider.cpp @@ -25,10 +25,10 @@ #include #include = -#include +#include #include = -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 =3D static_cast(= _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 =3D mActualDate.addDays(-2); = - KUrl url( QLatin1String( "http://api.flickr.co= m/services/rest/?api_key=3Da902f4e74cf1e7bce231742d8ffb46b4&method=3Dflickr= .interestingness.getList&date=3D" ) + mActualDate.toString( Qt::ISODate) ); + QUrl url(QLatin1String( "https://api.flickr.co= m/services/rest/")); + url.addQueryItem("api_key", FLICKR_API_KEY); + url.addQueryItem("method", "flickr.interesting= ness.getList"); + url.addQueryItem("date", mActualDate.toString(= Qt::ISODate)); KIO::StoredTransferJob *pageJob =3D KIO::store= dGet(url, KIO::NoReload, KIO::HideProgressInfo); mParent->connect( pageJob, SIGNAL(finished(KJo= b*)), SLOT(pageRequestFinished(KJob*)) ); return; @@ -103,11 +106,11 @@ void FlickrProvider::Private::pageRequestFinished( KJ= ob *_job ) } = if (m_photoList.begin() !=3D m_photoList.end()) { - KUrl url( m_photoList.at(qrand() % m_photoList.size()) ); + QUrl url( m_photoList.at(qrand() % m_photoList.size()) ); KIO::StoredTransferJob *imageJob =3D KIO::storedGet(url, KIO::= NoReload, KIO::HideProgressInfo); mParent->connect( imageJob, SIGNAL(finished(KJob*)), SLOT(imag= eRequestFinished(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 =3D date(); - KUrl url(QLatin1String( - "http://api.flickr.com/services/rest/?api_key=3Da902f4e74c= f1e7bce231742d8ffb46b4&method=3Dflickr.interestingness.getList&date=3D" - ) + 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 =3D KIO::storedGet( url, KIO::NoReload, KI= O::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", r= egisterPlugin();) + +#include "moc_flickrprovider.cpp" +#include "flickrprovider.moc" diff --git a/dataengines/potd/flickrprovider.h b/dataengines/potd/flickrpro= vider.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 = /** * This class grabs a random image from the flickr diff --git a/dataengines/potd/natgeoprovider.cpp b/dataengines/potd/natgeop= rovider.cpp index 364d533..090cad2 100644 --- a/dataengines/potd/natgeoprovider.cpp +++ b/dataengines/potd/natgeoprovider.cpp @@ -24,7 +24,7 @@ #include #include = -#include +#include #include = #include @@ -32,8 +32,6 @@ #include #include = -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 =3D mPage->mainFrame()->documentElement().= findAll( QLatin1String( "div.download_link a" ) ); + QWebElementCollection links =3D mPage->mainFrame()->findAllElements( Q= Latin1String( "meta" ) ); if ( links.count() < 1 ) { emit mParent->error( mParent ); return; } = - const QString url =3D links.at(0).attribute( QLatin1String( "href" ) ); + QString url; + for (int i =3D 0, e =3D links.count(); i < e; i++) { + if (links.at(i).attribute(QLatin1String("property")) =3D=3D "og:im= age") { + url =3D links.at(i).attribute(QLatin1String("content")); + break; + } + } if (url.isEmpty()) { emit mParent->error( mParent ); return; } = - - KIO::StoredTransferJob *imageJob =3D KIO::storedGet( url, KIO::NoReloa= d, KIO::HideProgressInfo ); + KIO::StoredTransferJob *imageJob =3D KIO::storedGet( QUrl(url), KIO::N= oReload, KIO::HideProgressInfo ); mParent->connect( imageJob, SIGNAL(finished(KJob*)), SLOT(imageRequest= Finished(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/pho= tography/photo-of-the-day" ) ); connect( d->mPage, SIGNAL(loadFinished(bool)), this, SLOT(pageRequestF= inished(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", r= egisterPlugin();) + +#include "natgeoprovider.moc" +#include "moc_natgeoprovider.moc" diff --git a/dataengines/potd/natgeoprovider.cpp b/dataengines/potd/noaapro= vider.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 - * Copyright 2008 Anne-Marie Mahfouf - * Copyright 2013 Aaron Seigo + * Copyright (C) 2007 Tobias Koenig + * Copyright 2008 by Anne-Marie Mahfouf * * 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 #include = -#include -#include - +#include +#include #include #include -#include #include = -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 =3D mPage->mainFrame()->documentElement().= findAll( QLatin1String( "div.download_link a" ) ); + QWebElementCollection links =3D mPage->mainFrame()->findAllElements( Q= Latin1String( "script" ) ); if ( links.count() < 1 ) { emit mParent->error( mParent ); return; } = - const QString url =3D links.at(0).attribute( QLatin1String( "href" ) ); + QString url; + for (int i =3D 0, e =3D links.count(); i < e; i++) { + const auto text =3D links.at(i).toPlainText(); + if (text.startsWith("_curPic =3D ")) { + url =3D "http://www.nnvl.noaa.gov/" + text.mid(10); + break; + } + } if (url.isEmpty()) { emit mParent->error( mParent ); return; } = - - KIO::StoredTransferJob *imageJob =3D KIO::storedGet( url, KIO::NoReloa= d, KIO::HideProgressInfo ); + KIO::StoredTransferJob *imageJob =3D KIO::storedGet( QUrl(url), KIO::N= oReload, KIO::HideProgressInfo ); mParent->connect( imageJob, SIGNAL(finished(KJob*)), SLOT(imageRequest= Finished(KJob*)) ); } = -void NatGeoProvider::Private::imageRequestFinished( KJob *_job ) +void NOAAProvider::Private::imageRequestFinished( KJob *_job ) { KIO::StoredTransferJob *job =3D static_cast(= _job ); if ( job->error() ) { - emit mParent->error( mParent ); - return; + emit mParent->error( mParent ); + return; } = mImage =3D 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(pageRequestF= inished(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", regis= terPlugin();) + +#include "moc_noaaprovider.cpp" +#include "noaaprovider.moc" diff --git a/dataengines/potd/noaaprovider.desktop b/dataengines/potd/noaap= rovider.desktop new file mode 100644 index 0000000..aa40142 --- /dev/null +++ b/dataengines/potd/noaaprovider.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=3DService +X-KDE-ServiceTypes=3DPlasmaPoTD/Plugin +X-KDE-Library=3Dplasma_potd_noaaprovider +X-KDE-PlasmaPoTDProvider-SuffixType=3DDate +X-KDE-PlasmaPoTDProvider-Identifier=3Dnoaa +Icon=3D + +Name=3DNOAA Environmental Visualization Laboratory Picture of the Day +Comment=3DNOAA Provider diff --git a/dataengines/potd/oseiprovider.h b/dataengines/potd/noaaprovide= r.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 - * Copyright 2008 by Anne-Marie Mahfouf = + * Copyright 2008 by Anne-Marie Mahfouf + * Copyright 2016 Weng Xuetian * * 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 Labo= ratory * 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/oseiprovi= der.cpp deleted file mode 100644 index 6205597..0000000 --- a/dataengines/potd/oseiprovider.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2007 Tobias Koenig - * Copyright 2008 by Anne-Marie Mahfouf - * - * 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 -#include - -#include -#include - -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 =3D static_cast(= _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 =3D KIO::storedGet( url, KIO::NoReloa= d, KIO::HideProgressInfo ); - mParent->connect( imageJob, SIGNAL(finished(KJob*)), SLOT(imageRequest= Finished(KJob*)) ); -} - -void OseiProvider::Private::imageRequestFinished( KJob *_job ) -{ - KIO::StoredTransferJob *job =3D static_cast(= _job ); - if ( job->error() ) { - emit mParent->error( mParent ); - return; - } - - mImage =3D 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 =3D KIO::storedGet( url, KIO::NoReload, KI= O::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/oseip= rovider.desktop deleted file mode 100644 index 4a10c8f..0000000 --- a/dataengines/potd/oseiprovider.desktop +++ /dev/null @@ -1,100 +0,0 @@ -[Desktop Entry] -Type=3DService -X-KDE-ServiceTypes=3DPlasmaPoTD/Plugin -X-KDE-Library=3Dplasma_potd_oseiprovider -X-KDE-PlasmaPoTDProvider-SuffixType=3DDate -X-KDE-PlasmaPoTDProvider-Identifier=3Dosei -Icon=3D - -Name=3DOperational Significant Event Imagery Picture of the Day -Name[bs]=3DSlika dana operacijskog zna=C4=8Dajnog Doga=C4=91aja -Name[ca]=3DImatge operacional d'esdeveniment rellevant del dia -Name[ca@valencia]=3DImatge operacional d'esdeveniment rellevant del dia -Name[cs]=3DObr=C3=A1zek dne z Operational Significant Event Imagery -Name[da]=3DDagens billede fra Operational Significant Event Imagery -Name[de]=3DBild des Tages der Operational Significant Event Imagery -Name[el]=3DOperational Significant Event Imagery =CF=86=CF=89=CF=84=CE=BF= =CE=B3=CF=81=CE=B1=CF=86=CE=AF=CE=B1 =CF=84=CE=B7=CF=82 =CE=B7=CE=BC=CE=AD= =CF=81=CE=B1=CF=82 -Name[en_GB]=3DOperational Significant Event Imagery Picture of the Day -Name[es]=3DImagen de OSEI (acontecimientos significativos) del d=C3=ADa -Name[et]=3DT=C3=A4hts=C3=BCndmuse p=C3=A4evapilt -Name[fi]=3DOperational Significant Event Imagery =E2=80=93 p=C3=A4iv=C3=A4= n kuva -Name[fr]=3DImage op=C3=A9rationnelle d'un =C3=A9v=C3=A8nement significatif= du jour -Name[ga]=3DGrianghraf an Lae =C3=B3 OSEI -Name[gl]=3DImaxe do d=C3=ADa de Operational Significant Event Imagery -Name[hr]=3DSlika dana na Operational Significant Event Imagery -Name[hu]=3DA nap k=C3=A9pe az Operational Significant Event Imagery-n -Name[it]=3DOperational Significant Event Imagery Picture of the Day -Name[kk]=3DOperational Significant Event Imagery (Osei) "=D0=A2=D3=99=D1= =83=D0=BB=D1=96=D0=BA =D1=81=D1=83=D1=80=D0=B5=D1=82=D1=96" -Name[km]=3D=E1=9E=9A=E1=9E=BC=E1=9E=94=E2=80=8B=E1=9E=97=E1=9E=B6=E1=9E=96= =E2=80=8B=E1=9E=9F=E1=9E=98=E1=9E=BE=E1=9E=9B=E2=80=8B=E1=9E=9F=E1=9F=92=E1= =9E=9A=E1=9E=98=E1=9F=83=E1=9E=96=E1=9F=92=E1=9E=9A=E1=9E=B9=E1=9E=8F=E1=9F= =92=E1=9E=8F=E1=9E=B7=E1=9E=80=E1=9E=B6=E1=9E=9A=E1=9E=8E=E1=9F=8D=E1=9E=8A= =E1=9F=8F=E1=9E=98=E1=9E=B6=E1=9E=93=E2=80=8B=E1=9E=9F=E1=9E=B6=E1=9E=9A=E1= =9F=88=E1=9E=9F=E1=9F=86=E1=9E=81=E1=9E=B6=E1=9E=93=E1=9F=8B=E2=80=8B=E1=9E= =93=E1=9F=83=E1=9E=94=E1=9F=92=E1=9E=9A=E1=9E=8F=E1=9E=B7=E1=9E=94=E1=9E=8F= =E1=9F=92=E1=9E=8F=E1=9E=B7=E2=80=8B=E1=9E=80=E1=9E=B6=E1=9E=9A=E1=9E=8E=E1= =9F=8D=E1=9E=93=E1=9F=83=E1=9E=90=E1=9F=92=E1=9E=84=E1=9F=83 -Name[ko]=3D=EC=98=A4=EB=8A=98=EC=9D=98 =EC=A4=91=EC=9A=94=ED=95=9C =EC=82= =AC=EA=B1=B4 =EA=B7=B8=EB=A6=BC -Name[lt]=3DDienos paveiksl=C4=97lis apie reik=C5=A1ming=C4=85 =C4=AFvyk=C4= =AF -Name[lv]=3DOperational Significant Event Imagery dienas att=C4=93ls -Name[mr]=3D=E0=A4=91=E0=A4=AA=E0=A4=B0=E0=A5=87=E0=A4=B6=E0=A4=A8=E0=A4=B2= =E0=A4=B8=E0=A4=BF=E0=A4=97=E0=A5=8D=E0=A4=A8=E0=A4=BF=E0=A4=AB=E0=A4=BF= =E0=A4=95=E0=A4=82=E0=A4=9F =E0=A4=87=E0=A4=B5=E0=A5=8D=E0=A4=B9=E0=A5=87= =E0=A4=A8=E0=A5=8D=E0=A4=9F =E0=A4=87=E0=A4=AE=E0=A5=87=E0=A4=9C=E0=A4=B0= =E0=A5=80 =E0=A4=A6=E0=A4=BF=E0=A4=B5=E0=A4=B8=E0=A4=BE=E0=A4=9A=E0=A5=87 = =E0=A4=9A=E0=A4=BF=E0=A4=A4=E0=A5=8D=E0=A4=B0 -Name[nb]=3DDagens bilde om betydelige milj=C3=B8hendelser -Name[nds]=3DOperational Significant Event Imagery (OSEI)-Bild f=C3=B6r Vun= daag -Name[nl]=3DAfbeelding van de dag uit de operationele belangrijke gebeurten= issen-bedenksels -Name[nn]=3DDagens viktige milj=C3=B8hending-bilete -Name[pl]=3DObraz dnia Operational Significant Event Imagery -Name[pt]=3DImagem do Dia para Eventos Operacionais Significativos -Name[pt_BR]=3DImagem do dia para eventos operacionais significativos -Name[ru]=3D=D0=97=D0=BD=D0=B0=D1=87=D0=B8=D0=BC=D1=8B=D0=B5 =D1=81=D0=BE= =D0=B1=D1=8B=D1=82=D0=B8=D1=8F: =D0=98=D0=B7=D0=BE=D0=B1=D1=80=D0=B0=D0=B6= =D0=B5=D0=BD=D0=B8=D0=B5 =D0=94=D0=BD=D1=8F -Name[sk]=3DObr=C3=A1zok d=C5=88a z Operational Significant Event Imagery -Name[sl]=3DSlika dneva z Operational Significant Event Imagery -Name[sr]=3D=D0=9E=D0=A1=D0=95=D0=98=E2=80=91=D1=98=D0=B5=D0=B2=D0=B0 =D1= =81=D0=BB=D0=B8=D0=BA=D0=B0 =D0=B4=D0=B0=D0=BD=D0=B0 -Name[sr@ijekavian]=3D=D0=9E=D0=A1=D0=95=D0=98=E2=80=91=D1=98=D0=B5=D0=B2= =D0=B0 =D1=81=D0=BB=D0=B8=D0=BA=D0=B0 =D0=B4=D0=B0=D0=BD=D0=B0 -Name[sr@ijekavianlatin]=3DOSEI=E2=80=91jeva slika dana -Name[sr@latin]=3DOSEI=E2=80=91jeva slika dana -Name[sv]=3DDagens bild av operationellt signifikant h=C3=A4ndelse -Name[tr]=3DAnlaml=C4=B1 =C4=B0=C5=9Flemsel Olayla =C4=B0lgili G=C3=BCn=C3= =BCn Resmi -Name[uk]=3D=D0=97=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=BD=D1=8F = =D0=B4=D0=BD=D1=8F Operational Significant Event Imagery -Name[x-test]=3DxxOperational Significant Event Imagery Picture of the Dayxx -Name[zh_CN]=3D=E6=AF=8F=E6=97=A5=E4=B8=80=E5=9B=BE(=E4=BA=BA=E7=B1=BB=E7= =8E=AF=E5=A2=83=E9=87=8D=E5=A4=A7=E4=BA=8B=E4=BB=B6=E5=9B=BE=E9=9B=86) -Name[zh_TW]=3D=E6=9C=AC=E6=97=A5 Operational Significant Event Imagery =E5= =9C=96=E7=89=87 -Comment=3DOsei Provider -Comment[ar]=3D=D8=A7=D9=84=D9=85=D8=B2=D9=88=D8=AF Osei -Comment[bs]=3DOsei dobavlja=C4=8D -Comment[ca]=3DProve=C3=AFdor Osei -Comment[ca@valencia]=3DProve=C3=AFdor Osei -Comment[cs]=3DPoskytovatel Osei -Comment[da]=3DOsei-udbyder. -Comment[de]=3DOsei-Anbieter -Comment[el]=3D=CE=A0=CE=AC=CF=81=CE=BF=CF=87=CE=BF=CF=82 Osei -Comment[en_GB]=3DOsei Provider -Comment[es]=3DProveedor de Osei -Comment[et]=3DOsei pakkuja -Comment[fi]=3DOsei-tarjoaja -Comment[fr]=3DFournisseur =C2=AB=C2=A0OSEI=C2=A0=C2=BB -Comment[ga]=3DSol=C3=A1thra=C3=AD OSEI -Comment[gl]=3DFornecedor de Osei -Comment[hr]=3DPru=C5=BEatelj Oseia -Comment[hu]=3DApod-szolg=C3=A1ltat=C3=B3 -Comment[is]=3DOsei =C3=BEj=C3=B3nusta -Comment[it]=3DFornitore Osei -Comment[ja]=3DOsei =E3=81=AE=E3=83=97=E3=83=AD=E3=83=90=E3=82=A4=E3=83=80 -Comment[kk]=3DOsei =D1=82=D0=B0=D1=80=D0=B0=D1=82=D1=83=D1=88=D1=8B=D1=81= =D1=8B -Comment[km]=3D=E1=9E=80=E1=9F=92=E1=9E=9A=E1=9E=BB=E1=9E=98=E1=9E=A0=E1=9F= =8A=E1=9E=BB=E1=9E=93=E2=80=8B=E1=9E=95=E1=9F=92=E1=9E=8A=E1=9E=9B=E1=9F=8B= Osei -Comment[ko]=3DOSEI =EA=B3=B5=EA=B8=89=EC=9E=90 -Comment[lt]=3DOsei tiek=C4=97jas -Comment[lv]=3DOsei pieg=C4=81d=C4=81t=C4=81js -Comment[mr]=3D=E0=A4=93=E0=A4=B8=E0=A5=87=E0=A4=87 =E0=A4=AA=E0=A5=81=E0= =A4=B0=E0=A4=B5=E0=A4=BF=E0=A4=A0=E0=A4=BE=E0=A4=95=E0=A4=B0=E0=A5=8D=E0=A4= =A4=E0=A4=BE -Comment[nb]=3DOsei-leverand=C3=B8r -Comment[nds]=3DOsei-Anbeder -Comment[nl]=3DOsei-provider -Comment[nn]=3DOsei-tilbydar -Comment[pl]=3DUs=C5=82ugodawca Osei -Comment[pt]=3DFornecedor do Osei -Comment[pt_BR]=3DFornecedor Osei -Comment[ro]=3DFurnizor Osei -Comment[ru]=3D=D0=98=D1=81=D1=82=D0=BE=D1=87=D0=BD=D0=B8=D0=BA =D0=B4=D0= =B0=D0=BD=D0=BD=D1=8B=D1=85 Osei -Comment[sk]=3DPoskytovate=C4=BE Osei -Comment[sl]=3DPonudnik Osei -Comment[sr]=3D=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D1=99=D0=B0=D1=87 =D0=9E=D0= =A1=D0=95=D0=98=E2=80=91=D1=98=D0=B0 -Comment[sr@ijekavian]=3D=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D1=99=D0=B0=D1=87 = =D0=9E=D0=A1=D0=95=D0=98=E2=80=91=D1=98=D0=B0 -Comment[sr@ijekavianlatin]=3DDobavlja=C4=8D OSEI=E2=80=91ja -Comment[sr@latin]=3DDobavlja=C4=8D OSEI=E2=80=91ja -Comment[sv]=3DTillhandah=C3=A5ll fr=C3=A5n Osei -Comment[tr]=3DOsei Sa=C4=9Flay=C4=B1c=C4=B1 -Comment[uk]=3D=D0=9F=D0=BE=D1=81=D1=82=D0=B0=D1=87=D0=B0=D0=BB=D1=8C=D0=BD= =D0=B8=D0=BA =D0=B4=D0=B0=D0=BD=D0=B8=D1=85 Osei -Comment[x-test]=3DxxOsei Providerxx -Comment[zh_CN]=3DOsei =E6=8F=90=E4=BE=9B=E6=96=B9 -Comment[zh_TW]=3DOsei =E6=8F=90=E4=BE=9B=E8=80=85 diff --git a/dataengines/potd/plasma_potd_export.h b/dataengines/potd/plasm= a_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 - * - * 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 - -#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 #include = -#include -#include +#include +#include +#include = #include = #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 QVariant= List& args ) // every 2 seconds (!) m_checkDatesTimer->setInterval( 10 * 60 * 1000 ); // check every 10 mi= nutes m_checkDatesTimer->start(); -} = -PotdEngine::~PotdEngine() -{ + const QVector plugins =3D KPluginLoader::findPlugins(= QStringLiteral("potd"), [](const KPluginMetaData & md) { + return md.serviceTypes().contains(QStringLiteral("PlasmaPoTD/Plugi= n")); + }); + + for (const auto &metadata : plugins) { + QString provider =3D metadata.value(QLatin1String( "X-KDE-PlasmaPo= TDProvider-Identifier" )); + if (provider.isEmpty()) { + continue; + } + mFactories.insert(provider, metadata); + setData( QLatin1String( "Providers" ), provider, metadata.name() ); + } } = -void PotdEngine::init() +PotdEngine::~PotdEngine() { - KService::List services =3D KServiceTypeTrader::self()->query(QLatin1S= tring( "PlasmaPoTD/Plugin" )); - Q_FOREACH ( const KService::Ptr &service, services ) { - QString provider =3D service->property(QLatin1String( "X-KDE-Plasm= aPoTDProvider-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 =3D identifier.split( QLatin1Char( ':' ), QStr= ing::SkipEmptyParts ); + if (parts.empty()) { + qDebug() << "invalid identifier"; + return false; + } const QString providerName =3D 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 &identifi= er, bool loadCachedAlways if ( parts.count() > 1 ) { const QDate date =3D 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 =3D qobject_cast( mFactories[ pr= oviderName ]->createInstance( this, args ) ); + auto factory =3D KPluginLoader(mFactories[ providerName ].fileName()).= factory(); + PotdProvider *provider =3D nullptr; + if (factory) { + provider =3D factory->create(this, args); + } if (provider) { connect( provider, SIGNAL(finished(PotdProvider*)), this, SLOT(fin= ished(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-datae= ngine-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 +#include = 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 loadCachedAlway= s ); = - QMap mFactories; + QMap mFactories; QTimer *m_checkDatesTimer; bool m_canDiscardCache; }; = -K_EXPORT_PLASMA_DATAENGINE(potd, PotdEngine) - #endif diff --git a/dataengines/potd/potdprovider.h b/dataengines/potd/potdprovide= r.h index 3f4d308..6578c45 100644 --- a/dataengines/potd/potdprovider.h +++ b/dataengines/potd/potdprovider.h @@ -23,16 +23,12 @@ #include #include = -#include +#include = #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/wcpotdp= rovider.cpp index c38afcc..63258f8 100644 --- a/dataengines/potd/wcpotdprovider.cpp +++ b/dataengines/potd/wcpotdprovider.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2007 Tobias Koenig * Copyright 2008 by Anne-Marie Mahfouf + * Copyright 2016 Weng Xuetian * * 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 #include = -#include +#include #include = -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/po= td.php/commons/800x600" ) ); KIO::StoredTransferJob *imageJob =3D KIO::sto= redGet( picUrl, KIO::NoReload, KIO::HideProgressInfo ); + QUrl picUrl( QLatin1String( "https://tools.wmflabs.org/potd-feed/potd.= php/commons/full" ) ); KIO::StoredTransferJob *imageJob =3D KIO::storedGet= ( picUrl, KIO::NoReload, KIO::HideProgressInfo ); mParent->connect( imageJob, SIGNAL(finished(KJob*)), SLOT(imageRequest= Finished(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 =3D KIO::storedGet( url, KIO::NoReload, KI= O::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", r= egisterPlugin();) + +#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)