Add atk-bridge
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_collection.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2007 IBM Corp.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #include <cspi/spi.h>
24 #include <cspi/spi-private.h>
25
26 /**
27  * AccessibleCollection_ref:
28  * @obj: a pointer to the #AccessibleCollection object on which to operate.
29  *
30  * Increment the reference count for an #AccessibleCollection object.
31  **/
32
33 void
34 AccessibleCollection_ref (AccessibleCollection *obj)
35 {
36   cspi_object_ref (obj);
37 }
38
39 /**
40  * AccessibleCollection_unref:
41  * @obj: a pointer to the #Accessible object on which to operate.
42  *
43  * Decrement the reference count for an #AccessibleCollection object.
44  **/
45
46 void
47 AccessibleCollection_unref (AccessibleCollection *obj)
48 {
49   cspi_object_unref (obj);
50 }
51
52 /**
53  * AccessibleCollection_createMatchRule:
54  * @obj: a pointer to the #Accessible object on which to operate.
55  * @states: An #AccessibleStateSet whose states are to be compared with the objects in the collection.
56  * @statematchtype A MatchType which determines the match requirements for the 'states' criterion.
57  * @attributes: An #AccessibleAttributeSet of attributes which should present 
58  * in members of a matching set. 
59  * @attributematchtype: A MatchType which determines the match requirements for the 'attributes' criterion.
60  * @roles: An #AcceessibleRoleSet specifying the #AccessibleRole values which are to be considered among the match criteria.
61  * @rolematchtype: A MatchType which determines the match requirements for the 'roles' criterion.
62  * @interfaces: A string which represents one or more IDL interface definitions which should be implemented by matching objects.
63  * @interfacematchtype: A MatchType which determines the match requirements for the 'interfaces' criterion.
64  * @invert: If TRUE, the resulting MatchRule will return objects which do NOT match the specified criteria, 
65  * instead of those which do; i.e. this parameter "inverts" the sense of the resulting query.
66  *
67  * Returns an #AccesibleMatchRule object which encapsulates the specified criteria.
68  **/
69
70 AccessibleMatchRule *
71 AccessibleCollection_createMatchRule (AccessibleCollection *obj,
72                                       AccessibleStateSet *states,
73                                       AccessibleCollectionMatchType statematchtype,
74                                       AccessibleAttributeSet *attributes,
75                                       AccessibleCollectionMatchType attributematchtype,
76                                       AccessibleRoleSet *roles,
77                                       AccessibleCollectionMatchType rolematchtype,
78                                       char *interfaces,
79                                       AccessibleCollectionMatchType interfacematchtype,
80                                       long int invert)
81 {
82
83      Accessibility_AttributeSet *attributeset;
84      Accessibility_RoleSet *roleset;
85      Accessibility_MatchRule retval;
86      int i;
87
88      cspi_return_val_if_fail (obj != NULL, NULL);
89
90      attributeset = CORBA_sequence_CORBA_string__alloc ();
91      attributeset->_length = attributes->len;
92      attributeset->_buffer = CORBA_sequence_CORBA_string_allocbuf (attributeset->_length);
93
94      for (i = 0; i < attributeset->_length; i++)
95           attributeset->_buffer [i] =  CORBA_string_dup (attributes->attributes [i]);
96
97      CORBA_sequence_set_release (attributeset, TRUE);
98
99      roleset =  Accessibility_RoleSet__alloc ();
100      roleset->_length = roles->len;
101      roleset->_buffer =  Accessibility_RoleSet_allocbuf (roleset->_length);
102                                         
103      for (i = 0; i < roleset->_length; i++)
104             roleset->_buffer [i] = roles->roles [i];
105
106      retval =  Accessibility_Collection_createMatchRule (CSPI_OBJREF (obj),
107                                                          states,
108                                                          statematchtype,
109                                                          attributeset, 
110                                                          attributematchtype,
111                                                          roleset, 
112                                                          rolematchtype,
113                                                          interfaces,
114                                                          interfacematchtype,
115                                                          invert,
116                                                          cspi_ev ());
117
118      cspi_return_val_if_ev ("createMatchRule", NULL);
119
120      return cspi_object_add (retval);
121     
122
123 }
124
125 /**
126  * AccessibleCollection_freeMatchRule:
127  * @obj: a pointer to the #Accessible object on which to operate.
128  * @matchrule: a pointer to the #AccessibleMatchRule to free
129  *
130  * Frees the resources associated with the specified #AccessibleMatchRule
131  **/
132
133 void
134 AccessibleCollection_freeMatchRule (AccessibleCollection *obj,
135                                     AccessibleMatchRule  *matchrule)
136 {
137
138      cspi_return_if_fail (obj != NULL);
139      
140      Accessibility_Collection_freeMatchRule (CSPI_OBJREF (obj),
141                                              CSPI_OBJREF (matchrule),
142                                              cspi_ev ());
143
144       cspi_return_if_ev ("freeMatchRule");
145 }