3#include "IceSignalQxmpp.h"
5#include <QCoreApplication>
7int g_CIceSignalQXmppIq = qRegisterMetaType<CIceSignalQXmppIq>(
"CIceSignalQXmppIq");
9CIceSignalQxmpp::CIceSignalQxmpp(QObject *parent)
16 m_Client.addExtension(&m_Manager);
18 check = connect(&m_Client, SIGNAL(connected()),
19 this, SIGNAL(sigConnected()));
21 check = connect(&m_Client, SIGNAL(disconnected()),
22 this, SIGNAL(sigDisconnected()));
24 check = connect(&m_Client, SIGNAL(error(QXmppClient::Error)),
25 this, SLOT(slotError(QXmppClient::Error)));
33int CIceSignalQxmpp::Open(
const QString &szServer, quint16 nPort,
const QString &user,
const QString &password)
35 QXmppConfiguration conf;
37 if(QXmppUtils::jidToDomain(user).isEmpty())
39 QString szMsg =
"The user name is error. please use format: user@domain/resource";
40 qCritical(m_Log) << szMsg;
41 emit sigError(-100, szMsg);
44 if(QXmppUtils::jidToResource(user).isEmpty())
46 qWarning(m_Log) <<
"The user name is error. please use format: user@domain/resource";
47 conf.setResource(qApp->applicationName()
48 #
if defined(Q_OS_ANDROID)
50 #elif defined(Q_OS_LINUX)
52 #elif defined(Q_OS_WIN)
54 #elif defined(Q_OS_OSX)
56 #elif defined(Q_OS_IOS)
62 conf.setHost(szServer);
65 conf.setPassword(password);
71 m_Client.connectToServer(conf);
75int CIceSignalQxmpp::Close()
77 m_Client.disconnectFromServer();
81bool CIceSignalQxmpp::IsConnected()
83 return m_Client.isConnected();
92 if(iq.SignalType() ==
"offer")
102 }
else if(iq.SignalType() ==
"answer") {
111 }
else if (iq.SignalType() ==
"candidate") {
122 qCritical(m_Log) <<
"iq type error:" << iq.SignalType();
128int CIceSignalQxmpp::SendDescription(
const QString &toUser,
129 const QString &channelId,
130 const rtc::Description &description,
131 const QString &fromUser)
134 iq.setType(QXmppIq::Set);
136 iq.setChannelId(channelId);
137 iq.setSignalType(description.typeString().c_str());
138 iq.setDescription(std::string(description).c_str());
139 emit sigSendPackage(iq);
143int CIceSignalQxmpp::SendCandidate(
const QString &toUser,
144 const QString &channelId,
145 const rtc::Candidate &candidate,
146 const QString &fromUser)
149 iq.setType(QXmppIq::Set);
151 iq.setChannelId(channelId);
152 iq.setSignalType(
"candidate");
153 iq.setMid(candidate.mid().c_str());
154 iq.setCandidate(std::string(candidate).c_str());
155 emit sigSendPackage(iq);
161 m_Manager.sendPacket(iq);
164void CIceSignalQxmpp::slotError(QXmppClient::Error e)
168 case QXmppClient::Error::SocketError:
169 szError = tr(
"Socket error");
171 case QXmppClient::Error::KeepAliveError:
172 szError = tr(
"Keep alive error");
174 case QXmppClient::Error::XmppStreamError:
175 szError = tr(
"xmpp stream error");
180 qCritical(m_Log) <<
"Error:" << szError;
181 emit sigError(e, szError);
The ICE signal interface class.
void sigOffer(const QString &fromUser, const QString &toUser, const QString &channelId, const QString &type, const QString &sdp)
sigOffer
void sigDescription(const QString &fromUser, const QString &toUser, const QString &channelId, const QString &type, const QString &sdp)
sigDescription
void sigCandidate(const QString &fromUser, const QString &toUser, const QString &channelId, const QString &mid, const QString &sdp)
sigCandiate