Exemple #1
0
void JingleVoiceCaller::call(const Jid& jid)
{
	qDebug(QString("jinglevoicecaller.cpp: Calling %1").arg(jid.full()));
	cricket::Call *c = ((cricket::PhoneSessionClient*)(phone_client_))->CreateCall();
	c->InitiateSession(buzz::Jid(jid.full().ascii()));
	phone_client_->SetFocus(c);
}
void MessageCarbons::stanzaRequestResult(const Jid &AStreamJid, const Stanza &AStanza)
{
	if (AStanza.type() == "result")
	{
		if (FEnableRequests.contains(AStanza.id()))
		{
			LogDetaile(QString("[MessageCarbons] Message Carbons enabled for '%1'").arg(AStreamJid.full()));
			FEnabled[AStreamJid] = true;
			emit enableChanged(AStreamJid,true);
		}
		else if(FDisableRequests.contains(AStanza.id()))
		{
			LogDetaile(QString("[MessageCarbons] Message Carbons disabled for '%1'").arg(AStreamJid.full()));
			FEnabled[AStreamJid] = false;
			emit enableChanged(AStreamJid,false);
		}
	}
	else
	{
		ErrorHandler err(AStanza.element());
		LogError(QString("[MessageCarbons] Failed to change Message Carbons state for '%1': %2").arg(AStreamJid.full(),err.message()));
		emit errorReceived(AStreamJid,err.condition(),err.message());
	}
	FEnableRequests.removeAll(AStanza.id());
	FDisableRequests.removeAll(AStanza.id());
}
Exemple #3
0
void JingleVoiceCaller::reject(const Jid& j)
{
	qDebug("jinglevoicecaller.cpp: Rejecting call");
	cricket::Call* call = calls_[j.full()];
	if (call != NULL) {
		call->RejectSession(call->sessions()[0]);
		calls_.remove(j.full());
	}
}
Exemple #4
0
void JingleVoiceCaller::terminate(const Jid& j)
{
	qDebug(QString("jinglevoicecaller.cpp: Terminating call to %1").arg(j.full()));
	cricket::Call* call = calls_[j.full()];
	if (call != NULL) {
		call->Terminate();
		calls_.remove(j.full());
	}
}
Exemple #5
0
void JingleVoiceCaller::registerCall(const Jid& jid, cricket::Call* call)
{
	qDebug("jinglevoicecaller.cpp: Registering call\n");
	if (!calls_.contains(jid.full())) {
		calls_[jid.full()] = call;
	}
	else {
		qWarning("jinglevoicecaller.cpp: Auto-rejecting call because another call is currently open");
		call->RejectSession(call->sessions()[0]);
	}
}
Exemple #6
0
void JingleVoiceCaller::registerCall(const Jid& jid, cricket::Call* call)
{
	qDebug("jinglevoicecaller.cpp: Registering call\n");
	kdDebug(14000) << k_funcinfo << jid.full() << endl;
	if (!calls_.contains(jid.full())) {
		calls_[jid.full()] = call;
	}
// 	else {
// 		qWarning("jinglevoicecaller.cpp: Auto-rejecting call because another call is currently open");
// 		call->RejectSession(call->sessions()[0]);
// 	}
}
Exemple #7
0
bool MultiUserChat::inviteContact(const Jid &AContactJid, const QString &AReason)
{
	if (FStanzaProcessor && isOpen())
	{
		Message message;
		message.setTo(FRoomJid.bare());

		Stanza &mstanza = message.stanza();
		QDomElement invElem = mstanza.addElement("x",NS_MUC_USER).appendChild(mstanza.createElement("invite")).toElement();
		invElem.setAttribute("to",AContactJid.full());
		if (!AReason.isEmpty())
			invElem.appendChild(mstanza.createElement("reason")).appendChild(mstanza.createTextNode(AReason));

		if (FStanzaProcessor->sendStanzaOut(FStreamJid, mstanza))
		{
			LOG_STRM_INFO(FStreamJid,QString("Conference invite request sent, room=%1, contact=%2").arg(FRoomJid.bare(),AContactJid.full()));
			return true;
		}
		else
		{
			LOG_STRM_WARNING(FStreamJid,QString("Failed to send conference invite request, room=%1, contact=%2").arg(FRoomJid.bare(),AContactJid.full()));
		}
	}
	return false;
}
Exemple #8
0
bool MultiUserChat::sendMessage(const Message &AMessage, const QString &AToNick)
{
	if (isOpen())
	{
		Jid toJid = FRoomJid;
		toJid.setResource(AToNick);

		Message message = AMessage;
		message.setTo(toJid.full());
		message.setType(AToNick.isEmpty() ? Message::GroupChat : Message::Chat);

		if (FMessageProcessor)
		{
			if (FMessageProcessor->sendMessage(FStreamJid,message,IMessageProcessor::DirectionOut))
				return true;
			else
				LOG_STRM_WARNING(FStreamJid,QString("Failed to send message to conference, room=%1").arg(FRoomJid.bare()));
		}
		else if (FStanzaProcessor)
		{
			if (FStanzaProcessor->sendStanzaOut(FStreamJid, message.stanza()))
			{
				emit messageSent(message);
				return true;
			}
			else
			{
				LOG_STRM_WARNING(FStreamJid,QString("Failed to send message to conference, room=%1").arg(FRoomJid.bare()));
			}
		}
	}
	return false;
}
Exemple #9
0
void JT_HTTPFileUpload::request(const Jid &to, const QString &fname,
                                quint64 fsize, const QString &ftype, XEP0363::version ver)
{
    d->to = to;
    d->ver = ver;
    d->iq = createIQ(doc(), "get", to.full(), id());
    QDomElement req = doc()->createElement("request");
    switch (ver)
    {
    case XEP0363::v0_2_5:
        req.setAttribute("xmlns", xmlns_v0_2_5);
        req.appendChild(textTag(doc(), "filename", fname));
        req.appendChild(textTag(doc(), "size", QString::number(fsize)));
        if (!ftype.isEmpty()) {
            req.appendChild(textTag(doc(), "content-type", ftype));
        }
        break;
    case XEP0363::v0_3_1:
        req.setAttribute("xmlns", xmlns_v0_3_1);
        req.setAttribute("filename", fname);
        req.setAttribute("size", fsize);
        if (!ftype.isEmpty())
            req.setAttribute("content-type", ftype);
        break;
    default:
        d->ver = XEP0363::vUnknown;
        break;
    }
    d->iq.appendChild(req);
}
Exemple #10
0
VoiceCallDlg::VoiceCallDlg(const Jid& jid, VoiceCaller* voiceCaller)
	: QDialog(0), jid_(jid), voiceCaller_(voiceCaller)
{
	setAttribute(Qt::WA_DeleteOnClose);
	ui_.setupUi(this);
	setModal(false);

	setWindowTitle(QString(tr("Voice Call (%1)")).arg(jid.full()));

	// Voice Caller signals
	connect(voiceCaller_,SIGNAL(accepted(const Jid&)),SLOT(accepted(const Jid&)));
	connect(voiceCaller_,SIGNAL(rejected(const Jid&)),SLOT(rejected(const Jid&)));
	connect(voiceCaller_,SIGNAL(in_progress(const Jid&)),SLOT(in_progress(const Jid&)));
	connect(voiceCaller_,SIGNAL(terminated(const Jid&)),SLOT(terminated(const Jid&)));

	// Buttons
	ui_.pb_hangup->setEnabled(false);
	ui_.pb_accept->setEnabled(false);
	ui_.pb_reject->setEnabled(false);

	connect(ui_.pb_hangup,SIGNAL(clicked()),SLOT(terminate_call()));
	connect(ui_.pb_accept,SIGNAL(clicked()),SLOT(accept_call()));
	connect(ui_.pb_reject,SIGNAL(clicked()),SLOT(reject_call()));
	
}
void SxeSession::processIncomingSxeElement(const QDomElement &sxe, const Jid &sender) {
    // create an SxeEdit for each child of the <sxe/>
    QDomNodeList children = sxe.childNodes();

    QList<SxeEdit*> edits;
    for(uint i=0; i < children.length(); i++) {
        if(children.item(i).nodeName() == "new")
            edits.append(new SxeNewEdit(children.item(i).toElement()));
        else if(children.item(i).nodeName() == "set")
            edits.append(new SxeRecordEdit(children.item(i).toElement()));
        else if(children.item(i).nodeName() == "remove")
            edits.append(new SxeRemoveEdit(children.item(i).toElement()));
    }

    
    if(queueing_ && !importing_) {
        // store incoming edits when queueing (unless importing)
        QString sxeid = sxe.attribute("id");
        QString senderfull = sender.full();

        foreach(SxeEdit* e, edits) {
            IncomingEdit incoming;
            incoming.sxeid = sxeid;
            incoming.sender = senderfull;
            incoming.edit = e;
            queuedIncomingEdits_.append(incoming);
        }
void JT_Roster::remove(const Jid &jid)
{
	type = 1;
	//to = client()->host();
	QDomElement item = doc()->createElement("item");
	item.setAttribute("jid", jid.full());
	item.setAttribute("subscription", "remove");
	d->itemList += item;
}
void JT_Register::setForm(const Jid& to, const XData& xdata)
{
	d->type = 4;
	iq = createIQ(doc(), "set", to.full(), id());
	QDomElement query = doc()->createElement("query");
	query.setAttribute("xmlns", "jabber:iq:register");
	iq.appendChild(query);
	query.appendChild(xdata.toXml(doc(), true));
}
void JabberResourceService::removeResource(const Jid &jid)
{
    auto it = std::find_if(std::begin(m_resources), std::end(m_resources), [&jid](const JabberResource &item) {
        return item.jid().full() == jid.full();
    });

    if (it != std::end(m_resources))
        m_resources.erase(it);
}
Exemple #15
0
void JingleVoiceCaller::accept(const Jid& j)
{
	qDebug("jinglevoicecaller.cpp: Accepting call");
	cricket::Call* call = calls_[j.full()];
	if (call != NULL) {
		call->AcceptSession(call->sessions()[0]);
		phone_client_->SetFocus(call);
	}
}
Exemple #16
0
QString JIDUtil::accountToString(const Jid& j, bool withResource)
{
	QString s = j.node();
// 	if (!defaultDomain().isEmpty()) {
// 		return (withResource && !j.resource().isEmpty() ? j.node() + "/" + j.resource() : j.node());
// 	}
// 	else {
		return (withResource ? j.full() : j.bare());
	//}
}
Exemple #17
0
QString JabberSearch::sendRequest(const Jid &AStreamJid, const Jid &AServiceJid)
{
    if (FStanzaProcessor)
    {
        Stanza request("iq");
        request.setTo(AServiceJid.full()).setType("get").setId(FStanzaProcessor->newId());
        request.addElement("query",NS_JABBER_SEARCH);
        if (FStanzaProcessor->sendStanzaRequest(this,AStreamJid,request,SEARCH_TIMEOUT))
        {
            LOG_STRM_INFO(AStreamJid,QString("Search request sent to=%1, id=%2").arg(AServiceJid.full(),request.id()));
            FRequests.append(request.id());
            return request.id();
        }
        else
        {
            LOG_STRM_WARNING(AStreamJid,QString("Failed to send search request to=%1").arg(AServiceJid.full()));
        }
    }
    return QString::null;
}
void JT_Roster::set(const Jid &jid, const QString &name, const QStringList &groups)
{
	type = 1;
	//to = client()->host();
	QDomElement item = doc()->createElement("item");
	item.setAttribute("jid", jid.full());
	if(!name.isEmpty())
		item.setAttribute("name", name);
	for(QStringList::ConstIterator it = groups.begin(); it != groups.end(); ++it)
		item.appendChild(textTag(doc(), "group", *it));
	d->itemList += item;
}
bool ClientInfo::requestLastActivity(const Jid &AStreamJid, const Jid &AContactJid)
{
	bool sent = FActivityId.values().contains(AContactJid);
	if (!sent && AStreamJid.isValid() && AContactJid.isValid())
	{
		Stanza iq(STANZA_KIND_IQ);
		iq.setType(STANZA_TYPE_GET).setTo(AContactJid.full()).setUniqueId();
		iq.addElement("query",NS_JABBER_LAST);
		sent = FStanzaProcessor->sendStanzaRequest(this,AStreamJid,iq,LAST_ACTIVITY_TIMEOUT);
		if (sent)
		{
			FActivityId.insert(iq.id(),AContactJid);
			LOG_STRM_INFO(AStreamJid,QString("Last activity request sent to=%1").arg(AContactJid.full()));
		}
		else
		{
			LOG_STRM_WARNING(AStreamJid,QString("Failed to send last activity request to=%1").arg(AContactJid.full()));
		}
	}
	return sent;
}
bool ClientInfo::requestSoftwareInfo(const Jid &AStreamJid, const Jid &AContactJid)
{
	bool sent = FSoftwareId.values().contains(AContactJid);
	if (!sent && AStreamJid.isValid() && AContactJid.isValid())
	{
		Stanza iq(STANZA_KIND_IQ);
		iq.setType(STANZA_TYPE_GET).setTo(AContactJid.full()).setUniqueId();
		iq.addElement("query",NS_JABBER_VERSION);
		sent = FStanzaProcessor->sendStanzaRequest(this,AStreamJid,iq,SOFTWARE_INFO_TIMEOUT);
		if (sent)
		{
			FSoftwareId.insert(iq.id(),AContactJid);
			FSoftwareItems[AContactJid].status = SoftwareLoading;
			LOG_STRM_INFO(AStreamJid,QString("Software version request sent to=%1").arg(AContactJid.full()));
		}
		else
		{
			LOG_STRM_WARNING(AStreamJid,QString("Failed to sent software request to=%1").arg(AContactJid.full()));
		}
	}
	return sent;
}
void JT_Register::unreg(const Jid &j)
{
	d->type = 2;
	to = j.isEmpty() ? client()->host() : j.full();
	iq = createIQ(doc(), "set", to.full(), id());
	QDomElement query = doc()->createElement("query");
	query.setAttribute("xmlns", "jabber:iq:register");
	iq.appendChild(query);

	// this may be useful
	if(!d->form.key().isEmpty())
		query.appendChild(textTag(doc(), "key", d->form.key()));

	query.appendChild(doc()->createElement("remove"));
}
bool ClientInfo::requestEntityTime(const Jid &AStreamJid, const Jid &AContactJid)
{
	bool sent = FTimeId.values().contains(AContactJid);
	if (!sent && AStreamJid.isValid() && AContactJid.isValid())
	{
		Stanza iq(STANZA_KIND_IQ);
		iq.setType(STANZA_TYPE_GET).setTo(AContactJid.full()).setUniqueId();
		iq.addElement("time",NS_XMPP_TIME);
		sent = FStanzaProcessor->sendStanzaRequest(this,AStreamJid,iq,ENTITY_TIME_TIMEOUT);
		if (sent)
		{
			TimeItem &tItem = FTimeItems[AContactJid];
			tItem.ping = QTime::currentTime().msecsTo(QTime(0,0,0,0));
			FTimeId.insert(iq.id(),AContactJid);
			LOG_STRM_INFO(AStreamJid,QString("Current time request sent to=%1").arg(AContactJid.full()));
			emit entityTimeChanged(AContactJid);
		}
		else
		{
			LOG_STRM_WARNING(AStreamJid,QString("Failed to send current time request to=%1").arg(AContactJid.full()));
		}
	}
	return sent;
}
Exemple #23
0
QString XmppUriQueries::makeXmppUri(const Jid &AContactJid, const QString &AAction, const QMultiMap<QString, QString> &AParams) const
{
	if (AContactJid.isValid() && !AAction.isEmpty())
	{
		QUrl url;
		url.setQueryDelimiters('=',';');

		url.setScheme(XMPP_URI_SCHEME);
		url.setPath(AContactJid.full());

		QList< QPair<QString, QString> > query;
		query.append(qMakePair<QString,QString>(AAction,QString::null));
		for(QMultiMap<QString, QString>::const_iterator it=AParams.constBegin(); it!=AParams.end(); ++it)
			query.append(qMakePair<QString,QString>(it.key(),it.value()));
		url.setQueryItems(query);

		return url.toString().replace(QString("?%1=;").arg(AAction),QString("?%1;").arg(AAction));
	}
	return QString::null;
}
Exemple #24
0
/*
 * Establish connection to the server.
 */
Xmpp::Xmpp(const Jid &jid, const QString &pServer, const int pPort)
{
	timeOut = 5000; // Default timeout set to 5 seconds
	tcpSocket = new QTcpSocket();
	sslSocket = new QSslSocket();
	sslSocket->setProtocol(QSsl::SslV3);
	connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError)));
	connect(sslSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError)));
	//connect(sslSocket, SIGNAL(sslErrors(const QList<QSslError> &errors)), this, SLOT(sslError(const QList<QSslError>& errors)));
	connect(sslSocket, SIGNAL(encrypted()), this, SLOT(socketEncrypted()));

	username = jid.node();
	server = jid.domain();

	if (pServer == "")
	{
		usePersonnalServer = false;
	}
	else
	{
		usePersonnalServer = true;
		personnalServer = pServer;
	}

	port = pPort;
	authenticated = false;
	isTlsing = false;
	tlsDone = false;
	saslDone = false;
	needBind = false;
	needSession = false;
	jidDone = false;
	useTls = true;
	connect(tcpSocket, SIGNAL(connected()), this, SLOT(start()));
	connect(sslSocket, SIGNAL(connected()), this, SLOT(start()));
	j = jid;
	printf("[XMPP] JID = %s\n", jid.full().toLatin1().constData());
}
Exemple #25
0
void JingleVoiceCaller::receiveStanza(const QString& stanza)
{
	QDomDocument doc;
	doc.setContent(stanza);

	// Check if it is offline presence from an open chat
	if (doc.documentElement().tagName() == "presence") {
		Jid from = Jid(doc.documentElement().attribute("from"));
		QString type = doc.documentElement().attribute("type");
		if (type == "unavailable" && calls_.contains(from.full())) {
			qDebug("JingleVoiceCaller: User went offline without closing a call.");
			removeCall(from);
			emit terminated(from);
		}
		return;
	}
	
	// Check if the packet is destined for libjingle.
	// We could use Session::IsClientStanza to check this, but this one crashes
	// for some reason.
	QDomNode n = doc.documentElement().firstChild();
	bool ok = false;
	while (!n.isNull() && !ok) {
		QDomElement e = n.toElement();
		if (!e.isNull() && e.attribute("xmlns") == JINGLE_NS) {
			ok = true;
		}
		n = n.nextSibling();
	}
	
	// Spread the word
	if (ok) {
		qDebug(QString("jinglevoicecaller.cpp: Handing down %1").arg(stanza));
		buzz::XmlElement *e = buzz::XmlElement::ForStr(stanza.ascii());
		phone_client_->OnIncomingStanza(e);
	}
}
void AddLegacyAccountOptions::appendServiceButton(const Jid &AServiceJid)
{
	IGateServiceDescriptor descriptor = FGateways->serviceDescriptor(FStreamJid,AServiceJid);
	if (!FWidgets.contains(AServiceJid) && !descriptor.id.isEmpty() && descriptor.needLogin)
	{
		QWidget *widget = new QWidget(ui.wdtGateways);
		widget->setObjectName("serviceContainer");
		//widget->setMinimumWidth(widget->fontMetrics().boundingRect("XXXXXXXXXXX").width());

		QVBoxLayout *wlayout = new QVBoxLayout;
		wlayout->setMargin(0);
		widget->setLayout(wlayout);

		QToolButton *button = new QToolButton(widget);
		button->setObjectName("serviceButton");
		button->setToolButtonStyle(Qt::ToolButtonIconOnly);
		button->setIconSize(QSize(32,32));

		QLabel *label = new QLabel(descriptor.name,widget);
		label->setObjectName("serviceName");
		label->setAlignment(Qt::AlignCenter);

		Action *action = new Action(button);
		action->setIcon(RSR_STORAGE_MENUICONS,descriptor.iconKey,0);
		action->setText(descriptor.name);
		action->setData(ADR_GATEJID,AServiceJid.full());
		connect(action,SIGNAL(triggered(bool)),SLOT(onGateActionTriggeted(bool)));
		button->setDefaultAction(action);

		wlayout->addWidget(button,0,Qt::AlignCenter);
		wlayout->addWidget(label,0,Qt::AlignCenter);
		FLayout->insertWidget(FLayout->count()-1, widget);

		FWidgets.insert(AServiceJid,widget);
	}
}
Exemple #27
0
/**
 * \brief Registers new incoming capabilities information of a JID.
 * If the features of the entity are unknown, discovery requests are sent to 
 * retrieve the information.
 *
 * @param jid The entity's JID 
 * @param node The entity's caps node
 * @param ver The entity's caps version
 * @param ext The entity's caps extensions
 */
void CapsManager::updateCaps(const Jid& jid, const QString& node, const QString& ver, const QString& ext)
{
	if (jid.compare(jid_,false))
		return;

	CapsSpec c(node,ver,ext);
	CapsSpecs caps = c.flatten();
	if (capsSpecs_[jid.full()] != c) {
		//qDebug() << QString("caps.cpp: Updating caps for %1 (node=%2,ver=%3,ext=%4)").arg(QString(jid.full()).replace('%',"%%")).arg(node).arg(ver).arg(ext);
		
		// Unregister from all old caps nodes
		CapsSpecs old_caps = capsSpecs_[jid.full()].flatten();
		foreach(CapsSpec s, old_caps) {
			if (s != CapsSpec()) {
				capsJids_[s].removeAll(jid.full());
			}
		}

		if (!node.isEmpty() && !ver.isEmpty()) {
			// Register with all new caps nodes
			capsSpecs_[jid.full()] = c;
			foreach(CapsSpec s, caps) {
				if (!capsJids_[s].contains(jid.full())) {
					capsJids_[s].push_back(jid.full());
				}
			}
			
			emit capsChanged(jid); 

			// Register new caps and check if we need to discover features
			if (isEnabled()) {
				foreach(CapsSpec s, caps) {
					if (!registry_->isRegistered(s) && capsJids_[s].count() == 1) {
						//qDebug() << QString("caps.cpp: Sending disco request to %1, node=%2").arg(QString(jid.full()).replace('%',"%%")).arg(node + "#" + s.extensions());
						discoInfoQuerier_->getDiscoInfo(jid,node + "#" + s.extensions());
					}
				}
			}
		}
Exemple #28
0
void Stanza::setFrom(const Jid &j)
{
	d->e.setAttribute("from", j.full());
}
Exemple #29
0
void Stanza::setTo(const Jid &j)
{
	d->e.setAttribute("to", j.full());
}
JingleStanza::JingleStanza(const Jid &AFrom, const Jid &ATo, const QString &ASid, IJingle::Action AAction):
    Stanza("iq"), jingle(addElement("jingle", NS_JINGLE))
{
    QString     action;
    switch (AAction)
    {
        case IJingle::SessionInitiate:
            action="session-initiate";
            break;
        case IJingle::SessionAccept:
            action="session-accept";
            break;
        case IJingle::SessionTerminate:
            action="session-terminate";
            break;
        case IJingle::SessionInfo:
            action="session-info";
            break;
        case IJingle::ScurityInfo:
            action="security-info";
            break;
        case IJingle::DescriptionInfo:
            action="description-info";
            break;
        case IJingle::ContentAdd:
            action="content-add";
            break;
        case IJingle::ContentModify:
            action="content-modify";
            break;
        case IJingle::ContentAccept:
            action="content-accept";
            break;
        case IJingle::ContentReject:
            action="content-reject";
            break;
        case IJingle::ContentRemove:
            action="content-remove";
            break;
        case IJingle::TransportAccept:
            action="transport-accept";
            break;
        case IJingle::TransportInfo:
            action="transport-info";
            break;
        case IJingle::TransportReject:
            action="transport-reject";
            break;
        case IJingle::TransportReplace:
            action="transport-replace";
            break;
        default:
            return;
    }

    setType("set");
    setFrom(AFrom.full());
    setTo(ATo.full());
    setId(QString("id%1").arg(QDateTime::currentDateTime().toTime_t(),0,16));

    jingle.setAttribute("action", action);
    jingle.setAttribute("sid", ASid);
}