/* * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include #include #include #include #include #include #include #include namespace Swift { FileVCardCollection::FileVCardCollection(boost::filesystem::path dir) : vcardsPath(dir) { } std::shared_ptr FileVCardCollection::getOwnVCard() const { if (boost::filesystem::exists(vcardsPath / std::string("vcard.xml"))) { ByteArray data; readByteArrayFromFile(data, boost::filesystem::path(vcardsPath / std::string("vcard.xml")).string()); VCardParser parser; PayloadParserTester tester(&parser); tester.parse(byteArrayToString(data)); return std::dynamic_pointer_cast(parser.getPayload()); } else { return std::make_shared(); } } void FileVCardCollection::setOwnVCard(std::shared_ptr v) { boost::filesystem::ofstream file(vcardsPath / std::string("vcard.xml")); file << VCardSerializer().serializePayload(v); file.close(); } }