void StanzaParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
	if (inStanza()) {
		if (!inPayload()) {
			assert(!currentPayloadParser_);
			PayloadParserFactory* payloadParserFactory = factories_->getPayloadParserFactory(element, ns, attributes);
			if (payloadParserFactory) {
				currentPayloadParser_.reset(payloadParserFactory->createPayloadParser());
			}
			else {
				currentPayloadParser_.reset(new UnknownPayloadParser());
			}
		}
		assert(currentPayloadParser_);
		currentPayloadParser_->handleStartElement(element, ns, attributes);
	}
	else {
		boost::optional<std::string> from = attributes.getAttributeValue("from");
		if (from) {
			getStanza()->setFrom(JID(*from));
		}
		boost::optional<std::string> to = attributes.getAttributeValue("to");
		if (to) {
			getStanza()->setTo(JID(*to));
		}
		boost::optional<std::string> id = attributes.getAttributeValue("id");
		if (id) {
			getStanza()->setID(*id);
		}
		handleStanzaAttributes(attributes);
	}
	++currentDepth_;
}
void JingleFileTransferDescriptionParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
	if (level == 1) {
		PayloadParserFactory* payloadParserFactory = factories->getPayloadParserFactory(element, ns, attributes);
		if (payloadParserFactory) {
			currentPayloadParser.reset(payloadParserFactory->createPayloadParser());
		}
	}

	if (level >= 1 && currentPayloadParser) {
		currentPayloadParser->handleStartElement(element, ns, attributes);
	}
	++level;
}
void JingleFileTransferReceivedParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
	if (level == 1 && element == "file") {
		PayloadParserFactory* payloadParserFactory = new GenericPayloadParserFactory<StreamInitiationFileInfoParser>("file", "http://jabber.org/protocol/si/profile/file-transfer");
		if (payloadParserFactory) {
			currentPayloadParser.reset(payloadParserFactory->createPayloadParser());
		}
	}
	
	if (currentPayloadParser && level >= 1) {
		currentPayloadParser->handleStartElement(element, ns, attributes);
	}
	
	++level;
}
Exemple #4
0
	void JingleParser::handleStartElement(const std::string& element, const std::string &ns, const AttributeMap& attributes) {
		if (level == 0) {
			// <jingle > tag
			JinglePayload::ref payload = getPayloadInternal();
			payload->setAction(stringToAction(attributes.getAttributeValue("action").get_value_or("")));
			payload->setInitiator(JID(attributes.getAttributeValue("initiator").get_value_or("")));
			payload->setResponder(JID(attributes.getAttributeValue("responder").get_value_or("")));
			payload->setSessionID(attributes.getAttributeValue("sid").get_value_or(""));
		}
		
		if (level == 1) {
			PayloadParserFactory* payloadParserFactory = factories->getPayloadParserFactory(element, ns, attributes);
			if (payloadParserFactory) {
				currentPayloadParser.reset(payloadParserFactory->createPayloadParser());
			}
		}
		
		if (level >= 1 && currentPayloadParser) {
			currentPayloadParser->handleStartElement(element, ns, attributes);
		}
		
		++level;
	}