1
/*
2
 * AT-SPI - Assistive Technology Service Provider Interface
3
 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4
 *
5
 * Copyright 2008 Novell, Inc.
6
 * Copyright 2001, 2002 Sun Microsystems Inc.,
7
 * Copyright 2001, 2002 Ximian, Inc.
8
 *
9
 * This library is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU Lesser General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2.1 of the License, or (at your option) any later version.
13
 *
14
 * This library is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 * Lesser General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public
20
 * License along with this library; if not, write to the
21
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22
 * Boston, MA 02110-1301, USA.
23
 */
24

            
25
#include "bridge.h"
26
#include <atk/atk.h>
27
#include <droute/droute.h>
28

            
29
#include "spi-dbus.h"
30

            
31
#include "introspection.h"
32
#include "object.h"
33

            
34
static DBusMessage *
35
1
impl_GetNLinks (DBusConnection *bus, DBusMessage *message, void *user_data)
36
{
37
1
  AtkHypertext *hypertext = (AtkHypertext *) user_data;
38
  gint rv;
39
  DBusMessage *reply;
40

            
41
1
  g_return_val_if_fail (ATK_IS_HYPERTEXT (user_data),
42
                        droute_not_yet_handled_error (message));
43
1
  rv = atk_hypertext_get_n_links (hypertext);
44
1
  reply = dbus_message_new_method_return (message);
45
1
  if (reply)
46
    {
47
1
      dbus_message_append_args (reply, DBUS_TYPE_INT32, &rv,
48
                                DBUS_TYPE_INVALID);
49
    }
50
1
  return reply;
51
}
52

            
53
static DBusMessage *
54
9
impl_GetLink (DBusConnection *bus, DBusMessage *message, void *user_data)
55
{
56
9
  AtkHypertext *hypertext = (AtkHypertext *) user_data;
57
  dbus_int32_t linkIndex;
58
  AtkHyperlink *link;
59

            
60
9
  g_return_val_if_fail (ATK_IS_HYPERTEXT (user_data),
61
                        droute_not_yet_handled_error (message));
62
9
  if (!dbus_message_get_args (message, NULL, DBUS_TYPE_INT32, &linkIndex, DBUS_TYPE_INVALID))
63
    {
64
      return droute_invalid_arguments_error (message);
65
    }
66
9
  link = atk_hypertext_get_link (hypertext, linkIndex);
67
  /*The above line doesn't ref the link, and the next call is going to unref*/
68
9
  if (link)
69
9
    g_object_ref (link);
70
9
  return spi_hyperlink_return_reference (message, link);
71
}
72

            
73
static DBusMessage *
74
3
impl_GetLinkIndex (DBusConnection *bus, DBusMessage *message, void *user_data)
75
{
76
3
  AtkHypertext *hypertext = (AtkHypertext *) user_data;
77
  dbus_int32_t characterIndex;
78
  dbus_int32_t rv;
79
  DBusMessage *reply;
80

            
81
3
  g_return_val_if_fail (ATK_IS_HYPERTEXT (user_data),
82
                        droute_not_yet_handled_error (message));
83
3
  if (!dbus_message_get_args (message, NULL, DBUS_TYPE_INT32, &characterIndex, DBUS_TYPE_INVALID))
84
    {
85
      return droute_invalid_arguments_error (message);
86
    }
87
3
  rv = atk_hypertext_get_link_index (hypertext, characterIndex);
88
3
  reply = dbus_message_new_method_return (message);
89
3
  if (reply)
90
    {
91
3
      dbus_message_append_args (reply, DBUS_TYPE_INT32, &rv,
92
                                DBUS_TYPE_INVALID);
93
    }
94
3
  return reply;
95
}
96

            
97
static DRouteMethod methods[] = {
98
  { impl_GetNLinks, "GetNLinks" },
99
  { impl_GetLink, "GetLink" },
100
  { impl_GetLinkIndex, "GetLinkIndex" },
101
  { NULL, NULL }
102
};
103

            
104
void
105
161
spi_initialize_hypertext (DRoutePath *path)
106
{
107
161
  spi_atk_add_interface (path,
108
                         ATSPI_DBUS_INTERFACE_HYPERTEXT, spi_org_a11y_atspi_Hypertext, methods, NULL);
109
161
};