Esempio n. 1
0
        // Entry point for the app
        public void GoToMenu()
        {
            Logger.ReportInfo("Media Browser (version " + AppVersion + ") Starting up.");
            try
            {
                if (Config.IsFirstRun)
                {
                    OpenConfiguration(false);
                    MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment;
                    ev.Dialog(CurrentInstance.StringData("FirstTimeDial"), CurrentInstance.StringData("FirstTimeCapDial"), DialogButtons.Ok, 60, true);
                }
                else
                {
                    //if the service is currently re-building our library - warn them
                    if (Kernel.Instance.ServiceConfigData.ForceRebuildInProgress)
                    {
                        MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment;
                        ev.Dialog(CurrentInstance.StringData("ForcedRebuildDial"), CurrentInstance.StringData("ForcedRebuildCapDial"), DialogButtons.Ok, 15, true);
                        session.Close();
                    }
                    //Check to see if this is the first time this version is run
                    string currentVersion = Kernel.Instance.Version.ToString();
                    if (Config.MBVersion != currentVersion)
                    {
                        //first time with this version - run routine
                        Logger.ReportInfo("First run for version " + currentVersion);
                        bool okToRun = FirstRunForVersion(currentVersion);
                        //and update
                        Config.MBVersion = currentVersion;
                        if (!okToRun)
                        {
                            Logger.ReportInfo("Closing MB to allow new version migration...");
                            this.Close();
                        }
                    }
                    //if the service refresh failed - notify them
                    if (Kernel.Instance.ServiceConfigData.RefreshFailed)
                    {
                        MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment;
                        ev.Dialog(CurrentInstance.StringData("RefreshFailedDial"), CurrentInstance.StringData("RefreshFailedCapDial"), DialogButtons.Ok, 15, true);

                    }
                    // We check config here instead of in the Updater class because the Config class
                    // CANNOT be instantiated outside of the application thread.
                    if (Config.EnableUpdates)
                    {
                        Updater update = new Updater(this);

                        Async.Queue(Async.STARTUP_QUEUE, () =>
                        {
                            update.CheckForUpdate();
                        }, 40000);
                        Async.Queue(Async.STARTUP_QUEUE, () =>
                        {
                            PluginUpdatesAvailable = update.PluginUpdatesAvailable();
                        }, 60000);
                    }

                    // set npv visibility according to current state
                    if (MediaCenterEnvironment.MediaExperience != null && MediaCenterEnvironment.MediaExperience.Transport != null)
                    {
                        ShowNowPlaying = MediaCenterEnvironment.MediaExperience.Transport.PlayState == Microsoft.MediaCenter.PlayState.Playing;
                    }

                    // setup image to use in external splash screen
                    string splashFilename = Path.Combine(Path.Combine(ApplicationPaths.AppIBNPath,"General"),"splash.png");
                    if (File.Exists(splashFilename))
                    {
                        ExtSplashBmp = new System.Drawing.Bitmap(splashFilename);
                    }
                    else
                    {
                        ExtSplashBmp = new System.Drawing.Bitmap(Resources.mblogo1000);
                    }

                    // we need to validate the library so that changes in the RAL will get picked up without having to navigate
                    if (Config.AutoValidate)
                    {
                        Async.Queue("Startup Library Validator", () =>
                        {
                            using (new Profiler("Startup Validation"))
                            {
                                Kernel.Instance.MajorActivity = true;
                                RootFolder.RefreshMetadata();

                                //These validations have been moved to the recent list builds since they are needed there anyway

                                //foreach (Folder folder in RootFolder.RecursiveFolders)
                                //{
                                //    folder.ValidateChildren();
                                //}
                                //foreach (BaseItem item in RootFolder.RecursiveChildren)
                                //{
                                //    //refresh new items
                                //    if ((DateTime.Now - item.DateModified).TotalDays < 2)
                                //        item.RefreshMetadata();
                                //}
                                ////finally - we need to invalidate the recent lists to pick up any new items we just found
                                //foreach (Item item in RootFolderModel.Children)
                                //{
                                //    (item as FolderModel).QuickListItems = null; //force to re-load
                                //}
                                Kernel.Instance.MajorActivity = false;
                            }
                        });
                    }
                    //Launch into our entrypoint
                    LaunchEntryPoint(EntryPointResolver.EntryPointPath);
                }
            }
            catch (Exception e)
            {
                Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment.Dialog(CurrentInstance.StringData("CriticalErrorDial") + e.ToString() + " " + e.StackTrace.ToString(), CurrentInstance.StringData("CriticalErrorCapDial"), DialogButtons.Ok, 60, true);
                Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication();
            }
        }
Esempio n. 2
0
        // Entry point for the app
        public void GoToMenu()
        {
            Logger.ReportInfo("Media Browser (version " + AppVersion + ") Starting up.");
            //let's put some useful info in here for diagnostics
            if (!Config.AutoValidate)
                Logger.ReportWarning("*** AutoValidate is OFF.");
            if (Config.ParentalControlEnabled)
                Logger.ReportInfo("*** Parental Controls are ON with a max rating of "+Config.ParentalMaxAllowedString+".  Block Unrated is "+Config.ParentalBlockUnrated+" and Hide Content is "+Config.HideParentalDisAllowed);
            Logger.ReportInfo("*** Internet Providers are "+(Config.AllowInternetMetadataProviders ? "ON." : "OFF."));
            if (Config.AllowInternetMetadataProviders) Logger.ReportInfo("*** Save Locally is "+(Config.SaveLocalMeta ? "ON." : "OFF."));
            Logger.ReportInfo("*** Theme in use is: " + Config.ViewTheme);
            // Now let's put a diagnostic ping in here for the beta cycle so we can see how much testing we're getting
            //string info = "IP=" + Config.AllowInternetMetadataProviders + " EXTP=" + Config.ExternalPlayers.Count + " EXT=" + RunningOnExtender;
            //Helper.Ping("http://www.ebrsoft.com/software/mb/plugins/ping.php?product=MBBeta&ver=" + Kernel.Instance.VersionStr + "&mac=" + Helper.GetMACAddress() + "&key=" + info);
            try
            {
                if (Config.IsFirstRun)
                {
                    OpenConfiguration(false);
                    MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment;
                    ev.Dialog(CurrentInstance.StringData("FirstTimeDial"), CurrentInstance.StringData("FirstTimeCapDial"), DialogButtons.Ok, 60, true);
                }
                else
                {
                    //if the service is currently re-building our library - warn them
                    if (Kernel.Instance.ServiceConfigData.ForceRebuildInProgress)
                    {
                        MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment;
                        ev.Dialog(CurrentInstance.StringData("ForcedRebuildDial"), CurrentInstance.StringData("ForcedRebuildCapDial"), DialogButtons.Ok, 15, true);
                        session.Close();
                    }
                    //Check to see if this is the first time this version is run
                    string currentVersion = Kernel.Instance.Version.ToString();
                    if (Config.MBVersion != currentVersion)
                    {
                        //first time with this version - run routine
                        Logger.ReportInfo("First run for version " + currentVersion);
                        bool okToRun = FirstRunForVersion(currentVersion);
                        //and update
                        Config.MBVersion = currentVersion;
                        if (!okToRun)
                        {
                            Logger.ReportInfo("Closing MB to allow new version migration...");
                            this.Close();
                        }
                    }
                    //if the service refresh failed - notify them
                    if (Kernel.Instance.ServiceConfigData.RefreshFailed)
                    {
                        MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment;
                        ev.Dialog(CurrentInstance.StringData("RefreshFailedDial"), CurrentInstance.StringData("RefreshFailedCapDial"), DialogButtons.Ok, 15, true);

                    }
                    // We check config here instead of in the Updater class because the Config class
                    // CANNOT be instantiated outside of the application thread.
                    if (Config.EnableUpdates)
                    {
                        Updater update = new Updater(this);

                        Async.Queue(Async.STARTUP_QUEUE, () =>
                        {
                            update.CheckForUpdate();
                        }, 40000);
                        Async.Queue(Async.STARTUP_QUEUE, () =>
                        {
                            PluginUpdatesAvailable = update.PluginUpdatesAvailable();
                        }, 60000);
                    }

                    ShowNowPlaying = IsPlaying || IsExternalWmcApplicationPlaying;

                    // setup image to use in external splash screen
                    string splashFilename = Path.Combine(Path.Combine(ApplicationPaths.AppIBNPath,"General"),"splash.png");
                    if (File.Exists(splashFilename))
                    {
                        ExtSplashBmp = new System.Drawing.Bitmap(splashFilename);
                    }
                    else
                    {
                        ExtSplashBmp = new System.Drawing.Bitmap(Resources.mblogo1000);
                    }

                    //validate that everything at the root level is actually a folder - the UI will blow chow with items
                    foreach (var item in RootFolder.Children)
                    {
                        if (!(item is Folder))
                        {
                            string msg = "W A R N I N G: Item " + item.Name + " is resolving to a " + item.GetType().Name + ". All root level items must be folders.\n  Check that this item isn't being mistaken because it is a folder with only a couple items and you have the playlist functionality enabled.";
                            Logger.ReportError(msg);
                            DisplayDialog(msg, "Invalid Root Item");
                        }
                    }

                    // we need to validate the library so that changes in the RAL will get picked up without having to navigate
                    if (Config.AutoValidate)
                    {
                        Async.Queue("Startup Library Validator", () =>
                        {
                            using (new Profiler("Startup Validation"))
                            {
                                Kernel.Instance.MajorActivity = true;
                                RootFolder.RefreshMetadata();

                                //These validations have been moved to the recent list builds since they are needed there anyway

                                //foreach (Folder folder in RootFolder.RecursiveFolders)
                                //{
                                //    folder.ValidateChildren();
                                //}
                                //foreach (BaseItem item in RootFolder.RecursiveChildren)
                                //{
                                //    //refresh new items
                                //    if ((DateTime.Now - item.DateModified).TotalDays < 2)
                                //        item.RefreshMetadata();
                                //}
                                ////finally - we need to invalidate the recent lists to pick up any new items we just found
                                //foreach (Item item in RootFolderModel.Children)
                                //{
                                //    (item as FolderModel).QuickListItems = null; //force to re-load
                                //}
                                Kernel.Instance.MajorActivity = false;
                            }
                        });
                    }
                    //Launch into our entrypoint
                    LaunchEntryPoint(EntryPointResolver.EntryPointPath);
                }
            }
            catch (Exception e)
            {
                Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment.Dialog(CurrentInstance.StringData("CriticalErrorDial") + e.ToString() + " " + e.StackTrace.ToString(), CurrentInstance.StringData("CriticalErrorCapDial"), DialogButtons.Ok, 60, true);
                Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication();
            }
        }