6bbc82d9768bfbed7b58a65da6b8cc248b18b0ec
[platform/core/uifw/at-spi2-atk.git] / cspi / spi-hyperlink.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 #include <cspi/spi-private.h>
25
26 /**
27  * AccessibleHyperlink_ref:
28  * @obj: a pointer to the #AccessibleHyperlink object on which to operate.
29  *
30  * Increment the reference count for an #AccessibleHyperlink object.
31  **/
32 void
33 AccessibleHyperlink_ref (AccessibleHyperlink *obj)
34 {
35   cspi_object_ref (obj);
36 }
37
38 /**
39  * AccessibleHyperlink_unref:
40  * @obj: a pointer to the #AccessibleHyperlink object on which to operate.
41  *
42  * Decrement the reference count for an #AccessibleHyperlink object.
43  **/
44 void
45 AccessibleHyperlink_unref (AccessibleHyperlink *obj)
46 {
47   cspi_object_unref (obj);
48 }
49
50 /**
51  * AccessibleHyperlink_getNAnchors:
52  * @obj: a pointer to the #AccessibleHyperlink object on which to operate.
53  *
54  * Get the total number of anchors which an #AccessibleHyperlink implementor has.
55  *       Though typical hyperlinks have only one anchor, client-side image maps and
56  *       other hypertext objects may potentially activate or refer to multiple
57  *       URIs.  For each anchor there is a corresponding URI and object.
58  * @see AccessibleHyperlink_getURI() and AccessibleHyperlink_getObject().
59  *
60  * Returns: a #long indicating the number of anchors in this hyperlink.
61  **/
62 long
63 AccessibleHyperlink_getNAnchors (AccessibleHyperlink *obj)
64 {
65   dbus_int16_t retval;
66
67   cspi_return_val_if_fail (obj != NULL, -1);
68
69   cspi_dbus_get_property (obj, spi_interface_hyperlink, "nAnchors", NULL, "n", &retval);
70
71   cspi_return_val_if_ev ("getNAnchors", -1);
72
73   return retval;
74 }
75
76 /**
77  * AccessibleHyperlink_getURI:
78  * @obj: a pointer to the #AccessibleHyperlink implementor on which to operate.
79  * @i: a (zero-index) long integer indicating which hyperlink anchor to query.
80  *
81  * Get the URI associated with a particular hyperlink anchor.  
82  *
83  * Returns: a UTF-8 string giving the URI of the @ith hyperlink anchor.
84  **/
85 char *
86 AccessibleHyperlink_getURI (AccessibleHyperlink *obj,
87                             long int             i)
88 {
89   dbus_int32_t d_i = i;
90   char *retval;
91
92   cspi_return_val_if_fail (obj != NULL, NULL);
93
94   cspi_dbus_call (obj, spi_interface_hyperlink, "getURI", NULL, "i=>s", d_i, &retval);
95
96   cspi_return_val_if_ev ("getURI", NULL);
97
98   return retval;
99 }
100
101 /**
102  * AccessibleHyperlink_getObject:
103  * @obj: a pointer to the #AccessibleHyperlink implementor on which to operate.
104  * @i: a (zero-index) long integer indicating which hyperlink anchor to query.
105  *
106  * Get the object associated with a particular hyperlink anchor, as an #Accessible. 
107  *
108  * Returns: an #Accessible that represents the object associated with the @ith anchor
109  *        of the specified #AccessibleHyperlink.
110  **/
111 Accessible*
112 AccessibleHyperlink_getObject (AccessibleHyperlink *obj,
113                                long int             i)
114 {
115   dbus_int32_t d_i = i;
116   char *path;
117   Accessible *retval;
118
119   cspi_return_val_if_fail (obj != NULL, NULL);
120
121   cspi_dbus_call (obj, spi_interface_hyperlink, "getObject", NULL, "i=>o", d_i, &path);
122   retval = cspi_ref_related_accessible (obj, path);
123   g_free (path);
124   return retval;
125 }
126
127 /**
128  * AccessibleHyperlink_getIndexRange:
129  * @obj: a pointer to the #AccessibleHyperlink implementor on which to operate.
130  * @startIndex: a pointer to a long integer into which the starting
131  *       offset of the text associated with this #AccessibleHyperlink is returned.
132  * @endIndex: a pointer to a long integer into which the offset of the first character
133  *       after the text associated with this #AccessibleHyperlink is returned.
134  *
135  *
136  * Get the starting and ending character offsets of the text range associated with
137  *       a #AccessibleHyperlink, in its originating #AccessibleHypertext.
138  **/
139 void
140 AccessibleHyperlink_getIndexRange (AccessibleHyperlink *obj,
141                                    long int *startIndex,
142                                    long int *endIndex)
143 {
144   dbus_int32_t si, ei;
145
146   cspi_return_if_fail (obj != NULL);
147
148   cspi_dbus_get_property (obj, spi_interface_hyperlink, "startIndex", NULL, "i", &si);
149  cspi_return_if_ev ("startIndex");
150   cspi_dbus_get_property (obj, spi_interface_hyperlink, "endIndex", NULL, "i", &ei);
151  cspi_return_if_ev ("endIndex");
152  *startIndex = si;
153  *endIndex = ei; 
154 }
155
156 /**
157  * AccessibleHyperlink_isValid:
158  * @obj: a pointer to the #AccessibleHyperlink on which to operate.
159  *
160  * Tell whether an #AccessibleHyperlink object is still valid with respect to its
161  *          originating hypertext object.
162  *
163  * Returns: #TRUE of the specified #AccessibleHyperlink is still valid with respect
164  *          to its originating #AccessibleHypertext object, #FALSE otherwise.
165  **/
166 SPIBoolean
167 AccessibleHyperlink_isValid (AccessibleHyperlink *obj)
168 {
169   dbus_bool_t retval;
170
171   cspi_return_val_if_fail (obj != NULL, FALSE);
172
173   cspi_dbus_call (obj, spi_interface_hyperlink, "isValid", NULL, "=>b", &retval);
174
175   cspi_return_val_if_ev ("isValid", FALSE);
176
177   return retval;
178 }
179
180