public void run() { this.begin(); loop = new GLib.MainLoop(); loop.Run(); Console.WriteLine(">>> Applet " + this.cAppletName + " terminated"); }
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 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 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 }
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 (); }
public static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine ("usage: mono playbin-player.exe audio_file_uri"); return; } songs = args; 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; } play.Uri = songs[song_idx++]; play.Bus.AddWatch (new BusFunc (BusCb)); play.SetState (State.Playing); loop.Run (); }
public static void Main (string[] args) { Application.Init(); loop = new MainLoop(); // Construct all the elements pipeline = new Pipeline(); appsrc = new Gst.App.AppSrc ("AppSrcDemo"); Element color = ElementFactory.Make ("ffmpegcolorspace"); Element sink = ElementFactory.Make ("autovideosink"); // Link the elements pipeline.Add (appsrc, color, sink); Element.Link (appsrc, color, sink); // Set the caps on the AppSrc to RGBA, 640x480, 4 fps, square pixels Gst.Video.VideoFormat fmt = (BitConverter.IsLittleEndian) ? Gst.Video.VideoFormat.BGRA : Gst.Video.VideoFormat.ARGB; appsrc.Caps = Gst.Video.VideoUtil.FormatNewCaps (fmt, 640, 480, 4, 1, 1, 1); // Connect the handlers appsrc.NeedData += PushAppData; pipeline.Bus.AddSignalWatch(); pipeline.Bus.Message += MessageHandler; // Run, loop, run! pipeline.SetState (State.Playing); loop.Run(); pipeline.SetState (State.Null); }
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(); } }
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(); } }
public HelloWorld(string [] args) { Application.Init(); loop = new MainLoop(); pipeline = new Pipeline ("audio-player"); if ( (source = ElementFactory.Make ("filesrc", "file-source")) == null) { Console.WriteLine ("Could not create file-source"); } parser = ElementFactory.Make ("oggdemux", "ogg-parser"); decoder = ElementFactory.Make ("vorbisdec", "vorbis-decoder"); conv = ElementFactory.Make ("audioconvert", "converter"); identity = ElementFactory.Make ("identity", "identitye"); sink = ElementFactory.Make ("alsasink", "alsa-output"); source["location"] = args[0]; Bin bin = (Bin) pipeline; bin.Bus.AddWatch (new BusFunc (BusCall)); bin.Add (source, parser, decoder, conv, identity, sink); if (!source.Link (parser)) { Console.WriteLine ("link failed between source and parser"); } if (!decoder.Link (conv)) { Console.WriteLine ("link failed between decoder and converter"); } if (!conv.Link (identity)) { Console.WriteLine ("link failed between converter and identity"); } if (!identity.Link (sink)) { Console.Error.WriteLine ("link failed between identity and sink"); } parser.PadAdded += new PadAddedHandler (OnPadAdded); identity.Connect ("handoff", OnHandoff); pipeline.SetState (State.Playing); Console.WriteLine ("Playing [" + args[0] + "]"); loop.Run(); pipeline.SetState (State.Null); pipeline.Dispose(); }
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); }
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); }
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(); }
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 static void Run() { MySrc.Register (); MySink.Register (); MySrc mysrc = Gst.ElementFactory.Make ("mysrc") as MySrc; MySink mysink = Gst.ElementFactory.Make ("mysink") as MySink; Gst.Pipeline pipeline = new Pipeline ("pipeline"); pipeline.Add (mysrc, mysink); Assert.IsTrue (mysrc.Link (mysink)); loop = new MainLoop (); pipeline.Bus.AddWatch (new BusFunc (BusCb)); pipeline.SetState (Gst.State.Playing); loop.Run (); pipeline.SetState (Gst.State.Null); }
public static void Main (string[] args) { // Initialize GObject type system g_type_init (); main_loop = new MainLoop (); if (args.Length == 0 || Array.IndexOf (args, "--help") > -1 || Array.IndexOf (args, "--usage") > -1) PrintUsageAndExit (); if (Array.IndexOf (args, "--version") > -1) { VersionFu.PrintVersion (); Environment.Exit (0); } StringBuilder query_str = new StringBuilder (); query = new Query (); QueryDomain domain = 0; // Parse args int i = 0; while (i < args.Length) { switch (args [i]) { case "--live-query": keep_running = true; break; case "--verbose": verbose = true; break; case "--cache": display_cached_text = true; break; case "--stats-only": verbose = true; display_hits = false; break; case "--max-hits": if (++i >= args.Length) PrintUsageAndExit (); query.MaxHits = Int32.Parse (args[i]); break; case "--flood": flood = true; break; case "--listener": listener = true; keep_running = true; break; case "--raw-uri": raw_uri = true; break; case "--keywords": PropertyKeywordFu.ReadKeywordMappings (); Console.WriteLine ("Supported query keywords are:"); foreach (string key in PropertyKeywordFu.Keys) { foreach (QueryKeywordMapping mapping in PropertyKeywordFu.Properties (key)) { // Dont print properties without description; they confuse people if (string.IsNullOrEmpty (mapping.Description)) continue; Console.WriteLine (" {0,-20} for {1}", key, mapping.Description); } } System.Environment.Exit (0); break; case "--domain": if (++i >= args.Length) PrintUsageAndExit (); switch (args [i].ToLower ()) { case "local": domain |= QueryDomain.Local; break; case "system": domain |= QueryDomain.System; break; case "network": domain |= QueryDomain.Neighborhood; break; case "global": domain |= QueryDomain.Global; break; case "all": domain |= QueryDomain.All; break; default: PrintUsageAndExit (); break; } break; default: if (args [i].StartsWith ("--")) PrintUsageAndExit (); if (query_str.Length > 0) query_str.Append (' '); query_str.Append (args [i]); break; } ++i; } if (domain != 0) query.QueryDomain = domain; if (listener) { query.IsIndexListener = true; } else { if (query_str.Length > 0) query.AddText (query_str.ToString ()); } query.HitsAddedEvent += OnHitsAdded; query.HitsSubtractedEvent += OnHitsSubtracted; if (! keep_running) query.FinishedEvent += OnFinished; else query.ClosedEvent += OnClosed; SendQuery (); main_loop.Run (); }
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"); }
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"); }
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."); }
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 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(); }