2 * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 * This file contains the DBUSDrop class.
30 class AccountSettings
;
31 class KornMailSubject
;
35 template<class A
, class B
> class QMap
;
36 template<class T
> class QList
;
41 * This class implements a KMailDrop for DBUS-objects.
42 * This class handles all new messages which are coming in through DBUS.
44 class DBUSDrop
: public KMailDrop
48 * Constructor: no parameters
57 * A DBUSDrop cannot produce error messages, so it always returns true.
59 * @return true is the box is valid
61 virtual bool valid() { return true; }
63 * This forces the drop to recheck. It is inpossible to recheck DBUS,
64 * so this function does nothing.
66 virtual void recheck();
68 * This function starts the monitor, however, this drop is always running,
69 * and doesn't need to be started.
70 * The return value is always true.
74 virtual bool startMonitor();
76 * This function starts the monitor, however, this drop is always running,
77 * and doesn't need to be started.
78 * The return value is always true.
82 virtual bool stopMonitor();
84 * Return true is the monitor has been started before.
86 * @return true is it is 'running'.
88 virtual bool running() { return _isRunning
; }
91 * This function gives a new instance of a DBUSDrop.
93 * @return A new instance of a DBUSDrop.
95 virtual KMailDrop
* clone() const { return new DBUSDrop
; }
98 * This function reeds the config which are shipped which the group.
100 * @param config The configuration group which contains the info for this account.
101 * @return The same value as KMailDrop::readConfigGroup( config ) returns.
103 virtual bool readConfig( AccountSettings
*config
);
105 * This function reeds the config which are shipped which the group.
107 * @param config The configuration group which contains the info for this account.
108 * @return The same value as KMailDrop::readConfigGroup( config ) returns.
110 virtual bool readConfigGroup( const QMap
< QString
, QString
> & map
, const Protocol
* protocol
);
112 * This function writes the information to a config group.
114 * @param config The configuration to write true
115 * @return true if no error occurred.
117 //virtual bool writeConfigGroup( KConfigBase& config ) const;
119 * This returns the type of the box, in this case always "dbus".
123 virtual QString
type() const;
126 * This function should return true if it uses a synchrone comminucation.
127 * It doesn't, so it returns false.
131 virtual bool synchrone() const { return false; }
134 * Return true if it is possible to read the subjects of new email.
138 virtual bool canReadSubjects() { return true; }
140 * This function does reads the subjects.
141 * @param stop A variable which isn't used: only used for synchrone actions
142 * @return A QValueVector which KornMailSubject* instance for every new mail.
144 virtual QVector
< KornMailSubject
>* doReadSubjects( bool *stop
);
147 * This function should return true if it is possible to delete emails.
148 * This is possible, so it always return true.
152 virtual bool canDeleteMails() { return true; }
154 * This function deletes the email.
156 * @param ids The id's of the email which must be deleted.
157 * @param stop Not used: only for synchrone opererations.
158 * @return true if deleting was succesfull
160 virtual bool deleteMails( QList
<QVariant
> * ids
, bool * stop
);
163 * This function returns true if it is possible to read emails.
164 * The emails are only given at once as a whole, so reading is impossible.
168 virtual bool canReadMail() const { return false; }
171 QMap
< int, KornMailSubject
* > *_msgList
;
175 void eraseList( void );
178 void doReadSubjectsASync( void );
180 public slots
: //accessed by DBUSDropInterface
182 * This function append a message to the box.
183 * This function is called from DBUSDropInterface.
185 * @param subject the subject of the message
186 * @param message the content of the message
187 * @return the message id
189 int addMessage( const QString
& subject
, const QString
& message
);
191 * This function removes a messages from the box.
192 * This function is called from DBUSDropInterface.
194 * @param id the message id to be removed
195 * @return true if succesfull, false otherwise
197 bool removeMessage( int id
);
199 //accessed by DBUSDropCfg
202 * This function returns the dbus name.
203 * This function is accessed by DBUSDropCfg.
205 * @return the dbus name
207 QString
DBUSName() const;
209 * This function sets the dbus name.
210 * This function is accessed by DBUSDropCfg.
212 * @param name the new dbus name
214 void setDBUSName( const QString
& name
);