~ubuntu-branches/ubuntu/utopic/psi/utopic

« back to all changes in this revision

Viewing changes to iris/src/xmpp/xmpp-core/securestream.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * securestream.h - combines a ByteStream with TLS and SASL
 
3
 * Copyright (C) 2004  Justin Karneges
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2.1 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library 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 GNU
 
13
 * Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public
 
16
 * License along with this library; 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 SECURESTREAM_H
 
22
#define SECURESTREAM_H
 
23
 
 
24
#include <qca.h>
 
25
#include "bytestream.h"
 
26
 
 
27
#define USE_TLSHANDLER
 
28
 
 
29
#ifdef USE_TLSHANDLER
 
30
namespace XMPP
 
31
{
 
32
        class TLSHandler;
 
33
}
 
34
#endif
 
35
 
 
36
class CompressionHandler;
 
37
 
 
38
class SecureStream : public ByteStream
 
39
{
 
40
        Q_OBJECT
 
41
public:
 
42
        enum Error { ErrTLS = ErrCustom, ErrSASL };
 
43
        SecureStream(ByteStream *s);
 
44
        ~SecureStream();
 
45
 
 
46
        void startTLSClient(QCA::TLS *t, const QByteArray &spare=QByteArray());
 
47
        void startTLSServer(QCA::TLS *t, const QByteArray &spare=QByteArray());
 
48
        void setLayerCompress(const QByteArray &spare=QByteArray());
 
49
        void setLayerSASL(QCA::SASL *s, const QByteArray &spare=QByteArray());
 
50
#ifdef USE_TLSHANDLER
 
51
        void startTLSClient(XMPP::TLSHandler *t, const QString &server, const QByteArray &spare=QByteArray());
 
52
#endif
 
53
 
 
54
        void closeTLS();
 
55
        int errorCode() const;
 
56
 
 
57
        // reimplemented
 
58
        bool isOpen() const;
 
59
        void write(const QByteArray &);
 
60
        int bytesToWrite() const;
 
61
 
 
62
signals:
 
63
        void tlsHandshaken();
 
64
        void tlsClosed();
 
65
 
 
66
private slots:
 
67
        void bs_readyRead();
 
68
        void bs_bytesWritten(int);
 
69
 
 
70
        void layer_tlsHandshaken();
 
71
        void layer_tlsClosed(const QByteArray &);
 
72
        void layer_readyRead(const QByteArray &);
 
73
        void layer_needWrite(const QByteArray &);
 
74
        void layer_error(int);
 
75
 
 
76
private:
 
77
        void linkLayer(QObject *);
 
78
        int calcPrebytes() const;
 
79
        void insertData(const QByteArray &a);
 
80
        void writeRawData(const QByteArray &a);
 
81
        void incomingData(const QByteArray &a);
 
82
 
 
83
        class Private;
 
84
        Private *d;
 
85
};
 
86
 
 
87
#endif