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

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