コード例 #1
0
ファイル: XMPPStream.cpp プロジェクト: nob13/schneeflocke
void XMPPStream::onAuthReply (const XMLChunk & chunk) {
	if (chunk.name() == "success"){
		finishOp (XMO_Authenticate, NoError);
		return;
	}
	finishOp (XMO_Authenticate, error::AuthError);
}
コード例 #2
0
ファイル: XMPPStream.cpp プロジェクト: nob13/schneeflocke
void XMPPStream::onStartTlsReply (const XMLChunk & chunk) {
	if (chunk.name() == "proceed"){
		finishOp (XMO_RequestTls, NoError);
		return;
	}
	Log (LogWarning) << LOGID << "Could not request TLS: " << chunk << std::endl;
	finishOp (XMO_RequestTls, error::NotSupported);
}
コード例 #3
0
ファイル: XMPPStream.cpp プロジェクト: nob13/schneeflocke
void XMPPStream::onXmlChunkRead (const XMLChunk & chunk) {
	if (mNextChunkHandler){
		mNextChunkHandler (chunk);
		mNextChunkHandler.clear();
		return;
	}

	if (chunk.name() == "stream:features") {
		if (mReceivedFeatures) {
			Log (LogWarning) << LOGID << "Double receive features!" << std::endl;
		}
		mFeatures         = chunk;
		mReceivedFeatures = true;
		finishOp (XMO_WaitFeatures, NoError);
		return;
	} else
	if (chunk.name() == "iq") {
		xmpp::Iq iq;
		bool suc = iq.decode(chunk);
		if (!suc) {
			Log (LogWarning) << LOGID << "Could not decode " << chunk << std::endl;
			return;
		}
		String id = chunk.getAttribute("id");
		if (id.empty()){
			Log (LogWarning) << LOGID << "Received empty id in iq" << std::endl;
		}

		OpenIqMap::iterator i = mOpenIqs.find (id);
		if (i != mOpenIqs.end()){
			IqResultCallback cb = i->second;
			mOpenIqs.erase(i); // make this behaviour selectable?
			if (cb){
				notifyAsync (cb, NoError, iq, chunk);
			} else {
				Log (LogInfo) << LOGID << "Ignoring iq reply as there is no callback set (id=" << iq.id << ")" << std::endl;
			}
		} else {
			if (mIncomingIq) {
				notifyAsync (mIncomingIq, iq, chunk);
			} else {
				Log (LogWarning) << LOGID << "No iq handler set!" << std::endl;
			}
		}
	} else
	if (chunk.name() == "message") {
		xmpp::Message m;
		bool suc = m.decode(chunk);
		if (!suc) {
			Log (LogWarning) << LOGID << "Could not decode message " << chunk << std::endl;
			return;
		}
		notifyAsync (mIncomingMessage, m, chunk);
	} else
	if (chunk.name() == "presence") {
		xmpp::PresenceInfo p;
		bool suc = p.decode(chunk);
		if (!suc) {
			Log (LogWarning) << LOGID << "Could not decode presence " << chunk << std::endl;
			return;
		}
		notifyAsync (mIncomingPresence, p, chunk);
	} else
	if (chunk.name() == "stream:error"){
		String text = chunk.getChild("text").text();
		if (mIncomingStreamError){
			notifyAsync (mIncomingStreamError, text, chunk);
		} else {
			Log (LogWarning) << LOGID << "Discarding incoming stream error, no delegate " << text << std::endl;
		}
	} else {
		Log (LogWarning) << LOGID << "Unknown chunk type " << chunk << std::endl;
	}
}