source: qutecom-coip/libs/coipmanager_base/src/serializer/OscarAccountXMLSerializer.cpp @ 122:c9c6efaa02b5

Last change on this file since 122:c9c6efaa02b5 was 1:7054718019f9, checked in by vadim@…, 5 years ago

This patch transforms wengophone 2.2 branch into trunk

File size: 2.2 KB
Line 
1/*
2 * WengoPhone, a voice over Internet phone
3 * Copyright (C) 2004-2006  Wengo
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20#include <coipmanager_base/serializer/OscarAccountXMLSerializer.h>
21
22#include <coipmanager_base/account/OscarAccount.h>
23
24#include <util/String.h>
25
26#include <tinyxml.h>
27
28OscarAccountXMLSerializer::OscarAccountXMLSerializer(OscarAccount & account) 
29        : IAccountXMLSerializer(account) {
30}
31
32std::string OscarAccountXMLSerializer::serialize() {
33        std::string result;
34       
35        OscarAccount & myAccount = (OscarAccount &) _account;
36
37        result += "<oscar.server>" + myAccount.getServer() + "</oscar.server>";
38        result += "<oscar.port>" + String::fromNumber(myAccount.getServerPort()) + "</oscar.port>";
39        result += "<oscar.encoding>" + myAccount.getEncoding() + "</oscar.encoding>";
40
41        return result;
42}
43
44bool OscarAccountXMLSerializer::unserialize(TiXmlHandle & rootElt) {
45        OscarAccount & myAccount = (OscarAccount &) _account;
46
47        // Retrieving server
48        TiXmlNode * server = rootElt.FirstChild("oscar.server").FirstChild().Node();
49        if (server) {
50                myAccount.setServer(server->Value());
51        }
52        ////
53
54        // Retrieving server port
55        TiXmlNode * port = rootElt.FirstChild("oscar.port").FirstChild().Node();
56        if (port) {
57                String serverPort = port->Value();
58                myAccount.setServerPort(serverPort.toInteger());
59        }
60        ////
61
62        // Retrieving encoding
63        TiXmlNode * encoding = rootElt.FirstChild("oscar.encoding").FirstChild().Node();
64        if (encoding) {
65                myAccount.setEncoding(encoding->Value());
66        }
67        ////
68
69        return true;
70}
Note: See TracBrowser for help on using the repository browser.