Oops, don't translate the mimetype, thanks Lukas for the heads up
[kdepim.git] / akonadiconsole / jobtracker.h
blob6ac18820e48d8162dcd7716f064f4e6c478a08f2
1 /*
2 This file is part of Akonadi.
4 Copyright (c) 2009 KDAB
5 Author: Till Adam <adam@kde.org>
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.
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.
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,
20 USA.
23 #ifndef JOBTRACKER_H_
24 #define JOBTRACKER_H_
26 #include <QtCore/QObject>
27 #include <QtCore/QDateTime>
28 #include <QtCore/QList>
29 #include <QtCore/QPair>
31 class JobInfo
33 public:
34 JobInfo() :parent(-1)
36 bool operator==( const JobInfo& other )
38 return id == other.id
39 && parent == other.parent
40 && type == other.type
41 && timestamp == other.timestamp
42 && state == other.state;
45 QString id;
46 int parent;
47 QString type;
48 QDateTime timestamp;
49 enum JobState
51 Initial = 0,
52 Running,
53 Ended,
54 Failed
56 JobState state;
57 QString error;
58 QString stateAsString() const;
61 class JobTracker : public QObject
63 Q_OBJECT
64 Q_CLASSINFO( "D-Bus Interface", "org.freedesktop.Akonadi.JobTracker" )
66 public:
67 explicit JobTracker( const char *name, QObject* parent = 0 );
68 ~JobTracker();
69 QStringList sessions() const;
71 /** Returns the list of (sub)jobs of a session or another job. */
72 QList<JobInfo> jobs( const QString& parent ) const;
73 QList<JobInfo> jobs( int id ) const;
75 int idForJob( const QString& job ) const;
76 QString jobForId( int id ) const;
77 int idForSession( const QString& session ) const;
78 QString sessionForId( int id ) const;
79 int parentId( int id ) const;
81 JobInfo info( const QString& job ) const;
82 JobInfo info( int ) const;
84 bool isEnabled() const;
86 Q_SIGNALS:
87 /** Emitted when jobs (or sessiona) have been added to the tracker.
88 * The format is a list of pairs consisting of the position of the
89 * job or session relative to the parent and the id of that parent.
90 * This makes it easy for the model to find and update the right
91 * part of the model, for efficiency.
93 void added( const QList< QPair<int, int> >& additions );
95 /** Emitted when jobs (or sessiona) have been updated in the tracker.
96 * The format is a list of pairs consisting of the position of the
97 * job or session relative to the parent and the id of that parent.
98 * This makes it easy for the model to find and update the right
99 * part of the model, for efficiency.
101 void updated( const QList< QPair<int, int> >& updates );
103 void reset();
105 public Q_SLOTS:
106 Q_SCRIPTABLE void jobCreated( const QString & session, const QString & job, const QString& parentJob, const QString & jobType );
107 Q_SCRIPTABLE void jobStarted( const QString & job );
108 Q_SCRIPTABLE void jobEnded( const QString & job, const QString &error );
109 Q_SCRIPTABLE void triggerReset();
110 Q_SCRIPTABLE void setEnabled( bool on );
112 private Q_SLOTS:
113 void signalUpdates();
115 private:
116 class Private;
117 Private * const d;
120 #endif /* JOBTRACKER_H_ */