Visual Studio builds: Support Visual Studio 2017
[atk.git] / atk / atkstreamablecontent.c
blob571ca2b6a13ed2e5d89e3690c6acbdc4c6d572ea
1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
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.
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.
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.
20 #include "config.h"
22 #include "atkstreamablecontent.h"
24 /**
25 * SECTION:atkstreamablecontent
26 * @Short_description: The ATK interface which provides access to
27 * streamable content.
28 * @Title:AtkStreamableContent
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.
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.
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.
48 GType
49 atk_streamable_content_get_type (void)
51 static GType type = 0;
53 if (!type) {
54 GTypeInfo tinfo =
56 sizeof (AtkStreamableContentIface),
57 (GBaseInitFunc) NULL,
58 (GBaseFinalizeFunc) NULL,
62 type = g_type_register_static (G_TYPE_INTERFACE, "AtkStreamableContent", &tinfo, 0);
65 return type;
68 /**
69 * atk_streamable_content_get_n_mime_types:
70 * @streamable: a GObject instance that implements AtkStreamableContentIface
72 * Gets the number of mime types supported by this object.
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)
79 AtkStreamableContentIface *iface;
81 g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), 0);
83 iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
85 if (iface->get_n_mime_types)
86 return (iface->get_n_mime_types) (streamable);
87 else
88 return 0;
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
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.
99 * Returns: a gchar* representing the specified mime type; the caller
100 * should not free the character string.
102 const gchar*
103 atk_streamable_content_get_mime_type (AtkStreamableContent *streamable,
104 gint i)
106 AtkStreamableContentIface *iface;
108 g_return_val_if_fail (i >= 0, NULL);
109 g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
111 iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
113 if (iface->get_mime_type)
114 return (iface->get_mime_type) (streamable, i);
115 else
116 return NULL;
120 * atk_streamable_content_get_stream:
121 * @streamable: a GObject instance that implements AtkStreamableContentIface
122 * @mime_type: a gchar* representing the mime type
124 * Gets the content in the specified mime type.
126 * Returns: (transfer full): A #GIOChannel which contains the content in the
127 * specified mime type.
129 GIOChannel*
130 atk_streamable_content_get_stream (AtkStreamableContent *streamable,
131 const gchar *mime_type)
133 AtkStreamableContentIface *iface;
135 g_return_val_if_fail (mime_type != NULL, NULL);
136 g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
138 iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
140 if (iface->get_stream)
141 return (iface->get_stream) (streamable, mime_type);
142 else
143 return NULL;
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.
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.
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.
161 * Returns: (nullable): Returns a string representing a URI, or %NULL
162 * if no corresponding URI can be constructed.
164 * Since: 1.12
166 const gchar*
167 atk_streamable_content_get_uri (AtkStreamableContent *streamable,
168 const gchar *mime_type)
170 AtkStreamableContentIface *iface;
172 g_return_val_if_fail (mime_type != NULL, NULL);
173 g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
175 iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
177 if (iface->get_uri)
178 return (iface->get_uri) (streamable, mime_type);
179 else
180 return NULL;