summaryrefslogtreecommitdiffstats
path: root/knewsticker/common/xmlnewsaccess.h
blob: 0d03669040a5e486272adb110e2a6e04202589fd (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 <[email protected]>
 *
 * 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 <tqvaluelist.h>
#include <tqobject.h>

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

class TQBuffer;
class TQDomDocument;
class XMLNewsSource;

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

		TQString headline() const { return m_headline; }
		void setHeadline(const TQString &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:
		TQString        m_headline;
		KURL           m_address;
};

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

		void loadFrom(const KURL &);

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

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

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

#endif // XMLNEWSACCESS_H