Home · Modules · All Classes · All Namespaces
stream-tube-client.h
1 
23 #ifndef _TelepathyQt_stream_tube_client_h_HEADER_GUARD_
24 #define _TelepathyQt_stream_tube_client_h_HEADER_GUARD_
25 
26 #include <TelepathyQt/AccountFactory>
27 #include <TelepathyQt/ChannelFactory>
28 #include <TelepathyQt/ConnectionFactory>
29 #include <TelepathyQt/ContactFactory>
30 #include <TelepathyQt/RefCounted>
31 #include <TelepathyQt/Types>
32 
33 class QHostAddress;
34 
35 namespace Tp
36 {
37 
38 class PendingStreamTubeConnection;
39 
40 class TP_QT_EXPORT StreamTubeClient : public QObject, public RefCounted
41 {
42  Q_OBJECT
43  Q_DISABLE_COPY(StreamTubeClient)
44 
45  class TubeWrapper;
46 
47 public:
48 
50  {
51  public:
52  virtual QPair<QHostAddress, quint16>
53  nextSourceAddress(const AccountPtr &account, const IncomingStreamTubeChannelPtr &tube) = 0;
54 
55  protected:
57  };
58 
59  class Tube : public QPair<AccountPtr, IncomingStreamTubeChannelPtr>
60  {
61  public:
62  Tube();
63  Tube(const AccountPtr &account, const IncomingStreamTubeChannelPtr &channel);
64  Tube(const Tube &other);
65  ~Tube();
66 
67  bool isValid() const { return mPriv.constData() != 0; }
68 
69  Tube &operator=(const Tube &other);
70 
71  const AccountPtr &account() const
72  {
73  return first;
74  }
75 
76  const IncomingStreamTubeChannelPtr &channel() const
77  {
78  return second;
79  }
80 
81  private:
82  struct Private;
83  friend struct Private;
84  QSharedDataPointer<Private> mPriv;
85  };
86 
87  static StreamTubeClientPtr create(
88  const QStringList &p2pServices,
89  const QStringList &roomServices = QStringList(),
90  const QString &clientName = QString(),
91  bool monitorConnections = false,
92  bool bypassApproval = false,
93  const AccountFactoryConstPtr &accountFactory =
94  AccountFactory::create(QDBusConnection::sessionBus()),
95  const ConnectionFactoryConstPtr &connectionFactory =
96  ConnectionFactory::create(QDBusConnection::sessionBus()),
97  const ChannelFactoryConstPtr &channelFactory =
98  ChannelFactory::create(QDBusConnection::sessionBus()),
99  const ContactFactoryConstPtr &contactFactory =
101 
102  static StreamTubeClientPtr create(
103  const QDBusConnection &bus,
104  const AccountFactoryConstPtr &accountFactory,
105  const ConnectionFactoryConstPtr &connectionFactory,
106  const ChannelFactoryConstPtr &channelFactory,
107  const ContactFactoryConstPtr &contactFactory,
108  const QStringList &p2pServices,
109  const QStringList &roomServices = QStringList(),
110  const QString &clientName = QString(),
111  bool monitorConnections = false,
112  bool bypassApproval = false);
113 
114  static StreamTubeClientPtr create(
115  const AccountManagerPtr &accountManager,
116  const QStringList &p2pServices,
117  const QStringList &roomServices = QStringList(),
118  const QString &clientName = QString(),
119  bool monitorConnections = false,
120  bool bypassApproval = false);
121 
122  static StreamTubeClientPtr create(
123  const ClientRegistrarPtr &registrar,
124  const QStringList &p2pServices,
125  const QStringList &roomServices = QStringList(),
126  const QString &clientName = QString(),
127  bool monitorConnections = false,
128  bool bypassApproval = false);
129 
130  virtual ~StreamTubeClient();
131 
132  ClientRegistrarPtr registrar() const;
133  QString clientName() const;
134  bool isRegistered() const;
135  bool monitorsConnections() const;
136 
137  bool acceptsAsTcp() const;
138  TcpSourceAddressGenerator *tcpGenerator() const;
139  bool acceptsAsUnix() const;
140 
141  void setToAcceptAsTcp(TcpSourceAddressGenerator *generator = 0);
142  void setToAcceptAsUnix(bool requireCredentials = false);
143 
144  QList<Tube> tubes() const;
145  QHash<Tube, QSet<uint> > connections() const;
146 
147 Q_SIGNALS:
148  void tubeOffered(
149  const Tp::AccountPtr &account,
150  const Tp::IncomingStreamTubeChannelPtr &tube);
151  void tubeClosed(
152  const Tp::AccountPtr &account,
153  const Tp::IncomingStreamTubeChannelPtr &tube,
154  const QString &error,
155  const QString &message);
156 
157  void tubeAcceptedAsTcp(
158  const QHostAddress &listenAddress,
159  quint16 listenPort,
160  const QHostAddress &sourceAddress,
161  quint16 sourcePort,
162  const Tp::AccountPtr &account,
163  const Tp::IncomingStreamTubeChannelPtr &tube);
164  void tubeAcceptedAsUnix(
165  const QString &listenAddress,
166  bool requiresCredentials,
167  uchar credentialByte,
168  const Tp::AccountPtr &account,
169  const Tp::IncomingStreamTubeChannelPtr &tube);
170 
171  void newConnection(
172  const Tp::AccountPtr &account,
173  const Tp::IncomingStreamTubeChannelPtr &tube,
174  uint connectionId);
175  void connectionClosed(
176  const Tp::AccountPtr &account,
177  const Tp::IncomingStreamTubeChannelPtr &tube,
178  uint connectionId,
179  const QString &error,
180  const QString &message);
181 
182 private Q_SLOTS:
183 
184  TP_QT_NO_EXPORT void onInvokedForTube(
185  const Tp::AccountPtr &account,
186  const Tp::StreamTubeChannelPtr &tube,
187  const QDateTime &userActionTime,
188  const Tp::ChannelRequestHints &requestHints);
189 
190  TP_QT_NO_EXPORT void onAcceptFinished(TubeWrapper *, Tp::PendingStreamTubeConnection *);
191  TP_QT_NO_EXPORT void onTubeInvalidated(Tp::DBusProxy *, const QString &, const QString &);
192 
193  TP_QT_NO_EXPORT void onNewConnection(
194  TubeWrapper *wrapper,
195  uint conn);
196  TP_QT_NO_EXPORT void onConnectionClosed(
197  TubeWrapper *wrapper,
198  uint conn,
199  const QString &error,
200  const QString &message);
201 
202 private:
203  TP_QT_NO_EXPORT StreamTubeClient(
204  const ClientRegistrarPtr &registrar,
205  const QStringList &p2pServices,
206  const QStringList &roomServices,
207  const QString &clientName,
208  bool monitorConnections,
209  bool bypassApproval);
210 
211  struct Private;
212  Private *mPriv;
213 };
214 
215 } // Tp
216 
217 #endif
static ConnectionFactoryPtr create(const QDBusConnection &bus, const Features &features=Features())
Definition: connection-factory.cpp:57
const IncomingStreamTubeChannelPtr & channel() const
Definition: stream-tube-client.h:76
The PendingStreamTubeConnection class represents an asynchronous operation for accepting an incoming ...
Definition: pending-stream-tube-connection.h:43
static ContactFactoryPtr create(const Features &features=Features())
Definition: contact-factory.cpp:48
static AccountFactoryPtr create(const QDBusConnection &bus, const Features &features=Features())
Definition: account-factory.cpp:58
const AccountPtr & account() const
Definition: stream-tube-client.h:71
The StreamTubeClient::Tube class represents a tube being handled by the client.
Definition: stream-tube-client.h:59
virtual ~TcpSourceAddressGenerator()
Definition: stream-tube-client.h:56
The ChannelRequestHints class represents a dictionary of metadata provided by the channel requester w...
Definition: channel-request.h:121
The RefCounted class is a base class for shared objects used by SharedPtr.
Definition: shared-ptr.h:42
bool isValid() const
Definition: stream-tube-client.h:67
The StreamTubeClient::TcpSourceAddressGenerator abstract interface allows using socket source address...
Definition: stream-tube-client.h:49
static ChannelFactoryPtr create(const QDBusConnection &bus)
Definition: channel-factory.cpp:86
Definition: abstract-adaptor.cpp:31
The StreamTubeClient class is a Handler implementation for incoming Stream Tube channels,...
Definition: stream-tube-client.h:40
The DBusProxy class is a base class representing a remote object available over D-Bus.
Definition: dbus-proxy.h:42