Esempio n. 1
0
    public static void Main()
    {
        BusG.Init();
        Application.Init();

        tv = new TextView();
        ScrolledWindow sw = new ScrolledWindow();

        sw.Add(tv);

        Button btn = new Button("Click me");

        btn.Clicked += OnClick;

        Button btnq = new Button("Click me (thread)");

        btnq.Clicked += OnClickQuit;

        VBox vb = new VBox(false, 2);

        vb.PackStart(sw, true, true, 0);
        vb.PackStart(btn, false, true, 0);
        vb.PackStart(btnq, 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.GetObject <IBus> ("org.freedesktop.DBus", new ObjectPath("/org/freedesktop/DBus"));

        Application.Run();
    }
Esempio n. 2
0
        public void Initialise()
        {
            try
            {
                Ticker.Tick();
                BusG.Init();
                alreadyRunning = Bus.Session.RequestName(BusName) != RequestNameReply.PrimaryOwner;

                if (alreadyRunning)
                {
                    commandParser = Bus.Session.GetObject <ICommandParser>(BusName, new ObjectPath(CommandParserPath));
                }
                else
                {
                    Bus.Session.Register(BusName, new ObjectPath(CommandParserPath), commandParser);
                }
            }
            catch (Exception)
            {
                Console.WriteLine("**************************************");
                Console.WriteLine("* DBus support could not be started. *");
                Console.WriteLine("* Some functionality will be missing *");
                Console.WriteLine("**************************************");
            }
            finally
            {
                Initialised = true;
                Ticker.Tock("DBus");
            }
        }
Esempio n. 3
0
 static Registrar()
 {
     try {
         BusG.Init();
     } catch {
     }
 }
Esempio n. 4
0
        void Init()
        {
            BusG.Init();

            var dbus = Bus.System;

            if (!dbus.NameHasOwner(BusName))
            {
#if LOG4NET
                Logger.Info("Init(): no DBus provider for network manager found, " +
                            "disabling...");
#endif
                return;
            }

            Manager = dbus.GetObject <INetworkManager>(
                BusName, new ObjectPath(ObjectPath)
                );
            if (Manager == null)
            {
#if LOG4NET
                Logger.Warn("Init(): DBus object is null, bailing out!");
#endif
                return;
            }
            Manager.StateChanged += OnStateChanged;

            IsInitialized = true;
        }
Esempio n. 5
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();
    }
Esempio n. 6
0
        public void Initialize()
        {
            // Set a sane default value for on_battery.  Thus, if we don't find a working power manager
            // we assume we're not on battery.
            on_battery = false;
            try {
                BusG.Init();
                if (Bus.System.NameHasOwner(DeviceKitPowerName))
                {
                    devicekit            = Bus.System.GetObject <IDeviceKitPower> (DeviceKitPowerName, new ObjectPath(DeviceKitPowerPath));
                    devicekit.OnChanged += DeviceKitOnChanged;
                    on_battery           = (bool)devicekit.Get(DeviceKitPowerName, "on-battery");
                    Log <SystemService> .Debug("Using org.freedesktop.DeviceKit.Power for battery information");
                }
                else if (Bus.Session.NameHasOwner(PowerManagementName))
                {
                    power = Bus.Session.GetObject <IPowerManagement> (PowerManagementName, new ObjectPath(PowerManagementPath));
                    power.OnBatteryChanged += PowerOnBatteryChanged;
                    on_battery              = power.GetOnBattery();
                    Log <SystemService> .Debug("Using org.freedesktop.PowerManager for battery information");
                }
            } catch (Exception e) {
                Log <SystemService> .Error("Could not initialize dbus: {0}", e.Message);

                Log <SystemService> .Debug(e.StackTrace);
            }
        }
Esempio n. 7
0
        public static void Main(string[] args)
        {
            Application.Init();
            // Set the localeDirectory right both for developement or for installed versions
            String localeDirectory = Paths.LOCALE_DIR;

            if (localeDirectory.Contains("@" + "expanded_datadir" + "@"))
            {
                localeDirectory = "./locale";
            }

            System.Console.WriteLine(localeDirectory);

            Mono.Unix.Catalog.Init("opencachemanager", localeDirectory);
            OCMApp app = new OCMApp();


            try
            {
                BusG.Init();
                Bus    bus     = Bus.Session;
                string busName = "org.ocm.dbus";
                if (bus.RequestName(busName) != RequestNameReply.PrimaryOwner)
                {
                    IDBusComm comm = bus.GetObject <IDBusComm> (busName, new ObjectPath("/org/ocm/dbus"));
                    if (args != null)
                    {
                        if (args.Length > 0)
                        {
                            comm.ImportGPX(args[0]);
                        }
                    }
                    comm.ShowOCM();
                    return;
                }
                else
                {
                    DBusComm comm = new DBusComm(app);
                    bus.Register(new ObjectPath("/org/ocm/dbus"), comm);
                }
            }
            catch
            {
                System.Console.Error.WriteLine("NO SESSION DBUS RUNNING");
            }
            if (args != null)
            {
                if (args.Length > 0)
                {
                    app.Start(args[0]);
                }
                else
                {
                    app.Start();
                }
            }
        }
Esempio n. 8
0
        public static void Main(string[] args)
        {
            Application.Init();
            BusG.Init();
            Mono.Unix.Catalog.Init("dbus-explorer", "/usr/share/local");

            MainWindow win = new MainWindow();

            win.Show();
            Application.Run();
        }
Esempio n. 9
0
        public static RemoteControl GetInstance()
        {
            BusG.Init();

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

            return(Bus.Session.GetObject <RemoteControl> (Namespace, new ObjectPath(Path)));
        }
Esempio n. 10
0
 public SpDBus()
 {
     try {
         BusG.Init();
         if (spotify == null)
         {
             FindInstance();
         }
     } catch (Exception) {
         Console.Error.WriteLine("Could not locate Spotify on D-Bus. Perhaps it's not running?");
     }
 }
Esempio n. 11
0
 public TomboyDBus()
 {
     try {
         BusG.Init();
         if (TomboyInstance == null)
         {
             FindInstance();
         }
         TomboyInstance.NoteAdded   += OnNoteAdded;
         TomboyInstance.NoteRemoved += OnNoteRemoved;
     } catch (Exception) {
         Console.Error.WriteLine("Could not locate Tomboy on D-Bus. Perhaps it's not running?");
     }
 }
Esempio n. 12
0
        public static RemoteControl Register(GtkApplicationBase application)
        {
            BusG.Init();

            var remoteControl = new RemoteControl(application);

            Bus.Session.Register(new ObjectPath(Path), remoteControl);

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

            return(remoteControl);
        }
Esempio n. 13
0
        private static RequestNameReply Connect(string serviceName, bool init)
        {
            connect_tried = true;

            if (init)
            {
                BusG.Init();
            }

            string           bus_name   = MakeBusName(serviceName);
            RequestNameReply name_reply = Bus.Session.RequestName(bus_name);

            Log.DebugFormat("Bus.Session.RequestName ('{0}') replied with {1}", bus_name, name_reply);
            return(name_reply);
        }
        public static RemoteControl Register()
        {
            BusG.Init();

            var remoteControl = new RemoteControl();
            var session       = Bus.Session;

            session.Register(Namespace, new ObjectPath(Path), remoteControl);

            if (session.RequestName(Namespace) != RequestNameReply.PrimaryOwner)
            {
                return(null);
            }

            return(remoteControl);
        }
Esempio n. 15
0
        public NetworkService()
        {
            this.IsConnected = true;
            try {
                BusG.Init();
                if (Bus.System.NameHasOwner(NetworkManagerName))
                {
                    network = Bus.System.GetObject <INetworkManager> (NetworkManagerName, new ObjectPath(NetworkManagerPath));
                    network.StateChanged += OnStateChanged;
                    SetConnected();
                }
            } catch (Exception e) {
                // if something bad happened, log the error and assume we are connected
                Log <NetworkService> .Error("Could not initialize Network Manager dbus: {0}", e.Message);

                Log <NetworkService> .Debug(e.StackTrace);
            }
        }
Esempio n. 16
0
        /*
         * private void OnNewChannel (ObjectPath object_path, string channel_type, HandleType handle_type,
         *                         uint handle, bool suppress_handler)
         * {
         *  Console.WriteLine (MSG_PREFIX + "OnNewChannel: op {0}, type {1}, handle {2}",
         *                     object_path, channel_type, handle);
         *
         *  if (channel_type.Equals (CHANNEL_TYPE_DBUSTUBE)) {
         *      itube = bus.GetObject<IDBusTube> (CONNMANAGER_GABBLE_IFACE, object_path);
         *      //itube.NewTube += OnNewTube;
         *      itube.TubeChannelStateChanged += OnTubeChannelStateChanged;
         *
         *      // get tube initiator handle
         *      // should be = to self_handle on client
         *      // should be != to self_handle on server
         *      Properties p = bus.GetObject<Properties> (CONNMANAGER_GABBLE_IFACE, object_path);
         *      tube_initiator = (uint) p.Get (CHANNEL_IFACE, "InitiatorHandle");
         *
         *      if (tube_initiator == self_handle) {
         *          Console.WriteLine (MSG_PREFIX + "Offering DTube");
         *          addr = itube.OfferDBusTube (new Dictionary<string, object>());
         *          Console.WriteLine (MSG_PREFIX + "Tube from {0} offered", addr);
         *      }
         *      else {
         *          addr = itube.AcceptDBusTube ();
         *          Console.WriteLine (MSG_PREFIX + "Tube from {0} accepted", addr);
         *      }
         *
         *  }
         * }
         */
        /*
         * private void OnNewTube (uint id, uint initiator, TubeType type, string service,
         *                      IDictionary<string,object> parameters, TubeState state)
         * {
         *  Console.WriteLine (MSG_PREFIX + "OnNewTube: id {0), initiator {1}, service {2}",
         *                     id, initiator, service);
         *  switch (state) {
         *      case TubeState.LocalPending:
         *          if (type == TubeType.DBus && initiator != self_handle && service.Equals (DTUBETEST_IFACE)) {
         *              Console.WriteLine (MSG_PREFIX + "Accepting DTube");
         *              itube.AcceptDBusTube (id);
         *          }
         *          break;
         *  }
         *
         * }
         */
        private void OnTubeChannelStateChanged(TubeChannelState state)
        {
            Console.WriteLine(MSG_PREFIX + "OnTubeStateChanged: state {0}",
                              state);

            switch (state)
            {
            // this state is never reached, so accepting OnNewChannel
            // leaving here just in case, however
            case TubeChannelState.LocalPending:
                addr = itube.Accept(SocketAccessControl.Localhost);
                Console.WriteLine(MSG_PREFIX + "Tube from {0} accepted", addr);
                break;

            // tube ready. set up connection and export/get object
            case TubeChannelState.Open:

                dbus_conn = Connection.Open(addr);
                BusG.Init(dbus_conn);

                if (tube_initiator != self_handle)
                {
                    RegisterDBusObject();
                }
                else
                {
                    obj             = dbus_conn.GetObject <IDTubeTest> (DTUBETEST_IFACE, new ObjectPath(DTUBETEST_PATH));
                    obj.TestSignal += OnTestSignal;
                    obj.Hello();
                    IDictionary <string, object>[] dic = obj.HelloDictionary();
                    Console.WriteLine(MSG_PREFIX + "Got response on tube. Dictionary array has {0} items.", dic.Length);
                    TestStruct[] ts = obj.HelloStruct();
                    Console.WriteLine(MSG_PREFIX + "Got response on tube. Struct array has {0} items", ts.Length);
                    Properties p        = dbus_conn.GetObject <Properties> (DTUBETEST_IFACE, new ObjectPath(DTUBETEST_PATH));
                    string     property = (string)p.Get(DTUBETEST_IFACE, "TestProperty");
                    Console.WriteLine(MSG_PREFIX + "Got response on tube. Property {0}", property);
                    itube.Close();
                }
                break;

            case TubeChannelState.NotOffered:
                break;
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Initializes the backend
        /// </summary>
        public void Initialize()
        {
            BusG.Init();

            // Watch the session bus for when ICEcore Daemon comes or goes.
            // When it comes, attempt to connect to it.
            sessionBus =
                Bus.Session.GetObject <org.freedesktop.DBus.IBus> (
                    "org.freedesktop.DBus",
                    new ObjectPath("/org/freedesktop/DBus"));
            sessionBus.NameOwnerChanged += OnDBusNameOwnerChanged;

            // Force the daemon to start up if it's not already running
            if (!Bus.Session.NameHasOwner(DaemonNamespace))
            {
                Bus.Session.StartServiceByName(DaemonNamespace);
            }

            // Register for ICEcore Daemon's events
            ConnectToICEcoreDaemon();

            //
            // Add in the AllCategory
            //
            AllCategory allCategory = new AllCategory();

            Gtk.TreeIter iter = categories.Append();
            categories.SetValue(iter, 0, allCategory);

            // Populate the models
            Refresh();

            initialized = true;

            if (BackendInitialized != null)
            {
                try {
                    BackendInitialized();
                } catch (Exception e) {
                    Logger.Debug("Exception in IceBackend.BackendInitialized handler: {0}", e.Message);
                }
            }
        }
Esempio n. 18
0
        public static void Main(string[] args)
        {
            try
            {
                Utilities.SetProcessName("Banter");
                BusG.Init();
                application = GetApplicationWithArgs(args);
                Banter.Application.RegisterSessionManagerRestart(
                    Environment.GetEnvironmentVariable("RTC_PATH"),
                    args);

                application.StartMainLoop();
            }
            catch (Exception e)
            {
                //TODO log
                Console.WriteLine(e.Message);
                Exit(-1);
            }
        }
Esempio n. 19
0
        public void Initialize(string locale_dir,
                               string display_name,
                               string process_name,
                               string [] args)
        {
            try {
                SetProcessName(process_name);
            } catch {}             // Ignore exception if fail (not needed to run)

            // Register handler for saving session when logging out of Gnome
            BusG.Init();
            string startup_id = Environment.GetEnvironmentVariable("DESKTOP_AUTOSTART_ID");

            if (String.IsNullOrEmpty(startup_id))
            {
                startup_id = display_name;
            }

            try {
                SessionManager session = Bus.Session.GetObject <SessionManager> (Constants.SessionManagerInterfaceName,
                                                                                 new ObjectPath(Constants.SessionManagerPath));
                session_client_id = session.RegisterClient(display_name, startup_id);

                ClientPrivate client = Bus.Session.GetObject <ClientPrivate> (Constants.SessionManagerInterfaceName,
                                                                              session_client_id);
                client.QueryEndSession += OnQueryEndSession;
                client.EndSession      += OnEndSession;
                client.Stop            += OnStop;
            } catch (Exception e) {
                Logger.Debug("Failed to register with session manager: {0}", e.Message);
            }

            Gtk.Application.Init();
#if PANEL_APPLET
            program = new Gnome.Program(display_name,
                                        Defines.VERSION,
                                        Gnome.Modules.UI,
                                        args);
#endif
        }
Esempio n. 20
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();
    }
Esempio n. 21
0
    public static void Main()
    {
        BusG.Init();
        Application.Init();

        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/btn");

        if (bus.RequestName(bus_name) == RequestNameReply.PrimaryOwner)
        {
            bus.Register(path, btn);
            rbtn = btn;
        }
        else
        {
            rbtn = bus.GetObject <Button> (bus_name, path);
        }

        //run the main loop
        Application.Run();
    }
Esempio n. 22
0
        public static void Main(string[] args)
        {
            GLib.Log.DefaultHandler("zencomic", GLib.LogLevelFlags.Info, "Starting up");

            Application.Init();
            BusG.Init();
            InitSignals();

            AddinManager.Initialize(Config.ConfigPath);
            AddinManager.Registry.Update(null);

            Config config = Config.RestoreSaved();

            CprStatusIcon icon = new CprStatusIcon(() => new PreferencesDialog(config));

            icon.ShowDelay = config.ShowDelay;
            icon.Method    = config.Method;
            icon.PopupTime = config.PopupTime;
            icon.Visible   = true;

            config.ShowDelayChanged += delegate {
                icon.ShowDelay = config.ShowDelay;
            };
            config.PopupTimeChanged += delegate {
                icon.PopupTime = config.PopupTime;
            };
            config.PopupMethodChanged += delegate {
                icon.Method    = config.Method;
                icon.PopupTime = config.PopupTime;
            };

            Application.Run();

            GLib.Log.DefaultHandler("zencomic", GLib.LogLevelFlags.Info, "Saving configuration and exiting");
            config.Save();
        }
Esempio n. 23
0
        public void Initialize()
        {
            BusG.Init();
            Application.Init();         // init GTK app for use of Glib mainloop

            IMissionControl mc = bus.GetObject <IMissionControl> (Constants.MISSIONCONTROL_IFACE,
                                                                  new ObjectPath(Constants.MISSIONCONTROL_PATH));

            if (mc == null)
            {
                Console.WriteLine(MSG_PREFIX + "Unable to find MissonControl interface.");
                return;
            }

            string     bus_name = null;
            ObjectPath op       = null;
            McStatus   status   = mc.GetConnectionStatus(account);

            if (status == McStatus.Connected)
            {
                mc.GetConnection(account, out bus_name, out op);
                iconn = bus.GetObject <IConnection> (Constants.CONNMANAGER_GABBLE_IFACE, op); // get connection
                if (iconn == null)
                {
                    running = false;
                }
                else
                {
                    Console.WriteLine(MSG_PREFIX + "Got connection using account {0}, bus {1}, path {2}"
                                      , account, bus_name, op);
                    //iconn.NewChannel += OnNewChannel;     // deprecated as of 0.17.23
                    irequests                = bus.GetObject <IRequests> (bus_name, op);
                    irequests.NewChannels   += OnNewChannels;
                    irequests.ChannelClosed += OnChannelClosed;     // don't really need this
                    self_handle              = iconn.SelfHandle;
                    Console.WriteLine(MSG_PREFIX + "Your handle is {0}", self_handle);

                    /*
                     * SetTubeCapability (bus_name, op);         // tell Telepathy about our special tube
                     * string service = DTUBE_HANDLER_IFACE + "." + DTUBETEST_IFACE;
                     * string service_path = DTUBE_HANDLER_PATH + DTUBETEST_PATH;
                     * if (tube_partner == null)
                     *  ClaimTubeName (service, service_path);
                     */
                    ProcessContacts(bus_name, op);

                    if (transfer_partner_handle > 0)
                    {
                        SetupFileTransfer();
                    }
                    else if (transfer_partner != null)
                    {
                        Console.WriteLine(MSG_PREFIX + "Our tube partner is missing. Quiting.");
                        running = false;
                    }
                }
            }

            if (running)
            {
                Application.Run();              // run Glib mainloop
            }

            Console.WriteLine(MSG_PREFIX + "Test complete.");
        }