Exemple #1
0
    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 ();
    }
Exemple #2
0
    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 ();
    }
        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);
            }
        }
        private void createDBusLoopEvent(string activityId)
        {
            if (olpcDbusObj!=null) {
                return;
            }

            try {
                if (activityId==null || activityId.Trim().Length<1) {
                    activityId="123456789";
                }
                NDesk.DBus.BusG.Init ();

                bus = Bus.Session;

                bus_name = "org.laptop.Activity"+activityId;
                path = new ObjectPath ("/org/laptop/Activity/"+activityId);

                if (bus.RequestName (bus_name) == RequestNameReply.PrimaryOwner) {

                    //create a new instance of the object to be exported
                    if (_window!=null) {
                        olpcDbusObj = new OlpcDBusObject (_window);
                    } else if (_activity != null) {
                        olpcDbusObj = new OlpcDBusObject (_activity);
                    }
                    bus.Register (path, olpcDbusObj);

                } else {
                    //import a remote to a local proxy
                    olpcDbusObj = bus.GetObject<OlpcDBusObject> (bus_name, path);
                }
            } catch (Exception ex) {

                System.Console.Out.WriteLine("Exception during the DBus Instance creation: "+ex.Message);
                System.Console.Out.WriteLine("Stack: "+ex.StackTrace);
            }
        }
		public void Register (Bus bus)
		{
			this.bus = bus;
			bus.Register (new ObjectPath (DC.Constants.AutomationElementBasePath + pathId.ToString ()),
			              this);
		}