summaryrefslogtreecommitdiff
path: root/calendar/base/public/calIIcsParser.idl
blob: dd2c3ed7deaec7bb5dc0dccbb7f026910e950334 (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
/* -*- Mode: idl; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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 calIIcalProperty;
interface calIIcalComponent;
interface calIItemBase;
interface nsIInputStream;
interface calITimezoneProvider;
interface calIIcsParser;

/**
 * Listener being called once asynchronous parsing is done.
 */
[scriptable, uuid(d22527da-b0e2-41b7-b6f4-ee9c243cd285)]
interface calIIcsParsingListener : nsISupports
{
    void onParsingComplete(in nsresult rc, in calIIcsParser parser);
};

/**
 * An interface for parsing an ics string or stream into its items.
 * Note that this is not a service. A new instance must be created for every new
 * string or stream to be parsed.
 */
[scriptable, uuid(83e9befe-5e9e-49de-8bc2-d882f464f7e7)]
interface calIIcsParser : nsISupports
{
  /**
   * Parse an ics string into its items, and store top-level properties and
   * components that are not interpreted.
   *
   * @param aICSString
   *    The ICS string to parse
   * @param optional aTzProvider
   *    The timezone provider used to resolve timezones not contained in the
   *    parent VCALENDAR or null (falls back to timezone service)
   * @param optional aAsyncParsing
   *    If non-null, parsing will be performed on a worker thread,
   *    and the passed listener is called when it's done
   */
  void parseString(in AString aICSString,
                   [optional] in calITimezoneProvider aTzProvider,
                   [optional] in calIIcsParsingListener aAsyncParsing);

  /**
   * Parse an input stream.
   *
   * @see parseString
   * @param aICSString
   *    The stream to parse
   * @param optional aTzProvider
   *    The timezone provider used to resolve timezones not contained in the
   *    parent VCALENDAR or null (falls back to timezone service)
   * @param optional aAsyncParsing
   *    If non-null, parsing will be performed on a worker thread,
   *    and the passed listener is called when it's done
   */
  void parseFromStream(in nsIInputStream aStream,
                       [optional] in calITimezoneProvider aTzProvider,
                       [optional] in calIIcsParsingListener aAsyncParsing);

  /**
   * Get the items that were in the string or stream. In case an item represents a
   * recurring series, the (unexpanded) parent item is returned only.
   * Please keep in mind that any parentless items (see below) are not contained
   * in the returned set of items.
   *
   * @param aCount
   *    Will hold the number of items that were parsed
   * @param aItems
   *    The items
   */
  void getItems(out uint32_t aCount,
                [array,size_is(aCount),retval] out calIItemBase aItems);

  /**
   * Get the parentless items that may have occurred, i.e. overridden items of a
   * recurring series (having a RECURRENCE-ID) missing their parent item in the
   * parsed content.
   *
   * @param aCount
   *    Will hold the number of items that were parsed
   * @param aItems
   *    The items
   */
  void getParentlessItems(out uint32_t aCount,
                          [array,size_is(aCount),retval] out calIItemBase aItems);

  /**
   * Get the top-level properties that were not interpreted as anything special
   * @param aCount
   *    Will hold the number of properties that were found
   * @param aProperties
   *    The properties
   */
  void getProperties(out uint32_t aCount,
                     [array,size_is(aCount),retval] out calIIcalProperty aProperties);

  /**
   * Get the top-level components that were not interpreted as anything special
   * @param aCount
   *    Will hold the number of components that were found
   * @param aComponents
   *    The components
   */
  void getComponents(out uint32_t aCount,
                     [array,size_is(aCount),retval] out calIIcalComponent aComponents);
};