File: RemoteControlProxy.cs

package info (click to toggle)
tasque 0.1.12-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,416 kB
  • ctags: 1,743
  • sloc: cs: 11,981; sh: 10,754; makefile: 147
file content (35 lines) | stat: -rw-r--r-- 863 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using DBus;
using org.freedesktop.DBus;

namespace Tasque
{
	public static class RemoteControlProxy {
		private const string Path = "/org/gnome/Tasque/RemoteControl";
		private const string Namespace = "org.gnome.Tasque";

		public static RemoteControl GetInstance () {
			BusG.Init ();

			if (! Bus.Session.NameHasOwner (Namespace))
				Bus.Session.StartServiceByName (Namespace);

			return Bus.Session.GetObject<RemoteControl> (Namespace,
			                new ObjectPath (Path));
		}

		public static RemoteControl Register () {
			BusG.Init ();

			RemoteControl remote_control = new RemoteControl ();
			Bus.Session.Register (new ObjectPath (Path),
			                      remote_control);

			if (Bus.Session.RequestName (Namespace)
			                != RequestNameReply.PrimaryOwner)
				return null;

			return remote_control;
		}
	}
}