public static void Main() { BusG.Init (); Application.Init (); Button btn = new Button ("Click me"); btn.Clicked += OnClick; VBox vb = new VBox (false, 2); vb.PackStart (btn, false, true, 0); Window win = new Window ("D-Bus#"); win.SetDefaultSize (640, 480); win.Add (vb); win.Destroyed += delegate {Application.Quit ();}; win.ShowAll (); bus = Bus.Session; string bus_name = "org.ndesk.gtest"; ObjectPath path = new ObjectPath ("/org/ndesk/test"); if (bus.RequestName (bus_name) == RequestNameReply.PrimaryOwner) { //create a new instance of the object to be exported demo = new DemoObject (); bus.Register (path, demo); } else { //import a remote to a local proxy demo = bus.GetObject<DemoObject> (bus_name, path); } //run the main loop Application.Run (); }
public static void Main() { BusG.Init (); Application.Init (); Window win = new Window ("D-Bus#"); win.SetDefaultSize (640, 480); win.Destroyed += delegate {Application.Quit ();}; win.ShowAll (); bus = Bus.Session; sysBus = Bus.System.GetObject<IBus> ("org.freedesktop.DBus", new ObjectPath ("/org/freedesktop/DBus")); string bus_name = "org.ndesk.gtest"; ObjectPath path = new ObjectPath ("/org/ndesk/test"); if (bus.RequestName (bus_name) == RequestNameReply.PrimaryOwner) { //create a new instance of the object to be exported demo = new DemoObject (); sysBus.NameOwnerChanged += demo.FireChange; bus.Register (path, demo); } else { //import a remote to a local proxy demo = bus.GetObject<DemoObject> (bus_name, path); } //run the main loop Application.Run (); }
public Hyperlink(Accessible accessible, string path) { application = accessible.application; ObjectPath op = new ObjectPath (path); proxy = Registry.Bus.GetObject<IHyperlink> (application.name, op); properties = Registry.Bus.GetObject<Properties> (application.name, op); }
public EngineAdapter(string name, EngineSettingsAdapter settings, ObjectPath path) { this.name = name; this.engine = new ClientEngine(settings.Settings); this.engineSettings = settings; this.path = path; DownloaderPath = path.ToString () + "/downloaders/{0}"; StoragePath = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData); StoragePath = System.IO.Path.Combine (StoragePath, "monotorrent-dbus"); EnsurePath (StoragePath); StoragePath = System.IO.Path.Combine (StoragePath, string.Format ("engine-{0}", name)); EnsurePath (StoragePath); downloaders = new Dictionary<ObjectPath, TorrentManagerAdapter> (new ObjectPathComparer()); torrents = new Dictionary<ObjectPath,TorrentAdapter> (); engine.StatsUpdate += delegate { StatsUpdateHandler h = StatsUpdate; if (h != null) h (); }; LoadState (); }
static bool isActivityRegistered(string activityId) { try { Connection conn; conn = Bus.Session; // ObjectPath opath = new ObjectPath ("/org/freedesktop/DBus"); // string name = "org.freedesktop.DBus"; ObjectPath opath = new ObjectPath ("/org/laptop/Activity"); string name = "org.laptop.Activity"; IBus bus = conn.GetObject<IBus> (name, opath); if (bus==null) { System.Console.Out.WriteLine("Return during the DBus process acquire."); return false; } else { if (bus.NameHasOwner("org/laptop/Activity"+activityId)) return true; else return false; } } catch (Exception ex) { System.Console.Out.WriteLine("Exception in the DBus process acquire of an activity: "+ex.Message); } return false; }
public static void Main(string[] args) { Settings settings = Settings.LoadSettingsFromFile (args[0]); //BusG.Init(); Bus bus = ClientHelper.MessageBus; string bus_name = "au.id.micolous.sp2"; ObjectPath path = new ObjectPath ("/presenterd"); if (bus.RequestName (bus_name) == RequestNameReply.PrimaryOwner) { Presenterd presenterd = new Presenterd (settings, bus); bus.Register (path, (IPresenterd)presenterd); Console.WriteLine("presenterd is running..."); presenterd.StartLoop(); while (true) bus.Iterate(); } else { // could not claim ownership of the bus Console.WriteLine("Error: Could not claim primary ownership of SAGAPresenter2 DBUS object."); Console.WriteLine("This is probably because another instance of presenterd is already running, or system policy prohibits it."); } }
public AccessControl (Context context, ObjectPath opath) { this.access_control = context.GetObject<IAccessControl> (opath); access_control.ACLAdded += OnACLAdded; access_control.ACLRemoved += OnACLRemoved; }
public static int Main(string[] args) { // Is Beagle up? DaemonInformationRequest infoReq = new DaemonInformationRequest(); try { infoReq.Send(); } catch { Console.Error.WriteLine("Error: beagled does not appear to be running"); return -1; } Bus bus = Bus.Session; ObjectPath opath = new ObjectPath("/org/freedesktop/xesam/searcher/main"); string service = "org.freedesktop.xesam.searcher"; Searcher search = new Searcher(); bus.Register(service, opath, search); RequestNameReply nameReply = bus.RequestName(service); System.Threading.Thread t = new System.Threading.Thread(BusIterate); t.Start(); MainLoop ml = new MainLoop(); ml.Run(); return 0; }
public void HandleTube(string bus_name, ObjectPath conn, ObjectPath channel, uint handle_type, uint handle) { return; }
internal Conduit(ObjectPath path) { conduit_proxy = Util.GetObject<IConduit> (path); this.path = path; // hookup events conduit_proxy.SyncStarted += HandleSyncStarted; conduit_proxy.SyncCompleted += HandleSyncCompleted; conduit_proxy.SyncProgress += HandleSyncProgress; conduit_proxy.SyncConflict += HandleSyncConflict; }
public Device (Context context, ObjectPath object_path) { this.context = context; this.object_path = object_path; this.device = context.GetObject<IDevice> (object_path); device.PropertyModified += OnPropertyModified; device.Condition += OnCondition; device.InterfaceLockAcquired += OnInterfaceLockAcquired; device.InterfaceLockReleased += OnInterfaceLockReleased; }
public static ExportObject CreateExportObject(Connection conn, ObjectPath object_path, object obj) { Type type = obj.GetType (); #if DLR if (type.Name == "RubyObject" || type.FullName == "IronPython.Runtime.Types.OldInstance") return new DynamicExportObject (conn, object_path, obj); #endif return new ExportObject (conn, object_path, obj); }
protected override void OnStart() { var bus = Bus.Open("tcp:host=localhost,port=12345"); //var bus = Bus.Open("win:path=dbus-session"); string bus_name = "org.mathias.xspservice"; ObjectPath path = new ObjectPath("/org/mathias/xspservice"); this.XspService = bus.GetObject<IXspService>(bus_name, path); this.XspService.StartWebApp(this.PhysicalPath, this.VirtualPath, this.Port); }
//dynamically defines a Type for the proxy object using D-Bus introspection public object GetObject(string bus_name, ObjectPath path) { org.freedesktop.DBus.Introspectable intros = GetObject<org.freedesktop.DBus.Introspectable> (bus_name, path); string data = intros.Introspect (); StringReader sr = new StringReader (data); XmlSerializer sz = new XmlSerializer (typeof (Node)); Node node = (Node)sz.Deserialize (sr); Type type = TypeDefiner.Define (node.Interfaces); return GetObject (type, bus_name, path); }
public MethodCall(ObjectPath path, string @interface, string member, string destination, Signature signature) { message.Header.MessageType = MessageType.MethodCall; message.ReplyExpected = true; message.Header[FieldCode.Path] = path; message.Header[FieldCode.Interface] = @interface; message.Header[FieldCode.Member] = member; message.Header[FieldCode.Destination] = destination; //TODO: consider setting Sender here for p2p situations //this will allow us to remove the p2p hacks in MethodCall and Message #if PROTO_REPLY_SIGNATURE //TODO #endif message.Signature = signature; }
public TorrentAdapter(Torrent torrent, ObjectPath path) { this.path = path; this.torrent = torrent; this.filesPath = path.ToString () + "/files/{0}"; files = new ObjectPath[torrent.Files.Length]; for (int i=0; i < files.Length; i++) { ObjectPath p = new ObjectPath (string.Format(filesPath, i)); TorrentFileAdapter adapter = new TorrentFileAdapter (torrent.Files[i], p); files[i] = p; TorrentService.Bus.Register (p, adapter); } }
public TorrentManagerAdapter(TorrentManager manager, TorrentAdapter torrent, TorrentSettingsAdapter settings, ObjectPath path) { this.manager = manager; this.torrent = torrent; this.settingsAdapter = settings; this.path = path; manager.TorrentStateChanged += delegate (object sender, TorrentStateChangedEventArgs e) { if (StateChanged != null) StateChanged (path, EnumAdapter.Adapt(e.OldState), EnumAdapter.Adapt (e.NewState)); }; manager.PieceHashed += OnPieceHashed; LoadTrackers (manager.TrackerManager.TrackerTiers); }
protected override void OnStart() { var bus = Bus.Open("tcp:host=localhost,port=12345"); //var bus = Bus.Open("win:path=dbus-session"); string bus_name = "org.mathias.test"; ObjectPath path = new ObjectPath("/org/mathias/test"); IMyService service = bus.GetObject<IMyService>(bus_name, path); running = true; while (running) { Console.WriteLine(service.Say(new Person {Name = "Mathias"})); Thread.Sleep(1000*2); } }
/// <summary>Request an application specific <see cref="Capuchin.AppObject /> object</summary> /// <param name="repository_url">URL to repository's XML file</param> public virtual ObjectPath GetAppObject(string repository_url) { if (this.Objects.ContainsKey(repository_url)) return this.Objects[repository_url]; string object_path = String.Format(CAPUCHIN_PATH, this.MakeObjectPath(this.GetApplicationName(repository_url)) ); ObjectPath new_stuff_opath = new ObjectPath (object_path); Log.Info ("Creating app object for {0} at {1}", repository_url, object_path); AppObject nsm = new AppObject(repository_url); nsm.Closed += new AppObject.ClosedHandler( this.OnClosed ); Bus.Session.Register(CAPUCHIN_SERVICE, new_stuff_opath, nsm); this.Objects.Add(repository_url, new_stuff_opath); return new_stuff_opath; }
protected override void OnStart() { var bus = Bus.Open("tcp:host=localhost,port=12345"); //var bus = Bus.Open("win:path=dbus-session"); string bus_name = "org.mathias.test"; ObjectPath path = new ObjectPath("/org/mathias/test"); IMyService service; if (bus.RequestName(bus_name) == RequestNameReply.PrimaryOwner) { //create a new instance of the object to be exported service = new MyActivator(); bus.Register(path, service); //run the main loop while (true) bus.Iterate(); } }
protected override void OnStart() { this.bus = Bus.Open("tcp:host=localhost,port=12345"); //var bus = Bus.Open("win:path=dbus-session"); var path = new ObjectPath("/org/mathias/xspservice"); IXspService service; if (bus.RequestName(BusName) == RequestNameReply.PrimaryOwner) { this.port = 1254; this.websource = new XSPWebSource(IPAddress.Any, this.port); this.webAppServer = new ApplicationServer(this.websource); //this.webAppServer.AddApplicationsFromCommandLine(string.Format("localhost:{0}:{1}:{2}", port, "/", "Bundles/WebAspBundle")); this.webAppServer.Start(true); //create a new instance of the object to be exported bus.Register(path, this); //this.webAppServer.Start(true); this.listen = true; ThreadPool.QueueUserWorkItem((o) => { //run the main loop while (true) { mutex.WaitOne(); try { if (!this.listen) break; bus.Iterate(); } finally { mutex.ReleaseMutex(); } } }, null); } }
public static void Main(string[] args) { Connection conn; if (args.Length == 0) conn = Bus.Session; else { if (args[0] == "--session") conn = Bus.Session; else if (args[0] == "--system") conn = Bus.System; else conn = Connection.Open (args[0]); } ObjectPath opath = new ObjectPath ("/org/freedesktop/DBus"); string name = "org.freedesktop.DBus"; IBus bus = conn.GetObject<IBus> (name, opath); bus.NameAcquired += delegate (string acquired_name) { Console.WriteLine ("NameAcquired: " + acquired_name); }; Console.WriteLine (); string xmlData = bus.Introspect (); Console.WriteLine ("xmlData: " + xmlData); Console.WriteLine (); foreach (string n in bus.ListNames ()) Console.WriteLine (n); Console.WriteLine (); foreach (string n in bus.ListNames ()) Console.WriteLine ("Name " + n + " has owner: " + bus.NameHasOwner (n)); Console.WriteLine (); }
public static int Main(string[] args) { Console.WriteLine ("Starting DBus service"); Bus bus = Bus.Session; IRunner runner; ObjectPath objPath = new ObjectPath("/com/CommandServer/Runner"); string busName = "com.CommandServer.Runner"; if(bus.RequestName(busName) == RequestNameReply.PrimaryOwner) { runner = new SampleRunnerImplementation(); bus.Register(objPath, runner); } else { Console.WriteLine("server instance already running"); return 1; } //run the main loop while (true) bus.Iterate (); }
public void LoadSettings() { settings = Settings.LoadSettingsFromFile (settings.CurrentFile); if (settings_path != null) { bus.Unregister (settings_path); settings_path = null; } }
public T GetObject <T> (string bus_name, ObjectPath path) { return((T)GetObject(typeof(T), bus_name, path)); }
public void Register(string bus_name, ObjectPath path, object obj) { Register(path, obj); }
public MatchTest(ObjectPath value) { Signature = Signature.ObjectPathSig; Value = value; }
public void Deregister(KeystrokeListener listener) { ObjectPath op = new ObjectPath (listener.Path); proxy.DeregisterKeystrokeListener (op, listener.Keys, listener.Mask, listener.Types); }
public object GetObject(Type type) { ObjectPath path = ReadObjectPath(); return(message.Connection.GetObject(type, (string)message.Header.Fields[FieldCode.Sender], path)); }
public ExportObject(Connection conn, ObjectPath object_path, object obj) : base(conn, null, object_path) { this.obj = obj; }
public ArgMatchTest(int argNum, ObjectPath value) { ArgNum = argNum; Signature = Signature.ObjectPathSig; Value = value; }
//not particularly efficient and needs to be generalized internal void HandleMethodCall(MethodCall method_call) { //TODO: Ping and Introspect need to be abstracted and moved somewhere more appropriate once message filter infrastructure is complete //FIXME: these special cases are slightly broken for the case where the member but not the interface is specified in the message if (method_call.Interface == "org.freedesktop.DBus.Peer" && method_call.Member == "Ping") { Message reply = MessageHelper.ConstructReply(method_call); Send(reply); return; } if (method_call.Interface == "org.freedesktop.DBus.Introspectable" && method_call.Member == "Introspect") { Introspector intro = new Introspector(); intro.root_path = method_call.Path; intro.WriteStart(); //FIXME: do this properly //this is messy and inefficient List <string> linkNodes = new List <string> (); int depth = method_call.Path.Decomposed.Length; foreach (ObjectPath pth in RegisteredObjects.Keys) { if (pth.Value == (method_call.Path.Value)) { ExportObject exo = (ExportObject)RegisteredObjects[pth]; intro.WriteType(exo.obj.GetType()); } else { for (ObjectPath cur = pth; cur != null; cur = cur.Parent) { if (cur.Value == method_call.Path.Value) { string linkNode = pth.Decomposed[depth]; if (!linkNodes.Contains(linkNode)) { intro.WriteNode(linkNode); linkNodes.Add(linkNode); } } } } } intro.WriteEnd(); Message reply = MessageHelper.ConstructReply(method_call, intro.xml); Send(reply); return; } BusObject bo; if (RegisteredObjects.TryGetValue(method_call.Path, out bo)) { ExportObject eo = (ExportObject)bo; eo.HandleMethodCall(method_call); } else { MaybeSendUnknownMethodError(method_call); } }
public void HandleChannels(ObjectPath account, ObjectPath connection, ChannelDetails[] channels, ObjectPath[] requests_satisfied, ulong user_action_time, IDictionary<string,object> handler_info) { }
public bool Register(KeystrokeListener listener) { ObjectPath op = new ObjectPath (listener.Path); EventListenerMode mode = new EventListenerMode (listener.Synchronous, listener.Preemptive, listener.Global); return proxy.RegisterKeystrokeListener (op, listener.Keys, listener.Mask, listener.Types, mode); }
public DeviceEventController() { lock (sync) { if (instance == null) instance = this; else throw new Exception ("Attempt to create a second device event controller"); } ObjectPath op = new ObjectPath ("/org/a11y/atspi/registry/deviceeventcontroller"); proxy = Registry.Bus.GetObject<IDeviceEventController> ("org.a11y.atspi.Registry", op); }
static void AppendPathArg(StringBuilder sb, int index, ObjectPath value) { Append(sb, "arg" + index + "path", value.ToString()); }
public void Deregister(MouseListener listener) { ObjectPath op = new ObjectPath (listener.Path); proxy.DeregisterDeviceEventListener (op, listener.Types); }
public object Unregister(string bus_name, ObjectPath path) { return(Unregister(path)); }
public bool Register(MouseListener listener) { ObjectPath op = new ObjectPath (listener.Path); return proxy.RegisterDeviceEventListener (op, listener.Types); }
public ExportObject(Connection conn, string bus_name, ObjectPath object_path, object obj) : base(conn, bus_name, object_path) { this.obj = obj; }