Beispiel #1
0
SPIBoolean
cspi_accessible_is_a (Accessible *accessible,
		      const char *interface_name)
{
  SPIBoolean        retval;
  Bonobo_Unknown unknown;

  if (accessible == NULL)
    {
      return FALSE;
    }

  unknown = Bonobo_Unknown_queryInterface (CSPI_OBJREF (accessible),
					   interface_name, cspi_ev ());

  if (ev._major != CORBA_NO_EXCEPTION)
    {
      g_warning ("Exception '%s' checking if is '%s'",
		 cspi_exception_get_text (),
		 interface_name);
      retval = FALSE;
    }

  else if (unknown != CORBA_OBJECT_NIL)
    {
      retval = TRUE;
      cspi_release_unref (unknown);
    }
  else
    {
      retval = FALSE;
    }

  return retval;
}
static void
stream_cache_item_free (gpointer a)
{
  struct StreamCacheItem *cache_item = a;

  cspi_release_unref (cache_item->stream);
  SPI_freeString (cache_item->mimetype);
  g_free (cache_item);
}
Beispiel #3
0
/*
 *   This method swallows the corba_object BonoboUnknown
 * reference, and returns an Accessible associated with it.
 * If the reference is loaned, it means it is only valid
 * between a borrow / return pair.
 */
static Accessible *
cspi_object_get_ref (CORBA_Object corba_object, gboolean on_loan)
{
  Accessible *ref;

  if (corba_object == CORBA_OBJECT_NIL)
    {
      ref = NULL;
    }
  else if (!cspi_check_ev ("pre method check: add"))
    {
      ref = NULL;
    }
  else
    {
      if ((ref = g_hash_table_lookup (cspi_get_live_refs (), corba_object)))
        {
          g_return_val_if_fail (ref->ref_count > 0, NULL);
	  ref->ref_count++;
	  if (!on_loan)
	    {
	      if (ref->on_loan) /* Convert to a permanant ref */
		{
                  ref->on_loan = FALSE;
		}
	      else
	        {
		  cspi_release_unref (corba_object);
		}
	    }
#ifdef DEBUG_OBJECTS
          g_print ("returning cached %p => %p\n", ref, ref->objref);
#endif
	}
      else
        {
	  ref = malloc (sizeof (Accessible));
	  ref->objref = corba_object;
	  ref->ref_count = 1;
	  ref->on_loan = on_loan;
#ifdef DEBUG_OBJECTS
          g_print ("allocated %p => %p\n", ref, corba_object);
#endif
          g_hash_table_insert (cspi_get_live_refs (), ref->objref, ref);
	}
    }

  return ref;
}
Beispiel #4
0
static void
cspi_cleanup (void)
{
  GHashTable *refs;

  cspi_streams_close_all ();

  refs = live_refs;
  live_refs = NULL;
  if (refs)
    {
      g_hash_table_destroy (refs);
    }

  if (registry != CORBA_OBJECT_NIL)
    {
      cspi_release_unref (registry);
      registry = CORBA_OBJECT_NIL;
    }
}
Beispiel #5
0
static void
cspi_object_release (gpointer value)
{
  Accessible *a = (Accessible *) value;

#ifdef DEBUG_OBJECTS
  g_print ("releasing %p => %p\n", a, a->objref);
#endif

  if (!a->on_loan)
    {
      cspi_release_unref (a->objref);
    }

  memset (a, 0xaa, sizeof (Accessible));
  a->ref_count = -1;

#ifndef DEBUG_OBJECTS
  free (a);
#endif
}