File indexing completed on 2024-04-28 15:28:59
0001 /* 0002 knewstuff3/xmlloader.h. 0003 SPDX-FileCopyrightText: 2002 Cornelius Schumacher <schumacher@kde.org> 0004 SPDX-FileCopyrightText: 2003-2007 Josef Spillner <spillner@kde.org> 0005 SPDX-FileCopyrightText: 2009 Jeremy Whiting <jpwhiting@kde.org> 0006 SPDX-FileCopyrightText: 2010 Frederik Gladhorn <gladhorn@kde.org> 0007 0008 SPDX-License-Identifier: LGPL-2.1-or-later 0009 */ 0010 0011 #ifndef KNEWSTUFF3_XMLLOADER_P_H 0012 #define KNEWSTUFF3_XMLLOADER_P_H 0013 0014 #include <QNetworkReply> 0015 #include <QObject> 0016 #include <QString> 0017 #include <QUrl> 0018 #include <qdom.h> 0019 0020 #include "knewstuffcore_export.h" 0021 0022 class KJob; 0023 0024 namespace KNSCore 0025 { 0026 QDomElement addElement(QDomDocument &doc, QDomElement &parent, const QString &tag, const QString &value); 0027 0028 /** 0029 * KNewStuff xml loader. 0030 * This class loads an xml document from a kurl and returns the 0031 * resulting domdocument once completed. 0032 * It should probably not be used directly by the application. 0033 * 0034 * @internal 0035 */ 0036 class KNEWSTUFFCORE_EXPORT XmlLoader : public QObject 0037 { 0038 Q_OBJECT 0039 public: 0040 /** 0041 * Constructor. 0042 */ 0043 explicit XmlLoader(QObject *parent); 0044 0045 /** 0046 * Starts asynchronously loading the xml document from the 0047 * specified URL. 0048 * 0049 * @param url location of the XML file 0050 */ 0051 void load(const QUrl &url); 0052 0053 Q_SIGNALS: 0054 /** 0055 * Indicates that the list of providers has been successfully loaded. 0056 */ 0057 void signalLoaded(const QDomDocument &); 0058 void signalFailed(); 0059 /** 0060 * Fired in case there is a http error reported 0061 * In some instances this is useful information for our users, and we want to make sure we report this centrally 0062 * @param status The HTTP status code (fired in cases where it is perceived by QNetworkReply as an error) 0063 * @param rawHeaders The raw HTTP headers for the errored-out network request 0064 */ 0065 void signalHttpError(int status, QList<QNetworkReply::RawHeaderPair> rawHeaders); 0066 0067 void jobStarted(KJob *); 0068 0069 protected Q_SLOTS: 0070 void slotJobData(KJob *, const QByteArray &); 0071 void slotJobResult(KJob *); 0072 0073 private: 0074 QByteArray m_jobdata; 0075 }; 0076 0077 } 0078 0079 #endif