summaryrefslogtreecommitdiff
path: root/Source/FusionDale/proxy
diff options
context:
space:
mode:
Diffstat (limited to 'Source/FusionDale/proxy')
-rwxr-xr-xSource/FusionDale/proxy/Makefile.am3
-rwxr-xr-xSource/FusionDale/proxy/dispatcher/Makefile.am34
-rwxr-xr-xSource/FusionDale/proxy/dispatcher/icoma_dispatcher.c224
-rwxr-xr-xSource/FusionDale/proxy/dispatcher/icoma_dispatcher.h38
-rwxr-xr-xSource/FusionDale/proxy/dispatcher/icomacomponent_dispatcher.c376
-rwxr-xr-xSource/FusionDale/proxy/dispatcher/icomacomponent_dispatcher.h45
-rwxr-xr-xSource/FusionDale/proxy/dispatcher/ifusiondale_dispatcher.c223
-rwxr-xr-xSource/FusionDale/proxy/dispatcher/ifusiondale_dispatcher.h41
-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
13 files changed, 1869 insertions, 0 deletions
diff --git a/Source/FusionDale/proxy/Makefile.am b/Source/FusionDale/proxy/Makefile.am
new file mode 100755
index 0000000..d9fa9ce
--- /dev/null
+++ b/Source/FusionDale/proxy/Makefile.am
@@ -0,0 +1,3 @@
+## Makefile.am for FusionDale/proxy
+
+SUBDIRS = dispatcher requestor
diff --git a/Source/FusionDale/proxy/dispatcher/Makefile.am b/Source/FusionDale/proxy/dispatcher/Makefile.am
new file mode 100755
index 0000000..bad6a09
--- /dev/null
+++ b/Source/FusionDale/proxy/dispatcher/Makefile.am
@@ -0,0 +1,34 @@
+## Makefile.am for FusionDale/proxy/dispatcher
+
+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/requestor \
+ $(DIRECTFB_INTERNAL_CFLAGS) \
+ -DDATADIR=\"${RUNTIME_SYSROOT}@DATADIR@\"
+
+LIBS = \
+ $(top_builddir)/lib/libfusiondale.la \
+ -lvoodoo \
+ $(DIRECTFB_LIBS)
+
+
+ifusiondale_LTLIBRARIES = \
+ libifusiondale_dispatcher.la
+
+if BUILD_STATIC
+ifusiondale_DATA = libifusiondale_dispatcher.o
+endif
+
+libifusiondale_dispatcher_la_SOURCES = ifusiondale_dispatcher.c ifusiondale_dispatcher.h
+libifusiondale_dispatcher_la_LDFLAGS = -avoid-version -module
+libifusiondale_dispatcher_la_LIBADDD = $(LIBS)
+
+
+include $(top_srcdir)/rules/libobject.make
diff --git a/Source/FusionDale/proxy/dispatcher/icoma_dispatcher.c b/Source/FusionDale/proxy/dispatcher/icoma_dispatcher.c
new file mode 100755
index 0000000..4c7f8d4
--- /dev/null
+++ b/Source/FusionDale/proxy/dispatcher/icoma_dispatcher.c
@@ -0,0 +1,224 @@
+/*
+ (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/interface.h>
+#include <voodoo/manager.h>
+#include <voodoo/message.h>
+
+#include <coma/coma.h>
+#include <coma/policy.h>
+
+#include <coma/icoma.h>
+
+#include "icoma_dispatcher.h"
+
+static DirectResult Probe( void );
+static DirectResult Construct( IComa *thiz,
+ IComa *real,
+ VoodooManager *manager,
+ VoodooInstanceID super,
+ void *arg, /* Optional arguments to constructor */
+ VoodooInstanceID *ret_instance );
+
+#include <direct/interface_implementation.h>
+
+DIRECT_INTERFACE_IMPLEMENTATION( IComa, Dispatcher )
+
+
+/**************************************************************************************************/
+
+/*
+ * private data struct of IComa_Dispatcher
+ */
+typedef struct {
+ int ref; /* reference counter */
+
+ IComa *real;
+
+ VoodooInstanceID super;
+ VoodooInstanceID self;
+
+ VoodooManager *manager;
+
+ char *name;
+} IComa_Dispatcher_data;
+
+/**************************************************************************************************/
+
+static void
+IComa_Dispatcher_Destruct( IComa *thiz )
+{
+ IComa_Dispatcher_data *data;
+
+ D_DEBUG( "%s (%p)\n", __FUNCTION__, thiz );
+
+ data = thiz->priv;
+
+ D_FREE( data->name );
+
+ voodoo_manager_unregister_local( data->manager, data->self );
+
+ data->real->Release( data->real );
+
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+IComa_Dispatcher_AddRef( IComa *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IComa_Dispatcher)
+
+ data->ref++;
+
+ return DR_OK;
+}
+
+static DirectResult
+IComa_Dispatcher_Release( IComa *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IComa_Dispatcher)
+
+ if (--data->ref == 0)
+ IComa_Dispatcher_Destruct( thiz );
+
+ return DR_OK;
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+Dispatch_GetComponent( IComa *thiz, IComa *real,
+ VoodooManager *manager, VoodooRequestMessage *msg )
+{
+ DirectResult ret;
+ const char *name;
+ unsigned int timeout;
+ VoodooMessageParser parser;
+ IComaComponent *component;
+ VoodooInstanceID instance;
+
+ DIRECT_INTERFACE_GET_DATA(IComa_Dispatcher)
+
+ VOODOO_PARSER_BEGIN( parser, msg );
+ VOODOO_PARSER_GET_STRING( parser, name );
+ VOODOO_PARSER_GET_UINT( parser, timeout );
+ VOODOO_PARSER_END( parser );
+
+ if (!coma_policy_check_component( data->name, name ))
+ return DR_ACCESSDENIED;
+
+ ret = real->GetComponent( real, name, timeout, &component );
+ if (ret)
+ return ret;
+
+ ret = voodoo_construct_dispatcher( manager, "IComaComponent",
+ component, data->self, real, &instance, NULL );
+ if (ret) {
+ component->Release( component );
+ return ret;
+ }
+
+ return voodoo_manager_respond( manager, true, msg->header.serial,
+ DR_OK, instance,
+ VMBT_NONE );
+}
+
+static DirectResult
+Dispatch( void *dispatcher, void *real, VoodooManager *manager, VoodooRequestMessage *msg )
+{
+ D_DEBUG( "IComa/Dispatcher: "
+ "Handling request for instance %u with method %u...\n", msg->instance, msg->method );
+
+ switch (msg->method) {
+ case ICOMA_METHOD_ID_GetComponent:
+ return Dispatch_GetComponent( dispatcher, real, manager, msg );
+ }
+
+ return DR_NOSUCHMETHOD;
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+Probe()
+{
+ /* This implementation has to be loaded explicitly. */
+ return DR_UNSUPPORTED;
+}
+
+/*
+ * Constructor
+ *
+ * Fills in function pointers and intializes data structure.
+ */
+static DirectResult
+Construct( IComa *thiz,
+ IComa *real,
+ VoodooManager *manager,
+ VoodooInstanceID super,
+ void *arg, /* Optional arguments to constructor */
+ VoodooInstanceID *ret_instance )
+{
+ DirectResult ret;
+ VoodooInstanceID instance;
+
+ DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IComa_Dispatcher)
+
+ ret = voodoo_manager_register_local( manager, false, thiz, real, Dispatch, &instance );
+ if (ret) {
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+ return ret;
+ }
+
+ IComa_data *real_data = real->priv;
+
+ data->ref = 1;
+ data->real = real;
+ data->super = super;
+ data->self = instance;
+ data->manager = manager;
+ data->name = D_STRDUP( real_data->coma->name );
+
+ thiz->AddRef = IComa_Dispatcher_AddRef;
+ thiz->Release = IComa_Dispatcher_Release;
+
+ *ret_instance = instance;
+
+ return DR_OK;
+}
+
diff --git a/Source/FusionDale/proxy/dispatcher/icoma_dispatcher.h b/Source/FusionDale/proxy/dispatcher/icoma_dispatcher.h
new file mode 100755
index 0000000..998c68e
--- /dev/null
+++ b/Source/FusionDale/proxy/dispatcher/icoma_dispatcher.h
@@ -0,0 +1,38 @@
+/*
+ (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_DISPATCHER_H__
+#define __ICOMA_DISPATCHER_H__
+
+#define ICOMA_METHOD_ID_AddRef 1
+#define ICOMA_METHOD_ID_Release 2
+#define ICOMA_METHOD_ID_CreateComponent 3
+#define ICOMA_METHOD_ID_GetComponent 4
+
+#endif
+
diff --git a/Source/FusionDale/proxy/dispatcher/icomacomponent_dispatcher.c b/Source/FusionDale/proxy/dispatcher/icomacomponent_dispatcher.c
new file mode 100755
index 0000000..23637dd
--- /dev/null
+++ b/Source/FusionDale/proxy/dispatcher/icomacomponent_dispatcher.c
@@ -0,0 +1,376 @@
+/*
+ (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/interface.h>
+#include <voodoo/manager.h>
+#include <voodoo/message.h>
+
+#include <coma/coma.h>
+#include <coma/component.h>
+#include <coma/policy.h>
+
+#include <coma/icoma.h>
+#include <coma/icomacomponent.h>
+
+#include "icomacomponent_dispatcher.h"
+
+static DirectResult Probe( void );
+static DirectResult Construct( IComaComponent *thiz,
+ IComaComponent *real,
+ VoodooManager *manager,
+ VoodooInstanceID super,
+ void *arg, /* Optional arguments to constructor */
+ VoodooInstanceID *ret_instance );
+
+#include <direct/interface_implementation.h>
+
+DIRECT_INTERFACE_IMPLEMENTATION( IComaComponent, Dispatcher )
+
+
+/**************************************************************************************************/
+
+/*
+ * private data struct of IComaComponent_Dispatcher
+ */
+typedef struct {
+ int ref; /* reference counter */
+
+ IComaComponent *real;
+
+ VoodooInstanceID super;
+ VoodooInstanceID self;
+
+ VoodooManager *manager;
+
+ IComa *coma;
+
+ DirectHash *listeners;
+
+ char *coma_name;
+ char *component_name;
+} IComaComponent_Dispatcher_data;
+
+/**************************************************************************************************/
+
+static void
+IComaComponent_Dispatcher_Destruct( IComaComponent *thiz )
+{
+ IComaComponent_Dispatcher_data *data;
+
+ D_DEBUG( "%s (%p)\n", __FUNCTION__, thiz );
+
+ data = thiz->priv;
+
+ D_FREE( data->component_name );
+ D_FREE( data->coma_name );
+
+ direct_hash_destroy( data->listeners );
+
+ voodoo_manager_unregister_local( data->manager, data->self );
+
+ data->real->Release( data->real );
+
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+IComaComponent_Dispatcher_AddRef( IComaComponent *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IComaComponent_Dispatcher)
+
+ data->ref++;
+
+ return DR_OK;
+}
+
+static DirectResult
+IComaComponent_Dispatcher_Release( IComaComponent *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IComaComponent_Dispatcher)
+
+ if (--data->ref == 0)
+ IComaComponent_Dispatcher_Destruct( thiz );
+
+ return DR_OK;
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+Dispatch_Call( IComaComponent *thiz, IComaComponent *real,
+ VoodooManager *manager, VoodooRequestMessage *msg )
+{
+ DirectResult ret;
+ ComaMethodID method;
+ unsigned int length;
+ void *arg;
+ int ret_val;
+ VoodooMessageParser parser;
+ IComa *coma;
+
+ DIRECT_INTERFACE_GET_DATA(IComaComponent_Dispatcher)
+
+ coma = data->coma;
+
+ VOODOO_PARSER_BEGIN( parser, msg );
+ VOODOO_PARSER_GET_UINT( parser, method );
+ VOODOO_PARSER_GET_UINT( parser, length );
+
+ if (!coma_policy_check_method( data->coma_name, data->component_name, method ))
+ return DR_ACCESSDENIED;
+
+ if (length) {
+ ret = coma->GetLocal( coma, length, &arg );
+ if (ret) {
+ VOODOO_PARSER_END( parser );
+ return ret;
+ }
+
+ VOODOO_PARSER_READ_DATA( parser, arg, length );
+ }
+ else
+ arg = NULL;
+
+ VOODOO_PARSER_END( parser );
+
+ ret = real->Call( real, method, arg, &ret_val );
+ if (ret)
+ return ret;
+
+ if (arg)
+ return voodoo_manager_respond( manager, true, msg->header.serial,
+ DR_OK, VOODOO_INSTANCE_NONE,
+ VMBT_DATA, length, arg,
+ VMBT_INT, ret_val,
+ VMBT_NONE );
+
+ return voodoo_manager_respond( manager, true, msg->header.serial,
+ DR_OK, VOODOO_INSTANCE_NONE,
+ VMBT_INT, ret_val,
+ VMBT_NONE );
+}
+
+/**********************************************************************************************************************/
+
+typedef struct {
+ VoodooManager *manager;
+ VoodooInstanceID instance;
+
+ IComa *coma;
+} Listener_Requestor;
+
+static void
+Listener_Request( void *ctx,
+ void *arg )
+{
+ DirectResult ret;
+ Listener_Requestor *requestor = ctx;
+ IComa_data *coma_data;
+ int size;
+
+ coma_data = (IComa_data *) requestor->coma->priv;
+
+ ret = coma_allocation_size( coma_data->coma, arg, &size );
+ if (ret) {
+ D_DERROR( ret, "IComaComponent_Dispatcher/Listener_Request: Could not lookup allocation size!\n" );
+ return;
+ }
+
+ ret = voodoo_manager_request( requestor->manager, requestor->instance, 0, VREQ_NONE, NULL,
+ VMBT_DATA, size, arg,
+ VMBT_NONE );
+ if (ret)
+ D_DERROR( ret, "IComaComponent_Dispatcher/Listener_Request: Request failed!\n" );
+}
+
+static DirectResult
+Dispatch_Listen( IComaComponent *thiz, IComaComponent *real,
+ VoodooManager *manager, VoodooRequestMessage *msg )
+{
+ DirectResult ret;
+ ComaNotificationID notification;
+ VoodooInstanceID instance;
+ VoodooMessageParser parser;
+ Listener_Requestor *requestor;
+
+ DIRECT_INTERFACE_GET_DATA(IComaComponent_Dispatcher)
+
+ VOODOO_PARSER_BEGIN( parser, msg );
+ VOODOO_PARSER_GET_UINT( parser, notification );
+ VOODOO_PARSER_GET_ID( parser, instance );
+ VOODOO_PARSER_END( parser );
+
+ if (!coma_policy_check_notification( data->coma_name, data->component_name, notification ))
+ return DR_ACCESSDENIED;
+
+ requestor = D_CALLOC( 1, sizeof(Listener_Requestor) );
+ if (!requestor)
+ return D_OOM();
+
+ requestor->manager = data->manager;
+ requestor->instance = instance;
+ requestor->coma = data->coma;
+
+ ret = real->Listen( real, notification, Listener_Request, requestor );
+ if (ret) {
+ D_FREE( requestor );
+ return ret;
+ }
+
+ direct_hash_insert( data->listeners, notification, requestor );
+
+ return voodoo_manager_respond( manager, true, msg->header.serial,
+ DR_OK, VOODOO_INSTANCE_NONE,
+ VMBT_NONE );
+}
+
+static DirectResult
+Dispatch_Unlisten( IComaComponent *thiz, IComaComponent *real,
+ VoodooManager *manager, VoodooRequestMessage *msg )
+{
+ DirectResult ret;
+ ComaNotificationID notification;
+ VoodooMessageParser parser;
+ Listener_Requestor *requestor;
+
+ DIRECT_INTERFACE_GET_DATA(IComaComponent_Dispatcher)
+
+ VOODOO_PARSER_BEGIN( parser, msg );
+ VOODOO_PARSER_GET_UINT( parser, notification );
+ VOODOO_PARSER_END( parser );
+
+ requestor = direct_hash_lookup( data->listeners, notification );
+ if (!requestor)
+ return DR_IDNOTFOUND;
+
+ ret = real->Unlisten( real, notification );
+ if (ret) {
+ D_DERROR( ret, "IComaComponent_Dispatcher: Unlisten failed!\n" );
+ return ret;
+ }
+
+ direct_hash_remove( data->listeners, notification );
+
+ D_FREE( requestor );
+
+ return voodoo_manager_respond( manager, true, msg->header.serial,
+ DR_OK, VOODOO_INSTANCE_NONE,
+ VMBT_NONE );
+}
+
+/**********************************************************************************************************************/
+
+static DirectResult
+Dispatch( void *dispatcher, void *real, VoodooManager *manager, VoodooRequestMessage *msg )
+{
+ D_DEBUG( "IComaComponent/Dispatcher: "
+ "Handling request for instance %u with method %u...\n", msg->instance, msg->method );
+
+ switch (msg->method) {
+ case ICOMACOMPONENT_METHOD_ID_Call:
+ return Dispatch_Call( dispatcher, real, manager, msg );
+
+ case ICOMACOMPONENT_METHOD_ID_Listen:
+ return Dispatch_Listen( dispatcher, real, manager, msg );
+
+ case ICOMACOMPONENT_METHOD_ID_Unlisten:
+ return Dispatch_Unlisten( dispatcher, real, manager, msg );
+ }
+
+ return DR_NOSUCHMETHOD;
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+Probe()
+{
+ /* This implementation has to be loaded explicitly. */
+ return DR_UNSUPPORTED;
+}
+
+/*
+ * Constructor
+ *
+ * Fills in function pointers and intializes data structure.
+ */
+static DirectResult
+Construct( IComaComponent *thiz,
+ IComaComponent *real,
+ VoodooManager *manager,
+ VoodooInstanceID super,
+ void *arg, /* Optional arguments to constructor */
+ VoodooInstanceID *ret_instance )
+{
+ DirectResult ret;
+ VoodooInstanceID instance;
+
+ DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IComaComponent_Dispatcher)
+
+ ret = voodoo_manager_register_local( manager, false, thiz, real, Dispatch, &instance );
+ if (ret) {
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+ return ret;
+ }
+
+ IComaComponent_data *real_data = real->priv;
+
+ data->ref = 1;
+ data->real = real;
+ data->super = super;
+ data->self = instance;
+ data->manager = manager;
+ data->coma = arg;
+
+ data->coma_name = D_STRDUP( real_data->coma->name );
+ data->component_name = D_STRDUP( real_data->component->name );
+
+ ret = direct_hash_create( 17, &data->listeners );
+ if (ret) {
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+ return ret;
+ }
+
+ thiz->AddRef = IComaComponent_Dispatcher_AddRef;
+ thiz->Release = IComaComponent_Dispatcher_Release;
+
+ *ret_instance = instance;
+
+ return DR_OK;
+}
+
diff --git a/Source/FusionDale/proxy/dispatcher/icomacomponent_dispatcher.h b/Source/FusionDale/proxy/dispatcher/icomacomponent_dispatcher.h
new file mode 100755
index 0000000..f37e64e
--- /dev/null
+++ b/Source/FusionDale/proxy/dispatcher/icomacomponent_dispatcher.h
@@ -0,0 +1,45 @@
+/*
+ (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 __ICOMACOMPONENT_DISPATCHER_H__
+#define __ICOMACOMPONENT_DISPATCHER_H__
+
+#define ICOMACOMPONENT_METHOD_ID_AddRef 1
+#define ICOMACOMPONENT_METHOD_ID_Release 2
+#define ICOMACOMPONENT_METHOD_ID_InitNotification 3
+#define ICOMACOMPONENT_METHOD_ID_InitNotifications 4
+#define ICOMACOMPONENT_METHOD_ID_Call 5
+#define ICOMACOMPONENT_METHOD_ID_Return 6
+#define ICOMACOMPONENT_METHOD_ID_Notify 7
+#define ICOMACOMPONENT_METHOD_ID_Listen 8
+#define ICOMACOMPONENT_METHOD_ID_InitListeners 9
+#define ICOMACOMPONENT_METHOD_ID_Unlisten 10
+#define ICOMACOMPONENT_METHOD_ID_Activate 11
+
+#endif
+
diff --git a/Source/FusionDale/proxy/dispatcher/ifusiondale_dispatcher.c b/Source/FusionDale/proxy/dispatcher/ifusiondale_dispatcher.c
new file mode 100755
index 0000000..cecd1a5
--- /dev/null
+++ b/Source/FusionDale/proxy/dispatcher/ifusiondale_dispatcher.c
@@ -0,0 +1,223 @@
+/*
+ (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 <coma/policy.h>
+
+#include <ifusiondale.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,
+ VoodooManager *manager,
+ VoodooInstanceID *ret_instance );
+
+#include <direct/interface_implementation.h>
+
+DIRECT_INTERFACE_IMPLEMENTATION( IFusionDale, Dispatcher )
+
+
+/**************************************************************************************************/
+
+/*
+ * private data struct of IFusionDale_Dispatcher
+ */
+typedef struct {
+ int ref; /* reference counter */
+
+ IFusionDale *real;
+
+ VoodooInstanceID self; /* The instance of this dispatcher itself. */
+
+ VoodooManager *manager;
+} IFusionDale_Dispatcher_data;
+
+/**************************************************************************************************/
+
+static void
+IFusionDale_Dispatcher_Destruct( IFusionDale *thiz )
+{
+ IFusionDale_Dispatcher_data *data;
+
+ D_DEBUG( "%s (%p)\n", __FUNCTION__, thiz );
+
+ data = thiz->priv;
+
+ voodoo_manager_unregister_local( data->manager, data->self );
+
+ data->real->Release( data->real );
+
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+IFusionDale_Dispatcher_AddRef( IFusionDale *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IFusionDale_Dispatcher)
+
+ data->ref++;
+
+ return DR_OK;
+}
+
+static DirectResult
+IFusionDale_Dispatcher_Release( IFusionDale *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IFusionDale_Dispatcher)
+
+ if (--data->ref == 0)
+ IFusionDale_Dispatcher_Destruct( thiz );
+
+ return DR_OK;
+}
+
+static DirectResult
+IFusionDale_Dispatcher_EnterComa( IFusionDale *thiz,
+ const char *name,
+ IComa **ret_coma )
+{
+ DIRECT_INTERFACE_GET_DATA(IFusionDale_Dispatcher)
+
+ return DR_UNIMPLEMENTED;
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+Dispatch_EnterComa( IFusionDale *thiz, IFusionDale *real,
+ VoodooManager *manager, VoodooRequestMessage *msg )
+{
+ DirectResult ret;
+ const char *name;
+ VoodooMessageParser parser;
+ IComa *coma;
+ VoodooInstanceID instance;
+
+ DIRECT_INTERFACE_GET_DATA(IFusionDale_Dispatcher)
+
+ VOODOO_PARSER_BEGIN( parser, msg );
+ VOODOO_PARSER_GET_STRING( parser, name );
+ VOODOO_PARSER_END( parser );
+
+ if (!coma_policy_check_manager( name ))
+ return DR_ACCESSDENIED;
+
+ ret = real->EnterComa( real, name, &coma );
+ if (ret)
+ return ret;
+
+ ret = voodoo_construct_dispatcher( manager, "IComa",
+ coma, data->self, NULL, &instance, NULL );
+ if (ret) {
+ coma->Release( coma );
+ return ret;
+ }
+
+ return voodoo_manager_respond( manager, true, msg->header.serial,
+ DR_OK, instance,
+ VMBT_NONE );
+}
+
+static DirectResult
+Dispatch( void *dispatcher, void *real, VoodooManager *manager, VoodooRequestMessage *msg )
+{
+ D_DEBUG( "IFusionDale/Dispatcher: "
+ "Handling request for instance %u with method %u...\n", msg->instance, msg->method );
+
+ switch (msg->method) {
+ case IFUSIONDALE_METHOD_ID_EnterComa:
+ return Dispatch_EnterComa( dispatcher, real, manager, msg );
+ }
+
+ return DR_NOSUCHMETHOD;
+}
+
+/**************************************************************************************************/
+
+static DirectResult
+Probe()
+{
+ /* This implementation has to be loaded explicitly. */
+ return DR_UNSUPPORTED;
+}
+
+/*
+ * Constructor
+ *
+ * Fills in function pointers and intializes data structure.
+ */
+static DirectResult
+Construct( IFusionDale *thiz, VoodooManager *manager, VoodooInstanceID *ret_instance )
+{
+ DirectResult ret;
+ IFusionDale *real;
+ VoodooInstanceID instance;
+
+ DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IFusionDale_Dispatcher)
+
+ ret = FusionDaleCreate( &real );
+ if (ret) {
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+ return ret;
+ }
+
+ ret = voodoo_manager_register_local( manager, VOODOO_INSTANCE_NONE, thiz, real, Dispatch, &instance );
+ if (ret) {
+ real->Release( real );
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+ return ret;
+ }
+
+ *ret_instance = instance;
+
+ data->ref = 1;
+ data->real = real;
+ data->self = instance;
+ data->manager = manager;
+
+ thiz->AddRef = IFusionDale_Dispatcher_AddRef;
+ thiz->Release = IFusionDale_Dispatcher_Release;
+ thiz->EnterComa = IFusionDale_Dispatcher_EnterComa;
+
+ return DR_OK;
+}
+
diff --git a/Source/FusionDale/proxy/dispatcher/ifusiondale_dispatcher.h b/Source/FusionDale/proxy/dispatcher/ifusiondale_dispatcher.h
new file mode 100755
index 0000000..9463f1a
--- /dev/null
+++ b/Source/FusionDale/proxy/dispatcher/ifusiondale_dispatcher.h
@@ -0,0 +1,41 @@
+/*
+ (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 __IFUSIONDALE_DISPATCHER_H__
+#define __IFUSIONDALE_DISPATCHER_H__
+
+#include <fusiondale.h>
+
+#define IFUSIONDALE_METHOD_ID_AddRef 1
+#define IFUSIONDALE_METHOD_ID_Release 2
+#define IFUSIONDALE_METHOD_ID_CreateMessenger 3
+#define IFUSIONDALE_METHOD_ID_GetMessenger 4
+#define IFUSIONDALE_METHOD_ID_EnterComa 5
+
+#endif
+
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;
+}
+