docs: Tiny typo.
[platform/upstream/atk.git] / atk / atkstreamablecontent.c
1 /* ATK -  Accessibility Toolkit
2  * Copyright 2001 Sun Microsystems Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "config.h"
21
22 #include "atkstreamablecontent.h"
23
24 /**
25  * SECTION:atkstreamablecontent
26  * @Short_description: The ATK interface which provides access to
27  *  streamable content.
28  * @Title:AtkStreamableContent
29  *
30  * An interface whereby an object allows its backing content to be
31  * streamed to clients.  Typical implementors would be images or
32  * icons, HTML content, or multimedia display/rendering widgets.
33  *
34  * Negotiation of content type is allowed. Clients may examine the
35  * backing data and transform, convert, or parse the content in order
36  * to present it in an alternate form to end-users.
37  *
38  * The AtkStreamableContent interface is particularly useful for
39  * saving, printing, or post-processing entire documents, or for
40  * persisting alternate views of a document. If document content
41  * itself is being serialized, stored, or converted, then use of the
42  * AtkStreamableContent interface can help address performance
43  * issues. Unlike most ATK interfaces, this interface is not strongly
44  * tied to the current user-agent view of the a particular document,
45  * but may in some cases give access to the underlying model data.
46  */
47
48 GType
49 atk_streamable_content_get_type (void)
50 {
51   static GType type = 0;
52
53   if (!type) {
54     GTypeInfo tinfo =
55     {
56       sizeof (AtkStreamableContentIface),
57       (GBaseInitFunc) NULL,
58       (GBaseFinalizeFunc) NULL,
59
60     };
61
62     type = g_type_register_static (G_TYPE_INTERFACE, "AtkStreamableContent", &tinfo, 0);
63   }
64
65   return type;
66 }
67
68 /**
69  * atk_streamable_content_get_n_mime_types:
70  * @streamable: a GObject instance that implements AtkStreamableContentIface
71  *
72  * Gets the number of mime types supported by this object.
73  *
74  * Returns: a gint which is the number of mime types supported by the object.
75  **/
76 gint
77 atk_streamable_content_get_n_mime_types (AtkStreamableContent *streamable)
78 {
79   AtkStreamableContentIface *iface;
80
81   g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), 0);
82
83   iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
84
85   if (iface->get_n_mime_types)
86     return (iface->get_n_mime_types) (streamable);
87   else
88     return 0;
89 }
90
91 /**
92  * atk_streamable_content_get_mime_type:
93  * @streamable: a GObject instance that implements AtkStreamableContent
94  * @i: a gint representing the position of the mime type starting from 0
95  *
96  * Gets the character string of the specified mime type. The first mime
97  * type is at position 0, the second at position 1, and so on.
98  *
99  * Returns: a gchar* representing the specified mime type; the caller
100  * should not free the character string.
101  **/
102 const gchar*
103 atk_streamable_content_get_mime_type (AtkStreamableContent *streamable,
104                                       gint                 i)
105 {
106   AtkStreamableContentIface *iface;
107
108   g_return_val_if_fail (i >= 0, NULL);
109   g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
110
111   iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
112
113   if (iface->get_mime_type)
114     return (iface->get_mime_type) (streamable, i);
115   else
116     return NULL;
117 }
118
119 /**
120  * atk_streamable_content_get_stream:
121  * @streamable: a GObject instance that implements AtkStreamableContentIface
122  * @mime_type: a gchar* representing the mime type
123  *
124  * Gets the content in the specified mime type.
125  *
126  * Returns: (transfer full): A #GIOChannel which contains the content in the
127  * specified mime type.
128  **/
129 GIOChannel*
130 atk_streamable_content_get_stream (AtkStreamableContent *streamable,
131                                    const gchar          *mime_type)
132 {
133   AtkStreamableContentIface *iface;
134
135   g_return_val_if_fail (mime_type != NULL, NULL);
136   g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
137
138   iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
139
140   if (iface->get_stream)
141     return (iface->get_stream) (streamable, mime_type);
142   else
143     return NULL;
144 }
145
146 /**
147  * atk_streamable_content_get_uri:
148  * @streamable: a GObject instance that implements AtkStreamableContentIface
149  * @mime_type: a gchar* representing the mime type, or NULL to request a URI 
150  * for the default mime type.
151  *
152  * Get a string representing a URI in IETF standard format
153  * (see http://www.ietf.org/rfc/rfc2396.txt) from which the object's content
154  * may be streamed in the specified mime-type, if one is available.
155  * If mime_type is NULL, the URI for the default (and possibly only) mime-type is
156  * returned. 
157  *
158  * Note that it is possible for get_uri to return NULL but for
159  * get_stream to work nonetheless, since not all GIOChannels connect to URIs.
160  *
161  * Returns: (nullable): Returns a string representing a URI, or %NULL
162  * if no corresponding URI can be constructed.
163  *
164  * Since: 1.12
165  **/
166 const gchar*
167 atk_streamable_content_get_uri (AtkStreamableContent *streamable,
168                                 const gchar          *mime_type)
169 {
170   AtkStreamableContentIface *iface;
171
172   g_return_val_if_fail (mime_type != NULL, NULL);
173   g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
174
175   iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
176
177   if (iface->get_uri)
178     return (iface->get_uri) (streamable, mime_type);
179   else
180     return NULL;
181 }