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 dbus_bool_t
35
1
impl_get_ImageDescription (DBusMessageIter *iter, void *user_data)
36
{
37
1
  AtkImage *image = (AtkImage *) user_data;
38
1
  g_return_val_if_fail (ATK_IS_IMAGE (user_data), FALSE);
39
1
  return droute_return_v_string (iter,
40
1
                                 atk_image_get_image_description (image));
41
}
42

            
43
static dbus_bool_t
44
1
impl_get_ImageLocale (DBusMessageIter *iter, void *user_data)
45
{
46
1
  AtkImage *image = (AtkImage *) user_data;
47
1
  g_return_val_if_fail (ATK_IS_IMAGE (user_data), FALSE);
48
1
  return droute_return_v_string (iter, atk_image_get_image_locale (image));
49
}
50

            
51
static DBusMessage *
52
1
impl_GetImageExtents (DBusConnection *bus, DBusMessage *message, void *user_data)
53
{
54
1
  AtkImage *image = (AtkImage *) user_data;
55
  dbus_uint32_t coordType;
56
  gint ix, iy, iwidth, iheight;
57

            
58
1
  g_return_val_if_fail (ATK_IS_IMAGE (user_data),
59
                        droute_not_yet_handled_error (message));
60
1
  if (!dbus_message_get_args (message, NULL, DBUS_TYPE_UINT32, &coordType, DBUS_TYPE_INVALID))
61
    {
62
      return droute_invalid_arguments_error (message);
63
    }
64
1
  atk_image_get_image_size (image, &iwidth, &iheight);
65
1
  atk_image_get_image_position (image, &ix, &iy, (AtkCoordType) coordType);
66
1
  return spi_dbus_return_rect (message, ix, iy, iwidth, iheight);
67
}
68

            
69
static DBusMessage *
70
1
impl_GetImagePosition (DBusConnection *bus, DBusMessage *message, void *user_data)
71
{
72
1
  AtkImage *image = (AtkImage *) user_data;
73
  dbus_uint32_t coord_type;
74
1
  gint ix = 0, iy = 0;
75
  dbus_int32_t x, y;
76
  DBusMessage *reply;
77

            
78
1
  g_return_val_if_fail (ATK_IS_IMAGE (user_data),
79
                        droute_not_yet_handled_error (message));
80
1
  if (!dbus_message_get_args (message, NULL, DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
81
    {
82
      return droute_invalid_arguments_error (message);
83
    }
84
1
  atk_image_get_image_position (image, &ix, &iy, (AtkCoordType) coord_type);
85
1
  x = ix;
86
1
  y = iy;
87
1
  reply = dbus_message_new_method_return (message);
88
1
  if (reply)
89
    {
90
1
      dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32,
91
                                &y, DBUS_TYPE_INVALID);
92
    }
93
1
  return reply;
94
}
95

            
96
static DBusMessage *
97
1
impl_GetImageSize (DBusConnection *bus, DBusMessage *message, void *user_data)
98
{
99
1
  AtkImage *image = (AtkImage *) user_data;
100
1
  gint iwidth = 0, iheight = 0;
101
  dbus_int32_t width, height;
102
  DBusMessage *reply;
103

            
104
1
  g_return_val_if_fail (ATK_IS_IMAGE (user_data),
105
                        droute_not_yet_handled_error (message));
106
1
  atk_image_get_image_size (image, &iwidth, &iheight);
107
1
  width = iwidth;
108
1
  height = iheight;
109
1
  reply = dbus_message_new_method_return (message);
110
1
  if (reply)
111
    {
112
1
      dbus_message_append_args (reply, DBUS_TYPE_INT32, &width,
113
                                DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID);
114
    }
115
1
  return reply;
116
}
117

            
118
static DRouteMethod methods[] = {
119
  { impl_GetImageExtents, "GetImageExtents" },
120
  { impl_GetImagePosition, "GetImagePosition" },
121
  { impl_GetImageSize, "GetImageSize" },
122
  { NULL, NULL }
123
};
124

            
125
static DRouteProperty properties[] = {
126
  { impl_get_ImageDescription, NULL, "ImageDescription" },
127
  { impl_get_ImageLocale, NULL, "ImageLocale" },
128
  { NULL, NULL, NULL }
129
};
130

            
131
void
132
161
spi_initialize_image (DRoutePath *path)
133
{
134
161
  spi_atk_add_interface (path,
135
                         ATSPI_DBUS_INTERFACE_IMAGE, spi_org_a11y_atspi_Image, methods, properties);
136
161
};