Пример #1
0
KDEConnectTelepathyProtocol::KDEConnectTelepathyProtocol(const QDBusConnection &dbusConnection, const QString &name)
    : BaseProtocol(dbusConnection, name)
{
    setParameters(Tp::ProtocolParameterList()
                    << Tp::ProtocolParameter(QLatin1String("device_id"), QLatin1String("s"), Tp::ConnMgrParamFlagRequired)
                    << Tp::ProtocolParameter(QLatin1String("self_name"), QLatin1String("s"), 0));

    setRequestableChannelClasses(Tp::RequestableChannelClassSpecList() << Tp::RequestableChannelClassSpec::textChat());

    // callbacks
    setCreateConnectionCallback(memFun(this, &KDEConnectTelepathyProtocol::createConnection));
    setIdentifyAccountCallback(memFun(this, &KDEConnectTelepathyProtocol::identifyAccount));
    setNormalizeContactCallback(memFun(this, &KDEConnectTelepathyProtocol::normalizeContact));

    addrIface = Tp::BaseProtocolAddressingInterface::create();
    addrIface->setAddressableVCardFields(QStringList() << QLatin1String("tel"));
    addrIface->setAddressableUriSchemes(QStringList() << QLatin1String("tel") << QLatin1String("sms"));
    addrIface->setNormalizeVCardAddressCallback(memFun(this, &KDEConnectTelepathyProtocol::normalizeVCardAddress));
    addrIface->setNormalizeContactUriCallback(memFun(this, &KDEConnectTelepathyProtocol::normalizeContactUri));
    plugInterface(Tp::AbstractProtocolInterfacePtr::dynamicCast(addrIface));


    presenceIface = Tp::BaseProtocolPresenceInterface::create();
    presenceIface->setStatuses(ConnectConnection::getSimpleStatusSpecMap());
    plugInterface(Tp::AbstractProtocolInterfacePtr::dynamicCast(presenceIface));

    auto bus = QDBusConnection::sessionBus();
    bus.registerObject("/kdeconnect", this, QDBusConnection::ExportAllSignals | QDBusConnection::ExportAllSlots);

    Tp::DBusError err;
}
Пример #2
0
KDEConnectTelepathyProtocol::KDEConnectTelepathyProtocol(const QDBusConnection &dbusConnection, const QString &name)
    : BaseProtocol(dbusConnection, name)
{
//     setParameters(Tp::ProtocolParameterList()
//                   << Tp::ProtocolParameter(QLatin1String("device_id"), QLatin1String("s"), Tp::ConnMgrParamFlagRequired)
//                   << Tp::ProtocolParameter(QLatin1String("self_name"), QLatin1String("s"), 0));

    setRequestableChannelClasses(Tp::RequestableChannelClassSpecList() << Tp::RequestableChannelClassSpec::textChat());

    // callbacks
    setCreateConnectionCallback(memFun(this, &KDEConnectTelepathyProtocol::createConnection));
    setIdentifyAccountCallback(memFun(this, &KDEConnectTelepathyProtocol::identifyAccount));
    setNormalizeContactCallback(memFun(this, &KDEConnectTelepathyProtocol::normalizeContact));

    addrIface = Tp::BaseProtocolAddressingInterface::create();
    addrIface->setAddressableVCardFields(QStringList() << QLatin1String("x-example-vcard-field"));
    addrIface->setAddressableUriSchemes(QStringList() << QLatin1String("example-uri-scheme"));
    addrIface->setNormalizeVCardAddressCallback(memFun(this, &KDEConnectTelepathyProtocol::normalizeVCardAddress));
    addrIface->setNormalizeContactUriCallback(memFun(this, &KDEConnectTelepathyProtocol::normalizeContactUri));
    plugInterface(Tp::AbstractProtocolInterfacePtr::dynamicCast(addrIface));
/*
    presenceIface = Tp::BaseProtocolPresenceInterface::create();
    presenceIface->setStatuses(Tp::PresenceSpecList(ConnectConnection::getConnectStatusSpecMap()));
    plugInterface(Tp::AbstractProtocolInterfacePtr::dynamicCast(presenceIface));*/

    Tp::DBusError err;
}
Пример #3
0
XMPPStream::XMPPStream() {
	SF_REGISTER_ME;
	mState     = XMS_Null;
	mCurrentOp = XMO_Null;
	mReceivedFeatures = false;
	mSkipInit = false;;

	// XmlStreamDecoder is not asynchronous, doesn't need dMemFun
	// Calls directly into locked state.
	mXmlStreamDecoder.stateChange() = memFun (this, &XMPPStream::onXmlStreamStateChange);
	mXmlStreamDecoder.chunkRead()   = memFun (this, &XMPPStream::onXmlChunkRead);
}
Пример #4
0
Error XMPPStream::requestTls (const ResultCallback & callback) {
	if (!mReceivedFeatures) {
		Log (LogWarning) << LOGID << "Cannot request TLS, no stream features" << std::endl;
		return error::WrongState;
	}
	if (!mFeatures.hasChildWithName("starttls")){
		Log (LogWarning) << LOGID << "Cannot request TLS, not supported by stream features" << std::endl;
		return error::NotSupported;
	}
	Error e = startOp (XMO_RequestTls, callback);
	if (e) return e;
	String tlsRequest ("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>");
	e = send (tlsRequest);
	if (e) return e;
	mNextChunkHandler = memFun (this, &XMPPStream::onStartTlsReply);
	return NoError;
}
Пример #5
0
Error XMPPStream::authenticate (const String & username, const String & password, const ResultCallback & result) {
	if (!mReceivedFeatures){
		Log (LogWarning) << LOGID << "Cannot authenticate, no stream features" << std::endl;
		return error::WrongState;
	}
	if (!hasMechanism ("PLAIN", mFeatures)){
		Log (LogWarning) << LOGID << "Authentication mechanism PLAIN not supported!" << std::endl;
		return error::NotSupported;
	}
	Error e = startOp (XMO_Authenticate, result);
	if (e) return e;

	String secret = plainSecret (username, password);
	String auth = "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" + secret + "</auth>";
	e = send (auth);
	if (e) return e;
	mNextChunkHandler = memFun (this, &XMPPStream::onAuthReply);
	return NoError;
}