X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git;a=blobdiff_plain;f=cspi%2Fspi_main.c;h=b8e11bd1c5cde99e772cb2d5d9cc51fb3f209a95;hp=e32a5d03b846f0b122cf78208aeead2fb8383906;hb=5d01be6ec7d2cb2e662c695bd4c28c50ac3f2dab;hpb=cce24ca259d92a12e5cb84fa64cba9f6e2f8a96a diff --git a/cspi/spi_main.c b/cspi/spi_main.c index e32a5d0..b8e11bd 100644 --- a/cspi/spi_main.c +++ b/cspi/spi_main.c @@ -35,7 +35,7 @@ #undef DEBUG_OBJECTS -static CORBA_Environment ev = { 0 }; +static CORBA_Environment ev = { NULL }; static Accessibility_Registry registry = CORBA_OBJECT_NIL; static GHashTable *live_refs = NULL; static GQueue *exception_handlers = NULL; @@ -80,7 +80,7 @@ cspi_object_release (gpointer value) } gboolean -_cspi_exception_throw (CORBA_Environment *ev, char *desc_prefix) +cspi_exception_throw (CORBA_Environment *ev, char *desc_prefix) { SPIExceptionHandler *handler = NULL; SPIException ex; @@ -268,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 || @@ -278,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--; + } } } @@ -320,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); @@ -354,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) @@ -371,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; } /** @@ -414,7 +430,7 @@ SPI_event_quit (void) * **/ SPIBoolean -SPI_eventIsReady () +SPI_eventIsReady (void) { return FALSE; } @@ -437,6 +453,7 @@ SPI_nextEvent (SPIBoolean waitForEvent) return NULL; } +#ifdef PRINT_LEAKS static void report_leaked_ref (gpointer key, gpointer val, gpointer user_data) { @@ -460,7 +477,7 @@ report_leaked_ref (gpointer key, gpointer val, gpointer user_data) SPI_freeString (name); } - +#endif /** * SPI_exit: @@ -485,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; } @@ -529,7 +542,36 @@ SPI_freeString (char *s) } /** - * DOCUMENT_ME! + * 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. + * + * @Since: AT-SPI 1.6 + **/ +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); + } +} + +/** + * SPI_dupString: + * @s: a UTF-8 string to be duplicated + * + * @Since: AT-SPI 1.4 + * + * Returns: a duplicate of the string passed as a parameter, which should + * be freed via SPI_freeString after use. **/ char * SPI_dupString (char *s) @@ -543,7 +585,15 @@ SPI_dupString (char *s) } /** - * DOCUMENT_ME! + * SPI_exceptionHandlerPush: + * @handler: an #SPIExceptionHandler to install as the first code to deal with exceptions. + * + * Install a client-side handler for #SPIException instances, which can see and handle any + * exceptions before chaining them to the next exception handler in the stack. + * + * @Since: AT-SPI 1.4 + * + * Returns %TRUE if the result succeeded, %FALSE if @hander could not be registered. **/ SPIBoolean SPI_exceptionHandlerPush (SPIExceptionHandler *handler) { @@ -554,7 +604,13 @@ SPIBoolean SPI_exceptionHandlerPush (SPIExceptionHandler *handler) } /** - * DOCUMENT_ME! + * SPI_exceptionHandlerPop: + * + * Remove/pop an #SPIExceptionHandler off the error handler stack and return the new handler. + * + * @Since: AT-SPI 1.4 + * + * Returns the #SPIExceptionHandler which is now at the top of the error handler stack after the call. **/ SPIExceptionHandler* SPI_exceptionHandlerPop (void) { @@ -562,18 +618,32 @@ SPIExceptionHandler* SPI_exceptionHandlerPop (void) } /** - * DOCUMENT_ME! + * SPIException_getSourceType: + * @err: the exception being queried + * + * Get the #SPIExceptionType of an exception which has been thrown. + * + * @Since: AT-SPI 1.4 + * + * Returns: the #SPIExceptionType corresponding to exception @err. **/ SPIExceptionType SPIException_getSourceType (SPIException *err) { if (err) return err->type; else - return SPI_EXCEPTION_UNSPECIFIED; + return SPI_EXCEPTION_SOURCE_UNSPECIFIED; } /** - * DOCUMENT_ME! + * SPIException_getExceptionCode: + * @err: the #SPIException being queried. + * + * Get the #SPIExceptionCode telling what type of exception condition has occurred. + * + * @Since: AT-SPI 1.4 + * + * Returns: the #SPIExceptionCode corresponding to exception @err. **/ SPIExceptionCode SPIException_getExceptionCode (SPIException *err) { @@ -581,7 +651,14 @@ SPIExceptionCode SPIException_getExceptionCode (SPIException *err) } /** - * DOCUMENT_ME! + * SPIAccessibleException_getSource: + * @err: the #SPIException being queried. + * + * Get the identity of the object which threw an exception. + * + * @Since: AT-SPI 1.4 + * + * Returns: a pointer to the #Accessible object which threw the exception. **/ Accessible* SPIAccessibleException_getSource (SPIException *err) { @@ -591,7 +668,14 @@ Accessible* SPIAccessibleException_getSource (SPIException *err) } /** - * DOCUMENT_ME! + * SPIException_getDescription: + * @err: the #SPIException being queried. + * + * Get a text description of the exception that has been thrown. + * Unfortunately these descriptions tend to be terse and limited in + * the detail which they can provide. + * + * Returns: a brief character string describing the exception. **/ char* SPIException_getDescription (SPIException *err) {