Blokkal
an Extendable KDE Blogging Client
SourceForge.net Logo

blokkalpostentryqueue.h

00001 /***************************************************************************
00002  *   Copyright (C) 2006 - 2008 by Martin Mueller                           *
00003  *   orvio@orvio.de                                                        *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef BLOKKALBLOKKALPOSTENTRYQUEUE_H
00021 #define BLOKKALBLOKKALPOSTENTRYQUEUE_H
00022 
00023 #include <QtCore/QObject>
00024 #include "blokkal_export.h"
00025 
00026 template <class T> class QLinkedList;
00027 
00028 class KJob;
00029 
00030 namespace Blokkal {
00031 class Entry;
00032 class Account;
00033 class PostEntryStatus;
00034 namespace Io {
00035 class EntryJob;
00036 }
00037 
00038 class PostEntryQueuePrivate;
00050 class BLOKKAL_EXPORT PostEntryQueue : public QObject
00051 {
00052 friend class PostEntryQueuePrivate;     
00053 Q_OBJECT
00054 public:
00060         static Blokkal::PostEntryQueue * self( void );
00061 
00066         int count( void ) const;
00067 
00072         bool isEmpty( void ) const;
00073 
00078         QLinkedList<Blokkal::Entry *> entries( void ) const;
00079 
00085         const Blokkal::PostEntryStatus * entryStatus( Blokkal::Entry * entry ) const;
00086 
00093         bool isProcessing( void ) const;
00094 
00095 public Q_SLOTS:
00099         void stopSyncing( void );
00100 
00104         void restoreState( void );
00105 
00113         void queue( Blokkal::Entry * entry );
00114 
00128         bool unqueue( Blokkal::Entry * entry, bool force = FALSE );
00129 
00136         void clearError( Blokkal::Entry * entry );
00137 
00141         void suspendProcessing( void );
00142 
00146         void resumeProcessing( void );
00147         
00148 Q_SIGNALS:
00154         void entryAdded( Blokkal::Entry * addedEntry );
00155 
00162         void entryRemoved( Blokkal::Entry * removedEntry );
00163 
00170         void entryPosted( Blokkal::Entry * postedEntry );
00171 
00176         void entryFailing( Blokkal::Entry * failingEntry );
00177 
00183         void entryStatusChanged( Blokkal::Entry * entry, const Blokkal::PostEntryStatus * status );
00184 
00185 private Q_SLOTS:
00190         void processQueue( void );
00191 
00195         void slotJobFinished( KJob * job );
00196 
00200         void slotConnectionsChanged( Blokkal::Account * account );
00201 
00205         void slotAccountAdded( Blokkal::Account * account );
00206 
00210         void slotEntryDestroyed( Blokkal::Entry * entry );
00211 
00212 private:
00213         PostEntryQueue( void );
00214         ~PostEntryQueue( void );
00215 };
00216 
00223 class BLOKKAL_EXPORT PostEntryStatus
00224 {
00225 public:
00229         PostEntryStatus( void );
00230 
00234         ~PostEntryStatus( void );
00235 
00239         enum Status {
00240                 StatusNormal = 1, 
00241                 StatusPosting = 2, 
00242                 StatusError = 3, 
00243         };
00244 
00249         int error( void ) const;
00250 
00255         QString errorString( void ) const;
00256 
00261         Blokkal::PostEntryStatus::Status status( void ) const;
00262 
00268         const Blokkal::Io::EntryJob * job( void ) const;
00269         
00270 private:
00271         class Private;
00272         Private * const d;
00273 
00274         friend class PostEntryQueue;
00275 };
00276 
00277 }
00278 
00279 #endif