Changes to introspection generation to remove DOCTYPE and XML
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_event.c
index c12e3dc..07feaed 100644 (file)
@@ -336,7 +336,16 @@ cspi_internal_event_get_text (const InternalEvent *e)
   g_return_val_if_fail (e, NULL);
   g_return_val_if_fail (e->data, NULL);
   any = (CORBA_any *) e->data;
-  if (CORBA_TypeCode_equivalent (any->_type, TC_CORBA_string, NULL)) 
+  if (CORBA_TypeCode_equivalent (any->_type, TC_Accessibility_EventDetails, NULL)) 
+    {
+      Accessibility_EventDetails *details = (Accessibility_EventDetails *)any->_value;
+      if (CORBA_TypeCode_equal (details->any_data._type, TC_CORBA_string, cspi_ev()))
+         return CORBA_string_dup (* (char **) (details->any_data._value));
+      else
+         return CORBA_string_dup ("");
+      return CORBA_string_dup (* (char **) (details->any_data._value));
+    }
+  else if (CORBA_TypeCode_equivalent (any->_type, TC_CORBA_string, NULL)) 
     {
       return CORBA_string_dup (* (char **) any->_value);
     } 
@@ -359,12 +368,179 @@ cspi_internal_event_get_object (const InternalEvent *e)
   g_return_val_if_fail (e->data, NULL);
 
   any = (CORBA_any *) e->data;
-  if (CORBA_TypeCode_equal (any->_type, TC_CORBA_Object, cspi_ev()))
+  if (CORBA_TypeCode_equivalent (any->_type, TC_Accessibility_EventDetails, NULL)) 
+    {
+      Accessibility_EventDetails *details = (Accessibility_EventDetails *)any->_value;
+      if (CORBA_TypeCode_equal (details->any_data._type, TC_CORBA_Object, cspi_ev()))
+         return cspi_object_take (* (CORBA_Object *) (details->any_data._value));
+      else
+         return NULL;
+    }
+  else if (CORBA_TypeCode_equal (any->_type, TC_CORBA_Object, cspi_ev()))
     return cspi_object_take (* (CORBA_Object *) any->_value);
   else 
     return NULL;
 }
 
+static SPIRect *
+cspi_internal_event_get_rect (const InternalEvent *e)
+{
+  CORBA_any *any;
+  g_return_val_if_fail (e, NULL);
+  g_return_val_if_fail (e->data, NULL);
+  any = (CORBA_any *) e->data;
+  if (CORBA_TypeCode_equivalent (any->_type, TC_Accessibility_EventDetails, NULL)) 
+    {
+      Accessibility_EventDetails *details = (Accessibility_EventDetails *)any->_value;
+      SPIRect *rect = g_new (SPIRect, 1);
+      if (CORBA_TypeCode_equal (details->any_data._type, TC_Accessibility_BoundingBox, cspi_ev()))
+      {
+         Accessibility_BoundingBox *bounds = (Accessibility_BoundingBox *) details->any_data._value;
+         rect->x = bounds->x;
+         rect->y = bounds->y;
+         rect->width = bounds->width;
+         rect->height = bounds->height;
+         return rect;
+      }
+      else
+         return NULL;
+    }
+  if (CORBA_TypeCode_equivalent (any->_type, TC_Accessibility_BoundingBox, NULL)) 
+    {
+      SPIRect *rect = g_new (SPIRect, 1);
+      Accessibility_BoundingBox *bounds = (Accessibility_BoundingBox *) any->_value;
+      rect->x = bounds->x;
+      rect->y = bounds->y;
+      rect->width = bounds->width;
+      rect->height = bounds->height;
+      return rect;
+    } 
+  else
+    {
+#ifdef EVENT_CONTEXT_DEBUG
+      fprintf (stderr, "requested string, TC is not TC_Accessible_RectBounds! (%u)\n",
+              (unsigned) any->_type);
+#endif
+      return NULL;
+    }
+}
+
+/**
+ * AccessibleEvent_getSourceName:
+ * @e: an #AccessibleEvent to be queried. 
+ *
+ * Get the 'accessible-name' of the object emitting the event.
+ *
+ * Returns: The name of the event source, or NULL if the event source cannot be identified
+ *          or does not report a name.
+ */
+char*        AccessibleEvent_getSourceName (const AccessibleEvent *e)
+{
+    InternalEvent *ie = (InternalEvent *)e;
+    CORBA_any *any = ((ie && ie->data) ? (CORBA_any *)ie->data : NULL);
+    if (any &&
+       CORBA_TypeCode_equivalent (any->_type, 
+                                  TC_Accessibility_EventDetails, NULL))
+      {
+         Accessibility_EventDetails *details = (Accessibility_EventDetails *) any->_value;
+         return CORBA_string_dup (details->source_name);
+      }
+    else
+       return NULL;
+}
+
+/**
+ * AccessibleEvent_getSourceRole:
+ * @e: an #AccessibleEvent to be queried. 
+ *
+ * Get the #AccessibleRole of the object emitting the event.
+ *
+ * Returns: #AccessibleRole of the event source, or SPI_ROLE_UNKNOWN
+ *          if the event source's role is unknown or unspecified.
+ *          (Some kinds of events, such as 'mouse:' events or
+ *          toolkit events, don't have associated object roles.)
+ */
+AccessibleRole AccessibleEvent_getSourceRole (const AccessibleEvent *e)
+{
+    InternalEvent *ie = (InternalEvent *)e;
+    CORBA_any *any = ((ie && ie->data) ? (CORBA_any *)ie->data : NULL);
+    if (any &&
+       CORBA_TypeCode_equivalent (any->_type, 
+                                  TC_Accessibility_EventDetails, NULL))
+      {
+         Accessibility_EventDetails *details = (Accessibility_EventDetails *) any->_value;
+         return cspi_role_from_spi_role (details->source_role);
+      }
+    else
+       return SPI_ROLE_UNKNOWN;
+}
+
+/**
+ * AccessibleEvent_getSourceApplication:
+ * @e: an #AccessibleEvent to be queried. 
+ *
+ * Get the #Application hosting the object which emitted the event.
+ *
+ * Returns: A pointer to the host #Application contining the event source
+ *          component.
+ */
+AccessibleApplication* AccessibleEvent_getSourceApplication (const AccessibleEvent *e)
+{
+    InternalEvent *ie = (InternalEvent *)e;
+    CORBA_any *any = ((ie && ie->data) ? (CORBA_any *)ie->data : NULL);
+    if (any &&
+       CORBA_TypeCode_equivalent (any->_type, 
+                                  TC_Accessibility_EventDetails, NULL))
+      {
+         Accessibility_EventDetails *details = (Accessibility_EventDetails *) any->_value;
+         return  cspi_object_take (details->host_application);
+      }
+    else
+       return NULL;
+}
+
+/**
+ * AccessibleEvent_getSourceDetails:
+ * @e: an #AccessibleEvent to be queried. 
+ * @name: a pointer to a character string which will point to the name of the event source 
+ * on successful completion of the call.
+ * @role: a pointer to an #AccessibleRole which will point to the role of the event source
+ * on successful completion of the call.
+ * @app: A pointer to an #AccessibleApplication which points to the host application for this event
+ * on successful completion of the call.
+ *
+ * Get the host #Application, "accessible name", and #AccessibleRole 
+ * of the object which emitted the event.
+ *
+ * Returns: TRUE if the source details were successfully retrieved, 
+ *          FALSE if they were not, either due to error, incomplete data,
+ *          or the fact that the event did not encapsulate the required data.
+ */
+SPIBoolean   AccessibleEvent_getSourceDetails (const AccessibleEvent *e, 
+                                              char **name, AccessibleRole *role, 
+                                              AccessibleApplication **app)
+{
+    InternalEvent *ie = (InternalEvent *)e;
+    CORBA_any *any = ((ie && ie->data) ? (CORBA_any *)ie->data : NULL);
+    if (any &&
+       CORBA_TypeCode_equivalent (any->_type, 
+                                  TC_Accessibility_EventDetails, NULL))
+      {
+         Accessibility_EventDetails *details = (Accessibility_EventDetails *) any->_value;
+         *name = CORBA_string_dup (details->source_name);
+         *role = cspi_role_from_spi_role (details->source_role);
+         *app = cspi_object_take (details->host_application);
+         return TRUE;
+      }
+    else
+      {
+        *name = NULL;
+       *role = SPI_ROLE_UNKNOWN;
+       *app = NULL;
+       return FALSE;
+      }
+}
+
 /**
  * AccessibleTextChangedEvent_getChangeString:
  * @e: a pointer to the #AccessibleEvent being queried.
@@ -379,7 +555,7 @@ char *
 AccessibleTextChangedEvent_getChangeString (const AccessibleEvent *e)
 {
   const InternalEvent *foo = (InternalEvent *) e;
-  /* TODO: check the event type? expensive... */
+  /* TODO: check the event type. */
   return cspi_internal_event_get_text (foo);
 }
 
@@ -396,7 +572,7 @@ char *
 AccessibleTextSelectionChangedEvent_getSelectionString (const AccessibleEvent *e)
 {
   const InternalEvent *foo = (InternalEvent *) e;
-  /* TODO: check the event type? expensive... */
+  /* TODO: check the event type. */
   return cspi_internal_event_get_text (foo);
 }
 
@@ -414,7 +590,7 @@ char *
 AccessibleWindowEvent_getTitleString (const AccessibleEvent *e)
 {
   const InternalEvent *foo = (InternalEvent *) e;
-  /* TODO: check the event type? expensive... */
+  /* TODO: check the event type. */
   return cspi_internal_event_get_text (foo);
 }
 
@@ -532,7 +708,7 @@ char *
 AccessibleTableCaptionChangedEvent_getCaptionString (const AccessibleEvent *e)
 {
   const InternalEvent *foo = (InternalEvent *) e;
-  /* TODO: check the event type? expensive... */
+  /* TODO: check the event type. */
   return cspi_internal_event_get_text (foo);
 }
 
@@ -551,7 +727,7 @@ char *
 AccessibleTableRowDescriptionChangedEvent_getDescriptionString (const AccessibleEvent *e)
 {
   const InternalEvent *foo = (InternalEvent *) e;
-  /* TODO: check the event type? expensive... */
+  /* TODO: check the event type. */
   return cspi_internal_event_get_text (foo);
 }
 
@@ -570,7 +746,7 @@ char *
 AccessibleTableColumnDescriptionChangedEvent_getDescriptionString (const AccessibleEvent *e)
 {
   const InternalEvent *foo = (InternalEvent *) e;
-  /* TODO: check the event type? expensive... */
+  /* TODO: check the event type. */
   return cspi_internal_event_get_text (foo);
 }
 
@@ -589,10 +765,32 @@ char *
 AccessibleDescriptionChangedEvent_getDescriptionString (const AccessibleEvent *e)
 {
   const InternalEvent *foo = (InternalEvent *) e;
-  /* TODO: check the event type? expensive... */
+  /* TODO: check the event type. */
   return cspi_internal_event_get_text (foo);
 }
 
+/**
+ * AccessibleBoundsChangedEvent_getNewBounds:
+ * @e: a pointer to the #AccessibleEvent being queried.
+ *
+ * Queries an #AccessibleEvent of type "object:bounds-changed", 
+ *         returning a pointer to an SPIRect structure containing the
+ *         new bounds, or NULL on error.
+ *         The returned structure should be freed with SPI_freeRect when 
+ *         the caller has finished referencing it.
+ *
+ * @Since: AT-SPI 1.6
+ *
+ * Returns: a pointer to an SPIRect defining the new object bounds.
+ **/
+SPIRect *
+AccessibleBoundsChangedEvent_getNewBounds (const AccessibleEvent *e)
+{
+  const InternalEvent *foo = (InternalEvent *) e;
+  /* TODO: check the event type. */
+  return cspi_internal_event_get_rect (foo);
+}
+
 static gint
 cspi_event_compare (gconstpointer p1, gconstpointer p2)
 {
@@ -704,7 +902,13 @@ AccessibleEvent_unref (const AccessibleEvent *e)
        {
          event->ref_count--;
          if (event->ref_count < 1)
-           cspi_internal_event_remove (event);
+            {
+             cspi_internal_event_remove (event);
+              g_free ((gpointer)e->type);
+              Accessible_unref (e->source);
+              CORBA_free (event->data);
+              g_free ((gpointer)e);
+            }
        }
     }
 }