summaryrefslogtreecommitdiff
path: root/src/lib/elm_atspi_proxy.c
blob: 3aac6d589f4a43568a8e4ae06dbe3bf6e76294d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifdef HAVE_CONFIG_H
  #include "elementary_config.h"
#endif

#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED

#include <Elementary.h>
#include "elm_widget.h"
#include "elm_priv.h"


static Eina_List *_socket_list;

typedef struct _Elm_Atspi_Proxy_Data Elm_Atspi_Proxy_Data;

struct _Elm_Atspi_Proxy_Data
{
   Elm_Atspi_Proxy_Type type;
   const char *bus;
   const char *path;
};

EOLIAN static void
_elm_atspi_proxy_eo_base_destructor(Eo *obj, Elm_Atspi_Proxy_Data *_pd)
{
   if (_pd->type == ELM_ATSPI_PROXY_TYPE_SOCKET)
      _socket_list = eina_list_remove(_socket_list, obj);

   if (_pd->bus) eina_stringshare_del(_pd->bus);
   if (_pd->path) eina_stringshare_del(_pd->path);

   eo_do_super(obj, ELM_ATSPI_PROXY_CLASS, eo_destructor());
}

EOLIAN static void
_elm_atspi_proxy_constructor(Eo *obj, Elm_Atspi_Proxy_Data *_pd, Elm_Atspi_Proxy_Type type)
{
   Eo *parent;

   _pd->type = type;
   eo_do(obj, parent = eo_parent_get());
   if (!parent || !eo_isa(parent, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
     {
        CRI("Elm_Atspi_Proxy parent (%s) must implement ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN", eo_class_name_get(eo_class_get(parent)));
        abort();
     }
   if (type == ELM_ATSPI_PROXY_TYPE_SOCKET)
      _socket_list = eina_list_append(_socket_list, obj);
}

EOLIAN Elm_Atspi_Proxy_Type
_elm_atspi_proxy_type_get(Eo *obj EINA_UNUSED, Elm_Atspi_Proxy_Data *_pd)
{
   return _pd->type;
}

EOLIAN void
_elm_atspi_proxy_address_get(Eo *obj EINA_UNUSED, Elm_Atspi_Proxy_Data *_pd, const char **bus, const char **path)
{
   if (bus) *bus = _pd->bus;
   if (path) *path = _pd->path;
}

EOLIAN void
_elm_atspi_proxy_address_set(Eo *obj EINA_UNUSED, Elm_Atspi_Proxy_Data *_pd, const char *bus, const char *path)
{
   if (bus) eina_stringshare_replace(&_pd->bus, bus);
   if (path) eina_stringshare_replace(&_pd->path, path);
}

EOLIAN Eina_List*
_elm_atspi_proxy_elm_interface_atspi_accessible_children_get(Eo *obj EINA_UNUSED, Elm_Atspi_Proxy_Data *_pd)
{
   Eina_List *ret = NULL;
   if (_pd->type == ELM_ATSPI_PROXY_TYPE_SOCKET)
     {
        Eo *parent;
        eo_do(obj, parent = eo_parent_get());
        ret = eina_list_append(ret, parent);
     }
   return ret;
}

EOLIAN Eo*
_elm_atspi_proxy_elm_interface_atspi_accessible_parent_get(Eo *obj EINA_UNUSED, Elm_Atspi_Proxy_Data *_pd)
{
   Eo *ret = NULL;
   if (_pd->type == ELM_ATSPI_PROXY_TYPE_PLUG)
     {
        eo_do(obj, ret = eo_parent_get());
     }
   return ret;
}

Eina_List*
_elm_atspi_proxy_socket_list_get(void)
{
   return eina_list_clone(_socket_list);
}

#include "elm_atspi_proxy.eo.c"