df6614108fb766199545e7ce192e6f14f5a5de2c
[platform/core/uifw/at-spi2-atk.git] / libspi / streamablecontent.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001, 2002 Sun Microsystems Inc.,
6  * Copyright 2001, 2002 Ximian, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 /* streamablecontent.c : implements the StreamableContent interface */
25
26 #include <config.h>
27 #include <stdio.h>
28 #include <libspi/accessible.h>
29 #include <libspi/component.h>
30 #include <libspi/streamablecontent.h>
31
32 /* Our parent Gtk object type */
33 #define PARENT_TYPE SPI_TYPE_BASE
34
35 /* A pointer to our parent object class */
36 static GObjectClass *spi_streamable_parent_class;
37
38 static AtkStreamableContent *
39 get_streamable_from_servant (PortableServer_Servant servant)
40 {
41   SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
42   g_return_val_if_fail (object != NULL, NULL);
43   g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT(object->gobj), NULL);
44   return ATK_STREAMABLE_CONTENT (object->gobj);
45 }
46
47 /*
48  * CORBA Accessibility::StreamableContent::getContentTypes method implementation
49  */
50 static Accessibility_StringSeq*
51 impl_accessibility_streamable_get_content_types (PortableServer_Servant servant,
52                                                  CORBA_Environment     *ev)
53 {
54   Accessibility_StringSeq *typelist = Accessibility_StringSeq__alloc ();
55   AtkStreamableContent *streamable = get_streamable_from_servant (servant);
56   int n_types, i;
57
58   typelist->_length = 0;
59   g_return_val_if_fail (streamable != NULL, typelist);
60
61   n_types = atk_streamable_content_get_n_mime_types (streamable);
62   typelist->_length = n_types;
63   typelist->_buffer = Accessibility_StringSeq_allocbuf (n_types);
64   for (i = 0; i < n_types; ++i) {
65     const gchar *mimetype = atk_streamable_content_get_mime_type (streamable, i);
66     typelist->_buffer[i] = CORBA_string_dup (mimetype ? mimetype : "");
67   }
68
69   return typelist;
70 }
71
72 /*
73  * CORBA Accessibility::StreamableContent::getContent method implementation
74  */
75 static Bonobo_Stream
76 impl_accessibility_streamable_get_content (PortableServer_Servant servant,
77                                            const CORBA_char * content_type,
78                                            CORBA_Environment     *ev)
79 {
80   Bonobo_Stream stream;
81   AtkStreamableContent *streamable = get_streamable_from_servant (servant);
82   GIOChannel *gio;
83
84   g_return_val_if_fail (streamable != NULL, NULL);
85
86   gio = atk_streamable_content_get_stream (streamable, content_type);
87
88   stream = CORBA_OBJECT_NIL; /* FIXME! */
89
90   return stream;
91 }
92
93 static void
94 spi_streamable_class_init (SpiStreamableClass *klass)
95 {
96         POA_Accessibility_StreamableContent__epv *epv = &klass->epv;
97         spi_streamable_parent_class = g_type_class_peek_parent (klass);
98
99         epv->getContentTypes = impl_accessibility_streamable_get_content_types;
100         epv->getContent = impl_accessibility_streamable_get_content;
101 }
102
103 static void
104 spi_streamable_init (SpiStreamable *streamable)
105 {
106 }
107
108 BONOBO_TYPE_FUNC_FULL (SpiStreamable,
109                        Accessibility_StreamableContent,
110                        PARENT_TYPE,
111                        spi_streamable)
112
113 SpiStreamable *
114 spi_streamable_interface_new (AtkObject *o)
115 {
116     SpiStreamable *retval = g_object_new (SPI_STREAMABLE_TYPE, NULL);
117
118     spi_base_construct (SPI_BASE (retval), G_OBJECT(o));
119
120     return retval;
121 }