1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38 /*
39
40 Interfaces for the RDF/XML sink, which parses RDF/XML into
41 a graph representation.
42
43 */
44
45 #include "nsISupports.idl"
46
47 // XXX Until these get scriptable. See nsIRDFXMLSink::AddNameSpace()
48 [ptr] native nsIAtomPtr(nsIAtom);
49 [ref] native nsStringRef(nsString);
50 %{C++
51 class nsIAtom;
52 class nsString;
53 %}
54
55 interface nsIRDFXMLSink;
56
57 /**
58 * An observer that is notified as progress is made on the load
59 * of an RDF/XML document in an <code>nsIRDFXMLSink</code>.
60 */
61 [scriptable, uuid(EB1A5D30-AB33-11D2-8EC6-00805F29F370)]
62 interface nsIRDFXMLSinkObserver : nsISupports
63 {
64 /**
65 * Called when the load begins.
66 * @param aSink the RDF/XML sink on which the load is beginning.
67 */
68 void onBeginLoad(in nsIRDFXMLSink aSink);
69
70 /**
71 * Called when the load is suspended (e.g., for network quantization).
72 * @param aSink the RDF/XML sink that is being interrupted.
73 */
74 void onInterrupt(in nsIRDFXMLSink aSink);
75
76 /**
77 * Called when a suspended load is resuming.
78 * @param aSink the RDF/XML sink that is resuming.
79 */
80 void onResume(in nsIRDFXMLSink aSink);
81
82 /**
83 * Called when an RDF/XML load completes successfully.
84 * @param aSink the RDF/XML sink that has finished loading.
85 */
86 void onEndLoad(in nsIRDFXMLSink aSink);
87
88 /**
89 * Called when an error occurs during the load
90 * @param aSink the RDF/XML sink in which the error occurred
91 * @param aStatus the networking result code
92 * @param aErrorMsg an error message, if applicable
93 */
94 void onError(in nsIRDFXMLSink aSink, in nsresult aStatus, in wstring aErrorMsg);
95 };
96
97
98
99 /**
100 * A "sink" that receives and processes RDF/XML. This interface is used
101 * by the RDF/XML parser.
102 */
103 [scriptable, uuid(EB1A5D31-AB33-11D2-8EC6-00805F29F370)]
104 interface nsIRDFXMLSink : nsISupports
105 {
106 /**
107 * Set to <code>true</code> if the sink is read-only and cannot
108 * be modified
109 */
110 attribute boolean readOnly;
111
112 /**
113 * Initiate the RDF/XML load.
114 */
115 void beginLoad();
116
117 /**
118 * Suspend the RDF/XML load.
119 */
120 void interrupt();
121
122 /**
123 * Resume the RDF/XML load.
124 */
125 void resume();
126
127 /**
128 * Complete the RDF/XML load.
129 */
130 void endLoad();
131
132 /**
133 * Add namespace information to the RDF/XML sink.
134 * @param aPrefix the namespace prefix
135 * @param aURI the namespace URI
136 */
137 [noscript] void addNameSpace(in nsIAtomPtr aPrefix,
138 [const] in nsStringRef aURI);
139
140 /**
141 * Add an observer that will be notified as the RDF/XML load
142 * progresses.
143 * <p>
144 *
145 * Note that the sink will acquire a strong reference to the
146 * observer, so care should be taken to avoid cyclical references
147 * that cannot be released (i.e., if the observer holds a
148 * reference to the sink, it should be sure that it eventually
149 * clears the reference).
150 *
151 * @param aObserver the observer to add to the sink's set of
152 * load observers.
153 */
154 void addXMLSinkObserver(in nsIRDFXMLSinkObserver aObserver);
155
156 /**
157 * Remove an observer from the sink's set of observers.
158 * @param aObserver the observer to remove.
159 */
160 void removeXMLSinkObserver(in nsIRDFXMLSinkObserver aObserver);
161 };