Port customDataContainersEngine example
This commit is contained in:
parent
0be909e24a
commit
82de6a8ecf
@ -1,3 +1,3 @@
|
|||||||
add_subdirectory(simpleEngine)
|
add_subdirectory(simpleEngine)
|
||||||
add_subdirectory(sourcesOnRequest)
|
add_subdirectory(sourcesOnRequest)
|
||||||
#add_subdirectory(customDataContainers)
|
add_subdirectory(customDataContainers)
|
@ -3,8 +3,14 @@ set(customDataContainers_SRCS
|
|||||||
httpContainer.cpp
|
httpContainer.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
kde4_add_plugin(plasma_dataengine_example_customDataContainers ${customDataContainers_SRCS})
|
kservice_desktop_to_json(plasma-dataengine-example-customDataContainers.desktop)
|
||||||
target_link_libraries(plasma_dataengine_example_customDataContainers ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS})
|
|
||||||
|
plasma_add_plugin(plasma_dataengine_example_customDataContainers ${customDataContainers_SRCS})
|
||||||
|
target_link_libraries(plasma_dataengine_example_customDataContainers
|
||||||
|
plasma
|
||||||
|
${KService_LIBRARIES}
|
||||||
|
${KDE4_KIO_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
install(TARGETS plasma_dataengine_example_customDataContainers DESTINATION ${PLUGIN_INSTALL_DIR})
|
install(TARGETS plasma_dataengine_example_customDataContainers DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||||
install(FILES plasma-dataengine-example-customDataContainers.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
|
install(FILES plasma-dataengine-example-customDataContainers.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include "customDataContainersEngine.h"
|
#include "customDataContainersEngine.h"
|
||||||
|
|
||||||
#include "httpContainer.h"
|
#include "httpContainer.h"
|
||||||
@ -44,9 +47,9 @@ bool DataContainersEngine::sourceRequestEvent(const QString &source)
|
|||||||
{
|
{
|
||||||
// This engine will fetch webpages over http. First thing we do is check
|
// This engine will fetch webpages over http. First thing we do is check
|
||||||
// the source to make sure it is indeed an http URL.
|
// the source to make sure it is indeed an http URL.
|
||||||
KUrl url(source);
|
QUrl url(source);
|
||||||
kDebug() << "goin to fetch" << source << url << url.protocol();
|
qDebug() << "goin to fetch" << source << url << url.scheme();
|
||||||
if (!url.protocol().startsWith("http", Qt::CaseInsensitive)) {
|
if (!url.scheme().startsWith("http", Qt::CaseInsensitive)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +83,7 @@ bool DataContainersEngine::updateSourceEvent(const QString &source)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// export the plugin; use the plugin name and the class name
|
// export the plugin; use the plugin name and the class name
|
||||||
K_EXPORT_PLASMA_DATAENGINE(org.kde.examples.customDataContainers, DataContainersEngine)
|
K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(org.kde.examples.customDataContainers, DataContainersEngine, "plasma-dataengine-example-customDataContainers.json")
|
||||||
|
|
||||||
// include the moc file so the build system makes it for us
|
// include the moc file so the build system makes it for us
|
||||||
#include "customDataContainersEngine.moc"
|
#include "customDataContainersEngine.moc"
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <KIO/Job>
|
#include <KIO/Job>
|
||||||
#include <KIO/TransferJob>
|
#include <KIO/TransferJob>
|
||||||
|
|
||||||
HttpContainer::HttpContainer(const KUrl &url, QObject *parent)
|
HttpContainer::HttpContainer(const QUrl &url, QObject *parent)
|
||||||
: Plasma::DataContainer(parent),
|
: Plasma::DataContainer(parent),
|
||||||
m_url(url)
|
m_url(url)
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#ifndef HTTPCONTAINER_H
|
#ifndef HTTPCONTAINER_H
|
||||||
#define HTTPCONTAINER_H
|
#define HTTPCONTAINER_H
|
||||||
|
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
#include <Plasma/DataContainer>
|
#include <Plasma/DataContainer>
|
||||||
|
|
||||||
namespace KIO
|
namespace KIO
|
||||||
@ -38,7 +40,7 @@ class HttpContainer : public Plasma::DataContainer
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HttpContainer(const KUrl &url, QObject *parent = 0);
|
HttpContainer(const QUrl &url, QObject *parent = 0);
|
||||||
|
|
||||||
void fetchUrl(bool reload = true);
|
void fetchUrl(bool reload = true);
|
||||||
|
|
||||||
@ -47,7 +49,7 @@ private Q_SLOTS:
|
|||||||
void fetchFinished(KJob *);
|
void fetchFinished(KJob *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const KUrl m_url;
|
const QUrl m_url;
|
||||||
QWeakPointer<KJob> m_job;
|
QWeakPointer<KJob> m_job;
|
||||||
QByteArray m_data;
|
QByteArray m_data;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user