settings_manager.cpp

00001 /* 00002 $Id: settings__manager_8cpp-source.html,v 1.1 2004/10/05 21:12:03 mentat Exp $ 00003 00004 GNU Messenger - The secure instant messenger 00005 00006 Copyright (C) 2004 Jesse Lovelace <jesse at aslogicsys dot com> 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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 } // !GNUMessenger

Generated on Tue Oct 5 14:41:47 2004 for GNU Messenger by doxygen 1.3.8