summaryrefslogtreecommitdiffstats
path: root/comm/calendar/base/public/calIAlarmService.idl
blob: 4af77628db4cd3c37fd91a5ec4d3d8d8754c53df (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
/* 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"

interface calIItemBase;
interface calICalendar;
interface calIDuration;
interface calITimezone;
interface calIAlarm;
interface calIOperation;

[scriptable,uuid(dc96dd04-d2dd-448e-b307-8c8ff39c72af)]
interface calIAlarmServiceObserver : nsISupports
{
  /**
   * Gets called when an alarm has fired. Depending on type of alarm, an
   * observer could bring up a dialog or play a sound.
   */
  void onAlarm(in calIItemBase item, in calIAlarm alarm);

  /**
   * Gets called when an notification has fired. The notification is only
   * controlled by prefs, and is independent from the alarm/reminder.
   */
  void onNotification(in calIItemBase item);

  /**
   * Called if alarm(s) of a specific item are to be removed from
   * the alarm window.
   *
   * @param aItem corresponding item, maybe master item of recurring
   *              series (then all alarms belonging to this item are to
   *              be removed)
   */
  void onRemoveAlarmsByItem(in calIItemBase item);

  /**
   * Called if all alarms of a specific calendar are to be removed.
   */
  void onRemoveAlarmsByCalendar(in calICalendar calendar);

  /**
   * Called when all alarms of a specific calendar are loaded.
   */
  void onAlarmsLoaded(in calICalendar calendar);
};

[scriptable,uuid(42cfa9ce-49d6-11e5-b88c-5b90eedc1c47)]
interface calIAlarmService : nsISupports
{
  /**
   * Upper limit for the snooze period for an alarm. To avoid performance issues, don't change this
   * to a value larger then 1 at least until bug 861594 or a similar concept is implemented.
   */
  const unsigned long MAX_SNOOZE_MONTHS = 1;

  /**
   * This is the timezone that all-day events will be converted to in order to
   * determine when their alarms should fire.
   */
  attribute calITimezone timezone;

  /**
   * Will return true while the alarm service is in the process of loading alarms
   */
  attribute boolean isLoading;

  /**
   * Cause the alarm service to start up, create a list of upcoming
   * alarms in all registered calendars, add observers to watch for
   * calendar registration and unregistration, and setup a timer to
   * maintain that list and fire alarms.
   *
   * @note Will throw NS_ERROR_NOT_INITIALIZED if you have not previously set
   *       the timezone attribute.
   */
  void startup();

  /**
   * Shuts down the alarm service, canceling all timers and removing all
   * alarms.
   */
  void shutdown();

  /* add and remove observers that will be notified when an
     alarm has gone off.  It is up to the application to display
     the alarm.
  */
  void addObserver(in calIAlarmServiceObserver observer);
  void removeObserver(in calIAlarmServiceObserver observer);

  /**
   * Call to reschedule an alarm to be notified at a later point. The alarm will
   * instead fire at "now + duration" This will cause an event to be scheduled
   * even if it was not previously scheduled.
   *
   * @param item            The item the alarm belongs to.
   * @param alarm           The alarm to snooze.
   * @param duration        The duration in minutes to snooze for.
   * @return                The operation that modifies the item to snooze the
   *                        alarm.
   */
  calIOperation snoozeAlarm(in calIItemBase item, in calIAlarm alarm, in calIDuration duration);

  /**
   * Dismisses the given alarm for the passed occurrence.
   *
   * @param item            The item the alarm belongs to.
   * @param alarm           The alarm to dismiss.
   * @return                The operation that modifies the item to dismiss the
   *                        alarm.
   */
  calIOperation dismissAlarm(in calIItemBase item, in calIAlarm alarm);
};