From: <che...@us...> - 2007-06-22 18:16:27
|
Revision: 599 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=599&view=rev Author: chef_koch Date: 2007-06-22 11:16:25 -0700 (Fri, 22 Jun 2007) Log Message: ----------- small cleanup 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:03:18 UTC (rev 598) +++ trunk/plugins/FritzBox/FritzBox/FritzBox.cs 2007-06-22 18:16:25 UTC (rev 599) @@ -79,7 +79,7 @@ #region public Variables - public const string _version = "0.2.2.0"; + public const string _version = "0.2.2.8"; public static int _lastVersion = 0; public static bool _extensiveLogging = false; @@ -98,14 +98,17 @@ #endregion #region Constructors/Destructors + public FritzBox() { } + #endregion #region Private Methods #region Settings + private void LoadSettings() { char[] charSeparators = new char[] { ';' }; @@ -177,9 +180,11 @@ SavePhonebook(); } + #endregion #region Phonebook + public static void LoadPhonebook() { if ((_lastVersion < 0220) && (!File.Exists(Config.GetFile(Config.Dir.Config, "fritzbox.xml")))) @@ -306,6 +311,7 @@ } return false; } + #endregion public bool IsFritzBoxConnected(string fritzBoxAddress, string fritzBoxPort) @@ -326,6 +332,7 @@ } #region FritzBoxActions + private void OnFritzBoxEvent(string dataStream) { if (!_showNotify) @@ -382,84 +389,79 @@ Log.Info(" MSN: {0}", msn); } - if (CheckMSN(msn) == true) + if (!CheckMSN(msn)) return; + + if (callerId == "") { - if (callerId == "") + Log.Info("Caller is not identified by CLIP."); + + if (FritzBox._showUnknownCaller) + DialogOnIncomingCall("", msn); + } + else + { + if (FritzBox._usePhonebook) { - Log.Info("Caller is not identified by CLIP."); + bool foundCaller = false; - if (FritzBox._showUnknownCaller) - DialogOnIncomingCall("", msn); - } - else - { - if (FritzBox._usePhonebook) + if (phonebook.Count == 0) { + Log.Info("Phonebook is empty. Caller is added to the phonebook."); + Caller caller = new Caller(callerId, callerId, true); + phonebook.Add(caller); + } + else + { + int i = 0; - - - - bool foundCaller = false; - - if (phonebook.Count == 0) + do { - Log.Info("Phonebook is empty. Caller is added to the phonebook."); - Caller caller = new Caller(callerId, callerId, true); - phonebook.Add(caller); - } - else - { - int i = 0; + Caller caller = phonebook[i]; - do + if (caller.ID.Equals(callerId)) { - Caller caller = phonebook[i]; + Log.Info("Caller is identified by phonebook as {0}.", caller.Name); + foundCaller = true; - if (caller.ID.Equals(callerId)) + if (caller.Show) { - Log.Info("Caller is identified by phonebook as {0}.", caller.Name); - foundCaller = true; + Log.Info("Caller is accepted by phonebook and dialog will be shown."); - if (caller.Show) - { - Log.Info("Caller is accepted by phonebook and dialog will be shown."); - - DialogOnIncomingCall(caller.Name, msn); - } - else - { - Log.Info("Caller is denied by phonebook and dialog won't be shown."); - } + DialogOnIncomingCall(caller.Name, msn); } - i++; + else + { + Log.Info("Caller is denied by phonebook and dialog won't be shown."); + } } - while (!foundCaller && (i < phonebook.Count)); + i++; + } + while (!foundCaller && (i < phonebook.Count)); - if (!foundCaller) + if (!foundCaller) + { + Log.Info("Caller is not identified by phonebook."); + + if (FritzBox._saveUnknownCaller) { - Log.Info("Caller is not identified by phonebook."); + Log.Info("saveUnknownCallers is ON - Caller is added to the phonebook."); - if (FritzBox._saveUnknownCaller) - { - Log.Info("saveUnknownCallers is ON - Caller is added to the phonebook."); + Caller caller = new Caller(callerId, callerId, FritzBox._showUnknownCaller); + phonebook.Add(caller); + } - Caller caller = new Caller(callerId, callerId, FritzBox._showUnknownCaller); - phonebook.Add(caller); - } + if (FritzBox._showUnknownCaller) + { + Log.Info("showUnknownCallers is ON - Caller is shown."); - if (FritzBox._showUnknownCaller) - { - Log.Info("showUnknownCallers is ON - Caller is shown."); - - DialogOnIncomingCall(callerId, msn); - } + DialogOnIncomingCall(callerId, msn); } + } - } } - else - DialogOnIncomingCall(callerId, msn); } + else + DialogOnIncomingCall(callerId, msn); } } @@ -492,6 +494,7 @@ Log.Info(" DateTime: {0}", dateTime); Log.Info(" conneted time (in s): {0}", connectedTime.ToString()); } + #endregion void DialogOnIncomingCall(string strCallerId, string strMSN) @@ -580,7 +583,6 @@ } } - 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. |
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. |
From: <che...@us...> - 2007-06-22 22:23:32
|
Revision: 604 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=604&view=rev Author: chef_koch Date: 2007-06-22 15:23:27 -0700 (Fri, 22 Jun 2007) Log Message: ----------- small change Modified Paths: -------------- trunk/plugins/FritzBox/FritzBox/FritzBox.cs Modified: trunk/plugins/FritzBox/FritzBox/FritzBox.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBox.cs 2007-06-22 22:11:15 UTC (rev 603) +++ trunk/plugins/FritzBox/FritzBox/FritzBox.cs 2007-06-22 22:23:27 UTC (rev 604) @@ -332,7 +332,6 @@ { case "RING": OnIncomingCall(strList[0], strList[3], strList[4]); - FritzBoxWatch.notifyCount--; break; case "CALL": @@ -347,6 +346,7 @@ OnConnectionClosed(strList[0], int.Parse(strList[3])); break; } + FritzBoxWatch.notifyCount--; } private void OnIncomingCall(string dateTime, string callerId, string msn) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |