00001 /* 00002 * Copyright (C) 2008-2011 The QXmpp developers 00003 * 00004 * Author: 00005 * Jeremy Lainé 00006 * 00007 * Source: 00008 * http://code.google.com/p/qxmpp 00009 * 00010 * This file is a part of QXmpp library. 00011 * 00012 * This library is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU Lesser General Public 00014 * License as published by the Free Software Foundation; either 00015 * version 2.1 of the License, or (at your option) any later version. 00016 * 00017 * This library is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 * Lesser General Public License for more details. 00021 * 00022 */ 00023 00024 #ifndef QXMPPCALLMANAGER_H 00025 #define QXMPPCALLMANAGER_H 00026 00027 #include <QObject> 00028 #include <QIODevice> 00029 #include <QMetaType> 00030 00031 #include "QXmppClientExtension.h" 00032 #include "QXmppLogger.h" 00033 00034 class QXmppCallPrivate; 00035 class QXmppCallManagerPrivate; 00036 class QXmppIq; 00037 class QXmppJingleCandidate; 00038 class QXmppJingleIq; 00039 class QXmppJinglePayloadType; 00040 class QXmppRtpChannel; 00041 00048 00049 class QXmppCall : public QXmppLoggable 00050 { 00051 Q_OBJECT 00052 00053 public: 00055 enum Direction 00056 { 00057 IncomingDirection, 00058 OutgoingDirection, 00059 }; 00060 00062 enum State 00063 { 00064 OfferState = 0, 00065 ConnectingState = 1, 00066 ActiveState = 2, 00067 DisconnectingState = 3, 00068 FinishedState = 4, 00069 }; 00070 00071 ~QXmppCall(); 00072 00073 QXmppCall::Direction direction() const; 00074 QString jid() const; 00075 QString sid() const; 00076 QXmppCall::State state() const; 00077 00078 QXmppRtpChannel *audioChannel() const; 00079 00080 signals: 00086 void connected(); 00087 00092 void finished(); 00093 00095 void localCandidatesChanged(); 00097 00099 void ringing(); 00100 00102 void stateChanged(QXmppCall::State state); 00103 00104 public slots: 00105 void accept(); 00106 void hangup(); 00107 00108 private slots: 00109 void terminate(); 00110 void terminated(); 00111 void updateOpenMode(); 00112 00113 private: 00114 QXmppCall(const QString &jid, QXmppCall::Direction direction, QObject *parent); 00115 00116 QXmppCallPrivate *d; 00117 friend class QXmppCallManager; 00118 friend class QXmppCallManagerPrivate; 00119 friend class QXmppCallPrivate; 00120 }; 00121 00142 00143 class QXmppCallManager : public QXmppClientExtension 00144 { 00145 Q_OBJECT 00146 00147 public: 00148 QXmppCallManager(); 00149 ~QXmppCallManager(); 00150 QXmppCall *call(const QString &jid); 00151 00153 QStringList discoveryFeatures() const; 00154 bool handleStanza(const QDomElement &element); 00156 00157 signals: 00162 void callReceived(QXmppCall *call); 00163 00164 protected: 00166 void setClient(QXmppClient* client); 00168 00169 private slots: 00170 void callDestroyed(QObject *object); 00171 void callStateChanged(QXmppCall::State state); 00172 void iqReceived(const QXmppIq &iq); 00173 void jingleIqReceived(const QXmppJingleIq &iq); 00174 void localCandidatesChanged(); 00175 00176 private: 00177 QXmppCallManagerPrivate *d; 00178 friend class QXmppCallManagerPrivate; 00179 }; 00180 00181 Q_DECLARE_METATYPE(QXmppCall::State) 00182 00183 #endif