~ubuntu-branches/ubuntu/edgy/psi/edgy

« back to all changes in this revision

Viewing changes to src/jabsess.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2002-04-19 02:28:44 UTC
  • Revision ID: james.westby@ubuntu.com-20020419022844-za7xgai5qyfd9xv6
Tags: upstream-0.8.5
ImportĀ upstreamĀ versionĀ 0.8.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
** jabsess.h - keeps track of Jabber accounts/sessions
 
3
** Copyright (C) 2001, 2002  Justin Karneges
 
4
**
 
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.
 
9
**
 
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.
 
14
**
 
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.
 
18
**
 
19
****************************************************************************/
 
20
 
 
21
#ifndef JABSESS_H
 
22
#define JABSESS_H
 
23
 
 
24
#include<qobject.h>
 
25
#include<qptrlist.h>
 
26
#include"profiles.h"
 
27
#include"jabber.h"
 
28
#include"userlist.h"
 
29
#include"statusdlg.h"
 
30
#include"contactview.h"
 
31
 
 
32
 
 
33
/****************************************************************************
 
34
  JabSession, JabSessionManager
 
35
 
 
36
  JabSession wraps a Jabber instance, as well as any other necessary
 
37
  variables.  With the help of JabSessionManager, a bunch of insane
 
38
  signal remapping is done so that each event from Jabber can be associated
 
39
  with the correct JabSession.
 
40
 
 
41
  JabSession now handles much of the functionality that the old jabcon used
 
42
  to.  Also, organization-wise, I consider JabSession to be on the same
 
43
  level in the class hierarchy as jabcon, so it need not always go through
 
44
  jabcon to get things done.  It can open its own windows, etc.
 
45
 
 
46
****************************************************************************/
 
47
class JabSessionManager;
 
48
 
 
49
class JabSession : public QObject
 
50
{
 
51
        Q_OBJECT
 
52
 
 
53
public:
 
54
        JabSession(JabSessionManager *par);
 
55
        ~JabSession();
 
56
 
 
57
        bool isActive() { return v_isActive; }
 
58
        void setActive(bool b) { v_isActive = b; }
 
59
 
 
60
        void setAccount(const UserAccount &);
 
61
        void setContactProfile(ContactProfile *);
 
62
 
 
63
        Jabber *serv() { return &v_serv; }
 
64
        UserAccount *acc() { return &v_acc; }
 
65
        ContactProfile *cp() { return v_cp; }
 
66
 
 
67
        const QString &name() { return v_acc.name; }
 
68
 
 
69
        void conn();
 
70
        void disc(bool fast=FALSE);
 
71
 
 
72
        void setStatus(const StatusInfo &);
 
73
 
 
74
        UserList userlist;
 
75
        int localStatus;
 
76
        QString localStatusString;
 
77
        bool usingAutoStatus;
 
78
        bool isDisconnecting; // flag during user-initiated disconnect
 
79
        bool onEventOnlineOk;
 
80
        StatusInfo loginAs;
 
81
 
 
82
signals:
 
83
        void connected();
 
84
        void disconnected();
 
85
 
 
86
        void statusUpdate(JabUpdate *);
 
87
        void error(JabError *);
 
88
 
 
89
        void messageReceived(const JabMessage &);
 
90
 
 
91
        void resourceAvailable(const Jid &, const JabResource &);
 
92
        void resourceUnavailable(const Jid &);
 
93
 
 
94
        void contactChanged(JabRosterEntry *);
 
95
        void contactNew(JabRosterEntry *);
 
96
        void contactRemove(JabRosterEntry *);
 
97
 
 
98
        void authRequest(const Jid &from);
 
99
        void authGrant(const Jid &from);
 
100
        void authRemove(const Jid &from);
 
101
 
 
102
public slots:
 
103
        void secondsIdle(int);
 
104
        void update(bool);
 
105
 
 
106
private slots:
 
107
        void slotDisconnected();
 
108
 
 
109
private:
 
110
        bool v_isActive;
 
111
        Jabber v_serv;
 
112
        UserAccount v_acc;
 
113
        ContactProfile *v_cp;
 
114
};
 
115
 
 
116
 
 
117
//
 
118
//  JabSessionManager - remaps class Jabber signals
 
119
//
 
120
 
 
121
class JabSessionManager : public QObject
 
122
{
 
123
        Q_OBJECT
 
124
 
 
125
public:
 
126
        JabSessionManager(QObject *par=0);
 
127
        ~JabSessionManager();
 
128
 
 
129
        void add(JabSession *);
 
130
        void clear();
 
131
        void manage();
 
132
        JabSession *find(const QString &);
 
133
        QPtrList<JabSession> getList() { return list; }
 
134
        void childUpdate(JabSession *);
 
135
 
 
136
signals:
 
137
        void sessionUpdate(JabSession *);
 
138
        void accountSettingsChanged();
 
139
 
 
140
        void jab_connected(JabSession *);
 
141
        void jab_disconnected(JabSession *);
 
142
        void jab_statusUpdate(JabSession *, JabUpdate *);
 
143
        void jab_error(JabSession *, JabError *);
 
144
        void jab_messageReceived(JabSession *, const JabMessage &);
 
145
        void jab_resourceAvailable(JabSession *, const Jid &, const JabResource &);
 
146
        void jab_resourceUnavailable(JabSession *, const Jid &);
 
147
        void jab_contactChanged(JabSession *, JabRosterEntry *);
 
148
        void jab_contactNew(JabSession *, JabRosterEntry *);
 
149
        void jab_contactRemove(JabSession *, JabRosterEntry *);
 
150
        void jab_authRequest(JabSession *, const Jid &);
 
151
        void jab_authGrant(JabSession *, const Jid &);
 
152
        void jab_authRemove(JabSession *, const Jid &);
 
153
 
 
154
public slots:
 
155
        void modify(const QString &);
 
156
        void modify(JabSession *);
 
157
 
 
158
private slots:
 
159
        void slotConnected();
 
160
        void slotDisconnected();
 
161
        void slotStatusUpdate(JabUpdate *);
 
162
        void slotError(JabError *);
 
163
        void slotMessageReceived(const JabMessage &);
 
164
        void slotResourceAvailable(const Jid &, const JabResource &);
 
165
        void slotResourceUnavailable(const Jid &);
 
166
        void slotContactChanged(JabRosterEntry *);
 
167
        void slotContactNew(JabRosterEntry *);
 
168
        void slotContactRemove(JabRosterEntry *);
 
169
        void slotAuthRequest(const Jid &);
 
170
        void slotAuthGrant(const Jid &);
 
171
        void slotAuthRemove(const Jid &);
 
172
 
 
173
private:
 
174
        QPtrList<JabSession> list;
 
175
};
 
176
 
 
177
#endif