From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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 --- dcoprss/service.cpp | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 dcoprss/service.cpp (limited to 'dcoprss/service.cpp') diff --git a/dcoprss/service.cpp b/dcoprss/service.cpp new file mode 100644 index 00000000..74544dc1 --- /dev/null +++ b/dcoprss/service.cpp @@ -0,0 +1,105 @@ +/* $Id$ */ +/*************************************************************************** + service.cpp - A DCOP Service to provide RSS data + ------------------- + begin : Saturday 15 February 2003 + copyright : (C) 2003 by Ian Reinhart Geiser + email : geiseri@kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include +#include +#include +#include "service.h" +#include "cache.h" + +RSSService::RSSService() : + DCOPObject("RSSService") +{ + m_list.setAutoDelete( true ); + + loadLinks(); +} + +RSSService::~RSSService() +{ +} + + +QStringList RSSService::list() +{ + QStringList lst; + QDictIterator itr(m_list); + for(; itr.current(); ++itr) + lst.append(itr.currentKey()); + return lst; +} + +DCOPRef RSSService::add(QString id) +{ + if(m_list.find(id) == 0L) { // add a new one only if we need to + m_list.insert(id, new RSSDocument(id)); + added(id); + saveLinks(); + } + return document(id); +} + +void RSSService::remove(QString id) +{ + m_list.remove(id); + removed(id); + saveLinks(); +} + +DCOPRef RSSService::document(QString id) +{ + if( m_list[id] ) + return DCOPRef(m_list[id]); + else + return DCOPRef(); +} + +void RSSService::exit() +{ + //Save all current RSS links. + saveLinks(); + Cache::self().save(); + kapp->quit(); +} + + +void RSSService::loadLinks() +{ + KConfig *conf = kapp->config(); + conf->setGroup("RSS Links"); + const QStringList links = conf->readListEntry ("links"); + QStringList::ConstIterator it = links.begin(); + QStringList::ConstIterator end = links.end(); + for ( ; it != end; ++it ) + add( *it ); +} + +void RSSService::saveLinks() +{ + KConfig *conf = kapp->config(); + conf->setGroup("RSS Links"); + QStringList lst; + QDictIterator itr(m_list); + for(; itr.current(); ++itr) + lst.append(itr.currentKey()); + + conf->writeEntry("links", lst); + conf->sync(); +} + + + -- cgit v1.2.1