1999-09-10 02:46:54 +04:00
|
|
|
|
/* CORBA support for the Midnight Commander
|
1998-12-14 07:14:16 +03:00
|
|
|
|
*
|
1999-03-30 10:09:56 +04:00
|
|
|
|
* 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>
|
1998-12-14 07:14:16 +03:00
|
|
|
|
*/
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
1998-12-14 07:14:16 +03:00
|
|
|
|
#include <config.h>
|
1999-03-30 10:09:56 +04:00
|
|
|
|
#include "panel.h"
|
1999-04-06 01:38:50 +04:00
|
|
|
|
#include "../vfs/vfs.h"
|
1998-12-14 07:14:16 +03:00
|
|
|
|
#include <libgnorba/gnorba.h>
|
1998-12-14 08:15:48 +03:00
|
|
|
|
#include "FileManager.h"
|
1998-12-14 07:14:16 +03:00
|
|
|
|
#include "gcorba.h"
|
1999-09-09 20:17:18 +04:00
|
|
|
|
#include "gdesktop.h"
|
1999-03-30 10:09:56 +04:00
|
|
|
|
#include "global.h"
|
|
|
|
|
#include "gmain.h"
|
1999-09-09 04:37:02 +04:00
|
|
|
|
#include "gscreen.h"
|
1999-06-23 01:02:08 +04:00
|
|
|
|
#include "main.h"
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
/* The ORB for the whole program */
|
1999-03-30 10:09:56 +04:00
|
|
|
|
CORBA_ORB orb = CORBA_OBJECT_NIL;
|
1998-12-14 07:14:16 +03:00
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
/* The POA */
|
1999-09-10 23:24:57 +04:00
|
|
|
|
PortableServer_POA poa = CORBA_OBJECT_NIL;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
/* Desktop servant */
|
|
|
|
|
typedef struct {
|
|
|
|
|
POA_GNOME_FileManager_Desktop servant;
|
|
|
|
|
} DesktopServant;
|
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
static PortableServer_ServantBase__epv desktop_base_epv;
|
1999-09-09 04:37:02 +04:00
|
|
|
|
static POA_GNOME_FileManager_Desktop__epv desktop_epv;
|
|
|
|
|
static POA_GNOME_FileManager_Desktop__vepv desktop_vepv;
|
1998-12-14 07:14:16 +03:00
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
/* Window servant */
|
1998-12-14 08:15:48 +03:00
|
|
|
|
typedef struct {
|
1999-09-09 04:37:02 +04:00
|
|
|
|
POA_GNOME_FileManager_Window servant;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
|
|
|
|
WPanel *panel;
|
1999-09-09 04:37:02 +04:00
|
|
|
|
} WindowServant;
|
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
static PortableServer_ServantBase__epv window_base_epv;
|
1999-09-09 04:37:02 +04:00
|
|
|
|
static POA_GNOME_FileManager_Window__epv window_epv;
|
|
|
|
|
static POA_GNOME_FileManager_Window__vepv window_vepv;
|
|
|
|
|
|
|
|
|
|
/* WindowFactory servant */
|
1998-12-14 08:15:48 +03:00
|
|
|
|
|
|
|
|
|
typedef struct {
|
1999-09-09 04:37:02 +04:00
|
|
|
|
POA_GNOME_FileManager_WindowFactory servant;
|
|
|
|
|
} WindowFactoryServant;
|
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
static PortableServer_ServantBase__epv window_factory_base_epv;
|
|
|
|
|
static POA_GNOME_GenericFactory__epv window_factory_generic_factory_epv;
|
1999-09-09 04:37:02 +04:00
|
|
|
|
static POA_GNOME_FileManager_WindowFactory__epv window_factory_epv;
|
|
|
|
|
static POA_GNOME_FileManager_WindowFactory__vepv window_factory_vepv;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* References to the window factory and desktop server objects */
|
|
|
|
|
|
|
|
|
|
static CORBA_Object window_factory_server = CORBA_OBJECT_NIL;
|
|
|
|
|
static CORBA_Object desktop_server = CORBA_OBJECT_NIL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-09-09 20:17:18 +04:00
|
|
|
|
/* Desktop implementation */
|
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
/* Desktop::rescan method */
|
1999-09-09 20:17:18 +04:00
|
|
|
|
static void
|
|
|
|
|
Desktop_rescan (PortableServer_Servant servant, CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
desktop_reload_icons (FALSE, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
/* Desktop::rescan_devices method */
|
1999-09-09 20:17:18 +04:00
|
|
|
|
static void
|
|
|
|
|
Desktop_rescan_devices (PortableServer_Servant servant, CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
desktop_rescan_devices ();
|
|
|
|
|
}
|
|
|
|
|
|
2000-01-25 13:30:53 +03:00
|
|
|
|
/* Desktop::arrange_icons method */
|
|
|
|
|
static void
|
|
|
|
|
Desktop_arrange_icons (PortableServer_Servant servant,
|
|
|
|
|
GNOME_FileManager_Desktop_ArrangeType type,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
SortType sort_type;
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
case GNOME_FileManager_Desktop_BY_NAME:
|
|
|
|
|
sort_type = SORT_NAME;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GNOME_FileManager_Desktop_BY_TYPE:
|
|
|
|
|
sort_type = SORT_EXTENSION;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GNOME_FileManager_Desktop_BY_SIZE:
|
|
|
|
|
sort_type = SORT_SIZE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GNOME_FileManager_Desktop_BY_ATIME:
|
|
|
|
|
sort_type = SORT_ACCESS;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GNOME_FileManager_Desktop_BY_MTIME:
|
|
|
|
|
sort_type = SORT_MODIFY;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GNOME_FileManager_Desktop_BY_CTIME:
|
|
|
|
|
sort_type = SORT_CHANGE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return; /* Should we raise an exception instead? */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
desktop_arrange_icons (sort_type);
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
/* Fills the vepv structure for the desktop object */
|
|
|
|
|
static void
|
|
|
|
|
Desktop_class_init (void)
|
|
|
|
|
{
|
|
|
|
|
static int inited = FALSE;
|
|
|
|
|
|
|
|
|
|
if (inited)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
inited = TRUE;
|
|
|
|
|
|
|
|
|
|
desktop_epv.rescan = Desktop_rescan;
|
|
|
|
|
desktop_epv.rescan_devices = Desktop_rescan_devices;
|
2000-01-25 13:30:53 +03:00
|
|
|
|
desktop_epv.arrange_icons = Desktop_arrange_icons;
|
1999-09-10 02:46:54 +04:00
|
|
|
|
|
|
|
|
|
desktop_vepv._base_epv = &desktop_base_epv;
|
|
|
|
|
desktop_vepv.GNOME_FileManager_Desktop_epv = &desktop_epv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Creates a reference for the desktop object */
|
|
|
|
|
static GNOME_FileManager_Desktop
|
|
|
|
|
Desktop_create (PortableServer_POA poa, CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
DesktopServant *ds;
|
|
|
|
|
PortableServer_ObjectId *objid;
|
|
|
|
|
|
|
|
|
|
Desktop_class_init ();
|
|
|
|
|
|
|
|
|
|
ds = g_new0 (DesktopServant, 1);
|
|
|
|
|
ds->servant.vepv = &desktop_vepv;
|
|
|
|
|
|
|
|
|
|
POA_GNOME_FileManager_Desktop__init ((PortableServer_Servant) ds, ev);
|
|
|
|
|
objid = PortableServer_POA_activate_object (poa, ds, ev);
|
|
|
|
|
CORBA_free (objid);
|
|
|
|
|
|
|
|
|
|
return PortableServer_POA_servant_to_reference (poa, ds, ev);
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-09 20:17:18 +04:00
|
|
|
|
|
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
/* Window implementation */
|
|
|
|
|
|
1999-09-09 20:17:18 +04:00
|
|
|
|
/* Window::close method */
|
|
|
|
|
static void
|
|
|
|
|
Window_close (PortableServer_Servant servant, CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
WindowServant *ws;
|
|
|
|
|
|
1999-09-12 06:44:11 +04:00
|
|
|
|
ws = (WindowServant *) servant;
|
1999-09-09 20:17:18 +04:00
|
|
|
|
gnome_close_panel (GTK_WIDGET (ws->panel->xwindow), ws->panel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Destroys the servant for an image window */
|
|
|
|
|
static void
|
|
|
|
|
window_destroy (WindowServant *ws, CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
PortableServer_ObjectId *objid;
|
|
|
|
|
|
|
|
|
|
objid = PortableServer_POA_servant_to_id (poa, ws, ev);
|
|
|
|
|
PortableServer_POA_deactivate_object (poa, objid, ev);
|
|
|
|
|
CORBA_free (objid);
|
1999-09-09 04:37:02 +04:00
|
|
|
|
|
1999-09-09 20:17:18 +04:00
|
|
|
|
POA_GNOME_FileManager_Window__fini (ws, ev);
|
|
|
|
|
g_free (ws);
|
|
|
|
|
}
|
1999-09-09 04:37:02 +04:00
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
/* Fills the vepv structure for the window object */
|
|
|
|
|
static void
|
|
|
|
|
Window_class_init (void)
|
|
|
|
|
{
|
|
|
|
|
static int inited = FALSE;
|
|
|
|
|
|
|
|
|
|
if (inited)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
inited = TRUE;
|
|
|
|
|
|
|
|
|
|
window_epv.close = Window_close;
|
|
|
|
|
|
|
|
|
|
window_vepv._base_epv = &window_base_epv;
|
|
|
|
|
window_vepv.GNOME_FileManager_Window_epv = &window_epv;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* WindowFactory implementation */
|
|
|
|
|
|
|
|
|
|
/* WindowFactory::the_desktop attribute getter */
|
|
|
|
|
static GNOME_FileManager_Desktop
|
|
|
|
|
WindowFactory_get_the_desktop (PortableServer_Servant servant,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
g_assert (desktop_server != CORBA_OBJECT_NIL);
|
|
|
|
|
|
|
|
|
|
return CORBA_Object_duplicate (desktop_server, ev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Called when a panel created through CORBA is destroyed */
|
|
|
|
|
static void
|
|
|
|
|
panel_destroyed (GtkObject *object, gpointer data)
|
|
|
|
|
{
|
|
|
|
|
WindowServant *ws;
|
|
|
|
|
CORBA_Environment ev;
|
|
|
|
|
|
|
|
|
|
ws = data;
|
|
|
|
|
|
|
|
|
|
CORBA_exception_init (&ev);
|
|
|
|
|
window_destroy (ws, &ev);
|
|
|
|
|
CORBA_exception_free (&ev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns a servant for a panel, creating one if necessary */
|
|
|
|
|
static WindowServant *
|
|
|
|
|
window_servant_from_panel (WPanel *panel, CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
WindowServant *ws;
|
|
|
|
|
PortableServer_ObjectId *objid;
|
|
|
|
|
|
|
|
|
|
if (panel->servant)
|
|
|
|
|
return panel->servant;
|
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
Window_class_init ();
|
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
ws = g_new0 (WindowServant, 1);
|
|
|
|
|
ws->servant.vepv = &window_vepv;
|
|
|
|
|
|
|
|
|
|
POA_GNOME_FileManager_Window__init ((PortableServer_Servant) ws, ev);
|
|
|
|
|
objid = PortableServer_POA_activate_object (poa, ws, ev);
|
|
|
|
|
CORBA_free (objid);
|
|
|
|
|
|
|
|
|
|
ws->panel = panel;
|
|
|
|
|
panel->servant = ws;
|
|
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (panel->xwindow), "destroy",
|
|
|
|
|
(GtkSignalFunc) panel_destroyed,
|
|
|
|
|
ws);
|
|
|
|
|
|
|
|
|
|
return ws;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* WindowFactory::create_window method */
|
|
|
|
|
static GNOME_FileManager_Window
|
|
|
|
|
WindowFactory_create_window (PortableServer_Servant servant,
|
|
|
|
|
CORBA_char *dir,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
WPanel *panel;
|
|
|
|
|
WindowServant *ws;
|
|
|
|
|
|
|
|
|
|
panel = new_panel_at (dir);
|
|
|
|
|
ws = window_servant_from_panel (panel, ev);
|
|
|
|
|
|
|
|
|
|
return PortableServer_POA_servant_to_reference (poa, ws, ev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* WindowFactory::rescan_directory method */
|
|
|
|
|
static void
|
|
|
|
|
WindowFactory_rescan_directory (PortableServer_Servant servant,
|
|
|
|
|
CORBA_char *dir,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
PanelContainer *pc;
|
|
|
|
|
GList *l;
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
|
|
/* We do a blind compare against the panel's cwd */
|
|
|
|
|
|
|
|
|
|
len = strlen (dir);
|
|
|
|
|
if (dir[len - 1] == PATH_SEP)
|
|
|
|
|
len--;
|
|
|
|
|
|
|
|
|
|
for (l = containers; l; l = l->next) {
|
|
|
|
|
pc = l->data;
|
|
|
|
|
|
|
|
|
|
if (strncmp (dir, pc->panel->cwd, len) == 0
|
|
|
|
|
&& (pc->panel->cwd[len] == 0 || pc->panel->cwd[len] == PATH_SEP))
|
|
|
|
|
update_one_panel_widget (pc->panel, UP_RELOAD, UP_KEEPSEL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* WindowFactory::close_invalid_windows method */
|
|
|
|
|
static void
|
|
|
|
|
WindowFactory_close_invalid_windows (PortableServer_Servant servant,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
PanelContainer *pc;
|
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
|
|
/* To see if a panel is valid or not, we try to cd to its cwd. If this
|
|
|
|
|
* fails, then we destroy the panel's window.
|
|
|
|
|
*/
|
|
|
|
|
|
1999-09-10 05:14:29 +04:00
|
|
|
|
l = containers;
|
|
|
|
|
while (l) {
|
1999-09-09 04:37:02 +04:00
|
|
|
|
pc = l->data;
|
1999-09-10 05:14:29 +04:00
|
|
|
|
l = l->next;
|
1999-09-09 04:37:02 +04:00
|
|
|
|
|
|
|
|
|
if (mc_chdir (pc->panel->cwd) != 0)
|
1999-09-09 20:17:18 +04:00
|
|
|
|
gnome_close_panel (GTK_WIDGET (pc->panel->xwindow), pc->panel);
|
1999-09-09 04:37:02 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Creates an object reference for a panel */
|
1999-09-09 20:17:18 +04:00
|
|
|
|
static GNOME_FileManager_Window
|
1999-09-09 04:37:02 +04:00
|
|
|
|
window_reference_from_panel (WPanel *panel, CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
WindowServant *ws;
|
|
|
|
|
|
|
|
|
|
ws = window_servant_from_panel (panel, ev);
|
|
|
|
|
return PortableServer_POA_servant_to_reference (poa, ws, ev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* WindowFactory::get_window_by_directory method */
|
|
|
|
|
static GNOME_FileManager_WindowFactory_WindowSeq *
|
|
|
|
|
WindowFactory_get_windows_by_directory (PortableServer_Servant servant,
|
|
|
|
|
CORBA_char *dir,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
GNOME_FileManager_WindowFactory_WindowSeq *seq;
|
|
|
|
|
PanelContainer *pc;
|
|
|
|
|
GList *l;
|
|
|
|
|
int n, i;
|
|
|
|
|
|
|
|
|
|
/* We return a sequence of the windows that match the specified
|
|
|
|
|
* directory.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Count 'em */
|
|
|
|
|
n = 0;
|
|
|
|
|
for (l = containers; l; l = l->next) {
|
|
|
|
|
pc = l->data;
|
|
|
|
|
|
|
|
|
|
if (strcmp (pc->panel->cwd, dir) == 0)
|
|
|
|
|
n++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
seq = GNOME_FileManager_WindowFactory_WindowSeq__alloc ();
|
1999-09-14 09:21:39 +04:00
|
|
|
|
seq->_length = n;
|
1999-09-09 04:37:02 +04:00
|
|
|
|
seq->_buffer = CORBA_sequence_GNOME_FileManager_Window_allocbuf (n);
|
|
|
|
|
|
1999-09-21 03:29:45 +04:00
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
|
|
for (l = containers; l; l = l->next) {
|
1999-09-09 04:37:02 +04:00
|
|
|
|
pc = l->data;
|
|
|
|
|
|
|
|
|
|
if (strcmp (pc->panel->cwd, dir) == 0)
|
1999-09-21 03:29:45 +04:00
|
|
|
|
seq->_buffer[i++] = window_reference_from_panel (pc->panel, ev);
|
1999-09-09 04:37:02 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return seq;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* WindowFactory GenericFactory::supports method */
|
|
|
|
|
static CORBA_boolean
|
|
|
|
|
WindowFactory_supports (PortableServer_Servant servant,
|
|
|
|
|
CORBA_char *obj_goad_id,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (obj_goad_id, "IDL:GNOME:FileManager:Window:1.0") == 0
|
|
|
|
|
|| strcmp (obj_goad_id, "IDL:GNOME:FileManager:Desktop:1.0") == 0)
|
|
|
|
|
return CORBA_TRUE;
|
|
|
|
|
else
|
|
|
|
|
return CORBA_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* WindowFactory GenericFactory::create_object method */
|
|
|
|
|
static CORBA_Object
|
|
|
|
|
WindowFactory_create_object (PortableServer_Servant servant,
|
|
|
|
|
CORBA_char *goad_id,
|
|
|
|
|
GNOME_stringlist *params,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (goad_id, "IDL:GNOME:FileManager:Window:1.0") != 0)
|
|
|
|
|
return WindowFactory_create_window (
|
|
|
|
|
servant,
|
|
|
|
|
params->_length != 0 ? params->_buffer[0] : home_dir,
|
|
|
|
|
ev);
|
1999-09-09 20:17:18 +04:00
|
|
|
|
else if (strcmp (goad_id, "IDL:GNOME:FileManager:Desktop:1.0") == 0)
|
|
|
|
|
return WindowFactory_get_the_desktop (servant, ev);
|
|
|
|
|
else {
|
1999-09-09 04:37:02 +04:00
|
|
|
|
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
|
|
|
|
|
ex_GNOME_GenericFactory_CannotActivate,
|
|
|
|
|
NULL);
|
|
|
|
|
return CORBA_OBJECT_NIL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
/* Fills the vepv structure for the window factory object */
|
|
|
|
|
static void
|
|
|
|
|
WindowFactory_class_init (void)
|
|
|
|
|
{
|
|
|
|
|
static int inited = FALSE;
|
|
|
|
|
|
|
|
|
|
if (inited)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
inited = TRUE;
|
|
|
|
|
|
|
|
|
|
window_factory_generic_factory_epv.supports = WindowFactory_supports;
|
|
|
|
|
window_factory_generic_factory_epv.create_object = WindowFactory_create_object;
|
|
|
|
|
|
|
|
|
|
window_factory_epv._get_the_desktop = WindowFactory_get_the_desktop;
|
|
|
|
|
window_factory_epv.create_window = WindowFactory_create_window;
|
|
|
|
|
window_factory_epv.rescan_directory = WindowFactory_rescan_directory;
|
|
|
|
|
window_factory_epv.close_invalid_windows = WindowFactory_close_invalid_windows;
|
|
|
|
|
window_factory_epv.get_windows_by_directory = WindowFactory_get_windows_by_directory;
|
|
|
|
|
|
|
|
|
|
window_factory_vepv._base_epv = &window_factory_base_epv;
|
|
|
|
|
window_factory_vepv.GNOME_GenericFactory_epv = &window_factory_generic_factory_epv;
|
|
|
|
|
window_factory_vepv.GNOME_FileManager_WindowFactory_epv = &window_factory_epv;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-09 20:17:18 +04:00
|
|
|
|
/* Creates a reference for the window factory object */
|
|
|
|
|
static GNOME_FileManager_WindowFactory
|
|
|
|
|
WindowFactory_create (PortableServer_POA poa, CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
WindowFactoryServant *wfs;
|
|
|
|
|
PortableServer_ObjectId *objid;
|
1999-09-09 04:37:02 +04:00
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
WindowFactory_class_init ();
|
|
|
|
|
|
1999-09-09 20:17:18 +04:00
|
|
|
|
wfs = g_new0 (WindowFactoryServant, 1);
|
|
|
|
|
wfs->servant.vepv = &window_factory_vepv;
|
1999-09-09 04:37:02 +04:00
|
|
|
|
|
1999-09-09 20:17:18 +04:00
|
|
|
|
POA_GNOME_FileManager_WindowFactory__init ((PortableServer_Servant) wfs, ev);
|
|
|
|
|
objid = PortableServer_POA_activate_object (poa, wfs, ev);
|
|
|
|
|
CORBA_free (objid);
|
1999-09-09 04:37:02 +04:00
|
|
|
|
|
1999-09-09 20:17:18 +04:00
|
|
|
|
return PortableServer_POA_servant_to_reference (poa, wfs, ev);
|
|
|
|
|
}
|
1999-09-09 04:37:02 +04:00
|
|
|
|
|
1999-09-09 20:17:18 +04:00
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
/* Creates and registers the CORBA servers. Returns TRUE on success, FALSE
|
|
|
|
|
* otherwise.
|
|
|
|
|
*/
|
1999-03-30 10:09:56 +04:00
|
|
|
|
static int
|
1999-09-10 02:46:54 +04:00
|
|
|
|
register_servers (void)
|
1998-12-14 07:14:16 +03:00
|
|
|
|
{
|
1998-12-14 09:45:07 +03:00
|
|
|
|
CORBA_Environment ev;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
int retval;
|
|
|
|
|
int v;
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
1998-12-14 07:14:16 +03:00
|
|
|
|
CORBA_exception_init (&ev);
|
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
/* Register the window factory and see if it was already there */
|
|
|
|
|
|
1999-09-09 20:17:18 +04:00
|
|
|
|
window_factory_server = WindowFactory_create (poa, &ev);
|
1999-03-30 10:09:56 +04:00
|
|
|
|
if (ev._major != CORBA_NO_EXCEPTION)
|
|
|
|
|
goto out;
|
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
v = goad_server_register (CORBA_OBJECT_NIL, window_factory_server,
|
1999-09-10 02:46:54 +04:00
|
|
|
|
"IDL:GNOME:FileManager:WindowFactory:1.0", "object", &ev);
|
1999-03-30 10:09:56 +04:00
|
|
|
|
switch (v) {
|
|
|
|
|
case 0:
|
|
|
|
|
corba_have_server = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case -2:
|
|
|
|
|
corba_have_server = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
goto out;
|
1998-12-14 07:14:16 +03:00
|
|
|
|
}
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
/* Register the desktop server */
|
|
|
|
|
|
|
|
|
|
desktop_server = Desktop_create (poa, &ev);
|
|
|
|
|
if (ev._major != CORBA_NO_EXCEPTION)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
goad_server_register (CORBA_OBJECT_NIL, desktop_server,
|
|
|
|
|
"IDL:GNOME:FileManager:Desktop:1.0", "object", &ev);
|
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
/* Done */
|
|
|
|
|
out:
|
1999-09-10 02:46:54 +04:00
|
|
|
|
CORBA_exception_free (&ev);
|
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
return retval;
|
1999-01-28 07:37:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
/**
|
|
|
|
|
* corba_init_server:
|
1999-07-02 03:15:08 +04:00
|
|
|
|
* @void:
|
|
|
|
|
*
|
1999-09-09 04:37:02 +04:00
|
|
|
|
* Initializes the CORBA server for GMC. Returns whether initialization was
|
|
|
|
|
* successful or not, and sets the global corba_have_server variable.
|
1999-07-02 03:15:08 +04:00
|
|
|
|
*
|
1999-03-30 10:09:56 +04:00
|
|
|
|
* Return value: TRUE if successful, FALSE otherwise.
|
|
|
|
|
**/
|
|
|
|
|
int
|
|
|
|
|
corba_init_server (void)
|
|
|
|
|
{
|
1999-09-10 23:24:57 +04:00
|
|
|
|
int retval;
|
|
|
|
|
CORBA_Environment ev;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
CORBA_exception_free (&ev);
|
|
|
|
|
|
|
|
|
|
/* See if the servers are there */
|
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
window_factory_server = goad_server_activate_with_id (
|
|
|
|
|
NULL,
|
|
|
|
|
"IDL:GNOME:FileManager:WindowFactory:1.0",
|
|
|
|
|
GOAD_ACTIVATE_EXISTING_ONLY,
|
|
|
|
|
NULL);
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
1999-09-10 02:46:54 +04:00
|
|
|
|
desktop_server = goad_server_activate_with_id (
|
|
|
|
|
NULL,
|
|
|
|
|
"IDL:GNOME:FileManager:Desktop:1.0",
|
|
|
|
|
GOAD_ACTIVATE_EXISTING_ONLY,
|
|
|
|
|
NULL);
|
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
if (window_factory_server != CORBA_OBJECT_NIL) {
|
1999-03-30 10:09:56 +04:00
|
|
|
|
corba_have_server = TRUE;
|
1999-09-10 23:24:57 +04:00
|
|
|
|
retval = TRUE;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
} else
|
1999-09-10 23:24:57 +04:00
|
|
|
|
retval = register_servers ();
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
return retval;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
1999-09-30 00:14:43 +04:00
|
|
|
|
/**
|
|
|
|
|
* corba_activate_server:
|
|
|
|
|
* @void:
|
|
|
|
|
*
|
|
|
|
|
* Activates the POA manager and thus makes the services available to the
|
|
|
|
|
* outside world.
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
corba_activate_server (void)
|
|
|
|
|
{
|
|
|
|
|
CORBA_Environment ev;
|
|
|
|
|
PortableServer_POAManager poa_manager;
|
|
|
|
|
|
|
|
|
|
/* Do nothing if the server is already running */
|
|
|
|
|
if (corba_have_server)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
CORBA_exception_init (&ev);
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
|
|
|
|
|
CORBA_exception_free (&ev);
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
/**
|
|
|
|
|
* corba_create_window:
|
1999-07-02 03:15:08 +04:00
|
|
|
|
* @dir: The directory in which to create the window, or NULL for the cwd.
|
|
|
|
|
*
|
1999-03-30 10:09:56 +04:00
|
|
|
|
* Creates a GMC window using a CORBA call to the server.
|
|
|
|
|
**/
|
1999-01-28 07:37:47 +03:00
|
|
|
|
void
|
1999-09-10 02:46:54 +04:00
|
|
|
|
corba_create_window (char *dir)
|
1999-01-28 07:37:47 +03:00
|
|
|
|
{
|
|
|
|
|
CORBA_Environment ev;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
char cwd[MC_MAXPATHLEN];
|
1999-07-02 03:15:08 +04:00
|
|
|
|
|
|
|
|
|
if (dir == NULL) {
|
1999-06-23 01:02:08 +04:00
|
|
|
|
mc_get_current_wd (cwd, MC_MAXPATHLEN);
|
1999-07-02 03:15:08 +04:00
|
|
|
|
dir = cwd;
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
CORBA_exception_init (&ev);
|
1999-09-09 20:17:18 +04:00
|
|
|
|
GNOME_FileManager_WindowFactory_create_window (window_factory_server, dir, &ev);
|
1999-01-28 07:37:47 +03:00
|
|
|
|
CORBA_exception_free (&ev);
|
1998-12-14 07:14:16 +03:00
|
|
|
|
}
|