diff options
-rw-r--r-- | shell/ChangeLog | 17 | ||||
-rw-r--r-- | shell/Evolution-ShellComponent.idl | 2 | ||||
-rw-r--r-- | shell/evolution-shell-component-client.c | 5 | ||||
-rw-r--r-- | shell/evolution-shell-component.c | 35 | ||||
-rw-r--r-- | shell/evolution-shell-component.h | 1 | ||||
-rw-r--r-- | shell/main.c | 18 |
6 files changed, 77 insertions, 1 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 26130ec536..c907c631b5 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,20 @@ +2001-03-30 Dan Winship <danw@ximian.com> + + * Evolution-ShellComponent.idl: add a "debug" method to tell a + component to output debugging messages to a given file. + + * main.c (main): Add a "--debug filename" argument, to direct + debugging output for all components to a file. Redirect the + shell's stdout/stderr to that file if this argument is used. + + * evolution-shell-component-client.c + (evolution_shell_component_client_set_owner): If debug_log is set, + call the component's debug method as well. + + * evolution-shell-component.c (impl_ShellComponent_debug): + redirect stdout/stderr to the named file and emit a "debug" + signal. + 2001-03-29 Kjartan Maraas <kmaraas@gnome.org> * e-component-registry.c: Remove/replace unneeded includes and diff --git a/shell/Evolution-ShellComponent.idl b/shell/Evolution-ShellComponent.idl index 29776b49d0..33d52e8145 100644 --- a/shell/Evolution-ShellComponent.idl +++ b/shell/Evolution-ShellComponent.idl @@ -40,6 +40,8 @@ module Evolution { void unsetOwner () raises (NotOwned); + void debug (in string log_path); + /* FIXME: We might want more exceptions here. */ exception NotFound {}; exception UnsupportedType {}; diff --git a/shell/evolution-shell-component-client.c b/shell/evolution-shell-component-client.c index 7f35d8571f..1a4ba17916 100644 --- a/shell/evolution-shell-component-client.c +++ b/shell/evolution-shell-component-client.c @@ -38,6 +38,8 @@ #include "evolution-shell-component-client.h" +extern char *debug_log; + #define PARENT_TYPE BONOBO_OBJECT_CLIENT_TYPE static BonoboObjectClass *parent_class = NULL; @@ -471,6 +473,9 @@ evolution_shell_component_client_set_owner (EvolutionShellComponentClient *shell result = corba_exception_to_result (&ev); + if (result == EVOLUTION_SHELL_COMPONENT_OK && debug_log) + GNOME_Evolution_ShellComponent_debug (bonobo_object_corba_objref (BONOBO_OBJECT (shell_component_client)), debug_log, &ev); + CORBA_exception_free (&ev); return result; diff --git a/shell/evolution-shell-component.c b/shell/evolution-shell-component.c index d76b28a9ae..c29b3b00b7 100644 --- a/shell/evolution-shell-component.c +++ b/shell/evolution-shell-component.c @@ -25,6 +25,8 @@ #include <config.h> #endif +#include <fcntl.h> + #include <gtk/gtksignal.h> #include <bonobo/bonobo-object.h> @@ -57,6 +59,7 @@ struct _EvolutionShellComponentPrivate { enum { OWNER_SET, OWNER_UNSET, + DEBUG, LAST_SIGNAL }; @@ -215,6 +218,29 @@ impl_ShellComponent_unset_owner (PortableServer_Servant servant, gtk_signal_emit (GTK_OBJECT (shell_component), signals[OWNER_UNSET]); } +static void +impl_ShellComponent_debug (PortableServer_Servant servant, + const CORBA_char *log_path, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + EvolutionShellComponent *shell_component; + int fd; + + bonobo_object = bonobo_object_from_servant (servant); + shell_component = EVOLUTION_SHELL_COMPONENT (bonobo_object); + + fd = open (log_path, O_WRONLY | O_APPEND); + if (!fd) + return; + + dup2 (fd, STDOUT_FILENO); + dup2 (fd, STDERR_FILENO); + close (fd); + + gtk_signal_emit (GTK_OBJECT (shell_component), signals[DEBUG]); +} + static Bonobo_Control impl_ShellComponent_create_view (PortableServer_Servant servant, const CORBA_char *physical_uri, @@ -436,6 +462,14 @@ class_init (EvolutionShellComponentClass *klass) gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); + signals[DEBUG] + = gtk_signal_new ("debug", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EvolutionShellComponentClass, debug), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); parent_class = gtk_type_class (PARENT_TYPE); @@ -443,6 +477,7 @@ class_init (EvolutionShellComponentClass *klass) epv->_get_supported_types = impl_ShellComponent__get_supported_types; epv->setOwner = impl_ShellComponent_set_owner; epv->unsetOwner = impl_ShellComponent_unset_owner; + epv->debug = impl_ShellComponent_debug; epv->createView = impl_ShellComponent_create_view; epv->createFolderAsync = impl_ShellComponent_async_create_folder; epv->removeFolderAsync = impl_ShellComponent_async_remove_folder; diff --git a/shell/evolution-shell-component.h b/shell/evolution-shell-component.h index 3248ca9e36..2b98b623ce 100644 --- a/shell/evolution-shell-component.h +++ b/shell/evolution-shell-component.h @@ -129,6 +129,7 @@ struct _EvolutionShellComponentClass { EvolutionShellClient *shell_client, const char *evolution_homedir); void (* owner_unset) (EvolutionShellComponent *shell_component); + void (* debug) (EvolutionShellComponent *shell_component); }; diff --git a/shell/main.c b/shell/main.c index c111b9faf1..dce135d9d9 100644 --- a/shell/main.c +++ b/shell/main.c @@ -22,6 +22,7 @@ */ #include <config.h> +#include <fcntl.h> #include <glib.h> #include <gtk/gtkmain.h> #include <gtk/gtklabel.h> @@ -50,6 +51,7 @@ static EShell *shell = NULL; static char *evolution_directory = NULL; static gboolean no_splash = FALSE; +char *debug_log = NULL; static void @@ -180,7 +182,8 @@ int main (int argc, char **argv) { struct poptOption options[] = { - { "no-splash", '\0', POPT_ARG_NONE, &no_splash, 0, N_("Disable."), NULL }, + { "no-splash", '\0', POPT_ARG_NONE, &no_splash, 0, N_("Disable splash screen"), NULL }, + { "debug", '\0', POPT_ARG_STRING, &debug_log, 0, N_("Send the debugging output of all components to a file."), NULL }, { NULL, '\0', POPT_ARG_INCLUDE_TABLE, &oaf_popt_options, 0, NULL, NULL }, POPT_AUTOHELP { NULL, '\0', 0, NULL, 0, NULL, NULL } @@ -190,6 +193,19 @@ main (int argc, char **argv) textdomain (PACKAGE); gnome_init_with_popt_table ("Evolution", VERSION, argc, argv, options, 0, NULL); + + if (debug_log) { + int fd; + + fd = open (debug_log, O_WRONLY | O_CREAT | O_TRUNC, 0600); + if (fd) { + dup2 (fd, STDOUT_FILENO); + dup2 (fd, STDERR_FILENO); + close (fd); + } else + g_warning ("Could not set up debugging output file."); + } + oaf_init (argc, argv); glade_gnome_init (); |