private void KeepAliveThreadMain() { do { GUIWindowManager.SendThreadCallbackAndWait(DoKeepAlive, 0, 0, null); }while (!_keepAliveThreadStopEvent.WaitOne(_keepAliveIntervalSeconds * 1000, false)); }
private static void ThreadActivateTheme(object param) { if (!(param is ThreadParams)) { Log.Error("param at ThreadActivateTheme has wrong type"); return; } ThreadParams threadParams = (ThreadParams)param; GUIWaitCursor.Show(); // Need to initialize fonts and references if they change based on the theme. // Check current theme. bool initFonts = (GUIGraphicsContext.HasThemeSpecificSkinFile(@"\fonts.xml")); bool initReferences = (GUIGraphicsContext.HasThemeSpecificSkinFile(@"\references.xml")); // Change the theme and save this new setting. SetTheme(threadParams._themeName); SkinSettings.Save(); // Check new theme. initFonts = initFonts || GUIGraphicsContext.HasThemeSpecificSkinFile(@"\fonts.xml"); initReferences = initReferences || GUIGraphicsContext.HasThemeSpecificSkinFile(@"\references.xml"); // Reset fonts if needed. if (initFonts) { // Reinitializing the device while changing fonts freezes the UI. // Add some sleep() to present the wait cursor animation for at least some user feedback. Thread.Sleep(500); GUIFontManager.ClearFontCache(); GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml")); GUIFontManager.InitializeDeviceObjects(); Thread.Sleep(500); } // Force a reload of the control references if needed. if (initReferences) { GUIControlFactory.ClearReferences(); } // Reactivate the current window and refocus on the control used to change the theme. // This applies the new theme to the current window immediately. GUIWindowManager.ResetAllControls(); GUIWindowManager.SendThreadCallbackAndWait((p1, p2, p3) => { GUIWindowManager.ActivateWindow(p1, true, true, (int)p3); return(0); }, GUIWindowManager.ActiveWindow, 0, threadParams._focusControlId); GUIWaitCursor.Hide(); }
void invoke(System.Action action, bool wait = true) { if (wait) { GUIWindowManager.SendThreadCallbackAndWait((p1, p2, o) => { action(); return(0); }, 0, 0, null); } else { GUIWindowManager.SendThreadCallback((p1, p2, o) => { action(); return(0); }, 0, 0, null); } }
void vlcCtrl_EncounteredError(VlcControl sender, VlcEventArgs <EventArgs> e) { string error = VlcContext.ErrorHandling.GetErrorMessage(); GUIWindowManager.SendThreadCallbackAndWait((p1, p2, o) => { Log.Instance.Warn("VLCPlayer Error: '{0}'", error); if (!bufferingDone && Initializing) { GUIWaitCursor.Hide(); // hide the wait cursor if still showing } MediaPortal.Dialogs.GUIDialogOK dlg_error = (MediaPortal.Dialogs.GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg_error != null) { dlg_error.Reset(); dlg_error.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg_error.SetLine(1, Translation.Instance.Error); dlg_error.SetLine(2, error); dlg_error.DoModal(GUIWindowManager.ActiveWindow); } PlaybackEnded(); return(0); }, 0, 0, null); }
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); }
private void Listener_XplMessageReceived(object sender, XplListener.XplEventArgs e) { if (e.XplMsg.Schema.msgClass.ToLower().Equals("hbeat") && e.XplMsg.Schema.msgType.ToLower().Equals("app")) { if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received HEARTBEAT"); } this._IsConnected = true; } else if (e.XplMsg.Schema.msgClass.ToLower().Equals("config")) { if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received CONFIG message"); } } else if ((e.XplMsg.Source.Vendor.ToLower().Equals(this.mVendorID.ToLower()) && e.XplMsg.Source.Device.ToLower().Equals(this.mDeviceID.ToLower())) && e.XplMsg.Source.Instance.ToLower().Equals(this.mInstanceID.ToLower())) { if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received ECHO"); } } else { if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: {0} - {1} - {2}", new object[] { e.XplMsg.Source.Vendor, e.XplMsg.Source.Device, e.XplMsg.Content }); } string str = e.XplMsg.Schema.msgClass.ToLower() + "." + e.XplMsg.Schema.msgType.ToLower(); string str11 = str; if (str11 != null) { if (!(str11 == "media.basic")) { if (!(str11 == "media.request")) { if (str11 == "remote.basic") { foreach (string str9 in e.XplMsg.GetParam(1, "keys").Split(new char[] { ',' })) { if (this.DoDebug) { Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic \"{0}\"", new object[] { str9 }); } if (Enum.IsDefined(typeof(GUIWindow.Window), str9.ToUpper())) { if (this.DoDebug) { Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic window name", new object[0]); } this.XPL_Send_Remote_Confirm_Message(e); int num8 = (int)Enum.Parse(typeof(GUIWindow.Window), str9.ToUpper()); if (!GUIWindowManager.ActiveWindow.Equals(num8)) { GUIWindowManager.SendThreadCallbackAndWait( new GUIWindowManager.Callback(this.ThreadMessageCallback), 1, num8, null); return; } break; } if (Enum.IsDefined(typeof(Keys), str9)) { if (this.DoDebug) { Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic key name", new object[0]); } this.XPL_Send_Remote_Confirm_Message(e); Key key = new Key(0, (int)Enum.Parse(typeof(Keys), str9)); Action action3 = new Action(); if (ActionTranslator.GetAction(GUIWindowManager.ActiveWindow, key, ref action3)) { GUIWindowManager.OnAction(action3); return; } } foreach (string str10 in Enum.GetNames(typeof(RemoteButton))) { if (str10.ToLower().Equals(str9.ToLower()) || str9.ToLower().Equals("remote_" + str10.ToLower())) { if (this.DoDebug) { Log.Info( "xPL_Connector.Listener_XplMessageReceived(): Received remote.basic remote key name \"{0}\"", new object[] { str9 }); } this.XPL_Send_Remote_Confirm_Message(e); if (!this.rHandler.MapAction((int)Enum.Parse(typeof(RemoteButton), str10)) && this.DoDebug) { Log.Info( "xPL_Connector.Listener_XplMessageReceived(): COULD NOT FIRE REMOTE ACTION (isLoaded = {0})", new object[] { this.rHandler.IsLoaded }); } break; } } int result = 0; int.TryParse(str9, out result); if (result != 0) { if (this.DoDebug) { Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic raw keycode", new object[0]); } this.XPL_Send_Remote_Confirm_Message(e); Key key2 = new Key(0, result); Action action4 = new Action(); if (ActionTranslator.GetAction(GUIWindowManager.ActiveWindow, key2, ref action4)) { GUIWindowManager.OnAction(action4); return; } break; } } } } else { switch (e.XplMsg.GetParam(1, "request")) { case "devinfo": this.XPL_SendDevInfo("xpl-stat"); return; case "devstate": if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player")) { this.XPL_SendPlayerDevstate("xpl-stat"); } return; case "mpinfo": if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player")) { this.XPL_SendPlayerMediaPlayerInfo("xpl-stat"); this.XPL_SendPlayerMediaPlayerInputInfo("xpl-stat"); } return; case "mptrnspt": if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player")) { this.XPL_SendPlayerTransportState("xpl-stat"); } return; case "mpmedia": if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player")) { this.XPL_SendMediaInfo("xpl-stat"); } return; case "mpconfig": if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player")) { this.XPL_SendPlayerMediaPlayerConfig("xpl-stat"); } return; case "mpqueue": return; } } } else { int num; switch (e.XplMsg.GetParam(1, "command").ToLower()) { case "record": case "position": case "chapter": case "power": case "reboot": case "input": case "options": return; case "play": { string path = e.XplMsg.GetParam(1, "url").ToLower(); if (!(path.Equals(string.Empty) & g_Player.Paused)) { if (path.Equals(g_Player.currentFileName) & g_Player.Paused) { g_Player.Pause(); if (this.DoDebug) { Log.Info( "xPLConnector_Listener_XplMessageReceived: Received media.basic play file command (unpause)", new object[0]); return; } return; } if (File.Exists(path) && !g_Player.currentFileName.Equals(path)) { GUIMessage message = new GUIMessage(); message.Message = GUIMessage.MessageType.GUI_MSG_PLAY_FILE; message.Label = path; GUIWindowManager.SendThreadMessage(message); if (!this.DoDebug) { return; } Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic play file command", new object[0]); } return; } g_Player.Pause(); if (this.DoDebug) { Log.Info( "xPLConnector_Listener_XplMessageReceived: Received media.basic play file command (unpause)", new object[0]); } return; } case "stop": { GUIMessage message2 = new GUIMessage(); message2.Message = GUIMessage.MessageType.GUI_MSG_STOP_FILE; GUIWindowManager.SendThreadMessage(message2); if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic stop command", new object[0]); } return; } case "pause": if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic pause command", new object[0]); } if (!g_Player.Paused) { g_Player.Pause(); } return; case "forward": { string str4 = e.XplMsg.GetParam(1, "speed").ToLower(); num = 0; if (!str4.Equals(string.Empty)) { num = int.Parse(str4.Replace("x", "")); break; } num = g_Player.Speed * 2; break; } case "rewind": { string str5 = e.XplMsg.GetParam(1, "speed").ToLower(); int num2 = 0; if (!str5.Equals(string.Empty)) { num2 = int.Parse(str5.Replace("x", "")); } else { num2 = Math.Abs(g_Player.Speed) * 2; } if (num2 > 0x20) { num2 = 0x20; } if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic rewind ({0}x) command", new object[] { num2 }); } g_Player.Speed = -num2; return; } case "next": Action action; if (!g_Player.IsDVD) { action = new Action(Action.ActionType.ACTION_NEXT_ITEM, 0f, 0f); } else { action = new Action(Action.ActionType.ACTION_NEXT_CHAPTER, 0f, 0f); } GUIGraphicsContext.OnAction(action); if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic next command", new object[0]); } return; case "back": Action action2; if (!g_Player.IsDVD) { action2 = new Action(Action.ActionType.ACTION_PREV_ITEM, 0f, 0f); } else { action2 = new Action(Action.ActionType.ACTION_PREV_CHAPTER, 0f, 0f); } GUIGraphicsContext.OnAction(action2); if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic back command", new object[0]); } return; case "mute": if (!(e.XplMsg.GetParam(1, "state").ToLower() == "on")) { if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic mute off command", new object[0]); } VolumeHandler.Instance.IsMuted = false; return; } if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic mute on command", new object[0]); } VolumeHandler.Instance.IsMuted = true; return; case "volume": { string str13; string s = e.XplMsg.GetParam(1, "level").ToLower(); if (((str13 = s.Substring(0, 1)) == null) || (!(str13 == "+") && !(str13 == "-"))) { int num7 = int.Parse(s); VolumeHandler.Instance.Volume = (VolumeHandler.Instance.Maximum / 100) * num7; if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic volume command", new object[0]); } return; } int volume = VolumeHandler.Instance.Volume; int num5 = int.Parse(s) * 0x28f; int num6 = volume + num5; if (num6 < 0) { num6 = 0; } if (num6 > 0xffdc) { num6 = 0xffdc; } VolumeHandler.Instance.Volume = num6; if (this.DoDebug) { Log.Info( "xPLConnector_Listener_XplMessageReceived: Received media.basic volume {0} command = orig = {1}, new = {2}, delta = {3}", new object[] { s, volume, num6, num5 }); } return; } default: return; } if (num > 0x20) { num = 0x20; } if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic play forward ({0}x) command", new object[] { num }); } g_Player.Speed = num; } } } }
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(); }
/// <summary> /// Evaluates the button number, gets its mapping and executes the action /// </summary> /// <param name="btnCode">Button code (ref: XML file)</param> /// <param name="processID">Process-ID for close/kill commands</param> private bool DoMapAction(string btnCode, int processID) { if (!_isLoaded) // No mapping loaded { Log.Info("Map: No button mapping loaded"); return(false); } Mapping map = null; map = GetMapping(btnCode); if (map == null) { return(false); } Log.Debug("{0} / {1} / {2} / {3}", map.Condition, map.ConProperty, map.Command, map.CmdProperty); Action action; if (map.Sound != string.Empty) // && !g_Player.Playing) { Util.Utils.PlaySound(map.Sound, false, true); } if (map.Focus && !GUIGraphicsContext.HasFocus) { GUIGraphicsContext.ResetLastActivity(); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GETFOCUS, 0, 0, 0, 0, 0, null); GUIWindowManager.SendThreadMessage(msg); return(true); } switch (map.Command) { case "ACTION": // execute Action x Key key = new Key(map.CmdKeyChar, map.CmdKeyCode); Log.Debug("Executing: key {0} / {1} / Action: {2} / {3}", map.CmdKeyChar, map.CmdKeyCode, map.CmdProperty, ((Action.ActionType)Convert.ToInt32(map.CmdProperty)).ToString()); action = new Action(key, (Action.ActionType)Convert.ToInt32(map.CmdProperty), 0, 0); GUIGraphicsContext.OnAction(action); break; case "KEY": // send Key x SendKeys.SendWait(map.CmdProperty); break; case "WINDOW": // activate Window x GUIGraphicsContext.ResetLastActivity(); GUIMessage msg; if ((Convert.ToInt32(map.CmdProperty) == (int)GUIWindow.Window.WINDOW_HOME) || (Convert.ToInt32(map.CmdProperty) == (int)GUIWindow.Window.WINDOW_SECOND_HOME)) { if (_basicHome) { msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)GUIWindow.Window.WINDOW_SECOND_HOME, 0, null); } else { msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)GUIWindow.Window.WINDOW_HOME, 0, null); } } else { msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, Convert.ToInt32(map.CmdProperty), 0, null); } GUIWindowManager.SendThreadMessage(msg); break; case "TOGGLE": // toggle Layer 1/2 if (_currentLayer == 1) { _currentLayer = 2; } else { _currentLayer = 1; } break; case "POWER": // power down commands if ((map.CmdProperty == "STANDBY") || (map.CmdProperty == "HIBERNATE")) { GUIGraphicsContext.ResetLastActivity(); //Stop all media before suspending or hibernating if (g_Player.Playing) { GUIWindowManager.SendThreadCallbackAndWait(StopPlayback, 0, 0, null); } // this is all handled in mediaportal.cs - OnSuspend /* * if (_basicHome) * msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)GUIWindow.Window.WINDOW_SECOND_HOME, 0, null); * else * msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)GUIWindow.Window.WINDOW_HOME, 0, null); * * GUIWindowManager.SendThreadMessage(msg); */ } switch (map.CmdProperty) { case "EXIT": action = new Action(Action.ActionType.ACTION_EXIT, 0, 0); GUIGraphicsContext.OnAction(action); break; case "REBOOT": action = new Action(Action.ActionType.ACTION_REBOOT, 0, 0); GUIGraphicsContext.OnAction(action); break; case "SHUTDOWN": action = new Action(Action.ActionType.ACTION_SHUTDOWN, 0, 0); GUIGraphicsContext.OnAction(action); break; case "STANDBY": // we need a slow standby (force=false), in order to have the onsuspend method being called on mediportal.cs // this is needed in order to have "ShowLastActiveModule" working correctly. // also using force=true results in a silent non critical D3DERR_DEVICELOST exception when resuming from powerstate. MPControlPlugin.OnSuspend(); WindowsController.ExitWindows(RestartOptions.Suspend, false); break; case "HIBERNATE": // we need a slow hibernation (force=false), in order to have the onsuspend method being called on mediportal.cs // this is needed in order to have "ShowLastActiveModule" working correctly. // also using force=true results in a silent non critical D3DERR_DEVICELOST exception when resuming from powerstate. MPControlPlugin.OnSuspend(); WindowsController.ExitWindows(RestartOptions.Hibernate, false); break; } break; case "PROCESS": { GUIGraphicsContext.ResetLastActivity(); if (processID > 0) { Process proc = Process.GetProcessById(processID); if (null != proc) { switch (map.CmdProperty) { case "CLOSE": proc.CloseMainWindow(); break; case "KILL": proc.Kill(); break; } } } } break; case "BLAST": MPControlPlugin.ProcessCommand(map.CmdProperty, true); break; default: return(false); } return(true); }