protected override void OnPageLoad()
        {
            base.OnPageLoad();

            Log.Instance.Info("OnPageLoad of Site Updater with PreviousWindowId '{0}'", PreviousWindowId);

            defaultLabelBtnSort          = GUIPropertyManager.Parse(GUI_btnSort.Label);
            defaultLabelBtnFilterState   = GUIPropertyManager.Parse(GUI_btnFilterState.Label);
            defaultLabelBtnFilterCreator = GUIPropertyManager.Parse(GUI_btnFilterCreator.Label);
            defaultLabelBtnFilterLang    = GUIPropertyManager.Parse(GUI_btnFilterLang.Label);

            if (GUI_btnFilterState.SubItemCount == 0)
            {
                foreach (string aFilterOption in Enum.GetNames(typeof(FilterStateOption)))
                {
                    GUIControl.AddItemLabelControl(GetID, GUI_btnFilterState.GetID, Translation.Instance.GetByName(aFilterOption));
                }
            }
            if (GUI_btnSort.SubItemCount == 0)
            {
                foreach (string aSortOption in Enum.GetNames(typeof(SortOption)))
                {
                    string[] singled = aSortOption.Split('_');
                    for (int i = 0; i < singled.Length; i++)
                    {
                        singled[i] = Translation.Instance.GetByName(singled[i]);
                    }
                    GUIControl.AddItemLabelControl(GetID, GUI_btnSort.GetID, string.Join(", ", singled));
                }
            }
            SetFilterButtonOptions();

            GUIPropertyManager.SetProperty("#OnlineVideos.HeaderLabel",
                                           PluginConfiguration.Instance.BasicHomeScreenName + ": " + Translation.Instance.ManageSites);
            GUIPropertyManager.SetProperty("#OnlineVideos.HeaderImage",
                                           SiteImageExistenceCache.GetImageForSite("OnlineVideos"));

            GUIOnlineVideos ovGuiInstance = (GUIOnlineVideos)GUIWindowManager.GetWindow(GUIOnlineVideos.WindowId);

            if (ovGuiInstance != null && ovGuiInstance.SelectedSite != null && ovGuiInstance.CurrentState != GUIOnlineVideos.State.sites)
            {
                selectedSite = ovGuiInstance.SelectedSite.Settings.Name;
            }

            RefreshDisplayedOnlineSites();
        }
        public OnlineVideosGuiListItem(Sites.SiteUtilBase item) : base(item.Settings.Name)
        {
            Label2   = item.Settings.Language;
            IsFolder = true;
            Item     = item;
            // use Icon with the same name as the Site
            string image = SiteImageExistenceCache.GetImageForSite(item.Settings.Name, item.Settings.UtilName, "Icon");

            if (!string.IsNullOrEmpty(image))
            {
                ThumbnailImage = image;
                IconImage      = image;
                IconImageBig   = image;
            }
            else
            {
                MediaPortal.Util.Utils.SetDefaultIcons(this);
            }
        }
Exemple #3
0
        void SetLatestVideoGuiProperties(KeyValuePair <string, VideoInfo> video, int index)
        {
            GUIPropertyManager.SetProperty(string.Format("#OnlineVideos.LatestVideo{0}.Site", index), video.Key);

            string siteIcon = SiteImageExistenceCache.GetImageForSite(video.Key, null, "Icon");

            if (string.IsNullOrEmpty(siteIcon))
            {
                siteIcon = SiteImageExistenceCache.GetImageForSite("OnlineVideos", type: "Icon");
            }
            if (siteIcon == null)
            {
                siteIcon = string.Empty;
            }
            GUIPropertyManager.SetProperty(string.Format("#OnlineVideos.LatestVideo{0}.SiteIcon", index), siteIcon);

            GUIPropertyManager.SetProperty(string.Format("#OnlineVideos.LatestVideo{0}.Title", index), video.Value.Title);
            GUIPropertyManager.SetProperty(string.Format("#OnlineVideos.LatestVideo{0}.Aired", index), video.Value.Airdate);
            GUIPropertyManager.SetProperty(string.Format("#OnlineVideos.LatestVideo{0}.Duration", index), video.Value.Length);
            GUIPropertyManager.SetProperty(string.Format("#OnlineVideos.LatestVideo{0}.Thumb", index), video.Value.ThumbnailImage);
            GUIPropertyManager.SetProperty(string.Format("#OnlineVideos.LatestVideo{0}.Description", index), video.Value.Description);
        }
        void ShowOptionsForSite(OnlineVideosWebservice.Site site)
        {
            SiteSettings localSite      = null;
            int          localSiteIndex = OnlineVideoSettings.Instance.GetSiteByName(site.Name, out localSite);

            GUIDialogMenu dlgSel = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            dlgSel.ShowQuickNumbers = false;
            if (dlgSel != null)
            {
                dlgSel.Reset();
                dlgSel.SetHeading(Translation.Instance.Actions);

                if (localSiteIndex == -1)
                {
                    if (site.State != OnlineVideosWebservice.SiteState.Broken)
                    {
                        dlgSel.Add(Translation.Instance.AddToMySites);
                    }
                }
                else
                {
                    if ((site.LastUpdated - localSite.LastUpdated).TotalMinutes > 2 && site.State != OnlineVideosWebservice.SiteState.Broken)
                    {
                        dlgSel.Add(Translation.Instance.UpdateMySite);
                        dlgSel.Add(Translation.Instance.UpdateMySiteSkipCategories);
                    }
                    dlgSel.Add(Translation.Instance.RemoveFromMySites);
                }

                if (GUI_infoList.Count > 1)
                {
                    dlgSel.Add(Translation.Instance.RemoveAllFromMySites);
                    dlgSel.Add(Translation.Instance.UpdateAll);
                    dlgSel.Add(Translation.Instance.UpdateAllSkipCategories);
                }

                if (!string.IsNullOrEmpty(site.Owner_FK) && localSiteIndex >= 0) // !only local && ! only global
                {
                    dlgSel.Add(Translation.Instance.ShowReports);
                    if (site.State != OnlineVideosWebservice.SiteState.Broken)
                    {
                        dlgSel.Add(Translation.Instance.ReportBroken);
                    }
                }
            }
            dlgSel.DoModal(GUIWindowManager.ActiveWindow);
            if (dlgSel.SelectedId == -1)
            {
                return;                          // ESC used, nothing selected
            }
            if (dlgSel.SelectedLabelText == Translation.Instance.AddToMySites ||
                dlgSel.SelectedLabelText == Translation.Instance.UpdateMySite ||
                dlgSel.SelectedLabelText == Translation.Instance.UpdateMySiteSkipCategories)
            {
                if (CheckOnlineVideosVersion())
                {
                    Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(
                        () =>
                    {
                        bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites(null, new List <OnlineVideosWebservice.Site> {
                            site
                        }, false,
                                                                                   dlgSel.SelectedLabelText == Translation.Instance.UpdateMySiteSkipCategories);
                        if (updateResult == true)
                        {
                            newDllsDownloaded = true;
                        }
                        else if (updateResult == null)
                        {
                            newDataSaved = true;
                        }
                        return(updateResult != false);
                    },
                        (success, result) =>
                    {
                        if (success && (bool)result)
                        {
                            SiteImageExistenceCache.UnCacheImageForSite(site.Name);
                            RefreshDisplayedOnlineSites();
                        }
                    },
                        Translation.Instance.GettingSiteXml, true);
                }
            }
            else if (dlgSel.SelectedLabelText == Translation.Instance.UpdateAll ||
                     dlgSel.SelectedLabelText == Translation.Instance.UpdateAllSkipCategories)
            {
                if (CheckOnlineVideosVersion())
                {
                    GUIDialogProgress dlgPrgrs = PrepareProgressDialog(Translation.Instance.FullUpdate);
                    new System.Threading.Thread(delegate()
                    {
                        bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites((m, p) =>
                        {
                            if (dlgPrgrs != null)
                            {
                                if (!string.IsNullOrEmpty(m))
                                {
                                    dlgPrgrs.SetLine(1, m);
                                }
                                if (p != null)
                                {
                                    dlgPrgrs.SetPercentage(p.Value);
                                }
                                return(dlgPrgrs.ShouldRenderLayer());
                            }
                            else
                            {
                                return(true);
                            }
                        }, GUI_infoList.ListItems.Select(g => g.TVTag as OnlineVideosWebservice.Site).ToList(), dlgSel.SelectedLabelText == Translation.Instance.UpdateAllSkipCategories);
                        if (updateResult == true)
                        {
                            newDllsDownloaded = true;
                        }
                        else if (updateResult == null)
                        {
                            newDataSaved = true;
                        }
                        if (updateResult != false)
                        {
                            SiteImageExistenceCache.ClearCache();
                        }
                        if (dlgPrgrs != null)
                        {
                            dlgPrgrs.Close();
                        }
                        GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) => { RefreshDisplayedOnlineSites(); return(0); }, 0, 0, null);
                    })
                    {
                        Name = "OVSelectUpdate", IsBackground = true
                    }.Start();
                }
            }
            else if (dlgSel.SelectedLabelText == Translation.Instance.RemoveFromMySites)
            {
                OnlineVideoSettings.Instance.RemoveSiteAt(localSiteIndex);
                OnlineVideoSettings.Instance.SaveSites();
                newDataSaved = true;
                RefreshDisplayedOnlineSites(GUI_infoList.SelectedListItemIndex);
            }
            else if (dlgSel.SelectedLabelText == Translation.Instance.RemoveAllFromMySites)
            {
                bool needRefresh = false;
                foreach (var siteToRemove in GUI_infoList.ListItems.Where(g => g.IsPlayed).Select(g => g.TVTag as OnlineVideosWebservice.Site).ToList())
                {
                    localSiteIndex = OnlineVideoSettings.Instance.GetSiteByName(siteToRemove.Name, out localSite);
                    if (localSiteIndex >= 0)
                    {
                        OnlineVideoSettings.Instance.RemoveSiteAt(localSiteIndex);
                        needRefresh = true;
                    }
                }
                if (needRefresh)
                {
                    OnlineVideoSettings.Instance.SaveSites();
                    newDataSaved = true;
                    RefreshDisplayedOnlineSites();
                }
            }
            else if (dlgSel.SelectedLabelText == Translation.Instance.ShowReports)
            {
                Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(
                    () =>
                {
                    OnlineVideosWebservice.OnlineVideosService ws = new OnlineVideosWebservice.OnlineVideosService();
                    return(ws.GetReports(site.Name));
                },
                    (success, result) =>
                {
                    if (success)
                    {
                        OnlineVideosWebservice.Report[] reports = result as OnlineVideosWebservice.Report[];

                        if (reports == null || reports.Length == 0)
                        {
                            GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                            if (dlg != null)
                            {
                                dlg.Reset();
                                dlg.SetImage(SiteImageExistenceCache.GetImageForSite("OnlineVideos", type: "Icon"));
                                dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName);
                                dlg.SetText(Translation.Instance.NoReportsForSite);
                                dlg.DoModal(GUIWindowManager.ActiveWindow);
                            }
                        }
                        else
                        {
                            selectedSite = site.Name;
                            GUIControl.ClearControl(GetID, GUI_infoList.GetID);

                            Array.Sort(reports, new Comparison <OnlineVideosWebservice.Report>(delegate(OnlineVideosWebservice.Report a, OnlineVideosWebservice.Report b)
                            {
                                return(b.Date.CompareTo(a.Date));
                            }));

                            foreach (OnlineVideosWebservice.Report report in reports)
                            {
                                string shortMsg            = report.Message.Replace(Environment.NewLine, " ").Replace("\n", " ").Replace("\r", " ");
                                GUIListItem loListItem     = new GUIListItem(shortMsg.Length > 44 ? shortMsg.Substring(0, 40) + " ..." : shortMsg);
                                loListItem.TVTag           = report;
                                loListItem.Label2          = report.Type.ToString();
                                loListItem.Label3          = report.Date.ToString("g", OnlineVideoSettings.Instance.Locale);
                                loListItem.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(OnReportSelected);
                                GUI_infoList.Add(loListItem);
                            }
                            GUIControl.SelectItemControl(GetID, GUI_infoList.GetID, 0);
                            GUIPropertyManager.SetProperty("#itemcount", GUI_infoList.Count.ToString());
                            GUIPropertyManager.SetProperty("#itemtype", Translation.Instance.Reports);
                        }
                    }
                }, Translation.Instance.GettingReports, true);
            }
            else if (dlgSel.SelectedLabelText == Translation.Instance.ReportBroken)
            {
                if (CheckOnlineVideosVersion())
                {
                    if ((site.LastUpdated - localSite.LastUpdated).TotalMinutes > 1)
                    {
                        GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                        if (dlg != null)
                        {
                            dlg.Reset();
                            dlg.SetHeading(site.Name);
                            dlg.SetLine(1, Translation.Instance.PleaseUpdateLocalSite);
                            dlg.DoModal(GUIWindowManager.ActiveWindow);
                        }
                    }
                    else
                    {
                        string userReason = "";
                        if (GUIOnlineVideos.GetUserInputString(ref userReason, false))
                        {
                            if (userReason.Length < 15)
                            {
                                GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                                if (dlg != null)
                                {
                                    dlg.Reset();
                                    dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName);
                                    dlg.SetLine(1, Translation.Instance.PleaseEnterDescription);
                                    dlg.DoModal(GUIWindowManager.ActiveWindow);
                                }
                            }
                            else
                            {
                                OnlineVideosWebservice.OnlineVideosService ws = new OnlineVideosWebservice.OnlineVideosService();
                                string      message = "";
                                bool        success = ws.SubmitReport(site.Name, userReason, OnlineVideosWebservice.ReportType.Broken, out message);
                                GUIDialogOK dlg     = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                                if (dlg != null)
                                {
                                    dlg.Reset();
                                    dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName);
                                    dlg.SetLine(1, success ? Translation.Instance.Done : Translation.Instance.Error);
                                    dlg.SetLine(2, message);
                                    dlg.DoModal(GUIWindowManager.ActiveWindow);
                                }
                                if (success)
                                {
                                    // reload online sites
                                    OnlineVideos.Sites.Updater.GetRemoteOverviews(true);
                                    RefreshDisplayedOnlineSites();
                                }
                            }
                        }
                    }
                }
            }
        }
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            if (Gui2UtilConnector.Instance.IsBusy)
            {
                return;                                    // wait for any background action e.g. online sites retrieval to finish
            }
            if (control == GUI_btnSort)
            {
                GUIControl.SelectItemControl(GetID, GUI_btnSort.GetID, GUI_btnSort.SelectedItem);
                RefreshDisplayedOnlineSites();
            }
            else if (control == GUI_btnFilterState)
            {
                GUIControl.SelectItemControl(GetID, GUI_btnFilterState.GetID, GUI_btnFilterState.SelectedItem);
                RefreshDisplayedOnlineSites();
            }
            else if (control == GUI_btnFilterCreator)
            {
                GUIControl.SelectItemControl(GetID, GUI_btnFilterCreator.GetID, GUI_btnFilterCreator.SelectedItem);
                RefreshDisplayedOnlineSites();
            }
            else if (control == GUI_btnFilterLang)
            {
                GUIControl.SelectItemControl(GetID, GUI_btnFilterLang.GetID, GUI_btnFilterLang.SelectedItem);
                RefreshDisplayedOnlineSites();
            }
            else if (control == GUI_infoList && actionType == Action.ActionType.ACTION_SELECT_ITEM)
            {
                if (GUI_infoList.SelectedListItem.TVTag is OnlineVideosWebservice.Site)
                {
                    ShowOptionsForSite(GUI_infoList.SelectedListItem.TVTag as OnlineVideosWebservice.Site);
                }
            }
            else if (control == GUI_btnAutoUpdate)
            {
                if (CheckOnlineVideosVersion())
                {
                    Log.Instance.Info("SiteManager: Running AutoUpdate");
                    GUIDialogProgress dlgPrgrs = PrepareProgressDialog(Translation.Instance.AutomaticUpdate);
                    new System.Threading.Thread(delegate()
                    {
                        bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites((m, p) =>
                        {
                            if (dlgPrgrs != null)
                            {
                                if (!string.IsNullOrEmpty(m))
                                {
                                    dlgPrgrs.SetLine(1, m);
                                }
                                if (p != null)
                                {
                                    dlgPrgrs.SetPercentage(p.Value);
                                }
                                return(dlgPrgrs.ShouldRenderLayer());
                            }
                            else
                            {
                                return(true);
                            }
                        });
                        if (updateResult == true)
                        {
                            newDllsDownloaded = true;
                        }
                        else if (updateResult == null)
                        {
                            newDataSaved = true;
                        }
                        if (updateResult != false)
                        {
                            SiteImageExistenceCache.ClearCache();
                        }
                        if (dlgPrgrs != null)
                        {
                            dlgPrgrs.Close();
                        }
                        GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) => { RefreshDisplayedOnlineSites(); return(0); }, 0, 0, null);
                    })
                    {
                        Name = "OVAutoUpdate", IsBackground = true
                    }.Start();
                }
            }

            base.OnClicked(controlId, control, actionType);
        }
        void DisplayOnlineSites(bool newDataRetrieved, int indexToSelect)
        {
            GUIPropertyManager.SetProperty("#OnlineVideos.owner", String.Empty);
            GUIPropertyManager.SetProperty("#OnlineVideos.desc", String.Empty);

            if (newDataRetrieved)
            {
                SetFilterButtonOptions();
            }

            if (Sites.Updater.OnlineSites == null || Sites.Updater.OnlineSites.Length == 0)
            {
                return;
            }

            GUIListItem selectedItem = GUI_infoList.SelectedListItem;

            GUIControl.ClearControl(GetID, GUI_infoList.GetID);

            var localSitesDic  = OnlineVideoSettings.Instance.SiteSettingsList.ToDictionary(s => s.Name, s => s);
            var onlyLocalSites = OnlineVideoSettings.Instance.SiteSettingsList.ToDictionary(s => s.Name, s => s);
            List <OnlineVideosWebservice.Site> filteredsortedSites = new List <OnlineVideos.OnlineVideosWebservice.Site>(Sites.Updater.OnlineSites);

            filteredsortedSites.ForEach(os => { if (localSitesDic.ContainsKey(os.Name))
                                                {
                                                    onlyLocalSites.Remove(os.Name);
                                                }
                                        });
            filteredsortedSites.AddRange(onlyLocalSites.Select(ls => new OnlineVideosWebservice.Site()
            {
                Name = ls.Value.Name, IsAdult = ls.Value.ConfirmAge, Description = ls.Value.Description, Language = ls.Value.Language, LastUpdated = ls.Value.LastUpdated
            }));
            filteredsortedSites = filteredsortedSites.FindAll(SitePassesFilter);
            filteredsortedSites.Sort(CompareSiteForSort);

            foreach (OnlineVideosWebservice.Site site in filteredsortedSites)
            {
                if (!site.IsAdult || !OnlineVideoSettings.Instance.UseAgeConfirmation || OnlineVideoSettings.Instance.AgeConfirmed)
                {
                    GUIListItem loListItem = new GUIListItem(site.Name);
                    loListItem.TVTag  = site;
                    loListItem.Label2 = site.Language;
                    loListItem.Label3 = site.LastUpdated.ToLocalTime().ToString("g", OnlineVideoSettings.Instance.Locale);
                    string image = SiteImageExistenceCache.GetImageForSite(site.Name, "", "Icon", false);
                    if (!string.IsNullOrEmpty(image))
                    {
                        loListItem.IconImage = image; loListItem.ThumbnailImage = image;
                    }
                    if (!string.IsNullOrEmpty(site.Owner_FK))
                    {
                        loListItem.PinImage = GUIGraphicsContext.Skin + @"\Media\OnlineVideos\" + site.State.ToString() + ".png";
                    }
                    loListItem.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(OnSiteSelected);
                    loListItem.IsPlayed        = localSitesDic.ContainsKey(site.Name);             // GetLocalSite(site.Name) != -1;
                    GUI_infoList.Add(loListItem);
                    if ((selectedItem != null && selectedItem.Label == loListItem.Label) ||
                        selectedSite == loListItem.Label ||
                        (indexToSelect > -1 && GUI_infoList.Count - 1 == indexToSelect))
                    {
                        GUI_infoList.SelectedListItemIndex = GUI_infoList.Count - 1;
                    }
                }
            }

            if (GUI_infoList.Count > 0)
            {
                GUIControl.SelectItemControl(GetID, GUI_infoList.GetID, GUI_infoList.SelectedListItemIndex);
            }

            selectedSite = null;

            //set object count and type labels
            GUIPropertyManager.SetProperty("#itemcount", GUI_infoList.Count.ToString());
            GUIPropertyManager.SetProperty("#itemtype", Translation.Instance.Sites);
        }
 void DoSubsequentLoad()
 {
     if (PreviousWindowId != OnlineVideos.MediaPortal1.Player.GUIOnlineVideoFullscreen.WINDOW_FULLSCREEN_ONLINEVIDEO &&
         PluginConfiguration.Instance.updateOnStart != false &&
         PluginConfiguration.Instance.lastFirstRun.AddHours(PluginConfiguration.Instance.updatePeriod) < DateTime.Now)
     {
         bool?doUpdate = PluginConfiguration.Instance.updateOnStart;
         if (!PluginConfiguration.Instance.updateOnStart.HasValue && !preventDialogOnLoad)
         {
             GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
             if (dlg != null)
             {
                 dlg.Reset();
                 dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName);
                 dlg.SetLine(1, Translation.Instance.PerformAutomaticUpdate);
                 dlg.SetLine(2, Translation.Instance.UpdateAllYourSites);
                 dlg.DoModal(GUIWindowManager.ActiveWindow);
                 doUpdate = dlg.IsConfirmed;
             }
         }
         PluginConfiguration.Instance.lastFirstRun = DateTime.Now;
         if (doUpdate == true || PluginConfiguration.Instance.ThumbsAge >= 0)
         {
             GUIDialogProgress dlgPrgrs = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);
             if (dlgPrgrs != null)
             {
                 dlgPrgrs.Reset();
                 dlgPrgrs.DisplayProgressBar = true;
                 dlgPrgrs.ShowWaitCursor     = false;
                 dlgPrgrs.DisableCancel(true);
                 dlgPrgrs.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName);
                 dlgPrgrs.StartModal(GUIWindowManager.ActiveWindow);
             }
             else
             {
                 GUIWaitCursor.Init(); GUIWaitCursor.Show();
             }
             new System.Threading.Thread(delegate()
             {
                 if (doUpdate == true)
                 {
                     if (dlgPrgrs != null)
                     {
                         dlgPrgrs.SetHeading(string.Format("{0} - {1}", PluginConfiguration.Instance.BasicHomeScreenName, Translation.Instance.AutomaticUpdate));
                     }
                     var onlineVersion = Sites.Updater.VersionOnline;
                     if (OnlineVideos.Sites.Updater.VersionCompatible)
                     {
                         bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites((m, p) =>
                         {
                             if (dlgPrgrs != null)
                             {
                                 if (!string.IsNullOrEmpty(m))
                                 {
                                     dlgPrgrs.SetLine(1, m);
                                 }
                                 if (p != null)
                                 {
                                     dlgPrgrs.SetPercentage(p.Value);
                                 }
                                 return(dlgPrgrs.ShouldRenderLayer());
                             }
                             else
                             {
                                 return(true);
                             }
                         }
                                                                                    );
                         if (updateResult == true && OnlineVideoSettings.Instance.SiteUtilsList.Count > 0)
                         {
                             GUISiteUpdater.ReloadDownloadedDlls();
                         }
                         else if (updateResult == null || OnlineVideoSettings.Instance.SiteUtilsList.Count > 0)
                         {
                             OnlineVideoSettings.Instance.BuildSiteUtilsList();
                         }
                         if (updateResult != false)
                         {
                             PluginConfiguration.Instance.BuildAutomaticSitesGroups();
                             SiteImageExistenceCache.ClearCache();
                         }
                     }
                     else
                     {
                         // inform the user that autoupdate is disabled due to outdated version!
                         dlgPrgrs.SetLine(1, Translation.Instance.AutomaticUpdateDisabled);
                         dlgPrgrs.SetLine(2, onlineVersion != null ? string.Format(Translation.Instance.LatestVersionRequired, onlineVersion) : "Check your Internet Connection!");
                         Thread.Sleep(5000);
                         dlgPrgrs.SetLine(2, string.Empty);
                     }
                 }
                 if (PluginConfiguration.Instance.ThumbsAge >= 0)
                 {
                     if (dlgPrgrs != null)
                     {
                         dlgPrgrs.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName);
                         dlgPrgrs.SetLine(1, Translation.Instance.DeletingOldThumbs);
                         dlgPrgrs.Percentage = 0;
                     }
                     ImageDownloader.DeleteOldThumbs(PluginConfiguration.Instance.ThumbsAge, r =>
                     {
                         if (dlgPrgrs != null)
                         {
                             dlgPrgrs.Percentage = r;
                         }
                         return(dlgPrgrs != null ? dlgPrgrs.ShouldRenderLayer() : true);
                     });
                 }
                 if (dlgPrgrs != null)
                 {
                     dlgPrgrs.Percentage = 100; dlgPrgrs.SetLine(1, Translation.Instance.Done); dlgPrgrs.Close();
                 }
                 else
                 {
                     GUIWaitCursor.Hide();
                 }
                 GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) =>
                 {
                     DoPageLoad();
                     return(0);
                 }, 0, 0, null);
             })
             {
                 Name = "OVLoad", IsBackground = true
             }.Start();
             return;
         }
     }
     DoPageLoad();
 }