Removed intltool dependency and translation of .server file. Fixes bug 322846.
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_main.c
index f2a4e46..a0acdae 100644 (file)
@@ -157,6 +157,12 @@ cspi_get_live_refs (void)
 }
 
 CORBA_Environment *
+cspi_peek_ev (void)
+{
+  return &ev;
+}
+
+CORBA_Environment *
 cspi_ev (void)
 {
   CORBA_exception_init (&ev);
@@ -262,6 +268,7 @@ cspi_object_borrow (CORBA_Object corba_object)
 void
 cspi_object_return (Accessible *accessible)
 {
+  int old_ref_count;
   g_return_if_fail (accessible != NULL);
 
   if (!accessible->on_loan ||
@@ -272,8 +279,17 @@ cspi_object_return (Accessible *accessible)
   else /* Convert to a permanant ref */
     {
       accessible->on_loan = FALSE;
+      old_ref_count = accessible->ref_count;
       accessible->objref = cspi_dup_ref (accessible->objref);
-      accessible->ref_count--;
+      if (old_ref_count != accessible->ref_count &&
+          accessible->ref_count == 1)
+        {
+            cspi_object_unref (accessible);
+        }
+      else    
+        {
+          accessible->ref_count--;
+        }
     }
 }
 
@@ -314,6 +330,7 @@ cspi_object_unref (Accessible *accessible)
       return;
     }
 
+  g_return_if_fail (accessible->ref_count > 0);
   if (--accessible->ref_count == 0)
     {
       g_hash_table_remove (cspi_get_live_refs (), accessible->objref);
@@ -348,7 +365,7 @@ static gboolean SPI_inited = FALSE;
  *
  * Connects to the accessibility registry and initializes the SPI.
  *
- * Returns: 0 on success, otherwise an integer error code.
+ * Returns: 0 on success, otherwise an integer error code.  
  **/
 int
 SPI_init (void)
@@ -365,8 +382,13 @@ SPI_init (void)
   registry = cspi_init ();
 
   g_atexit (cspi_cleanup);
-  
-  return 0;
+
+  /* fprintf (stderr, "registry=%x\n", (int) registry); */
+
+  if ((registry != CORBA_OBJECT_NIL) && (cspi_ping (registry)))
+      return 0;
+  else
+      return 2;
 }
 
 /**
@@ -431,6 +453,7 @@ SPI_nextEvent (SPIBoolean waitForEvent)
   return NULL;
 }
 
+#ifdef PRINT_LEAKS
 static void
 report_leaked_ref (gpointer key, gpointer val, gpointer user_data)
 {
@@ -454,7 +477,7 @@ report_leaked_ref (gpointer key, gpointer val, gpointer user_data)
 
   SPI_freeString (name);
 }
-
+#endif
 
 /**
  * SPI_exit:
@@ -479,27 +502,23 @@ SPI_exit (void)
   if (live_refs)
     {
       leaked = g_hash_table_size (live_refs);
+#ifdef DEBUG_OBJECTS
+      fprintf (stderr, "Leaked %d SPI handles\n", leaked);
+
 #define PRINT_LEAKS
 #ifdef PRINT_LEAKS
       g_hash_table_foreach (live_refs, report_leaked_ref, NULL);
 #endif
+
+#endif
     }
   else
     {
       leaked = 0;
     }
 
-#ifdef DEBUG_OBJECTS
-  if (leaked)
-    {
-      fprintf (stderr, "Leaked %d SPI handles\n", leaked);
-    }
-#endif
-
   cspi_cleanup ();
 
-  fprintf (stderr, "bye-bye!\n");
-
   return leaked;
 }
 
@@ -523,6 +542,27 @@ SPI_freeString (char *s)
 }
 
 /**
+ * SPI_freeRect:
+ * @r: a pointer to an SPIRect returned from another at-spi call.
+ *
+ * Free a SPIRect structure returned from an at-spi call.  Clients of
+ * at-spi should use this function instead of free () or g_free().
+ * A NULL rect @r will be silently ignored.
+ * This API should not be used to free data
+ * from other libraries or allocated by the client.
+ **/
+void
+SPI_freeRect (SPIRect *r)
+{
+  if (r)
+    {
+      /* err, okay, in this case the client _could_ 
+        have called g_free, but we don't want to guarantee it */
+      g_free (r);
+    }
+}
+
+/**
  * DOCUMENT_ME!
  **/
 char *
@@ -563,7 +603,7 @@ SPIExceptionType SPIException_getSourceType (SPIException *err)
   if (err)
     return err->type;
   else
-    return SPI_EXCEPTION_UNSPECIFIED;
+    return SPI_EXCEPTION_SOURCE_UNSPECIFIED;
 }
 
 /**