コード例 #1
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);
            }
        }
コード例 #2
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();
    }
コード例 #3
0
ファイル: Registrar.cs プロジェクト: codecopy/core-1
 static Registrar()
 {
     try {
         BusG.Init();
     } catch {
     }
 }
コード例 #4
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");
            }
        }
コード例 #5
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;
        }
コード例 #6
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();
    }
コード例 #7
0
        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
        }
コード例 #8
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();
                }
            }
        }
コード例 #9
0
        static SystemManagement()
        {
            try {
                BusG.Init();
            } catch (Exception e) {
                Log <SystemManagement> .Error("Could not initialize the bus: {0}", e.Message);

                Log <SystemManagement> .Debug(e.StackTrace);
            }
        }
コード例 #10
0
ファイル: RemoteControl.cs プロジェクト: teotikalki/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)));
        }
コード例 #11
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();
        }
コード例 #12
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?");
     }
 }
コード例 #13
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?");
     }
 }
コード例 #14
0
ファイル: RemoteControl.cs プロジェクト: teotikalki/tasque
        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);
        }
コード例 #15
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);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
ファイル: NetworkManager.cs プロジェクト: jamesaxl/smuxi
        void Init()
        {
            BusG.Init();

            if (!Bus.System.NameHasOwner(BusName))
            {
                return;
            }

            Manager = Bus.System.GetObject <INetworkManager>(
                BusName, new ObjectPath(ObjectPath)
                );
            Manager.StateChanged += OnStateChanged;

            IsInitialized = true;
        }
コード例 #18
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);
            }
        }
コード例 #19
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;
            }
        }
コード例 #20
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);
                }
            }
        }
コード例 #21
0
ファイル: RemoteControlProxy.cs プロジェクト: PypeBros/tomboy
        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
        }
コード例 #22
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);
            }
        }
コード例 #23
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
        }
コード例 #24
0
ファイル: TestExport.cs プロジェクト: karim10/dbus-sharp-glib
    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();
    }
コード例 #25
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();
    }
コード例 #26
0
ファイル: Main.cs プロジェクト: garuma/zencomic
        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();
        }
コード例 #27
0
        public static void Main(string[] args)
        {
            bool dbus_enabled = true;

            try {
                // Init DBus
                BusG.Init();
            } catch (Exception e) {
                // Lack of specific exception
                Log.Error(e, "Failed to access dbus session bus. Make sure dbus session bus is running and the environment variable DBUS_SESSION_BUS_ADDRESS is set.");
                dbus_enabled = false;
            }

            string query = ParseArgs(args);

            // If there is already an instance of beagle-search running
            // request our search proxy object and open up a query in
            // that instance.

            if (dbus_enabled && Bus.Session.RequestName(BUS_NAME) != RequestNameReply.PrimaryOwner)
            {
                if (icon_enabled)
                {
                    Console.WriteLine("There is already an instance of beagle-search running.");
                    Console.WriteLine("Cannot run in --icon mode! Exiting...");
                    Environment.Exit(1);
                }

                ISearch s = Bus.Session.GetObject <ISearch> (BUS_NAME, new ObjectPath(PATH_NAME));
                s.Query(query);

                return;
            }

            SystemInformation.SetProcessName("beagle-search");
            Catalog.Init("beagle", ExternalStringsHack.LocaleDir);

            Gnome.Program program = new Gnome.Program("search", "0.0", Gnome.Modules.UI, args);
            Gtk.IconTheme.Default.AppendSearchPath(System.IO.Path.Combine(ExternalStringsHack.PkgDataDir, "icons"));

            if (icon_enabled && !dbus_enabled)
            {
                HigMessageDialog.RunHigMessageDialog(null,
                                                     Gtk.DialogFlags.Modal,
                                                     Gtk.MessageType.Error,
                                                     Gtk.ButtonsType.Close,
                                                     Catalog.GetString("Session D-Bus not accessible"),
                                                     Catalog.GetString("Cannot run with parameter '--icon' when session D-Bus is not accessible."));
                Environment.Exit(1);
            }

            Gnome.Vfs.Vfs.Initialize();

            // FIXME: Passing these icon and docs enabled properties
            // sucks. We really need to do something about them.
            Search search = new Search(icon_enabled, docs_enabled);

            if (!String.IsNullOrEmpty(query) || !icon_enabled)
            {
                search.Query(query);
            }

            if (dbus_enabled)
            {
                Bus.Session.Register(BUS_NAME, new ObjectPath(PATH_NAME), search);
            }

            program.Run();
        }
コード例 #28
0
 static Notification()
 {
     BusG.Init();
 }
コード例 #29
0
ファイル: Docky.cs プロジェクト: d1v0id/docky
        public static void Main(string[] args)
        {
            // output the version number & system info
            Log.DisplayLevel = LogLevel.Info;
            Log.Info("Docky version: {0} {1}", AssemblyInfo.DisplayVersion, AssemblyInfo.VersionDetails);
            Log.Info("Kernel version: {0}", System.Environment.OSVersion.Version);
            Log.Info("CLR version: {0}", System.Environment.Version);

            //Init gtk and GLib related
            Catalog.Init("docky", AssemblyInfo.LocaleDirectory);
            if (!GLib.Thread.Supported)
            {
                GLib.Thread.Init();
            }
            Gdk.Threads.Init();
            Gtk.Application.Init("Docky", ref args);
            GLib.GType.Init();
            try {
                BusG.Init();
            } catch {
                Log.Fatal("DBus could not be found and is required by Docky. Exiting.");
                return;
            }

            // process the command line args
            if (!UserArgs.Parse(args))
            {
                return;
            }

            DockServices.Init(UserArgs.DisableDockManager);

            Wnck.Global.ClientType = Wnck.ClientType.Pager;

            // set process name
            DockServices.System.SetProcessName("docky");

            // cache main thread
            DockServices.System.MainThread = Thread.CurrentThread;

            // check compositing
            if (Controller.CompositeCheckEnabled)
            {
                CheckComposite(8);
                Gdk.Screen.Default.CompositedChanged += delegate {
                    CheckComposite(2);
                };
            }

            if (!DBusManager.Default.Initialize(UserArgs.DisableDockManager))
            {
                Log.Fatal("Another Docky instance was detected - exiting.");
                return;
            }

            DBusManager.Default.QuitCalled += delegate {
                Quit();
            };
            DBusManager.Default.SettingsCalled += delegate {
                ConfigurationWindow.Instance.Show();
            };
            DBusManager.Default.AboutCalled += delegate {
                ShowAbout();
            };
            PluginManager.Initialize();
            Controller.Initialize();

            Gdk.Threads.Enter();
            Gtk.Application.Run();
            Gdk.Threads.Leave();

            Controller.Dispose();
            DockServices.Dispose();
            PluginManager.Shutdown();
        }
コード例 #30
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.");
        }