Exemple #1
0
 public void run()
 {
     this.begin();
     loop = new GLib.MainLoop();
     loop.Run();
     Console.WriteLine(">>> Applet " + this.cAppletName + " terminated");
 }
Exemple #2
0
    public static void Main(string[] args)
    {
        GLib.GType.Init();
        GLib.Thread.Init();

        Client client = new Client(new string[] { null });

        client.Uevent += HandleClientUevent;

        Console.WriteLine("Created client {0}", client.ToString());

        foreach (string sub in client.Subsystems)
        {
//			if (string.IsNullOrEmpty (sub))
//			   continue;

            Console.WriteLine("Looking at subsystem: {0}", sub);
            foreach (Device device in client.QueryBySubsystem(sub))
            {
                Console.WriteLine("Looking at:\n\t {0} ({1})\n\t{2}", string.IsNullOrEmpty(device.Name) ? "nameless device" : device.Name,
                                  device.Number, device.DeviceFile);
            }
        }
        GLib.MainLoop loop = new GLib.MainLoop();
        loop.Run();
    }
		static void Main (string[] args)
		{
			if (args.Length != 1) {
				Console.WriteLine ("Usage: TestDirectory <uri>");
				return;
			}
		
			Gnome.Vfs.Vfs.Initialize ();

			FileInfo[] entries = Gnome.Vfs.Directory.GetEntries (args[0]);

			Console.WriteLine ("Directory {0} contains {1} entries:", args[0], entries.Length);
			foreach (FileInfo info in entries) {
				//Console.WriteLine (info.Name);
			}
			
			Gnome.Vfs.Directory.GetEntries (args[0], FileInfoOptions.Default,
							20, (int)Gnome.Vfs.Async.Priority.Default,
							new AsyncDirectoryLoadCallback (OnDirectoryLoad));
			
			loop = new MainLoop ();
			loop.Run ();
			
			Gnome.Vfs.Vfs.Shutdown ();
		}
Exemple #4
0
    static void RunServer(string addr)
    {
        Server serv = Server.ListenAt(addr);

        ServerBus sbus = new ServerBus();

        string activationEnv = Environment.GetEnvironmentVariable("DBUS_ACTIVATION");

        if (activationEnv == "1")
        {
            sbus.ScanServices();
            sbus.allowActivation = true;
        }

        sbus.server         = serv;
        serv.SBus           = sbus;
        serv.NewConnection += sbus.AddConnection;

#if USE_GLIB
        new Thread(new ThreadStart(serv.Listen)).Start();
        //GLib.Idle.Add (delegate { serv.Listen (); return false; });
        GLib.MainLoop main = new GLib.MainLoop();
        main.Run();
#else
        serv.Listen();
#endif
    }
			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;
			}
		static void Main (string[] args)
		{
			if (args.Length != 1) {
				Console.WriteLine ("Usage: TestAsyncStream <uri>");
				return;
			}
		
			Gnome.Vfs.Vfs.Initialize ();

			VfsStream stream = new VfsStream (args[0], FileMode.Open, true);
			
			UTF8Encoding utf8 = new UTF8Encoding ();
			buffer = new byte[1024];
			int read;
			while ((read = stream.Read (buffer, 0, buffer.Length)) != 0) {
				Console.WriteLine ("read ({0} bytes) : '{1}'",
						   read, utf8.GetString (buffer, 0, read));
			}

			long offset = stream.Seek (0, SeekOrigin.Begin);
			Console.WriteLine ("Offset after seek is {0}", offset);
			
			buffer = new byte[1024];
			IAsyncResult result = stream.BeginRead (buffer, 0, buffer.Length,
								new System.AsyncCallback (OnReadComplete),
								stream);

			loop = new MainLoop ();
			loop.Run ();

			Gnome.Vfs.Vfs.Shutdown ();
		}
        public static void Run(string[] args)
        {
            // Initialize GStreamer
            Gst.Application.Init(ref args);

            _bufferingLevel = 100;

            // Build the pipeline

            /* error when setting download flag
             *                      using (_pipeline = Parse.Launch("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"))
             *          Error: The stream is in the wrong format.
             *          ../gst-libs/gst/audio/gstaudiobasesink.c(1117): gst_audio_base_sink_wait_event (): /GstPlayBin:playbin0/GstPlaySink:playsink/GstBin:abin/GstWasapiSink:wasapisink0:
             *          Sink not negotiated before eos event.
             */

            using (_pipeline = Parse.Launch("playbin uri=https://download.blender.org/durian/trailer/sintel_trailer-1080p.ogv")) // Works
//            using (_pipeline = Parse.Launch("playbin uri=https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps_1920x1080_8000k.mpd")) // works
//          using (_pipeline = Parse.Launch("playbin uri=file:///U:/Video/test.mp4")) // works
            {
                var bus = _pipeline.Bus;

                var flags = _pipeline.Flags;
                flags          |= GST_PLAY_FLAG_DOWNLOAD;
                _pipeline.Flags = flags;

                // Uncomment this line to limit the amount of downloaded data
                _pipeline["ring-buffer-max-size"] = 4000000L;

                // Start playing
                var ret = _pipeline.SetState(State.Playing);
                if (ret == StateChangeReturn.Failure)
                {
                    "Unable to set the pipeline to the playing state.".PrintErr();
                    _pipeline.Dispose();
                    return;
                }
                else if (ret == StateChangeReturn.NoPreroll)
                {
                    _isLive = true;
                }

                _loop = new GLib.MainLoop();

                bus.AddSignalWatch();
                bus.Message += CbMessage;
                _pipeline.Connect("deep-notify::temp-location", GotLocation);

                // Register a function that GLib will call every second
                GLib.Timeout.AddSeconds(1, RefreshUI);

                _loop.Run();

                _pipeline.SetState(State.Null);
                bus.Dispose();
            }
        }
Exemple #8
0
		public static void Main24 (string[] args)
		{
			CommandLineSyncTest ();
			CommandLineAsyncTest ();
			SyncTest ();
			AsyncTest ();
			AsyncWithPipesTest ();
			ml = new MainLoop ();
			ml.Run ();
		}
        public static void Run(string[] args)
        {
            // Initialize GStreamer
            Gst.Application.Init(ref args);

            _bufferingLevel = 100;

            // Build the pipeline
            using (_pipeline = Parse.Launch("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"))
            {
                var bus = _pipeline.Bus;

                // Set the download flag
                GstPlayFlags flags = (GstPlayFlags)_pipeline["flags"];
                flags |= GstPlayFlags.Download;
                _pipeline["flags"] = (uint)flags;

                /* This doesn't work? flags = 0 ?
                 *              GstPlayFlags flags = (GstPlayFlags)_pipeline.Flags;
                 *              flags |= GstPlayFlags.Download;
                 *              _pipeline.Flags = (uint)flags;
                 */
                // Uncomment this line to limit the amount of downloaded data
                _pipeline["ring-buffer-max-size"] = 4000000L;

                // Start playing
                var ret = _pipeline.SetState(State.Playing);
                if (ret == StateChangeReturn.Failure)
                {
                    "Unable to set the pipeline to the playing state.".PrintErr();
                    _pipeline.Dispose();
                    return;
                }
                else if (ret == StateChangeReturn.NoPreroll)
                {
                    _isLive = true;
                }

                _loop = new GLib.MainLoop();

                bus.AddSignalWatch();
                bus.Message += CbMessage;
                _pipeline.Connect("deep-notify::temp-location", GotLocation);

                // Register a function that GLib will call every second
                GLib.Timeout.AddSeconds(1, RefreshUI);

                _loop.Run();

                _pipeline.SetState(State.Null);
                bus.Dispose();
            }
        }
Exemple #10
0
        public GStreamerAudioStream()
        {
            Gst.Application.Init();
            loop = new MainLoop();

            play = ElementFactory.Make ("playbin", "play") as PlayBin;

            if (play == null) {
                Console.WriteLine ("error creating a playbin gstreamer object");
                return;
            }
        }
    public void TestBufferOwnershipNIp()
    {
        MyTransformNIp.Register();

        Pipeline pipeline = new Pipeline();
        Element  src      = ElementFactory.Make("fakesrc");

        src["sizetype"] = 2;
        Element capsfilter = ElementFactory.Make("capsfilter");

        capsfilter["caps"] = Caps.FromString("foo/bar");
        src["num-buffers"] = 10;
        MyTransformNIp transform = new MyTransformNIp();
        Element        sink      = ElementFactory.Make("fakesink");

        pipeline.Add(src, capsfilter, transform, sink);
        Element.Link(src, capsfilter, transform, sink);

        GLib.MainLoop loop = new GLib.MainLoop();

        pipeline.Bus.AddWatch(delegate(Bus bus, Message message) {
            switch (message.Type)
            {
            case MessageType.Error:
                Enum err;
                string msg;

                message.ParseError(out err, out msg);
                Assert.Fail(String.Format("Error message: {0}", msg));
                loop.Quit();
                break;

            case MessageType.Eos:
                loop.Quit();
                break;
            }
            return(true);
        });

        pipeline.SetState(State.Playing);
        loop.Run();
        Assert.IsTrue(transform.transformed);
        pipeline.SetState(State.Null);
    }
		static void Main (string[] args)
		{
			if (args.Length != 1) {
				Console.WriteLine ("Usage: TestAsync <uri>");
				return;
			}
		
			Gnome.Vfs.Vfs.Initialize ();

			Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri (args[0]);
			handle = Async.Open (uri, OpenMode.Read,
					     (int)Async.Priority.Default,
					     new Gnome.Vfs.AsyncCallback (OnOpen));
			
			loop = new MainLoop ();
			loop.Run ();
			
			Gnome.Vfs.Vfs.Shutdown ();
		}
    static void Main(string[] args)
    {
        Gst.Application.Init();
        TransformSample.Register();

        Pipeline pipeline         = new Pipeline();
        Element  videotestsrc     = ElementFactory.Make("videotestsrc");
        Element  transform        = new TransformSample();
        Element  ffmpegcolorspace = ElementFactory.Make("ffmpegcolorspace");
        Element  videosink        = ElementFactory.Make("autovideosink");

        pipeline.Add(videotestsrc, transform, ffmpegcolorspace, videosink);
        Element.Link(videotestsrc, transform, ffmpegcolorspace, videosink);

        GLib.MainLoop loop = new GLib.MainLoop();

        pipeline.Bus.AddSignalWatch();
        pipeline.Bus.Message += delegate(object sender, MessageArgs margs) {
            Message message = margs.Message;

            switch (message.Type)
            {
            case MessageType.Error:
                Enum   err;
                string msg;

                message.ParseError(out err, out msg);
                System.Console.WriteLine(String.Format("Error message: {0}", msg));
                loop.Quit();
                break;

            case MessageType.Eos:
                loop.Quit();
                break;
            }
        };

        pipeline.SetState(State.Playing);
        loop.Run();
        pipeline.SetState(State.Null);
    }
Exemple #14
0
    public void TestBusCallback(bool use_AddWatch)
    {
        pipeline = new Pipeline();
        Assert.IsNotNull(pipeline, "Could not create pipeline");

        Element src = ElementFactory.Make("fakesrc");

        Assert.IsNotNull(src, "Could not create fakesrc");
        Element sink = ElementFactory.Make("fakesink");

        Assert.IsNotNull(sink, "Could not create fakesink");

        Bin bin = (Bin)pipeline;

        bin.Add(src, sink);
        Assert.IsTrue(src.Link(sink), "Could not link between src and sink");

        if (use_AddWatch)
        {
            pipeline.Bus.AddWatch(new BusFunc(MessageReceived));
        }
        else
        {
            pipeline.Bus.AddSignalWatch();
            pipeline.Bus.Message += delegate(object o, MessageArgs args) {
                MessageReceived(null, args.Message);
            };
        }
        Assert.AreEqual(pipeline.SetState(State.Playing), StateChangeReturn.Async);

        loop = new GLib.MainLoop();
        loop.Run();

        Assert.AreEqual(pipeline.SetState(State.Null), StateChangeReturn.Success);
        State current, pending;

        Assert.AreEqual(pipeline.GetState(out current, out pending, Clock.TimeNone), StateChangeReturn.Success);
        Assert.AreEqual(current, State.Null, "state is not NULL but " + current);
    }
Exemple #15
0
    public static void Main(string[] args)
    {
        GLib.GType.Init ();
        GLib.Thread.Init ();

        Client client = new Client (new string[] {null});
        client.Uevent += HandleClientUevent;

        Console.WriteLine ("Created client {0}", client.ToString());

        foreach (string sub in client.Subsystems) {
        //			if (string.IsNullOrEmpty (sub))
        //			   continue;

            Console.WriteLine ("Looking at subsystem: {0}", sub);
            foreach (Device device in client.QueryBySubsystem (sub)) {
                Console.WriteLine ("Looking at:\n\t {0} ({1})\n\t{2}", string.IsNullOrEmpty (device.Name) ? "nameless device" : device.Name,
                    device.Number, device.DeviceFile);
            }
        }
        GLib.MainLoop loop = new GLib.MainLoop ();
        loop.Run ();
    }
    public static void Main(string [] args)
    {
        if (args.Length < 2)
        {
            Console.WriteLine("Usage: mono decodebin-transcoder.exe <input-file> <output-file>");
            return;
        }

        Gst.Application.Init();
        loop = new GLib.MainLoop();

        DecodeBinTranscoder transcoder = new DecodeBinTranscoder();

        transcoder.Error += delegate(object o, ErrorArgs eargs) {
            Console.WriteLine("Error: {0}", eargs.Error);
            transcoder.Dispose();
            loop.Quit();
        };

        transcoder.Finished += delegate {
            Console.WriteLine("\nFinished");
            transcoder.Dispose();
            loop.Quit();
        };

        transcoder.Progress += delegate(object o, ProgressArgs pargs) {
            Console.Write("\rEncoding: {0} / {1} ({2:00.00}%) ",
                          new TimeSpan((pargs.Position / (long)Clock.Second) * TimeSpan.TicksPerSecond),
                          new TimeSpan((pargs.Duration / (long)Clock.Second) * TimeSpan.TicksPerSecond),
                          ((double)pargs.Position / (double)pargs.Duration) * 100.0);
        };

        transcoder.Transcode(args[0], args[1]);

        loop.Run();
    }
Exemple #17
0
                private static void DoMain (string [] args)
                {
                        SystemInformation.SetProcessName ("beagrepd-helper");

                        bool run_by_hand = (Environment.GetEnvironmentVariable ("BEAGREP_RUN_HELPER_BY_HAND") != null);
                        bool log_in_fg = (Environment.GetEnvironmentVariable ("BEAGREP_LOG_IN_THE_FOREGROUND_PLEASE") != null);

                        bool debug = false, disable_textcache = false;

                        foreach (string arg in args)
                                if (arg == "--disable-text-cache")
                                        disable_textcache = true;
                                else if (arg == "--debug")
                                        debug = true;

                        last_activity = DateTime.Now;

                        Log.Initialize (PathFinder.LogDir,
                                        "IndexHelper",
                                        debug ? LogLevel.Debug : LogLevel.Warn,
                                        run_by_hand || log_in_fg);

                        Log.Always ("Starting Index Helper process (version {0})", ExternalStringsHack.Version);
                        Log.Always ("Running on {0}", SystemInformation.MonoRuntimeVersion);
                        Log.Always ("Extended attributes are {0}", ExtendedAttribute.Supported ? "supported" : "not supported");
                        Log.Always ("Command Line: {0}",
                                    Environment.CommandLine != null ? Environment.CommandLine : "(null)");
                        if (disable_textcache)
                                Log.Always ("Text cache is disabled.");

                        // Initialize GObject type system
                        g_type_init ();

                        // Set the IO priority to idle, nice ourselves, and set
                        // a batch scheduling policy so we that we play nice
                        // on the system
                        if (Environment.GetEnvironmentVariable ("BEAGREP_EXERCISE_THE_DOG") != null)
                                Log.Always ("BEAGREP_EXERCISE_THE_DOG is set");

                        Server.Init ();

#if MONO_1_9
                        Shutdown.SetupSignalHandlers (new Shutdown.SignalHandler (HandleSignal));
#else
                        SetupSignalHandlers ();
#endif

                        Shutdown.ShutdownEvent += OnShutdown;

                        main_loop = new MainLoop ();
                        Shutdown.RegisterMainLoop (main_loop);

                        // Start the server
                        Log.Debug ("Starting messaging server");
                        bool server_has_been_started = false;
                        try {
                                server = new Server ("socket-helper", true, false);
                                server.Start ();
                                server_has_been_started = true;
                        } catch (InvalidOperationException ex) {
                                Logger.Log.Error (ex, "Couldn't start server.  Exiting immediately.");
                        }

                        if (server_has_been_started) {
                                // Whether we should generate heap-shot snapshots
                                heap_shot = (Environment.GetEnvironmentVariable ("_HEY_LETS_DO_A_HEAP_SHOT") != null);

                                if (! run_by_hand) {
                                        // Start the monitor thread, which keeps an eye on memory usage and idle time.
                                        ExceptionHandlingThread.Start (new ThreadStart (MemoryAndIdleMonitorWorker));

                                        // Start a thread that watches the daemon and begins a shutdown
                                        // if it terminates.
                                        ExceptionHandlingThread.Start (new ThreadStart (DaemonMonitorWorker));
                                }

                                // Start the main loop
                                main_loop.Run ();

                                ExceptionHandlingThread.JoinAllThreads ();

                                // If we placed our sockets in a temp directory, try to clean it up
                                // Note: this may fail because the daemon is still running
                                if (PathFinder.GetRemoteStorageDir (false) != PathFinder.StorageDir) {
                                        try {
                                                Directory.Delete (PathFinder.GetRemoteStorageDir (false));
                                        } catch (IOException) { }
                                }

                                Log.Always ("Index helper process shut down cleanly.");
                        }
                }
 public void Run()
 {
     MainLoop loop = new MainLoop();
     loop.Run();
 }
	public void run()
	{
		this.begin();
		loop = new GLib.MainLoop();
		loop.Run();
		Console.WriteLine(">>> Applet " + this.cAppletName + " terminated");
	}
Exemple #20
0
        public void Setup()
        {
            world = new World ();
            loop = new MainLoop ();

            actor1 = new MockActor ("Mock Actor 1", loop, world);
            actor2 = new MockActor ("Mock Actor 2", loop, world);
        }
Exemple #21
0
        public void TestSpawn()
        {
            Spawn spawn;
            UnixReader reader;
            string[] argv = { "/bin/cat" };
            UnixStream stream;
            StreamWriter writer;
            int stdin, stdout, stderr;

            spawn = new Spawn ();

            spawn.SpawnAsyncWithPipes (null,
                           argv,
                           null,
                           GSpawnFlags.G_SPAWN_DO_NOT_REAP_CHILD,
                           null,
                           out pid,
                           out stdin, out stdout, out stderr);

            pids_matched = false;
            exit_status_is_good = false;
            spawn.ChildWatchAdd (pid, child_watch_cb);

            stream = new UnixStream (stdin, true);
            writer = new StreamWriter (stream);

            writer.Write ("Hello, world!");
            writer.Close (); /* this will close the stdin fd */

            reader = new UnixReader (stdout);
            reader.DataAvailable += data_available_cb;
            reader.Closed += closed_cb;

            string_equal = false;
            closed = false;

            loop = new MainLoop ();
            loop.Run ();

            Assert.IsTrue (string_equal, "Read the correct string");
            Assert.IsTrue (closed, "UnixReader got closed");
            Assert.IsTrue (pids_matched, "PID of child process");
            Assert.IsTrue (exit_status_is_good, "Exit status of child process");
        }
Exemple #22
0
                public static void DoMain (string[] args)
                {
                        SystemInformation.InternalCallInitializer.Init ();
                        SystemInformation.SetProcessName ("beagrepd");

                        // Process the command-line arguments
                        bool arg_debug = false;
                        bool arg_debug_memory = false;
                        bool arg_fg = false;

                        int i = 0;
                        while (i < args.Length) {

                                string arg = args [i];
                                ++i;
                                string next_arg = i < args.Length ? args [i] : null;

                                switch (arg) {
                                case "-h":
                                case "--help":
                                        PrintUsage ();
                                        Environment.Exit (0);
                                        break;

                                case "--mdb":
                                case "--mono-debug":
                                        // Silently ignore these arguments: they get handled
                                        // in the wrapper script.
                                        break;

                                case "--list-backends":
                                        Console.WriteLine ("Current available backends:");
                                        Console.Write (QueryDriver.ListBackends ());
                                        Environment.Exit (0);
                                        break;

                                case "--fg":
                                case "--foreground":
                                        arg_fg = true;
                                        break;

                                case "--bg":
                                case "--background":
                                        arg_fg = false;
                                        break;

                                case "--replace":
                                        arg_replace = true;
                                        break;

                                case "--debug":
                                        arg_debug = true;
                                        break;

                                case "--heap-shot":
                                        arg_heap_shot = true;
                                        arg_debug = true;
                                        arg_debug_memory = true;
                                        break;

                                case "--no-snapshots":
                                case "--no-snapshot":
                                        arg_heap_shot_snapshots = false;
                                        break;

                                case "--heap-buddy":
                                case "--debug-memory":
                                        arg_debug = true;
                                        arg_debug_memory = true;
                                        break;

                                case "--indexing-test-mode":
                                        arg_indexing_test_mode = true;
                                        arg_fg = true;
                                        break;

                                case "--backend":
                                        if (next_arg == null) {
                                                Console.WriteLine ("--backend requires a backend name");
                                                Environment.Exit (1);
                                                break;
                                        }

                                        if (next_arg.StartsWith ("--")) {
                                                Console.WriteLine ("--backend requires a backend name. Invalid name '{0}'", next_arg);
                                                Environment.Exit (1);
                                                break;
                                        }

                                        if (next_arg [0] != '+' && next_arg [0] != '-')
                                                QueryDriver.OnlyAllow (next_arg);
                                        else {
                                                if (next_arg [0] == '+')
                                                        QueryDriver.Allow (next_arg.Substring (1));
                                                else
                                                        QueryDriver.Deny (next_arg.Substring (1));
                                        }

                                        ++i; // we used next_arg
                                        break;

                               case "--add-static-backend":
                                        if (next_arg != null)
                                                QueryDriver.AddStaticQueryable (next_arg);
                                        ++i;
                                        break;

                                case "--disable-scheduler":
                                        arg_disable_scheduler = true;
                                        break;

                                case "--indexing-delay":
                                        if (next_arg != null) {
                                                try {
                                                        QueryDriver.IndexingDelay = Int32.Parse (next_arg);
                                                } catch {
                                                        Console.WriteLine ("'{0}' is not a valid number of seconds", next_arg);
                                                        Environment.Exit (1);
                                                }
                                        }

                                        ++i;
                                        break;

                                case "--autostarted":
                                        // FIXME: This option is deprecated and will be removed in a future release.
                                        break;

                                case "--disable-text-cache":
                                        disable_textcache = true;
                                        break;

                                case "--version":
                                        VersionFu.PrintVersion ();
                                        Environment.Exit (0);
                                        break;

                                default:
                                        Console.WriteLine ("Unknown argument '{0}'", arg);
                                        Environment.Exit (1);
                                        break;

                                }
                        }

                        if (Environment.GetEnvironmentVariable ("SABAYON_SESSION_RUNNING") == "yes") {
                                Console.WriteLine ("Beagrep is running underneath Sabayon, exiting.");
                                Environment.Exit (0);
                        }

                        if (arg_indexing_test_mode) {
                                LuceneQueryable.OptimizeRightAway = true;
                        }

                        // Bail out if we are trying to run as root
                        if (Environment.UserName == "root" && Environment.GetEnvironmentVariable ("SUDO_USER") != null) {
                                Console.WriteLine ("You appear to be running beagrep using sudo.  This can cause problems with");
                                Console.WriteLine ("permissions in your .beagrep and .wapi directories if you later try to run");
                                Console.WriteLine ("as an unprivileged user.  If you need to run beagrep as root, please use");
                                Console.WriteLine ("'su -c' instead.");
                                Environment.Exit (-1);
                        }

                        if (Environment.UserName == "root" && ! Conf.Daemon.GetOption (Conf.Names.AllowRoot, false)) {
                                Console.WriteLine ("You can not run beagrep as root.  Beagrep is designed to run from your own");
                                Console.WriteLine ("user account.  If you want to create multiuser or system-wide indexes, use");
                                Console.WriteLine ("the beagrep-build-index tool.");
                                Console.WriteLine ();
                                Console.WriteLine ("You can override this setting using the beagrep-config or beagrep-settings tools.");
                                Environment.Exit (-1);
                        }

                        try {
                                string tmp = PathFinder.HomeDir;
                        } catch (Exception e) {
                                Console.WriteLine ("Unable to start the daemon: {0}", e.Message);
                                Environment.Exit (-1);
                        }

                        MainLoopThread = Thread.CurrentThread;

                        // FIXME: We always turn on full debugging output!  We are still
                        // debugging this code, after all...
                        // arg_debug ? LogLevel.Debug : LogLevel.Warn

                        Log.Initialize (PathFinder.LogDir, "Beagrep", LogLevel.Debug, arg_fg);
                        Log.Always ("Starting Beagrep Daemon (version {0})", ExternalStringsHack.Version);
                        Log.Always ("Running on {0}", SystemInformation.MonoRuntimeVersion);
                        Log.Always ("Command Line: {0}",
                                           Environment.CommandLine != null ? Environment.CommandLine : "(null)");

                        if (! ExtendedAttribute.Supported) {
                                Logger.Log.Warn ("Extended attributes are not supported on this filesystem. " +
                                                 "Performance will suffer as a result.");
                        }

                        if (disable_textcache) {
                                Log.Warn ("Running with text-cache disabled!");
                                Log.Warn ("*** Snippets will not be returned for documents indexed in this session.");
                        }

                        // Check if global configuration files are installed
                        if (! Conf.CheckGlobalConfig ()) {
                                Console.WriteLine ("Global configuration files not found in '{0}'", PathFinder.ConfigDataDir);
                                Environment.Exit (-1);
                        }

                        // Start our memory-logging thread
                        if (arg_debug_memory) {
                                ExceptionHandlingThread.Start (new ThreadStart (LogMemoryUsage));
                        }

                        // Do BEAGREP_EXERCISE_THE_DOG_HARDER-related processing.
                        ExerciseTheDogHarder ();

                        // Initialize GObject type system
                        g_type_init ();

                        QueryDriver.Init ();
                        Server.Init ();

#if MONO_1_9
                        Shutdown.SetupSignalHandlers (new Shutdown.SignalHandler (HandleSignal));
#else
                        SetupSignalHandlers ();
#endif

                        Shutdown.ShutdownEvent += OnShutdown;

                        main_loop = new MainLoop ();
                        Shutdown.RegisterMainLoop (main_loop);

                        // Defer all actual startup until the main loop is
                        // running.  That way shutdowns during the startup
                        // process work correctly.
                        GLib.Idle.Add (new GLib.IdleHandler (StartupProcess));

                        // Start our event loop.
                        main_loop.Run ();

                        // We're out of the main loop now, join all the
                        // running threads so we can exit cleanly.
                        ExceptionHandlingThread.JoinAllThreads ();

                        // If we placed our sockets in a temp directory, try to clean it up
                        // Note: this may fail because the helper is still running
                        if (PathFinder.GetRemoteStorageDir (false) != PathFinder.StorageDir) {
                                try {
                                        Directory.Delete (PathFinder.GetRemoteStorageDir (false));
                                } catch (IOException) { }
                        }

                        Log.Always ("Beagrep daemon process shut down cleanly.");
                }
Exemple #23
0
	static void RunServer (string addr)
	{
		Server serv = Server.ListenAt (addr);

		ServerBus sbus = new ServerBus ();

		string activationEnv = Environment.GetEnvironmentVariable ("DBUS_ACTIVATION");
		if (activationEnv == "1") {
			sbus.ScanServices ();
			sbus.allowActivation = true;
		}

		sbus.server = serv;
		serv.SBus = sbus;
		serv.NewConnection += sbus.AddConnection;

#if USE_GLIB
		new Thread (new ThreadStart (serv.Listen)).Start ();
		//GLib.Idle.Add (delegate { serv.Listen (); return false; });
		GLib.MainLoop main = new GLib.MainLoop ();
		main.Run ();
#else
		serv.Listen ();
#endif
	}
Exemple #24
0
        public void Aggregate()
        {
            string[] argv = { "/bin/cat" };
            string stdin_str = get_stdin_str ();

            AggregatorRunner runner = new AggregatorRunner ();
            runner.ChildExited += child_exited_cb;

            runner.Run (aggregator, argv, stdin_str);

            loop = new MainLoop ();
            loop.Run ();

            Assert.IsTrue (unix.WIFEXITED (child_status) && unix.WEXITSTATUS (child_status) == 0,
                       "Child exit status = 0");

            Assert.IsTrue (check_log (), "Contents of aggregated log");
        }
        static void Main(string[] args)
        {
            Application.Init(ref args);

            Element src = ElementFactory.Make("audiotestsrc");
            Element convert = ElementFactory.Make("audioconvert");
            Element volume = new ExampleVolume();
            Element sink = ElementFactory.Make("autoaudiosink");

            Pipeline pipeline = new Pipeline();
            pipeline.Add(src, convert, volume, sink);
            Element.Link(src, convert, volume, sink);

            pipeline.SetState(State.Playing);

            MainLoop loop = new MainLoop();
            loop.Run();

            pipeline.SetState(State.Null);

            Console.ReadLine();
        }