SVN_SILENT made messages (.desktop file) - always resolve ours
[kdepim.git] / akonadiconsole / jobtracker.h
blob25e36b2817f5bcc88f38c40bc725d2fe697c82d8
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 AKONADICONSOLE_JOBTRACKER_H
24 #define AKONADICONSOLE_JOBTRACKER_H
26 #include <QObject>
27 #include <QDateTime>
28 #include <QList>
29 #include <QPair>
31 class JobInfo
33 public:
34 JobInfo() : parent(-1), state(Initial)
36 bool operator==(const JobInfo &other) const
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 QDateTime startedTimestamp;
50 QDateTime endedTimestamp;
51 enum JobState {
52 Initial = 0,
53 Running,
54 Ended,
55 Failed
57 JobState state;
58 QString error;
59 QString debugString;
60 QString stateAsString() const;
63 class JobTracker : public QObject
65 Q_OBJECT
66 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Akonadi.JobTracker")
68 public:
69 explicit JobTracker(const char *name, QObject *parent = Q_NULLPTR);
70 ~JobTracker();
71 QStringList sessions() const;
73 /** Returns the list of (sub)jobs of a session or another job. */
74 QList<JobInfo> jobs(const QString &parent) const;
75 QStringList jobNames(int id) const;
76 QList<JobInfo> jobs(int id) const;
78 int idForJob(const QString &job) const;
79 QString jobForId(int id) const;
80 int idForSession(const QString &session) const;
81 QString sessionForId(int id) const;
82 int parentId(int id) const;
84 JobInfo info(const QString &job) const;
85 JobInfo info(int) const;
87 bool isEnabled() const;
89 Q_SIGNALS:
90 /** Emitted when jobs (or sessiona) have been added to the tracker.
91 * The format is a list of pairs consisting of the position of the
92 * job or session relative to the parent and the id of that parent.
93 * This makes it easy for the model to find and update the right
94 * part of the model, for efficiency.
96 void added(const QList< QPair<int, int> > &additions);
98 /** Emitted when jobs (or sessiona) have been updated in the tracker.
99 * The format is a list of pairs consisting of the position of the
100 * job or session relative to the parent and the id of that parent.
101 * This makes it easy for the model to find and update the right
102 * part of the model, for efficiency.
104 void updated(const QList< QPair<int, int> > &updates);
106 void reset();
108 public Q_SLOTS:
109 Q_SCRIPTABLE void jobCreated(const QString &session, const QString &job, const QString &parentJob, const QString &jobType, const QString &debugString);
110 Q_SCRIPTABLE void jobStarted(const QString &job);
111 Q_SCRIPTABLE void jobEnded(const QString &job, const QString &error);
112 Q_SCRIPTABLE void triggerReset();
113 Q_SCRIPTABLE void setEnabled(bool on);
115 private Q_SLOTS:
116 void signalUpdates();
118 private:
119 class Private;
120 Private *const d;
123 #endif /* JOBTRACKER_H_ */