mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-09 04:52:04 +03:00
Implement FileManagerFactory and FileManagerWindow interfaces for
CORBAization.
This commit is contained in:
parent
5e69e9af71
commit
4f7e1ccf31
202
gnome/gcorba.c
202
gnome/gcorba.c
@ -6,65 +6,179 @@
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <libgnorba/gnorba.h>
|
||||
#include <libgnorba/gnome-factory.h>
|
||||
#include "FileManager.h"
|
||||
#include "gcorba.h"
|
||||
|
||||
CORBA_ORB orb;
|
||||
PortaPortableServer_POA poa;
|
||||
CORBA_Object *name_server;
|
||||
CORBA_Environment ev;
|
||||
|
||||
/* The object we define: */
|
||||
typedef struct {
|
||||
POA_GNOME_FileManagerWindow servant;
|
||||
PortableServer_POA poa;
|
||||
|
||||
WPanel *mywin;
|
||||
} impl_POA_GNOME_FileManagerWindow;
|
||||
|
||||
typedef struct {
|
||||
POA_GNOME_FileManagerFactory servant;
|
||||
PortableServer_POA poa;
|
||||
} impl_POA_GNOME_FileManagerFactory;
|
||||
|
||||
impl_POA_GNOME_FileManagerFactory poa_filemanagerfactory_servant;
|
||||
GNOME_FileManagerFactory filemanagerfactory_server;
|
||||
|
||||
PortableServer_ServantBase__epv base_epv = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
/*** Implementation stub prototypes ***/
|
||||
|
||||
static void
|
||||
impl_GNOME_FileManagerWindow_close(impl_POA_GNOME_FileManagerWindow * servant,
|
||||
CORBA_Environment * ev);
|
||||
|
||||
GNOME_FileManagerWindow
|
||||
impl_GNOME_FileManagerFactory_create_window(impl_POA_GNOME_FileManagerFactory * servant,
|
||||
CORBA_char * dir,
|
||||
CORBA_Environment * ev);
|
||||
|
||||
CORBA_boolean
|
||||
impl_GNOME_FileManagerFactory_supports(impl_POA_GNOME_FileManagerFactory * servant,
|
||||
CORBA_char * obj_goad_id,
|
||||
CORBA_Environment * ev);
|
||||
CORBA_Object
|
||||
impl_GNOME_FileManagerFactory_create_object(impl_POA_GNOME_FileManagerFactory * servant,
|
||||
CORBA_char * goad_id,
|
||||
GNOME_stringlist * params,
|
||||
CORBA_Environment * ev);
|
||||
|
||||
/*** epv structures ***/
|
||||
|
||||
static PortableServer_ServantBase__epv impl_GNOME_FileManagerWindow_base_epv =
|
||||
{
|
||||
NULL, NULL, NULL
|
||||
};
|
||||
static POA_GNOME_FileManagerWindow__epv impl_GNOME_FileManagerWindow_epv =
|
||||
{
|
||||
NULL /* _private */
|
||||
(gpointer) & impl_GNOME_FileManagerWindow_close,
|
||||
};
|
||||
static PortableServer_ServantBase__epv impl_GNOME_FileManagerFactory_base_epv =
|
||||
{
|
||||
NULL, /* _private data */
|
||||
NULL,
|
||||
NULL /* default_POA routine */
|
||||
};
|
||||
static POA_GNOME_FileManagerFactory__epv impl_GNOME_FileManagerFactory_epv =
|
||||
{
|
||||
NULL, /* _private */
|
||||
(gpointer) & impl_GNOME_FileManagerFactory_create_window,
|
||||
};
|
||||
|
||||
/* GNOME::Factory implementation */
|
||||
static CORBA_Object
|
||||
FileManager_Factory_new (PortableServer_Servant servant, CORBA_Environment *ev)
|
||||
static POA_GNOME_GenericFactory__epv impl_GNOME_FileManagerFactory_GNOME_GenericFactory_epv =
|
||||
{
|
||||
NULL, /* _private */
|
||||
(gpointer) & impl_GNOME_FileManagerFactory_supports,
|
||||
(gpointer) & impl_GNOME_FileManagerFactory_create_object,
|
||||
};
|
||||
|
||||
/*** vepv structures ***/
|
||||
|
||||
static POA_GNOME_FileManagerWindow__vepv impl_GNOME_FileManagerWindow_vepv =
|
||||
{
|
||||
&impl_GNOME_FileManagerWindow_base_epv,
|
||||
&impl_GNOME_FileManagerWindow_epv,
|
||||
};
|
||||
static POA_GNOME_FileManagerFactory__vepv impl_GNOME_FileManagerFactory_vepv =
|
||||
{
|
||||
&impl_GNOME_FileManagerFactory_base_epv,
|
||||
&impl_GNOME_FileManagerFactory_GNOME_GenericFactory_epv,
|
||||
&impl_GNOME_FileManagerFactory_epv,
|
||||
};
|
||||
|
||||
/*** Stub implementations ***/
|
||||
|
||||
static void
|
||||
do_window_close(GtkWidget *widget, gpointer servant)
|
||||
{
|
||||
CORBA_Environment ev;
|
||||
CORBA_exception_init(&ev);
|
||||
PortableServer_ObjectId *objid;
|
||||
|
||||
objid = PortableServer_POA_servant_to_id(servant->poa, servant, ev);
|
||||
PortableServer_POA_deactivate_object(servant->poa, objid, ev);
|
||||
CORBA_free(objid);
|
||||
POA_GNOME_FileManagerWindow__fini((PortableServer_Servant) servant, ev);
|
||||
|
||||
g_free(servant);
|
||||
CORBA_exception_free(&ev);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static CORBA_Object
|
||||
FileManager_Factory_new_args (PortableServer_Servant servant,
|
||||
CORBA_char *argument,
|
||||
CORBA_Environment *ev)
|
||||
static void
|
||||
impl_GNOME_FileManagerWindow_close(impl_POA_GNOME_FileManagerWindow * servant, CORBA_Environment * ev)
|
||||
{
|
||||
return FileManager_Factory_new (servant, ev);
|
||||
gtk_widget_destroy(servant->mywin->xwindow);
|
||||
}
|
||||
|
||||
FileManager_Factory_new_args
|
||||
POA_GNOME_Factory__epv poa_gnome_factory__epv = {
|
||||
FileManager_Factory_new,
|
||||
FileManager_Factory_new_args
|
||||
|
||||
};
|
||||
GNOME_FileManagerWindow
|
||||
impl_GNOME_FileManagerFactory_create_window(impl_POA_GNOME_FileManagerFactory * servant,
|
||||
CORBA_char * dir,
|
||||
CORBA_Environment * ev)
|
||||
{
|
||||
GNOME_FileManagerWindow retval;
|
||||
impl_POA_GNOME_FileManagerWindow *newservant;
|
||||
PortableServer_ObjectId *objid;
|
||||
|
||||
POA_FileManager_Factory__vepv poa_filemanager_factory_vepv = {
|
||||
&base_epv,
|
||||
&poa_gnome_factory_epv,
|
||||
NULL /* POA_FileManager_Factory_epv */
|
||||
};
|
||||
newservant = g_new0(impl_POA_GNOME_FileManagerWindow, 1);
|
||||
newservant->servant.vepv = &impl_GNOME_FileManagerWindow_vepv;
|
||||
newservant->poa = poa;
|
||||
newservant->mywin = new_panel_at((dir && *dir)?dir:gnome_util_user_home());
|
||||
|
||||
POA_FileManager_Factory poa_filemanagerfactory_servant = {
|
||||
NULL,
|
||||
&poa_filemanager_factory_vepv,
|
||||
};
|
||||
gtk_signal_connect(GTK_OBJECT(newservant->mywin->xwindow),
|
||||
"destroy", impl_GNOME_FileManagerWindow_close,
|
||||
newservant);
|
||||
|
||||
#define FACTORY_ID "IDL:GNOME/FileManagerFactory:1.0"
|
||||
PortableServer_ObjectId factory_id = { 0, sizeof (FACTORY_ID), FACTORY_ID };
|
||||
POA_GNOME_FileManagerWindow__init((PortableServer_Servant) newservant, ev);
|
||||
objid = PortableServer_POA_activate_object(poa, newservant, ev);
|
||||
CORBA_free(objid);
|
||||
retval = PortableServer_POA_servant_to_reference(poa, newservant, ev);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
CORBA_boolean
|
||||
impl_GNOME_FileManagerFactory_supports(impl_POA_GNOME_FileManagerFactory * servant,
|
||||
CORBA_char * obj_goad_id,
|
||||
CORBA_Environment * ev)
|
||||
{
|
||||
return !strcmp(obj_goad_id, "gmc_filemanager_window");
|
||||
}
|
||||
|
||||
CORBA_Object
|
||||
impl_GNOME_FileManagerFactory_create_object(impl_POA_GNOME_FileManagerFactory * servant,
|
||||
CORBA_char * goad_id,
|
||||
GNOME_stringlist * params,
|
||||
CORBA_Environment * ev)
|
||||
{
|
||||
if(!strcmp(goad_id, "gmc_filemanager_window"))
|
||||
return impl_GNOME_FileManagerFactory_create_window(servant,
|
||||
params->_length?params->_buffer[0]:gnome_util_user_home(), ev);
|
||||
|
||||
CORBA_exception_set(ev, CORBA_USER_EXCEPTION,
|
||||
ex_GNOME_GenericFactory_CannotActivate,
|
||||
NULL);
|
||||
|
||||
return CORBA_OBJECT_NIL;
|
||||
}
|
||||
|
||||
void
|
||||
corba_register_server (void)
|
||||
{
|
||||
PortableServer_POAManager poa_manager;
|
||||
int v;
|
||||
CORBA_ORB orb;
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
|
||||
orb = gnome_CORBA_ORB();
|
||||
|
||||
poa = CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev);
|
||||
if (ev.major != CORBA_NO_EXCEPTION){
|
||||
printf ("Can not resolve initial reference to RootPOA");
|
||||
@ -93,30 +207,18 @@ corba_register_server (void)
|
||||
}
|
||||
|
||||
/* Activate the object */
|
||||
PortableServer_POA_activate_object_with_id (
|
||||
poa, &factory_id, &poa_filemanagerfactory_servant, &ev);
|
||||
CORBA_free(PortableServer_POA_activate_object(poa,
|
||||
&poa_filemanagerfactory_servant, &ev));
|
||||
|
||||
/* Get a refeerence to te object */
|
||||
filemanagerfactory_server = PortableServer_POA_servant_to_reference (
|
||||
poa, &poa_filemanagerfactory_servant, &ev);
|
||||
|
||||
/*
|
||||
* Register the FileManagerFactory with GOAD.
|
||||
*/
|
||||
name_server = gnome_name_service_get ();
|
||||
|
||||
|
||||
if (!name_server){
|
||||
printf ("Can not talk to the name server\n");
|
||||
return;
|
||||
}
|
||||
|
||||
v = goad_server_register (
|
||||
name_server, file_manager_factory,
|
||||
"FileManagerFactory", "FileManager:1.0", &ev);
|
||||
NULL, file_manager_factory,
|
||||
"gmc_FileManagerFactory", "server", &ev);
|
||||
|
||||
if (v != 0)
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,17 @@
|
||||
#include <factory.idl>
|
||||
#pragma inhibit push
|
||||
#include <gnome-factory.idl>
|
||||
#pragma inhibit pop
|
||||
|
||||
module FileManager {
|
||||
interface Factory : GNOME::Factory {};
|
||||
module GNOME {
|
||||
exception POSIX_ERROR { string errorstr; };
|
||||
|
||||
exception POSIX_ERROR {};
|
||||
interface FileManagerWindow {
|
||||
/* not much yet */
|
||||
oneway void close();
|
||||
};
|
||||
|
||||
interface Window {
|
||||
void chdir (in string dir)
|
||||
raises (POSIX_ERROR);
|
||||
};
|
||||
interface FileManagerFactory : GenericFactory {
|
||||
FileManagerWindow create_window(in string dir)
|
||||
raises (POSIX_ERROR);
|
||||
};
|
||||
};
|
||||
|
@ -145,6 +145,7 @@ typedef struct {
|
||||
|
||||
int dragging;
|
||||
#endif
|
||||
void *corbadat;
|
||||
} WPanel;
|
||||
|
||||
WPanel *panel_new (char *panel_name);
|
||||
|
Loading…
Reference in New Issue
Block a user