summaryrefslogtreecommitdiffstats
path: root/korn/dcopdrop.h
blob: 32e85066d73fe87d7b217ee97ae1c5ca68aa0ace (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
 * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
 *
 * 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.
 *
 * 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.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef DCOPDROP_H
#define DCOPDROP_H

#include "maildrop.h"

#include <dcopobject.h>

class DCOPDropInterface;
//class KDropCfgDialog;
class KornMailId;
class KornMailSubject;

class KConfigBase;

template<class A, class B> class QMap;
class QString;

/**
 * This class implements a KMailDrop for DCOP-objects.
 * This class handles all new messages which are comming in through DCOP.
 */
class DCOPDrop : public KMailDrop
{ Q_OBJECT
public:
	/**
	 * Constructor: no parameters
	 */
	DCOPDrop();
	/**
	 * Destructor
	 */
	virtual ~DCOPDrop();
	
	/**
	 * A DCOPDrop cannot produce error messages, so it always returns true.
	 *
	 * @return true is the box is valid
	 */
	virtual bool valid() { return true; }
	/**
	 * This forces the drop to recheck. It is inpossible to recheck dcop,
	 * so this function does nothing.
	 */
	virtual void recheck();
	/**
	 * This function starts the monitor, however, this drop is always running,
	 * and doesn't need to be started.
	 * The return value is always true.
	 *
	 * @return true
	 */
	virtual bool startMonitor();
	/**
	 * This function starts the monitor, however, this drop is always running,
	 * and doesn't need to be started.
	 * The return value is always true.
	 *
	 * @return true
	 */
	virtual bool stopMonitor();
	/**
	 * Return true is the monitor has been started before.
	 * @return true is it is 'running'.
	 */
	virtual bool running() { return _isRunning; }
	
	//virtual void addConfigPage( KDropCfgDialog* ) ;
	/**
	 * This function gives a new instance of a DCOPDrop.
	 *
	 * @return A new instance of a DCOPDrop.
	 */
	virtual KMailDrop* clone() const { return new DCOPDrop; }

	/**
	 * This function reeds the config which are shipped which the group.
	 *
	 * @param config The configuration group which contains the info for this account.
	 * @return The same value as KMailDrop::readConfigGroup( config ) returns.
	 */
	virtual bool readConfigGroup( const KConfigGroup& config );
	/**
	 * This function also reeds the configurion, but from a mapping.
	 *
	 * @param map The mapping containing the configuration.
	 * @param protocol The protocol which comes with the mapping.
	 *
	 * @return true is all information is retrieved succesfully.
	 */
	virtual bool readConfigGroup( const TQMap< TQString, TQString > & map, const Protocol * protocol );
	/**
	 * This function writes the information to a config group.
	 *
	 * @param config The configuration to write true
	 * @return true if no error occured.
	 */
	virtual bool writeConfigGroup( KConfigBase& config ) const;
	/**
	 * This returns the type of the box, in this case allways "dcop".
	 *
	 * @return "dcop"
	 */
	virtual TQString type() const;
	
	/**
	 * This function should return true if it uses a synchrone comminucation.
	 * It doens't, so it returns false.
	 *
	 * @return false
	 */
	virtual bool synchrone() const { return false; }
	
	/**
	 * Return true if it is possible to read the subjects of new email.
	 *
	 * @return true
	 */
	virtual bool canReadSubjects() { return true; }
	/**
	 * This function does reads the subjects.
	 * @param stop A variable which isn't used: only used for synchrone actions
	 * @return A TQValueVector which KornMailSubject* instance for every new mail.
	 */
	virtual TQValueVector< KornMailSubject >* doReadSubjects( bool *stop );
	
	/**
	 * This function should return true if it is possible to delete emails.
	 * This is possible, so it always return true.
	 *
	 * @return true
	 */
	virtual bool canDeleteMails() { return true; }
	/**
	 * This function deletes the email.
	 *
	 * @param ids The id's of the email which must be deleted.
	 * @param stop Not used: only for synchrone opererations.
	 * @return true if deleting was succesfull
	 */
	virtual bool deleteMails( TQPtrList<const KornMailId> * ids, bool * stop );
	
	/**
	 * This function returns true if it is possible to read emails.
	 * The emails are only given at once as a whole, so reading is impossible.
	 *
	 * @return false
	 */
	virtual bool canReadMail() { return false; }
	
	
private:
	bool _isRunning;
	TQMap< int, KornMailSubject* > *_msgList;
	TQString *_name;
	int _counter;
	DCOPDropInterface *_interface;
	
	void eraseList( void );
	
private slots:
	void doReadSubjectsASync( void );
	
public: //accessed by DCOPDropInterface
	int addMessage( const TQString& subject, const TQString& message );
	bool removeMessage( int id );
	
	//accessed by DCOPDropCfg
	TQString DCOPName() const;
	void setDCOPName( const TQString& );
};

#endif