Re: [Evolution-hackers] evolution plugins/extensions



Hello,

> > Sent this yesterday but it never seemed to send...
> > 
> > I was wondering if it was possible to write "plugins/extensions" for 
> > evolution ( either the 1.4.x series or 1.5.x ).
> > 
> > At work we currently have a product that plugs into Microsoft outlook, 
> > adding an item on the toolbar for sending SMS messages, showing an 
> > addressbook that contains a filtered list of contacts that have mobile 
> > phones listed.
> > 
> > Also, if such extensions can be written, do they have to be written in C ? 
> > Or could one write an extension in C#/Mono or language-of-choice ( I'm 
> > assuming anything that could create a Bonobo component? )
> 
> I know miguel has been experimenting with stuff like this.  Chris also
> did some work embedding a component in evo.  Not sure how advanced this
> is yet.

I found a nice way of doing this without having to touch Evolution, you
have to use the --load-modules option, the following illustrates this:

Compile like this:

	gcc -shared -fPIC module.c `pkg-config --libs --cflags mono` -o libdemo.so
	mcs demo.cs
	cp demo.exe /tmp

	cp libdemo.so /usr/lib
	/sbin/ldconfig

Then pick a Gnome app, any, say gnome-stones:

	GTK_MODULES=module gnome-stones

That will give you a greeting from C# code.

That shows the basics, the problem is that we need to transfer control
back to C, so you will want to install your hooks there to be called back.

One hack I have used is to use g_signal_add_emission_hook for
interesting Gtk+ signals, one that will be triggered by the time you
are ready.  For example I have used "add" on Container to catch and
monitor all adds and when I find a menu, I can hook it up ;-)

Miguel.
#include <mono/jit/jit.h>
#include <mono/metadata/environment.h>

/*
 * Very simple mono embedding example.
 * Compile with: 
 * 	gcc -o teste teste.c `pkg-config --cflags --libs mono` -lm
 * 	mcs test.cs
 * Run with:
 * 	./teste test.exe
 */

static MonoString*
gimme () {
	return mono_string_new (mono_domain_get (), "All your monos are belong to us!");
}

typedef struct
{
	MonoDomain *domain;
	const char *file;
	int argc;
	char **argv;
} MainThreadArgs;

static void main_thread_handler (gpointer user_data)
{
	MainThreadArgs *main_args=(MainThreadArgs *)user_data;
	MonoAssembly *assembly;

	assembly = mono_domain_assembly_open (main_args->domain,
					      main_args->file);
	if (!assembly)
		exit (2);
	/*
	 * mono_jit_exec() will run the Main() method in the assembly.
	 * The return value needs to be looked up from
	 * System.Environment.ExitCode.
	 */
	mono_jit_exec (main_args->domain, assembly, main_args->argc,
		       main_args->argv);
}

int xmain ()
{
	MonoDomain *domain;
	const char *file;
	int retval;
	MainThreadArgs main_args;
	char *av [] = { "program" };
	
	domain = mono_jit_init ("/tmp/demo.exe");
	main_args.domain=domain;
	main_args.file="/tmp/demo.exe";
	main_args.argc=0;
	main_args.argv=av;
	
	mono_runtime_exec_managed_code (domain, main_thread_handler, &main_args);
	
	retval=mono_environment_exitcode_get ();
	
	mono_jit_cleanup (domain);
	return retval;
}


int gtk_module_init ()
{
	xmain ();
}
using System;
using System.Threading;

class X {
	static void Main ()
	{
		Console.WriteLine ("Welcome to Mono");
	}
}
	


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