public LocalClientStandbyHandler(String url, int tag) { try { _remote = (IStandbyHandler)Activator.GetObject(typeof(IStandbyHandler), url); this._tag = tag; this._url = url; } catch (Exception ex) { Log.Debug("LocalClientStandbyHandler: {0}", ex.Message); } }
public void UserShutdownNow() { if (remote == null) { return; } try { remote.UserShutdownNow(); } catch (Exception) { // broken remote handler, nullify this one (dead) remote = null; } }
public void UserShutdownNow() { try { if (_remote == null) { return; } _remote.UserShutdownNow(); } catch (Exception ex) { // broken remote handler, nullify this one (dead) Log.Debug("LocalClientStandbyHandler: {0}", ex.Message); _remote = null; } }
public void Start() { Log.Info("PS: Starting PowerScheduler client plugin..."); try { // Register for MediaPortal actions to see if user is active GUIWindowManager.OnNewAction += new OnActionHandler(this.OnAction); // Create the timer that will wakeup the system after a specific amount of time after the // system has been put into standby _wakeupTimer = new WaitableTimer(); // Load settings LoadSettings(); // Unmute master volume if (_settings.GetSetting("UnmuteMasterVolume").Get<bool>()) { try { using (MasterVolume _masterVolume = new MasterVolume()) { if (_masterVolume.IsMuted) { Log.Debug("PS: Master volume is muted - unmute it"); _masterVolume.IsMuted = false; } } } catch (Exception ex) { Log.Error("PS: Error in handling master volume - {0}", ex.Message); } } // Register as global service provider instance if (!GlobalServiceProvider.Instance.IsRegistered<IPowerScheduler>()) { GlobalServiceProvider.Instance.Add<IPowerScheduler>(this); } Log.Debug("PS: Registered PowerScheduler as IPowerScheduler service to GlobalServiceProvider"); // Register standby/wakeup handlers _wakeableStandbyHandler = new WakeableStandbyHandler(); Register(_wakeableStandbyHandler); _wakeableWakeupHandler = new WakeableWakeupHandler(); Register(_wakeableWakeupHandler); if (!_singleSeat) { // Register special standby/wakeup handlers (remote client only) _factory = new PowerSchedulerFactory(); _factory.CreateDefaultSet(); } Log.Debug("PS: Registered standby/wakeup handlers to PowerScheduler client plugin"); // Register PSClientPlugin as standby / wakeup handler for PowerScheduler server (single-seat only) if (_singleSeat) RegisterToRemotePowerScheduler(); // Create the EventWaitHandles for the StandbyWakeupThread and GetCurrentState _standbyWakeupTriggered = new EventWaitHandle(false, EventResetMode.AutoReset, "MediaPortal.PowerScheduler.StandbyWakeupTriggered"); _standbyWakeupFinished = new AutoResetEvent(false); _standbyWakeupSuspend = new AutoResetEvent(false); // initially do not take suspend branch _standbyWakeupResume = new ManualResetEvent(true); // initially releases (no block) // Start the StandbyWakeupThread responsible for checking standby conditions and setting the wakeup timer _parentThread = Thread.CurrentThread; _standbyWakeupThread = new Thread(StandbyWakeupThread); _standbyWakeupThread.Name = "PS StandbyWakeup"; _standbyWakeupThread.Start(); Log.Debug("PS: StandbyWakeupThread started"); SendPowerSchedulerEvent(PowerSchedulerEventType.Started); Log.Info("PS: PowerScheduler client plugin started"); } catch (Exception ex) { Log.Error("PS: Exception in Start: {0}", ex); Stop(); } }
public bool IsRegistered(IStandbyHandler handler) { return _standbyHandlers.Contains(handler); }
public void Unregister(IStandbyHandler handler) { if (_standbyHandlers.Contains(handler)) _standbyHandlers.Remove(handler); }
public void Register(IStandbyHandler handler) { if (!_standbyHandlers.Contains(handler)) _standbyHandlers.Add(handler); }
public void Close() { remote = null; }
public RemoteStandbyHandler(String URL, int tag) { remote = (IStandbyHandler)Activator.GetObject(typeof(IStandbyHandler), URL); this.tag = tag; this.Url = URL; }
public void UserShutdownNow() { try { if (_remote == null) return; _remote.UserShutdownNow(); } catch (Exception ex) { // broken remote handler, nullify this one (dead) Log.Debug("LocalClientStandbyHandler: {0}", ex.Message); _remote = null; } }
public void Close() { _remote = null; }