2003-07-01 Artur Flinta <aflinta@cvs.gnome.org>
[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/streamablecontent.h>
30
31 /* Our parent Gtk object type */
32 #define PARENT_TYPE SPI_TYPE_BASE
33
34 /* A pointer to our parent object class */
35 static GObjectClass *spi_streamable_parent_class;
36
37 static AtkStreamableContent *
38 get_streamable_from_servant (PortableServer_Servant servant)
39 {
40   SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
41   g_return_val_if_fail (object != NULL, NULL);
42   g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT(object->gobj), NULL);
43   return ATK_STREAMABLE_CONTENT (object->gobj);
44 }
45
46 /*
47  * CORBA Accessibility::StreamableContent::getContentTypes method implementation
48  */
49 static Accessibility_StringSeq*
50 impl_accessibility_streamable_get_content_types (PortableServer_Servant servant,
51                                                  CORBA_Environment     *ev)
52 {
53   Accessibility_StringSeq *typelist = Accessibility_StringSeq__alloc ();
54   AtkStreamableContent *streamable = get_streamable_from_servant (servant);
55   int n_types, i;
56
57   typelist->_length = 0;
58   g_return_val_if_fail (streamable != NULL, typelist);
59
60   n_types = atk_streamable_content_get_n_mime_types (streamable);
61   typelist->_length = n_types;
62   typelist->_buffer = Accessibility_StringSeq_allocbuf (n_types);
63   for (i = 0; i < n_types; ++i) {
64     const gchar *mimetype = atk_streamable_content_get_mime_type (streamable, i);
65     typelist->_buffer[i] = CORBA_string_dup (mimetype ? mimetype : "");
66   }
67
68   return typelist;
69 }
70
71 /*
72  * CORBA Accessibility::StreamableContent::getContent method implementation
73  */
74 static Bonobo_Stream
75 impl_accessibility_streamable_get_content (PortableServer_Servant servant,
76                                            const CORBA_char * content_type,
77                                            CORBA_Environment     *ev)
78 {
79   Bonobo_Stream stream;
80   AtkStreamableContent *streamable = get_streamable_from_servant (servant);
81   GIOChannel *gio;
82
83   g_return_val_if_fail (streamable != NULL, NULL);
84
85   gio = atk_streamable_content_get_stream (streamable, content_type);
86
87   stream = CORBA_OBJECT_NIL; /* FIXME! */
88
89   return stream;
90 }
91
92 static void
93 spi_streamable_class_init (SpiStreamableClass *klass)
94 {
95         POA_Accessibility_StreamableContent__epv *epv = &klass->epv;
96         spi_streamable_parent_class = g_type_class_peek_parent (klass);
97
98         epv->getContentTypes = impl_accessibility_streamable_get_content_types;
99         epv->getContent = impl_accessibility_streamable_get_content;
100 }
101
102 static void
103 spi_streamable_init (SpiStreamable *streamable)
104 {
105 }
106
107 BONOBO_TYPE_FUNC_FULL (SpiStreamable,
108                        Accessibility_StreamableContent,
109                        PARENT_TYPE,
110                        spi_streamable)
111
112 SpiStreamable *
113 spi_streamable_interface_new (AtkObject *o)
114 {
115     SpiStreamable *retval = g_object_new (SPI_STREAMABLE_TYPE, NULL);
116
117     spi_base_construct (SPI_BASE (retval), G_OBJECT(o));
118
119     return retval;
120 }