summaryrefslogtreecommitdiffstats
path: root/knewsticker/common/xmlnewsaccess.h
blob: 91cbf77f59290fb618dab5560a8db54bf46ee872 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * xmlnewsaccess.h
 *
 * Copyright (c) 2001 Frerich Raabe <raabe@kde.org>
 *
 * 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. For licensing and distribution details, check the
 * accompanying file 'COPYING'.
 */
#ifndef XMLNEWSACCESS_H
#define XMLNEWSACCESS_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <qvaluelist.h>
#include <qobject.h>

#include <kio/job.h>
#include <kurl.h>

class QBuffer;
class QDomDocument;
class XMLNewsSource;

class XMLNewsArticle
{
	public:
		typedef QValueList<XMLNewsArticle> List;
		
		XMLNewsArticle() {}
		XMLNewsArticle(const QString &headline, const KURL &addresss);
		XMLNewsArticle(const XMLNewsArticle &other) { (*this) = other; }
		XMLNewsArticle &operator=(const XMLNewsArticle &other);

		QString headline() const { return m_headline; }
		void setHeadline(const QString &headline) { m_headline = headline; }

		KURL address() const { return m_address; }
		void setAddress(const KURL &address) { m_address = address; }

		bool operator== (const XMLNewsArticle &a);
		bool operator!= (const XMLNewsArticle &a) { return !operator==(a); }

	private:
		QString        m_headline;
		KURL           m_address;
};

class XMLNewsSource : public QObject
{
	Q_OBJECT
		
	public:
		XMLNewsSource();
		virtual ~XMLNewsSource();

		void loadFrom(const KURL &);

		virtual QString newsSourceName() const { return m_name; }
		virtual QString link() const { return m_link; }
		virtual QString description() const { return m_description; }
		const XMLNewsArticle::List &articles() const { return m_articles; }

	signals:
		void loadComplete(XMLNewsSource *, bool);
	
	protected:
		void processData(const QByteArray &, bool = true);
		
		QString m_name;
		QString m_link;
		QString m_description;

	private slots:
		void slotData(KIO::Job *, const QByteArray &);
		void slotResult(KIO::Job *);
	
	private:
		XMLNewsArticle::List m_articles;
		QBuffer             *m_downloadData;
};

#endif // XMLNEWSACCESS_H