summaryrefslogtreecommitdiffstats
path: root/comm/mail/components/activity/nsIActivity.idl
blob: d80e69088f1daa27edd2202c225709d402b16f69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"
#include "nsISupportsPrimitives.idl"

interface nsIActivityListener;
interface nsIActivity;
interface nsIActivityProcess;
interface nsIActivityEvent;
interface nsIActivityWarning;
interface nsIVariant;
interface nsISupportsPRTime;

/**
 * See https://wiki.mozilla.org/Thunderbird:Activity_Manager/Developer for UML
 * diagram and sample codes.
 */

/**
 * Background:
 * Activity handlers define the behavioral capabilities of the activities. They
 * are used by the Activity Manager to change the execution flow of the activity
 * based on the user interaction. They are not mandatory, but when set, causes
 * behavioral changes on the binding representing the activity, such as showing
 * a cancel button, etc. The following handlers are currently supported;
 */

/**
 * The handler to invoke when the recover button is pressed. Used by a Warning
 * to recover from the situation causing the warning. For instance, recovery
 * action for a "Over Quota Limit" warning, would be to cleanup some disk space,
 * and this operation can be implemented and set by the activity developer in
 * form of nsIActivityRecoveryHandler component.
 */
[scriptable, uuid(30E0A76F-880A-4093-8F3C-AF2239977A3D)]
interface nsIActivityRecoveryHandler : nsISupports {
  nsresult recover(in nsIActivityWarning aActivity);
};

/**
 * The handler to invoke when the cancel button is pressed. Used by a Process to
 * cancel the operation.
 */
[scriptable, uuid(35ee2461-70db-4b3a-90d0-7a68c856e911)]
interface nsIActivityCancelHandler : nsISupports {
  nsresult cancel(in nsIActivityProcess aActivity);
};

/**
 * The handler to invoke when the pause button is pressed. Used by a Process to
 * pause/resume the operation.
 */
[scriptable, uuid(9eee22bf-5378-460e-83a7-781cdcc9050b)]
interface nsIActivityPauseHandler : nsISupports {
  nsresult pause(in nsIActivityProcess aActivity);
  nsresult resume(in nsIActivityProcess aActivity);
};

/**
 * The handler to invoke when the retry button is pressed. Used by a Process to
 * retry the operation in case of failure.
 */
[scriptable, uuid(8ec42517-951f-4bc0-aba5-fde7258b1705)]
interface nsIActivityRetryHandler : nsISupports {
  nsresult retry(in nsIActivityProcess aActivity);
};

/**
 * The handler to invoke when the undo button is pressed. Used by a Event to
 * undo the operation generated the event.
 */
[scriptable, uuid(b8632ac7-9d8b-4341-a349-ef000e8c89ac)]
interface nsIActivityUndoHandler : nsISupports {
  nsresult undo(in nsIActivityEvent aActivity);
};

/**
 * Base interface of all activity interfaces. It is abstract in a sense that
 * there is no component in the activity management system that solely
 * implements this interface.
 */
[scriptable, uuid(6CD33E65-B2D8-4634-9B6D-B80BF1273E99)]
interface nsIActivity : nsISupports {

  /**
   * Shows the activity as a standalone item.
   */
  const short GROUPING_STYLE_STANDALONE = 1;

  /**
   * Groups activity by its context.
   */
  const short GROUPING_STYLE_BYCONTEXT = 2;

  /**
   * Internal ID given by the activity manager when
   * added into the activity list.  Not readonly so that
   * the activity manager can write to them, but not to be written to
   * by anyone else.
   */
  attribute unsigned long id;

  // Following attributes change the UI characteristics of the activity

  /**
   * A brief description of the activity, to be shown by the
   * associated binding (XBL) in the Activity Manager window.
   */
  readonly attribute AString displayText;

  /**
   * Changes the default icon associated with the activity. Core activity
   * icons are declared in |mail/themes/<themename>/mail/activity/activity.css|
   * files.
   *
   * Extension developers can add and assign their own icons by setting
   * this attribute.
   */
  attribute AString iconClass;

  /**
   * Textual id of the XBL binding that will be used to represent the
   * activity in the Activity Manager window.
   *
   * This attribute allows to associate default activity components
   * with custom XBL bindings. See |activity.xml| file for default
   * activity XBL bindings, and |activity.css| file for default binding
   * associations.
   */
  attribute AString bindingName;

  /**
   * Defines the grouping style of the activity when being shown in the
   * activity manager window:
   *  GROUPING_STYLE_STANDALONE or GROUPING_STYLE_BYCONTEXT
   */
  attribute short groupingStyle;

  /**
   * A text value to associate a facet type with the activity. If empty,
   * the activity will be shown in the 'Misc' section.
   */
  attribute AString facet;

  // UI related attributes end.

  /**
   * Gets the initiator of the activity. An initiator represents an object
   * that generates and controls the activity. For example, Copy Service can be
   * the initiator of the copy, and move activities. Similarly Gloda can be the
   * initiator of indexing activity, etc.
   *
   * This attribute is used mostly by handler components to change the execution
   * flow of the activity such as canceling, pausing etc. Since not used by the
   * Activity Manager, it is not mandatory to set it.
   *
   * An initiator can be any JS Object or an XPCOM component that provides an
   * nsIVariant interface.
   */
  readonly attribute nsIVariant initiator;

  /**
   * Adds an object to the activity's internal subject list. Subject list
   * provides argument(s) to activity handlers to complete their operation.
   * For example, nsIActivityUndoHandler needs the source and destination
   * folders to undo a move operation.
   *
   * Since subjects are not used by the Activity Manager, it is up to the
   * activity developer to provide these objects.
   *
   * A subject can be any JS object or XPCOM component that supports nsIVariant
   * interface.
   */
  void addSubject(in nsIVariant aSubject);

  /**
   * Retrieves all subjects associated with this activity.
   *
   * @return The list of subject objects associated by the activity.
   */
  Array<nsIVariant> getSubjects();

  /*
   * Background:
   *  A context is a generic concept that is used to group the processes and
   *  warnings having similar properties such as same imap server, same smtp
   *  server etc.
   *  A context is uniquely identified by its "type" and "object" attributes.
   *  Each activity that has the same context type and object are considered
   *  belong to the same logical group, context.
   *
   *  There are 4 predefined context types known by the Activity Manager:
   *  Account, Smtp, Calendar, and Addressbook. The most common context type
   *  for activities is the "Account Context" and when combined with an account
   *  server instance, it allows to group different activities happening on the
   *  the same account server.
   */

  /**
   * Sets and gets the context object of the activity. A context object can be
   * any JS object or XPCOM component that supports nsIVariant interface.
   */
  attribute nsIVariant contextObj;

  /**
   * Sets and gets the context type of the activity. If this is set, then
   * the contextDisplayText should also be set.
   */
  attribute AString contextType;

  /**
   * Return the displayText to be used for the context
   **/
  attribute AString contextDisplayText;

  /**
   * Adds a listener. See nsIActivityListener below.
   */
  void addListener(in nsIActivityListener aListener);

  /**
   * Removes the given listener. See nsIActivityListener below.
   */
  void removeListener(in nsIActivityListener aListener);
};


/**
 * A Process represents an on-going activity.
 */
[scriptable, uuid(9DC7CA67-828D-4AFD-A5C6-3ECE091A98B8)]
interface nsIActivityProcess : nsIActivity {

  /**
   * Default state for uninitialized process activity
   * object.
   */
  const short STATE_NOTSTARTED = -1;

  /**
   * Activity is currently in progress.
   */
  const short STATE_INPROGRESS = 0;

  /**
   * Activity is completed.
   */
  const short STATE_COMPLETED = 1;

  /**
   * Activity was canceled by the user.
   * (same as completed)
   */
  const short STATE_CANCELED = 2;

  /**
   * Activity was paused by the user.
   */
  const short STATE_PAUSED = 3;

  /**
   * Activity waits for the user input's to retry.
   * (i.e. login password)
   */
  const short STATE_WAITINGFORINPUT = 4;

  /**
   * Activity is ready for an automatic or manual retry.
   */
  const short STATE_WAITINGFORRETRY = 5;

  /**
   * The state of the activity.
   * See above for possible values.
   * @exception NS_ERROR_ILLEGAL_VALUE if the state isn't one of the states
   *   defined above.
   */
  attribute short state;

  /**
   * The percentage of activity completed.
   * If the max value is unknown it'll be -1 here.
   */
  readonly attribute long percentComplete;

  /**
   * A brief text about the process' status.
   */
  readonly attribute AString lastStatusText;

  /**
   * The amount of work units completed so far.
   */
  readonly attribute unsigned long workUnitComplete;

  /**
   * Total amount of work units.
   */
  readonly attribute unsigned long totalWorkUnits;

  /**
   * The starting time of the process.
   * 64-bit signed integers relative to midnight (00:00:00), January 1, 1970
   * Greenwich Mean Time (GMT). (GMT is also known as Coordinated Universal
   * Time, UTC.). The units of time are in microseconds.
   *
   * In JS Date.now(), in C++ PR_Now() / PR_USEC_PER_MSEC can be used to set
   * this value.
   */
  readonly attribute long long startTime;

  /**
   * The handler to invoke when the cancel button is pressed. If present
   * (non-null), the activity can be canceled and a cancel button will be
   * displayed to the user.  If null, it cannot be canceled and no button will
   * be displayed.
   */
  attribute nsIActivityCancelHandler cancelHandler;

  /**
   * The handler to invoke when the pause button is pressed. If present
   * (non-null), the activity can be pauseable and a pause button will be
   * displayed to the user.  If null, it cannot be paused and no button will
   * be displayed.
   */
  attribute nsIActivityPauseHandler pauseHandler;

  /**
   * The handler to invoke when the retry button is pressed. If present
   * (non-null), the activity can be retryable and a retry button will be
   * displayed to the user.  If null, it cannot be retried and no button will
   * be displayed.
   */
  attribute nsIActivityRetryHandler retryHandler;

  /**
   * Updates the activity progress info.
   *
   * @param aStatusText A localized text describing the current status of the
   *                    process
   * @param aWorkUnitComplete The amount of work units completed. Not used by
   *                          Activity Manager or default binding for any
   *                          purpose.
   * @param aTotalWorkUnits Total amount of work units. Not used by
   *                        Activity Manager or default binding for any
   *                        purpose. If set to zero, this indicates that the
   *                        number of work units is unknown, and the percentage
   *                        attribute will be set to -1.
   */
  void setProgress(in AString aStatusText,
                   in unsigned long aWorkUnitComplete,
                   in unsigned long aTotalWorkUnits);

  /**
   * Component initialization method.
   *
   * @param aDisplayText A localized text to be shown on the Activity Manager
   *                     window
   * @param aInitiator The initiator of the process
   */
  void init(in AString aDisplayText, in nsIVariant aInitiator);
};

/**
 * Historical actions performed by the user, by extensions or by the system.
 */
[scriptable, uuid(5B1B0D03-2820-4E37-8BF8-102AFDE4FC45)]
interface nsIActivityEvent : nsIActivity {

  /**
   * Any localized textual information related to this event.
   * It is shown at the bottom of the displayText area.
   */
  readonly attribute AString statusText;

  /**
   * The starting time of the event.
   * 64-bit signed integers relative to midnight (00:00:00), January 1, 1970
   * Greenwich Mean Time (GMT). (GMT is also known as Coordinated Universal
   * Time, UTC.). The units of time are in microseconds.
   *
   * In JS Date.now(), in C++ PR_Now() / PR_USEC_PER_MSEC can be used to set
   * this value.
   */
  readonly attribute long long startTime;

  /**
   * The completion time of the event in microseconds.
   * 64-bit signed integers relative to midnight (00:00:00), January 1, 1970
   * Greenwich Mean Time (GMT). (GMT is also known as Coordinated Universal
   * Time, UTC.). The units of time are in microseconds.
   *
   * In JS Date.now(), in C++ PR_Now() / PR_USEC_PER_MSEC can be used to set
   * this value.
   */
  readonly attribute long long completionTime;

  /**
   * The handler to invoke when the undo button is pressed.  If present
   * (non-null), the activity can be undoable and an undo button will be
   * displayed to the user.  If null, it cannot be undone and no button will
   * be displayed.
   */
  attribute nsIActivityUndoHandler undoHandler;

  /**
   * Component initialization method.
   *
   * @param aDisplayText Any localized text describing the event and its context
   * @param aInitiator The initiator of the event
   * @param aStatusText Any localized additional information about the event
   * @param aStartTime The starting time of the event
   * @param aCompletionTime The completion time of the event
   */
  void init(in AString aDisplayText, in nsIVariant aInitiator,
            in AString aStatusText, in long long aStartTime,
            in long long aCompletionTime);
};

[scriptable, uuid(8265833e-c604-4585-a43c-a76bd8ed3a8c)]
interface nsIActivityWarning : nsIActivity {

  /**
   * Any localized textual information related to this warning.
   */
  readonly attribute AString warningText;

  /**
   * The time of the warning.
   * 64-bit signed integers relative to midnight (00:00:00), January 1, 1970
   * Greenwich Mean Time (GMT). (GMT is also known as Coordinated Universal
   * Time, UTC.). The units of time are in microseconds.
   *
   * In JS Date.now(), in C++ PR_Now() / PR_USEC_PER_MSEC can be used to set
   * this value.
   */
  readonly attribute long long time;

  /**
   * Recovery tip of the warning, localized.
   */
  readonly attribute AString recoveryTipText;

  /**
   * The handler to invoke when the recover button is pressed.  If present
   * (non-null), the activity can be recoverable and a recover button will be
   * displayed to the user.  If null, it cannot be recovered and no button will
   * be displayed.
   */
  attribute nsIActivityRecoveryHandler recoveryHandler;

  /**
   * Component initialization method.
   *
   * @param aWarningText The localized text that will be shown on the display
   *                     area
   * @param aInitiator The initiator of the warning
   * @param aRecoveryTip A localized textual information to guide the user in
   *                     order to recover from the warning situation.
   */
  void init(in AString aWarningText, in nsIVariant aInitiator,
            in AString aRecoveryTip);
};

[scriptable, uuid(bd11519f-b297-4b34-a793-1861dc90d5e9)]
interface nsIActivityListener : nsISupports {
  /**
   * Triggered after activity state is changed.
   */
  void onStateChanged(in nsIActivity aActivity, in short aOldState);

  /**
   * Triggered after the progress of the process activity is changed.
   */
  void onProgressChanged(in nsIActivity aActivity,
                         in AString aStatusText,
                         in unsigned long aWorkUnitsCompleted,
                         in unsigned long aTotalWorkUnits);

  /**
   * Triggered after one of the activity handler is set.
   *
   * This is mostly used to update the UI of the activity when
   * one of the handler is set to null after the operation is completed.
   * For example after the activity is undone, to make the undo button
   * invisible.
   */
  void onHandlerChanged(in nsIActivity aActivity);
};