1
1
mc/gnome/gcorba.c
Miguel de Icaza b3bb157ad5 These are a bunch of changes to fix CORBA and session management. They
are almost complete (i.e. to handle all nitty gritty cases), but they
seem to be working OK right now.  SM should be much more stable now.
Please tell me if you find any weird behavior - Federico

1999-03-30  Federico Mena Quintero  <federico@nuclecu.unam.mx>

	* gdesktop-icon.c (desktop_icon_realize): Remove the
	WM_CLIENT_LEADER property from icon windows so that window
	managers will not store SM information for them.

	* gnome-open-dialog.c: Added missing #includes.

	* gdesktop-init.c (desktop_init_at): Removed an unused variable.

	* gdesktop.h: Added some missing prototypes.

	* gmain.h: Added some missing prototypes.

	* Makefile.in: Added gsession.[ch] to the list of sources.

	* gmain.c (create_panels): Consider whether we have a CORBA server
	and session management.

	* gdesktop.c: #include "gdesktop-init.h"
	* gdesktop.c: Added a missing cast to GNOME_DIALOG.

	* gmain.c (create_panels): Removed the run_desktop global
	variable.

	* glayout.c (create_container): Set the wmclass of the panel to
	include its unique ID.

	* gsession.[ch]: New file with the functions that deal with
	session management.

	* glayout.c (gnome_exit): Use session_set_restart().

	* gcorba.c (corba_init): Now returns an int with an error value.
	(corba_init_server): Initialize the server properly.
	Fixed all the object implementation code.
	(corba_create_window): New function used to create a window with
	the CORBA server.

	* gmain.c (gnome_check_super_user): Now the check for running as
	root is done here.  There should be no GUI code in src/.

1999-03-30  Federico Mena Quintero  <federico@nuclecu.unam.mx>

	* dlg.c (dlg_run_done): Do not call the callback of a NULL current
	widget.

	* setup.h: Added missing prototype for setup_init().

	* filegui.c (check_progress_buttons): Added a missing return
	value.

	* dlg.c (remove_widget): Added a missing return value.

	* main.c: Removed the global directory_list variable.
	Removed the main_corba_register_server() function.

	* main.h: Removed the global run_desktop variable.

	* panel.h: Now the panel structure has a unique numerical ID used
	for session management.

	* screen.c (panel_new): Maintain a unique ID for each panel.

	* main.c (maybe_display_linksdir): Handle display of the desktop
	init dir here.
	(main): Call gnome_check_super_user().
	(init_corba_with_args): Call corba_init_server().

	* main.c (init_corba_with_args): Do CORBA initialization here.  Also
	removed the global force_activation option.

1999-03-30  Federico Mena Quintero  <federico@nuclecu.unam.mx>

	* vfs.c (vfs_add_current_stamps): Only do stamping of the panels
	if they exist.

	* mcserv.c: #include <sys/wait.h>
	(get_client): Put `#ifdef __EMX__' around an otherwise-unused
	variable.

	* utilvfs.c (vfs_split_url): Fix NULL <-> 0 confusion when
	comparing characters.

	* ftpfs.c (retrieve_dir): Removed unused variable dot_dot_found.

	* extfs.c (extfs_init): Assign `key' to c, not `&key'.
1999-03-30 06:09:56 +00:00

375 строки
9.7 KiB
C

/* CORBA support for the Midhignt Commander
*
* Copyright (C) 1999 The Free Sofware Foundation
*
* Authors: Miguel de Icaza <miguel@nuclecu.unam.mx>
* Federico Mena <federico@nuclecu.unam.mx>
* Elliot Lee <sopwith@cuc.edu>
*/
#include <config.h>
#include "panel.h"
#include <libgnorba/gnorba.h>
#include "FileManager.h"
#include "gcmd.h"
#include "gcorba.h"
#include "global.h"
#include "gmain.h"
/*** Global variables ***/
CORBA_ORB orb = CORBA_OBJECT_NIL;
/*** Local variables ***/
/* Reference to the server object */
static CORBA_Object gmc_server;
/*** App-specific servant structures ***/
typedef struct {
POA_GNOME_FileManagerWindow servant;
PortableServer_POA poa;
WPanel *panel;
} impl_POA_GNOME_FileManagerWindow;
typedef struct {
POA_GNOME_FileManagerFactory servant;
PortableServer_POA poa;
} impl_POA_GNOME_FileManagerFactory;
/*** Implementation stub prototypes ***/
static void impl_GNOME_FileManagerWindow__destroy (impl_POA_GNOME_FileManagerWindow *servant,
CORBA_Environment *ev);
static void impl_GNOME_FileManagerWindow_close (impl_POA_GNOME_FileManagerWindow *servant,
CORBA_Environment *ev);
static void impl_GNOME_FileManagerFactory__destroy (impl_POA_GNOME_FileManagerFactory *servant,
CORBA_Environment *ev);
static CORBA_boolean impl_GNOME_FileManagerFactory_supports (
impl_POA_GNOME_FileManagerFactory *servant,
const CORBA_char *obj_goad_id,
CORBA_Environment *ev);
static CORBA_Object impl_GNOME_FileManagerFactory_create_object (
impl_POA_GNOME_FileManagerFactory *servant,
const CORBA_char *goad_id,
const GNOME_stringlist *params,
CORBA_Environment *ev);
static GNOME_FileManagerWindow impl_GNOME_FileManagerFactory_create_window (
impl_POA_GNOME_FileManagerFactory * servant,
const CORBA_char * dir,
CORBA_Environment * ev);
/*** epv structures ***/
static PortableServer_ServantBase__epv impl_GNOME_FileManagerWindow_base_epv =
{
NULL, /* _private data */
NULL, /* finalize routine */
NULL, /* default_POA routine */
};
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, /* finalize routine */
NULL, /* default_POA routine */
};
static POA_GNOME_FileManagerFactory__epv impl_GNOME_FileManagerFactory_epv =
{
NULL, /* _private */
(gpointer) &impl_GNOME_FileManagerFactory_create_window,
};
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 GNOME_FileManagerWindow
impl_GNOME_FileManagerWindow__create(PortableServer_POA poa,
impl_POA_GNOME_FileManagerWindow **servant,
CORBA_Environment *ev)
{
GNOME_FileManagerWindow retval;
impl_POA_GNOME_FileManagerWindow *newservant;
PortableServer_ObjectId *objid;
newservant = g_new0 (impl_POA_GNOME_FileManagerWindow, 1);
newservant->servant.vepv = &impl_GNOME_FileManagerWindow_vepv;
newservant->poa = poa;
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);
if (servant)
*servant = newservant;
return retval;
}
/* You shouldn't call this routine directly without first deactivating the servant... */
static void
impl_GNOME_FileManagerWindow__destroy(impl_POA_GNOME_FileManagerWindow *servant,
CORBA_Environment *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);
}
static void
impl_GNOME_FileManagerWindow_close(impl_POA_GNOME_FileManagerWindow *servant,
CORBA_Environment *ev)
{
gnome_close_panel (GTK_WIDGET (servant->panel->xwindow), servant->panel);
}
static GNOME_FileManagerFactory
impl_GNOME_FileManagerFactory__create(PortableServer_POA poa,
impl_POA_GNOME_FileManagerFactory **servant,
CORBA_Environment *ev)
{
GNOME_FileManagerFactory retval;
impl_POA_GNOME_FileManagerFactory *newservant;
PortableServer_ObjectId *objid;
newservant = g_new0 (impl_POA_GNOME_FileManagerFactory, 1);
newservant->servant.vepv = &impl_GNOME_FileManagerFactory_vepv;
newservant->poa = poa;
POA_GNOME_FileManagerFactory__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);
if (servant)
*servant = newservant;
return retval;
}
/* You shouldn't call this routine directly without first deactivating the servant... */
static void
impl_GNOME_FileManagerFactory__destroy(impl_POA_GNOME_FileManagerFactory *servant,
CORBA_Environment *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_FileManagerFactory__fini ((PortableServer_Servant) servant, ev);
g_free (servant);
}
static CORBA_boolean
impl_GNOME_FileManagerFactory_supports (impl_POA_GNOME_FileManagerFactory *servant,
const CORBA_char *obj_goad_id,
CORBA_Environment *ev)
{
if (strcmp (obj_goad_id, "gmc_filemanager_window") == 0)
return CORBA_TRUE;
else
return CORBA_FALSE;
}
static CORBA_Object
impl_GNOME_FileManagerFactory_create_object (impl_POA_GNOME_FileManagerFactory *servant,
const CORBA_char *goad_id,
const GNOME_stringlist *params,
CORBA_Environment *ev)
{
if (strcmp (goad_id, "gmc_filemanager_window") != 0) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_GenericFactory_CannotActivate,
NULL);
return CORBA_OBJECT_NIL;
}
return impl_GNOME_FileManagerFactory_create_window (
servant,
params->_length ? params->_buffer[0] : home_dir,
ev);
}
/* Callback used when a panel is destroyed */
static void
panel_destroyed (GtkObject *object, gpointer data)
{
impl_POA_GNOME_FileManagerWindow *servant;
CORBA_Environment ev;
servant = data;
CORBA_exception_init (&ev);
impl_GNOME_FileManagerWindow__destroy (servant, &ev);
CORBA_exception_free (&ev);
}
static GNOME_FileManagerWindow
impl_GNOME_FileManagerFactory_create_window(impl_POA_GNOME_FileManagerFactory *servant,
const CORBA_char *dir,
CORBA_Environment *ev)
{
GNOME_FileManagerWindow retval;
impl_POA_GNOME_FileManagerWindow *newservant;
WPanel *panel;
retval = impl_GNOME_FileManagerWindow__create (servant->poa,
&newservant,
ev);
panel = new_panel_at ((dir && *dir) ? dir : home_dir);
newservant->panel = panel;
gtk_signal_connect (GTK_OBJECT (panel->xwindow), "destroy",
(GtkSignalFunc) panel_destroyed,
newservant);
return retval;
}
/*** Public non-implementation functions ***/
/* Creates the CORBA server */
static int
create_server (void)
{
CORBA_Environment ev;
PortableServer_POA poa;
PortableServer_POAManager poa_manager;
int retval;
int v;
retval = FALSE;
CORBA_exception_init (&ev);
/* Get the POA and create the server */
poa = (PortableServer_POA) CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev);
if (ev._major != CORBA_NO_EXCEPTION)
goto out;
poa_manager = PortableServer_POA__get_the_POAManager (poa, &ev);
if (ev._major != CORBA_NO_EXCEPTION)
goto out;
PortableServer_POAManager_activate (poa_manager, &ev);
if (ev._major != CORBA_NO_EXCEPTION)
goto out;
gmc_server = impl_GNOME_FileManagerFactory__create (poa, NULL, &ev);
if (ev._major != CORBA_NO_EXCEPTION)
goto out;
CORBA_Object_release ((CORBA_Object) poa, &ev);
if (ev._major != CORBA_NO_EXCEPTION)
goto out;
/* Register the server and see if it was already there */
v = goad_server_register (CORBA_OBJECT_NIL, gmc_server,
"gmc_filemanager_factory", "server", &ev);
switch (v) {
case 0:
corba_have_server = FALSE;
break;
case -2:
corba_have_server = FALSE;
break;
default:
goto out;
}
retval = TRUE;
/* Done */
out:
return retval;
}
/**
* corba_init_server:
* @void:
*
* Initializes the CORBA factory object for gmc. Returns whether initialization
* was successful or not, and sets the global corba_have_server variable.
*
* Return value: TRUE if successful, FALSE otherwise.
**/
int
corba_init_server (void)
{
gmc_server = goad_server_activate_with_id (NULL,
"gmc_filemanager_factory",
GOAD_ACTIVATE_EXISTING_ONLY,
NULL);
if (gmc_server != CORBA_OBJECT_NIL) {
corba_have_server = TRUE;
return TRUE;
} else
return create_server ();
}
/**
* corba_create_window:
* @void:
*
* Creates a GMC window using a CORBA call to the server.
**/
void
corba_create_window (void)
{
CORBA_Environment ev;
char cwd[MC_MAXPATHLEN];
mc_get_current_wd (cwd, MC_MAXPATHLEN);
CORBA_exception_init (&ev);
GNOME_FileManagerFactory_create_window (gmc_server, cwd, &ev);
CORBA_exception_free (&ev);
}