From: <che...@us...> - 2008-08-07 17:28:40
|
Revision: 2008 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=2008&view=rev Author: chef_koch Date: 2008-08-07 17:28:35 +0000 (Thu, 07 Aug 2008) Log Message: ----------- version bump to 0.3.2.0 - completely rework the communication with the fritzBox - added reconnect feature, now it also gets the call infos after the fritzbox was rebooted, without restarting MediaPortal Modified Paths: -------------- trunk/plugins/FritzBox/FritzBox/FritzBox.cs trunk/plugins/FritzBox/FritzBox/FritzBox.csproj trunk/plugins/FritzBox/FritzBox/FritzBoxSetupFrom.cs trunk/plugins/FritzBox/FritzBox/PhoneBook.cs trunk/plugins/FritzBox/FritzBox.xmp Added Paths: ----------- trunk/plugins/FritzBox/FritzBox/FritzBoxClient.cs Modified: trunk/plugins/FritzBox/FritzBox/FritzBox.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBox.cs 2008-08-07 11:26:02 UTC (rev 2007) +++ trunk/plugins/FritzBox/FritzBox/FritzBox.cs 2008-08-07 17:28:35 UTC (rev 2008) @@ -44,39 +44,15 @@ [PluginIcons("FritzBox.FritzBox.png", "FritzBox.FritzBoxDisabled.png")] public class FritzBox : ISetupForm, IPlugin { - #region Private Fields - - /// <summary> - /// networkstream to receive data, sent by fritzbox - /// </summary> - private NetworkStream networkStream; - - /// <summary> - /// address for the connected fritzbox - /// </summary> - private string fritzBoxAddress; - - /// <summary> - /// port for the connected fritzbox - /// </summary> - private int fritzBoxPort; - - /// <summary> - /// indicates whether listing is enabled or not - /// </summary> - private bool stopThread; - - #endregion - #region Variables - public const string _version = "0.3.1.1"; + public const string _version = "0.3.2.0"; public static int _lastVersion = 0; static bool _extensiveLogging = false; List<CallAction> actionList = new List<CallAction>(); object tempNotify = null; - + // notify settings int _timeout = -1; // autoclose the dialog after the timeout expired bool _closeOnTimeout = false; @@ -86,9 +62,8 @@ List<String> _msnList = new List<String>(); bool _showMsnOnHeading = false; - + private bool _usePhonebook = true; - private PhoneBook phoneBook; int maxNotifies = 20; int notifyCount = 0; @@ -104,69 +79,18 @@ #region Constructors and Destructors - /// <summary> - /// constructor - /// </summary> public FritzBox() { - ReceivedData += new ReceivedDataEventHandler(FritzBox_ReceivedData); } - /// <summary> - /// Destructor. - /// </summary> - ~FritzBox() { } + ~FritzBox() + { + } #endregion - #region Public Events and Delegates - - public delegate void ReceivedDataEventHandler(object sender, EventArgs e); - public event ReceivedDataEventHandler ReceivedData; - - #endregion - #region Private Functions/Methods - private void ReceiveThread() - { - Log.Info("FRITZ!Box: ReceiveThread()"); - - while (!stopThread) - { - System.Threading.Thread.Sleep(100); - if (this.networkStream.DataAvailable) - if (ReceivedData != null) - ReceivedData(this, new EventArgs()); - } - } - - void FritzBox_ReceivedData(object sender, EventArgs e) - { - Log.Info("FRITZ!Box: FritzBox_ReceivedData()"); - - byte[] myReadBuffer = new byte[1024]; - StringBuilder myCompleteMessage = new StringBuilder(); - int numberOfBytesRead = 0; - - // Incoming message may be larger than the buffer size. - while (networkStream.DataAvailable) - { - numberOfBytesRead = networkStream.Read(myReadBuffer, 0, myReadBuffer.Length); - - myCompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead)); - } - if (_extensiveLogging) - Log.Info("received data: {0}", myCompleteMessage.ToString()); - - CallAction callAction = ParseAction(myCompleteMessage.ToString()); - if (callAction == null) return; - if (_extensiveLogging) - callAction.WriteToLog(); - - OnCallAction(callAction); - } - void OnStartExternal(Process proc, bool waitForExit) { if (waitForExit) @@ -188,11 +112,11 @@ notifyQueue.Clear(); } - void OnCallAction(CallAction callAction) { Log.Info("FRITZ!Box: OnCallAction()"); - + callAction.WriteToLog(); + if (!_showNotify) { Log.Info("External process is running. Notify is queued and will be shown later."); @@ -204,7 +128,7 @@ { case CallAction.CallType.Incoming: if (_usePhonebook) - callAction.caller = phoneBook.GetCaller(callAction.caller); + callAction.caller = PhoneBook.GetCaller(callAction.caller); OnIncomingCall(callAction); break; case CallAction.CallType.Outgoing: @@ -223,6 +147,9 @@ } } break; + default: + Log.Error("incorrect callaction.type"); + break; } } @@ -230,7 +157,7 @@ void OnIncomingCall(CallAction callAction) { Log.Info("FRITZ!Box: OnIncomingCall()"); - + if (tempNotify != null) { Log.Info("yet another dialog is active. action is sent to queue."); @@ -279,15 +206,15 @@ private void LoadSettings() { Log.Info("FRITZ!Box: LoadSettings()"); - + char[] charSeparators = new char[] { ';' }; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { _lastVersion = xmlreader.GetValueAsInt("fritzbox", "lastVersion", 0); - fritzBoxAddress = xmlreader.GetValueAsString("fritzbox", "address", "fritz.box"); - fritzBoxPort = xmlreader.GetValueAsInt("fritzbox", "port", 1012); + FritzBoxClient.address = xmlreader.GetValueAsString("fritzbox", "address", "fritz.box"); + FritzBoxClient.port = xmlreader.GetValueAsInt("fritzbox", "port", 1012); _extensiveLogging = xmlreader.GetValueAsBool("fritzbox", "extensiveLogging", false); @@ -317,8 +244,7 @@ _usePhonebook = xmlreader.GetValueAsBool("fritzbox", "usePhonebook", true); if (_usePhonebook) { - phoneBook = new PhoneBook(); - phoneBook.LoadSettings(); + PhoneBook.LoadSettings(); } if (_extensiveLogging) @@ -334,8 +260,8 @@ Log.Info("FRITZ!Box: usePhonebook = {0}", _usePhonebook.ToString()); if (_usePhonebook) { - Log.Info("FRITZ!Box: showUnknownCaller = {0}", phoneBook.ShowUnknownCaller.ToString()); - Log.Info("FRITZ!Box: saveUnknownCaller = {0}", phoneBook.SaveUnknownCaller.ToString()); + Log.Info("FRITZ!Box: showUnknownCaller = {0}", PhoneBook.ShowUnknownCaller.ToString()); + Log.Info("FRITZ!Box: saveUnknownCaller = {0}", PhoneBook.SaveUnknownCaller.ToString()); } } } @@ -350,63 +276,13 @@ xmlwriter.SetValue("fritzbox", "lastVersion", _version.Replace(".", string.Empty)); } - phoneBook.SaveSettings(); + PhoneBook.SaveSettings(); } #endregion #region Helper Methods - CallAction ParseAction(string dataStream) - { - Log.Info("FRITZ!Box: ParseAction()"); - if (dataStream == null) return null; - - // data-stream can be in following format: - // incoming calls: DateTime;RING;ConnectionID;CallerID;MSN;??POTS??; - // outgoing calls: DateTime;CALL;ConnectionID;??Nebenstelle??;MSN;CallerID;??POTS??; - // connection started: DateTime;CONNECT;ConnectionID;??Nebenstelle??;CallerID; - // connection closed: DateTime;DISCONNECT;ConnectionID;ConnectedTime; - - // DateTime format: - // 12.12.06 12:12:12 - // dd.MM.yy hh:mm:ss - - string[] strList = dataStream.Trim().Split(';'); - CallAction callAction = new CallAction(); - - // time when action happens - callAction.time = DateTime.Parse(strList[0], new System.Globalization.CultureInfo("de-DE", false)); - - // set the type of the callAction - switch (strList[1]) - { - case "RING": - callAction.type = CallAction.CallType.Incoming; - // sets the callerID - callAction.caller.ID = strList[3]; - callAction.msn = strList[4]; - break; - case "CALL": - callAction.type = CallAction.CallType.Outgoing; - // sets the callerID - callAction.caller.ID = strList[5]; - callAction.msn = strList[4]; - break; - case "CONNECT": - callAction.type = CallAction.CallType.ConnectionStarted; - // sets the callerID - callAction.caller.ID = strList[4]; - break; - case "DISCONNECT": - callAction.type = CallAction.CallType.ConnectionClosed; - break; - default: - return null; - } - return callAction; - } - string GetCallerImage(Caller caller) { if (caller.ID == "") @@ -418,7 +294,7 @@ // search image for caller if (_extensiveLogging) Log.Info("searching image: " + strImage); - + if (File.Exists(strImage)) { if (_extensiveLogging) @@ -506,7 +382,7 @@ try { - TcpClient = new TcpClient(fritzBoxAddress, fritzBoxPort); + TcpClient = new TcpClient(FritzBoxClient.address, FritzBoxClient.port); } catch (Exception) { @@ -532,24 +408,10 @@ LoadSettings(); Utils.OnStartExternal += new Utils.UtilEventHandler(OnStartExternal); - Utils.OnStopExternal += new Utils.UtilEventHandler(OnStopExternal); + Utils.OnStopExternal += new Utils.UtilEventHandler(OnStopExternal); - TcpClient tcpClient; - // To get the calling informations, the port 1012 on the FRITZBox have to be opened. - // You can open the port with you phone by calling: #96*5* - // To close the port you can call: #96*4* - - // create a new connection to the FritzBox and listen to the TCP port - tcpClient = new TcpClient(fritzBoxAddress, fritzBoxPort); - - tcpClient.ReceiveBufferSize = 1; - networkStream = tcpClient.GetStream(); - - - Thread FBReceiveThread = new Thread(new ThreadStart(ReceiveThread)); - FBReceiveThread.Priority = ThreadPriority.BelowNormal; - FBReceiveThread.Name = "FRITZ!Box Monitoring"; - FBReceiveThread.Start(); + FritzBoxClient.CallEvent += new FritzBoxClient.CallEventHandler(OnCallAction); + FritzBoxClient.StartClient(); } /// <summary> @@ -558,9 +420,10 @@ public void Stop() { Log.Info("FRITZ!Box Plugin {0} stopping.", _version); - stopThread = true; - ReceivedData -= new ReceivedDataEventHandler(FritzBox_ReceivedData); + FritzBoxClient.StopClient(); + FritzBoxClient.CallEvent -= new FritzBoxClient.CallEventHandler(OnCallAction); + Utils.OnStartExternal -= new Utils.UtilEventHandler(OnStartExternal); Utils.OnStopExternal -= new Utils.UtilEventHandler(OnStopExternal); Modified: trunk/plugins/FritzBox/FritzBox/FritzBox.csproj =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBox.csproj 2008-08-07 11:26:02 UTC (rev 2007) +++ trunk/plugins/FritzBox/FritzBox/FritzBox.csproj 2008-08-07 17:28:35 UTC (rev 2008) @@ -53,6 +53,7 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="FritzBoxClient.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Caller.cs" /> <Compile Include="CallAction.cs" /> Added: trunk/plugins/FritzBox/FritzBox/FritzBoxClient.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBoxClient.cs (rev 0) +++ trunk/plugins/FritzBox/FritzBox/FritzBoxClient.cs 2008-08-07 17:28:35 UTC (rev 2008) @@ -0,0 +1,263 @@ +using System; +using System.Net; +using System.Net.Sockets; +using System.Threading; +using System.Text; + +using MediaPortal.GUI.Library; + +namespace FritzBox +{ + #region class StateObject + // State object for receiving data from remote device. + public class StateObject + { + // Client socket. + public Socket workSocket = null; + // Size of receive buffer. + public const int BufferSize = 256; + // Receive buffer. + public byte[] buffer = new byte[BufferSize]; + // Received data string. + public StringBuilder sb = new StringBuilder(); + } + #endregion + + public static class FritzBoxClient + { + #region variables + + public static string address = "fritz.box"; + // The port number for the remote device. + public static int port = 1012; + + static TimeSpan minConnectWaitTime = new TimeSpan(0, 2, 0); + static DateTime connectionFailed; + + static Socket _client; + + #endregion + + #region Public Events and Delegates + + public delegate void CallEventHandler(CallAction callAction); + public static event CallEventHandler CallEvent; + + #endregion + + #region Public methods + + public static void StartClient() + { + Log.Debug("StartClient"); + connectionFailed = DateTime.MinValue; + + Thread thread = new Thread(new ThreadStart(Connect)); + thread.Start(); + } + + public static void StopClient() + { + Log.Debug("StopClient"); + try + { + // Release the socket. + _client.Shutdown(SocketShutdown.Both); + _client.Close(); + } + catch (Exception e) + { + Log.Error(e.ToString()); + } + } + + #endregion + + #region Private methods + + private static void ReConnect() + { + Log.Debug("ReConnect"); + connectionFailed = DateTime.Now; + + Thread thread = new Thread(new ThreadStart(Connect)); + thread.Start(); + } + + private static void Connect() + { + Log.Debug("Connect"); + + // Enforce a minimum wait time between connects. + DateTime nextconnect = connectionFailed.Add(minConnectWaitTime); + if (DateTime.Now < nextconnect) + { + TimeSpan waittime = nextconnect - DateTime.Now; + Log.Debug("Avoiding too much reconnects, sleeping until {0}.", nextconnect.ToString()); + Thread.Sleep(waittime); + } + + try + { + //Establish the remote endpoint for the socket. + //The name of the + //remote device is "host.contoso.com". + IPHostEntry ipHostInfo = Dns.GetHostEntry(address); + IPAddress ipAddress = ipHostInfo.AddressList[0]; + IPEndPoint remoteEP = new IPEndPoint(ipAddress, port); + + // Create a TCP/IP socket. + _client = new Socket(AddressFamily.InterNetwork, + SocketType.Stream, ProtocolType.Tcp); + + // Connect to the remote endpoint. + _client.BeginConnect(address, port, new AsyncCallback(ConnectCallback), _client); + } + catch (SocketException) + { + Log.Debug("Connect - SocketException - Connection to FritzBox failed, trying again in 2 minutes."); + ReConnect(); + } + catch (Exception e) + { + Log.Error(e.ToString()); + } + } + + private static void ConnectCallback(IAsyncResult ar) + { + Log.Debug("ConnectCallback"); + try + { + // Retrieve the socket from the state object. + Socket client = (Socket)ar.AsyncState; + + // Complete the connection. + client.EndConnect(ar); + + Log.Debug("Socket connected to {0}", + client.RemoteEndPoint.ToString()); + + Receive(client); + } + catch (Exception e) + { + Log.Error(e.ToString()); + } + } + + + private static void Receive(Socket client) + { + Log.Debug("Receive"); + try + { + // Create the state object. + StateObject state = new StateObject(); + state.workSocket = client; + + // Begin receiving the data from the remote device. + client.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, + new AsyncCallback(ReceiveCallback), state); + } + catch (Exception e) + { + Log.Error(e.ToString()); + } + } + + private static void ReceiveCallback(IAsyncResult ar) + { + Log.Debug("ReceiveCallback"); + try + { + // Retrieve the state object and the client socket + // from the asynchronous state object. + StateObject state = (StateObject)ar.AsyncState; + Socket client = state.workSocket; + + // Read data from the remote device. + int bytesRead = client.EndReceive(ar); + + if (bytesRead > 0) + { + // There might be more data, so store the data received so far. + string data = Encoding.ASCII.GetString(state.buffer, 0, bytesRead); + //Log.Debug("ReceiveCallback : received data: {0}", data); + + // data-stream can be in following format: + // incoming calls: DateTime;RING;ConnectionID;CallerID;MSN;??POTS??; + // outgoing calls: DateTime;CALL;ConnectionID;??Nebenstelle??;MSN;CallerID;??POTS??; + // connection started: DateTime;CONNECT;ConnectionID;??Nebenstelle??;CallerID; + // connection closed: DateTime;DISCONNECT;ConnectionID;ConnectedTime; + + // DateTime format: + // 12.12.06 12:12:12 + // dd.MM.yy hh:mm:ss + + string[] strList = data.Trim().Split(';'); + CallAction callAction = new CallAction(); + + // time when action happens + callAction.time = DateTime.Parse(strList[0], new System.Globalization.CultureInfo("de-DE", false)); + + // set the type of the callAction + switch (strList[1]) + { + case "RING": + callAction.type = CallAction.CallType.Incoming; + // sets the callerID + callAction.caller.ID = strList[3]; + callAction.msn = strList[4]; + break; + case "CALL": + callAction.type = CallAction.CallType.Outgoing; + // sets the callerID + callAction.caller.ID = strList[5]; + callAction.msn = strList[4]; + break; + case "CONNECT": + callAction.type = CallAction.CallType.ConnectionStarted; + // sets the callerID + callAction.caller.ID = strList[4]; + break; + case "DISCONNECT": + callAction.type = CallAction.CallType.ConnectionClosed; + break; + default: + callAction = null; + break; + } + + // continue to listen to the fb + client.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, + new AsyncCallback(ReceiveCallback), state); + + CallEvent(callAction); + } + else + { + Log.Debug("ReceiveCallback: no bytes to read"); + // continue to listen to the fb + client.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, + new AsyncCallback(ReceiveCallback), state); + } + } + catch (ObjectDisposedException) + { + Log.Debug("ReceiveCallback: ObjectDisposedException - Maybe socket has been closed."); + } + catch (SocketException) + { + Log.Debug("ReceiveCallback - SocketException - Connection to FritzBox failed, trying again in 2 minutes."); + ReConnect(); + } + catch (Exception e) + { + Log.Error(e.ToString()); + } + } + + #endregion + } +} Modified: trunk/plugins/FritzBox/FritzBox/FritzBoxSetupFrom.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBoxSetupFrom.cs 2008-08-07 11:26:02 UTC (rev 2007) +++ trunk/plugins/FritzBox/FritzBox/FritzBoxSetupFrom.cs 2008-08-07 17:28:35 UTC (rev 2008) @@ -19,8 +19,6 @@ { public partial class FritzBoxSetupFrom : Form { - PhoneBook phoneBook; - public FritzBoxSetupFrom() { InitializeComponent(); @@ -68,17 +66,16 @@ // phonebook settings checkBoxUsePhonebook.Checked = xmlreader.GetValueAsBool("fritzbox", "usePhonebook", true); - phoneBook = new PhoneBook(); - phoneBook.LoadSettings(); + PhoneBook.LoadSettings(); - checkBoxShowUnknownCaller.Checked = phoneBook.ShowUnknownCaller; - checkBoxSaveUnknownCaller.Checked = phoneBook.SaveUnknownCaller; + checkBoxShowUnknownCaller.Checked = PhoneBook.ShowUnknownCaller; + checkBoxSaveUnknownCaller.Checked = PhoneBook.SaveUnknownCaller; checkBoxShowUnknownCaller.Enabled = checkBoxUsePhonebook.Checked; checkBoxSaveUnknownCaller.Enabled = checkBoxUsePhonebook.Checked; - textBoxSuffixHome.Text = phoneBook.SuffixHome; - textBoxSuffixWork.Text = phoneBook.SuffixWork; - textBoxSuffixMobile.Text = phoneBook.SuffixMobile; + textBoxSuffixHome.Text = PhoneBook.SuffixHome; + textBoxSuffixWork.Text = PhoneBook.SuffixWork; + textBoxSuffixMobile.Text = PhoneBook.SuffixMobile; } RefreshDataGridView(); @@ -118,15 +115,15 @@ // phonebook settings xmlwriter.SetValueAsBool("fritzbox", "usePhonebook", checkBoxUsePhonebook.Checked); - phoneBook.ShowUnknownCaller = checkBoxShowUnknownCaller.Checked; - phoneBook.SaveUnknownCaller = checkBoxSaveUnknownCaller.Checked; - phoneBook.SuffixHome = textBoxSuffixHome.Text; - phoneBook.SuffixWork = textBoxSuffixWork.Text; - phoneBook.SuffixMobile = textBoxSuffixMobile.Text; + PhoneBook.ShowUnknownCaller = checkBoxShowUnknownCaller.Checked; + PhoneBook.SaveUnknownCaller = checkBoxSaveUnknownCaller.Checked; + PhoneBook.SuffixHome = textBoxSuffixHome.Text; + PhoneBook.SuffixWork = textBoxSuffixWork.Text; + PhoneBook.SuffixMobile = textBoxSuffixMobile.Text; } SaveDataGridView(); - phoneBook.SaveSettings(); + PhoneBook.SaveSettings(); } @@ -337,7 +334,7 @@ { if (openFileDialog.ShowDialog() == DialogResult.OK) { - int count = phoneBook.ImportFritzBoxMonitor(openFileDialog.FileName); + int count = PhoneBook.ImportFritzBoxMonitor(openFileDialog.FileName); RefreshDataGridView(); MessageBox.Show("Import done!\nAdded " + count.ToString() + " new CallerIDs to phonebook."); @@ -348,15 +345,15 @@ { dataGridView.Rows.Clear(); - for (int i = 0; i < phoneBook.Contacts.Count; i++) + for (int i = 0; i < PhoneBook.Contacts.Count; i++) { - dataGridView.Rows.Add(phoneBook.Contacts[i].ID, phoneBook.Contacts[i].Name, phoneBook.Contacts[i].Show); + dataGridView.Rows.Add(PhoneBook.Contacts[i].ID, PhoneBook.Contacts[i].Name, PhoneBook.Contacts[i].Show); } } private void SaveDataGridView() { - phoneBook.Contacts.Clear(); + PhoneBook.Contacts.Clear(); for (int i = 0; i < dataGridView.RowCount - 1; i++) { @@ -366,7 +363,7 @@ caller.Name = dataGridView.Rows[i].Cells[1].Value.ToString(); caller.Show = bool.Parse(dataGridView.Rows[i].Cells[2].Value.ToString()); - phoneBook.Contacts.Add(caller); + PhoneBook.Contacts.Add(caller); } } @@ -384,7 +381,7 @@ { if (MessageBox.Show("Attention! Do you really want to clear the phone book? This will delete all your entries!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { - phoneBook.Contacts.Clear(); + PhoneBook.Contacts.Clear(); dataGridView.Rows.Clear(); } } Modified: trunk/plugins/FritzBox/FritzBox/PhoneBook.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/PhoneBook.cs 2008-08-07 11:26:02 UTC (rev 2007) +++ trunk/plugins/FritzBox/FritzBox/PhoneBook.cs 2008-08-07 17:28:35 UTC (rev 2008) @@ -33,55 +33,55 @@ namespace FritzBox { - public class PhoneBook + public static class PhoneBook { #region variables - List<Caller> _contacts; + static List<Caller> _contacts; // phonebook settings - bool _showUnknownCaller; - bool _saveUnknownCaller; + static bool _showUnknownCaller; + static bool _saveUnknownCaller; - string _suffixHome; - string _suffixWork; - string _suffixMobile; + static string _suffixHome; + static string _suffixWork; + static string _suffixMobile; - bool _extensiveLogging; + static bool _extensiveLogging; #endregion #region public properties - public bool ShowUnknownCaller + public static bool ShowUnknownCaller { get { return _showUnknownCaller; } set { _showUnknownCaller = value; } } - public bool SaveUnknownCaller + public static bool SaveUnknownCaller { get { return _saveUnknownCaller; } set { _saveUnknownCaller = value; } } - public string SuffixHome + public static string SuffixHome { get { return _suffixHome; } set { _suffixHome = value; } } - public string SuffixWork + public static string SuffixWork { get { return _suffixWork; } set { _suffixWork = value; } } - public string SuffixMobile + public static string SuffixMobile { get { return _suffixMobile; } set { _suffixMobile = value; } } - public List<Caller> Contacts + public static List<Caller> Contacts { get { return _contacts; } set { _contacts = value; } @@ -89,34 +89,9 @@ #endregion - #region private methods - - void UpdateTo0220() - { - char[] charSeparators = new char[] { ';' }; - - using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) - { - string[] strLCallerId = xmlreader.GetValueAsString("fritzbox", "phonebookCallerId", "").Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); - string[] strLName = xmlreader.GetValueAsString("fritzbox", "phonebookName", "").Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); - string[] strLShow = xmlreader.GetValueAsString("fritzbox", "phonebookShow", "").Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); - - for (int i = 0; i <= strLCallerId.GetUpperBound(0); i++) - { - Caller caller = new Caller(strLCallerId[i], strLName[i], bool.Parse(strLShow[i])); - _contacts.Add(caller); - - if (_extensiveLogging) - Log.Debug("FRITZ!Box: caller loaded: {0} {1} {2}", caller.ID, caller.Name, caller.Show); - } - } - } - - #endregion - #region public methods - public void LoadSettings() + public static void LoadSettings() { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { @@ -130,15 +105,8 @@ _suffixMobile = xmlreader.GetValueAsString("fritzbox", "suffixMobile", " (mobile)"); } - _contacts = new List<Caller>(); - if ((FritzBox._lastVersion < 0220) && (!File.Exists(Config.GetFile(Config.Dir.Config, "fritzbox.xml")))) - { - UpdateTo0220(); - return; - } - using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "fritzbox.xml"))) { int countCaller = xmlreader.GetValueAsInt("phonebook", "count", 0); @@ -161,7 +129,7 @@ Log.Debug("FRITZ!Box: imported {0} callers", _contacts.Count.ToString()); } - public void SaveSettings() + public static void SaveSettings() { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { @@ -189,7 +157,7 @@ } - public int ImportFritzBoxMonitor(string filepath) + public static int ImportFritzBoxMonitor(string filepath) { try { @@ -260,7 +228,7 @@ } } - public bool CallerExists(string callerId) + public static bool CallerExists(string callerId) { foreach (Caller caller in _contacts) if (caller.ID.Equals(callerId)) return true; @@ -268,7 +236,7 @@ return false; } - public Caller GetCaller(Caller caller) + public static Caller GetCaller(Caller caller) { if (caller.ID == "") return caller; Modified: trunk/plugins/FritzBox/FritzBox.xmp =================================================================== --- trunk/plugins/FritzBox/FritzBox.xmp 2008-08-07 11:26:02 UTC (rev 2007) +++ trunk/plugins/FritzBox/FritzBox.xmp 2008-08-07 17:28:35 UTC (rev 2008) @@ -8,7 +8,7 @@ <Source>FritzBox\gfx\Thumbs\YAC\_noImage.png</Source> <Id>04010</Id> <Option>OutputFileName=|DefaultFile=False|</Option> - <Guid>d666735b-206e-48a9-be1c-95b38102d5fe</Guid> + <Guid>f474cf67-d85f-4593-b0dc-75c0ab015654</Guid> </File> <File> <FileName>_unknown.png</FileName> @@ -17,7 +17,7 @@ <Source>FritzBox\gfx\Thumbs\YAC\_unknown.png</Source> <Id>04010</Id> <Option /> - <Guid>2a655c5d-c556-47ba-8392-9dc0d3b438dd</Guid> + <Guid>5e4d6f98-6a73-4f59-92a2-a115cbc3ae65</Guid> </File> <File> <FileName>FritzBox.dll</FileName> @@ -26,7 +26,7 @@ <Source>FritzBox\bin\Release\FritzBox.dll</Source> <Id>01020</Id> <Option /> - <Guid>259204ab-d64b-40d6-82cf-761972fa3fa2</Guid> + <Guid>0647a912-d220-4940-9db8-f065ae6c6ca8</Guid> </File> </FileList> <StringList /> @@ -36,14 +36,16 @@ <SetupGroups /> <SetupGroupMappings /> <Option> - <BuildFileName>D:\mediaportal\mediaportal_plugins\FritzBox\FritzBox_v0.3.1.1.mpi</BuildFileName> + <BuildFileName>D:\mediaportal\mediaportal_plugins\FritzBox\FritzBox_v0.3.1.5.mpi</BuildFileName> <ProiectFileName>D:\mediaportal\mediaportal_plugins\FritzBox\FritzBox.xmp</ProiectFileName> - <ProiectName>FritzBox CallMonitor</ProiectName> + <ProiectName>FRITZ!Box CallMonitor</ProiectName> <Author>chefkoch @ Team MediaPortal</Author> - <UpdateURL>http://mpi.team-mediaportal.com/downloads</UpdateURL> - <Version>0.3.1.1</Version> - <Description>The FRITZ!Box plugin is a process plugin, which is able to notify you within MediaPortal on an incomming call on your FRITZ!Box. + <UpdateURL>http://www.team-mediaportal.com/files/Download/MediaPortalInstaller(MPI)/Input/FRITZ!BoxCallMonitor/</UpdateURL> + <Version>0.3.2.0</Version> + <Description>TEST version - mit Reconnect feature ;-) +The FRITZ!Box plugin is a process plugin, which is able to notify you within MediaPortal on an incomming call on your FRITZ!Box. + All strings are multi language. You will be informed with a small notify. It is possible to stop media playback automatically or to resume if you close the notify. You can specify your MSNs now, for which the notify should be shown. That avoids showing the notify when you get a fax. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |