From: <che...@us...> - 2007-06-22 18:37:33
|
Revision: 600 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=600&view=rev Author: chef_koch Date: 2007-06-22 11:37:31 -0700 (Fri, 22 Jun 2007) Log Message: ----------- _msn[] is now a List of Strings and called _msnList Modified Paths: -------------- trunk/plugins/FritzBox/FritzBox/FritzBox.cs Modified: trunk/plugins/FritzBox/FritzBox/FritzBox.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBox.cs 2007-06-22 18:16:25 UTC (rev 599) +++ trunk/plugins/FritzBox/FritzBox/FritzBox.cs 2007-06-22 18:37:31 UTC (rev 600) @@ -24,26 +24,20 @@ #endregion using System; -using System.Collections; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Net.Sockets; -using System.Reflection; -using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; using System.Xml; -using MediaPortal.Ripper; - -using MediaPortal.Util; -using MediaPortal.GUI.Library; using MediaPortal.Configuration; using MediaPortal.Dialogs; +using MediaPortal.GUI.Library; using MediaPortal.Player; -using System.Collections.Generic; +using MediaPortal.Util; - namespace FritzBox { /* @@ -55,8 +49,13 @@ public class FritzBox : ISetupForm, IPlugin { #region Variables - #region Private Variables + public const string _version = "0.2.2.8"; + public static int _lastVersion = 0; + public static bool _extensiveLogging = false; + + FritzBoxWatch FritzBoxWatch; + private bool _fritzBoxDisabled = false; // notify settings @@ -64,7 +63,7 @@ private bool _closeOnTimeout = false; public static bool _filterMSNs = false; - public static string[] _msn; + public static List<String> _msnList = new List<String>(); public static bool _showMsnOnHeading = false; @@ -73,16 +72,8 @@ private bool _resumeMedia = true; // resume media when notify is closed private bool _showNotify = true; - private List<string> notifyQueue = new List<string>(); + private List<String> notifyQueue = new List<String>(); - #endregion - - #region public Variables - - public const string _version = "0.2.2.8"; - public static int _lastVersion = 0; - public static bool _extensiveLogging = false; - // phonebook settings public static bool _usePhonebook = true; public static bool _showUnknownCaller = true; @@ -92,11 +83,6 @@ #endregion - FritzBoxWatch FritzBoxWatch; - - // Protected Variables - #endregion - #region Constructors/Destructors public FritzBox() @@ -105,8 +91,6 @@ #endregion - #region Private Methods - #region Settings private void LoadSettings() @@ -134,7 +118,7 @@ _filterMSNs = xmlreader.GetValueAsBool("fritzbox", "filterMSNs", false); string strMSN = xmlreader.GetValueAsString("fritzbox", "MSN", ""); - _msn = strMSN.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); + _msnList.AddRange(strMSN.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries)); if (_extensiveLogging) Log.Debug("FRITZ!Box: MSNs loaded: {0}", strMSN); @@ -314,23 +298,6 @@ #endregion - public bool IsFritzBoxConnected(string fritzBoxAddress, string fritzBoxPort) - { - TcpClient TcpClient; - - try - { - TcpClient = new TcpClient(fritzBoxAddress, Int32.Parse(fritzBoxPort)); - } - catch (Exception) - { - return false; - } - - TcpClient.Close(); - return true; - } - #region FritzBoxActions private void OnFritzBoxEvent(string dataStream) @@ -389,7 +356,7 @@ Log.Info(" MSN: {0}", msn); } - if (!CheckMSN(msn)) return; + if (!IsMsnEnabled(msn)) return; if (callerId == "") { @@ -554,35 +521,49 @@ g_Player.Pause(); } - private bool CheckMSN(string msn) + #region Helper Methods + + public bool IsFritzBoxConnected(string fritzBoxAddress, string fritzBoxPort) { - bool foundMSN = false; + TcpClient TcpClient; - if (FritzBox._filterMSNs) + try { - for (int i = 0; i <= FritzBox._msn.GetUpperBound(0); i++) - { - if (FritzBox._msn[i].ToString() == msn) - foundMSN = true; - } - if (foundMSN == true) - { - Log.Info("MSN is on list."); - return true; - } - else - { - Log.Info("MSN is not on list. Notify won't be shown."); - return false; - } + TcpClient = new TcpClient(fritzBoxAddress, Int32.Parse(fritzBoxPort)); } - else + catch (Exception) { + return false; + } + + TcpClient.Close(); + return true; + } + + private bool IsMsnEnabled(string msn) + { + if (!_filterMSNs) + { Log.Info("MSN filter is disabled."); return true; } + + if (_msnList.Contains(msn)) + { + Log.Info("MSN is on list."); + return true; + } + else + { + Log.Info("MSN is not on list. Notify won't be shown."); + return false; + } } + #endregion + + #region ExternalProcess Actions + public void OnStartExternal(Process proc, bool waitForExit) { if (waitForExit) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |