summaryrefslogtreecommitdiff
path: root/Source/FusionDale/proxy/requestor
diff options
context:
space:
mode:
Diffstat (limited to 'Source/FusionDale/proxy/requestor')
-rwxr-xr-xSource/FusionDale/proxy/requestor/Makefile.am34
-rwxr-xr-xSource/FusionDale/proxy/requestor/icoma_requestor.c272
-rwxr-xr-xSource/FusionDale/proxy/requestor/icoma_requestor.h58
-rwxr-xr-xSource/FusionDale/proxy/requestor/icomacomponent_requestor.c339
-rwxr-xr-xSource/FusionDale/proxy/requestor/ifusiondale_requestor.c182
5 files changed, 885 insertions, 0 deletions
diff --git a/Source/FusionDale/proxy/requestor/Makefile.am b/Source/FusionDale/proxy/requestor/Makefile.am
new file mode 100755
index 0000000..049f455
--- /dev/null
+++ b/Source/FusionDale/proxy/requestor/Makefile.am
@@ -0,0 +1,34 @@
+## Makefile.am for FusionDale/proxy/requestor
+
+INTERFACES_DIR = $(MODULEDIR)/interfaces
+
+ifusiondaledir = $(INTERFACES_DIR)/IFusionDale
+
+INCLUDES = \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include \
+ -I$(top_builddir)/lib \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/proxy/dispatcher \
+ $(DIRECTFB_INTERNAL_CFLAGS) \
+ -DDATADIR=\"${RUNTIME_SYSROOT}@DATADIR@\"
+
+LIBS = \
+ $(top_builddir)/lib/libfusiondale.la \
+ -lvoodoo \
+ $(DIRECTFB_LIBS)
+
+
+ifusiondale_LTLIBRARIES = \
+ libifusiondale_requestor.la
+
+if BUILD_STATIC
+ifusiondale_DATA = libifusiondale_requestor.o
+endif
+
+libifusiondale_requestor_la_SOURCES = ifusiondale_requestor.c
+libifusiondale_requestor_la_LDFLAGS = -avoid-version -module
+libifusiondale_requestor_la_LIBADDD = $(LIBS)
+
+
+include $(top_srcdir)/rules/libobject.make
diff --git a/Source/FusionDale/proxy/requestor/icoma_requestor.c b/Source/FusionDale/proxy/requestor/icoma_requestor.c
new file mode 100755
index 0000000..e0774fe
--- /dev/null
+++ b/Source/FusionDale/proxy/requestor/icoma_requestor.c
@@ -0,0 +1,272 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <fusiondale.h>
+
+#include <direct/debug.h>
+#include <direct/interface.h>
+#include <direct/messages.h>
+
+#include <voodoo/client.h>
+#include <voodoo/interface.h>
+#include <voodoo/manager.h>
+#include <voodoo/message.h>
+
+#include <icoma_dispatcher.h>
+
+#include "icoma_requestor.h"
+
+
+static DirectResult Probe( void );
+static DirectResult Construct( IComa *thiz,
+ VoodooManager *manager,
+ VoodooInstanceID instance,
+ void *arg );
+
+#include <direct/interface_implementation.h>
+
+DIRECT_INTERFACE_IMPLEMENTATION( IComa, Requestor )
+
+
+/**************************************************************************************************/
+
+static void tlshm_destroy( void *arg );
+
+/**********************************************************************************************************************/
+
+
+static void
+IComa_Requestor_Destruct( IComa *thiz )
+{
+ IComa_Requestor_data *data = thiz->priv;
+
+ D_DEBUG( "%s (%p)\n", __FUNCTION__, thiz );
+
+ voodoo_manager_request( data->manager, data->instance,
+ ICOMA_METHOD_ID_Release, VREQ_NONE, NULL,
+ VMBT_NONE );
+
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+IComa_Requestor_AddRef( IComa *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IComa_Requestor)
+
+ data->ref++;
+
+ return DR_OK;
+}
+
+static DirectResult
+IComa_Requestor_Release( IComa *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IComa_Requestor)
+
+ if (--data->ref == 0)
+ IComa_Requestor_Destruct( thiz );
+
+ return DR_OK;
+}
+
+static DirectResult
+IComa_Requestor_CreateComponent( IComa *thiz,
+ const char *name,
+ ComaMethodFunc func,
+ int num_notifications,
+ void *ctx,
+ IComaComponent **ret_interface )
+{
+ D_UNIMPLEMENTED();
+
+ return DR_UNIMPLEMENTED;
+}
+
+static DirectResult
+IComa_Requestor_GetComponent( IComa *thiz,
+ const char *name,
+ unsigned int timeout,
+ IComaComponent **ret_component )
+{
+ DirectResult ret;
+ VoodooResponseMessage *response;
+ void *interface = NULL;
+
+ DIRECT_INTERFACE_GET_DATA(IComa_Requestor)
+
+ ret = voodoo_manager_request( data->manager, data->instance,
+ ICOMA_METHOD_ID_GetComponent, VREQ_RESPOND, &response,
+ VMBT_STRING, name,
+ VMBT_UINT, timeout,
+ VMBT_NONE );
+ if (ret)
+ return ret;
+
+ ret = response->result;
+ if (ret == DR_OK)
+ ret = voodoo_construct_requestor( data->manager, "IComaComponent",
+ response->instance, thiz, &interface );
+
+ voodoo_manager_finish_request( data->manager, response );
+
+ *ret_component = interface;
+
+ return ret;
+}
+
+static DirectResult
+IComa_Requestor_Allocate( IComa *thiz,
+ unsigned int bytes,
+ void **ret_ptr )
+{
+ D_UNIMPLEMENTED();
+
+ return DR_UNIMPLEMENTED;
+}
+
+static DirectResult
+IComa_Requestor_Deallocate( IComa *thiz,
+ void *ptr )
+{
+ D_UNIMPLEMENTED();
+
+ return DR_UNIMPLEMENTED;
+}
+
+static DirectResult
+IComa_Requestor_GetLocal( IComa *thiz,
+ unsigned int length,
+ void **ret_ptr )
+{
+ ComaTLS *coma_tls;
+
+ DIRECT_INTERFACE_GET_DATA(IComa_Requestor)
+
+ coma_tls = pthread_getspecific( data->tlshm_key );
+ if (!coma_tls) {
+ coma_tls = D_CALLOC( 1, sizeof(ComaTLS) );
+ if (!coma_tls)
+ return D_OOM();
+
+ pthread_setspecific( data->tlshm_key, coma_tls );
+ }
+
+ if (coma_tls->capacity < length) {
+ if (coma_tls->local)
+ D_FREE( coma_tls->local );
+
+ coma_tls->local = D_MALLOC( length );
+ coma_tls->capacity = length;
+ }
+
+ coma_tls->length = length;
+
+ *ret_ptr = coma_tls->local;
+
+ return DR_OK;
+}
+
+static DirectResult
+IComa_Requestor_FreeLocal( IComa *thiz )
+{
+ ComaTLS *coma_tls;
+
+ DIRECT_INTERFACE_GET_DATA(IComa_Requestor)
+
+ coma_tls = pthread_getspecific( data->tlshm_key );
+ if (!coma_tls)
+ return DR_BUG;
+
+ if (coma_tls->local)
+ D_FREE( coma_tls->local );
+
+ coma_tls->local = NULL;
+ coma_tls->capacity = 0;
+ coma_tls->length = 0;
+
+ return DR_OK;
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+Probe( void )
+{
+ /* This implementation has to be loaded explicitly. */
+ return DR_UNSUPPORTED;
+}
+
+/*
+ * Constructor
+ *
+ * Fills in function pointers and intializes data structure.
+ */
+static DirectResult
+Construct( IComa *thiz,
+ VoodooManager *manager,
+ VoodooInstanceID instance,
+ void *arg )
+{
+ DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IComa_Requestor)
+
+ data->ref = 1;
+ data->manager = manager;
+ data->instance = instance;
+
+ pthread_key_create( &data->tlshm_key, tlshm_destroy );
+
+ thiz->AddRef = IComa_Requestor_AddRef;
+ thiz->Release = IComa_Requestor_Release;
+ thiz->CreateComponent = IComa_Requestor_CreateComponent;
+ thiz->GetComponent = IComa_Requestor_GetComponent;
+ thiz->Allocate = IComa_Requestor_Allocate;
+ thiz->Deallocate = IComa_Requestor_Deallocate;
+ thiz->GetLocal = IComa_Requestor_GetLocal;
+ thiz->FreeLocal = IComa_Requestor_FreeLocal;
+
+ return DR_OK;
+}
+
+/**********************************************************************************************************************/
+
+static void
+tlshm_destroy( void *arg )
+{
+ ComaTLS *coma_tls = arg;
+
+ if (coma_tls->local)
+ D_FREE( coma_tls->local );
+
+ D_FREE( coma_tls );
+}
+
diff --git a/Source/FusionDale/proxy/requestor/icoma_requestor.h b/Source/FusionDale/proxy/requestor/icoma_requestor.h
new file mode 100755
index 0000000..c2e94c5
--- /dev/null
+++ b/Source/FusionDale/proxy/requestor/icoma_requestor.h
@@ -0,0 +1,58 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __ICOMA_REQUESTOR_H__
+#define __ICOMA_REQUESTOR_H__
+
+#include <voodoo/types.h>
+
+#include <pthread.h>
+
+/*
+ * private data struct of IComa_Requestor
+ */
+typedef struct {
+ int ref; /* reference counter */
+
+ VoodooClient *client;
+ VoodooManager *manager;
+
+ VoodooInstanceID instance;
+
+ pthread_key_t tlshm_key;
+} IComa_Requestor_data;
+
+
+typedef struct {
+ void *local;
+ unsigned int capacity;
+ unsigned int length;
+} ComaTLS;
+
+#endif
+
diff --git a/Source/FusionDale/proxy/requestor/icomacomponent_requestor.c b/Source/FusionDale/proxy/requestor/icomacomponent_requestor.c
new file mode 100755
index 0000000..14b43bd
--- /dev/null
+++ b/Source/FusionDale/proxy/requestor/icomacomponent_requestor.c
@@ -0,0 +1,339 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <fusiondale.h>
+
+#include <direct/debug.h>
+#include <direct/hash.h>
+#include <direct/interface.h>
+#include <direct/messages.h>
+
+#include <voodoo/client.h>
+#include <voodoo/interface.h>
+#include <voodoo/manager.h>
+#include <voodoo/message.h>
+
+#include <icomacomponent_dispatcher.h>
+
+#include "icoma_requestor.h"
+
+
+static DirectResult Probe( void );
+static DirectResult Construct( IComaComponent *thiz,
+ VoodooManager *manager,
+ VoodooInstanceID instance,
+ void *arg );
+
+#include <direct/interface_implementation.h>
+
+DIRECT_INTERFACE_IMPLEMENTATION( IComaComponent, Requestor )
+
+
+/**************************************************************************************************/
+
+/*
+ * private data struct of IComaComponent_Requestor
+ */
+typedef struct {
+ int ref; /* reference counter */
+
+ VoodooClient *client;
+ VoodooManager *manager;
+
+ VoodooInstanceID instance;
+
+ IComa *coma;
+
+ DirectHash *listeners;
+} IComaComponent_Requestor_data;
+
+/**************************************************************************************************/
+
+static void
+IComaComponent_Requestor_Destruct( IComaComponent *thiz )
+{
+ IComaComponent_Requestor_data *data = thiz->priv;
+
+ D_DEBUG( "%s (%p)\n", __FUNCTION__, thiz );
+
+ voodoo_manager_request( data->manager, data->instance,
+ ICOMACOMPONENT_METHOD_ID_Release, VREQ_NONE, NULL,
+ VMBT_NONE );
+
+ direct_hash_destroy( data->listeners );
+
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+IComaComponent_Requestor_AddRef( IComaComponent *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IComaComponent_Requestor)
+
+ data->ref++;
+
+ return DR_OK;
+}
+
+static DirectResult
+IComaComponent_Requestor_Release( IComaComponent *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IComaComponent_Requestor)
+
+ if (--data->ref == 0)
+ IComaComponent_Requestor_Destruct( thiz );
+
+ return DR_OK;
+}
+
+static DirectResult
+IComaComponent_Requestor_Call( IComaComponent *thiz,
+ ComaMethodID method,
+ void *arg,
+ int *ret_val )
+{
+ DirectResult ret;
+ VoodooResponseMessage *response;
+ unsigned int length;
+ IComa_Requestor_data *coma_data;
+
+ DIRECT_INTERFACE_GET_DATA(IComaComponent_Requestor)
+
+ DIRECT_INTERFACE_GET_DATA_FROM( data->coma, coma_data, IComa_Requestor );
+
+ if (arg) {
+ ComaTLS *coma_tls;
+
+ coma_tls = pthread_getspecific( coma_data->tlshm_key );
+ if (!coma_tls)
+ return DR_BUG;
+
+ if (coma_tls->local == arg) {
+ length = coma_tls->length;
+ }
+ else {
+ D_UNIMPLEMENTED();
+
+ // add code for memory from IComa::Allocate
+
+ return DR_UNIMPLEMENTED;
+ }
+ }
+ else {
+ length = 0;
+ }
+
+ ret = voodoo_manager_request( data->manager, data->instance,
+ ICOMACOMPONENT_METHOD_ID_Call, VREQ_RESPOND, &response,
+ VMBT_UINT, method,
+ VMBT_UINT, length,
+ VMBT_ODATA, length, arg,
+ VMBT_NONE );
+ if (ret)
+ return ret;
+
+ ret = response->result;
+ if (ret == DR_OK) {
+ VoodooMessageParser parser;
+ int val;
+
+ VOODOO_PARSER_BEGIN( parser, response );
+ if (arg)
+ VOODOO_PARSER_READ_DATA( parser, arg, length );
+ VOODOO_PARSER_GET_INT( parser, val );
+ VOODOO_PARSER_END( parser );
+
+ if (ret_val)
+ *ret_val = val;
+ }
+
+ voodoo_manager_finish_request( data->manager, response );
+
+ return ret;
+}
+
+/**********************************************************************************************************************/
+
+typedef struct {
+ ComaListenerFunc func;
+ void *ctx;
+
+ VoodooInstanceID instance;
+} Listener_Dispatcher;
+
+static DirectResult
+Listener_Dispatch( void *ctx,
+ void *real,
+ VoodooManager *manager,
+ VoodooRequestMessage *msg )
+{
+ Listener_Dispatcher *dispatcher = ctx;
+ const void *arg;
+ VoodooMessageParser parser;
+
+ VOODOO_PARSER_BEGIN( parser, msg );
+ VOODOO_PARSER_GET_DATA( parser, arg );
+ VOODOO_PARSER_END( parser );
+
+ dispatcher->func( dispatcher->ctx, (void*) arg );
+
+ return DR_OK;
+}
+
+static DirectResult
+IComaComponent_Requestor_Listen( IComaComponent *thiz,
+ ComaNotificationID notification,
+ ComaListenerFunc func,
+ void *ctx )
+{
+ DirectResult ret;
+ VoodooResponseMessage *response;
+ Listener_Dispatcher *dispatcher;
+
+ DIRECT_INTERFACE_GET_DATA(IComaComponent_Requestor)
+
+ dispatcher = D_CALLOC( 1, sizeof(Listener_Dispatcher) );
+ if (!dispatcher)
+ return D_OOM();
+
+ dispatcher->func = func;
+ dispatcher->ctx = ctx;
+
+ ret = voodoo_manager_register_local( data->manager, false, dispatcher, dispatcher,
+ Listener_Dispatch, &dispatcher->instance );
+ if (ret)
+ goto error;
+
+
+ ret = voodoo_manager_request( data->manager, data->instance,
+ ICOMACOMPONENT_METHOD_ID_Listen, VREQ_RESPOND, &response,
+ VMBT_UINT, notification,
+ VMBT_ID, dispatcher->instance,
+ VMBT_NONE );
+ if (ret)
+ goto error;
+
+ ret = response->result;
+
+ voodoo_manager_finish_request( data->manager, response );
+
+ if (ret)
+ goto error;
+
+ direct_hash_insert( data->listeners, notification, dispatcher );
+
+ return DR_OK;
+
+
+error:
+ if (dispatcher->instance)
+ voodoo_manager_unregister_local( data->manager, dispatcher->instance );
+
+ D_FREE( dispatcher );
+
+ return ret;
+}
+
+/**********************************************************************************************************************/
+
+static DirectResult
+IComaComponent_Requestor_Unlisten( IComaComponent *thiz,
+ ComaNotificationID notification )
+{
+ DirectResult ret;
+ VoodooResponseMessage *response;
+ Listener_Dispatcher *dispatcher;
+
+ DIRECT_INTERFACE_GET_DATA(IComaComponent_Requestor)
+
+ dispatcher = direct_hash_lookup( data->listeners, notification );
+ if (!dispatcher)
+ return DR_IDNOTFOUND;
+
+
+ ret = voodoo_manager_request( data->manager, data->instance,
+ ICOMACOMPONENT_METHOD_ID_Unlisten, VREQ_RESPOND, &response,
+ VMBT_UINT, notification,
+ VMBT_NONE );
+ if (ret)
+ return ret;
+
+ voodoo_manager_finish_request( data->manager, response );
+
+
+ voodoo_manager_unregister_local( data->manager, dispatcher->instance );
+
+ direct_hash_remove( data->listeners, notification );
+
+ D_FREE( dispatcher );
+
+ return ret;
+}
+
+/**********************************************************************************************************************/
+
+static DirectResult
+Probe( void )
+{
+ /* This implementation has to be loaded explicitly. */
+ return DR_UNSUPPORTED;
+}
+
+/*
+ * Constructor
+ *
+ * Fills in function pointers and intializes data structure.
+ */
+static DirectResult
+Construct( IComaComponent *thiz,
+ VoodooManager *manager,
+ VoodooInstanceID instance,
+ void *arg )
+{
+ DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IComaComponent_Requestor)
+
+ data->ref = 1;
+ data->manager = manager;
+ data->instance = instance;
+ data->coma = arg;
+
+ direct_hash_create( 23, &data->listeners );
+
+ thiz->AddRef = IComaComponent_Requestor_AddRef;
+ thiz->Release = IComaComponent_Requestor_Release;
+ thiz->Call = IComaComponent_Requestor_Call;
+ thiz->Listen = IComaComponent_Requestor_Listen;
+ thiz->Unlisten = IComaComponent_Requestor_Unlisten;
+
+ return DR_OK;
+}
+
diff --git a/Source/FusionDale/proxy/requestor/ifusiondale_requestor.c b/Source/FusionDale/proxy/requestor/ifusiondale_requestor.c
new file mode 100755
index 0000000..cb101d2
--- /dev/null
+++ b/Source/FusionDale/proxy/requestor/ifusiondale_requestor.c
@@ -0,0 +1,182 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <fusiondale.h>
+
+#include <direct/debug.h>
+#include <direct/interface.h>
+#include <direct/messages.h>
+
+#include <ifusiondale.h>
+
+#include <voodoo/client.h>
+#include <voodoo/interface.h>
+#include <voodoo/manager.h>
+#include <voodoo/message.h>
+
+#include <ifusiondale_dispatcher.h>
+
+
+static DirectResult Probe( void );
+static DirectResult Construct( IFusionDale *thiz, const char *host, int session );
+
+#include <direct/interface_implementation.h>
+
+DIRECT_INTERFACE_IMPLEMENTATION( IFusionDale, Requestor )
+
+
+/**************************************************************************************************/
+
+/*
+ * private data struct of IFusionDale_Requestor
+ */
+typedef struct {
+ int ref; /* reference counter */
+
+ VoodooClient *client;
+ VoodooManager *manager;
+
+ VoodooInstanceID instance;
+} IFusionDale_Requestor_data;
+
+/**************************************************************************************************/
+
+static void
+IFusionDale_Requestor_Destruct( IFusionDale *thiz )
+{
+ IFusionDale_Requestor_data *data = thiz->priv;
+
+ D_DEBUG( "%s (%p)\n", __FUNCTION__, thiz );
+
+ voodoo_manager_request( data->manager, data->instance,
+ IFUSIONDALE_METHOD_ID_Release, VREQ_NONE, NULL,
+ VMBT_NONE );
+
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+IFusionDale_Requestor_AddRef( IFusionDale *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IFusionDale_Requestor)
+
+ data->ref++;
+
+ return DR_OK;
+}
+
+static DirectResult
+IFusionDale_Requestor_Release( IFusionDale *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IFusionDale_Requestor)
+
+ if (--data->ref == 0)
+ IFusionDale_Requestor_Destruct( thiz );
+
+ return DR_OK;
+}
+
+static DirectResult
+IFusionDale_Requestor_EnterComa( IFusionDale *thiz,
+ const char *name,
+ IComa **ret_coma )
+{
+ DirectResult ret;
+ VoodooResponseMessage *response;
+ void *interface = NULL;
+
+ DIRECT_INTERFACE_GET_DATA(IFusionDale_Requestor)
+
+ ret = voodoo_manager_request( data->manager, data->instance,
+ IFUSIONDALE_METHOD_ID_EnterComa, VREQ_RESPOND, &response,
+ VMBT_STRING, name,
+ VMBT_NONE );
+ if (ret)
+ return ret;
+
+ ret = response->result;
+ if (ret == DR_OK)
+ ret = voodoo_construct_requestor( data->manager, "IComa",
+ response->instance, NULL, &interface );
+
+ voodoo_manager_finish_request( data->manager, response );
+
+ *ret_coma = interface;
+
+ return ret;
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+Probe( void )
+{
+ /* This implementation has to be loaded explicitly. */
+ return DR_UNSUPPORTED;
+}
+
+/*
+ * Constructor
+ *
+ * Fills in function pointers and intializes data structure.
+ */
+static DirectResult
+Construct( IFusionDale *thiz, const char *host, int session )
+{
+ DirectResult ret;
+
+ DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IFusionDale_Requestor)
+
+ data->ref = 1;
+
+ ret = voodoo_client_create( host, session, &data->client );
+ if (ret) {
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+ return ret;
+ }
+
+ data->manager = voodoo_client_manager( data->client );
+
+ ret = voodoo_manager_super( data->manager, "IFusionDale", &data->instance );
+ if (ret) {
+ voodoo_client_destroy( data->client );
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+ return ret;
+ }
+
+ thiz->AddRef = IFusionDale_Requestor_AddRef;
+ thiz->Release = IFusionDale_Requestor_Release;
+ thiz->EnterComa = IFusionDale_Requestor_EnterComa;
+
+ return DR_OK;
+}
+