// http://xmpp.org/extensions/xep-0261.html#example-1 void testSerialize_Xep0261_Example1() { std::string expected = "<jingle action=\"session-initiate\"" " initiator=\"[email protected]/orchard\"" " sid=\"a73sjjvkla37jfea\"" " xmlns=\"urn:xmpp:jingle:1\">" "<content creator=\"initiator\" name=\"ex\">" "<transport block-size=\"4096\"" " sid=\"ch3d9s71\"" " xmlns=\"urn:xmpp:jingle:transports:ibb:1\"/>" "</content>" "</jingle>"; JinglePayload::ref payload = boost::make_shared<JinglePayload>(); payload->setAction(JinglePayload::SessionInitiate); payload->setSessionID("a73sjjvkla37jfea"); payload->setInitiator(JID("[email protected]/orchard")); JingleIBBTransportPayload::ref transport = boost::make_shared<JingleIBBTransportPayload>(); transport->setBlockSize(4096); transport->setSessionID("ch3d9s71"); JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>(); content->setCreator(JingleContentPayload::InitiatorCreator); content->setName("ex"); content->addTransport(transport); payload->addPayload(content); CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload)); }
void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated( const std::string& s5bSessionID, const std::vector<JingleS5BTransportPayload::Candidate>& candidates, const std::string& dstAddr) { SWIFT_LOG(debug) << std::endl; if (state != GeneratingInitialLocalCandidates) { SWIFT_LOG(warning) << "Incorrect state: " << state << std::endl; return; } fillCandidateMap(localCandidates, candidates); JingleFileTransferDescription::ref description = std::make_shared<JingleFileTransferDescription>(); fileInfo.addHash(HashElement("sha-1", ByteArray())); fileInfo.addHash(HashElement("md5", ByteArray())); description->setFileInfo(fileInfo); JingleTransportPayload::ref transport; if (candidates.empty()) { SWIFT_LOG(debug) << "no S5B candidates generated. Send IBB transport candidate." << std::endl; JingleIBBTransportPayload::ref ibbTransport = std::make_shared<JingleIBBTransportPayload>(); ibbTransport->setBlockSize(DEFAULT_BLOCK_SIZE); ibbTransport->setSessionID(idGenerator->generateID()); transport = ibbTransport; } else { JingleS5BTransportPayload::ref s5bTransport = std::make_shared<JingleS5BTransportPayload>(); s5bTransport->setSessionID(s5bSessionID); s5bTransport->setMode(JingleS5BTransportPayload::TCPMode); s5bTransport->setDstAddr(dstAddr); for (auto&& candidate : candidates) { s5bTransport->addCandidate(candidate); SWIFT_LOG(debug) << "\t" << "S5B candidate: " << candidate.hostPort.toString() << std::endl; } transport = s5bTransport; } setInternalState(WaitingForAccept); session->sendInitiate(contentID, description, transport); }
void OutgoingJingleFileTransfer::fallback() { if (options.isInBandAllowed()) { SWIFT_LOG(debug) << "Trying to fallback to IBB transport." << std::endl; JingleIBBTransportPayload::ref ibbTransport = std::make_shared<JingleIBBTransportPayload>(); ibbTransport->setBlockSize(DEFAULT_BLOCK_SIZE); ibbTransport->setSessionID(idGenerator->generateID()); setInternalState(FallbackRequested); session->sendTransportReplace(contentID, ibbTransport); } else { SWIFT_LOG(debug) << "Fallback to IBB transport not allowed." << std::endl; terminate(JinglePayload::Reason::ConnectivityError); } }