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

tip
Last change on this file was 281:81383cc30ed4, checked in by laurent <laurent@…>, 22 months ago

update libs/

File size: 2.0 KB
Line 
1/*
2 * QuteCom, a voice over Internet phone
3 * Copyright (C) 2010 Mbdsys
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 <QtXml>
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(QDomElement * rootElt) {
45        OscarAccount & myAccount = (OscarAccount &) _account;
46
47    // Retrieving server
48    myAccount.setServer(rootElt->firstChildElement("oscar.server").text().toStdString());
49       
50        // Retrieving server port
51    myAccount.setServerPort(rootElt->firstChildElement("oscar.port").text().toInt());
52
53        // Retrieving encoding
54    myAccount.setEncoding(rootElt->firstChildElement("oscar.encoding").text().toStdString());
55
56        return true;
57}
Note: See TracBrowser for help on using the repository browser.