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

« back to all changes in this revision

Viewing changes to iris/src/irisnet/noncore/icelocaltransport.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
 * Copyright (C) 2009  Barracuda Networks, Inc.
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2.1 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
17
 * 02110-1301  USA
 
18
 *
 
19
 */
 
20
 
 
21
#ifndef ICELOCALTRANSPORT_H
 
22
#define ICELOCALTRANSPORT_H
 
23
 
 
24
#include <QObject>
 
25
#include <QByteArray>
 
26
 
 
27
class QHostAddress;
 
28
 
 
29
namespace QCA {
 
30
        class SecureArray;
 
31
}
 
32
 
 
33
namespace XMPP {
 
34
 
 
35
// this class manages a single port on a single interface, including the
 
36
//   relationship with an associated STUN/TURN server.  if TURN is used, this
 
37
//   class offers two UDP channels (direct or relayed), otherwise it offers
 
38
//   just one UDP channel (direct).
 
39
class IceLocalTransport : public QObject
 
40
{
 
41
        Q_OBJECT
 
42
 
 
43
public:
 
44
        enum Error
 
45
        {
 
46
                ErrorGeneric
 
47
        };
 
48
 
 
49
        enum StunServiceType
 
50
        {
 
51
                Basic,
 
52
                Relay
 
53
        };
 
54
 
 
55
        enum TransmitPath
 
56
        {
 
57
                Direct,
 
58
                Relayed
 
59
        };
 
60
 
 
61
        IceLocalTransport(QObject *parent = 0);
 
62
        ~IceLocalTransport();
 
63
 
 
64
        void start(const QHostAddress &addr, int port = -1);
 
65
        void stop();
 
66
 
 
67
        void setStunService(StunServiceType type, const QHostAddress &addr, int port);
 
68
        void setStunUsername(const QString &user);
 
69
        void setStunPassword(const QCA::SecureArray &pass);
 
70
 
 
71
        // obtain relay / reflexive
 
72
        void stunStart();
 
73
 
 
74
        QHostAddress localAddress() const;
 
75
        int localPort() const;
 
76
 
 
77
        QHostAddress serverReflexiveAddress() const;
 
78
        int serverReflexivePort() const;
 
79
 
 
80
        QHostAddress relayedAddress() const;
 
81
        int relayedPort() const;
 
82
 
 
83
        bool hasPendingDatagrams(TransmitPath path) const;
 
84
        QByteArray readDatagram(TransmitPath path, QHostAddress *addr, int *port);
 
85
        void writeDatagram(TransmitPath path, const QByteArray &buf, const QHostAddress &addr, int port);
 
86
 
 
87
signals:
 
88
        void started();
 
89
        void stopped();
 
90
        void stunFinished();
 
91
        void error(XMPP::IceLocalTransport::Error e);
 
92
 
 
93
        void readyRead(XMPP::IceLocalTransport::TransmitPath path);
 
94
        void datagramsWritten(XMPP::IceLocalTransport::TransmitPath path, int count);
 
95
 
 
96
private:
 
97
        class Private;
 
98
        friend class Private;
 
99
        Private *d;
 
100
};
 
101
 
 
102
}
 
103
 
 
104
#endif