Commit fb95e9b2 authored by Eskil Heyn Olsen's avatar Eskil Heyn Olsen

More work on the initial services GTK+ object framework...

The Trilobite...
parent df6a8969
......@@ -28,12 +28,12 @@
#define TRILOBITE_SERVICE_PRIVATE_H
struct _TrilobiteServicePrivate {
char *name;
char *version;
char *vendor_name;
char *vendor_url;
char *url;
char *icon_uri;
char *service_name;
char *service_version;
char *service_vendor_name;
char *service_vendor_url;
char *service_url;
char *service_icon_uri;
};
......
......@@ -65,13 +65,14 @@ typedef struct _TrilobiteServicePrivate TrilobiteServicePrivate;
struct _TrilobiteService
{
POA_Trilobite_Service poa;
POA_Trilobite_Service service_poa;
Trilobite_Service corba_object;
GtkObject parent;
TrilobiteServicePrivate *private;
};
GtkType trilobite_service_get_type (void);
TrilobiteService* trilobite_service_new (void);
TrilobiteService* trilobite_service_new (char *oaf_id);
char* trilobite_service_get_name (TrilobiteService *trilobite);
char* trilobite_service_get_version (TrilobiteService *trilobite);
char* trilobite_service_get_vendor_name (TrilobiteService *trilobite);
......
......@@ -27,6 +27,8 @@
#include <config.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkmarshal.h>
#include <liboaf/liboaf.h>
#include "trilobite-service-public.h"
#include "trilobite-service-private.h"
......@@ -45,17 +47,49 @@ enum {
LAST_SIGNAL
};
/* The signal array */
/* The signal array and prototypes for default handlers*/
static guint trilobite_service_signals[LAST_SIGNAL] = { 0 };
char* trilobite_service_default_get_name(TrilobiteService *service);
/*****************************************
Corba stuff
*****************************************/
static CORBA_char*
impl_Trilobite_Service_get_name(TrilobiteService *trilobite,
CORBA_Environment *ev) {
char *result;
gtk_signal_emit (GTK_OBJECT (trilobite), trilobite_service_signals[GET_NAME], &result);
return CORBA_string_dup (result);
};
static void
impl_Trilobite_Service_done(TrilobiteService *trilobite,
CORBA_Environment *ev) {
gtk_signal_emit (GTK_OBJECT (trilobite), trilobite_service_signals[DONE]);
return;
};
POA_Trilobite_Service__epv Trilobite_Service_epv =
{
NULL, /* CORBA internals */
/* Put pointer to methods here */
NULL, /* CORBA internal */
(gpointer) &impl_Trilobite_Service_get_name,
(gpointer) &impl_Trilobite_Service_get_name,
(gpointer) &impl_Trilobite_Service_get_name,
(gpointer) &impl_Trilobite_Service_get_name,
(gpointer) &impl_Trilobite_Service_get_name,
(gpointer) &impl_Trilobite_Service_get_name,
/* (gpointer) &impl_Trilobite_Service_get_version,
(gpointer) &impl_Trilobite_Service_get_vendor_name,
(gpointer) &impl_Trilobite_Service_get_vendor_url,
(gpointer) &impl_Trilobite_Service_get_url,
(gpointer) &impl_Trilobite_Service_get_icon_uri,
*/
(gpointer) &impl_Trilobite_Service_done
};
static PortableServer_ServantBase__epv base_epv = { NULL, NULL, NULL };
......@@ -94,6 +128,10 @@ static void
trilobite_service_destroy (GtkObject *object)
{
TrilobiteService *trilobite;
PortableServer_ObjectId *objid;
CORBA_Environment ev;
PortableServer_POA poa;
void (*poa_servant_fini) (PortableServer_Servant servant, CORBA_Environment *ev);
g_return_if_fail (object != NULL);
g_return_if_fail (TRILOBITE_IS_SERVICE (object));
......@@ -103,6 +141,17 @@ trilobite_service_destroy (GtkObject *object)
if (TRILOBITE_SERVICE_CLASS (trilobite)->parent_class->destroy != NULL) {
TRILOBITE_SERVICE_CLASS (trilobite)->parent_class->destroy (object);
}
CORBA_exception_init(&ev);
poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references (oaf_orb_get (), "RootPOA", &ev);
poa_servant_fini = TRILOBITE_SERVICE_CLASS (GTK_OBJECT (trilobite)->klass)->poa_servant_fini;
objid = PortableServer_POA_servant_to_id (poa, trilobite, &ev);
PortableServer_POA_deactivate_object (poa, objid, &ev);
CORBA_free (objid);
poa_servant_fini ((PortableServer_Servant) trilobite, &ev);
g_free (trilobite);
CORBA_exception_free(&ev);
}
......@@ -133,14 +182,50 @@ trilobite_service_class_initialize (TrilobiteServiceClass *klass)
GTK_TYPE_POINTER,0);
gtk_object_class_add_signals (object_class, trilobite_service_signals,LAST_SIGNAL);
klass->get_name = trilobite_service_default_get_name;
};
static Trilobite_Service
trilobite_service_corba_initialization (TrilobiteService *trilobite)
{
Trilobite_Service result;
PortableServer_POA poa;
CORBA_Environment ev;
void (*poa_servant_init) (PortableServer_Servant servant, CORBA_Environment *ev);
g_assert (trilobite != NULL);
g_assert (TRILOBITE_IS_SERVICE (trilobite));
CORBA_exception_init(&ev);
poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references (oaf_orb_get (), "RootPOA", &ev);
poa_servant_init = TRILOBITE_SERVICE_CLASS (GTK_OBJECT(trilobite)->klass)->poa_servant_init;
poa_servant_init ((PortableServer_Servant)trilobite, &ev);
CORBA_free (PortableServer_POA_activate_object (poa, trilobite, &ev));
result = (Trilobite_Service)PortableServer_POA_servant_to_reference (poa, trilobite, &ev);
CORBA_exception_free (&ev);
return result;
}
static void
trilobite_service_initialize (TrilobiteService *trilobite)
{
g_return_if_fail (trilobite != NULL);
g_return_if_fail (TRILOBITE_IS_SERVICE (trilobite));
/* FIXME: bugzilla.eazel.com 854
how to initialize the values */
trilobite->private = g_new0 (TrilobiteServicePrivate,1);
trilobite->private->service_name = g_strdup ("Default");
trilobite->private->service_version = g_strdup ("0.1");
trilobite->private->service_vendor_name = g_strdup ("Dev Null");
trilobite->private->service_vendor_url = g_strdup ("http://www.dev.null");
trilobite->private->service_url = g_strdup ("http://www.dev.null");
trilobite->private->service_icon_uri = g_strdup ("file://dev/random");
trilobite->corba_object = trilobite_service_corba_initialization (trilobite);
}
/*
......@@ -182,11 +267,24 @@ trilobite_service_get_type (void)
or using _set_name(...) calls.
*/
TrilobiteService*
trilobite_service_new()
trilobite_service_new(char *oaf_id)
{
CORBA_Environment ev;
PortableServer_POA poa;
TrilobiteService *service;
service = TRILOBITE_SERVICE (gtk_object_new (TRILOBITE_TYPE_SERVICE, NULL));
CORBA_exception_init(&ev);
poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references (oaf_orb_get (), "RootPOA", &ev);
oaf_active_server_register (oaf_id, service->corba_object);
PortableServer_POAManager_activate (PortableServer_POA__get_the_POAManager (poa, &ev), &ev);
return service;
}
char*
trilobite_service_default_get_name(TrilobiteService *service)
{
return service->private->service_name;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment