Exemplo n.º 1
0
        public void Launch(AddInHost host)
        {
            session = new HistoryOrientedPageSession();
            Application app = new Application(session, host);

            app.Start();
        }
Exemplo n.º 2
0
        public void DownloadComplete()
        {
            OMLApplication.Current.MediaCenterEnvironment.Dialog(
                "OML will now exit to install the update, and will be automatically restated once complete.",
                "Ready to Update",
                DialogButtons.Ok, 5, false);

            OMLEngine.Utilities.DebugLine("Local file is: {0}", localFile);
            string updateBatch = "msiexec.exe /qb /log c:\\programdata\\openmedialibrary\\logs\\update.log /i \"" + localFile + "\n";
            string ehshellPath = Path.Combine(Environment.ExpandEnvironmentVariables("%SystemRoot%"), @"ehome\ehshell");

            updateBatch += ehshellPath + " /entrypoint:{ad208fce-2431-47d6-abed-1974a2a0555f}\\{7533724D-C7CB-4ac2-8AEE-1B0B91ADD393}";
            string filename = Path.GetTempFileName() + ".bat";

            OMLEngine.Utilities.DebugLine("batch file to run is: {0}", filename);
            File.WriteAllText(filename, updateBatch);

            Process update = new Process();

            update.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
            update.StartInfo.FileName    = filename;
            update.Start();

            AddInHost context = AddInHost.Current;

            context.ApplicationContext.CloseApplication();
        }
Exemplo n.º 3
0
        public void Launch(AddInHost host)
        {
            //  uncomment to debug
#if DEBUG
            host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true);
#endif

            var config = GetConfig();
            if (config == null)
            {
                Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication();
                return;
            }

            Kernel.Init(config);

            Environment.CurrentDirectory = ApplicationPaths.AppConfigPath;
            try
            {
                SetupStylesMcml(host);
                SetupFontsMcml(host);
            }
            catch (Exception ex)
            {
                host.MediaCenterEnvironment.Dialog(ex.Message, "Customisation Error", DialogButtons.Ok, 100, true);
                Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication();
                return;
            }

            Application app = new Application(new MyHistoryOrientedPageSession(), host);

            app.GoToMenu();
        }
Exemplo n.º 4
0
        private void CheckFirstRun(AddInHost host)
        {
            if (Properties.Settings.Default.ShowFirstRunPrompt == true)
            {
                List <string> buttons = new List <string>();
                buttons.Add("Configure OML");
                buttons.Add("No Thanks");
                Microsoft.MediaCenter.MediaCenterEnvironment env = host.MediaCenterEnvironment;
                string dialogText = "Would you like to configure Open Media Library now? To run this wizard later you can access OML from the program library.";
                Microsoft.MediaCenter.DialogResult res = env.Dialog(dialogText, "OPEN MEDIA LIBRARY", buttons, -1, true, null, delegate(Microsoft.MediaCenter.DialogResult dialogResult) { });
                if ((int)res == 100)
                {
                    //tmp until firstrun page
                    Properties.Settings.Default.ShowFirstRunPrompt = false;
                    Properties.Settings.Default.Save();

                    //run setup
                    s_session = new Library.Code.V3.HistoryOrientedPageSessionEx();
                    GoToLoader();
                    Microsoft.MediaCenter.UI.Application.DeferredInvoke(new Microsoft.MediaCenter.UI.DeferredHandler(this.BeginStart), (object)host, new TimeSpan(1));
                }
                else
                {
                    Properties.Settings.Default.ShowFirstRunPrompt = false;
                    Properties.Settings.Default.Save();
                    //env.Dialog("You can access OML from the program library.", "OPEN MEDIA LIBRARY", Microsoft.MediaCenter.DialogButtons.Ok, -1, true);
                }
            }
        }
Exemplo n.º 5
0
        public void Launch(AddInHost host)
        {
            //  uncomment to debug
#if DEBUG
            host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true); 
#endif


            var config = GetConfig();
            if (config == null)
            {
                host.ApplicationContext.CloseApplication();
                return;
            }
            //set us up for single instance
            host.ApplicationContext.SingleInstance = true;

            Environment.CurrentDirectory = ApplicationPaths.AppProgramPath;
            using (new Util.Profiler("Total Kernel Init"))
            {
                Kernel.Init(config);
            }
            using (new Util.Profiler("Application Init"))
            {
                App = new Application(new MyHistoryOrientedPageSession(), host);

                App.Init();
            }

            Kernel.Instance.OnApplicationInitialized();

        }
Exemplo n.º 6
0
        private void DeleteOldRegistryKey(AddInHost host)
        {
            // remove old HKCU key that caused settings to appear on the TV+Movies menu strip
            if (!host.MediaCenterEnvironment.Capabilities.ContainsKey("Console"))
            {
                try
                {
                    RegistryKey delKeyValue = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\" +
                                                                              @"Media Center\Extensibility\Categories\Services\" +
                                                                              @"Movies\{543d0438-b10d-43d8-a20d-f0c96db4e6bd}", true);
                    if (delKeyValue != null)
                    {
                        OMLApplication.DebugLine("[Launch] Deleting old registry key value");
                        delKeyValue.DeleteValue(@"UseCount");
                    }
                }
                catch (Exception) { } // we don't really care, just delete it if you find it

                try
                {
                    RegistryKey delSubKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\" +
                                                                            @"Media Center\Extensibility\Categories\Services\Movies", true);
                    if (delSubKey != null)
                    {
                        OMLApplication.DebugLine("[Launch] Deleting old registry key");
                        delSubKey.DeleteSubKey(@"{543d0438-b10d-43d8-a20d-f0c96db4e6bd}");
                    }
                }
                catch (Exception) { } // we don't really care, just delete it if you find it
            }
        }
Exemplo n.º 7
0
        //-------------------------------------------------------------
        // methods
        //-------------------------------------------------------------

        protected override void WndProc(ref Message message)
        {
            try
            {
                AddInHost host = AddInHost.Current;
                if (host.ApplicationContext.IsForegroundApplication)
                {
                    int param;
                    Console.WriteLine(message.Msg.ToString());
                    switch (message.Msg)
                    {
                    case WM_KEYDOWN:
                        param = message.WParam.ToInt32();
                        ProcessKeyDown(param);
                        break;

                    case WM_APPCOMMAND:
                        param = message.LParam.ToInt32();
                        ProcessAppCommand(param);
                        break;

                    case WM_INPUT:
                        ProcessInputCommand(ref message);
                        break;
                        //case WM_RBUTTONUP:
                        //    ProcessMouseCommand();
                        //    break;
                    }
                }
            }
            finally { }
            base.WndProc(ref message);
        }
Exemplo n.º 8
0
        public void Launch(AddInHost host)
        {
            //  uncomment to debug
            #if DEBUG
            host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true);
            #endif

            var config = GetConfig();
            if (config == null) {
                Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication();
                return;
            }

            Kernel.Init(config);

            Environment.CurrentDirectory = ApplicationPaths.AppConfigPath;
            try
            {
                SetupStylesMcml(host);
                SetupFontsMcml(host);
            }
            catch (Exception ex)
            {
                host.MediaCenterEnvironment.Dialog(ex.Message, "Customisation Error", DialogButtons.Ok, 100, true);
                Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication();
                return;
            }

            Application app = new Application(new MyHistoryOrientedPageSession(), host);

            app.GoToMenu();
        }
Exemplo n.º 9
0
        // Process the completed update download.
        public void DownloadComplete()
        {
            // Let them know we will be closing VB then restarting it.
            DialogResult reply = Application.DisplayDialog(Application.CurrentInstance.StringData("UpdateSuccessDial"),
                                                           Application.CurrentInstance.StringData("UpdateSuccessCapDial"), DialogButtons.Ok, 10);

            //shut down the service
            MBServiceController.SendCommandToService(IPCCommands.Shutdown);

            // put together a batch file to execute the installer in silent mode and restart VB.
            string updateBat = "msiexec.exe /qb /i \"" + localFile + "\"\n";
            string windir    = Environment.GetEnvironmentVariable("windir");

            updateBat += Path.Combine(windir, "ehome\\ehshell /entrypoint:{CE32C570-4BEC-4aeb-AD1D-CF47B91DE0B2}\\{FC9ABCCC-36CB-47ac-8BAB-03E8EF5F6F22}");
            string filename = System.IO.Path.GetTempFileName();

            filename += ".bat";
            System.IO.File.WriteAllText(filename, updateBat);

            // Start the batch file minimized so they don't notice.
            Process toDo = new Process();

            toDo.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
            toDo.StartInfo.FileName    = filename;

            toDo.Start();

            // Once we start the process we can kill the VB application.
            AddInHost context = AddInHost.Current;

            context.ApplicationContext.CloseApplication();
        }
Exemplo n.º 10
0
        public void Launch(AddInHost host)
        {
            //  uncomment to debug
#if DEBUG
            host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true);
#endif


            var config = GetConfig();
            if (config == null)
            {
                host.ApplicationContext.CloseApplication();
                return;
            }
            //set us up for single instance
            host.ApplicationContext.SingleInstance = true;

            Environment.CurrentDirectory = ApplicationPaths.AppProgramPath;
            using (new Util.Profiler("Total Kernel Init"))
            {
                Kernel.Init(config);
            }
            using (new Util.Profiler("Application Init"))
            {
                App = new Application(new MyHistoryOrientedPageSession(), host);

                App.Init();
            }

            Kernel.Instance.OnApplicationInitialized();
        }
Exemplo n.º 11
0
 public BuddyViewer(HistoryOrientedPageSession session, AddInHost host)
 {
     this.session = session;
     this.host    = host;
     _status      = RunningStatus.Stopped;
     _jobslist    = new ArrayListDataSet(this);
     MCEBuddyConf.GlobalMCEConfig = new MCEBuddyConf(); // Initialize with default parameters for now, we will get the config file from the server and then re-initialize (don't use null as it keeps accessing win.ini) - this is never written to a file (just a memory object)
 }
Exemplo n.º 12
0
 public void Launch(AddInHost host)
 {
     if (host != null && host.ApplicationContext != null)
     {
         host.ApplicationContext.SingleInstance = true;
     }
     s_session = new HistoryOrientedPageSession();
     s_session.GoToPage("resx://$projectname$/$safeprojectname$.Resources/Default");
 }
Exemplo n.º 13
0
        public void Launch(AddInHost host)
        {
            string      dataFile = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Microsoft\PowerPlaylist2\Data\Data.xml";
            Application app      = new Application(host);

            app.id       = id;
            app.DataFile = dataFile;
            app.Start();
        }
 public void Launch(AddInHost host)
 {
     if (host != null && host.ApplicationContext != null)
     {
         host.ApplicationContext.SingleInstance = true;
     }
     s_session = new HistoryOrientedPageSession();
     s_session.GoToPage("resx://CellarTrackerAddIn2/CellarTrackerAddIn2.Resources.Default");
 }
Exemplo n.º 15
0
        public void Launch(AddInHost host)
        {
            if (host != null && host.ApplicationContext != null)
            {
                host.ApplicationContext.SingleInstance = true;
            }
            Application app = new Application(host);

            app.Start();
        }
Exemplo n.º 16
0
 public void Launch(AddInHost host)
 {
     if (host != null && host.ApplicationContext != null)
     {
         host.ApplicationContext.SingleInstance = true;
     }
     s_session = new HistoryOrientedPageSession();
     Application app = new Application(s_session, host);
     app.GoToMenu();
 }
Exemplo n.º 17
0
        public void Launch(AddInHost host)
        {
            if (host != null && host.ApplicationContext != null)
            {
                host.ApplicationContext.SingleInstance = true;
            }
            s_session = new HistoryOrientedPageSession();
            Application app = new Application(s_session, host);

            app.GoToMenu();
        }
Exemplo n.º 18
0
        /// <summary>
        /// Starts running an application
        /// Because the Windows Media Center object is guaranteed to be valid only until the Launch
        /// method returns, an on-demand application must make all calls to the Windows Media Center
        /// API within the context of the application's Launch method. Calling the Windows Media
        /// Center object after the Launch method returns can result in a fatal error. If your
        /// application's Launch method spawns multiple threads, those threads must all be terminated
        /// before your Launch method returns. After calling the Launch method, if you do not call
        /// any method directly from the host object, .NET remoting releases unused objects every
        /// five minutes. To avoid this, use the host object or use the objects within five minutes
        /// to prevent them from being released.
        /// </summary>
        /// <param name="host">An application uses this interface to access other interfaces provided by the Microsoft.MediaCenter namespace</param>
        public void Launch(AddInHost host)
        {
            try
            {
                //  Lower the priority of this thread
                System.Threading.Thread.CurrentThread.Priority = ThreadPriority.Lowest;

                //  Setup TCP socket listener
                m_socketServer.StartListening(GetPortNumber(m_basePortNumber));
                m_socketServer.NewMessage += new EventHandler <SocketEventArgs>(m_socketServer_NewMessage);
                m_socketServer.Connected  += new EventHandler <SocketEventArgs>(m_socketServer_Connected);

                //  Setup HTTP socket listener
                m_httpServer.StartListening(GetPortNumber(m_basePortNumber) + 10);
                m_httpServer.NewRequest += new EventHandler <HttpEventArgs>(m_httpServer_NewRequest);

                //EventLog.WriteEntry("VmcController Client AddIn", "Listening on port " + m_socketServer.PortNumber + " (Version " + VersionInfo + ")", EventLogEntryType.Information);

                if (System.IO.File.Exists(System.Environment.GetEnvironmentVariable("windir") + "\\ehome\\vmcController.xml"))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(System.Environment.GetEnvironmentVariable("windir") + "\\ehome\\vmcController.xml");
                    XmlNode startupCommand = doc.DocumentElement.SelectSingleNode("startupMacro");

                    if (startupCommand == null)
                    {
                        //AddInHost.Current.MediaCenterEnvironment.Dialog("startup node not found", "", DialogButtons.Ok, 5, false);
                    }
                    else
                    {
                        MacroCmd macro  = new MacroCmd();
                        OpResult result = macro.Execute(startupCommand.InnerText);
                        result = null;
                        macro  = null;
                    }
                    doc = null;
                }

                //  Wait until exit request from host
                m_waitHandle.WaitOne();
            }
            catch (Exception ex)
            {
                //EventLog.WriteEntry("VmcController Client AddIn", "Exception in Launch: " + ex.ToString(), EventLogEntryType.Error);
            }
            finally
            {
                //  Shutdown listener
                if (m_socketServer.PortNumber > 0)
                {
                    m_socketServer.StopListening();
                }
            }
        }
Exemplo n.º 19
0
        private void SetupStylesMcml(AddInHost host)
        {
            try
            {
                string file   = Path.Combine(ApplicationPaths.AppConfigPath, "Styles_DoNotEdit.mcml");
                string custom = Path.Combine(ApplicationPaths.AppConfigPath, CUSTOM_STYLE_FILE);
                if (File.Exists(file))
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch { }
                }
                if (File.Exists(custom))
                {
                    Logger.ReportInfo("Using custom styles mcml");
                    if (!VerifyStylesXml(custom, Resources.StylesDefault))
                    {
                        host.MediaCenterEnvironment.Dialog(CUSTOM_STYLE_FILE + " has been patched with missing values", CUSTOM_STYLE_FILE, DialogButtons.Ok, 100, true);
                    }
                    File.Copy(custom, file);
                }
                else
                {
                    // new options must be added to the ThemeModel choice in configpage.mcml
                    switch (Config.Instance.Theme)
                    {
                    case "Black":
                        File.WriteAllBytes(file, Resources.StylesBlack);
                        break;

                    case "Extender Default":
                        File.WriteAllBytes(file, Resources.StylesDefaultExtender);
                        break;

                    case "Extender Black":
                        File.WriteAllBytes(file, Resources.StylesBlackExtender);
                        break;

                    case "Default":
                    default:
                        File.WriteAllBytes(file, Resources.StylesDefault);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.ReportException("Error creating Styles_DoNotEdit.mcml", ex);
                throw;
            }
        }
Exemplo n.º 20
0
        public void Launch(AddInHost host)
        {
            if (host != null && host.ApplicationContext != null)
            {
                host.ApplicationContext.SingleInstance = true;
            }
            s_session = new HistoryOrientedPageSession();
            Application app         = new Application(s_session, host);
            string      sectionGuid = host.ApplicationContext.EntryPointInfo["context"].ToString();

            app.GoToSection(sectionGuid);
        }
        public static void SetupStylesMcml(AddInHost host, Config config = null)
        {
            try
            {
                string file   = Path.Combine(ApplicationPaths.AppProgramPath, "Styles_DoNotEdit.mcml");
                string custom = Path.Combine(ApplicationPaths.AppProgramPath, CUSTOM_STYLE_FILE);
                if (File.Exists(file))
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch { }
                }
                if (File.Exists(custom))
                {
                    Logger.ReportInfo("Using custom styles mcml");
                    if (!VerifyXmlResource(custom, Resources.StylesDefault))
                    {
                        host.MediaCenterEnvironment.Dialog(string.Format(Application.CurrentInstance.StringData("StyleMissingDial"), CUSTOM_STYLE_FILE), CUSTOM_STYLE_FILE, DialogButtons.Ok, 100, true);
                    }
                    File.Copy(custom, file);
                }
                else
                {
                    var styleTheme = config != null ? config.Theme : "Black";
                    // new options must be added to the ThemeModel choice in configpage.mcml
                    switch (styleTheme)
                    {
                    case "Black":
                        File.WriteAllBytes(file, Resources.StylesBlack);
                        break;

                    case "Extender Blue":
                        File.WriteAllBytes(file, Resources.StylesDefaultExtender);
                        break;

                    case "Extender Black":
                        File.WriteAllBytes(file, Resources.StylesBlackExtender);
                        break;

                    default:
                        File.WriteAllBytes(file, Resources.StylesDefault);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.ReportException("Error creating Styles_DoNotEdit.mcml", ex);
                throw;
            }
        }
        public void Launch(AddInHost host)
        {
            if (host != null && host.ApplicationContext != null)
            {
                host.ApplicationContext.SingleInstance = true;
            }
            //host.MediaCenterEnvironment.PlayMedia(Microsoft.MediaCenter.MediaType.Datacast,
            s_session = new HistoryOrientedPageSession();
            s_session.GoToPage("resx://CellarTrackerAddIn/CellarTrackerAddIn.Resources/Default");
            XMLData Data = new XMLData();

            Data.Test();
        }
Exemplo n.º 23
0
        public Application(HistoryOrientedPageSession session, AddInHost host)
        {
            this.session = session;
            this.host = host;

            _myData = new ArrayListDataSet();
            var list = GetFeedList();
            foreach (var radio in list)
            {
                _myData.Add(radio);

            }
        }
        public static void SetupStylesMcml(AddInHost host, Config config = null)
        {
            try
            {
                string file = Path.Combine(ApplicationPaths.AppProgramPath, "Styles_DoNotEdit.mcml");
                string custom = Path.Combine(ApplicationPaths.AppProgramPath, CUSTOM_STYLE_FILE);
                if (File.Exists(file))
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch { }
                }
                if (File.Exists(custom))
                {
                    Logger.ReportInfo("Using custom styles mcml");
                    if (!VerifyXmlResource(custom, Resources.StylesDefault))
                    {
                        Application.AddInHost.MediaCenterEnvironment.Dialog(string.Format(Application.CurrentInstance.StringData("StyleMissingDial"), CUSTOM_STYLE_FILE), CUSTOM_STYLE_FILE, DialogButtons.Ok, 100, true);
                    }
                    File.Copy(custom, file);
                }
                else
                {
                    var styleTheme = config != null ? config.Theme : "Black";
                    // new options must be added to the ThemeModel choice in configpage.mcml
                    switch (styleTheme)
                    {
                        case "Black":
                            File.WriteAllBytes(file, Resources.StylesBlack);
                            break;
                        case "Extender Blue":
                            File.WriteAllBytes(file, Resources.StylesDefaultExtender);
                            break;
                        case "Extender Black":
                            File.WriteAllBytes(file, Resources.StylesBlackExtender);
                            break;
                        default:
                            File.WriteAllBytes(file, Resources.StylesDefault);
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.ReportException("Error creating Styles_DoNotEdit.mcml", ex);
                throw;
            }

        }
Exemplo n.º 25
0
        public void Launch(AddInHost host)
        {
            if (host != null && host.ApplicationContext != null)
            {
                host.ApplicationContext.SingleInstance = true;
            }

            s_session = new HistoryOrientedPageSession();
            s_session.GoToPage("resx://CellarTrackerProject/CellarTrackerProject.Resources/CellarMain");

            //CellarTrackerProject.Properties.Settings.Default.Username = "******";
            //CellarTrackerProject.Properties.Settings.Default.Password = "******";
            //CellarTrackerProject.Properties.Settings.Default.Save();
        }
Exemplo n.º 26
0
        public CadPlusSwAddIn()
        {
            var disp = Dispatcher.CurrentDispatcher;

            if (disp != null)
            {
                disp.UnhandledException += OnDispatcherUnhandledException;
            }
            AppDomain.CurrentDomain.UnhandledException += OnDomainUnhandledException;

            m_Host = new AddInHost(new SwAddInApplication(this),
                                   new Initiator());
            m_Host.ConfigureServices += OnConfigureModuleServices;
        }
Exemplo n.º 27
0
        /// <summary>
        /// Launches the add-on.
        /// </summary>
        /// <param name="host">Represents the media center host.</param        
        public void Launch(AddInHost host)
        {
            if (host != null && host.ApplicationContext != null)
            {
                host.ApplicationContext.SingleInstance = true;
                AddInHost = host;
            }

#if DEBUG
            AddInHost.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "myForecast - Debug", DialogButtons.Ok, 100, true);
#endif
            Session = new HistoryOrientedPageSession();

            GoMainPage();
        }
Exemplo n.º 28
0
        public void Launch(AddInHost host)
        {
            //  uncomment to debug
#if DEBUG
            host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true); 
#endif


            var config = GetConfig();
            if (config == null)
            {
                AddInHost.Current.ApplicationContext.CloseApplication();
                return;
            }
            //set us up for single instance
            AddInHost.Current.ApplicationContext.SingleInstance = true;

            Environment.CurrentDirectory = ApplicationPaths.AppProgramPath;
            using (new Util.Profiler("Total Kernel Init"))
            {
                Kernel.Init(config);
                while (!Kernel.ServerConnected)
                {
                    if (!Kernel.ServerConnected)
                    {
                        if (host.MediaCenterEnvironment.Dialog("Could not connect to Media Browser 3 Server.  Please be sure it is running on the local network.\n\nWould you like to re-try?", "Error", DialogButtons.Yes | DialogButtons.No, 100, true) != DialogResult.No)
                        {
                            Kernel.ConnectToServer(config);
                        }
                        else
                        {
                            AddInHost.Current.ApplicationContext.CloseApplication();
                            return;
                        }
                    }
                }
            }
            using (new Util.Profiler("Application Init"))
            {
                App = new Application(new MyHistoryOrientedPageSession(), host);

                App.Init();
            }

            Kernel.Instance.OnApplicationInitialized();

        }
Exemplo n.º 29
0
        public void Launch(AddInHost host)
        {
            //  uncomment to debug
#if DEBUG
            host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true);
#endif


            var config = GetConfig();
            if (config == null)
            {
                AddInHost.Current.ApplicationContext.CloseApplication();
                return;
            }
            //set us up for single instance
            AddInHost.Current.ApplicationContext.SingleInstance = true;

            Environment.CurrentDirectory = ApplicationPaths.AppProgramPath;
            using (new Util.Profiler("Total Kernel Init"))
            {
                Kernel.Init(config);
                while (!Kernel.ServerConnected)
                {
                    if (!Kernel.ServerConnected)
                    {
                        if (host.MediaCenterEnvironment.Dialog("Could not connect to Media Browser 3 Server.  Please be sure it is running on the local network.\n\nWould you like to re-try?", "Error", DialogButtons.Yes | DialogButtons.No, 100, true) != DialogResult.No)
                        {
                            Kernel.ConnectToServer(config);
                        }
                        else
                        {
                            AddInHost.Current.ApplicationContext.CloseApplication();
                            return;
                        }
                    }
                }
            }
            using (new Util.Profiler("Application Init"))
            {
                App = new Application(new MyHistoryOrientedPageSession(), host);

                App.Init();
            }

            Kernel.Instance.OnApplicationInitialized();
        }
Exemplo n.º 30
0
        /// <summary>
        /// Construct an Application object and associate it with a page
        /// session.
        /// </summary>
        public Application(HistoryOrientedPageSession session, AddInHost host)
        {
            // Store the page session and host
            this.session = session;
            this.host    = host;

            // initialize the field used by the static Application.Current property
            singleApplicationInstance = this;

            //
            // Construct the application experiences
            //

            AddExperience(new Movies());
            AddExperience(new TV());
            AddExperience(new Music());
        }
Exemplo n.º 31
0
        //
        // Launch (IAddInModule)
        //

        public void Launch(AddInHost host)
        {
            if (host != null && host.ApplicationContext != null)
            {
                host.ApplicationContext.SingleInstance = true;
            }

            s_session = new HistoryOrientedPageSession();
            Application app = new Application(s_session, host);

            // Set the background color
            // Matches Background.C from Syles.mcml
            host.MediaCenterEnvironment.BackgroundColor = System.Drawing.Color.FromArgb(21, 35, 39);

            // Navigate to the main menu.
            app.GoToStartPage();
        }
        public static void SetupFontsMcml(AddInHost host, Config config = null)
        {
            try
            {
                string file   = Path.Combine(ApplicationPaths.AppProgramPath, FONTS_FILE);
                string custom = Path.Combine(ApplicationPaths.AppProgramPath, CUSTOM_FONTS_FILE);
                if (File.Exists(file))
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch { }
                }
                if (File.Exists(custom))
                {
                    Logger.ReportInfo("Using custom fonts mcml");
                    if (!VerifyXmlResource(custom, Resources.FontsDefault))
                    {
                        host.MediaCenterEnvironment.Dialog(Application.CurrentInstance.StringData("FontsMissingDial"), CUSTOM_FONTS_FILE, DialogButtons.Ok, 100, true);
                    }
                    File.Copy(custom, file);
                }
                else
                {
                    var fontTheme = config != null ? config.FontTheme : "Default";
                    switch (fontTheme)
                    {
                    case "Small":
                        File.WriteAllBytes(file, Resources.FontsSmall);
                        break;

                    case "Default":
                    default:
                        File.WriteAllBytes(file, Resources.FontsDefault);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.ReportException("Error creating Fonts_DoNotEdit.mcml", ex);
                throw;
            }
        }
Exemplo n.º 33
0
        public void Launch(AddInHost host)
        {
            try
            {
                //  Lower the priority of this thread
                Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;

                //Prevents occurrence of the program has stopped responding?
                System.Threading.Thread.Sleep(200);

                //MediaExperienceWrapper.Instance.GoToFullScreen();

                logger.Write("Starting http server...");

                //  Setup HTTP socket listener
                m_httpServer.StartListening(GetPortNumber(m_basePortNumber) + 10);

                if (System.IO.File.Exists(System.Environment.GetEnvironmentVariable("windir") + "\\ehome\\vmcController.xml"))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(System.Environment.GetEnvironmentVariable("windir") + "\\ehome\\vmcController.xml");
                    XmlNode startupCommand = doc.DocumentElement.SelectSingleNode("startupMacro");

                    if (startupCommand != null)
                    {
                        MacroCmd macro  = new MacroCmd();
                        OpResult result = macro.Execute(startupCommand.InnerText);
                        result = null;
                        macro  = null;
                    }
                    doc = null;
                }

                //  Wait until exit request from host
                m_waitHandle.WaitOne();
            }
            catch (Exception e)
            {
                logger.Write("Exception in wait handle on Launch method: " + e.Message);
            }
            finally
            {
                cleanup();
            }
        }
Exemplo n.º 34
0
        private void SetupFontsMcml(AddInHost host)
        {
            try
            {
                string file   = Path.Combine(ApplicationPaths.AppConfigPath, FONTS_FILE);
                string custom = Path.Combine(ApplicationPaths.AppConfigPath, CUSTOM_FONTS_FILE);
                if (File.Exists(file))
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch { }
                }
                if (File.Exists(custom))
                {
                    Logger.ReportInfo("Using custom fonts mcml");
                    if (!VerifyStylesXml(custom, Resources.FontsDefault))
                    {
                        host.MediaCenterEnvironment.Dialog("CustomFonts.mcml as been pathed with missing values", CUSTOM_FONTS_FILE, DialogButtons.Ok, 100, true);
                    }
                    File.Copy(custom, file);
                }
                else
                {
                    switch (Config.Instance.FontTheme)
                    {
                    case "Small":
                        File.WriteAllBytes(file, Resources.FontsSmall);
                        break;

                    case "Default":
                    default:
                        File.WriteAllBytes(file, Resources.FontsDefault);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.ReportException("Error creating Fonts_DoNotEdit.mcml", ex);
                throw;
            }
        }
Exemplo n.º 35
0
 public void Launch(AddInHost host)
 {
     try
     {
         if (this.executionInfo.Media != null && this.executionInfo.Media.Count > 0)
         {
             bool flag = true;
             foreach (MediaInfo mediaInfo in this.executionInfo.Media)
             {
                 MediaCenterEnvironment centerEnvironment = AddInHost.Current.MediaCenterEnvironment;
                 MediaType?mediaType = mediaInfo.MediaType;
                 int       num1      = mediaType.HasValue ? (int)mediaType.GetValueOrDefault() : -1;
                 string    url       = mediaInfo.Url;
                 int       num2      = !flag ? 1 : 0;
                 centerEnvironment.PlayMedia((MediaType)num1, (object)url, num2 != 0);
                 flag = false;
             }
             MediaExperience mediaExperience = AddInHost.Current.MediaCenterEnvironment.MediaExperience;
             if (mediaExperience != null)
             {
                 mediaExperience.GoToFullScreen();
             }
         }
         if (VmcExecuteAddIn.ExecutionEngine != null)
         {
             VmcExecuteAddIn.session = new HistoryOrientedPageSession();
             ((PageSession)VmcExecuteAddIn.session).GoToPage("resx://Advent.VmcExecute/Advent.VmcExecute.Resources/MainPage");
             VmcExecuteAddIn.ExecutionEngine.BeginExecute();
         }
         else
         {
             if (!this.executionInfo.Page.HasValue)
             {
                 return;
             }
             AddInHost.Current.MediaCenterEnvironment.NavigateToPage(this.executionInfo.Page.Value, (object)null);
         }
     }
     catch (Exception ex)
     {
         VmcExecuteAddIn.LogError(ex.ToString());
         throw;
     }
 }
 public static void SetupFontsMcml(AddInHost host, Config config = null)
 {
     try
     {
         string file = Path.Combine(ApplicationPaths.AppProgramPath, FONTS_FILE);
         string custom = Path.Combine(ApplicationPaths.AppProgramPath, CUSTOM_FONTS_FILE);
         if (File.Exists(file))
         {
             try
             {
                 File.Delete(file);
             }
             catch { }
         }
         if (File.Exists(custom))
         {
             Logger.ReportInfo("Using custom fonts mcml");
             if (!VerifyXmlResource(custom, Resources.FontsDefault))
             {
                 host.MediaCenterEnvironment.Dialog(Application.CurrentInstance.StringData("FontsMissingDial"), CUSTOM_FONTS_FILE, DialogButtons.Ok, 100, true);
             }
             File.Copy(custom, file);
         }
         else
         {
             var fontTheme = config != null ? config.FontTheme : "Default";
             switch (fontTheme)
             {
                 case "Small":
                     File.WriteAllBytes(file, Resources.FontsSmall);
                     break;
                 case "Default":
                 default:
                     File.WriteAllBytes(file, Resources.FontsDefault);
                     break;
             }
         }
     }
     catch (Exception ex)
     {
         Logger.ReportException("Error creating Fonts_DoNotEdit.mcml", ex);
         throw;
     }
 }
Exemplo n.º 37
0
        private bool TestDBConnection(AddInHost host)
        {
            try
            {
                //return OMLEngine.Settings.OMLSettings.IsConnected;
                OMLEngine.DatabaseManagement.DatabaseManagement           dbm   = new OMLEngine.DatabaseManagement.DatabaseManagement();
                OMLEngine.DatabaseManagement.DatabaseInformation.SQLState state = dbm.CheckDatabase();
                switch (state)
                {
                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OK:
                    return(true);

                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionCodeOlderThanSchema:
                    throw (new Exception("The OML client is an older version than the database. Please upgrade the client components!"));

                //is this right?
                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionNotFound:
                    return(true);

                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.LoginFailure:
                    return(false);

                case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionUpgradeRequired:
                {
                    //TODO: do upgrade bits here...
                    return(true);
                }

                default:
                    throw (new Exception(OMLEngine.DatabaseManagement.DatabaseInformation.LastSQLError));
                }
            }
            catch (Exception ex)
            {
                host.MediaCenterEnvironment.Dialog(
                    ex.Message,
                    "CONNECTION FAILED", Microsoft.MediaCenter.DialogButtons.Ok, 5, false);
                return(false);

                //this._session.Close();
            }
            return(true);
        }
Exemplo n.º 38
0
        public void Launch(AddInHost host)
        {
            if (host != null && host.ApplicationContext != null)
            {
                host.ApplicationContext.SingleInstance = true;
            }
            s_session = new HistoryOrientedPageSession();
            Application app = new Application(s_session, host);

            string appdata = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            string[] fileList = Directory.GetFiles(appdata + @"\Microsoft\Windows\Temporary Internet Files", "watch_as3*.swf", SearchOption.AllDirectories);

            foreach (string f in fileList)
            {
                File.Delete(f);
            }
            //app.GoToMenu();
            host.MediaCenterEnvironment.NavigateToPage(PageId.ExtensibilityUrl, "http://www.youtube.com/leanback");
            host.MediaCenterEnvironment.MediaExperience.Transport.PlayRate = 0;
        }
Exemplo n.º 39
0
        public void Launch(AddInHost host)
        {
            //set our location to the programdata dir - if we don't theme support breaks!
            Environment.CurrentDirectory = OMLEngine.FileSystemWalker.PublicRootDirectory;
            //need to start checking ehres themes on startup!
            ThemeManager.CreateThemeFiles();

            //_id = "FirstRun";
            if (_id == "FirstRun")
            {
                //generate our themes - this happens every time mc starts
                //ThemeManager.CreateThemeFiles();
                CheckFirstRun(host);
            }
            else
            {
                s_session = new Library.Code.V3.HistoryOrientedPageSessionEx();
                GoToLoader();
                Microsoft.MediaCenter.UI.Application.DeferredInvoke(new Microsoft.MediaCenter.UI.DeferredHandler(this.BeginStart), (object)host, new TimeSpan(1));
            }
        }
Exemplo n.º 40
0
        public void Launch(AddInHost host)
        {
            //set our location to the programdata dir - if we don't theme support breaks!
            Environment.CurrentDirectory = OMLEngine.FileSystemWalker.PublicRootDirectory;
            //need to start checking ehres themes on startup!
            ThemeManager.CreateThemeFiles();

            //_id = "FirstRun";
            if (_id == "FirstRun")
            {
                //generate our themes - this happens every time mc starts
                //ThemeManager.CreateThemeFiles();
                CheckFirstRun(host);
            }
            else
            {
                s_session = new Library.Code.V3.HistoryOrientedPageSessionEx();
                GoToLoader();
                Microsoft.MediaCenter.UI.Application.DeferredInvoke(new Microsoft.MediaCenter.UI.DeferredHandler(this.BeginStart), (object)host, new TimeSpan(1));
            }
        }
Exemplo n.º 41
0
        public void Launch(AddInHost host)
        {
            MediaCenterHost = host;

            try
            {
                // Start caching
                MediaLibraryService.CacheMediaLibrary();
                PlaylistService.Current.InitializeService();
                EndpointService.Current.InitializeService();
            }
            catch (Exception ex)
            {
                LogUtility.LogException(ex);
                throw;
            }

            do
            {
                System.Threading.Thread.Sleep(500);
            } while (true);
        }
Exemplo n.º 42
0
		public void Launch(AddInHost host)
		{
			Host = host;
			_session = new HistoryOrientedPageSession();
			GoToPlayback(@"http://cloudstash.com/gamechanger.mpg");
		}
Exemplo n.º 43
0
        public void Launch(AddInHost host)
        {
            //  uncomment to debug
#if DEBUG
            host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true); 
#endif

            using (Mutex mutex = new Mutex(false, Kernel.MBCLIENT_MUTEX_ID))
            {
                //set up so everyone can access
                var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);
                var securitySettings = new MutexSecurity();
                try
                {
                    //don't bomb if this fails
                    securitySettings.AddAccessRule(allowEveryoneRule);
                    mutex.SetAccessControl(securitySettings);
                }
                catch (Exception)
                {
                    //we don't want to die here and we don't have a logger yet so just go on
                }
                try
                {
                    if (mutex.WaitOne(100,false))
                    {

                        var config = GetConfig();
                        if (config == null)
                        {
                            AddInHost.Current.ApplicationContext.CloseApplication();
                            return;
                        }

                        Environment.CurrentDirectory = ApplicationPaths.AppProgramPath;
                        using (new Util.Profiler("Total Kernel Init"))
                        {
                            Kernel.Init(config);
                            while (!Kernel.ServerConnected)
                            {
                                if (!Kernel.ServerConnected)
                                {
                                    if (host.MediaCenterEnvironment.Dialog("Could not connect to Media Browser 3 Server.  Please be sure it is running on the local network.\n\nWould you like to re-try?", "Error", DialogButtons.Yes | DialogButtons.No, 100, true) != DialogResult.No)
                                    {
                                        Kernel.ConnectToServer(config);
                                    }
                                    else
                                    {
                                        AddInHost.Current.ApplicationContext.CloseApplication();
                                        return;
                                    }
                                }
                            }
                        }
                        using (new Util.Profiler("Application Init"))
                        {
                            App = new Application(new MyHistoryOrientedPageSession(), host);

                            App.Init();
                        }

                        Kernel.Instance.OnApplicationInitialized();

                        mutex.ReleaseMutex();
                    }
                    else
                    {
                        //another instance running and in initialization - just blow out of here
                        Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication();
                        return;
                    }

                }
                catch (AbandonedMutexException)
                {
                    // Log the fact the mutex was abandoned in another process, it will still get acquired
                    Logger.ReportWarning("Previous instance of core ended abnormally...");
                    mutex.ReleaseMutex();
                }
            }
        }
Exemplo n.º 44
0
        public OMLApplication(HistoryOrientedPageSession session, AddInHost host)
        {
            #if LAYOUT_V3
            //sets up the hooks for context menu
            this.hooker = new Library.Code.V3.MoreInfoHooker2();
            this.mouseActiveHooker = new Library.Code.V3.IsMouseActiveHooker();
            this.mouseActiveHooker.MouseActive += new Library.Code.V3.IsMouseActiveHooker.MouseActiveHandler(mouseActiveHooker_MouseActive);
            #endif

            this.parentalControlManager = new ParentalControlManager();
            this._session = session;
            AddInHost.Current.MediaCenterEnvironment.PropertyChanged +=new PropertyChangedEventHandler(MediaCenterEnvironment_PropertyChanged);
            
            //I know its a factory
            //this._factory = new MoviePlayerFactory();

            try { // borrowed from vmcNetFlix project on google-code
                bool isConsole = false;
                if (host.MediaCenterEnvironment.Capabilities.ContainsKey("Console"))
                {
                    isConsole = (bool)host.MediaCenterEnvironment.Capabilities["Console"];
                }
                bool isVideo = false;
                if (host.MediaCenterEnvironment.Capabilities.ContainsKey("Video"))
                {
                    isVideo = (bool)host.MediaCenterEnvironment.Capabilities["Video"];
                }
                if (isConsole == false)
                {
                    if (isVideo == true)
                        _isExtender = true;
                }
            } catch (Exception)
            {
                _isExtender = false;
            }
#if DEBUG_EXT
            System.Diagnostics.Debugger.Launch();
            _isExtender = true;
#endif
#if DEBUG
            OMLApplication.DebugLine("[OMLApplication] MediaCenterEnvironment.Capabilities:");
            foreach (KeyValuePair<string, object> cap in host.MediaCenterEnvironment.Capabilities)
                try { DebugLine("  ['{0}'] = '{1}'", cap.Key, cap.Value); }
                catch { }
#else
            OMLApplication.DebugLine("[OMLApplication] constructor called");
#endif
            this._host = host;
            _singleApplicationInstance = this;
            I18n.InitializeResourceManager();
            string uiCulture = OMLSettings.UILanguage;
            if (!string.IsNullOrEmpty(uiCulture)) I18n.SetCulture(new CultureInfo(uiCulture));
            _nowPlayingMovieName = "Playing an unknown movie";
        }
Exemplo n.º 45
0
 private void SetupStylesMcml(AddInHost host)
 {
     try
     {
         string file = Path.Combine(ApplicationPaths.AppConfigPath, "Styles_DoNotEdit.mcml");
         string custom = Path.Combine(ApplicationPaths.AppConfigPath, CUSTOM_STYLE_FILE);
         if (File.Exists(file))
         {
             try
             {
                 File.Delete(file);
             }
             catch { }
         }
         if (File.Exists(custom))
         {
             Logger.ReportInfo("Using custom styles mcml");
             if (!VerifyStylesXml(custom, Resources.StylesDefault))
             {
                 host.MediaCenterEnvironment.Dialog(CUSTOM_STYLE_FILE + " has been patched with missing values", CUSTOM_STYLE_FILE, DialogButtons.Ok, 100, true);
             }
             File.Copy(custom, file);
         }
         else
         {
             // new options must be added to the ThemeModel choice in configpage.mcml
             switch (Config.Instance.Theme)
             {
                 case "Black":
                     File.WriteAllBytes(file, Resources.StylesBlack);
                     break;
                 case "Extender Default":
                     File.WriteAllBytes(file, Resources.StylesDefaultExtender);
                     break;
                 case "Extender Black":
                     File.WriteAllBytes(file, Resources.StylesBlackExtender);
                     break;
                 case "Default":
                 default:
                     File.WriteAllBytes(file, Resources.StylesDefault);
                     break;
             }
         }
     }
     catch (Exception ex)
     {
         Logger.ReportException("Error creating Styles_DoNotEdit.mcml", ex);
         throw;
     }
 }
Exemplo n.º 46
0
        private bool TestDBConnection(AddInHost host)
        {
            try
            {
                //return OMLEngine.Settings.OMLSettings.IsConnected;
                OMLEngine.DatabaseManagement.DatabaseManagement dbm = new OMLEngine.DatabaseManagement.DatabaseManagement();
                OMLEngine.DatabaseManagement.DatabaseInformation.SQLState state = dbm.CheckDatabase();
                switch (state)
                {
                    case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OK:
                        return true;
                    case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionCodeOlderThanSchema:
                        throw (new Exception("The OML client is an older version than the database. Please upgrade the client components!"));
                    //is this right?
                    case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionNotFound:
                        return true;
                    case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.LoginFailure:
                        return false;
                    case OMLEngine.DatabaseManagement.DatabaseInformation.SQLState.OMLDBVersionUpgradeRequired:
                        {
                            //TODO: do upgrade bits here...
                            return true;
                        }
                    default:
                        throw (new Exception(OMLEngine.DatabaseManagement.DatabaseInformation.LastSQLError));
                }
            }
            catch (Exception ex)
            {
                host.MediaCenterEnvironment.Dialog(
                ex.Message,
                "CONNECTION FAILED", Microsoft.MediaCenter.DialogButtons.Ok, 5, false);
                return false;

                //this._session.Close();
            }
            return true;
        }
Exemplo n.º 47
0
 private void SetupFontsMcml(AddInHost host)
 {
     try
     {
         string file = Path.Combine(ApplicationPaths.AppConfigPath, FONTS_FILE);
         string custom = Path.Combine(ApplicationPaths.AppConfigPath, CUSTOM_FONTS_FILE);
         if (File.Exists(file))
         {
             try
             {
                 File.Delete(file);
             }
             catch { }
         }
         if (File.Exists(custom))
         {
             Logger.ReportInfo("Using custom fonts mcml");
             if (!VerifyStylesXml(custom, Resources.FontsDefault))
             {
                 host.MediaCenterEnvironment.Dialog("CustomFonts.mcml as been pathed with missing values", CUSTOM_FONTS_FILE, DialogButtons.Ok, 100, true);
             }
             File.Copy(custom, file);
         }
         else
         {
             switch (Config.Instance.FontTheme)
             {
                 case "Small":
                     File.WriteAllBytes(file, Resources.FontsSmall);
                     break;
                 case "Default":
                 default:
                     File.WriteAllBytes(file, Resources.FontsDefault);
                     break;
             }
         }
     }
     catch (Exception ex)
     {
         Logger.ReportException("Error creating Fonts_DoNotEdit.mcml" , ex);
         throw;
     }
 }
Exemplo n.º 48
0
 public void Launch(AddInHost host)
 {
     try
     {
         if (this.executionInfo.Media != null && this.executionInfo.Media.Count > 0)
         {
             bool flag = true;
             foreach (MediaInfo mediaInfo in this.executionInfo.Media)
             {
                 MediaCenterEnvironment centerEnvironment = AddInHost.Current.MediaCenterEnvironment;
                 MediaType? mediaType = mediaInfo.MediaType;
                 int num1 = mediaType.HasValue ? (int)mediaType.GetValueOrDefault() : -1;
                 string url = mediaInfo.Url;
                 int num2 = !flag ? 1 : 0;
                 centerEnvironment.PlayMedia((MediaType)num1, (object)url, num2 != 0);
                 flag = false;
             }
             MediaExperience mediaExperience = AddInHost.Current.MediaCenterEnvironment.MediaExperience;
             if (mediaExperience != null)
                 mediaExperience.GoToFullScreen();
         }
         if (VmcExecuteAddIn.ExecutionEngine != null)
         {
             VmcExecuteAddIn.session = new HistoryOrientedPageSession();
             ((PageSession)VmcExecuteAddIn.session).GoToPage("resx://Advent.VmcExecute/Advent.VmcExecute.Resources/MainPage");
             VmcExecuteAddIn.ExecutionEngine.BeginExecute();
         }
         else
         {
             if (!this.executionInfo.Page.HasValue)
                 return;
             AddInHost.Current.MediaCenterEnvironment.NavigateToPage(this.executionInfo.Page.Value, (object)null);
         }
     }
     catch (Exception ex)
     {
         VmcExecuteAddIn.LogError(ex.ToString());
         throw;
     }
 }
        public void Launch(AddInHost host)
        {
            //  uncomment to debug
            #if DEBUG
            host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true);
            #endif

            using (Mutex mutex = new Mutex(false, Kernel.MBCLIENT_MUTEX_ID))
            {
                //set up so everyone can access
                var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);
                var securitySettings = new MutexSecurity();
                try
                {
                    //don't bomb if this fails
                    securitySettings.AddAccessRule(allowEveryoneRule);
                    mutex.SetAccessControl(securitySettings);
                }
                catch (Exception)
                {
                    //we don't want to die here and we don't have a logger yet so just go on
                }
                try
                {
                    if (mutex.WaitOne(100,false))
                    {

                        var config = GetConfig();
                        if (config == null)
                        {
                            Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication();
                            return;
                        }

                        Environment.CurrentDirectory = ApplicationPaths.AppConfigPath;
                        try
                        {
                            CustomResourceManager.SetupStylesMcml(host);
                            CustomResourceManager.SetupFontsMcml(host);
                        }
                        catch (Exception ex)
                        {
                            host.MediaCenterEnvironment.Dialog(ex.Message, Application.CurrentInstance.StringData("CustomErrorDial"), DialogButtons.Ok, 100, true);
                            Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication();
                            return;
                        }
                        using (new MediaBrowser.Util.Profiler("Total Kernel Init"))
                        {
                            Kernel.Init(config);
                        }
                        using (new MediaBrowser.Util.Profiler("Application Init"))
                        {
                            Application app = new Application(new MyHistoryOrientedPageSession(), host);

                            app.GoToMenu();
                        }
                        mutex.ReleaseMutex();
                    }
                    else
                    {
                        //another instance running and in initialization - just blow out of here
                        Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication();
                        return;
                    }

                }
                catch (AbandonedMutexException)
                {
                    // Log the fact the mutex was abandoned in another process, it will still get acquired
                    Logger.ReportWarning("Previous instance of core ended abnormally...");
                    mutex.ReleaseMutex();
                }
            }
        }
Exemplo n.º 50
0
        /// <summary>
        /// Starts running an application
        /// Because the Windows Media Center object is guaranteed to be valid only until the Launch
        /// method returns, an on-demand application must make all calls to the Windows Media Center
        /// API within the context of the application's Launch method. Calling the Windows Media
        /// Center object after the Launch method returns can result in a fatal error. If your
        /// application's Launch method spawns multiple threads, those threads must all be terminated
        /// before your Launch method returns. After calling the Launch method, if you do not call
        /// any method directly from the host object, .NET remoting releases unused objects every
        /// five minutes. To avoid this, use the host object or use the objects within five minutes
        /// to prevent them from being released.
        /// </summary>
        /// <param name="host">An application uses this interface to access other interfaces provided by the Microsoft.MediaCenter namespace</param>
        public void Launch(AddInHost host)
        {
            try
            {
                //  Lower the priority of this thread
                System.Threading.Thread.CurrentThread.Priority = ThreadPriority.Lowest;

                //  Setup TCP socket listener
                m_socketServer.StartListening(GetPortNumber(m_basePortNumber));
                m_socketServer.NewMessage += new EventHandler<SocketEventArgs>(m_socketServer_NewMessage);
                m_socketServer.Connected += new EventHandler<SocketEventArgs>(m_socketServer_Connected);

                //  Setup HTTP socket listener
                m_httpServer.StartListening(GetPortNumber(m_basePortNumber) + 10);
                m_httpServer.NewRequest += new EventHandler<HttpEventArgs>(m_httpServer_NewRequest);

                //EventLog.WriteEntry("VmcController Client AddIn", "Listening on port " + m_socketServer.PortNumber + " (Version " + VersionInfo + ")", EventLogEntryType.Information);

                if (System.IO.File.Exists(System.Environment.GetEnvironmentVariable("windir") + "\\ehome\\vmcController.xml"))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(System.Environment.GetEnvironmentVariable("windir") + "\\ehome\\vmcController.xml");
                    XmlNode startupCommand = doc.DocumentElement.SelectSingleNode("startupMacro");

                    if (startupCommand == null)
                    {
                        //AddInHost.Current.MediaCenterEnvironment.Dialog("startup node not found", "", DialogButtons.Ok, 5, false);
                    }
                    else
                    {
                        MacroCmd macro = new MacroCmd();
                        OpResult result = macro.Execute(startupCommand.InnerText);
                        result = null;
                        macro = null;
                    }
                    doc = null;
                }

                //  Wait until exit request from host
                m_waitHandle.WaitOne();
            }
            catch (Exception ex)
            {
                //EventLog.WriteEntry("VmcController Client AddIn", "Exception in Launch: " + ex.ToString(), EventLogEntryType.Error);
            }
            finally
            {
                //  Shutdown listener
                if (m_socketServer.PortNumber > 0)
                    m_socketServer.StopListening();
            }
        }
Exemplo n.º 51
0
 public Application(HistoryOrientedPageSession session, AddInHost host)
 {
     this.session = session;
     this.host = host;
 }
Exemplo n.º 52
0
        private void DeleteOldRegistryKey(AddInHost host)
        {
            // remove old HKCU key that caused settings to appear on the TV+Movies menu strip
            if (!host.MediaCenterEnvironment.Capabilities.ContainsKey("Console"))
            {
                try
                {
                    RegistryKey delKeyValue = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\" +
                                                                              @"Media Center\Extensibility\Categories\Services\" +
                                                                              @"Movies\{543d0438-b10d-43d8-a20d-f0c96db4e6bd}", true);
                    if (delKeyValue != null)
                    {
                        OMLApplication.DebugLine("[Launch] Deleting old registry key value");
                        delKeyValue.DeleteValue(@"UseCount");
                    }
                }
                catch (Exception) { } // we don't really care, just delete it if you find it

                try
                {
                    RegistryKey delSubKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\" +
                                                                            @"Media Center\Extensibility\Categories\Services\Movies", true);
                    if (delSubKey != null)
                    {
                        OMLApplication.DebugLine("[Launch] Deleting old registry key");
                        delSubKey.DeleteSubKey(@"{543d0438-b10d-43d8-a20d-f0c96db4e6bd}");
                    }
                }
                catch (Exception) { } // we don't really care, just delete it if you find it
            }
        }
Exemplo n.º 53
0
        private void CheckFirstRun(AddInHost host)
        {
            if (Properties.Settings.Default.ShowFirstRunPrompt == true)
            {
                List<string> buttons = new List<string>();
                buttons.Add("Configure OML");
                buttons.Add("No Thanks");
                Microsoft.MediaCenter.MediaCenterEnvironment env = host.MediaCenterEnvironment;
                string dialogText = "Would you like to configure Open Media Library now? To run this wizard later you can access OML from the program library.";
                Microsoft.MediaCenter.DialogResult res = env.Dialog(dialogText, "OPEN MEDIA LIBRARY", buttons, -1, true, null, delegate(Microsoft.MediaCenter.DialogResult dialogResult) { });
                if ((int)res == 100)
                {
                    //tmp until firstrun page
                    Properties.Settings.Default.ShowFirstRunPrompt = false;
                    Properties.Settings.Default.Save();

                    //run setup
                    s_session = new Library.Code.V3.HistoryOrientedPageSessionEx();
                    GoToLoader();
                    Microsoft.MediaCenter.UI.Application.DeferredInvoke(new Microsoft.MediaCenter.UI.DeferredHandler(this.BeginStart), (object)host, new TimeSpan(1));
                }
                else
                {
                    Properties.Settings.Default.ShowFirstRunPrompt = false;
                    Properties.Settings.Default.Save();
                    //env.Dialog("You can access OML from the program library.", "OPEN MEDIA LIBRARY", Microsoft.MediaCenter.DialogButtons.Ok, -1, true);
                }

            }
        }
Exemplo n.º 54
0
        /// <summary>
        /// Starts running an application
        /// Because the Windows Media Center object is guaranteed to be valid only until the Launch
        /// method returns, an on-demand application must make all calls to the Windows Media Center
        /// API within the context of the application's Launch method. Calling the Windows Media
        /// Center object after the Launch method returns can result in a fatal error. If your
        /// application's Launch method spawns multiple threads, those threads must all be terminated
        /// before your Launch method returns. After calling the Launch method, if you do not call
        /// any method directly from the host object, .NET remoting releases unused objects every
        /// five minutes. To avoid this, use the host object or use the objects within five minutes
        /// to prevent them from being released.
        /// </summary>
        /// <param name="host">An application uses this interface to access other interfaces provided by the Microsoft.MediaCenter namespace</param>
        public void Launch(AddInHost host)
        {
            try
            {
                //  Lower the priority of this thread
                Thread.CurrentThread.Priority = ThreadPriority.Lowest;

                //  Setup HTTP socket listener
                m_httpServer.StartListening(GetPortNumber(m_basePortNumber) + 10);

                if (System.IO.File.Exists(System.Environment.GetEnvironmentVariable("windir") + "\\ehome\\vmcController.xml"))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(System.Environment.GetEnvironmentVariable("windir") + "\\ehome\\vmcController.xml");
                    XmlNode startupCommand = doc.DocumentElement.SelectSingleNode("startupMacro");

                    if (startupCommand != null)
                    {
                        MacroCmd macro = new MacroCmd();
                        OpResult result = macro.Execute(startupCommand.InnerText);
                        result = null;
                        macro = null;
                    }
                    doc = null;
                }

                //  Wait until exit request from host
                m_waitHandle.WaitOne();

            }
            catch (Exception)
            {
            }
        }