4 * Copyright (c) 2007 Frerich Raabe <raabe@kde.org>
6 * This program is distributed in the hope that it will be useful, but WITHOUT
7 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8 * FOR A PARTICULAR PURPOSE. For licensing and distribution details, check the
9 * accompanying file 'COPYING'.
11 #include "newsfeedmanager.h"
15 using namespace Syndication
;
17 NewsFeedManager
*NewsFeedManager::s_instance
= 0;
19 NewsFeedManager
*NewsFeedManager::self()
22 s_instance
= new NewsFeedManager
;
27 NewsFeedManager::NewsFeedManager() : QObject()
31 void NewsFeedManager::setSubscriptions( const QStringList
&urls
)
33 m_subscriptions
= urls
;
36 void NewsFeedManager::update()
38 m_availableFeeds
.clear();
39 foreach ( const QString
&url
, m_subscriptions
) {
44 void NewsFeedManager::updateFeed( const QUrl
&url
)
46 Loader
*loader
= Loader::create( this, SLOT( loaderFinished( Syndication::Loader
*, Syndication::FeedPtr
, Syndication::ErrorCode
) ) );
47 m_activeLoaders
[ loader
] = url
;
48 loader
->loadFrom( url
);
51 const QMap
<QUrl
, FeedPtr
> &NewsFeedManager::availableFeeds() const
53 return m_availableFeeds
;
56 void NewsFeedManager::loaderFinished( Loader
*loader
, FeedPtr feed
, ErrorCode status
)
58 const QUrl url
= m_activeLoaders
[ loader
];
59 m_activeLoaders
.remove( loader
);
61 if ( status
== Syndication::Success
) {
62 m_availableFeeds
[ url
] = feed
;
64 emit
feedLoaded( url
);
67 if ( m_activeLoaders
.isEmpty() ) {
68 emit
updateFinished();
72 #include "newsfeedmanager.moc"