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 <atk/atk.h>
26
#include <droute/droute.h>
27

            
28
#include "introspection.h"
29
#include "spi-dbus.h"
30

            
31
/* for spi_global_app_data  is there a better way? */
32
#include "../bridge.h"
33

            
34
static dbus_bool_t
35
1
impl_get_ToolkitName (DBusMessageIter *iter, void *user_data)
36
{
37
1
  return droute_return_v_string (iter, atk_get_toolkit_name ());
38
}
39

            
40
static dbus_bool_t
41
1
impl_get_Version (DBusMessageIter *iter, void *user_data)
42
{
43
1
  return droute_return_v_string (iter, atk_get_toolkit_version ());
44
}
45

            
46
static dbus_bool_t
47
1
impl_get_AtspiVersion (DBusMessageIter *iter, void *user_data)
48
{
49
1
  return droute_return_v_string (iter, "2.1");
50
}
51

            
52
static dbus_int32_t id;
53

            
54
static dbus_bool_t
55
1
impl_get_Id (DBusMessageIter *iter, void *user_data)
56
{
57
1
  return droute_return_v_int32 (iter, id);
58
}
59

            
60
static dbus_bool_t
61
161
impl_set_Id (DBusMessageIter *iter, void *user_data)
62
{
63
161
  id = droute_get_v_int32 (iter);
64
161
  return TRUE;
65
}
66

            
67
static DBusMessage *
68
impl_registerToolkitEventListener (DBusConnection *bus,
69
                                   DBusMessage *message,
70
                                   void *user_data)
71
{
72
  return NULL;
73
}
74

            
75
static DBusMessage *
76
impl_registerObjectEventListener (DBusConnection *bus, DBusMessage *message, void *user_data)
77
{
78
  return NULL;
79
}
80

            
81
static DBusMessage *
82
impl_GetLocale (DBusConnection *bus, DBusMessage *message, void *user_data)
83
{
84
  return NULL;
85
}
86

            
87
static DBusMessage *
88
161
impl_get_app_bus (DBusConnection *bus, DBusMessage *msg, void *data)
89
{
90
  DBusMessage *reply;
91

            
92
161
  if (bus == spi_global_app_data->bus)
93
161
    spi_atk_add_client (dbus_message_get_sender (msg));
94

            
95
161
  if (!spi_global_app_data->app_bus_addr)
96
161
    spi_atk_create_socket (spi_global_app_data);
97

            
98
161
  reply = dbus_message_new_method_return (msg);
99
161
  if (reply)
100
    {
101
161
      const char *retval = (atspi_is_initialized () ? "" : spi_global_app_data->app_bus_addr);
102
161
      if (!retval)
103
161
        retval = "";
104
161
      dbus_message_append_args (reply, DBUS_TYPE_STRING, &retval, DBUS_TYPE_INVALID);
105
    }
106

            
107
161
  return reply;
108
}
109

            
110
static DRouteMethod methods[] = {
111
  { impl_registerToolkitEventListener, "registerToolkitEventListener" },
112
  { impl_registerObjectEventListener, "registerObjectEventListener" },
113
  { impl_GetLocale, "GetLocale" },
114
  { impl_get_app_bus, "GetApplicationBusAddress" },
115
  { NULL, NULL }
116
};
117

            
118
static DRouteProperty properties[] = {
119
  { impl_get_ToolkitName, NULL, "ToolkitName" },
120
  { impl_get_Version, NULL, "Version" },
121
  { impl_get_AtspiVersion, NULL, "AtspiVersion" },
122
  { impl_get_Id, impl_set_Id, "Id" },
123
  { NULL, NULL, NULL }
124
};
125

            
126
/*static long
127
obj_is_root (const char *path, void *user_data)
128
{
129
  AtkObject *obj = atk_dbus_get_object (path);
130
  return (obj == atk_get_root ());
131
}*/
132

            
133
void
134
161
spi_initialize_application (DRoutePath *path)
135
{
136
161
  droute_path_add_interface (path,
137
                             ATSPI_DBUS_INTERFACE_APPLICATION,
138
                             spi_org_a11y_atspi_Application,
139
                             methods, properties);
140
161
};