summaryrefslogtreecommitdiffstats
path: root/dcoprss/query.h
blob: dbaf50932c6fb609a075bcaca2d9f55ece5d833b (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* $Id$ */
#ifndef _QUERY_SERVICE
#define _QUERY_SERVICE

/***************************************************************************
                          query.h  -  A query interface to select RSS feeds.
                             -------------------
    begin                : Saturday 15 February 2003
    copyright            : (C) 2003 by Ian Reinhart Geiser
    email                : geiseri@kde.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "rssnewsfeed.h"
#include "xmlrpciface.h"

#include <dcopobject.h>

#include <tqmap.h>
#include <tqobject.h>
#include <tqvaluelist.h>
#include <tqvariant.h>

class RSSService;

/**
 * Helper class which just calls the slot given it's QObject/const char*
 * representation.
 */
class SlotCaller : public QObject
{
	Q_OBJECT
	public:
		static void call( TQObject *object, const char *slot,
		                  const KXMLRPC::Query::Result &value );

	signals:
		void signal( const KXMLRPC::Query::Result &value );

	private:
		SlotCaller() { }
};

class QueryService : public TQObject, public DCOPObject
{
	K_DCOP
	Q_OBJECT
	public:
		QueryService( RSSService *service );

	k_dcop_signals:
		void feedIds( TQValueList<int> ids );
		void feedInfo(TQMap<TQString, TQString> links);
		void feedInfo(TQValueList<RSSNewsFeed> feeds);
		void gotCategories( const TQStringList &categories );
		void gotFeedsInCategory( const TQValueList<int> &ids );

	k_dcop:
		/**
		 * Lists the active feeds in use...
		 **/
		TQStringList listActive(); // just for testing...

		/**
		 * Query the www.syndic8.com XML-RPC interface for the
		 * string. The RSS ids are treturned in a integer list.
		 **/
		void findFeeds( const TQString& query );

		/**
		 * Query the www.syndic8.com XML-RPC interface for the
		 * string and matches it against the SiteURL feed of 
		 * each feed in the feed list. The RSS ids are treturned 
		 * in a integer list.
		 **/
		void findSites( const TQString& query );

		/**
		 * Query the www.syndic8.com XML-RPC interface for the
		 * requested RSS feed(s).  Returned is a TQMap with the format
		 * of Name (Site URL), RSS URL
		 **/
		void getFeedInfo( const TQVariant& ids );

		/**
		 * Returns the list of subcategories in the specified category.
		 * If no "Top" is specified, the root categories are returned.
		 */
		void getCategories( const TQString &category );

		/**
		 * Queries the database for the list of needsfeed ID's which are
		 * associated with the given category.
		 */
		void getFeedsInCategory( const TQString &category );


	private slots:
		void slotFoundFeeds( const KXMLRPC::Query::Result &result );
		void slotGotFeedInfo( const KXMLRPC::Query::Result &result );
		void slotGotCategories( const KXMLRPC::Query::Result &result );
		void slotGotFeedsInCategory( const KXMLRPC::Query::Result &result );

	private:
		void cachedCall( const TQString &method, const TQValueList<TQVariant> &args,
		                 const char *slot );
		void updateCache( const KXMLRPC::Query::Result &result );

		RSSService *m_service;
		KXMLRPC::Server *m_xmlrpcServer;
};
#endif