mirror of https://github.com/MidnightCommander/mc
1999-09-10 Federico Mena Quintero <federico@redhat.com>
* gmount.c (setup_devices): See if our supported automounter, magicdev, is running and only create links for mounted CD-ROMs if so. (automounter_is_running): For now just return TRUE; we have to wait for magicdev to export a CORBA server. * gcorba.c (corba_init_server): Initialize the POA here instead of in register_servers().
This commit is contained in:
parent
0f59a02894
commit
e13620fca5
|
@ -1,3 +1,14 @@
|
||||||
|
1999-09-10 Federico Mena Quintero <federico@redhat.com>
|
||||||
|
|
||||||
|
* gmount.c (setup_devices): See if our supported automounter,
|
||||||
|
magicdev, is running and only create links for mounted CD-ROMs if
|
||||||
|
so.
|
||||||
|
(automounter_is_running): For now just return TRUE; we have to
|
||||||
|
wait for magicdev to export a CORBA server.
|
||||||
|
|
||||||
|
* gcorba.c (corba_init_server): Initialize the POA here instead of
|
||||||
|
in register_servers().
|
||||||
|
|
||||||
1999-09-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
1999-09-10 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||||
|
|
||||||
* gnome-file-property-dialog.c (apply_uid_group_change): Fix more
|
* gnome-file-property-dialog.c (apply_uid_group_change): Fix more
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
CORBA_ORB orb = CORBA_OBJECT_NIL;
|
CORBA_ORB orb = CORBA_OBJECT_NIL;
|
||||||
|
|
||||||
/* The POA */
|
/* The POA */
|
||||||
PortableServer_POA poa;
|
PortableServer_POA poa = CORBA_OBJECT_NIL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -421,27 +421,12 @@ static int
|
||||||
register_servers (void)
|
register_servers (void)
|
||||||
{
|
{
|
||||||
CORBA_Environment ev;
|
CORBA_Environment ev;
|
||||||
PortableServer_POAManager poa_manager;
|
|
||||||
int retval;
|
int retval;
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
retval = FALSE;
|
retval = FALSE;
|
||||||
CORBA_exception_init (&ev);
|
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;
|
|
||||||
|
|
||||||
/* Register the window factory and see if it was already there */
|
/* Register the window factory and see if it was already there */
|
||||||
|
|
||||||
window_factory_server = WindowFactory_create (poa, &ev);
|
window_factory_server = WindowFactory_create (poa, &ev);
|
||||||
|
@ -493,6 +478,31 @@ register_servers (void)
|
||||||
int
|
int
|
||||||
corba_init_server (void)
|
corba_init_server (void)
|
||||||
{
|
{
|
||||||
|
int retval;
|
||||||
|
CORBA_Environment ev;
|
||||||
|
PortableServer_POAManager poa_manager;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
CORBA_exception_free (&ev);
|
||||||
|
|
||||||
|
/* See if the servers are there */
|
||||||
|
|
||||||
window_factory_server = goad_server_activate_with_id (
|
window_factory_server = goad_server_activate_with_id (
|
||||||
NULL,
|
NULL,
|
||||||
"IDL:GNOME:FileManager:WindowFactory:1.0",
|
"IDL:GNOME:FileManager:WindowFactory:1.0",
|
||||||
|
@ -507,9 +517,12 @@ corba_init_server (void)
|
||||||
|
|
||||||
if (window_factory_server != CORBA_OBJECT_NIL) {
|
if (window_factory_server != CORBA_OBJECT_NIL) {
|
||||||
corba_have_server = TRUE;
|
corba_have_server = TRUE;
|
||||||
return TRUE;
|
retval = TRUE;
|
||||||
} else
|
} else
|
||||||
return register_servers ();
|
retval = register_servers ();
|
||||||
|
|
||||||
|
out:
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,8 +13,9 @@
|
||||||
#include <orb/orbit.h>
|
#include <orb/orbit.h>
|
||||||
|
|
||||||
|
|
||||||
/* The ORB */
|
/* The ORB and the POA */
|
||||||
extern CORBA_ORB orb;
|
extern CORBA_ORB orb;
|
||||||
|
PortableServer_POA poa;
|
||||||
|
|
||||||
|
|
||||||
int corba_init_server (void);
|
int corba_init_server (void);
|
||||||
|
|
|
@ -2872,7 +2872,7 @@ click_proxy_button_press (GtkWidget *widget, GdkEventButton *event, gpointer dat
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->button == 1) {
|
if (event->button == 1) {
|
||||||
click_start_x = event->x;
|
click_start_x = event->x;
|
||||||
click_start_y = event->y;
|
click_start_y = event->y;
|
||||||
|
|
123
gnome/gmount.c
123
gnome/gmount.c
|
@ -95,10 +95,13 @@ void free (void *ptr);
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Information for a mountable device */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *devname;
|
char *devname;
|
||||||
char *mount_point;
|
char *mount_point;
|
||||||
|
|
||||||
/* This is just a good guess */
|
/* This is just a good guess */
|
||||||
enum {
|
enum {
|
||||||
TYPE_UNKNOWN,
|
TYPE_UNKNOWN,
|
||||||
|
@ -107,12 +110,14 @@ typedef struct {
|
||||||
} type;
|
} type;
|
||||||
} devname_info_t;
|
} devname_info_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
option_has_user (char *str)
|
option_has_user (char *str)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
if ((p = strstr (str, "user")) != NULL){
|
if ((p = strstr (str, "user")) != NULL) {
|
||||||
if ((p - 2) >= str){
|
if ((p - 2) >= str) {
|
||||||
if (strncmp (p - 2, "nouser", 6) == 0)
|
if (strncmp (p - 2, "nouser", 6) == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -121,12 +126,12 @@ option_has_user (char *str)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MOUNTED_GETMNTENT1
|
#ifdef MOUNTED_GETMNTENT1
|
||||||
|
|
||||||
/*
|
/* Returns whether devname is mountable: NULL if it is not or g_strdup()ed
|
||||||
* Returns wheter devname is mountable:
|
* string with the mount point.
|
||||||
* NULL if it is not or
|
|
||||||
* g_strdup()ed string with the mount point
|
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
is_block_device_mountable (char *mount_point)
|
is_block_device_mountable (char *mount_point)
|
||||||
|
@ -134,32 +139,31 @@ is_block_device_mountable (char *mount_point)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
struct mntent *mnt;
|
struct mntent *mnt;
|
||||||
char *retval = NULL;
|
char *retval = NULL;
|
||||||
|
|
||||||
f = setmntent ("/etc/fstab", "r");
|
f = setmntent ("/etc/fstab", "r");
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while ((mnt = getmntent (f))){
|
while ((mnt = getmntent (f)) != NULL) {
|
||||||
if (strcmp (mnt->mnt_dir, mount_point) != 0){
|
if (strcmp (mnt->mnt_dir, mount_point) != 0) {
|
||||||
|
/* This second test is for compatibility with older
|
||||||
/*
|
* desktops that might be using this.
|
||||||
* This second test is for compatibility with older
|
|
||||||
* desktops that might be using this
|
|
||||||
*/
|
*/
|
||||||
if (strcmp (mnt->mnt_dir, mount_point) != 0)
|
if (strcmp (mnt->mnt_dir, mount_point) != 0)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getuid () == 0){
|
if (getuid () == 0) {
|
||||||
retval = g_strdup (mnt->mnt_dir);
|
retval = g_strdup (mnt->mnt_dir);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (option_has_user (mnt->mnt_opts)){
|
if (option_has_user (mnt->mnt_opts)) {
|
||||||
retval = g_strdup (mnt->mnt_dir);
|
retval = g_strdup (mnt->mnt_dir);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endmntent (f);
|
endmntent (f);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -170,15 +174,16 @@ is_block_device_mounted (char *filename)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
struct mntent *mnt;
|
struct mntent *mnt;
|
||||||
gboolean retval = FALSE;
|
gboolean retval = FALSE;
|
||||||
|
|
||||||
f = setmntent ("/etc/mtab", "r");
|
f = setmntent ("/etc/mtab", "r");
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
while ((mnt = getmntent (f))){
|
while ((mnt = getmntent (f)) != NULL) {
|
||||||
if (strcmp (mnt->mnt_dir, filename) == 0)
|
if (strcmp (mnt->mnt_dir, filename) == 0)
|
||||||
retval = TRUE;
|
retval = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
endmntent (f);
|
endmntent (f);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -189,17 +194,17 @@ get_mountable_devices (void)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
struct mntent *mnt;
|
struct mntent *mnt;
|
||||||
GList *list = NULL;
|
GList *list = NULL;
|
||||||
|
|
||||||
f = setmntent ("/etc/fstab", "r");
|
f = setmntent ("/etc/fstab", "r");
|
||||||
if (f == NULL){
|
if (f == NULL) {
|
||||||
message (1, MSG_ERROR, _("Could not open the /etc/fstab file"));
|
message (1, MSG_ERROR, _("Could not open the /etc/fstab file"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((mnt = getmntent (f))){
|
while ((mnt = getmntent (f)) != NULL) {
|
||||||
if (option_has_user (mnt->mnt_opts)){
|
if (option_has_user (mnt->mnt_opts)) {
|
||||||
devname_info_t *dit;
|
devname_info_t *dit;
|
||||||
|
|
||||||
dit = g_new0 (devname_info_t, 1);
|
dit = g_new0 (devname_info_t, 1);
|
||||||
dit->devname = g_strdup (mnt->mnt_fsname);
|
dit->devname = g_strdup (mnt->mnt_fsname);
|
||||||
dit->mount_point = g_strdup (mnt->mnt_dir);
|
dit->mount_point = g_strdup (mnt->mnt_dir);
|
||||||
|
@ -210,7 +215,7 @@ get_mountable_devices (void)
|
||||||
|
|
||||||
if (strcmp (mnt->mnt_type, "nfs") == 0)
|
if (strcmp (mnt->mnt_type, "nfs") == 0)
|
||||||
dit->type = TYPE_NFS;
|
dit->type = TYPE_NFS;
|
||||||
|
|
||||||
list = g_list_prepend (list, dit);
|
list = g_list_prepend (list, dit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,15 +231,15 @@ mount_point_to_device (char *mount_point)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
struct mntent *mnt;
|
struct mntent *mnt;
|
||||||
|
|
||||||
f = setmntent ("/etc/fstab", "r");
|
f = setmntent ("/etc/fstab", "r");
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while ((mnt = getmntent (f))){
|
while ((mnt = getmntent (f))) {
|
||||||
if (strcmp (mnt->mnt_dir, mount_point) == 0){
|
if (strcmp (mnt->mnt_dir, mount_point) == 0) {
|
||||||
char *v;
|
char *v;
|
||||||
|
|
||||||
v = g_strdup (mnt->mnt_fsname);
|
v = g_strdup (mnt->mnt_fsname);
|
||||||
endmntent (f);
|
endmntent (f);
|
||||||
return v;
|
return v;
|
||||||
|
@ -244,6 +249,8 @@ mount_point_to_device (char *mount_point)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
@ -271,11 +278,20 @@ mount_point_to_device (char *mount_point)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/* Returns whether our supported automounter is running */
|
||||||
* Cleans up the desktop directory from device files
|
static gboolean
|
||||||
*
|
automounter_is_running (void)
|
||||||
* Includes block devices and printers.
|
{
|
||||||
|
/* FIXME: finish this when magicdev is finished */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Cleans up the desktop directory from device files. Includes block devices
|
||||||
|
* and printers.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
desktop_cleanup_devices (void)
|
desktop_cleanup_devices (void)
|
||||||
|
@ -304,19 +320,20 @@ desktop_cleanup_devices (void)
|
||||||
g_free (full_name);
|
g_free (full_name);
|
||||||
}
|
}
|
||||||
gnome_metadata_unlock ();
|
gnome_metadata_unlock ();
|
||||||
|
|
||||||
mc_closedir (dir);
|
mc_closedir (dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Creates the desktop link for the specified device */
|
/* Creates the desktop link for the specified device */
|
||||||
static void
|
static void
|
||||||
create_device_link (char *dev_name, char *short_dev_name, char *caption, char *icon, gboolean ejectable)
|
create_device_link (char *dev_name, char *short_dev_name, char *caption, char *icon,
|
||||||
|
gboolean ejectable)
|
||||||
{
|
{
|
||||||
char *full_name;
|
char *full_name;
|
||||||
char *icon_full;
|
char *icon_full;
|
||||||
char type = 'D';
|
char type = 'D';
|
||||||
char ejectable_c = ejectable;
|
char ejectable_c = ejectable;
|
||||||
|
|
||||||
icon_full = g_concat_dir_and_file (ICONDIR, icon);
|
icon_full = g_concat_dir_and_file (ICONDIR, icon);
|
||||||
full_name = g_concat_dir_and_file (desktop_directory, short_dev_name);
|
full_name = g_concat_dir_and_file (desktop_directory, short_dev_name);
|
||||||
if (mc_symlink (dev_name, full_name) != 0) {
|
if (mc_symlink (dev_name, full_name) != 0) {
|
||||||
|
@ -347,8 +364,10 @@ setup_devices (void)
|
||||||
int cdrom_count;
|
int cdrom_count;
|
||||||
int generic_count;
|
int generic_count;
|
||||||
int nfs_count;
|
int nfs_count;
|
||||||
|
int automounter;
|
||||||
|
|
||||||
list = get_mountable_devices ();
|
list = get_mountable_devices ();
|
||||||
|
automounter = automounter_is_running ();
|
||||||
|
|
||||||
hd_count = 0;
|
hd_count = 0;
|
||||||
cdrom_count = 0;
|
cdrom_count = 0;
|
||||||
|
@ -365,19 +384,28 @@ setup_devices (void)
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
gboolean release_format;
|
gboolean release_format;
|
||||||
gboolean ejectable;
|
gboolean ejectable;
|
||||||
|
gboolean do_create;
|
||||||
|
|
||||||
dev_name = dit->devname;
|
dev_name = dit->devname;
|
||||||
short_dev_name = x_basename (dev_name);
|
short_dev_name = x_basename (dev_name);
|
||||||
|
|
||||||
release_format = FALSE;
|
release_format = FALSE;
|
||||||
ejectable = FALSE;
|
ejectable = FALSE;
|
||||||
|
do_create = TRUE;
|
||||||
|
|
||||||
/* Create the format/icon/count. This could use better heuristics. */
|
/* Create the format/icon/count. This could use better heuristics. */
|
||||||
if (dit->type == TYPE_CDROM){
|
if (dit->type == TYPE_CDROM || strncmp (short_dev_name, "cdrom", 5) == 0) {
|
||||||
format = _("CD-ROM %d");
|
format = _("CD-ROM %d");
|
||||||
icon = "i-cdrom.png";
|
icon = "i-cdrom.png";
|
||||||
count = cdrom_count++;
|
count = cdrom_count++;
|
||||||
ejectable = TRUE;
|
ejectable = TRUE;
|
||||||
|
|
||||||
|
/* If our supported automounter is running, then we can
|
||||||
|
* be nice and create only the links for CD-ROMS that
|
||||||
|
* are actually mounted.
|
||||||
|
*/
|
||||||
|
if (automounter && !is_block_device_mounted (dev_name))
|
||||||
|
do_create = FALSE;
|
||||||
} else if (strncmp (short_dev_name, "fd", 2) == 0) {
|
} else if (strncmp (short_dev_name, "fd", 2) == 0) {
|
||||||
format = _("Floppy %d");
|
format = _("Floppy %d");
|
||||||
icon = "i-floppy.png";
|
icon = "i-floppy.png";
|
||||||
|
@ -388,12 +416,7 @@ setup_devices (void)
|
||||||
format = _("Disk %d");
|
format = _("Disk %d");
|
||||||
icon = "i-blockdev.png";
|
icon = "i-blockdev.png";
|
||||||
count = hd_count++;
|
count = hd_count++;
|
||||||
} else if (strncmp (short_dev_name, "cdrom", 5) == 0){
|
} else if (dit->type == TYPE_NFS) {
|
||||||
format = _("CD-ROM %d");
|
|
||||||
icon = "i-cdrom.png";
|
|
||||||
count = cdrom_count++;
|
|
||||||
ejectable = TRUE;
|
|
||||||
} else if (dit->type == TYPE_NFS){
|
|
||||||
release_format = TRUE;
|
release_format = TRUE;
|
||||||
format = g_strdup_printf (_("NFS dir %s"), dit->mount_point);
|
format = g_strdup_printf (_("NFS dir %s"), dit->mount_point);
|
||||||
icon = "i-nfs.png";
|
icon = "i-nfs.png";
|
||||||
|
@ -405,19 +428,20 @@ setup_devices (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
g_snprintf (buffer, sizeof (buffer), format, count);
|
g_snprintf (buffer, sizeof (buffer), format, count);
|
||||||
if (release_format){
|
if (release_format) {
|
||||||
g_free (format);
|
g_free (format);
|
||||||
format = NULL;
|
format = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the actual link */
|
/* Create the actual link */
|
||||||
|
|
||||||
create_device_link (dit->mount_point, short_dev_name, buffer, icon, ejectable);
|
if (do_create)
|
||||||
|
create_device_link (dit->mount_point, short_dev_name,
|
||||||
|
buffer, icon, ejectable);
|
||||||
|
|
||||||
g_free (dit->devname);
|
g_free (dit->devname);
|
||||||
g_free (dit->mount_point);
|
g_free (dit->mount_point);
|
||||||
g_free (dit);
|
g_free (dit);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free (list);
|
g_list_free (list);
|
||||||
|
@ -428,4 +452,3 @@ gmount_setup_devices (void)
|
||||||
{
|
{
|
||||||
setup_devices ();
|
setup_devices ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue