All pastes #777649 Raw Edit

DBus Test

public text v1 · immutable
·published 2007-11-16 22:53 UTC
rendered paste body
// project created on 11/16/2007 at 3:01 PM
using System;
using NDesk.DBus;
using org.freedesktop.DBus;

namespace mono_tomboy
{
	[Interface("org.gnome.Tomboy.RemoteControl")]
	public interface ITboy
	{
	    string Version();
	}
	
	class MainClass		
	{
		private const string OBJECT_PATH = "/org/gnome/Tomboy/RemoteControl";
		private const string BUS_NAME = "org.gnome.Tomboy";
		
		private static ITboy TomboyInstance = null;

		static ITboy FindInstance() {
	        if (!Bus.Session.NameHasOwner(BUS_NAME))
	            throw new Exception(String.Format("Name {0} has no owner", BUS_NAME));

	        return Bus.Session.GetObject<ITboy>(BUS_NAME, new ObjectPath (OBJECT_PATH));
	    }
		
		public static void Main(string[] args) {
			
			try {
	            TomboyInstance = FindInstance();
	        } catch(Exception) {
	            Console.Error.WriteLine("Could not locate Tomboy on D-Bus. Perhaps it's not running?");
	            Environment.Exit(1);
	        }
	        
	        BusG.Init();
	        //Application.Init();
	        //new BansheeClient();
	        //Application.Run();

			Console.WriteLine(TomboyInstance.Version());
			
			Console.WriteLine("Hello World!");
		}
	}
}