1
/****************************************************************************
2
** jabber.h - communicates with the Jabber network
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 program; if not, write to the Free Software
17
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
19
****************************************************************************/
37
#define JABERR_CONNECT 0
39
#define JABERR_CREATE 2
40
#define JABERR_DISCONNECT 3
43
#define JABERR_SERVICES 5
44
#define JABERR_REGFORM 6
45
#define JABERR_BROWSE 7
48
#define JABCONN_LOGIN 0
49
#define JABCONN_REGISTER 1
50
#define JABCONN_UNREGISTER 2
53
// for signaling updates
60
// for signaling errors
68
/****************************************************************************
69
Jabber - handles a Jabber session
74
serv.setHost("jabber.org", 5222");
75
serv.setAccount("Joe", "Password", "Resource");
76
serv.login(STATUS_ONLINE);
78
The class communicates back to you via signals.
80
All Jabber tasks are carried out via JabTasks. Some tasks are handled
81
internally, like messaging. Other tasks are your responsibility. See
82
JabIO to learn how tasks work.
84
****************************************************************************/
85
class Jabber : public QObject
93
void setHost(const QString &xhost, int xport);
94
void setAccount(const QString &xuser, const QString &xpass, const QString &xresource);
96
JabRosterEntry *userEntry() { return &me; }
98
bool isActive() { return v_isActive; }
99
bool isConnected() { return stream.isConnected(); }
100
int status() { return v_status; }
104
bool isSSLSupported() { return stream.isSSLSupported(); }
105
bool isSSLEnabled() { return stream.isSSLEnabled(); }
106
void setSSLEnabled(bool use) { stream.setSSLEnabled(use); }
108
void login(int status, const QString &statusStr, int priority, bool plain=FALSE);
110
void accUnregister();
111
void disc(bool fast=FALSE);
113
void sendMessage(const JabMessage &);
114
void setRoster(const QString &jid, const QString &nick, const QString &group);
115
void setPresence(int status, const QString &statusStr, int priority);
117
void subscribe(const QString &to);
118
void subscribed(const QString &to);
119
void unsubscribe(const QString &to);
120
void unsubscribed(const QString &to);
122
void cancelTransaction(const QString &id);
123
JabTask *ioUser() { return userTask; }
125
void insertXml(const QString &);
126
void agentSetStatus(const QString &jid, int x);
128
JabRosterEntry *findByJid(const QString &);
130
void setOfflineEnabled(bool);
131
void setCurrentRoster(JabRoster *);
132
JabRoster *getCurrentRoster();
133
void setOLR(const QString &);
143
// FIXME: these 2 should not pass pointers
144
void statusUpdate(JabUpdate *);
145
void error(JabError *);
147
void messageReceived(const JabMessage &);
149
void resourceAvailable(const Jid &, const JabResource &);
150
void resourceUnavailable(const Jid &);
152
void contactChanged(JabRosterEntry *);
153
void contactNew(JabRosterEntry *);
154
void contactRemove(JabRosterEntry *);
156
void authRequest(const Jid &from);
157
void authGrant(const Jid &from);
158
void authRemove(const Jid &from);
160
void accRegisterFinished(bool success, const QString &errMsg);
163
void streamConnected();
164
void streamError(int);
165
void receivePacket(const QDomElement &);
167
void ioDone(JabTask *);
168
void ioOutgoingPacket(const QDomElement &);
171
void ioPresence(int status, const QString &statusString);
172
void ioReceiveRoster(JabRoster &r);
173
void pushRoster(JabRoster &r);
174
void pushSubscription(const Jid &, int);
175
void pushPresence(const JT_PushPresence::Info &);
176
void pushMessage(const JabMessage &);
181
bool sock_isConnected;
185
bool v_isActive, v_isConnected, v_offlineEnabled;
186
QString user, pass, resource;
201
int i_status, i_priority;
202
QString i_statusString;
205
void remove(const QString &);
207
void processRosterEntryRecv(const JabRosterEntry &);
209
QCString encodeXML(const QString &);
210
void send(const QString &);
211
void cleanup(bool fast=FALSE);
214
JabUpdate makeUpdate();
223
static QString digest(QString in);
230
unsigned char buffer[64];
238
void transform(Q_UINT32 state[5], unsigned char buffer[64]);
239
void init(SHA1_CONTEXT* context);
240
void update(SHA1_CONTEXT* context, unsigned char* data, Q_UINT32 len);
241
void final(unsigned char digest[20], SHA1_CONTEXT* context);
243
unsigned long blk0(Q_UINT32 i);