[Evolution-hackers] Patch for evolution-component export



Currently the shell interfaces are kind of useless, you can't do
anything but invoke a uri.

This patch adds a couple of things:
 - a method to Shell which lets you find a component by component alias,
i.e. findComponent("mail") will find the mail component.
 - an abstract bonobo object EvolutionComponent ... so that components
can subclass it
 - an example of extending the MailComponent with new interfaces which
can then be accessed by an external application (which currently does
nothing and isn't hooked up either).

Why?  Particularly if we're trying to move away from Bonobo for
components?

Well, this way additional scriptable functionality could be added to
each component on a per-component basis, and this provides a way to
access those components directly through CORBA.

e.g. it could be used to access the remote mail api object in a method
better than reading an ior from a file

it could be used to add remote interactive mail functions, like
presenting a composer, etc.

Plugins could add additional interfaces at run-time which could be
accessed remotely.

It is more fine-grained than doing everything through a uri.

Anyway, just an idea, not sure on committing it yet.  Would anyone find
this useful?


Index: mail/Evolution-Mail.idl
===================================================================
RCS file: mail/Evolution-Mail.idl
diff -N mail/Evolution-Mail.idl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mail/Evolution-Mail.idl	26 May 2005 10:42:41 -0000
@@ -0,0 +1,9 @@
+#include <shell/Evolution-Component.idl>
+
+module GNOME {
+module Evolution {
+	interface MailComponent : Component {
+		void test();
+	};
+};
+};
Index: mail/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/mail/Makefile.am,v
retrieving revision 1.262
diff -u -p -r1.262 Makefile.am
--- mail/Makefile.am	16 May 2005 07:53:53 -0000	1.262
+++ mail/Makefile.am	26 May 2005 10:42:42 -0000
@@ -51,6 +51,24 @@ $(SPELL_IDL_GENERATED_C): $(SPELL_IDL_GE
 
 Spell-impl.o: Spell.h
 
+# Mail.idl
+MAIL_IDL = Evolution-Mail.idl
+MAIL_IDL_GENERATED_H = 		\
+	Evolution-Mail.h
+MAIL_IDL_GENERATED_C = 		\
+	Evolution-Mail-common.c		\
+	Evolution-Mail-skels.c		\
+	Evolution-Mail-stubs.c
+MAIL_IDL_GENERATED = $(MAIL_IDL_GENERATED_C) $(MAIL_IDL_GENERATED_H)
+
+$(MAIL_IDL_GENERATED_H): $(MAIL_IDL)
+	$(ORBIT_IDL) -I $(top_srcdir) -I $(datadir)/idl $(IDL_INCLUDES) $^
+$(MAIL_IDL_GENERATED_C): $(MAIL_IDL_GENERATED_H)
+
+# IDL install
+
+idl_DATA = $(MAIL_IDL)
+
 # plugin mail api
 mailinclude_HEADERS =				\
 	em-composer-utils.h			\
@@ -91,6 +109,7 @@ mailinclude_HEADERS =				\
 
 libevolution_mail_la_SOURCES =			\
 	$(SPELL_IDL_GENERATED)			\
+	$(MAIL_IDL_GENERATED)			\
 	$(MARSHAL_GENERATED)			\
 	$(mailinclude_HEADERS)			\
 	e-searching-tokenizer.c			\
@@ -246,6 +265,7 @@ EXTRA_DIST = 				\
 	ChangeLog.pre-1-4		\
 	em-marshal.list			\
 	$(SPELL_IDL)			\
+	$(MAIL_IDL)			\
 	mail.error.xml			\
 	$(glade_DATA)			\
 	$(schema_in_files)		\
@@ -293,6 +313,6 @@ install-data-local:
 dist-hook:
 	cd $(distdir); rm -f $(BUILT_SOURCES)
 
-BUILT_SOURCES = $(SPELL_IDL_GENERATED) $(MARSHAL_GENERATED) $(server_DATA) $(error_DATA)
+BUILT_SOURCES = $(SPELL_IDL_GENERATED) $(MAIL_IDL_GENERATED) $(MARSHAL_GENERATED) $(server_DATA) $(error_DATA)
 
 CLEANFILES = $(BUILT_SOURCES)
Index: mail/mail-component.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-component.c,v
retrieving revision 1.115
diff -u -p -r1.115 mail-component.c
--- mail/mail-component.c	24 May 2005 18:23:22 -0000	1.115
+++ mail/mail-component.c	26 May 2005 10:42:42 -0000
@@ -89,7 +89,7 @@ static void create_local_item_cb(EUserCr
 
 #define MAIL_COMPONENT_DEFAULT(mc) if (mc == NULL) mc = mail_component_peek();
 
-#define PARENT_TYPE bonobo_object_get_type ()
+#define PARENT_TYPE evolution_component_get_type ()
 static BonoboObjectClass *parent_class = NULL;
 
 struct _store_info {	
@@ -865,7 +865,8 @@ impl_upgradeFromVersion (PortableServer_
 static void
 mail_component_class_init (MailComponentClass *class)
 {
-	POA_GNOME_Evolution_Component__epv *epv = &class->epv;
+	POA_GNOME_Evolution_Component__epv *epv = &((EvolutionComponentClass *)class)->epv;
+	POA_GNOME_Evolution_MailComponent__epv *mepv = &class->epv;
 	GObjectClass *object_class = G_OBJECT_CLASS (class);
 	
 	parent_class = g_type_class_peek_parent (class);
@@ -881,6 +882,8 @@ mail_component_class_init (MailComponent
 	epv->handleURI               = impl_handleURI;
 	epv->sendAndReceive          = impl_sendAndReceive;
 	epv->upgradeFromVersion      = impl_upgradeFromVersion;
+
+	mepv = mepv;
 }
 
 static void
Index: mail/mail-component.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-component.h,v
retrieving revision 1.14
diff -u -p -r1.14 mail-component.h
--- mail/mail-component.h	20 May 2005 13:13:27 -0000	1.14
+++ mail/mail-component.h	26 May 2005 10:42:42 -0000
@@ -27,8 +27,8 @@
 #define _MAIL_COMPONENT_H_
 
 #include <bonobo/bonobo-object.h>
-
-#include "shell/Evolution.h"
+#include "shell/evolution-component.h"
+#include "Evolution-Mail.h"
 
 struct _CamelStore;
 
@@ -51,15 +51,15 @@ enum _mail_component_folder_t {
 };
 
 struct _MailComponent {
-	BonoboObject parent;
+	EvolutionComponent parent;
 	
 	MailComponentPrivate *priv;
 };
 
 struct _MailComponentClass {
-	BonoboObjectClass parent_class;
+	EvolutionComponentClass parent_class;
 	
-	POA_GNOME_Evolution_Component__epv epv;
+	POA_GNOME_Evolution_MailComponent__epv epv;
 };
 
 GType  mail_component_get_type  (void);
Index: shell/Evolution-Shell.idl
===================================================================
RCS file: /cvs/gnome/evolution/shell/Evolution-Shell.idl,v
retrieving revision 1.26
diff -u -p -r1.26 Evolution-Shell.idl
--- shell/Evolution-Shell.idl	10 Jan 2005 02:35:12 -0000	1.26
+++ shell/Evolution-Shell.idl	26 May 2005 10:42:42 -0000
@@ -48,6 +48,12 @@ module Evolution {
 		 */
 		void setLineStatus (in boolean online)
 			raises (NotReady);
+
+		/*
+		 * Lookup a component by id.
+		 */
+		Component findComponent(in string id)
+			raises (NotReady, ComponentNotFound);
 	};
 };
 };
Index: shell/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/shell/Makefile.am,v
retrieving revision 1.206
diff -u -p -r1.206 Makefile.am
--- shell/Makefile.am	16 May 2005 06:17:41 -0000	1.206
+++ shell/Makefile.am	26 May 2005 10:42:42 -0000
@@ -80,11 +80,13 @@ eshellinclude_HEADERS = 			\
 	e-shell-utils.h				\
 	e-user-creatable-items-handler.h	\
 	evolution-config-control.h		\
+	evolution-component.h			\
 	evolution-shell-component-utils.h
 
 libeshell_la_SOURCES = 				\
 	$(IDL_GENERATED)			\
 	$(MARSHAL_GENERATED)			\
+	evolution-component.c			\
 	e-shell-utils.c				\
 	e-user-creatable-items-handler.c	\
 	evolution-config-control.c		\
Index: shell/e-shell.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell.c,v
retrieving revision 1.263
diff -u -p -r1.263 e-shell.c
--- shell/e-shell.c	16 May 2005 06:17:42 -0000	1.263
+++ shell/e-shell.c	26 May 2005 10:42:42 -0000
@@ -305,6 +305,30 @@ impl_Shell_setLineStatus (PortableServer
 		e_shell_go_offline (shell, NULL);
 }
 
+static GNOME_Evolution_Component
+impl_Shell_findComponent(PortableServer_Servant servant,
+			 const CORBA_string id,
+			 CORBA_Environment *ev)
+{
+	EShell *shell;
+	EComponentInfo *ci;
+
+	if (raise_exception_if_not_ready (servant, ev))
+		return CORBA_OBJECT_NIL;
+
+	shell = (EShell *)bonobo_object_from_servant (servant);
+	ci = e_component_registry_peek_info(shell->priv->component_registry, ECR_FIELD_ALIAS, id);
+	if (ci == NULL) {
+		CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_ComponentNotFound, NULL);
+		return CORBA_OBJECT_NIL;
+	} else if (ci->iface == NULL) {
+		CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_NotReady, NULL);
+		return CORBA_OBJECT_NIL;
+	} else {
+		return ci->iface;
+	}
+}
+
 
 /* EShellWindow handling and bookkeeping.  */
 
@@ -491,6 +515,7 @@ e_shell_class_init (EShellClass *klass)
 	epv->createNewWindow = impl_Shell_createNewWindow;
 	epv->handleURI       = impl_Shell_handleURI;
 	epv->setLineStatus   = impl_Shell_setLineStatus;
+	epv->findComponent   = impl_Shell_findComponent;
 }
 
 static void
Index: shell/evolution-component.c
===================================================================
RCS file: shell/evolution-component.c
diff -N shell/evolution-component.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ shell/evolution-component.c	26 May 2005 10:42:42 -0000
@@ -0,0 +1,47 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* 
+ * Copyright (C) 2005  Novell, Inc.
+ *
+ * Authors: Michael Zucchi <notzed novell com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "evolution-component.h"
+
+#define PARENT_TYPE bonobo_object_get_type ()
+
+static BonoboObjectClass *parent_class = NULL;
+
+/* Evolution.Component */
+
+/* Initialization */
+
+static void
+evolution_component_class_init (EvolutionComponentClass *klass)
+{
+	parent_class = g_type_class_peek_parent (klass);
+}
+
+static void
+evolution_component_init(EvolutionComponent *emf, EvolutionComponentClass *klass)
+{
+}
+
+BONOBO_TYPE_FUNC_FULL (EvolutionComponent, GNOME_Evolution_Component, PARENT_TYPE, evolution_component)
Index: shell/evolution-component.h
===================================================================
RCS file: shell/evolution-component.h
diff -N shell/evolution-component.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ shell/evolution-component.h	26 May 2005 10:42:42 -0000
@@ -0,0 +1,45 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Copyright (C) 2005  Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Michael Zucchi <notzed novell com>
+ *
+ * Abstract class wrapper for EvolutionComponent
+ */
+
+#ifndef _EVOLUTION_COMPONENT_H_
+#define _EVOLUTION_COMPONENT_H_
+
+#include <bonobo/bonobo-object.h>
+#include "Evolution.h"
+
+typedef struct _EvolutionComponent        EvolutionComponent;
+typedef struct _EvolutionComponentClass   EvolutionComponentClass;
+
+struct _EvolutionComponent {
+	BonoboObject parent;
+};
+
+struct _EvolutionComponentClass {
+	BonoboObjectClass parent_class;
+
+	POA_GNOME_Evolution_Component__epv epv;
+};
+
+GType           evolution_component_get_type(void);
+
+#endif /* _EVOLUTION_COMPONENT_H_ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]