00001
00023 #ifndef _TelepathyQt4_simple_stream_tube_handler_h_HEADER_GUARD_
00024 #define _TelepathyQt4_simple_stream_tube_handler_h_HEADER_GUARD_
00025
00026 #include <TelepathyQt4/AbstractClientHandler>
00027 #include <TelepathyQt4/ChannelRequestHints>
00028 #include <TelepathyQt4/RefCounted>
00029 #include <TelepathyQt4/Types>
00030
00031 #include <QDateTime>
00032 #include <QLinkedList>
00033 #include <QHash>
00034 #include <QQueue>
00035 #include <QSet>
00036
00037 namespace Tp
00038 {
00039
00040 class PendingOperation;
00041
00042 class TELEPATHY_QT4_NO_EXPORT SimpleStreamTubeHandler : public QObject,
00043 public AbstractClientHandler
00044 {
00045 Q_OBJECT
00046 Q_DISABLE_COPY(SimpleStreamTubeHandler)
00047
00048 public:
00049 static SharedPtr<SimpleStreamTubeHandler> create(
00050 const QStringList &p2pServices,
00051 const QStringList &roomServices,
00052 bool requested,
00053 bool monitorConnections,
00054 bool bypassApproval = false);
00055 ~SimpleStreamTubeHandler();
00056
00057 bool monitorsConnections() const
00058 {
00059 return mMonitorConnections;
00060 }
00061
00062 bool bypassApproval() const
00063 {
00064 return mBypassApproval;
00065 }
00066
00067 void handleChannels(const MethodInvocationContextPtr<> &context,
00068 const AccountPtr &account,
00069 const ConnectionPtr &connection,
00070 const QList<ChannelPtr> &channels,
00071 const QList<ChannelRequestPtr> &requestsSatisfied,
00072 const QDateTime &userActionTime,
00073 const HandlerInfo &handlerInfo);
00074
00075 Q_SIGNALS:
00076 void invokedForTube(
00077 const Tp::AccountPtr &account,
00078 const Tp::StreamTubeChannelPtr &tube,
00079 const QDateTime &userActionTime,
00080 const Tp::ChannelRequestHints &requestHints);
00081 void tubeInvalidated(
00082 const Tp::AccountPtr &account,
00083 const Tp::StreamTubeChannelPtr &tube,
00084 const QString &errorName,
00085 const QString &errorMessage);
00086
00087 private Q_SLOTS:
00088 void onReadyOpFinished(Tp::PendingOperation *);
00089 void onTubeInvalidated(Tp::DBusProxy *, const QString &, const QString &);
00090
00091 private:
00092 SimpleStreamTubeHandler(
00093 const QStringList &p2pServices,
00094 const QStringList &roomServices,
00095 bool requested,
00096 bool monitorConnections,
00097 bool bypassApproval);
00098
00099 bool mMonitorConnections;
00100
00101 struct InvocationData : RefCounted {
00102 InvocationData() : readyOp(0) {}
00103
00104 PendingOperation *readyOp;
00105 QString error, message;
00106
00107 MethodInvocationContextPtr<> ctx;
00108 AccountPtr acc;
00109 QList<StreamTubeChannelPtr> tubes;
00110 QDateTime time;
00111 ChannelRequestHints hints;
00112 };
00113 QLinkedList<SharedPtr<InvocationData> > mInvocations;
00114 QHash<StreamTubeChannelPtr, AccountPtr> mTubes;
00115 bool mBypassApproval;
00116 };
00117
00118 }
00119
00120 #endif