summaryrefslogtreecommitdiffstats
path: root/dcoprss/service.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbcb704366cb5e333a626c18c308c7e0448a8e69f (patch)
treef0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /dcoprss/service.cpp
downloadtdenetwork-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 'dcoprss/service.cpp')
-rw-r--r--dcoprss/service.cpp105
1 files changed, 105 insertions, 0 deletions
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 <kdebug.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include "service.h"
+#include "cache.h"
+
+RSSService::RSSService() :
+ DCOPObject("RSSService")
+{
+ m_list.setAutoDelete( true );
+
+ loadLinks();
+}
+
+RSSService::~RSSService()
+{
+}
+
+
+QStringList RSSService::list()
+{
+ QStringList lst;
+ QDictIterator<RSSDocument> 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<RSSDocument> itr(m_list);
+ for(; itr.current(); ++itr)
+ lst.append(itr.currentKey());
+
+ conf->writeEntry("links", lst);
+ conf->sync();
+}
+
+
+