Commit c2e8c493 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Removed. Removed. Removed.

2007-12-10  Alexander Larsson  <alexl@redhat.com>

        * libnautilus-private/nautilus-directory-async.c:
        * libnautilus-private/nautilus-directory-metafile.[ch]:
        * libnautilus-private/nautilus-metafile.[ch]:
        * libnautilus-private/nautilus-directory-private.h:
        * libnautilus-private/nautilus-directory.c:
        * libnautilus-private/Makefile.am:
        * libnautilus-private/nautilus-directory-metafile-monitor.[ch]: Removed.
        * libnautilus-private/nautilus-metafile-factory.[ch]: Removed.
        * libnautilus-private/nautilus-metafile-server.idl: Removed.
        * src/nautilus-application.c:
        * src/nautilus-main.c:
        * src/nautilus-spatial-window.c:
	Remove the bonobo layer for metadata, as we're always in-process anyway
	these days.


svn path=/trunk/; revision=13515
parent 679a09d2
2007-12-10 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-directory-async.c:
* libnautilus-private/nautilus-directory-metafile.[ch]:
* libnautilus-private/nautilus-metafile.[ch]:
* libnautilus-private/nautilus-directory-private.h:
* libnautilus-private/nautilus-directory.c:
* libnautilus-private/Makefile.am:
* libnautilus-private/nautilus-directory-metafile-monitor.[ch]: Removed.
* libnautilus-private/nautilus-metafile-factory.[ch]: Removed.
* libnautilus-private/nautilus-metafile-server.idl: Removed.
* src/nautilus-application.c:
* src/nautilus-main.c:
* src/nautilus-spatial-window.c:
Remove the bonobo layer for metadata, as we're always in-process anyway
these days.
2007-12-07 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-file.[ch]:
......
......@@ -35,20 +35,12 @@ libnautilus_private_la_LIBADD = \
$(CORE_LIBS) \
$(NULL)
nautilus_metafile_server_idl_sources = \
nautilus-metafile-server-stubs.c \
nautilus-metafile-server-skels.c \
nautilus-metafile-server.h \
nautilus-metafile-server-common.c \
$(NULL)
marshal_sources = \
nautilus-marshal.h \
nautilus-marshal-guts.c \
$(NULL)
libnautilus_private_la_SOURCES = \
$(nautilus_metafile_server_idl_sources) \
nautilus-bookmark.c \
nautilus-bookmark.h \
nautilus-cell-renderer-pixbuf-emblem.c \
......@@ -82,8 +74,6 @@ libnautilus_private_la_SOURCES = \
nautilus-directory-async.c \
nautilus-directory-background.c \
nautilus-directory-background.h \
nautilus-directory-metafile-monitor.c \
nautilus-directory-metafile-monitor.h \
nautilus-directory-metafile.c \
nautilus-directory-metafile.h \
nautilus-directory-notify.h \
......@@ -140,8 +130,6 @@ libnautilus_private_la_SOURCES = \
nautilus-merged-directory.c \
nautilus-merged-directory.h \
nautilus-metadata.h \
nautilus-metafile-factory.c \
nautilus-metafile-factory.h \
nautilus-metafile.c \
nautilus-metafile.h \
nautilus-mime-actions.c \
......@@ -227,17 +215,12 @@ endif
$(lib_LTLIBRARIES): $(dependency_static_libs)
$(nautilus_metafile_server_idl_sources): nautilus_metafile_server_idl_stamp
nautilus_metafile_server_idl_stamp: nautilus-metafile-server.idl $(ORBIT_IDL)
$(ORBIT_IDL) -I$(top_srcdir) $(CORE_IDL_INCLUDES) $<
touch $@
nautilus-marshal.h: nautilus-marshal.list $(GLIB_GENMARSHAL)
$(GLIB_GENMARSHAL) $< --header --prefix=nautilus_marshal > $@
nautilus-marshal-guts.c: nautilus-marshal.list $(GLIB_GENMARSHAL)
$(GLIB_GENMARSHAL) $< --body --prefix=nautilus_marshal > $@
$(libnautilus_private_la_OBJECTS): nautilus_metafile_server_idl_stamp $(marshal_sources)
$(libnautilus_private_la_OBJECTS): $(marshal_sources)
schema_in_files = apps_nautilus_preferences.schemas.in
......@@ -257,7 +240,6 @@ install-data-local:
endif
EXTRA_DIST = \
nautilus-metafile-server.idl \
nautilus-marshal.list \
$(schema_in_files) \
$(BEAGLE_SOURCES) \
......@@ -265,8 +247,6 @@ EXTRA_DIST = \
$(NULL)
CLEANFILES = \
$(nautilus_metafile_server_idl_sources) \
nautilus_metafile_server_idl_stamp \
$(marshal_sources) \
$(schema_DATA) \
$(NULL)
......
......@@ -683,7 +683,7 @@ nautilus_directory_monitor_add_internal (NautilusDirectory *directory,
/* We could just call update_metadata_monitors here, but we can be smarter
* since we know what monitor was just added.
*/
if (monitor->request.metafile && directory->details->metafile_monitor == NULL) {
if (monitor->request.metafile && !directory->details->metafile_monitored) {
nautilus_directory_register_metadata_monitor (directory);
}
......@@ -1066,13 +1066,13 @@ update_metadata_monitors (NautilusDirectory *directory)
is_metadata_monitored = is_anyone_waiting_for_metafile (directory);
if (directory->details->metafile_monitor == NULL) {
if (!directory->details->metafile_monitored) {
if (is_metadata_monitored) {
nautilus_directory_register_metadata_monitor (directory);
nautilus_directory_register_metadata_monitor (directory);
}
} else {
if (!is_metadata_monitored) {
nautilus_directory_unregister_metadata_monitor (directory);
nautilus_directory_unregister_metadata_monitor (directory);
}
}
}
......@@ -1298,7 +1298,7 @@ nautilus_directory_call_when_ready_internal (NautilusDirectory *directory,
* We could just call update_metadata_monitors here, but we can be smarter
* since we know what was just added.
*/
if (callback.request.metafile && directory->details->metafile_monitor == NULL) {
if (callback.request.metafile && !directory->details->metafile_monitored) {
nautilus_directory_register_metadata_monitor (directory);
}
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-directory-metafile-monitor.c
*
* Copyright (C) 2001 Eazel, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include "nautilus-directory-metafile-monitor.h"
#include "nautilus-directory-private.h"
#include "nautilus-file-private.h"
#include <eel/eel-gtk-macros.h>
#include <eel/eel-glib-extensions.h>
struct NautilusMetafileMonitorDetails {
NautilusDirectory *directory;
};
BONOBO_CLASS_BOILERPLATE_FULL (NautilusMetafileMonitor, nautilus_metafile_monitor,
Nautilus_MetafileMonitor,
BonoboObject, BONOBO_OBJECT_TYPE)
static void
nautilus_metafile_monitor_instance_init (NautilusMetafileMonitor *monitor)
{
monitor->details = g_new0 (NautilusMetafileMonitorDetails, 1);
}
static void
finalize (GObject *object)
{
NautilusMetafileMonitor *monitor;
monitor = NAUTILUS_METAFILE_MONITOR (object);
g_free (monitor->details);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
NautilusMetafileMonitor *
nautilus_metafile_monitor_new (NautilusDirectory *directory)
{
NautilusMetafileMonitor *monitor;
monitor = NAUTILUS_METAFILE_MONITOR (g_object_new (NAUTILUS_TYPE_METAFILE_MONITOR, NULL));
monitor->details->directory = directory;
/* The monitor is owned by the directory, so we don't ref the directory. */
return monitor;
}
static void
corba_metafile_changed (PortableServer_Servant servant,
const Nautilus_FileNameList *file_names,
CORBA_Environment *ev)
{
GList *file_list;
NautilusFile *file;
CORBA_unsigned_long buf_pos;
NautilusMetafileMonitor *monitor;
monitor = NAUTILUS_METAFILE_MONITOR (bonobo_object_from_servant (servant));
file_list = NULL;
for (buf_pos = 0; buf_pos < file_names->_length; ++buf_pos) {
file = nautilus_directory_find_file_by_internal_filename
(monitor->details->directory, file_names->_buffer [buf_pos]);
if (file != NULL) {
if (nautilus_file_is_self_owned (file)) {
nautilus_file_emit_changed (file);
} else {
file_list = g_list_prepend (file_list, file);
}
}
}
if (file_list != NULL) {
file_list = g_list_reverse (file_list);
nautilus_directory_emit_change_signals (monitor->details->directory, file_list);
g_list_free (file_list);
}
}
static void
corba_metafile_ready (PortableServer_Servant servant,
CORBA_Environment *ev)
{
NautilusMetafileMonitor *monitor;
monitor = NAUTILUS_METAFILE_MONITOR (bonobo_object_from_servant (servant));
emit_change_signals_for_all_files (monitor->details->directory);
nautilus_idle_queue_add (monitor->details->directory->details->idle_queue,
(GFunc) nautilus_directory_async_state_changed,
monitor->details->directory,
NULL,
NULL);
}
static void
nautilus_metafile_monitor_class_init (NautilusMetafileMonitorClass *klass)
{
G_OBJECT_CLASS (klass)->finalize = finalize;
klass->epv.metafile_changed = corba_metafile_changed;
klass->epv.metafile_ready = corba_metafile_ready;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */
/* nautilus-directory-metafile-monitor.h
*
* Copyright (C) 2001 Eazel, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef NAUTILUS_METAFILE_MONITOR_H
#define NAUTILUS_METAFILE_MONITOR_H
#include <bonobo/bonobo-object.h>
#include <libnautilus-private/nautilus-directory.h>
#include <libnautilus-private/nautilus-metafile-server.h>
#define NAUTILUS_TYPE_METAFILE_MONITOR (nautilus_metafile_monitor_get_type ())
#define NAUTILUS_METAFILE_MONITOR(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_METAFILE_MONITOR, NautilusMetafileMonitor))
#define NAUTILUS_METAFILE_MONITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_METAFILE_MONITOR, NautilusMetafileMonitorClass))
#define NAUTILUS_IS_METAFILE_MONITOR(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_METAFILE_MONITOR))
#define NAUTILUS_IS_METAFILE_MONITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_METAFILE_MONITOR))
typedef struct NautilusMetafileMonitorDetails NautilusMetafileMonitorDetails;
typedef struct {
BonoboObject parent_slot;
NautilusMetafileMonitorDetails *details;
} NautilusMetafileMonitor;
typedef struct {
BonoboObjectClass parent_slot;
POA_Nautilus_MetafileMonitor__epv epv;
} NautilusMetafileMonitorClass;
GType nautilus_metafile_monitor_get_type (void);
NautilusMetafileMonitor *nautilus_metafile_monitor_new (NautilusDirectory *directory);
#endif /* NAUTILUS_METAFILE_MONITOR_H */
......@@ -26,167 +26,42 @@
#include <config.h>
#include "nautilus-directory-metafile.h"
#include "nautilus-directory-metafile-monitor.h"
#include "nautilus-directory-private.h"
#include "nautilus-metafile-factory.h"
#include "nautilus-metafile-server.h"
#include <bonobo-activation/bonobo-activation.h>
#include "nautilus-file-private.h"
#include "nautilus-metafile.h"
#include <eel/eel-debug.h>
#include <eel/eel-string.h>
#include <stdio.h>
static Nautilus_MetafileFactory factory = CORBA_OBJECT_NIL;
/* We disable the remote metafile factory, because there seems to be some
* sort of races with bonobo activation that sometimes leads to crashes
* like in bug #351713. This isn't really a problem anyway, since nautilus
* is only one process these days, and we still use bonobo activation to
* avoid starting multiple copies of it.
*/
static gboolean get_factory_from_oaf = FALSE;
void
nautilus_directory_use_self_contained_metafile_factory (void)
{
g_return_if_fail (factory == CORBA_OBJECT_NIL);
get_factory_from_oaf = FALSE;
}
static void
free_factory (void)
{
CORBA_Object_release (factory, NULL);
factory = CORBA_OBJECT_NIL;
}
static void
die_on_failed_activation (const char *server_name,
CORBA_Environment *ev)
{
/* This isn't supposed to happen. So do some core-dumping
* action, and don't bother translating the error message.
*/
const char *details;
Bonobo_GeneralError *general_error;
switch (ev->_major) {
case CORBA_NO_EXCEPTION:
details = "got NIL but no exception";
break;
case CORBA_SYSTEM_EXCEPTION:
case CORBA_USER_EXCEPTION:
details = CORBA_exception_id (ev);
if (strcmp (details, "IDL:Bonobo/GeneralError:1.0") == 0) {
general_error = CORBA_exception_value (ev);
details = general_error->description;
}
break;
default:
details = "got bad exception";
break;
}
g_error ("Failed to activate the server %s; this may indicate a broken\n"
"Nautilus or Bonobo installation, or may reflect a bug in something,\n"
"or may mean that your PATH or LD_LIBRARY_PATH or the like is\n"
"incorrect. Nautilus will dump core and exit.\n"
"Details: '%s'", server_name, details);
}
static Nautilus_MetafileFactory
get_factory (void)
{
CORBA_Environment ev;
if (factory == CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
if (get_factory_from_oaf) {
factory = bonobo_activation_activate_from_id (METAFILE_FACTORY_IID, 0, NULL, &ev);
if (ev._major != CORBA_NO_EXCEPTION || factory == CORBA_OBJECT_NIL) {
die_on_failed_activation ("Nautilus_MetafileFactory", &ev);
}
} else {
factory = CORBA_Object_duplicate
(BONOBO_OBJREF (nautilus_metafile_factory_get_instance ()), &ev);
}
CORBA_exception_free (&ev);
eel_debug_call_at_shutdown (free_factory);
}
return factory;
}
static Nautilus_Metafile
open_metafile (const char *uri, gboolean make_errors_fatal)
{
Nautilus_Metafile metafile;
CORBA_Environment ev;
CORBA_exception_init (&ev);
metafile = Nautilus_MetafileFactory_open (get_factory (), uri, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
metafile = CORBA_OBJECT_NIL;
if (make_errors_fatal) {
g_error ("%s: CORBA error opening MetafileFactory: %s",
g_get_prgname (),
CORBA_exception_id (&ev));
}
}
CORBA_exception_free (&ev);
return metafile;
}
static Nautilus_Metafile
static NautilusMetafile *
get_metafile (NautilusDirectory *directory)
{
char *uri;
if (directory->details->metafile_corba_object == CORBA_OBJECT_NIL) {
if (directory->details->metafile == NULL) {
uri = nautilus_directory_get_uri (directory);
directory->details->metafile_corba_object = open_metafile (uri, FALSE);
directory->details->metafile = nautilus_metafile_get_for_uri (uri);
g_free (uri);
}
return directory->details->metafile_corba_object;
return directory->details->metafile;
}
gboolean
nautilus_directory_is_metadata_read (NautilusDirectory *directory)
{
CORBA_Environment ev;
gboolean result;
Nautilus_Metafile metafile;
NautilusMetafile *metafile;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
CORBA_exception_init (&ev);
metafile = get_metafile (directory);
if (metafile == CORBA_OBJECT_NIL) {
if (metafile == NULL) {
return TRUE;
}
result = Nautilus_Metafile_is_read (metafile, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
result = TRUE;
g_debug ("CORBA exception when determining whether metafile is read: %s",
CORBA_exception_id (&ev));
}
CORBA_exception_free (&ev);
return result;
return nautilus_metafile_is_read (metafile);
}
char *
......@@ -195,49 +70,15 @@ nautilus_directory_get_file_metadata (NautilusDirectory *directory,
const char *key,
const char *default_metadata)
{
CORBA_Environment ev;
char *result;
const char *non_null_default;
CORBA_char *corba_value;
Nautilus_Metafile metafile;
NautilusMetafile *metafile;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), g_strdup (default_metadata));
g_return_val_if_fail (!eel_str_is_empty (file_name), g_strdup (default_metadata));
g_return_val_if_fail (!eel_str_is_empty (key), g_strdup (default_metadata));
/* We can't pass NULL as a CORBA_string - pass "" instead. */
non_null_default = default_metadata != NULL ? default_metadata : "";
CORBA_exception_init (&ev);
metafile = get_metafile (directory);
if (metafile == CORBA_OBJECT_NIL) {
return g_strdup (default_metadata);
}
corba_value = Nautilus_Metafile_get (metafile, file_name, key, non_null_default, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_debug ("CORBA exception when getting file metadata: %s", CORBA_exception_id (&ev));
CORBA_exception_free (&ev);
return g_strdup (default_metadata);
}
CORBA_exception_free (&ev);
if (eel_str_is_empty (corba_value)) {
/* Even though in all other respects we treat "" as NULL, we want to
* make sure the caller gets back the same default that was passed in.
*/
result = g_strdup (default_metadata);
} else {
result = g_strdup (corba_value);
}
CORBA_free (corba_value);
return result;
return nautilus_metafile_get (metafile, file_name, key, default_metadata);
}
GList *
......@@ -246,11 +87,7 @@ nautilus_directory_get_file_metadata_list (NautilusDirectory *directory,
const char *list_key,
const char *list_subkey)
{
CORBA_Environment ev;
GList *result;
Nautilus_MetadataList *corba_value;
CORBA_unsigned_long buf_pos;
Nautilus_Metafile metafile;
NautilusMetafile * metafile;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
g_return_val_if_fail (!eel_str_is_empty (file_name), NULL);
......@@ -258,30 +95,7 @@ nautilus_directory_get_file_metadata_list (NautilusDirectory *directory,
g_return_val_if_fail (!eel_str_is_empty (list_subkey), NULL);
metafile = get_metafile (directory);
if (metafile == CORBA_OBJECT_NIL) {
return NULL;
}
CORBA_exception_init (&ev);
corba_value = Nautilus_Metafile_get_list (metafile, file_name, list_key, list_subkey, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_debug ("Failed to get metafile list: %s\n", CORBA_exception_id (&ev));
CORBA_exception_free (&ev);
return NULL;
}
CORBA_exception_free (&ev);
result = NULL;
for (buf_pos = 0; buf_pos < corba_value->_length; ++buf_pos) {
result = g_list_prepend (result, g_strdup (corba_value->_buffer [buf_pos]));
}
result = g_list_reverse (result);
CORBA_free (corba_value);
return result;
return nautilus_metafile_get_list (metafile, file_name, list_key, list_subkey);
}
void
......@@ -291,37 +105,14 @@ nautilus_directory_set_file_metadata (NautilusDirectory *directory,
const char *default_metadata,
const char *metadata)
{
CORBA_Environment ev;
Nautilus_Metafile metafile;
NautilusMetafile *metafile;
g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory));
g_return_if_fail (!eel_str_is_empty (file_name));
g_return_if_fail (!eel_str_is_empty (key));
metafile = get_metafile (directory);
if (metafile == CORBA_OBJECT_NIL) {
return;
}
/* We can't pass NULL as a CORBA_string - pass "" instead.
*/
if (default_metadata == NULL) {
default_metadata = "";
}
if (metadata == NULL) {
metadata = "";
}
CORBA_exception_init (&ev);
Nautilus_Metafile_set (metafile, file_name, key, default_metadata, metadata, &ev);