public BeaglePlugin() { server = Daemon.Server; db = Daemon.DefaultDatabase; log = Daemon.Log; query = new Query (); query.AddDomain (QueryDomain.Neighborhood); query.MaxHits = 10000; QueryPart_Property filePart = new QueryPart_Property (); filePart.Type = PropertyType.Keyword; filePart.Key = "beagle:HitType"; filePart.Value = "File"; query.AddPart (filePart); QueryPart_Or queryUnion = new QueryPart_Or (); foreach (string mt in supportedMimeTypes) { QueryPart_Property part = new QueryPart_Property (); part.Type = PropertyType.Keyword; part.Key = "beagle:MimeType"; part.Value = mt; queryUnion.Add (part); } query.AddPart (queryUnion); query.HitsAddedEvent += OnHitsAdded; query.HitsSubtractedEvent += OnHitsSubtracted; query.FinishedEvent += OnFinished; int attempts = 0; while (true) { try { query.SendAsync (); break; } catch (Exception e) { if (attempts++ >= 5) { log.Warn ("Failed to initialize beagle plugin"); query = null; break; } // something bad happened, wait a sec and try again log.Debug ("Sending query failed: " + e.Message); log.Debug ("Waiting 3 seconds..."); Thread.Sleep (3000); } } }
public IPodPlugin() { server = Daemon.Server; db = Daemon.DefaultDatabase; log = Daemon.Log; listener = new IPod.DeviceEventListener (); AddDevices (); listener.DeviceAdded += OnDeviceAdded; listener.DeviceRemoved += OnDeviceRemoved; log.Info ("Finished adding iPod devices"); }
public static void Run() { InitializeLogging (); if (!File.Exists (ConfigPath)) { log.WarnFormat ("Config file '{0}' was not found, using defaults", ConfigPath); } AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; #if LINUX || MACOSX UnixSignal.RegisterHandler (Signum.SIGTERM, OnSignal); UnixSignal.RegisterHandler (Signum.SIGINT, OnSignal); UnixSignal.Start (); #else Application.EnableVisualStyles (); Application.SetCompatibleTextRenderingDefault (false); #endif server = new Server (Name); server.UserLogin += OnUserLogin; server.UserLogout += OnUserLogout; server.Port = Port; server.IsPublished = IsPublished; server.Collision += OnCollision; db = new Database (Name); server.AddDatabase (db); server.MaxUsers = MaxUsers; server.TrackRequested += OnTrackRequested; log.Info ("Server name: " + Name); PluginManager.LoadPlugins (PluginNames); #if LINUX if (Inotify.Enabled) { Inotify.Start (); } #endif AddUsers (); try { lock (server) { server.Commit (); server.Start (); } } catch (Exception e) { LogError ("Failed to start server", e); Shutdown (); } RunLoop (); Shutdown (); }