From: <an...@us...> - 2007-11-03 12:48:09
|
Revision: 1019 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1019&view=rev Author: and-81 Date: 2007-11-03 05:48:07 -0700 (Sat, 03 Nov 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/MCEReplacement/Forms/LearnIR.cs trunk/plugins/MCEReplacement/Forms/MacroEditor.cs trunk/plugins/MCEReplacement/Forms/SetupForm.cs trunk/plugins/MCEReplacement/InputMapper/InputHandler.cs trunk/plugins/MCEReplacement/MCEReplacement.cs Modified: trunk/plugins/MCEReplacement/Forms/LearnIR.cs =================================================================== --- trunk/plugins/MCEReplacement/Forms/LearnIR.cs 2007-11-03 12:41:55 UTC (rev 1018) +++ trunk/plugins/MCEReplacement/Forms/LearnIR.cs 2007-11-03 12:48:07 UTC (rev 1019) @@ -90,7 +90,7 @@ string fileName = MCEReplacement.IRFolder + name + Common.FileExtensionIR; - IRServerPluginInterface.LearnStatus status = MCEReplacement.LearnIRCommand(fileName); + IRServerPluginInterface.LearnStatus status = MCEReplacement.LearnIR(fileName); switch (status) { Modified: trunk/plugins/MCEReplacement/Forms/MacroEditor.cs =================================================================== --- trunk/plugins/MCEReplacement/Forms/MacroEditor.cs 2007-11-03 12:41:55 UTC (rev 1018) +++ trunk/plugins/MCEReplacement/Forms/MacroEditor.cs 2007-11-03 12:48:07 UTC (rev 1019) @@ -32,7 +32,7 @@ { InitializeComponent(); - textBoxName.Text = "New"; + textBoxName.Text = "New"; textBoxName.Enabled = true; } @@ -65,7 +65,10 @@ comboBoxCommands.Items.Add(Common.UITextPause); comboBoxCommands.Items.Add(Common.UITextSerial); comboBoxCommands.Items.Add(Common.UITextWindowMsg); + comboBoxCommands.Items.Add(Common.UITextTcpMsg); comboBoxCommands.Items.Add(Common.UITextKeys); + comboBoxCommands.Items.Add(Common.UITextMouse); + comboBoxCommands.Items.Add(Common.UITextEject); comboBoxCommands.Items.Add(Common.UITextGoto); comboBoxCommands.Items.Add(Common.UITextPopup); comboBoxCommands.Items.Add(Common.UITextMultiMap); @@ -139,11 +142,26 @@ writer.WriteAttributeString("command", Common.XmlTagWindowMsg); writer.WriteAttributeString("cmdproperty", item.Substring(Common.CmdPrefixWindowMsg.Length)); } + else if (item.StartsWith(Common.CmdPrefixTcpMsg)) + { + writer.WriteAttributeString("command", Common.XmlTagTcpMsg); + writer.WriteAttributeString("cmdproperty", item.Substring(Common.CmdPrefixTcpMsg.Length)); + } else if (item.StartsWith(Common.CmdPrefixKeys)) { writer.WriteAttributeString("command", Common.XmlTagKeys); writer.WriteAttributeString("cmdproperty", item.Substring(Common.CmdPrefixKeys.Length)); } + else if (item.StartsWith(Common.CmdPrefixMouse)) + { + writer.WriteAttributeString("command", Common.XmlTagMouse); + writer.WriteAttributeString("cmdproperty", item.Substring(Common.CmdPrefixMouse.Length)); + } + else if (item.StartsWith(Common.CmdPrefixEject)) + { + writer.WriteAttributeString("command", Common.XmlTagEject); + writer.WriteAttributeString("cmdproperty", item.Substring(Common.CmdPrefixEject.Length)); + } else if (item.StartsWith(Common.CmdPrefixPopup)) { writer.WriteAttributeString("command", Common.XmlTagPopup); @@ -265,10 +283,22 @@ listBoxMacro.Items.Add(Common.CmdPrefixWindowMsg + commandProperty); break; + case Common.XmlTagTcpMsg: + listBoxMacro.Items.Add(Common.CmdPrefixTcpMsg + commandProperty); + break; + case Common.XmlTagKeys: listBoxMacro.Items.Add(Common.CmdPrefixKeys + commandProperty); break; + case Common.XmlTagMouse: + listBoxMacro.Items.Add(Common.CmdPrefixMouse + commandProperty); + break; + + case Common.XmlTagEject: + listBoxMacro.Items.Add(Common.CmdPrefixEject + commandProperty); + break; + case Common.XmlTagGoto: listBoxMacro.Items.Add(Common.CmdPrefixGoto + commandProperty); break; @@ -361,12 +391,32 @@ if (messageCommand.ShowDialog(this) == DialogResult.OK) listBoxMacro.Items.Add(Common.CmdPrefixWindowMsg + messageCommand.CommandString); } + else if (selected == Common.UITextTcpMsg) + { + TcpMessageCommand tcpMessageCommand = new TcpMessageCommand(); + if (tcpMessageCommand.ShowDialog(this) == DialogResult.Cancel) + return; + + listBoxMacro.Items.Add(Common.CmdPrefixTcpMsg + tcpMessageCommand.CommandString); + } else if (selected == Common.UITextKeys) { KeysCommand keysCommand = new KeysCommand(); if (keysCommand.ShowDialog(this) == DialogResult.OK) listBoxMacro.Items.Add(Common.CmdPrefixKeys + keysCommand.CommandString); } + else if (selected == Common.UITextMouse) + { + MouseCommand mouseCommand = new MouseCommand(); + if (mouseCommand.ShowDialog(this) == DialogResult.OK) + listBoxMacro.Items.Add(Common.CmdPrefixMouse + mouseCommand.CommandString); + } + else if (selected == Common.UITextEject) + { + EjectCommand ejectCommand = new EjectCommand(); + if (ejectCommand.ShowDialog(this) == DialogResult.OK) + listBoxMacro.Items.Add(Common.CmdPrefixEject + ejectCommand.CommandString); + } else if (selected == Common.UITextGoto) { GoToScreen goToScreen = new GoToScreen(); @@ -381,18 +431,10 @@ } else if (selected == Common.UITextMultiMap) { - //SelectBlasterSpeed selectBlasterSpeed = new SelectBlasterSpeed(_blastSpeed); - //if (selectBlasterSpeed.ShowDialog(this) == DialogResult.Cancel) - //return; - listBoxMacro.Items.Add(Common.CmdPrefixMultiMap + "TOGGLE"); } else if (selected == Common.UITextMouseMode) { - //SelectBlasterSpeed selectBlasterSpeed = new SelectBlasterSpeed(_blastSpeed); - //if (selectBlasterSpeed.ShowDialog(this) == DialogResult.Cancel) - //return; - listBoxMacro.Items.Add(Common.CmdPrefixMouseMode + "TOGGLE"); } else if (selected == Common.UITextInputLayer) @@ -524,6 +566,7 @@ if (name.Length == 0) { MessageBox.Show(this, "You must supply a name for this Macro", "Name missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + textBoxName.Focus(); return; } @@ -599,6 +642,18 @@ listBoxMacro.Items.Insert(index, Common.CmdPrefixWindowMsg + messageCommand.CommandString); listBoxMacro.SelectedIndex = index; } + else if (selected.StartsWith(Common.CmdPrefixTcpMsg)) + { + string[] commands = Common.SplitTcpMessageCommand(selected.Substring(Common.CmdPrefixTcpMsg.Length)); + TcpMessageCommand tcpMessageCommand = new TcpMessageCommand(commands); + if (tcpMessageCommand.ShowDialog(this) == DialogResult.Cancel) + return; + + int index = listBoxMacro.SelectedIndex; + listBoxMacro.Items.RemoveAt(index); + listBoxMacro.Items.Insert(index, Common.CmdPrefixTcpMsg + tcpMessageCommand.CommandString); + listBoxMacro.SelectedIndex = index; + } else if (selected.StartsWith(Common.CmdPrefixKeys)) { KeysCommand keysCommand = new KeysCommand(selected.Substring(Common.CmdPrefixKeys.Length)); @@ -610,6 +665,28 @@ listBoxMacro.Items.Insert(index, Common.CmdPrefixKeys + keysCommand.CommandString); listBoxMacro.SelectedIndex = index; } + else if (selected.StartsWith(Common.CmdPrefixMouse)) + { + MouseCommand mouseCommand = new MouseCommand(selected.Substring(Common.CmdPrefixMouse.Length)); + if (mouseCommand.ShowDialog(this) == DialogResult.Cancel) + return; + + int index = listBoxMacro.SelectedIndex; + listBoxMacro.Items.RemoveAt(index); + listBoxMacro.Items.Insert(index, Common.CmdPrefixMouse + mouseCommand.CommandString); + listBoxMacro.SelectedIndex = index; + } + else if (selected.StartsWith(Common.CmdPrefixEject)) + { + EjectCommand ejectCommand = new EjectCommand(selected.Substring(Common.CmdPrefixEject.Length)); + if (ejectCommand.ShowDialog(this) == DialogResult.Cancel) + return; + + int index = listBoxMacro.SelectedIndex; + listBoxMacro.Items.RemoveAt(index); + listBoxMacro.Items.Insert(index, Common.CmdPrefixEject + ejectCommand.CommandString); + listBoxMacro.SelectedIndex = index; + } else if (selected.StartsWith(Common.CmdPrefixGoto)) { GoToScreen goToScreen = new GoToScreen(selected.Substring(Common.CmdPrefixGoto.Length)); Modified: trunk/plugins/MCEReplacement/Forms/SetupForm.cs =================================================================== --- trunk/plugins/MCEReplacement/Forms/SetupForm.cs 2007-11-03 12:41:55 UTC (rev 1018) +++ trunk/plugins/MCEReplacement/Forms/SetupForm.cs 2007-11-03 12:48:07 UTC (rev 1019) @@ -194,8 +194,16 @@ comboBoxCommands.Items.Add(Common.UITextRun); comboBoxCommands.Items.Add(Common.UITextSerial); comboBoxCommands.Items.Add(Common.UITextWindowMsg); + comboBoxCommands.Items.Add(Common.UITextTcpMsg); comboBoxCommands.Items.Add(Common.UITextKeys); + comboBoxCommands.Items.Add(Common.UITextEject); comboBoxCommands.Items.Add(Common.UITextGoto); + //comboBoxCommands.Items.Add(Common.UITextWindowState); + comboBoxCommands.Items.Add(Common.UITextExit); + comboBoxCommands.Items.Add(Common.UITextStandby); + comboBoxCommands.Items.Add(Common.UITextHibernate); + comboBoxCommands.Items.Add(Common.UITextReboot); + comboBoxCommands.Items.Add(Common.UITextShutdown); string[] fileList = MCEReplacement.GetFileList(true); @@ -484,14 +492,6 @@ command = Common.CmdPrefixRun + externalProgram.CommandString; } - else if (selected == Common.UITextGoto) - { - GoToScreen goToScreen = new GoToScreen(); - if (goToScreen.ShowDialog(this) == DialogResult.Cancel) - return; - - command = Common.CmdPrefixGoto + goToScreen.Screen; - } else if (selected == Common.UITextSerial) { SerialCommand serialCommand = new SerialCommand(); @@ -508,6 +508,14 @@ command = Common.CmdPrefixWindowMsg + messageCommand.CommandString; } + else if (selected == Common.UITextTcpMsg) + { + TcpMessageCommand tcpMessageCommand = new TcpMessageCommand(); + if (tcpMessageCommand.ShowDialog(this) == DialogResult.Cancel) + return; + + command = Common.CmdPrefixTcpMsg + tcpMessageCommand.CommandString; + } else if (selected == Common.UITextKeys) { KeysCommand keysCommand = new KeysCommand(); @@ -516,6 +524,22 @@ command = Common.CmdPrefixKeys + keysCommand.CommandString; } + else if (selected == Common.UITextEject) + { + EjectCommand ejectCommand = new EjectCommand(); + if (ejectCommand.ShowDialog(this) == DialogResult.Cancel) + return; + + command = Common.CmdPrefixEject + ejectCommand.CommandString; + } + else if (selected == Common.UITextGoto) + { + GoToScreen goToScreen = new GoToScreen(); + if (goToScreen.ShowDialog(this) == DialogResult.Cancel) + return; + + command = Common.CmdPrefixGoto + goToScreen.Screen; + } else if (selected.StartsWith(Common.CmdPrefixBlast)) { BlastCommand blastCommand = new BlastCommand( @@ -529,7 +553,7 @@ command = Common.CmdPrefixBlast + blastCommand.CommandString; } - else if (selected.StartsWith(Common.CmdPrefixMacro)) + else { command = selected; } @@ -546,8 +570,8 @@ string mappingName = multiMapNameBox.MapName; - string pathCustom = MCEReplacement.CustomInputDevice + "MCE Replacement.xml"; - string pathDefault = MCEReplacement.CustomInputDefault + "MCE Replacement.xml"; + string pathCustom = MPUtils.MPCommon.CustomInputDevice + "MCE Replacement.xml"; + string pathDefault = MPUtils.MPCommon.CustomInputDefault + "MCE Replacement.xml"; string sourceFile; if (File.Exists(pathCustom)) @@ -560,7 +584,7 @@ return; } - string destinationFile = MCEReplacement.CustomInputDevice + mappingName + ".xml"; + string destinationFile = MPUtils.MPCommon.CustomInputDevice + mappingName + ".xml"; File.Copy(sourceFile, destinationFile, true); @@ -700,16 +724,18 @@ return; } - if (!Common.IsValidFileName(e.Label)) + string name = e.Label.Trim(); + + if (!Common.IsValidFileName(name)) { - MessageBox.Show("File name not valid: " + e.Label, "Cannot rename, New file name not valid", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("File name not valid: " + name, "Cannot rename, New file name not valid", MessageBoxButtons.OK, MessageBoxIcon.Error); e.CancelEdit = true; return; } try { - string newFileName = MCEReplacement.IRFolder + e.Label + Common.FileExtensionIR; + string newFileName = MCEReplacement.IRFolder + name + Common.FileExtensionIR; File.Move(oldFileName, newFileName); } @@ -744,16 +770,18 @@ return; } - if (!Common.IsValidFileName(e.Label)) + string name = e.Label.Trim(); + + if (!Common.IsValidFileName(name)) { - MessageBox.Show("File name not valid: " + e.Label, "Cannot rename, New file name not valid", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("File name not valid: " + name, "Cannot rename, New file name not valid", MessageBoxButtons.OK, MessageBoxIcon.Error); e.CancelEdit = true; return; } try { - string newFileName = MCEReplacement.MacroFolder + e.Label + Common.FileExtensionMacro; + string newFileName = MCEReplacement.MacroFolder + name + Common.FileExtensionMacro; File.Move(oldFileName, newFileName); } Modified: trunk/plugins/MCEReplacement/InputMapper/InputHandler.cs =================================================================== --- trunk/plugins/MCEReplacement/InputMapper/InputHandler.cs 2007-11-03 12:41:55 UTC (rev 1018) +++ trunk/plugins/MCEReplacement/InputMapper/InputHandler.cs 2007-11-03 12:48:07 UTC (rev 1019) @@ -134,8 +134,7 @@ /// <param name="deviceXmlName">Input device name.</param> public InputHandler(string deviceXmlName) { - - using (Profile.Settings xmlreader = new Profile.Settings(MCEReplacement.MPConfigFile)) + using (Profile.Settings xmlreader = new Profile.Settings(MPUtils.MPCommon.MPConfigFile)) _basicHome = xmlreader.GetValueAsBool("general", "startbasichome", false); string xmlPath = GetXmlPath(deviceXmlName); @@ -182,8 +181,8 @@ public string GetXmlPath(string deviceXmlName) { string path = String.Empty; - string pathCustom = MCEReplacement.CustomInputDevice + deviceXmlName + ".xml"; - string pathDefault = MCEReplacement.CustomInputDefault + deviceXmlName + ".xml"; + string pathCustom = MPUtils.MPCommon.CustomInputDevice + deviceXmlName + ".xml"; + string pathDefault = MPUtils.MPCommon.CustomInputDefault + deviceXmlName + ".xml"; if (System.IO.File.Exists(pathCustom) && CheckXmlFile(pathCustom)) { Modified: trunk/plugins/MCEReplacement/MCEReplacement.cs =================================================================== --- trunk/plugins/MCEReplacement/MCEReplacement.cs 2007-11-03 12:41:55 UTC (rev 1018) +++ trunk/plugins/MCEReplacement/MCEReplacement.cs 2007-11-03 12:48:07 UTC (rev 1019) @@ -41,22 +41,13 @@ /// <summary> /// The plugin version string. /// </summary> - internal const string PluginVersion = "MCE Replacement Plugin 1.0.3.5 for MediaPortal 0.2.3.0"; + internal const string PluginVersion = "MCE Replacement Plugin 1.0.3.5 for MediaPortal 0.2.3.0"; /// <summary> /// The wParam for Message Mode Windows Messages. /// </summary> - public const int MessageModeCommand = 0x0018; + public const int MessageModeCommand = 0x0018; - // Macro Commands - //internal const string WindowStateCommand = "Toggle Window State"; - - // Macro File Commands - //internal const string WindowStateMacroText = "WINDOW_STATE"; - - // English text for Macro commands - //internal const string ChangeWindowStateText = "Change Window State"; - internal static readonly string AppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MediaPortal MCE Replacement Plugin\\"; @@ -65,11 +56,6 @@ internal static readonly string MacroFolder = AppDataFolder + "Macro\\"; internal static readonly string STBFolder = AppDataFolder + "STB\\"; - internal static readonly string CustomInputDevice = Config.GetFolder(Config.Dir.CustomInputDevice) + "\\"; - internal static readonly string CustomInputDefault = Config.GetFolder(Config.Dir.CustomInputDefault) + "\\"; - - internal static readonly string MPConfigFile = Config.GetFolder(Config.Dir.Config) + "\\MediaPortal.xml"; - internal static readonly string MCERemoteFile = AppDataFolder + "MCERemote.xml"; internal static readonly string DifferentRemoteFile = AppDataFolder + "DifferentRemote.xml"; internal static readonly string MultiMappingFile = AppDataFolder + "MultiMapping.xml"; @@ -147,18 +133,7 @@ get { return _logVerbose; } set { _logVerbose = value; } } - /// <summary> - /// Gets or sets a value indicating whether in configuration. - /// </summary> - /// <value><c>true</c> if in configuration; otherwise, <c>false</c>.</value> - internal static bool InConfiguration - { - get { return _inConfiguration; } - set { _inConfiguration = value; } - } - - /// <summary> /// Gets or sets a value indicating whether MediaPortal will require focus to handle input. /// </summary> /// <value><c>true</c> if requires focus; otherwise, <c>false</c>.</value> @@ -198,7 +173,7 @@ /// Gets or sets a value indicating whether different remote handling is enabled. /// </summary> /// <value> - /// <c>true</c> if different remote handling is enabled; otherwise, <c>false</c>. + /// <c>true</c> if different remote handling is enabled; otherwise, <c>false</c>. /// </value> internal static bool DifferentRemoteEnabled { @@ -300,6 +275,16 @@ } /// <summary> + /// Gets or sets a value indicating whether in configuration. + /// </summary> + /// <value><c>true</c> if in configuration; otherwise, <c>false</c>.</value> + internal static bool InConfiguration + { + get { return _inConfiguration; } + set { _inConfiguration = value; } + } + + /// <summary> /// Count of available TV Cards. /// </summary> internal static int TvCardCount @@ -429,7 +414,7 @@ GUIWindowManager.Receivers -= new SendMessageHandler(OnMessage); _defaultInputHandler = null; - + if (MultiMappingEnabled) for (int i = 0; i < _multiInputHandlers.Count; i++) _multiInputHandlers[i] = null; @@ -451,41 +436,41 @@ /// Determines whether this plugin can be enabled. /// </summary> /// <returns> - /// <c>true</c> if this plugin can be enabled; otherwise, <c>false</c>. + /// <c>true</c> if this plugin can be enabled; otherwise, <c>false</c>. /// </returns> - public bool CanEnable() { return true; } + public bool CanEnable() { return true; } /// <summary> /// Determines whether this plugin has setup. /// </summary> /// <returns> - /// <c>true</c> if this plugin has setup; otherwise, <c>false</c>. + /// <c>true</c> if this plugin has setup; otherwise, <c>false</c>. /// </returns> - public bool HasSetup() { return true; } + public bool HasSetup() { return true; } /// <summary> /// Gets the plugin name. /// </summary> /// <returns>The plugin name.</returns> - public string PluginName() { return "MCE Replacement"; } + public string PluginName() { return "MCE Replacement"; } /// <summary> /// Defaults enabled. /// </summary> /// <returns>true if this plugin is enabled by default, otherwise false.</returns> - public bool DefaultEnabled() { return true; } + public bool DefaultEnabled() { return true; } /// <summary> /// Gets the window id. /// </summary> /// <returns>The window id.</returns> - public int GetWindowId() { return 0; } + public int GetWindowId() { return 0; } /// <summary> /// Gets the plugin author. /// </summary> /// <returns>The plugin author.</returns> - public string Author() { return "and-81"; } + public string Author() { return "and-81"; } /// <summary> /// Gets the description of the plugin. /// </summary> /// <returns>The plugin description.</returns> - public string Description() { return "Replaces MediaPortal's native MCE remote control support"; } + public string Description() { return "Replaces MediaPortal's native MCE remote control support"; } /// <summary> /// Shows the plugin configuration. @@ -559,7 +544,7 @@ /// <param name="strButtonImageFocus">The button image focus.</param> /// <param name="strPictureImage">The picture image.</param> /// <returns>true if the plugin can be seen, otherwise false.</returns> - public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage) + public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage) { strButtonText = strButtonImage = strButtonImageFocus = strPictureImage = String.Empty; return false; @@ -657,7 +642,7 @@ _mouseModeMiddleHeld = false; } - MPCommands.ShowNotifyDialog("Mouse Mode", notifyMessage, 2); + MPCommon.ShowNotifyDialog("Mouse Mode", notifyMessage, 2); if (LogVerbose) Log.Info("MCEReplacement: {0}", notifyMessage); @@ -999,14 +984,14 @@ { // Cycle through Multi-Mappings ... _multiMappingSet = (_multiMappingSet + 1) % MultiMaps.Length; - + // Show the mapping set name on screen ... string setName = MultiMaps[_multiMappingSet]; if (LogVerbose) Log.Info("MCEReplacement: Multi-Mapping has changed to \"{0}\"", setName); - MPCommands.ShowNotifyDialog("Multi-Mapping", setName, 2); + MPCommon.ShowNotifyDialog("Multi-Mapping", setName, 2); } /// <summary> /// Changes the multi mapping. @@ -1034,7 +1019,7 @@ if (LogVerbose) Log.Info("MCEReplacement: Multi-Mapping has changed to \"{0}\"", setName); - MPCommands.ShowNotifyDialog("Multi-Mapping", setName, 2); + MPCommon.ShowNotifyDialog("Multi-Mapping", setName, 2); return; } @@ -1431,6 +1416,62 @@ MapEvent(MappedEvent.MappingEvent.PC_Resume); } + static void Hibernate() + { + if (InConfiguration) + return; + + GUIGraphicsContext.ResetLastActivity(); + // Stop all media before hibernating + g_Player.Stop(); + + GUIMessage msg; + + if (_mpBasicHome) + 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); + + OnSuspend(); + WindowsController.ExitWindows(RestartOptions.Hibernate, false); + } + + static void Standby() + { + if (InConfiguration) + return; + + GUIGraphicsContext.ResetLastActivity(); + // Stop all media before suspending + g_Player.Stop(); + + GUIMessage msg; + + if (_mpBasicHome) + 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); + + OnSuspend(); + WindowsController.ExitWindows(RestartOptions.Suspend, false); + } + + static void Reboot() + { + if (!InConfiguration) + GUIGraphicsContext.OnAction(new Action(Action.ActionType.ACTION_SHUTDOWN, 0, 0)); + } + + static void ShutDown() + { + if (!InConfiguration) + GUIGraphicsContext.OnAction(new Action(Action.ActionType.ACTION_REBOOT, 0, 0)); + } + /// <summary> /// Adds to the Macro Stack. /// </summary> @@ -1511,7 +1552,6 @@ case Common.XmlTagBlast: { string[] commands = Common.SplitBlastCommand(commandProperty); - BlastIR(IRFolder + commands[0] + Common.FileExtensionIR, commands[1]); break; } @@ -1542,7 +1582,7 @@ if (InConfiguration) MessageBox.Show(commandProperty, "Go To Window", MessageBoxButtons.OK, MessageBoxIcon.Information); else - MPCommands.ProcessGoTo(commandProperty, MP_BasicHome); + MPCommon.ProcessGoTo(commandProperty, MP_BasicHome); break; } @@ -1553,7 +1593,7 @@ if (InConfiguration) MessageBox.Show(commands[1], commands[0], MessageBoxButtons.OK, MessageBoxIcon.Information); else - MPCommands.ShowNotifyDialog(commands[0], commands[1], int.Parse(commands[2])); + MPCommon.ShowNotifyDialog(commands[0], commands[1], int.Parse(commands[2])); break; } @@ -1565,6 +1605,13 @@ break; } + case Common.XmlTagTcpMsg: + { + string[] commands = Common.SplitTcpMessageCommand(commandProperty); + Common.ProcessTcpMessageCommand(commands); + break; + } + case Common.XmlTagKeys: { if (InConfiguration) @@ -1634,7 +1681,7 @@ _mouseModeMiddleHeld = false; } - MPCommands.ShowNotifyDialog("Mouse Mode", notifyMessage, 2); + MPCommon.ShowNotifyDialog("Mouse Mode", notifyMessage, 2); if (LogVerbose) Log.Info("MCEReplacement: {0}", notifyMessage); @@ -1703,63 +1750,33 @@ break; } + case Common.XmlTagEject: + { + Common.ProcessEjectCommand(commandProperty); + break; + } + case Common.XmlTagStandby: { - if (!InConfiguration) - { - GUIGraphicsContext.ResetLastActivity(); - // Stop all media before suspending or hibernating - g_Player.Stop(); - - GUIMessage msg; - - if (_mpBasicHome) - 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); - - MCEReplacement.OnSuspend(); - WindowsController.ExitWindows(RestartOptions.Suspend, true); - } + Standby(); break; } case Common.XmlTagHibernate: { - if (!InConfiguration) - { - GUIGraphicsContext.ResetLastActivity(); - // Stop all media before suspending or hibernating - g_Player.Stop(); - - GUIMessage msg; - - if (_mpBasicHome) - 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); - - MCEReplacement.OnSuspend(); - WindowsController.ExitWindows(RestartOptions.Hibernate, true); - } + Hibernate(); break; } - case Common.XmlTagReboot: + case Common.XmlTagShutdown: { - if (!InConfiguration) - GUIGraphicsContext.OnAction(new Action(Action.ActionType.ACTION_REBOOT, 0, 0)); + ShutDown(); break; } - case Common.XmlTagShutdown: + case Common.XmlTagReboot: { - if (!InConfiguration) - GUIGraphicsContext.OnAction(new Action(Action.ActionType.ACTION_SHUTDOWN, 0, 0)); + Reboot(); break; } } @@ -1772,6 +1789,37 @@ } /// <summary> + /// Learn an IR command. + /// </summary> + /// <param name="fileName">File to place learned IR command in (absolute path).</param> + /// <returns>true if successful, otherwise false.</returns> + internal static IRServerPluginInterface.LearnStatus LearnIR(string fileName) + { + IRServerPluginInterface.LearnStatus status = IRServerPluginInterface.LearnStatus.Failure; + + try + { + byte[] data; + status = _mceTransceiver.Learn(out data); + + if (status == IRServerPluginInterface.LearnStatus.Success) + { + if (data == null || data.Length == 0) + throw new ApplicationException("No data learned"); + + using (FileStream file = File.Create(fileName)) + file.Write(data, 0, data.Length); + } + } + catch (Exception ex) + { + Log.Error("MCEReplacement: LearnIRCommand() {0}", ex.ToString()); + } + + return status; + } + + /// <summary> /// Blast an IR command. /// </summary> /// <param name="fileName">File to blast (absolute path).</param> @@ -1827,7 +1875,7 @@ string[] commands = Common.SplitBlastCommand(command.Substring(Common.CmdPrefixBlast.Length)); BlastIR(IRFolder + commands[0] + Common.FileExtensionIR, commands[1]); } - else if (command.StartsWith(Common.CmdPrefixSTB)) // STB IR Code + else if (command.StartsWith(Common.CmdPrefixSTB, StringComparison.InvariantCultureIgnoreCase)) // STB IR Code { string[] commands = Common.SplitBlastCommand(command.Substring(Common.CmdPrefixSTB.Length)); BlastIR(STBFolder + commands[0] + Common.FileExtensionIR, commands[1]); @@ -1855,45 +1903,40 @@ else Common.ProcessKeyCommand(keyCommand); } - else if (command.StartsWith(Common.CmdPrefixGoto, StringComparison.InvariantCultureIgnoreCase)) // Go To Screen + else if (command.StartsWith(Common.CmdPrefixMouse, StringComparison.InvariantCultureIgnoreCase)) // Mouse Command { - MPCommands.ProcessGoTo(command.Substring(Common.CmdPrefixGoto.Length), MP_BasicHome); + string mouseCommand = command.Substring(Common.CmdPrefixMouse.Length); + Common.ProcessMouseCommand(mouseCommand); } - else + else if (command.StartsWith(Common.CmdPrefixEject, StringComparison.InvariantCultureIgnoreCase)) // Eject Command { - throw new ArgumentException(String.Format("Cannot process unrecognized command \"{0}\"", command), "command"); + string ejectCommand = command.Substring(Common.CmdPrefixEject.Length); + Common.ProcessEjectCommand(ejectCommand); } - } - - /// <summary> - /// Learn an IR Command and put it in a file. - /// </summary> - /// <param name="fileName">File to place learned IR command in (absolute path).</param> - /// <returns>true if successful, otherwise false.</returns> - internal static IRServerPluginInterface.LearnStatus LearnIRCommand(string fileName) - { - IRServerPluginInterface.LearnStatus status = IRServerPluginInterface.LearnStatus.Failure; - - try + else if (command.StartsWith(Common.CmdPrefixHibernate, StringComparison.InvariantCultureIgnoreCase)) // Hibernate Command { - byte[] data; - status = _mceTransceiver.Learn(out data); - - if (status == IRServerPluginInterface.LearnStatus.Success) - { - if (data == null || data.Length == 0) - throw new ApplicationException("No data learned"); - - using (FileStream file = File.Create(fileName)) - file.Write(data, 0, data.Length); - } + Hibernate(); } - catch (Exception ex) + else if (command.StartsWith(Common.CmdPrefixReboot, StringComparison.InvariantCultureIgnoreCase)) // Reboot Command { - Log.Error("MCEReplacement: LearnIRCommand() {0}", ex.ToString()); + Reboot(); } - - return status; + else if (command.StartsWith(Common.CmdPrefixShutdown, StringComparison.InvariantCultureIgnoreCase)) // Shutdown Command + { + ShutDown(); + } + else if (command.StartsWith(Common.CmdPrefixStandby, StringComparison.InvariantCultureIgnoreCase)) // Standby Command + { + Standby(); + } + else if (command.StartsWith(Common.CmdPrefixGoto, StringComparison.InvariantCultureIgnoreCase)) // Go To Screen + { + MPCommon.ProcessGoTo(command.Substring(Common.CmdPrefixGoto.Length), MP_BasicHome); + } + else + { + throw new ArgumentException(String.Format("Cannot process unrecognized command \"{0}\"", command), "command"); + } } /// <summary> @@ -1976,7 +2019,7 @@ { try { - using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(MPConfigFile)) + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(MPCommon.MPConfigFile)) { LogVerbose = xmlreader.GetValueAsBool("MCEReplacement", "LogVerbose", false); RequireFocus = xmlreader.GetValueAsBool("MCEReplacement", "RequireFocus", false); @@ -2009,7 +2052,7 @@ { try { - using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(MPConfigFile)) + using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(MPCommon.MPConfigFile)) { xmlwriter.SetValueAsBool("MCEReplacement", "LogVerbose", LogVerbose); xmlwriter.SetValueAsBool("MCEReplacement", "RequireFocus", RequireFocus); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |