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,
23 #ifndef AKONADICONSOLE_JOBTRACKER_H
24 #define AKONADICONSOLE_JOBTRACKER_H
34 JobInfo() : parent(-1), state(Initial
)
36 bool operator==(const JobInfo
&other
) const
39 && parent
== other
.parent
41 && timestamp
== other
.timestamp
42 && state
== other
.state
;
49 QDateTime startedTimestamp
;
50 QDateTime endedTimestamp
;
60 QString
stateAsString() const;
63 class JobTracker
: public QObject
66 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Akonadi.JobTracker")
69 explicit JobTracker(const char *name
, QObject
*parent
= Q_NULLPTR
);
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;
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
);
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
);
116 void signalUpdates();
123 #endif /* JOBTRACKER_H_ */