Esempio n. 1
0
        public void Start(IController controller)
        {
            _inConfiguration = false;

            Log.Info("TV3BlasterPlugin: Starting ({0})", PluginVersion);

            // Load basic settings
            LoadSettings();

            LoadExternalConfigs();

            ITvServerEvent events = GlobalServiceProvider.Instance.Get <ITvServerEvent>();

            events.OnTvServerEvent += events_OnTvServerEvent;

            IPAddress  serverIP = Network.GetIPFromName(_serverHost);
            IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort);

            if (!StartClient(endPoint))
            {
                Log.Error("TV3BlasterPlugin: Failed to start local comms, IR blasting is disabled for this session");
            }

            Log.Debug("TV3BlasterPlugin: Started");
        }
Esempio n. 2
0
        /// Starts the plugin
        /// </summary>
        public void Start(IController controller)
        {
            Controller = controller as TvService.TVController;

            ITvServerEvent events = GlobalServiceProvider.Instance.Get <ITvServerEvent>();

            if (events != null)
            {
                events.OnTvServerEvent += new TvServerEventHandler(events_OnTvServerEvent);
            }

            try
            {
                httpChannel = new HttpChannel(9998);
                ChannelServices.RegisterChannel(httpChannel, false);
            }
            catch (Exception ex)
            {
                //Log.Error("TsBufferExtractor exception: {0}", ex);
            }

            try
            {
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(TsBufferExtractorServer), "TsBufferExtractorServer",
                                                                   WellKnownObjectMode.SingleCall);
            }
            catch (Exception ex)
            {
                Log.Error("TsBufferExtractor exception: {0}", ex);
            }
            Log.Debug("TsBufferExtractor Started");
        }
        private void StartTimer()
        {
            Channel chan = Channel.Retrieve(_idChannelToWatch);

            if (chan != null && chan.IsRadio)
            {
                Log.Debug("TsBufferExtractor: IsRadio = True");
                return;
            }

            if (_timer == null)
            {
                _timer           = new System.Timers.Timer();
                _timer.Elapsed  += new ElapsedEventHandler(_timer_Tick);
                _timer.AutoReset = true;
                _timer.Interval  = 500;
                _timer.Start();

                try
                {
                    ITvServerEvent events = GlobalServiceProvider.Instance.Get <ITvServerEvent>();
                    events.OnTvServerEvent += new TvServerEventHandler(events_OnTvServerEvent);
                }
                catch (Exception ex)
                {
                    Log.Error("TsBufferExtractor exception : {0}", ex);
                }
            }
            Log.Debug("TsBufferExtractor: started on {1}, BufferExtractorSetup = {0}", _tsBufferExtractorSetup, _tvEvent.User.Name);
        }
Esempio n. 4
0
        /// <summary>
        /// Starts the plugin
        /// </summary>
        public void Start(IController controller)
        {
            Log.WriteFile("plugin: ConflictsManager started");
            _conflictingPrograms = new List <Program>();
            ITvServerEvent events = GlobalServiceProvider.Instance.Get <ITvServerEvent>();

            events.OnTvServerEvent += new TvServerEventHandler(events_OnTvServerEvent);
        }
        private void StopTimer()
        {
            _timer.Stop();
            _timer.Dispose();
            ITvServerEvent events = GlobalServiceProvider.Instance.Get <ITvServerEvent>();

            events.OnTvServerEvent -= new TvServerEventHandler(events_OnTvServerEvent);
            Log.Debug("TsBufferExtractor: Timer stopped on {0}, errors = {1}", _tvEvent.User.Name, _errors);
        }
Esempio n. 6
0
        /// <summary>
        /// Stops this instance.
        /// </summary>
        public void Stop()
        {
            ITvServerEvent events = GlobalServiceProvider.Instance.Get <ITvServerEvent>();

            events.OnTvServerEvent -= events_OnTvServerEvent;

            StopClient();

            Log.Debug("TV3BlasterPlugin: Stopped");
        }
Esempio n. 7
0
        protected override bool RegisterEvents()
        {
            ITvServerEvent tvServerEvent = GlobalServiceProvider.Instance.TryGet <ITvServerEvent>();

            if (tvServerEvent == null)
            {
                return(false);
            }
            tvServerEvent.OnTvServerEvent += OnTvServerEvent;
            return(true);
        }
Esempio n. 8
0
        /// <summary>
        /// Starts the plugin
        /// </summary>
        public void Start(IController controller)
        {
            LoadSettings();
            Log.WriteFile("plugin: PersonalTVGuide started");
            _stopService = false;
            ITvServerEvent events = GlobalServiceProvider.Instance.Get <ITvServerEvent>();

            events.OnTvServerEvent += new TvServerEventHandler(events_OnTvServerEvent);
            if (_debugMode)
            {
                UpdatePersonalTVGuide();       // Only for testing !!!!
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Stops the plugin
        /// </summary>
        public void Stop()
        {
            ITvServerEvent events = GlobalServiceProvider.Instance.Get <ITvServerEvent>();

            events.OnTvServerEvent -= new TvServerEventHandler(events_OnTvServerEvent);
            try
            {
                ChannelServices.UnregisterChannel(httpChannel);
            }
            catch (Exception ex)
            {
                //Log.Error("TsBufferExtractor exception: {0}", ex);
            }
        }
Esempio n. 10
0
        protected bool RegisterEvents()
        {
#if TVE3
            ITvServerEvent tvServerEvent = GlobalServiceProvider.Instance.TryGet <ITvServerEvent>();
#else
            ITvServerEvent tvServerEvent = GlobalServiceProvider.Instance.Get <ITvServerEvent>();
#endif
            if (tvServerEvent == null)
            {
                return(false);
            }
            tvServerEvent.OnTvServerEvent += OnTvServerEvent;
            return(true);
        }
Esempio n. 11
0
        /// <summary>
        /// Handles the OnTvServerEvent event fired by the server.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="eventArgs">The <see cref="System.EventArgs"/> the event data.</param>
        void events_OnTvServerEvent(object sender, EventArgs eventArgs)
        {
            TvServerEventArgs tvEvent = (TvServerEventArgs)eventArgs;

            if (eventArgs == null || tvEvent == null)
            {
                return;
            }

            if (tvEvent.EventType == TvServerEventType.RecordingEnded && _filename == tvEvent.Recording.FileName)
            {
                _startMerge = true;

                ITvServerEvent events = GlobalServiceProvider.Instance.Get <ITvServerEvent>();
                events.OnTvServerEvent -= new TvServerEventHandler(events_OnTvServerEvent);
            }
        }
        public void Start(IController controller)
        {
            Log.WriteFile("ServerBlaster.Start Version {0}: Starting", _version);
            ITvServerEvent events = GlobalServiceProvider.Instance.Get <ITvServerEvent>();

            events.OnTvServerEvent += events_OnTvServerEvent;

            Blaster.DeviceArrival += OnDeviceArrival;
            Blaster.DeviceRemoval += OnDeviceRemoval;
            LoadRemoteCodes();

            Log.WriteFile("plugin: ServerBlaster start sender");
            Thread thread = new Thread(Sender);

            thread.SetApartmentState(ApartmentState.STA);
            thread.IsBackground = true;
            thread.Name         = "Remote blaster";
            _running            = true;
            thread.Start();


            Log.WriteFile("plugin: ServerBlaster.Start started");
        }
Esempio n. 13
0
        public void Start(IController controller)
#endif
        
        {            
            try
            {
                Log.Info("TvWishList started");

                SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);
                SystemEvents.SessionEnded += new SessionEndedEventHandler(SystemEvents_SessionEnded);

                events = GlobalServiceProvider.Instance.Get<ITvServerEvent>();
                events.OnTvServerEvent += new TvServerEventHandler(events_OnTvServerEvent);

                TvBusinessLayer layer = new TvBusinessLayer();
                Setting setting = null; 
                //set BUSY = false
                setting = layer.GetSetting("TvWishList_BUSY", "false");
                setting.Value = "false";
                setting.Persist();

                

                setting = layer.GetSetting("TvWishList_Debug", "false");
                Log.Info("setting DEBUG MODE = " + setting.Value);
                

                DEBUG = false;
                Boolean.TryParse(setting.Value, out DEBUG);
                Log.DebugValue = DEBUG;

                Log.Info("DEBUG MODE = " + DEBUG.ToString());

                //unlock pluginversion
                setting = layer.GetSetting("TvWishList_LockingPluginname", "NONE");
                setting.Value = "NONE";
                setting.Persist();

                //write Tv version
                setting = layer.GetSetting("TvWishList_TvServerVersion", "0.0.0.0");
                setting.Value = Version;
                setting.Persist();
                Log.Debug("TvVersion = "+Version);


                //is host name stored in database for TvWishListMP?
                setting = layer.GetSetting("TvWishList_MachineName", "NONE");
                Log.Debug("TvServer Machine Name="+setting.Value);
                if (setting.Value != System.Environment.MachineName.ToString())
                {
                    setting.Value = System.Environment.MachineName.ToString();
                    setting.Persist();
                    Log.Debug("Overwriting TvServer Machine Name To " + setting.Value);
                }

                //save pipename for Tvserver2
                setting = layer.GetSetting("TvWishList_PipeName", "NONE");
                Log.Debug("TvWishList_PipeName=" + setting.Value);
#if (MPTV2)
                setting.Value = "MP2TvWishListPipe";
#else
                setting.Value = "TvWishListPipe";
#endif
                setting.Persist();
                

                TV_USER_FOLDER = layer.GetSetting("TvWishList_TV_USER_FOLDER", "NOT_FOUND").Value;
                if ((File.Exists(TV_USER_FOLDER + @"\TvService.exe") == true) || (Directory.Exists(TV_USER_FOLDER) == false))
                {
                    //autodetect paths
                    InstallPaths instpaths = new InstallPaths();  //define new instance for folder detection
#if (MPTV2) //Native MP2 Tv server
                    instpaths.GetInstallPathsMP2();
                    TV_USER_FOLDER = instpaths.TV2_USER_FOLDER;
#else
                    instpaths.GetInstallPaths();
                    TV_USER_FOLDER = instpaths.TV_USER_FOLDER;
#endif
                    Logdebug("TV server user folder detected at " + TV_USER_FOLDER); 

                    if ((File.Exists(TV_USER_FOLDER + @"\TvService.exe") == true) || (Directory.Exists(TV_USER_FOLDER) == false))
                    {
                        Log.Error(@" TV server user folder does not exist - using C:\MediaPortal\TvWishList");
                        Logdebug(@" TV server user folder does not exist - using C:\MediaPortal\TvWishList");
                        TV_USER_FOLDER = @"C:\MediaPortal";
                        if (Directory.Exists(TV_USER_FOLDER) == false)
                            Directory.CreateDirectory(TV_USER_FOLDER + @"\TvWishList");
                    }
                    else
                    {//store found TV_USER_FOLDER
                        setting = layer.GetSetting("TvWishList_TV_USER_FOLDER", "NOT_FOUND");
                        setting.Value = TV_USER_FOLDER;
                        setting.Persist();
                    }
                }

                


                _RecordingFlagTime = DateTime.Now.AddHours(1.0); //add 1 hour to give time for setup
                _NextEpgTime = DateTime.Now.AddHours(1.0); //add 1 hour to give time for setup
                setting = layer.GetSetting("TvWishList_NextEpgDate", _NextEpgTime.ToString("yyyy-MM-dd_HH:mm", System.Globalization.CultureInfo.InvariantCulture));
                try
                {
                    _NextEpgTime = DateTime.ParseExact(setting.Value, "yyyy-MM-dd_HH:mm", System.Globalization.CultureInfo.InvariantCulture);
                }
                catch (Exception exc)
                {
                    Log.Error("NextEpgDate reading failed with exception: " + exc.Message);
                }
                Log.Debug("Start(IController controller):  _NextEpgTime=" + _NextEpgTime.ToString());



                

                /*
                // lock next time for receive mail for upcoming startups if Tvserver is being restarted after each standby
                setting = layer.GetSetting("TvWishList_SetEpgTime", "false");
                setting.Value = "false";
                setting.Persist();*/


                epgwatchclass = new EpgParser();

                if (epgwatchclass == null)
                {
                    Log.Error("EpgParser could not be initiated - aborting operation");
                    return;
                }
                else
                {
                    epgwatchclass.newlabelmessage += new setuplabelmessage(SendServerPipeMessage);
                    Logdebug("EpgParser initiated");
                }
                
                //start pollingthread
                runpolling = true;
                System.Threading.Thread th = new System.Threading.Thread(startpolling);
                th.IsBackground = true;
                th.Start();
                Logdebug("Polling thread starting");
                

                /*
                // activate filewatcher for active command
                try
                {
                    filewatcherstartepg = TV_USER_FOLDER + @"\TvWishList\StartEPGsearch.txt";
                    if (File.Exists(filewatcherstartepg) == true)
                    {
                        File.Delete(filewatcherstartepg);
                    }

                    filewatcherfinishedepg = TV_USER_FOLDER + @"\TvWishList\FinishedEPGsearch.txt";
                    if (File.Exists(filewatcherfinishedepg) == true)
                    {
                        File.Delete(filewatcherfinishedepg);
                    }

                    FileInfo myfileinfo = new FileInfo(filewatcherstartepg);
                    StartEPGsearch.Path = myfileinfo.DirectoryName;
                    StartEPGsearch.Created += new FileSystemEventHandler(StartEPGsearchFilewatcher);
                    StartEPGsearch.Filter = myfileinfo.Name;
                    StartEPGsearch.EnableRaisingEvents = true;
                    Logdebug("file watcher StartEPGsearch enabled");
                }
                catch (Exception ex)
                {
                    Log.Error("Error in starting StartEPGsearch File watcher: Exception message was " + ex.Message);
                    return;

                }*/

                // activate filewatcher for setupTvStarted
                try
                {
                    filewatcherSetupTvStarted = TV_USER_FOLDER + @"\TvWishList\SetupTvStarted.txt";
                    if (File.Exists(filewatcherSetupTvStarted) == true)
                    {
                        File.Delete(filewatcherSetupTvStarted);
                    }

                    FileInfo myfileinfo = new FileInfo(filewatcherSetupTvStarted);
                    SetupTvStarted.Path = myfileinfo.DirectoryName;
                    SetupTvStarted.Created += new FileSystemEventHandler(SetupTvStartedFilewatcher);
                    SetupTvStarted.Filter = myfileinfo.Name;
                    SetupTvStarted.EnableRaisingEvents = true;
                    Logdebug("file watcher SetupTvStarted enabled");
                }
                catch (Exception ex)
                {
                    Log.Error("Error in starting SetupTvStarted File watcher: Exception message was " + ex.Message);
                    return;

                }


                // activate filewatcher for NextEpgCheck
                try
                {
                    filewatcherNextEpgCheck = TV_USER_FOLDER + @"\TvWishList\NextEpgCheck.txt";
                    if (File.Exists(filewatcherNextEpgCheck) == true)
                    {
                        File.Delete(filewatcherNextEpgCheck);
                    }

                    FileInfo myfileinfo = new FileInfo(filewatcherNextEpgCheck);
                    NextEpgCheck.Path = myfileinfo.DirectoryName;
                    NextEpgCheck.Created += new FileSystemEventHandler(NextEpgCheckFilewatcher);
                    NextEpgCheck.Filter = myfileinfo.Name;
                    NextEpgCheck.EnableRaisingEvents = true;
                    Logdebug("file watcher NextEpgCheck enabled");
                }
                catch (Exception ex)
                {
                    Log.Error("Error in starting NextEpgCheck File watcher: Exception message was " + ex.Message);
                    return;

                }
                
                //startpipeserver and listen for commands
                StartServer();

            }
            catch (Exception ex)
            {
                Log.Debug("Error in starting TvWishList: Exception message was " + ex.Message);
                return;

            }
            Log.Debug("TvWishList start completed");


            
        }
Esempio n. 14
0
        public Copyer()
        {
            ITvServerEvent events = GlobalServiceProvider.Instance.Get <ITvServerEvent>();

            events.OnTvServerEvent += new TvServerEventHandler(events_OnTvServerEvent);
        }
Esempio n. 15
0
        public void Start(IController controller)
        {
            Log.Debug("BackupSettingsServer: Plugin BackupSettings active");

            events = GlobalServiceProvider.Instance.Get<ITvServerEvent>();
            events.OnTvServerEvent += new TvServerEventHandler(events_OnTvServerEvent);

            TvBusinessLayer layer = new TvBusinessLayer();
            Setting setting = null;

            //get debug setting
            setting = layer.GetSetting("Backup_SettingsSetup_debug", "false");
            if (setting.Value.ToLower() == "true")
            {
                DEBUG = true;
            }
            else
            {
                DEBUG = false;
            }

            //get next backup time
            _NextBackup = DateTime.Now.AddDays(30);//add one month default
            _RecordingFlagTime = DateTime.Now.AddHours(1.0); //add 1 hour to give time for setup

            setting = layer.GetSetting("Backup_SettingsNextBackup", DateTime.Now.ToString("yyyy-MM-dd_HH:mm", System.Globalization.CultureInfo.InvariantCulture));
            try
            {
                _NextBackup = DateTime.ParseExact(setting.Value, "yyyy-MM-dd_HH:mm", System.Globalization.CultureInfo.InvariantCulture);
            }
            catch (Exception exc)
            {
                Log.Error("NextBackup failed with exception: " + exc.Message);
            }

            //is host name stored in database for BackupSettingsMP2?
            setting = layer.GetSetting("BackupSettings_MachineName", "NONE");
            if (setting.Value != System.Environment.MachineName.ToString())
            {
                setting.Value = System.Environment.MachineName.ToString();
                setting.Persist();
            }

            //Get TV_USER_FOLDER
            TV_USER_FOLDER = layer.GetSetting("BackupSettings_TV_USER_FOLDER", "NOT_FOUND").Value;
            if ((File.Exists(TV_USER_FOLDER + @"\TvService.exe") == true) || (Directory.Exists(TV_USER_FOLDER) == false))
            {
                //autodetect paths
                InstallPaths instpaths = new InstallPaths();  //define new instance for folder detection
                instpaths.GetInstallPaths();
                TV_USER_FOLDER = instpaths.TV_USER_FOLDER;
                Log.Debug("TV server user folder detected at " + TV_USER_FOLDER);

                if ((File.Exists(TV_USER_FOLDER + @"\TvService.exe") == true) || (Directory.Exists(TV_USER_FOLDER) == false))
                {
                    Log.Error(@" TV server user folder does not exist - using C:\MediaPortal BackupSettings");
                    Log.Debug(@" TV server user folder does not exist - using C:\MediaPortal BackupSettings");
                    TV_USER_FOLDER = @"C:\MediaPortal BackupSettings";
                    if (Directory.Exists(TV_USER_FOLDER) == false)
                        Directory.CreateDirectory(TV_USER_FOLDER + @"\BackupSettings");
                }

                //store new TV_USER_FOLDER
                setting = layer.GetSetting("BackupSettings_TV_USER_FOLDER", "NOT_FOUND");
                setting.Value = TV_USER_FOLDER;
                setting.Persist();
            }

            //enable textmessages from other classes by starting filewatchers

            if (Directory.Exists(TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR) == true)
            {
                if (File.Exists(TV_USER_FOLDER + @"\"+BACKUPSETTING_TV_DIR + @"\" + POSTPROCESSING_FILE) == true)  //delete old corrupt file
                {
                    File.Delete(TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR + @"\" + POSTPROCESSING_FILE);
                    Log.Debug("BackupSettings Server: File " + TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR + @"\" + POSTPROCESSING_FILE + " deleted");
                }
                ImportWatcher.Path = TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR;
                ImportWatcher.Created += new FileSystemEventHandler(importpostprocessing);
                ImportWatcher.Filter = POSTPROCESSING_FILE;
                ImportWatcher.EnableRaisingEvents = true;
                WATCHERACTIVE = true;
                Log.Debug("BackupSettings Server: Importwatcher activated for " + ImportWatcher.Path + "\\" + ImportWatcher.Filter);

                if (File.Exists(TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR + @"\" + AUTO_EXPORT_FILE) == true)  //delete old corrupt file
                {
                    File.Delete(TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR + @"\" + AUTO_EXPORT_FILE);
                    Log.Debug("BackupSettings Server: File " + TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR + @"\" + AUTO_EXPORT_FILE + " deleted");
                }
                AutomatedExport.Path = TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR;
                AutomatedExport.Created += new FileSystemEventHandler(AutomatedExportProcessing);
                AutomatedExport.Filter = AUTO_EXPORT_FILE;
                AutomatedExport.EnableRaisingEvents = true;
                Log.Debug("BackupSettings Server: AutomatedExport activated for " + AutomatedExport.Path + "\\" + AutomatedExport.Filter);

                if (File.Exists(TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR + @"\" + SCHEDULED_EXPORT_FILE) == true)  //delete old corrupt file
                {
                    File.Delete(TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR + @"\" + SCHEDULED_EXPORT_FILE);
                    Log.Debug("BackupSettings Server: File " + TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR + @"\" + SCHEDULED_EXPORT_FILE + " deleted");
                }
                ScheduledExport.Path = TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR;
                ScheduledExport.Created += new FileSystemEventHandler(ScheduledExportProcessing);
                ScheduledExport.Filter = SCHEDULED_EXPORT_FILE;
                ScheduledExport.EnableRaisingEvents = true;
                Log.Debug("BackupSettings Server: AutomatedExport activated for " + ScheduledExport.Path + "\\" + ScheduledExport.Filter);

            }
            else
            {
                Log.Debug("BackupSettings Server Error: Importwatcher/AutomatedExport could not be started because directory " + @"\" + TV_USER_FOLDER + @"\" + BACKUPSETTING_TV_DIR + " does not exist");
            }

            //start pollingthread
            runpolling = true;
            System.Threading.Thread th = new System.Threading.Thread(startpolling);
            th.IsBackground = true;
            th.Start();
            //Log.Debug("Polling thread starting");
        }