settings_manager.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <string>
00023
00024 #include "gm/settings_manager.h"
00025 #include "gm/xml_manager.h"
00026
00027 namespace GNUMessenger {
00028
00029 using namespace std;
00030
00031 bool
00032 SettingsManager::getNet(const string& net, XMLNode& node)
00033 {
00034 if (m_xml.child("user").child("netconf").hasChild(net))
00035 {
00036 node = m_xml.child("user").child("netconf").child(net);
00037 return true;
00038 }
00039
00040 return false;
00041 }
00042
00043 bool
00044 SettingsManager::setProfile(const string& info)
00045 {
00046 m_xml.child("user").child("profile").setData(info);
00047
00048 return true;
00049 }
00050
00051 string
00052 SettingsManager::getProfile()
00053 {
00054 return m_xml.child("user").child("profile").data();
00055 }
00056
00057 bool
00058 SettingsManager::setAwayMessage(const string& label, const string& message)
00059 {
00060 XMLNode searcher;
00061
00062 if (XMLManager::search(label, "item", m_xml.child("user").child("away"), searcher))
00063 searcher.setData(message);
00064 else
00065 m_xml.child("user").child("away").addChild("item").setProperty("name", label).setData(message);
00066 return
00067 true;
00068
00069 }
00070
00071 string
00072 SettingsManager::getAwayMessage(const string& label)
00073 {
00074 XMLNode searcher;
00075
00076 if (XMLManager::search(label, "item", m_xml.child("user").child("away"), searcher))
00077 return searcher.data();
00078 return "";
00079 }
00080
00081 bool
00082 SettingsManager::deleteAwayMessage(const string& label)
00083 {
00084 XMLNode searcher;
00085 unsigned int num(0);
00086
00087 if (XMLManager::baseSearch(label, "item", m_xml.child("user").child("away"), searcher, num))
00088 {
00089 searcher.delChild("item", num);
00090 return true;
00091 }
00092
00093 return false;
00094 }
00095
00096 void SettingsManager::setPublicKey(const string& key)
00097 {
00098 m_xml.child("user").child("publickey").setData(key);
00099
00100
00101 }
00102
00103 string SettingsManager::getPublicKey()
00104 {
00105
00106 return m_xml.child("user").child("publickey").data();
00107 }
00108
00109 bool
00110 SettingsManager::setNet(XMLNode &net)
00111 {
00112 if (m_xml.child("user").child("netconf").hasChild(net.name())){
00113 m_xml.child("user").child("netconf").delChild(net.name());
00114 m_xml.child("user").child("netconf").addChild(net);
00115 LOG_DEBUG("SettingsManager::SetNet - Replacing Net");
00116 } else {
00117 m_xml.child("user").child("netconf").addChild(net);
00118 LOG_DEBUG("SettingsManager::SetNet - Adding Net");
00119 }
00120 return true;
00121 }
00122
00123 bool
00124 SettingsManager::deleteNet(const string& netname)
00125 {
00126 if (m_xml.child("user").child("netconf").hasChild(netname))
00127 {
00128 m_xml.child("user").child("netconf").delChild(netname);
00129 return true;
00130 }
00131 return false;
00132 }
00133
00134 }
Generated on Tue Oct 5 14:41:47 2004 for GNU Messenger by
1.3.8