From: <an...@us...> - 2008-01-04 23:08:48
|
Revision: 1205 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1205&view=rev Author: and-81 Date: 2008-01-04 15:08:43 -0800 (Fri, 04 Jan 2008) Log Message: ----------- Modified Paths: -------------- trunk/plugins/MCEReplacement/Forms/ExternalChannels.cs trunk/plugins/MCEReplacement/Forms/MacroEditor.cs trunk/plugins/MCEReplacement/Forms/SetupForm.cs trunk/plugins/MCEReplacement/Forms/StbSetup.cs trunk/plugins/MCEReplacement/MCEReplacement.cs trunk/plugins/MCEReplacement/Properties/AssemblyInfo.cs Modified: trunk/plugins/MCEReplacement/Forms/ExternalChannels.cs =================================================================== --- trunk/plugins/MCEReplacement/Forms/ExternalChannels.cs 2008-01-04 22:57:22 UTC (rev 1204) +++ trunk/plugins/MCEReplacement/Forms/ExternalChannels.cs 2008-01-04 23:08:43 UTC (rev 1205) @@ -15,7 +15,6 @@ using IrssUtils; using MPUtils; -using MPUtils.Forms; namespace MediaPortal.Plugins { @@ -41,32 +40,34 @@ private void ExternalChannels_Load(object sender, EventArgs e) { - int cards = MCEReplacement.TvCardCount; + ArrayList cards = new ArrayList(); + MediaPortal.TV.Database.TVDatabase.GetCards(ref cards); - string cardName; - string cardNumber; + if (cards.Count == 0) + throw new ApplicationException("Cannot load external channel configurations, there are no TV cards registered"); - _tvCardTabs = new TabPage[cards]; - _tvCardStbSetups = new StbSetup[cards]; + _tvCardTabs = new TabPage[cards.Count]; + _tvCardStbSetups = new StbSetup[cards.Count]; comboBoxCopyFrom.Items.Clear(); - for (int index = 0; index < cards; index++) + int index = 0; + foreach (int cardId in cards) { - cardNumber = (index + 1).ToString(); - cardName = "TV Card " + cardNumber; + string cardName = String.Format("TV Card {0}", cardId); comboBoxCopyFrom.Items.Add(cardName); - _tvCardStbSetups[index] = new StbSetup(index); - _tvCardStbSetups[index].Name = "StbSetup" + cardNumber; + _tvCardStbSetups[index] = new StbSetup(cardId); + _tvCardStbSetups[index].Name = "StbSetup" + index; _tvCardStbSetups[index].Dock = DockStyle.Fill; - _tvCardStbSetups[index].TabIndex = 0; _tvCardTabs[index] = new TabPage(cardName); _tvCardTabs[index].Controls.Add(_tvCardStbSetups[index]); this.tabControlTVCards.TabPages.Add(_tvCardTabs[index]); + + index++; } comboBoxCopyFrom.SelectedIndex = 0; @@ -108,8 +109,14 @@ foreach (StbSetup setup in _tvCardStbSetups) setup.Save(); - for (int index = 0; index < MCEReplacement.TvCardCount; index++) - MCEReplacement.GetExternalChannelConfig(index).Save(); + ArrayList cards = new ArrayList(); + MediaPortal.TV.Database.TVDatabase.GetCards(ref cards); + + if (cards.Count == 0) + throw new ApplicationException("Cannot save external channel configurations, there are no TV cards registered"); + + foreach (int cardId in cards) + MCEReplacement.GetExternalChannelConfig(cardId).Save(); } catch (Exception ex) { Modified: trunk/plugins/MCEReplacement/Forms/MacroEditor.cs =================================================================== --- trunk/plugins/MCEReplacement/Forms/MacroEditor.cs 2008-01-04 22:57:22 UTC (rev 1204) +++ trunk/plugins/MCEReplacement/Forms/MacroEditor.cs 2008-01-04 23:08:43 UTC (rev 1205) @@ -122,7 +122,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); } } @@ -146,7 +146,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); } } @@ -327,7 +327,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); MessageBox.Show(this, ex.Message, "Failed to add macro command", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -387,7 +387,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); MessageBox.Show(this, ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -422,7 +422,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); MessageBox.Show(this, ex.Message, "Failed writing macro to file", MessageBoxButtons.OK, MessageBoxIcon.Error); } @@ -568,7 +568,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); MessageBox.Show(this, ex.Message, "Failed to edit macro item", MessageBoxButtons.OK, MessageBoxIcon.Error); } } Modified: trunk/plugins/MCEReplacement/Forms/SetupForm.cs =================================================================== --- trunk/plugins/MCEReplacement/Forms/SetupForm.cs 2008-01-04 22:57:22 UTC (rev 1204) +++ trunk/plugins/MCEReplacement/Forms/SetupForm.cs 2008-01-04 23:08:43 UTC (rev 1205) @@ -127,7 +127,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.Message); + Log.Error(ex); MessageBox.Show(this, ex.Message, "MCE Replacement Plugin Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -334,7 +334,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.Message); + Log.Error(ex); } } @@ -355,6 +355,7 @@ } catch (Exception ex) { + Log.Error(ex); MessageBox.Show(this, ex.Message, "Failed to load help", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -444,6 +445,7 @@ } catch (Exception ex) { + Log.Error(ex); MessageBox.Show(this, ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -723,8 +725,8 @@ } catch (Exception ex) { - IrssLog.Error(ex.ToString()); - MessageBox.Show(ex.ToString(), "Failed to rename file", MessageBoxButtons.OK, MessageBoxIcon.Error); + IrssLog.Error(ex); + MessageBox.Show(ex.Message, "Failed to rename file", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void listViewMacro_AfterLabelEdit(object sender, LabelEditEventArgs e) @@ -769,8 +771,8 @@ } catch (Exception ex) { - IrssLog.Error(ex.ToString()); - MessageBox.Show(ex.ToString(), "Failed to rename file", MessageBoxButtons.OK, MessageBoxIcon.Error); + IrssLog.Error(ex); + MessageBox.Show(ex.Message, "Failed to rename file", MessageBoxButtons.OK, MessageBoxIcon.Error); } } Modified: trunk/plugins/MCEReplacement/Forms/StbSetup.cs =================================================================== --- trunk/plugins/MCEReplacement/Forms/StbSetup.cs 2008-01-04 22:57:22 UTC (rev 1204) +++ trunk/plugins/MCEReplacement/Forms/StbSetup.cs 2008-01-04 23:08:43 UTC (rev 1205) @@ -24,7 +24,7 @@ #region Constants - const string parameterInfo = + const string ParameterInfo = @"%1 = Current channel number digit (-1 for Select/Pre-Change) %2 = Full channel number string %3 = Blaster port (0 = Both, 1 = Port 1, 2 = Port 2)"; @@ -150,9 +150,6 @@ { ExternalChannelConfig config = MCEReplacement.GetExternalChannelConfig(cardId); - if (config == null) - return; - // Setup command list. for (int i = 0; i < 10; i++) listViewExternalCommands.Items[i].SubItems[1].Text = config.Digits[i]; @@ -181,11 +178,6 @@ { ExternalChannelConfig config = MCEReplacement.GetExternalChannelConfig(cardId); - if (config == null) - return; - - config.CardId = cardId; - config.PauseTime = Decimal.ToInt32(numericUpDownPauseTime.Value); config.SendSelect = checkBoxSendSelect.Checked; config.DoubleChannelSelect = checkBoxDoubleSelect.Checked; @@ -372,7 +364,7 @@ { string[] commands = Common.SplitRunCommand(selected.Substring(Common.CmdPrefixRun.Length)); - ExternalProgram executeProgram = new ExternalProgram(commands, parameterInfo); + ExternalProgram executeProgram = new ExternalProgram(commands, ParameterInfo); if (executeProgram.ShowDialog(this) == DialogResult.OK) newCommand = Common.CmdPrefixRun + executeProgram.CommandString; } @@ -380,7 +372,7 @@ { string[] commands = Common.SplitSerialCommand(selected.Substring(Common.CmdPrefixSerial.Length)); - SerialCommand serialCommand = new SerialCommand(commands, parameterInfo); + SerialCommand serialCommand = new SerialCommand(commands, ParameterInfo); if (serialCommand.ShowDialog(this) == DialogResult.OK) newCommand = Common.CmdPrefixSerial + serialCommand.CommandString; } @@ -429,7 +421,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); MessageBox.Show(this, ex.Message, "Failed to edit command", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -446,13 +438,13 @@ if (selected.Equals(Common.UITextRun, StringComparison.OrdinalIgnoreCase)) { - ExternalProgram externalProgram = new ExternalProgram(parameterInfo); + ExternalProgram externalProgram = new ExternalProgram(ParameterInfo); if (externalProgram.ShowDialog(this) == DialogResult.OK) newCommand = Common.CmdPrefixRun + externalProgram.CommandString; } else if (selected.Equals(Common.UITextSerial, StringComparison.OrdinalIgnoreCase)) { - SerialCommand serialCommand = new SerialCommand(parameterInfo); + SerialCommand serialCommand = new SerialCommand(ParameterInfo); if (serialCommand.ShowDialog(this) == DialogResult.OK) newCommand = Common.CmdPrefixSerial + serialCommand.CommandString; } @@ -512,7 +504,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); MessageBox.Show(this, ex.Message, "Failed to set command", MessageBoxButtons.OK, MessageBoxIcon.Error); } } Modified: trunk/plugins/MCEReplacement/MCEReplacement.cs =================================================================== --- trunk/plugins/MCEReplacement/MCEReplacement.cs 2008-01-04 22:57:22 UTC (rev 1204) +++ trunk/plugins/MCEReplacement/MCEReplacement.cs 2008-01-04 23:08:43 UTC (rev 1205) @@ -43,7 +43,7 @@ /// <summary> /// The plugin version string. /// </summary> - internal const string PluginVersion = "MCE Replacement Plugin 1.0.4.0 for MediaPortal 0.2.3.0"; + internal const string PluginVersion = "MCE Replacement Plugin 1.0.4.1 for MediaPortal 0.2.3.0"; /// <summary> /// The wParam for Message Mode Windows Messages. @@ -289,24 +289,6 @@ } /// <summary> - /// Count of available TV Cards. - /// </summary> - internal static int TvCardCount - { - get - { - ArrayList cards = new ArrayList(); - MediaPortal.TV.Database.TVDatabase.GetCards(ref cards); - - int cardCount = cards.Count; - if (cardCount == 0) - cardCount = 1; - - return cardCount; - } - } - - /// <summary> /// Gets a value indicating whether MediaPortal has basic home enabled. /// </summary> /// <value><c>true</c> if MediaPortal has basic home enabled; otherwise, <c>false</c>.</value> @@ -383,7 +365,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); } } @@ -489,7 +471,7 @@ LoadMultiMappings(); LoadExternalConfigs(); - InConfiguration = true; + _inConfiguration = true; if (MP_MCERemote) { @@ -524,7 +506,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: ShowPlugin() - {0}", ex.ToString()); + Log.Error(ex); _mceTransceiver = null; } @@ -912,32 +894,32 @@ Log.Info("MCEReplacement: keyCode \"{0}\" was not handled", keyCode); } } + /// <summary> /// OnMessage is used to receive requests to Tune External Channels and for event mapping. /// </summary> /// <param name="msg">Message.</param> void OnMessage(GUIMessage msg) { - if (ControlExternalEnabled && msg.Message == GUIMessage.MessageType.GUI_MSG_TUNE_EXTERNAL_CHANNEL) + if (EventMapperEnabled) + MapEvent(msg); + + if (!ControlExternalEnabled || msg.Message != GUIMessage.MessageType.GUI_MSG_TUNE_EXTERNAL_CHANNEL) + return; + + Log.Info("MCEReplacement: Tune request - Card: {0}, Channel: {1}", msg.Label2, msg.Label); + + try { - if (LogVerbose) - Log.Info("MCEReplacement: Tune External Channel: {0}, Tuner card: {1}", msg.Label, msg.Label2); - - try - { - Thread newThread = new Thread(new ParameterizedThreadStart(ProcessExternalChannel)); - newThread.Name = "ProcessExternalChannel"; - newThread.Priority = ThreadPriority.BelowNormal; - newThread.Start(new string[] { msg.Label, msg.Label2 }); - } - catch (Exception ex) - { - Log.Error("MCEReplacement: {0}", ex.ToString()); - } + Thread newThread = new Thread(new ParameterizedThreadStart(ProcessExternalChannel)); + newThread.Name = "ProcessExternalChannel"; + newThread.IsBackground = true; + newThread.Start(new string[] { msg.Label, msg.Label2 }); } - - if (EventMapperEnabled) - MapEvent(msg); + catch (Exception ex) + { + Log.Error(ex); + } } /// <summary> @@ -945,25 +927,31 @@ /// </summary> static void LoadExternalConfigs() { - int cardCount = TvCardCount; + ArrayList cards = new ArrayList(); + MediaPortal.TV.Database.TVDatabase.GetCards(ref cards); - _externalChannelConfigs = new ExternalChannelConfig[cardCount]; + if (cards.Count == 0) + throw new ApplicationException("Cannot load external channel configurations, there are no TV cards registered"); - string fileName; - for (int index = 0; index < cardCount; index++) + _externalChannelConfigs = new ExternalChannelConfig[cards.Count]; + + int index = 0; + foreach (int cardId in cards) { - fileName = String.Format("{0}ExternalChannelConfig{1}.xml", AppDataFolder, Convert.ToString(index + 1)); + string fileName = String.Format("{0}ExternalChannelConfig{1}.xml", AppDataFolder, cardId); try { _externalChannelConfigs[index] = ExternalChannelConfig.Load(fileName); } catch (Exception ex) { + Log.Error(ex); + _externalChannelConfigs[index] = new ExternalChannelConfig(fileName); - Log.Error("MCEReplacement: {0}", ex.ToString()); } - _externalChannelConfigs[index].CardId = index; + _externalChannelConfigs[index].CardId = cardId; + index++; } } @@ -993,6 +981,8 @@ try { string[] data = args as string[]; + if (data == null) + throw new ArgumentException("Parameter is not of type string[]", "args"); int card = int.Parse(data[1]); @@ -1000,11 +990,8 @@ if (card < 0) card = 0; - if (card >= _externalChannelConfigs.Length) - throw new ArgumentException("Card number is higher than last card in list, reconfigure plugin TV cards.", "args"); + ExternalChannelConfig config = GetExternalChannelConfig(card); - ExternalChannelConfig config = _externalChannelConfigs[card]; - // Clean up the "data[0]" string into "channel". StringBuilder channel = new StringBuilder(); foreach (char digit in data[0]) @@ -1071,7 +1058,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); } } @@ -1083,6 +1070,10 @@ /// <param name="channelFull">The channel full ID.</param> internal static void ProcessExternalCommand(string command, int channelDigit, string channelFull) { +#if DEBUG + Log.Debug("MCEReplacement: ProcessExternalCommand(\"{0}\", {1}, {2})", command, channelDigit, channelFull); +#endif + if (command.StartsWith(Common.CmdPrefixRun, StringComparison.OrdinalIgnoreCase)) { string[] commands = Common.SplitRunCommand(command.Substring(Common.CmdPrefixRun.Length)); @@ -1273,7 +1264,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); } } @@ -1460,7 +1451,7 @@ /// 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> + /// <returns><c>true</c> if successful, otherwise <c>false</c>.</returns> internal static IRServerPluginInterface.LearnStatus LearnIR(string fileName) { IRServerPluginInterface.LearnStatus status = IRServerPluginInterface.LearnStatus.Failure; @@ -1481,7 +1472,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: LearnIRCommand() {0}", ex.ToString()); + Log.Error(ex); } return status; @@ -1531,12 +1522,12 @@ { Thread newThread = new Thread(new ParameterizedThreadStart(ProcCommand)); newThread.Name = ProcessCommandThreadName; - newThread.Priority = ThreadPriority.BelowNormal; + newThread.IsBackground = true; newThread.Start(command); } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); } } else @@ -1592,6 +1583,16 @@ string[] commands = Common.SplitWindowMessageCommand(command.Substring(Common.CmdPrefixWindowMsg.Length)); Common.ProcessWindowMessageCommand(commands); } + else if (command.StartsWith(Common.CmdPrefixTcpMsg, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitTcpMessageCommand(command.Substring(Common.CmdPrefixTcpMsg.Length)); + Common.ProcessTcpMessageCommand(commands); + } + else if (command.StartsWith(Common.CmdPrefixHttpMsg, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitHttpMessageCommand(command.Substring(Common.CmdPrefixHttpMsg.Length)); + Common.ProcessHttpCommand(commands); + } else if (command.StartsWith(Common.CmdPrefixKeys, StringComparison.OrdinalIgnoreCase)) { string keyCommand = command.Substring(Common.CmdPrefixKeys.Length); @@ -1610,9 +1611,22 @@ string ejectCommand = command.Substring(Common.CmdPrefixEject.Length); Common.ProcessEjectCommand(ejectCommand); } + else if (command.StartsWith(Common.CmdPrefixPopup, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitPopupCommand(command.Substring(Common.CmdPrefixPopup.Length)); + if (_inConfiguration) + MessageBox.Show(commands[1], commands[0], MessageBoxButtons.OK, MessageBoxIcon.Information); + else + MPCommon.ShowNotifyDialog(commands[0], commands[1], int.Parse(commands[2])); + } else if (command.StartsWith(Common.CmdPrefixGoto, StringComparison.OrdinalIgnoreCase)) { - MPCommon.ProcessGoTo(command.Substring(Common.CmdPrefixGoto.Length), _mpBasicHome); + string screenID = command.Substring(Common.CmdPrefixGoto.Length); + + if (_inConfiguration) + MessageBox.Show(screenID, Common.UITextGoto, MessageBoxButtons.OK, MessageBoxIcon.Information); + else + MPCommon.ProcessGoTo(screenID, _mpBasicHome); } else if (command.StartsWith(Common.CmdPrefixHibernate, StringComparison.OrdinalIgnoreCase)) { @@ -1676,7 +1690,7 @@ catch (Exception ex) { if (Thread.CurrentThread.Name.Equals(ProcessCommandThreadName, StringComparison.OrdinalIgnoreCase)) - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); else throw; } @@ -1880,7 +1894,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); } } /// <summary> @@ -1908,7 +1922,7 @@ } catch (Exception ex) { - Log.Error("MCEReplacement: {0}", ex.ToString()); + Log.Error(ex); } } Modified: trunk/plugins/MCEReplacement/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/MCEReplacement/Properties/AssemblyInfo.cs 2008-01-04 22:57:22 UTC (rev 1204) +++ trunk/plugins/MCEReplacement/Properties/AssemblyInfo.cs 2008-01-04 23:08:43 UTC (rev 1205) @@ -34,8 +34,8 @@ // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.4.0")] -[assembly: AssemblyFileVersionAttribute("1.0.4.0")] +[assembly: AssemblyVersion("1.0.4.1")] +[assembly: AssemblyFileVersionAttribute("1.0.4.1")] // // In order to sign your assembly you must specify a key to use. Refer to the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |