/* * Copyright (c) 2012 Tobias Markmann * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ #include #include #include #include #include #include #include #include #include namespace Swift { JingleFileTransferFileInfoSerializer::JingleFileTransferFileInfoSerializer() { } std::string JingleFileTransferFileInfoSerializer::serializePayload(boost::shared_ptr fileInfo) const { XMLElement fileElement("file"); if (fileInfo->getDate() != stringToDateTime("")) { boost::shared_ptr date = boost::make_shared("date", "", dateTimeToString(fileInfo->getDate())); fileElement.addNode(date); } if (!fileInfo->getDescription().empty()) { boost::shared_ptr desc = boost::make_shared("desc", "", fileInfo->getDescription()); fileElement.addNode(desc); } if (!fileInfo->getName().empty()) { boost::shared_ptr name = boost::make_shared("name", "", fileInfo->getName()); fileElement.addNode(name); } if (fileInfo->getSupportsRangeRequests()) { boost::shared_ptr range = boost::make_shared("range"); if (fileInfo->getRangeOffset() != 0) { range->setAttribute("offset", boost::lexical_cast(fileInfo->getRangeOffset())); } fileElement.addNode(range); } if (fileInfo->getSize() != 0) { boost::shared_ptr size = boost::make_shared("size", "", boost::lexical_cast(fileInfo->getSize())); fileElement.addNode(size); } if (!fileInfo->getHash().empty()) { boost::shared_ptr hash = boost::make_shared("hash", "urn:xmpp:hashes:1", fileInfo->getHash()); if (!fileInfo->getAlgo().empty()) { hash->setAttribute("algo", fileInfo->getAlgo()); } fileElement.addNode(hash); } return fileElement.serialize(); } }