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

akregator

  • sources
  • kde-4.14
  • kdepim
  • akregator
  • src
akregator_part.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Akregator.
3 
4  Copyright (C) 2004 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net>
5  2005 Frank Osterfeld <osterfeld@kde.org>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of Qt, and distribute the resulting executable,
23  without including the source code for Qt in the source distribution.
24 */
25 
26 #include "akregator_part.h"
27 #include "akregatorconfig.h"
28 #include "aboutdata.h"
29 #include "actionmanagerimpl.h"
30 #include "article.h"
31 #include "fetchqueue.h"
32 #include "feediconmanager.h"
33 #include "framemanager.h"
34 #include "kernel.h"
35 #include "loadfeedlistcommand.h"
36 #include "mainwidget.h"
37 #include "notificationmanager.h"
38 #include "plugin.h"
39 #include "pluginmanager.h"
40 #include "storage.h"
41 #include "storagefactory.h"
42 #include "storagefactoryregistry.h"
43 #include "trayicon.h"
44 #include "dummystorage/storagefactorydummyimpl.h"
45 
46 #include <libkdepim/misc/broadcaststatus.h>
47 #include "kdepim-version.h"
48 
49 #include <knotifyconfigwidget.h>
50 #include <kaboutdata.h>
51 #include <kapplication.h>
52 #include <KCmdLineArgs>
53 #include <kconfig.h>
54 #include <kconfigdialog.h>
55 #include <kfiledialog.h>
56 #include <kglobalsettings.h>
57 #include <kmessagebox.h>
58 #include <kstandarddirs.h>
59 #include <ktemporaryfile.h>
60 #include <KSaveFile>
61 #include <kservice.h>
62 #include <kxmlguifactory.h>
63 #include <kio/netaccess.h>
64 #include <KPluginFactory>
65 #include <KParts/Plugin>
66 #include <KCMultiDialog>
67 #include <kstandardaction.h>
68 
69 #include <QFile>
70 #include <QObject>
71 #include <QStringList>
72 #include <QTextStream>
73 #include <QTimer>
74 #include <QWidget>
75 #include <QDomDocument>
76 #include "partadaptor.h"
77 
78 #include <memory>
79 
80 using namespace boost;
81 
82 namespace {
83 
84  static QDomDocument createDefaultFeedList() {
85  QDomDocument doc;
86  QDomProcessingInstruction z = doc.createProcessingInstruction("xml","version=\"1.0\" encoding=\"UTF-8\"");
87  doc.appendChild( z );
88 
89  QDomElement root = doc.createElement( "opml" );
90  root.setAttribute("version","1.0");
91  doc.appendChild( root );
92 
93  QDomElement head = doc.createElement( "head" );
94  root.appendChild(head);
95 
96  QDomElement text = doc.createElement( "text" );
97  text.appendChild(doc.createTextNode(i18n("Feeds")));
98  head.appendChild(text);
99 
100  QDomElement body = doc.createElement( "body" );
101  root.appendChild(body);
102 
103  QDomElement mainFolder = doc.createElement( "outline" );
104  mainFolder.setAttribute("text","KDE");
105  body.appendChild(mainFolder);
106 
107  /*
108  // NOTE: If these feeds ever get updated again, reenable them.
109  // For now I (Bertjan, July 2010) just disable them to
110  // make the default feeds non-embarassing (these are
111  // still updated regularly.
112  QDomElement ak = doc.createElement( "outline" );
113  ak.setAttribute("text",i18n("Akregator News"));
114  ak.setAttribute("xmlUrl","http://akregator.sf.net/rss2.php");
115  mainFolder.appendChild(ak);
116 
117  QDomElement akb = doc.createElement( "outline" );
118  akb.setAttribute("text",i18n("Akregator Blog"));
119  akb.setAttribute("xmlUrl","http://akregator.pwsp.net/blog/?feed=rss2");
120  mainFolder.appendChild(akb);
121  */
122 
123  QDomElement dot = doc.createElement( "outline" );
124  dot.setAttribute("text",i18n("KDE Dot News"));
125  dot.setAttribute("xmlUrl","http://www.kde.org/dotkdeorg.rdf");
126  mainFolder.appendChild(dot);
127 
128  QDomElement linuxFeeds = doc.createElement( "outline" );
129  linuxFeeds.setAttribute("text",i18n("Linux.com"));
130  linuxFeeds.setAttribute("xmlUrl","https://www.linux.com/rss/feeds.php");
131  mainFolder.appendChild(linuxFeeds);
132 
133  QDomElement planetkde = doc.createElement( "outline" );
134  planetkde.setAttribute("text",i18n("Planet KDE"));
135  planetkde.setAttribute("xmlUrl","http://planetkde.org/rss20.xml");
136  mainFolder.appendChild(planetkde);
137 
138  QDomElement planetkdepim = doc.createElement( "outline" );
139  planetkdepim.setAttribute("text",i18n("Planet KDE PIM"));
140  planetkdepim.setAttribute("xmlUrl","http://pim.planetkde.org/rss20.xml");
141  mainFolder.appendChild(planetkdepim);
142 
143  QDomElement apps = doc.createElement( "outline" );
144  apps.setAttribute("text",i18n("KDE Apps"));
145  apps.setAttribute("xmlUrl","http://www.kde.org/dot/kde-apps-content.rdf");
146  mainFolder.appendChild(apps);
147 
148  QDomElement look = doc.createElement( "outline" );
149  look.setAttribute("text",i18n("KDE Look"));
150  look.setAttribute("xmlUrl","http://www.kde.org/kde-look-content.rdf");
151  mainFolder.appendChild(look);
152 
153  // hungarian feed(s)
154  QDomElement hungarianFolder = doc.createElement( "outline" );
155  hungarianFolder.setAttribute("text",i18n("Hungarian feeds"));
156  mainFolder.appendChild(hungarianFolder);
157 
158  QDomElement hungarianKde = doc.createElement( "outline" );
159  hungarianKde.setAttribute("text",i18n("KDE.HU"));
160  hungarianKde.setAttribute("xmlUrl","http://kde.hu/rss.xml");
161  hungarianFolder.appendChild(hungarianKde);
162 
163  // spanish feed(s)
164  QDomElement spanishFolder = doc.createElement( "outline" );
165  spanishFolder.setAttribute("text",i18n("Spanish feeds"));
166  mainFolder.appendChild(spanishFolder);
167 
168  QDomElement spanishKde = doc.createElement( "outline" );
169  spanishKde.setAttribute("text",i18n("Planet KDE EspaƱa"));
170  spanishKde.setAttribute("xmlUrl","http://planet.kde-espana.es/");
171  spanishFolder.appendChild(spanishKde);
172 
173  return doc;
174  }
175 }
176 
177 namespace Akregator {
178 
179 static const KAboutData &createAboutData()
180 {
181  static Akregator::AboutData about;
182  return about;
183 }
184 
185 K_PLUGIN_FACTORY(AkregatorFactory, registerPlugin<Part>();)
186 K_EXPORT_PLUGIN(AkregatorFactory(createAboutData()))
187 
188 BrowserExtension::BrowserExtension(Part *p, const char *name)
189  : KParts::BrowserExtension( p)
190 {
191  setObjectName(name);
192  m_part=p;
193 }
194 
195 void BrowserExtension::saveSettings()
196 {
197  m_part->saveSettings();
198 }
199 
200 Part::Part( QWidget *parentWidget, QObject *parent, const QVariantList& )
201  : inherited(parent)
202  , m_standardListLoaded(false)
203  , m_shuttingDown(false)
204  , m_doCrashSave(true)
205  , m_backedUpList(false)
206  , m_mainWidget(0)
207  , m_storage(0)
208  , m_dialog(0)
209 
210 {
211  initFonts();
212 
213  setPluginLoadingMode( LoadPluginsIfEnabled );
214  setPluginInterfaceVersion( AKREGATOR_PLUGIN_INTERFACE_VERSION );
215 
216  setComponentData( AkregatorFactory::componentData() );
217  setXMLFile("akregator_part.rc", true);
218 
219  new PartAdaptor( this );
220  QDBusConnection::sessionBus().registerObject("/Akregator", this);
221 
222  FeedIconManager::self(); // FIXME: registering the icon manager dbus iface here,
223  // because otherwise we get a deadlock later
224 
225  m_standardFeedList = KGlobal::dirs()->saveLocation("data", "akregator/data") + "/feeds.opml";
226 
227  Backend::StorageFactoryDummyImpl* dummyFactory = new Backend::StorageFactoryDummyImpl();
228  if (!Backend::StorageFactoryRegistry::self()->registerFactory(dummyFactory, dummyFactory->key())) {
229  // There was already a dummy factory registered.
230  delete dummyFactory;
231  }
232  loadPlugins( QLatin1String("storage") ); // FIXME: also unload them!
233 
234  m_storage = 0;
235  Backend::StorageFactory* storageFactory = Backend::StorageFactoryRegistry::self()->getFactory(Settings::archiveBackend());
236  if (storageFactory != 0)
237  m_storage = storageFactory->createStorage(QStringList());
238 
239  if (!m_storage) // Houston, we have a problem
240  {
241  m_storage = Backend::StorageFactoryRegistry::self()->getFactory("dummy")->createStorage(QStringList());
242 
243  KMessageBox::error(parentWidget, i18n("Unable to load storage backend plugin \"%1\". No feeds are archived.", Settings::archiveBackend()), i18n("Plugin error") );
244  }
245 
246  m_storage->open(true);
247  Kernel::self()->setStorage(m_storage);
248 
249  m_actionManager = new ActionManagerImpl(this);
250  ActionManager::setInstance(m_actionManager);
251 
252  m_mainWidget = new Akregator::MainWidget(this, parentWidget, m_actionManager, "akregator_view");
253  m_extension = new BrowserExtension(this, "ak_extension");
254 
255  connect(Kernel::self()->frameManager(), SIGNAL(signalCaptionChanged(QString)), this, SIGNAL(setWindowCaption(QString)));
256  connect(Kernel::self()->frameManager(), SIGNAL(signalStatusText(QString)), this, SLOT(slotSetStatusText(QString)));
257  connect(Kernel::self()->frameManager(), SIGNAL(signalLoadingProgress(int)), m_extension, SIGNAL(loadingProgress(int)));
258  connect(Kernel::self()->frameManager(), SIGNAL(signalCanceled(QString)), this, SIGNAL(canceled(QString)));
259  connect(Kernel::self()->frameManager(), SIGNAL(signalStarted()), this, SLOT(slotStarted()));
260  connect(Kernel::self()->frameManager(), SIGNAL(signalCompleted()), this, SIGNAL(completed()));
261 
262  // notify the part that this is our internal widget
263  setWidget(m_mainWidget);
264 
265  if ( Settings::showTrayIcon() && !TrayIcon::getInstance() )
266  {
267  TrayIcon* trayIcon = new TrayIcon( m_mainWidget->window() );
268  TrayIcon::setInstance(trayIcon);
269  m_actionManager->setTrayIcon(trayIcon);
270 
271  if ( isTrayIconEnabled() )
272  trayIcon->setStatus( KStatusNotifierItem::Active );
273 
274  QWidget* const notificationParent = isTrayIconEnabled() ? m_mainWidget->window() : 0;
275  NotificationManager::self()->setWidget(notificationParent, componentData());
276 
277  connect( m_mainWidget, SIGNAL(signalUnreadCountChanged(int)), trayIcon, SLOT(slotSetUnread(int)) );
278  connect( m_mainWidget, SIGNAL(signalArticlesSelected(QList<Akregator::Article>)),
279  this, SIGNAL(signalArticlesSelected(QList<Akregator::Article>)) );
280  }
281 
282  connect(kapp, SIGNAL(aboutToQuit()), this, SLOT(slotOnShutdown()));
283 
284  m_autosaveTimer = new QTimer(this);
285  connect(m_autosaveTimer, SIGNAL(timeout()), this, SLOT(slotSaveFeedList()));
286  m_autosaveTimer->start(5*60*1000); // 5 minutes
287 
288  QString useragent = QString( "Akregator/%1; syndication" ).arg( KDEPIM_VERSION );
289 
290  if( !Settings::customUserAgent().isEmpty() )
291  useragent = Settings::customUserAgent();
292 
293  Syndication::FileRetriever::setUserAgent( useragent );
294 
295  loadPlugins( QLatin1String("extension") ); // FIXME: also unload them!
296 
297  if (!readCrashProperties())
298  autoReadProperties();
299 }
300 
301 void Part::loadPlugins( const QString& type )
302 {
303  const KService::List offers = PluginManager::query( QString::fromLatin1("[X-KDE-akregator-plugintype] == '%1'").arg( type ) );
304 
305  Q_FOREACH ( const KService::Ptr& i, offers ) {
306  Akregator::Plugin* plugin = PluginManager::createFromService( i, this );
307  if ( !plugin )
308  continue;
309  plugin->initialize();
310  plugin->insertGuiClients( this );
311  }
312 }
313 
314 void Part::slotStarted()
315 {
316  emit started(0L);
317 }
318 
319 void Part::slotOnShutdown()
320 {
321  autoSaveProperties();
322  m_shuttingDown = true;
323  m_autosaveTimer->stop();
324  saveSettings();
325  slotSaveFeedList();
326  m_mainWidget->slotOnShutdown();
327  //delete m_mainWidget;
328  delete TrayIcon::getInstance();
329  TrayIcon::setInstance(0L);
330  delete m_storage;
331  m_storage = 0;
332  //delete m_actionManager;
333 }
334 
335 void Part::slotSettingsChanged()
336 {
337  NotificationManager::self()->setWidget(isTrayIconEnabled() ? m_mainWidget->window() : 0, componentData());
338 
339  if ( Settings::showTrayIcon() && !TrayIcon::getInstance() )
340  {
341  TrayIcon* trayIcon = new TrayIcon( m_mainWidget->window() );
342  TrayIcon::setInstance(trayIcon);
343  m_actionManager->setTrayIcon(trayIcon);
344 
345  if ( isTrayIconEnabled() )
346  trayIcon->setStatus( KStatusNotifierItem::Active );
347 
348  connect( m_mainWidget, SIGNAL(signalUnreadCountChanged(int)), trayIcon, SLOT(slotSetUnread(int)) );
349  connect( m_mainWidget, SIGNAL(signalArticlesSelected(QList<Akregator::Article>)),
350  this, SIGNAL(signalArticlesSelected(QList<Akregator::Article>)) );
351 
352  m_mainWidget->slotSetTotalUnread();
353  }
354  if ( !Settings::showTrayIcon() )
355  {
356  TrayIcon::getInstance()->disconnect();
357  delete TrayIcon::getInstance();
358  TrayIcon::setInstance(0);
359  m_actionManager->setTrayIcon(0);
360  }
361 
362  Syndication::FileRetriever::setUseCache(Settings::useHTMLCache());
363 
364  QStringList fonts;
365  fonts.append(Settings::standardFont());
366  fonts.append(Settings::fixedFont());
367  fonts.append(Settings::sansSerifFont());
368  fonts.append(Settings::serifFont());
369  fonts.append(Settings::standardFont());
370  fonts.append(Settings::standardFont());
371  fonts.append("0");
372  Settings::setFonts(fonts);
373 
374  if (Settings::minimumFontSize() > Settings::mediumFontSize())
375  Settings::setMediumFontSize(Settings::minimumFontSize());
376  saveSettings();
377  emit signalSettingsChanged();
378 }
379 
380 void Part::slotSetStatusText( const QString& statusText )
381 {
382  KPIM::BroadcastStatus::instance()->setStatusMsg( statusText );
383 }
384 
385 void Part::saveSettings()
386 {
387  m_mainWidget->saveSettings();
388 }
389 
390 Part::~Part()
391 {
392  kDebug() <<"Part::~Part() enter";
393  // If the widget is destroyed for some reason, KParts::Part will set its
394  // widget property to 0 and then delete itself (and therefore this object).
395  // In this case, it's not safe to do our normal shutdown routine.
396  if (widget() && !m_shuttingDown) {
397  slotOnShutdown();
398  }
399  kDebug() <<"Part::~Part(): leaving";
400 }
401 
402 void Part::readProperties(const KConfigGroup & config)
403 {
404  m_backedUpList = false;
405  openStandardFeedList();
406 
407  if(m_mainWidget)
408  m_mainWidget->readProperties(config);
409 }
410 
411 void Part::saveProperties(KConfigGroup & config)
412 {
413  if (m_mainWidget)
414  {
415  slotSaveFeedList();
416  m_mainWidget->saveProperties(config);
417  }
418 }
419 
420 bool Part::openUrl(const KUrl& url)
421 {
422  setLocalFilePath(url.toLocalFile());
423  return openFile();
424 }
425 
426 void Part::openStandardFeedList()
427 {
428  if ( !m_standardFeedList.isEmpty() )
429  openUrl( KUrl::fromPath( m_standardFeedList ) );
430 }
431 
432 bool Part::openFile() {
433  if ( m_loadFeedListCommand || m_standardListLoaded )
434  return true;
435  std::auto_ptr<LoadFeedListCommand> cmd( new LoadFeedListCommand( m_mainWidget ) );
436  cmd->setParentWidget( m_mainWidget );
437  cmd->setStorage( Kernel::self()->storage() );
438  cmd->setFileName( localFilePath() );
439  cmd->setDefaultFeedList( createDefaultFeedList() );
440  connect( cmd.get(), SIGNAL(result(boost::shared_ptr<Akregator::FeedList>)),
441  this, SLOT(feedListLoaded(boost::shared_ptr<Akregator::FeedList>)) );
442  m_loadFeedListCommand = cmd.release();
443  m_loadFeedListCommand->start();
444  return true;
445 }
446 
447 bool Part::writeToTextFile( const QString& data, const QString& filename ) const {
448  KSaveFile file( filename );
449  if ( !file.open( QIODevice::WriteOnly ) )
450  return false;
451  QTextStream stream( &file );
452  stream.setCodec( "UTF-8" );
453  stream << data << endl;
454  return file.finalize();
455 }
456 
457 void Part::feedListLoaded( const shared_ptr<FeedList>& list ) {
458  assert( !m_standardListLoaded );
459  m_mainWidget->setFeedList( list );
460  m_standardListLoaded = list != 0;
461 
462  if( Settings::markAllFeedsReadOnStartup() )
463  m_mainWidget->slotMarkAllFeedsRead();
464 
465  if ( m_standardListLoaded )
466  QTimer::singleShot( 0, this, SLOT(flushAddFeedRequests()) );
467 
468  if (Settings::fetchOnStartup())
469  m_mainWidget->slotFetchAllFeeds();
470 }
471 
472 void Part::flushAddFeedRequests() {
473  Q_FOREACH( const AddFeedRequest& i, m_requests ) {
474  Q_FOREACH ( const QString& j, i.urls )
475  m_mainWidget->addFeedToGroup( j, i.group );
476  NotificationManager::self()->slotNotifyFeeds( i.urls );
477  }
478  m_requests.clear();
479 }
480 
481 void Part::slotSaveFeedList()
482 {
483  // don't save to the standard feed list, when it wasn't completely loaded before
484  if ( !m_standardListLoaded )
485  return;
486 
487  // the first time we overwrite the feed list, we create a backup
488  if ( !m_backedUpList )
489  {
490  const QString backup = localFilePath() + QLatin1String( "~" );
491  if ( QFile::copy( localFilePath(), backup ) )
492  m_backedUpList = true;
493  }
494 
495  const QString xml = m_mainWidget->feedListToOPML().toString();
496  m_storage->storeFeedList( xml );
497  if ( writeToTextFile( xml, localFilePath() ) )
498  return;
499 
500  KMessageBox::error( m_mainWidget,
501  i18n( "Access denied: Cannot save feed list to <b>%1</b>. Please check your permissions.", localFilePath() ),
502  i18n( "Write Error" ) );
503 }
504 
505 bool Part::isTrayIconEnabled() const
506 {
507  return Settings::showTrayIcon();
508 }
509 
510 void Part::importFile(const KUrl& url)
511 {
512  QString filename;
513 
514  bool isRemote = false;
515 
516  if (url.isLocalFile())
517  filename = url.toLocalFile();
518  else
519  {
520  isRemote = true;
521 
522  if (!KIO::NetAccess::download(url, filename, m_mainWidget) )
523  {
524  KMessageBox::error(m_mainWidget, KIO::NetAccess::lastErrorString() );
525  return;
526  }
527  }
528 
529  QFile file(filename);
530  if (file.open(QIODevice::ReadOnly))
531  {
532  // Read OPML feeds list and build QDom tree.
533  QDomDocument doc;
534  if (doc.setContent(file.readAll()))
535  m_mainWidget->importFeedList( doc );
536  else
537  KMessageBox::error(m_mainWidget, i18n("Could not import the file %1 (no valid OPML)", filename), i18n("OPML Parsing Error") );
538  }
539  else
540  KMessageBox::error(m_mainWidget, i18n("The file %1 could not be read, check if it exists or if it is readable for the current user.", filename), i18n("Read Error"));
541 
542  if (isRemote)
543  KIO::NetAccess::removeTempFile(filename);
544 }
545 
546 void Part::exportFile(const KUrl& url)
547 {
548  if (url.isLocalFile())
549  {
550  const QString fname = url.toLocalFile();
551 
552  if ( QFile::exists( fname ) &&
553  KMessageBox::questionYesNo(m_mainWidget,
554  i18n("The file %1 already exists; do you want to overwrite it?", fname ),
555  i18n("Export"),
556  KStandardGuiItem::overwrite(),
557  KStandardGuiItem::cancel()) == KMessageBox::No )
558  return;
559 
560  if ( !writeToTextFile( m_mainWidget->feedListToOPML().toString(), fname ) )
561  KMessageBox::error(m_mainWidget, i18n("Access denied: cannot write to file %1. Please check your permissions.", fname), i18n("Write Error") );
562 
563  return;
564  }
565  else
566  {
567  KTemporaryFile tmpfile;
568  tmpfile.open();
569 
570  QTextStream stream(&tmpfile);
571  stream.setCodec("UTF-8");
572 
573  stream << m_mainWidget->feedListToOPML().toString() << "\n";
574  stream.flush();
575 
576  if (!KIO::NetAccess::upload(tmpfile.fileName(), url, m_mainWidget))
577  KMessageBox::error(m_mainWidget, KIO::NetAccess::lastErrorString() );
578  }
579 }
580 
581 void Part::fileImport()
582 {
583  KUrl url = KFileDialog::getOpenUrl( KUrl(),
584  "*.opml *.xml|" + i18n("OPML Outlines (*.opml, *.xml)")
585  +"\n*|" + i18n("All Files") );
586 
587  if (!url.isEmpty())
588  importFile(url);
589 }
590 
591  void Part::fileExport()
592 {
593  KUrl url= KFileDialog::getSaveUrl( KUrl(),
594  "*.opml *.xml|" + i18n("OPML Outlines (*.opml, *.xml)")
595  +"\n*|" + i18n("All Files") );
596 
597  if ( !url.isEmpty() )
598  exportFile(url);
599 }
600 
601 void Part::fetchAllFeeds()
602 {
603  m_mainWidget->slotFetchAllFeeds();
604 }
605 
606 void Part::fetchFeedUrl(const QString&s)
607 {
608  kDebug() <<"fetchFeedURL==" << s;
609 }
610 
611 void Part::addFeedsToGroup(const QStringList& urls, const QString& group)
612 {
613  AddFeedRequest req;
614  req.group = group;
615  req.urls = urls;
616  m_requests.append( req );
617  if ( m_standardListLoaded )
618  flushAddFeedRequests();
619 }
620 
621 void Part::addFeed()
622 {
623  m_mainWidget->slotFeedAdd();
624 }
625 
626 void Part::showNotificationOptions()
627 {
628  const Akregator::AboutData about;
629  KNotifyConfigWidget::configure(m_mainWidget, about.appName() );
630 }
631 
632 void Part::showOptions()
633 {
634  saveSettings();
635 
636  if ( !m_dialog ) {
637  m_dialog = new KCMultiDialog( m_mainWidget );
638  connect( m_dialog, SIGNAL(configCommitted()),
639  this, SLOT(slotSettingsChanged()) );
640  connect( m_dialog, SIGNAL(configCommitted()),
641  TrayIcon::getInstance(), SLOT(settingsChanged()) );
642 
643  // query for akregator's kcm modules
644  const QString constraint = "[X-KDE-ParentApp] == 'akregator'";
645  const KService::List offers = KServiceTypeTrader::self()->query( "KCModule", constraint );
646  foreach( const KService::Ptr &service, offers ) {
647  m_dialog->addModule( service->storageId() );
648  }
649  }
650 
651  m_dialog->show();
652  m_dialog->raise();
653 }
654 
655 KParts::Part* Part::hitTest(QWidget *widget, const QPoint &globalPos)
656 {
657 /* bool child = false;
658  QWidget *me = this->widget();
659  while (widget)
660  {
661  if (widget == me)
662  {
663  child = true;
664  break;
665  }
666  if (!widget)
667  {
668  break;
669  }
670  widget = widget->parentWidget();
671  }
672  if (m_mainWidget && m_mainWidget->currentFrame() && child)
673  {
674  return m_mainWidget->currentFrame()->part();
675  }
676  else
677  {*/
678  return inherited::hitTest(widget, globalPos);
679 /* }*/
680 }
681 
682 void Part::initFonts()
683 {
684  QStringList fonts = Settings::fonts();
685  if (fonts.isEmpty())
686  {
687  fonts.append(KGlobalSettings::generalFont().family());
688  fonts.append(KGlobalSettings::fixedFont().family());
689  fonts.append(KGlobalSettings::generalFont().family());
690  fonts.append(KGlobalSettings::generalFont().family());
691  fonts.append("0");
692  }
693  Settings::setFonts(fonts);
694  if (Settings::standardFont().isEmpty())
695  Settings::setStandardFont(fonts[0]);
696  if (Settings::fixedFont().isEmpty())
697  Settings::setFixedFont(fonts[1]);
698  if (Settings::sansSerifFont().isEmpty())
699  Settings::setSansSerifFont(fonts[2]);
700  if (Settings::serifFont().isEmpty())
701  Settings::setSerifFont(fonts[3]);
702 
703  KConfigGroup conf( Settings::self()->config(), "HTML Settings");
704 
705  KConfig _konq( "konquerorrc", KConfig::NoGlobals );
706  KConfigGroup konq(&_konq, "HTML Settings");
707 
708  if (!conf.hasKey("MinimumFontSize"))
709  {
710  int minfs;
711  if (konq.hasKey("MinimumFontSize"))
712  minfs = konq.readEntry("MinimumFontSize", 8);
713  else
714  minfs = std::max( KGlobalSettings::generalFont().pointSize() - 2, 4 );
715  Settings::setMinimumFontSize(minfs);
716  }
717 
718  if (!conf.hasKey("MediumFontSize"))
719  {
720  int medfs;
721  if (konq.hasKey("MediumFontSize"))
722  medfs = konq.readEntry("MediumFontSize", 12);
723  else
724  medfs = KGlobalSettings::generalFont().pointSize();
725  Settings::setMediumFontSize(medfs);
726  }
727 
728  if (!conf.hasKey("UnderlineLinks"))
729  {
730  bool underline = true;
731  if (konq.hasKey("UnderlineLinks"))
732  underline = konq.readEntry("UnderlineLinks", false);
733  Settings::setUnderlineLinks(underline);
734  }
735 }
736 
737 bool Part::handleCommandLine() {
738  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
739  QString addFeedGroup = !args->getOption("group").isEmpty() ?
740  args->getOption("group")
741  : i18n("Imported Folder");
742 
743  QStringList feedsToAdd = args->getOptionList("addfeed");
744 
745  if (feedsToAdd.isEmpty() && args->count() > 0) {
746  QString url = args->url(0).url();
747  if(!url.isEmpty())
748  feedsToAdd.append(url);
749  }
750 
751  if (!feedsToAdd.isEmpty())
752  addFeedsToGroup( feedsToAdd, addFeedGroup );
753  return true;
754 }
755 
756 void Part::clearCrashProperties()
757 {
758  if (!m_doCrashSave)
759  return;
760  KConfig config("crashed", KConfig::SimpleConfig,
761  "appdata");
762  KConfigGroup configGroup(&config, "Part");
763  configGroup.writeEntry("crashed", false);
764 }
765 
766 
767 void Part::saveCrashProperties()
768 {
769  if (!m_doCrashSave)
770  return;
771  KConfig config("crashed", KConfig::SimpleConfig,
772  "appdata");
773  KConfigGroup configGroup(&config, "Part");
774  configGroup.deleteGroup();
775 
776  configGroup.writeEntry("crashed", true);
777 
778  saveProperties(configGroup);
779 }
780 
781 bool Part::readCrashProperties()
782 {
783  KConfig config("crashed", KConfig::SimpleConfig,
784  "appdata");
785  KConfigGroup configGroup(&config, "Part");
786 
787  if (!configGroup.readEntry("crashed", false))
788  return false;
789 
790  const int choice = KMessageBox::questionYesNoCancel( m_mainWidget,
791  i18n("Akregator did not close correctly. Would you like to restore the previous session?"),
792  i18n("Restore Session?"),
793  KGuiItem(i18n("Restore Session"), "window-new"),
794  KGuiItem(i18n("Do Not Restore"), "dialog-close"),
795  KGuiItem(i18n("Ask Me Later"), "chronometer"),
796  "Restore session when akregator didn't close correctly" );
797  switch ( choice ) {
798  case KMessageBox::Yes:
799  readProperties(configGroup);
800  clearCrashProperties();
801  return true;
802  case KMessageBox::No:
803  clearCrashProperties();
804  return false;
805  default:
806  break;
807  }
808  m_doCrashSave = false;
809  return false;
810 }
811 
812 void Part::slotAutoSave()
813 {
814  saveCrashProperties();
815 }
816 
817 void Part::autoSaveProperties()
818 {
819  KConfig config("autosaved", KConfig::SimpleConfig, "appdata");
820  KConfigGroup configGroup(&config, "Part");
821  configGroup.deleteGroup();
822 
823  saveProperties(configGroup);
824 
825  clearCrashProperties();
826 }
827 
828 void Part::autoReadProperties()
829 {
830  if(kapp->isSessionRestored())
831  return;
832 
833  KConfig config("autosaved", KConfig::SimpleConfig, "appdata");
834  KConfigGroup configGroup(&config, "Part");
835 
836  readProperties(configGroup);
837 }
838 
839 } // namespace Akregator
840 
QTextStream::setCodec
void setCodec(QTextCodec *codec)
storagefactoryregistry.h
QWidget
Akregator::Part::~Part
~Part()
Destructor.
Definition: akregator_part.cpp:390
Akregator::MainWidget::saveProperties
void saveProperties(KConfigGroup &config)
Definition: mainwidget.cpp:1163
QDomDocument::createProcessingInstruction
QDomProcessingInstruction createProcessingInstruction(const QString &target, const QString &data)
Akregator::MainWidget::saveSettings
void saveSettings()
saves settings.
Definition: mainwidget.cpp:342
Akregator::TrayIcon
Definition: trayicon.h:37
Akregator::Plugin::initialize
void initialize()
Definition: plugin.cpp:46
Akregator::MainWidget::slotFeedAdd
void slotFeedAdd()
adds a new feed to the feed tree
Definition: mainwidget.cpp:650
QDomNode::appendChild
QDomNode appendChild(const QDomNode &newChild)
QVector::append
void append(const T &value)
Akregator::LoadFeedListCommand
Definition: loadfeedlistcommand.h:44
pluginmanager.h
QWidget::window
QWidget * window() const
AKREGATOR_PLUGIN_INTERFACE_VERSION
#define AKREGATOR_PLUGIN_INTERFACE_VERSION
Definition: plugin.h:37
Akregator::MainWidget
This is the main widget of the view, containing tree view, article list, viewer etc.
Definition: mainwidget.h:68
Akregator::Part::readProperties
virtual void readProperties(const KConfigGroup &config)
This method is called when this app is restored.
Definition: akregator_part.cpp:402
Akregator::Part::saveSettings
void saveSettings()
Used to save settings after changing them from configuration dialog.
Definition: akregator_part.cpp:385
kernel.h
QDomDocument::toString
QString toString(int indent) const
Akregator::AboutData
Definition: aboutdata.h:35
Akregator::MainWidget::importFeedList
void importFeedList(const QDomDocument &doc)
Adds the feeds in doc to the "Imported Folder".
Definition: mainwidget.cpp:414
Akregator::MainWidget::setFeedList
void setFeedList(const boost::shared_ptr< FeedList > &feedList)
Definition: mainwidget.cpp:423
Akregator::Backend::StorageFactoryDummyImpl::key
virtual QString key() const
identifier of the storage type, like "metakit", "postgres" etc.
Definition: storagefactorydummyimpl.cpp:41
QDBusConnection::registerObject
bool registerObject(const QString &path, QObject *object, QFlags< QDBusConnection::RegisterOption > options)
Akregator::Part::handleCommandLine
bool handleCommandLine()
Definition: akregator_part.cpp:737
plugin.h
Akregator::Kernel::setStorage
void setStorage(Backend::Storage *storage)
Definition: kernel.cpp:77
Akregator::Part::signalSettingsChanged
void signalSettingsChanged()
Akregator::Part::addFeedsToGroup
void addFeedsToGroup(const QStringList &urls, const QString &group)
Add a feed to a group.
Definition: akregator_part.cpp:611
QDBusConnection::sessionBus
QDBusConnection sessionBus()
Akregator::ActionManager::setInstance
static void setInstance(ActionManager *manager)
Definition: actionmanager.cpp:40
QPoint
QFile::exists
bool exists() const
Akregator::Part
This is a RSS Aggregator "Part".
Definition: akregator_part.h:77
Akregator::Part::saveProperties
virtual void saveProperties(KConfigGroup &config)
This method is called when it is time for the app to save its properties for session management purpo...
Definition: akregator_part.cpp:411
Akregator::Backend::StorageFactoryRegistry::self
static StorageFactoryRegistry * self()
Definition: storagefactoryregistry.cpp:43
Akregator::Plugin
Definition: plugin.h:41
QFile
QFile::copy
bool copy(const QString &newName)
Akregator::Plugin::insertGuiClients
virtual void insertGuiClients(KXMLGUIClient *parent)
Definition: plugin.cpp:68
QTextStream
Akregator::ActionManagerImpl::setTrayIcon
void setTrayIcon(TrayIcon *trayIcon)
Definition: actionmanagerimpl.cpp:155
Akregator::Part::signalArticlesSelected
void signalArticlesSelected(const QList< Akregator::Article > &)
Akregator::Part::showNotificationOptions
void showNotificationOptions()
Definition: akregator_part.cpp:626
Akregator::MainWidget::slotSetTotalUnread
void slotSetTotalUnread()
emits signalUnreadCountChanged(int)
Definition: mainwidget.cpp:763
Akregator::NotificationManager::setWidget
void setWidget(QWidget *widget, const KComponentData &inst=KComponentData())
the widget used for notification, normally either the mainwindow or the tray icon ...
Definition: notificationmanager.cpp:54
storagefactorydummyimpl.h
Akregator::PluginManager::query
static KService::List query(const QString &constraint=QString())
It will return a list of services that match your specifications.
Definition: pluginmanager.cpp:41
QList::append
void append(const T &value)
QTimer
Akregator::Backend::StorageFactory
Definition: storagefactory.h:37
Akregator::Part::exportFile
void exportFile(const KUrl &url)
Definition: akregator_part.cpp:546
Akregator::ActionManagerImpl
Akregator-specific implementation of the ActionManager interface.
Definition: actionmanagerimpl.h:50
QObject
Akregator::NotificationManager::self
static NotificationManager * self()
singleton instance of notification manager
Definition: notificationmanager.cpp:130
QDomElement::setAttribute
void setAttribute(const QString &name, const QString &value)
Akregator::TrayIcon::setInstance
static void setInstance(TrayIcon *trayIcon)
Definition: trayicon.cpp:50
akregator_part.h
QList::isEmpty
bool isEmpty() const
Akregator::Kernel::self
static Kernel * self()
Definition: kernel.cpp:39
Akregator::MainWidget::slotOnShutdown
void slotOnShutdown()
Definition: mainwidget.cpp:316
QString::isEmpty
bool isEmpty() const
aboutdata.h
fetchqueue.h
Akregator::MainWidget::readProperties
void readProperties(const KConfigGroup &config)
session management
Definition: mainwidget.cpp:1138
QDomProcessingInstruction
Akregator::BrowserExtension
Definition: akregator_part.h:61
KAboutData
Akregator::Part::slotSaveFeedList
void slotSaveFeedList()
Saves the standard feed list to it's default location.
Definition: akregator_part.cpp:481
Akregator::Backend::Storage::storeFeedList
virtual void storeFeedList(const QString &opmlStr)=0
stores the feed list in the storage backend.
QString
storagefactory.h
QList< Akregator::Article >
Akregator::MainWidget::slotFetchAllFeeds
void slotFetchAllFeeds()
starts fetching of all feeds in the tree
Definition: mainwidget.cpp:792
article.h
storage.h
Akregator::Part::fileExport
void fileExport()
Definition: akregator_part.cpp:591
Akregator::Backend::StorageFactoryRegistry::getFactory
StorageFactory * getFactory(const QString &typestr)
Definition: storagefactoryregistry.cpp:64
Akregator::Backend::Storage::open
virtual bool open(bool autoCommit=false)=0
Open storage and prepare it for work.
QStringList
loadfeedlistcommand.h
trayicon.h
Akregator::Part::showOptions
void showOptions()
Shows configuration dialog.
Definition: akregator_part.cpp:632
QDomDocument::createTextNode
QDomText createTextNode(const QString &value)
Akregator::Part::addFeed
void addFeed()
Definition: akregator_part.cpp:621
Akregator::Backend::StorageFactory::createStorage
virtual Storage * createStorage(const QStringList &params) const =0
creates a storage object with given parameters
QDomDocument
Akregator::Part::fileImport
void fileImport()
Definition: akregator_part.cpp:581
Akregator::Part::openUrl
bool openUrl(const KUrl &url)
Opens feedlist.
Definition: akregator_part.cpp:420
QTimer::stop
void stop()
mainwidget.h
Akregator::TrayIcon::getInstance
static TrayIcon * getInstance()
Definition: trayicon.cpp:45
Akregator::Backend::StorageFactoryDummyImpl
Definition: storagefactorydummyimpl.h:39
Akregator::K_EXPORT_PLUGIN
K_EXPORT_PLUGIN(AkregatorFactory(createAboutData())) BrowserExtension
Definition: akregator_part.cpp:186
Akregator::MainWidget::slotMarkAllFeedsRead
void slotMarkAllFeedsRead()
marks all articles in all feeds in the tree as read
Definition: mainwidget.cpp:747
actionmanagerimpl.h
QTextStream::flush
void flush()
QLatin1String
Akregator::MainWidget::feedListToOPML
QDomDocument feedListToOPML()
Definition: mainwidget.cpp:464
Akregator::Part::fetchAllFeeds
void fetchAllFeeds()
Fetch all feeds in the feed tree.
Definition: akregator_part.cpp:601
Akregator::PluginManager::createFromService
static Akregator::Plugin * createFromService(const KService::Ptr service, QObject *parent=0)
Load and instantiate plugin from service.
Definition: pluginmanager.cpp:81
Akregator::Part::fetchFeedUrl
void fetchFeedUrl(const QString &)
Definition: akregator_part.cpp:606
QString::fromLatin1
QString fromLatin1(const char *str, int size)
QTimer::start
void start(int msec)
notificationmanager.h
feediconmanager.h
QDomDocument::createElement
QDomElement createElement(const QString &tagName)
Akregator::Part::slotAutoSave
void slotAutoSave()
Call to auto save.
Definition: akregator_part.cpp:812
framemanager.h
QDomElement
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Akregator::Part::openStandardFeedList
void openStandardFeedList()
Opens standard feedlist.
Definition: akregator_part.cpp:426
Akregator::FeedIconManager::self
static FeedIconManager * self()
Definition: feediconmanager.cpp:115
Akregator::Part::inherited
KParts::ReadOnlyPart inherited
Definition: akregator_part.h:81
QDomDocument::setContent
bool setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
Akregator::createAboutData
static const KAboutData & createAboutData()
Definition: akregator_part.cpp:179
QTimer::singleShot
singleShot
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akregator

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

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal