• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

akregator

akregator.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of Akregator.
00003 
00004     Copyright (C) 2008 Didier Hoarau <did.hoarau@gmail.com>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 #include "akregator.h"
00026 #include "subscriptionlist.h"
00027 
00028 #include "feedlistmanagementinterface.h"
00029 
00030 #include <kdebug.h>
00031 #include <QStringList>
00032 #include <QTimer>
00033 
00034 namespace feedsync {
00035 
00036 Akregator::Akregator( QObject* p ) : Aggregator( p ) 
00037 {
00038     kDebug();
00039 }
00040 
00041 Akregator::~Akregator() 
00042 {
00043     kDebug();
00044 }
00045 
00046 SubscriptionList Akregator::getSubscriptionList() const 
00047 {
00048     kDebug();
00049     return _subscriptionList;
00050 }
00051 
00052 void Akregator::load() 
00053 {
00054     kDebug();
00055 
00056     using namespace Akregator;
00057 
00058     FeedListManagementInterface * ak_feedlist = FeedListManagementInterface::instance();
00059     QStringList catlist = ak_feedlist->categories();
00060     for (int idcat=0;idcat<catlist.size();idcat++) {
00061         QStringList feedlist = ak_feedlist->feeds(catlist.at(idcat));
00062         for (int idfeed=0;idfeed<feedlist.size();idfeed++) {
00063             QString tmpcat;
00064             if (catlist.at(idcat).compare("1/")==0) {
00065                 tmpcat = "";
00066             } else {
00067                 tmpcat = ak_feedlist->getCategoryName(catlist.at(idcat));
00068             }
00069             _subscriptionList.add( feedlist.at(idfeed),
00070                                     feedlist.at(idfeed),
00071                                     tmpcat );
00072         }
00073     }
00074 
00075     // Send the signal
00076     QTimer::singleShot( 0, this, SLOT(sendSignalLoadDone()) );
00077 }
00078 
00079 void Akregator::sendSignalLoadDone() 
00080 {
00081     emit loadDone();
00082 }
00083 
00084 void Akregator::add( const SubscriptionList & list) 
00085 {
00086     kDebug();
00087 
00088     using namespace Akregator;
00089 
00090     for (int i=0; i<list.count(); i++) {
00091         kDebug() << list.getRss(i).left(20);
00092 
00093         FeedListManagementInterface * ak_feedlist = FeedListManagementInterface::instance();
00094 
00095         // Look for the category id
00096         QString foundCatId;
00097         if (list.getCat(i).isEmpty()) {
00098             foundCatId = "1";
00099         } else {
00100             QStringList catlist = ak_feedlist->categories();
00101             int idcat = 0;
00102             while (idcat<catlist.size() && foundCatId.isEmpty()) {
00103                 QString ak_catId = catlist.at(idcat).split("/",QString::SkipEmptyParts).last();
00104                 QString ak_cat = ak_feedlist->getCategoryName(ak_catId).split("/",QString::SkipEmptyParts).last();
00105                 if (ak_cat.compare(list.getCat(i),Qt::CaseInsensitive)==0) {
00106                     foundCatId = ak_catId;
00107                 }
00108                 idcat++;
00109             }
00110         }
00111 
00112         // Cat not found --> Create
00113         if (foundCatId.isEmpty()) {
00114             foundCatId = ak_feedlist->addCategory( list.getCat(i), "1" );
00115         }
00116 
00117         // Add
00118         kDebug() << "Cat:" << foundCatId;
00119         ak_feedlist->addFeed(list.getRss(i),foundCatId);
00120     }
00121 
00122     // Emit signal
00123     emit addDone();
00124 }
00125 
00126 void Akregator::update(const SubscriptionList & list) 
00127 {
00128     kDebug();
00129 
00130     // Emit signal
00131     emit updateDone();
00132 }
00133 
00134 void Akregator::remove(const SubscriptionList & list) 
00135 {
00136     kDebug();
00137 
00138     for (int i=0; i<list.count(); i++) {
00139         kDebug() << list.getRss(i).left(20);
00140 
00141         using namespace Akregator;
00142 
00143         FeedListManagementInterface * ak_feedlist = FeedListManagementInterface::instance();
00144 
00145         // Look for the category id
00146         QString foundCatId;
00147         QStringList catlist = ak_feedlist->categories();
00148         int idcat = 0;
00149         while (idcat<catlist.size() && foundCatId.isEmpty()) {
00150             QString ak_catId = catlist.at(idcat).split("/",QString::SkipEmptyParts).last();
00151             QString ak_cat = ak_feedlist->getCategoryName(ak_catId).split("/",QString::SkipEmptyParts).last();
00152             if (ak_cat.compare(list.getCat(i),Qt::CaseInsensitive)==0) {
00153                 foundCatId = ak_catId;
00154             }
00155             idcat++;
00156         }
00157 
00158         // Remove
00159         ak_feedlist->removeFeed(list.getRss(i),foundCatId);
00160     }
00161 
00162     // Emit signal
00163     emit removeDone();
00164 }
00165 
00166 }

akregator

Skip menu "akregator"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal