2
* Copyright (C) 2009 Barracuda Networks, Inc.
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.
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.
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
21
#ifndef STUNTRANSACTION_H
22
#define STUNTRANSACTION_H
35
class StunTransaction : public QObject
42
Udp, // handle retransmissions
52
StunTransaction(QObject *parent = 0);
55
// pass a message with transaction id unset. it will be filled in.
56
// after calling this function, immediately obtain the result by
57
// calling packet(), and send it. the start() function will not
58
// perform the first send attempt. it leaves that to you.
59
// FIXME: stuser/stpass are a hack
60
void start(Mode mode, const StunMessage &request, const QString &stuser = QString(), const QString &stpass = QString());
62
QByteArray transactionId() const;
63
QByteArray packet() const;
65
// transmission/timeout parameters, from RFC 5389. by default,
66
// they are set to the recommended values from the RFC.
72
// note: not DOR-DS safe. this will either emit signals and return
73
// true, or not emit signals and return false.
74
bool writeIncomingMessage(const StunMessage &msg);
77
// indicates you should retransmit the value of packet()
79
void finished(const XMPP::StunMessage &response);
80
void error(XMPP::StunTransaction::Error error);
83
Q_DISABLE_COPY(StunTransaction)
90
// keep track of many open transactions. note that retransmit() may be
91
// emitted as a direct result of calling certain member functions of this
92
// class as well as any other class that might use it (such as StunBinding).
93
// so, be careful with what you do in your retransmit slot.
94
class StunTransactionPool : public QObject
99
StunTransactionPool(StunTransaction::Mode mode, QObject *parent = 0);
100
~StunTransactionPool();
102
StunTransaction::Mode mode() const;
104
// generate a random id not used by any transaction in the pool
105
QByteArray generateId() const;
107
// you must start the transaction before inserting it.
108
// note: not DOR-DS safe. this function will cause retransmit() to be
110
void insert(StunTransaction *trans);
112
void remove(StunTransaction *trans);
114
// note: not DOR-DS safe. this will either cause transactions to emit
115
// signals and return true, or not cause signals and return false.
116
bool writeIncomingMessage(const StunMessage &msg);
118
QString realm() const;
119
void setUsername(const QString &username);
120
void setPassword(const QCA::SecureArray &password);
121
void setRealm(const QString &realm);
123
void setShortTermCredentialsEnabled(bool enabled);
124
void continueAfterParams();
126
QString username() const;
127
QString password() const;
130
// note: not DOR-SS safe. writeIncomingMessage() must not be called
131
// during this signal.
132
void retransmit(XMPP::StunTransaction *trans);
134
void needAuthParams();
137
Q_DISABLE_COPY(StunTransactionPool)
140
friend class Private;