~ubuntu-branches/ubuntu/precise/kactivities/precise-proposed

« back to all changes in this revision

Viewing changes to service/ActivityManager.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-13 11:53:27 UTC
  • Revision ID: package-import@ubuntu.com-20111213115327-vqhdel92qx65us8y
Tags: upstream-4.7.90
ImportĀ upstreamĀ versionĀ 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU General Public License version 2,
 
6
 *   or (at your option) any later version, as published by the Free
 
7
 *   Software Foundation
 
8
 *
 
9
 *   This program is distributed in the hope that it will be useful,
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *   GNU General Public License for more details
 
13
 *
 
14
 *   You should have received a copy of the GNU General Public
 
15
 *   License along with this program; if not, write to the
 
16
 *   Free Software Foundation, Inc.,
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
#ifndef ACTIVITY_MANAGER_H_
 
21
#define ACTIVITY_MANAGER_H_
 
22
 
 
23
#define ActivityManagerServicePath "org.kde.ActivityManager"
 
24
 
 
25
#include <QString>
 
26
#include <QStringList>
 
27
 
 
28
#include <KUniqueApplication>
 
29
 
 
30
class ActivityManagerPrivate;
 
31
 
 
32
/**
 
33
 * Service for tracking the user actions and managing the
 
34
 * activities
 
35
 */
 
36
class ActivityManager: public KUniqueApplication {
 
37
    Q_OBJECT
 
38
    Q_CLASSINFO("D-Bus Interface", "org.kde.ActivityManager")
 
39
 
 
40
public:
 
41
    /**
 
42
     * Activity state
 
43
     * @note: Do not change the values, needed for bit-operations
 
44
     */
 
45
    enum State {
 
46
        Invalid  = 0,
 
47
        Running  = 2,
 
48
        Starting = 3,
 
49
        Stopped  = 4,
 
50
        Stopping = 5
 
51
    };
 
52
 
 
53
    /**
 
54
     * The event type
 
55
     */
 
56
    enum EventType {
 
57
        Accessed = 1,
 
58
        Opened = 2,
 
59
        Modified = 3,
 
60
        Closed = 4,
 
61
        FocussedIn = 5,
 
62
        FocussedOut = 6
 
63
    };
 
64
 
 
65
    /**
 
66
     * Creates new ActivityManager
 
67
     */
 
68
    ActivityManager();
 
69
 
 
70
    /**
 
71
     * Destroys this interface
 
72
     */
 
73
    virtual ~ActivityManager();
 
74
 
 
75
    static ActivityManager* self();
 
76
 
 
77
// service control methods
 
78
public Q_SLOTS:
 
79
    /**
 
80
     * Does nothing. If the service is not running, the D-Bus daemon
 
81
     * will automatically create it
 
82
     */
 
83
    void Start();
 
84
 
 
85
    /**
 
86
     * Stops the service
 
87
     */
 
88
    void Stop();
 
89
 
 
90
 
 
91
 
 
92
// workspace activities control
 
93
public Q_SLOTS:
 
94
    /**
 
95
     * @returns the id of the current activity, empty string if none
 
96
     */
 
97
    QString CurrentActivity() const;
 
98
 
 
99
    /**
 
100
     * Sets the current activity
 
101
     * @param id id of the activity to make current
 
102
     */
 
103
    bool SetCurrentActivity(const QString & id);
 
104
 
 
105
    /**
 
106
     * Adds a new activity
 
107
     * @param name name of the activity
 
108
     * @returns id of the newly created activity
 
109
     */
 
110
    QString AddActivity(const QString & name);
 
111
 
 
112
    /**
 
113
     * Starts the specified activity
 
114
     * @param id id of the activity to stash
 
115
     */
 
116
    void StartActivity(const QString & id);
 
117
 
 
118
    /**
 
119
     * Stops the specified activity
 
120
     * @param id id of the activity to stash
 
121
     */
 
122
    void StopActivity(const QString & id);
 
123
 
 
124
    /**
 
125
     * @returns the state of the activity
 
126
     * @param id id of the activity
 
127
     */
 
128
    int ActivityState(const QString & id) const;
 
129
 
 
130
    /**
 
131
     * Removes the specified activity
 
132
     * @param id id of the activity to delete
 
133
     */
 
134
    void RemoveActivity(const QString & id);
 
135
 
 
136
    /**
 
137
     * @returns the list of all existing activities
 
138
     */
 
139
    QStringList ListActivities() const;
 
140
 
 
141
    /**
 
142
     * @returns the list of activities with the specified state
 
143
     * @param state state
 
144
     */
 
145
    QStringList ListActivities(int state) const;
 
146
 
 
147
    /**
 
148
     * @returns the name of the specified activity
 
149
     * @param id id of the activity
 
150
     */
 
151
    QString ActivityName(const QString & id) const;
 
152
 
 
153
    /**
 
154
     * Sets the name of the specified activity
 
155
     * @param id id of the activity
 
156
     * @param name name to be set
 
157
     */
 
158
    void SetActivityName(const QString & id, const QString & name);
 
159
 
 
160
    /**
 
161
     * @returns the description of the specified activity
 
162
     * @param id id of the activity
 
163
     */
 
164
    QString ActivityDescription(const QString & id) const;
 
165
 
 
166
    /**
 
167
     * Sets the description of the specified activity
 
168
     * @param id id of the activity
 
169
     * @param description description to be set
 
170
     */
 
171
    void SetActivityDescription(const QString & id, const QString & description);
 
172
 
 
173
    /**
 
174
     * @returns the icon of the specified activity
 
175
     * @param id id of the activity
 
176
     */
 
177
    QString ActivityIcon(const QString & id) const;
 
178
 
 
179
    /**
 
180
     * Sets the icon of the specified activity
 
181
     * @param id id of the activity
 
182
     * @param icon icon to be set
 
183
     */
 
184
    void SetActivityIcon(const QString & id, const QString & icon);
 
185
 
 
186
 
 
187
    /**
 
188
     * @returns whether the backstore (Nepomuk) is available
 
189
     */
 
190
    bool IsBackstoreAvailable() const;
 
191
 
 
192
Q_SIGNALS:
 
193
    /**
 
194
     * This signal is emitted when the global
 
195
     * activity is changed
 
196
     * @param id id of the new current activity
 
197
     */
 
198
    void CurrentActivityChanged(const QString & id);
 
199
 
 
200
    /**
 
201
     * This signal is emitted when a new activity is created
 
202
     * @param id id of the activity
 
203
     */
 
204
    void ActivityAdded(const QString & id);
 
205
 
 
206
    /**
 
207
     * This signal is emitted when an activity is started
 
208
     * @param id id of the activity
 
209
     */
 
210
    void ActivityStarted(const QString & id);
 
211
 
 
212
    /**
 
213
     * This signal is emitted when an activity is stashed
 
214
     * @param id id of the activity
 
215
     */
 
216
    void ActivityStopped(const QString & id);
 
217
 
 
218
    /**
 
219
     * This signal is emitted when an activity is deleted
 
220
     * @param id id of the activity
 
221
     */
 
222
    void ActivityRemoved(const QString & id);
 
223
 
 
224
    /**
 
225
     * Emitted when an activity name, description and/or icon are changed
 
226
     * @param id id of the changed activity
 
227
     */
 
228
    void ActivityChanged(const QString & id);
 
229
 
 
230
    /**
 
231
     * Emitted when the state of activity is changed
 
232
     */
 
233
    void ActivityStateChanged(const QString & id, int state);
 
234
 
 
235
// Resource related mothods
 
236
public Q_SLOTS:
 
237
 
 
238
    /**
 
239
     * Registers a new event
 
240
     * @param application the name of application that sent the event. Ignored if the event is not of type Opened
 
241
     * @param windowId ID of the window that displays the resource. Ignored if the event is of type Accessed
 
242
     * @param uri URI of the resource on which the event happened
 
243
     * @param event type of the event
 
244
     * @param reason reason for opening the resource
 
245
     */
 
246
    void RegisterResourceEvent(const QString & application, uint windowId, const QString & uri, uint event, uint reason);
 
247
 
 
248
    /**
 
249
     * Registers resource's mimetype. If not manually specified, it will
 
250
     * be retrieved if needed from Nepomuk
 
251
     *
 
252
     * Note that this will be forgotten when the resource in question is closed.
 
253
     * @param uri URI of the resource
 
254
     */
 
255
    void RegisterResourceMimeType(const QString & uri, const QString & mimetype);
 
256
 
 
257
    /**
 
258
     * Registers resource's title. If not manually specified, it will be a shortened
 
259
     * version of the uri
 
260
     *
 
261
     * Note that this will be forgotten when the resource in question is closed.
 
262
     * @param uri URI of the resource
 
263
     */
 
264
    void RegisterResourceTitle(const QString & uri, const QString & title);
 
265
 
 
266
    /**
 
267
     * Links the specified resource to the activity
 
268
     * @param uri URI of the resource
 
269
     * @param uri activity id of the activity to link to. If empty, the resource
 
270
     *     is linked to the current activity
 
271
     */
 
272
    void LinkResourceToActivity(const QString & uri, const QString & activity = QString());
 
273
 
 
274
    /**
 
275
     * Links the specified resource to the activity
 
276
     * @param uri URI of the resource
 
277
     * @param uri activity id of the activity to link to. If empty, the resource
 
278
     *     is linked to the current activity
 
279
     */
 
280
    // void UnlinkResourceFromActivity(const QString & uri, const QString & activity = QString());
 
281
 
 
282
 
 
283
private:
 
284
    friend class ActivityManagerPrivate;
 
285
    class ActivityManagerPrivate * const d;
 
286
};
 
287
 
 
288
#endif // ACTIVITY_MANAGER_H_