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 Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 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
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with this library; if not, write to the
20
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21
 * Boston, MA 02110-1301, USA.
22
 */
23

            
24
#include "atspi-private.h"
25

            
26
/**
27
 * AtspiApplication:
28
 *
29
 * An interface identifying the root object associated
30
 * with a running application.
31
 *
32
 * An interface identifying an object which is the root of the
33
 * hierarchy associated with a running application.
34
 */
35

            
36
2
G_DEFINE_TYPE (AtspiApplication, atspi_application, G_TYPE_OBJECT)
37

            
38
static void
39
166
atspi_application_init (AtspiApplication *application)
40
{
41
166
}
42

            
43
static void
44
1295
dispose_accessible (gpointer key, gpointer obj_data, gpointer data)
45
{
46
1295
  g_object_run_dispose (obj_data);
47
1295
}
48

            
49
static void
50
382
atspi_application_dispose (GObject *object)
51
{
52
382
  AtspiApplication *application = ATSPI_APPLICATION (object);
53

            
54
382
  if (application->bus)
55
    {
56
166
      if (application->bus != _atspi_bus ())
57
160
        dbus_connection_close (application->bus);
58
166
      dbus_connection_unref (application->bus);
59
166
      application->bus = NULL;
60
    }
61

            
62
382
  if (application->hash)
63
    {
64
166
      g_hash_table_foreach (application->hash, dispose_accessible, NULL);
65
166
      g_hash_table_unref (application->hash);
66
166
      application->hash = NULL;
67
    }
68

            
69
382
  if (application->root)
70
    {
71
326
      g_clear_object (&application->root->parent.app);
72
326
      g_object_unref (application->root);
73
326
      application->root = NULL;
74
    }
75

            
76
382
  G_OBJECT_CLASS (atspi_application_parent_class)->dispose (object);
77
382
}
78

            
79
static void
80
2
atspi_application_finalize (GObject *object)
81
{
82
2
  AtspiApplication *application = ATSPI_APPLICATION (object);
83

            
84
2
  g_free (application->bus_name);
85
2
  g_free (application->toolkit_name);
86
2
  g_free (application->toolkit_version);
87
2
  g_free (application->atspi_version);
88

            
89
2
  G_OBJECT_CLASS (atspi_application_parent_class)->finalize (object);
90
2
}
91

            
92
static void
93
2
atspi_application_class_init (AtspiApplicationClass *klass)
94
{
95
2
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
96

            
97
2
  object_class->dispose = atspi_application_dispose;
98
2
  object_class->finalize = atspi_application_finalize;
99
2
}
100

            
101
AtspiApplication *
102
166
_atspi_application_new (const gchar *bus_name)
103
{
104
  AtspiApplication *application;
105

            
106
166
  application = g_object_new (ATSPI_TYPE_APPLICATION, NULL);
107
166
  application->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
108
166
  application->bus_name = g_strdup (bus_name);
109
166
  application->root = NULL;
110
166
  return application;
111
}