1/*
2 knewstuff3/xmlloader.h.
3 SPDX-FileCopyrightText: 2002 Cornelius Schumacher <schumacher@kde.org>
4 SPDX-FileCopyrightText: 2003-2007 Josef Spillner <spillner@kde.org>
5 SPDX-FileCopyrightText: 2009 Jeremy Whiting <jpwhiting@kde.org>
6 SPDX-FileCopyrightText: 2010 Frederik Gladhorn <gladhorn@kde.org>
7
8 SPDX-License-Identifier: LGPL-2.1-or-later
9*/
10
11#ifndef KNEWSTUFF3_XMLLOADER_P_H
12#define KNEWSTUFF3_XMLLOADER_P_H
13
14#include "provider.h"
15#include <QNetworkReply>
16#include <QObject>
17#include <QString>
18#include <QUrl>
19#include <qdom.h>
20
21class KJob;
22
23namespace KNSCore
24{
25QDomElement addElement(QDomDocument &doc, QDomElement &parent, const QString &tag, const QString &value);
26
27/**
28 * KNewStuff xml loader.
29 * This class loads an xml document from a kurl and returns the
30 * resulting domdocument once completed.
31 * It should probably not be used directly by the application.
32 *
33 * @internal
34 */
35class XmlLoader : public QObject
36{
37 Q_OBJECT
38public:
39 /**
40 * Constructor.
41 */
42 explicit XmlLoader(QObject *parent);
43
44 /**
45 * Starts asynchronously loading the xml document from the
46 * specified URL.
47 *
48 * @param url location of the XML file
49 */
50 void load(const QUrl &url);
51
52 void setFilter(Provider::Filter filter)
53 {
54 m_filter = filter;
55 }
56
57 void setSearchTerm(const QString &searchTerm)
58 {
59 m_searchTerm = searchTerm;
60 }
61
62 Provider::Filter filter() const
63 {
64 return m_filter;
65 }
66
67 QString searchTerm() const
68 {
69 return m_searchTerm;
70 }
71Q_SIGNALS:
72 /**
73 * Indicates that the list of providers has been successfully loaded.
74 */
75 void signalLoaded(const QDomDocument &);
76 void signalFailed();
77 /**
78 * Fired in case there is a http error reported
79 * In some instances this is useful information for our users, and we want to make sure we report this centrally
80 * @param status The HTTP status code (fired in cases where it is perceived by QNetworkReply as an error)
81 * @param rawHeaders The raw HTTP headers for the errored-out network request
82 */
83 void signalHttpError(int status, QList<QNetworkReply::RawHeaderPair> rawHeaders);
84
85 void jobStarted(KJob *);
86
87protected Q_SLOTS:
88 void slotJobData(KJob *, const QByteArray &);
89 void slotJobResult(KJob *);
90
91private:
92 QByteArray m_jobdata;
93 Provider::Filter m_filter;
94 QString m_searchTerm;
95};
96
97}
98
99#endif
100

source code of knewstuff/src/core/xmlloader_p.h