diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bcb704366cb5e333a626c18c308c7e0448a8e69f (patch) | |
tree | f0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /kopete/plugins/addbookmarks/addbookmarksprefssettings.cpp | |
download | tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/plugins/addbookmarks/addbookmarksprefssettings.cpp')
-rw-r--r-- | kopete/plugins/addbookmarks/addbookmarksprefssettings.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/kopete/plugins/addbookmarks/addbookmarksprefssettings.cpp b/kopete/plugins/addbookmarks/addbookmarksprefssettings.cpp new file mode 100644 index 00000000..045ce801 --- /dev/null +++ b/kopete/plugins/addbookmarks/addbookmarksprefssettings.cpp @@ -0,0 +1,87 @@ +// +// C++ Implementation: %{MODULE} +// +// Description: +// +// +// Author: Roie Kerstein <[email protected]>, (C) 2004 +// +// License: GPL v2 +// +// +#include <kdebug.h> +#include <kconfig.h> +#include <kglobal.h> + +#include "addbookmarksprefssettings.h" + +BookmarksPrefsSettings::BookmarksPrefsSettings(QObject *parent, const char *name) + : QObject(parent, name) +{ + load(); +} + + +BookmarksPrefsSettings::~BookmarksPrefsSettings() +{ +} + +void BookmarksPrefsSettings::load() +{ + KConfig * configfile = KGlobal::config(); + m_isfolderforeachcontact = Always; + m_contactslist.clear(); + m_addbookmarksfromunknowns = false; + if( configfile->getConfigState() == KConfigBase::NoAccess ){ + kdDebug( 14501 ) << "load: failed to open config file for reading" << endl; + return; + } + if( !configfile->hasGroup("Bookmarks Plugin") ){ + kdDebug( 14501 ) << "load: no config found in file" << endl; + return; + } + configfile->setGroup("Bookmarks Plugin"); + m_isfolderforeachcontact = (UseSubfolders)configfile->readNumEntry( "UseSubfolderForEachContact", 0 ); + m_contactslist = configfile->readListEntry( "ContactsList" ); + m_addbookmarksfromunknowns = configfile->readBoolEntry( "AddBookmarksFromUnknownContacts" ); +} + +void BookmarksPrefsSettings::save() +{ + KConfig * configfile = KGlobal::config(); + + if( configfile->getConfigState() != KConfigBase::ReadWrite ){ + kdDebug( 14501 ) << "save: failed to open config file for writing" << endl; + return; + } + configfile->setGroup( "Bookmarks Plugin" ); + configfile->writeEntry( "UseSubfolderForEachContact", (int)m_isfolderforeachcontact ); + configfile->writeEntry( "ContactsList", m_contactslist ); + configfile->writeEntry( "AddBookmarksFromUnknownContacts", m_addbookmarksfromunknowns ); + configfile->sync(); +} + +bool BookmarksPrefsSettings::useSubfolderForContact( QString nickname ) +{ + if ( !nickname.isEmpty() ) + { + switch( m_isfolderforeachcontact ){ + case Never: + return false; + case Always: + return true; + case SelectedContacts: + return ( m_contactslist.find( nickname ) != m_contactslist.end() ); + case UnselectedContacts: + return ( m_contactslist.find( nickname ) == m_contactslist.end() ); + } + } + return false; +} + +void BookmarksPrefsSettings::setAddBookmarksFromUnknownContacts( bool addUntrusted ) +{ + m_addbookmarksfromunknowns = addUntrusted; +} + +#include "addbookmarksprefssettings.moc" |