Пример #1
0
bool Stanza::isFromServer() const
{
	if (!to().isEmpty())
	{
		Jid toJid = to();
		Jid fromJid = from();
		return fromJid.isEmpty() || fromJid==toJid || fromJid==toJid.bare() || fromJid==toJid.domain();
	}
	return false;
}
Пример #2
0
void CoreProtocol::startClientOut(const Jid &_jid, bool _oldOnly, bool tlsActive, bool _doAuth, bool _doCompress)
{
	jid_ = _jid;
	to = _jid.domain();
	oldOnly = _oldOnly;
	doAuth = _doAuth;
	doCompress = _doCompress;
	tls_started = tlsActive;

	if(oldOnly)
		version = Version(0,0);
	startConnect();
}
AddLegacyAccountOptions::AddLegacyAccountOptions(IGateways *AGateways, IServiceDiscovery *ADiscovery, const Jid &AStreamJid, QWidget *AParent) : QWidget(AParent)
{
	ui.setupUi(this);

	FGateways = AGateways;
	FDiscovery = ADiscovery;
	FStreamJid = AStreamJid;

	connect(FGateways->instance(),SIGNAL(availServicesChanged(const Jid &)),SLOT(onServicesChanged(const Jid &)));
	connect(FGateways->instance(),SIGNAL(streamServicesChanged(const Jid &)),SLOT(onServicesChanged(const Jid &)));

	FLayout = new QHBoxLayout(ui.wdtGateways);
	FLayout->setContentsMargins(20, 6, 20, 6);
	FLayout->addStretch();

	if (FDiscovery)
		FDiscovery->requestDiscoItems(AStreamJid,AStreamJid.domain());

	onServicesChanged(FStreamJid);
}
Пример #4
0
bool RosterItemExchange::rosterDragEnter(const QDragEnterEvent *AEvent)
{
	if (AEvent->source()==FRostersViewPlugin->rostersView()->instance() && AEvent->mimeData()->hasFormat(DDT_ROSTERSVIEW_INDEX_DATA))
	{
		QMap<int, QVariant> indexData;
		QDataStream stream(AEvent->mimeData()->data(DDT_ROSTERSVIEW_INDEX_DATA));
		operator>>(stream,indexData);

		if (DragRosterKinds.contains(indexData.value(RDR_KIND).toInt()))
		{
			Jid indexJid = indexData.value(RDR_PREP_BARE_JID).toString();
			if (indexJid.hasNode())
			{
				QList<Jid> services = FGateways!=NULL ? FGateways->streamServices(indexData.value(RDR_STREAM_JID).toString()) : QList<Jid>();
				return !services.contains(indexJid.domain());
			}
			return true;
		}
	}
	return false;
}
Пример #5
0
bool Task::iqVerify(const QDomElement &x, const Jid &to, const QString &id, const QString &xmlns)
{
	if(x.tagName() != "iq")
		return false;

	Jid from(x.attribute("from"));
	Jid local = client()->jid();
	Jid server = client()->host();

	// empty 'from' ?
	if(from.isEmpty()) {
		// allowed if we are querying the server
		if(!to.isEmpty() && !to.compare(server))
			return false;
	}
	// from ourself?
	else if(from.compare(local, false) || from.compare(local.domain(),false)) {
		// allowed if we are querying ourself or the server
		if(!to.isEmpty() && !to.compare(local, false) && !to.compare(server))
			return false;
	}
	// from anywhere else?
	else {
		if(!from.compare(to))
			return false;
	}

	if(!id.isEmpty()) {
		if(x.attribute("id") != id)
			return false;
	}

	if(!xmlns.isEmpty()) {
		if(queryNS(x) != xmlns)
			return false;
	}

	return true;
}
Пример #6
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());
}
Пример #7
0
void MiniClient::connectToServer(const Jid &jid, bool legacy_ssl_probe, bool legacy_ssl, bool forcessl, const QString &_host, int _port, QString proxy, QString *_pass)
{
	j = jid;

	QString host;
	int port = -1;
	bool useHost = false;
	force_ssl = forcessl;
	if(!_host.isEmpty()) {
		useHost = true;
		host = _host;
		port = _port;
	}

	AdvancedConnector::Proxy p;
	if(!proxy.isEmpty()) {
		const ProxyItem &pi = ProxyManager::instance()->getItem(proxy);
		if(pi.type == "http") // HTTP Connect
			p.setHttpConnect(pi.settings.host, pi.settings.port);
		else if(pi.type == "socks") // SOCKS
			p.setSocks(pi.settings.host, pi.settings.port);
		else if(pi.type == "poll") { // HTTP Poll
			QUrl u = pi.settings.url;
			if(u.queryItems().isEmpty()) {
				if (useHost)
					u.addQueryItem("server",host + ':' + QString::number(port));
				else
					u.addQueryItem("server",jid.domain());
			}
			p.setHttpPoll(pi.settings.host, pi.settings.port, u.toString());
			p.setPollInterval(2);
		}

		if(pi.settings.useAuth) {
			p.setUserPass(pi.settings.user, pi.settings.pass);
		}
	}

	conn = new AdvancedConnector;
	if (QCA::isSupported("tls")) {
		tls = new QCA::TLS;
		tls->setTrustedCertificates(CertificateHelpers::allCertificates(ApplicationInfo::getCertificateStoreDirs()));
		tlsHandler = new QCATLSHandler(tls);
		tlsHandler->setXMPPCertCheck(true);
		connect(tlsHandler, SIGNAL(tlsHandshaken()), SLOT(tls_handshaken()));
	}

	conn->setProxy(p);
	if (useHost) {
		conn->setOptHostPort(host, port);
		conn->setOptSSL(legacy_ssl);
	}
	else {
		conn->setOptProbe(legacy_ssl_probe);
	}

	stream = new ClientStream(conn, tlsHandler);
	connect(stream, SIGNAL(connected()), SLOT(cs_connected()));
	connect(stream, SIGNAL(securityLayerActivated(int)), SLOT(cs_securityLayerActivated(int)));
	connect(stream, SIGNAL(needAuthParams(bool, bool, bool)), SLOT(cs_needAuthParams(bool, bool, bool)));
	connect(stream, SIGNAL(authenticated()), SLOT(cs_authenticated()));
	connect(stream, SIGNAL(connectionClosed()), SLOT(cs_connectionClosed()));
	connect(stream, SIGNAL(delayedCloseFinished()), SLOT(cs_delayedCloseFinished()));
	connect(stream, SIGNAL(warning(int)), SLOT(cs_warning(int)));
	connect(stream, SIGNAL(error(int)), SLOT(cs_error(int)), Qt::QueuedConnection);

	if(_pass) {
		auth = true;
		pass = *_pass;
		_client->connectToServer(stream, j);
	}
	else {
		auth = false;
		_client->connectToServer(stream, j, false);
	}
}
Пример #8
0
void ClientInfo::showClientInfo(const Jid &AStreamJid, const Jid &AContactJid, int AInfoTypes)
{
	if (AStreamJid.isValid() && AContactJid.isValid() && AInfoTypes>0)
	{
		ClientInfoDialog *dialog = FClientInfoDialogs.value(AContactJid,NULL);
		if (!dialog)
		{
			QString contactName =  AContactJid.uNode();
			if (FDiscovery!=NULL && FDiscovery->discoInfo(AStreamJid,AContactJid.bare()).identity.value(0).category=="conference")
				contactName = AContactJid.resource();
			if (contactName.isEmpty())
				contactName = FDiscovery!=NULL ? FDiscovery->discoInfo(AStreamJid,AContactJid).identity.value(0).name : AContactJid.domain();
			
			if (FRosterManager)
			{
				IRoster *roster = FRosterManager->findRoster(AStreamJid);
				if (roster)
				{
					IRosterItem ritem = roster->findItem(AContactJid);
					if (!ritem.name.isEmpty())
						contactName = ritem.name;
				}
			}

			dialog = new ClientInfoDialog(this,AStreamJid,AContactJid,!contactName.isEmpty() ? contactName : AContactJid.uFull(),AInfoTypes);
			connect(dialog,SIGNAL(clientInfoDialogClosed(const Jid &)),SLOT(onClientInfoDialogClosed(const Jid &)));
			FClientInfoDialogs.insert(AContactJid,dialog);
			dialog->show();
		}
		else
		{
			dialog->setInfoTypes(dialog->infoTypes() | AInfoTypes);
			WidgetManager::showActivateRaiseWindow(dialog);
		}
	}
}
Пример #9
0
bool MessageCarbons::isSupported(const Jid &AStreamJid) const
{
	return FDiscovery!=NULL && FDiscovery->discoInfo(AStreamJid,AStreamJid.domain()).features.contains(NS_MESSAGE_CARBONS);
}