예제 #1
0
		// http://xmpp.org/extensions/xep-0234.html#example-1
		void testSerialize_Xep0234_Example1() {
			std::string expected =	"<description xmlns=\"urn:xmpp:jingle:apps:file-transfer:4\">"
					"<file>"
						"<date>1969-07-21T02:56:15Z</date>"
						"<desc>This is a test. If this were a real file...</desc>"
						"<name>test.txt</name>"
						"<range/>"
						"<size>1022</size>"
						"<hash algo=\"sha-1\" xmlns=\"urn:xmpp:hashes:1\">VS2nSZMIUsaa5dIUHTdmsQ==</hash>"
					"</file>"
				"</description>";
			JingleFileTransferDescription::ref desc = boost::make_shared<JingleFileTransferDescription>();
			JingleFileTransferFileInfo fileInfo;
			
			fileInfo.setDate(stringToDateTime("1969-07-21T02:56:15Z"));
			fileInfo.addHash(HashElement("sha-1", Base64::decode("VS2nSZMIUsaa5dIUHTdmsQ==")));
			fileInfo.setSize(1022);
			fileInfo.setName("test.txt");
			fileInfo.setDescription("This is a test. If this were a real file...");
			fileInfo.setSupportsRangeRequests(true);
			
			desc->setFileInfo(fileInfo);
			
			CPPUNIT_ASSERT_EQUAL(expected, boost::make_shared<JingleFileTransferDescriptionSerializer>()->serialize(desc));
		}
예제 #2
0
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);
}
예제 #3
0
		// http://xmpp.org/extensions/xep-0234.html#example-3
		void testSerialize_Xep0234_Example3() {
			std::string expected =
				"<jingle action=\"session-accept\""
					" initiator=\"[email protected]/orchard\""
					" sid=\"851ba2\""
					" xmlns=\"urn:xmpp:jingle:1\">"
					"<content creator=\"initiator\" name=\"a-file-offer\">"
						"<description xmlns=\"urn:xmpp:jingle:apps:file-transfer:4\">"
							"<file>"
								"<date>1969-07-21T02:56:15Z</date>"
								"<desc>This is a test. If this were a real file...</desc>"
								"<name>test.txt</name>"
								"<range/>"
								"<size>1022</size>"
								"<hash algo=\"sha-1\" xmlns=\"urn:xmpp:hashes:1\">VS2nSZMIUsaa5dIUHTdmsQ==</hash>"
							"</file>"
						"</description>"
						/*"<transport xmlns=\"urn:xmpp:jingle:transports:s5b:1\""
							" mode=\"tcp\""
							" sid=\"vj3hs98y\">"
							"<candidate cid=\"ht567dq\""
								" host=\"192.169.1.10\""
								" jid=\"[email protected]/balcony\""
								" port=\"6539\""
								" priority=\"8257636\""
								" type=\"direct\"/>"
							"<candidate cid=\"hr65dqyd\""
								" host=\"134.102.201.180\""
								" jid=\"[email protected]/balcony\""
								" port=\"16453\""
								" priority=\"7929856\""
								" type=\"assisted\"/>"
							"<candidate cid=\"grt654q2\""
								" host=\"2001:638:708:30c9:219:d1ff:fea4:a17d\""
								" jid=\"[email protected]/balcony\""
								" port=\"6539\""
								" priority=\"8257606\""
								" type=\"direct\"/>"
						"</transport>"*/
					"</content>"
				"</jingle>";
			
			JinglePayload::ref payload = boost::make_shared<JinglePayload>();
			payload->setAction(JinglePayload::SessionAccept);
			payload->setInitiator(JID("[email protected]/orchard"));
			payload->setSessionID("851ba2");
			
			JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
			content->setCreator(JingleContentPayload::InitiatorCreator);
			content->setName("a-file-offer");
			
			JingleFileTransferDescription::ref description = boost::make_shared<JingleFileTransferDescription>();
			JingleFileTransferFileInfo fileInfo;
			fileInfo.setName("test.txt");
			fileInfo.setSize(1022);
			fileInfo.addHash(HashElement("sha-1", Base64::decode("VS2nSZMIUsaa5dIUHTdmsQ==")));
			fileInfo.setDate(stringToDateTime("1969-07-21T02:56:15Z"));
			fileInfo.setDescription("This is a test. If this were a real file...");
			fileInfo.setSupportsRangeRequests(true);
			
			description->setFileInfo(fileInfo);
			content->addDescription(description);
			payload->addPayload(content);
			
			CPPUNIT_ASSERT_EQUAL(expected, createTestling()->serialize(payload));
		}