public static RemoteControl Register(NoteManager manager) { #if ENABLE_DBUS BusG.Init(); RemoteControl remote_control = new RemoteControl(manager); Bus.Session.Register(Namespace, new ObjectPath(Path), remote_control); if (Bus.Session.RequestName(Namespace) != RequestNameReply.PrimaryOwner) { return(null); } return(remote_control); #else if (FirstInstance) { // Register an IPC channel for .NET remoting // access to our Remote Control IpcChannel = new IpcChannel(ServerName); ChannelServices.RegisterChannel(IpcChannel, false); RemotingConfiguration.RegisterWellKnownServiceType( typeof(RemoteControlWrapper), WrapperName, WellKnownObjectMode.Singleton); // The actual Remote Control has many methods // that need to be called in the GTK+ mainloop, // which will not happen when the method calls // come from a .NET remoting client. So we wrap // the Remote Control in a class that implements // the same interface, but wraps most method // calls in Gtk.Application.Invoke. // // Note that only one RemoteControl is ever // created, and that it is stored statically // in the RemoteControlWrapper. RemoteControl realRemote = new RemoteControl(manager); RemoteControlWrapper.Initialize(realRemote); RemoteControlWrapper remoteWrapper = (RemoteControlWrapper)Activator.GetObject( typeof(RemoteControlWrapper), ServiceUrl); return(realRemote); } else { // If Tomboy is already running, register a // client IPC channel. IpcChannel = new IpcChannel(ClientName); ChannelServices.RegisterChannel(IpcChannel, false); return(null); } #endif }
public static IRemoteControl GetInstance() { #if ENABLE_DBUS BusG.Init(); if (!Bus.Session.NameHasOwner(Namespace)) { Bus.Session.StartServiceByName(Namespace); } return(Bus.Session.GetObject <RemoteControl> (Namespace, new ObjectPath(Path))); #else RemoteControlWrapper remote = (RemoteControlWrapper)Activator.GetObject( typeof(RemoteControlWrapper), ServiceUrl); return(remote); #endif }