3
* Copyright (C) 2001, 2002 Justin Karneges
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
#include <qdatetime.h>
28
#include <qguardedptr.h>
43
class PsiEvent : public QObject
47
PsiEvent(PsiAccount *);
48
PsiEvent(const PsiEvent &);
49
virtual ~PsiEvent() = 0;
57
virtual int type() const = 0;
59
virtual Jid from() const = 0;
60
virtual void setFrom(const Jid &j) = 0;
63
void setJid(const Jid &);
65
bool originLocal() const;
67
QDateTime timeStamp() const;
69
void setOriginLocal(bool b);
71
void setTimeStamp(const QDateTime &t);
73
PsiAccount *account() const;
75
virtual QDomElement *toXml(QDomDocument *) const;
76
virtual bool fromXml(PsiCon *, const QDomElement *);
78
virtual int priority() const;
81
bool v_originLocal, v_late;
84
PsiAccount *v_account;
87
// normal, chat, error, headline, etc
88
class MessageEvent : public PsiEvent
92
MessageEvent(PsiAccount *acc);
93
MessageEvent(const MessageEvent &from);
94
MessageEvent(const XMPP::Message &, PsiAccount *acc);
99
void setFrom(const Jid &j);
101
bool sentToChatWindow() const;
102
const XMPP::Message & message() const;
104
void setSentToChatWindow(bool b);
105
void setMessage(const XMPP::Message &m);
107
QDomElement *toXml(QDomDocument *) const;
108
bool fromXml(PsiCon *, const QDomElement *);
110
virtual int priority() const;
114
bool v_sentToChatWindow;
117
// subscribe, subscribed, unsubscribe, unsubscribed
118
class AuthEvent : public PsiEvent
122
AuthEvent(const Jid &j, const QString &authType, PsiAccount *acc);
123
AuthEvent(const AuthEvent &from);
128
void setFrom(const Jid &j);
130
QString authType() const;
132
QDomElement *toXml(QDomDocument *) const;
133
bool fromXml(PsiCon *, const QDomElement *);
135
virtual int priority() const;
142
// request pgp passphrase
143
class PGPEvent : public PsiEvent
147
PGPEvent(PsiAccount *acc) : PsiEvent(acc) {}
148
PGPEvent(const PGPEvent &from)
151
int type() const { return PGP; }
152
Jid from() const { return QString(); }
153
void setFrom(const Jid &) {}
156
// incoming file transfer
157
class FileEvent : public PsiEvent
161
FileEvent(const Jid &j, FileTransfer *ft, PsiAccount *acc);
164
int type() const { return File; }
166
void setFrom(const Jid &);
167
FileTransfer *takeFileTransfer();
169
virtual int priority() const;
173
QGuardedPtr<FileTransfer> ft;
177
class EventQueue : public QObject
181
EventQueue(PsiCon *);
182
EventQueue(const EventQueue &);
185
EventQueue &operator= (const EventQueue &);
189
int count(const Jid &, bool compareRes=true) const;
190
void enqueue(PsiEvent *);
191
void dequeue(PsiEvent *);
192
PsiEvent *dequeue(const Jid &, bool compareRes=true);
193
PsiEvent *peek(const Jid &, bool compareRes=true) const;
194
PsiEvent *dequeueNext();
195
PsiEvent *peekNext() const;
196
bool hasChats(const Jid &, bool compareRes=true) const;
197
PsiEvent *peekFirstChat(const Jid &, bool compareRes=true) const;
198
void extractChats(QPtrList<PsiEvent> *list, const Jid &, bool compareRes=true);
199
void printContent() const;
201
void clear(const Jid &, bool compareRes=true);
203
QDomElement *toXml(QDomDocument *) const; // these work with pointers, to save inclusion of qdom.h, which is pretty large
204
bool fromXml(const QDomElement *);
206
bool toFile(const QString &fname);
207
bool fromFile(const QString &fname);
210
void handleEvent(PsiEvent *);