• Skip to content
  • Skip to link menu
KDE 4.7 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

akonadi

changerecorder.cpp
00001 /*
00002     Copyright (c) 2007 Volker Krause <vkrause@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or modify it
00005     under the terms of the GNU Library General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or (at your
00007     option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful, but WITHOUT
00010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012     License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to the
00016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00019 
00020 #include "changerecorder.h"
00021 #include "changerecorder_p.h"
00022 
00023 #include <kdebug.h>
00024 #include <QtCore/QSettings>
00025 
00026 using namespace Akonadi;
00027 
00028 ChangeRecorder::ChangeRecorder( QObject * parent ) :
00029     Monitor( new ChangeRecorderPrivate( 0, this ), parent )
00030 {
00031 }
00032 
00033 ChangeRecorder::ChangeRecorder( ChangeRecorderPrivate *privateclass, QObject * parent ) :
00034     Monitor( privateclass, parent )
00035 {
00036 }
00037 
00038 ChangeRecorder::~ChangeRecorder()
00039 {
00040   Q_D( ChangeRecorder );
00041   d->saveNotifications();
00042 }
00043 
00044 void ChangeRecorder::setConfig(QSettings * settings)
00045 {
00046   Q_D( ChangeRecorder );
00047   if ( settings ) {
00048     d->settings = settings;
00049     Q_ASSERT( d->pendingNotifications.isEmpty() );
00050     d->loadNotifications();
00051   } else if ( d->settings ) {
00052     d->saveNotifications();
00053     d->settings = settings;
00054   }
00055 }
00056 
00057 void ChangeRecorder::replayNext()
00058 {
00059   Q_D( ChangeRecorder );
00060   if ( !d->pendingNotifications.isEmpty() ) {
00061     const NotificationMessage msg = d->pendingNotifications.head();
00062     if ( d->ensureDataAvailable( msg ) )
00063       d->emitNotification( msg );
00064     else if ( !d->translateAndCompress( d->pipeline, msg ) ) {
00065       // In the case of a move where both source and destination are
00066       // ignored, we ignore the message and process the next one.
00067       d->pendingNotifications.dequeue();
00068       return replayNext();
00069     }
00070   } else {
00071     // This is necessary when none of the notifications were accepted / processed
00072     // above, and so there is no one to call changeProcessed() and the ChangeReplay task
00073     // will be stuck forever in the ResourceScheduler.
00074     emit nothingToReplay();
00075   }
00076   d->saveNotifications();
00077 }
00078 
00079 bool ChangeRecorder::isEmpty() const
00080 {
00081   Q_D( const ChangeRecorder );
00082   return d->pendingNotifications.isEmpty();
00083 }
00084 
00085 void ChangeRecorder::changeProcessed()
00086 {
00087   Q_D( ChangeRecorder );
00088   if ( !d->pendingNotifications.isEmpty() )
00089     d->pendingNotifications.dequeue();
00090   d->saveNotifications();
00091 }
00092 
00093 void ChangeRecorder::setChangeRecordingEnabled( bool enable )
00094 {
00095   Q_D( ChangeRecorder );
00096   if ( d->enableChangeRecording == enable )
00097     return;
00098   d->enableChangeRecording = enable;
00099   if ( !enable )
00100     d->dispatchNotifications();
00101 }
00102 
00103 #include "changerecorder.moc"

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.5
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