From: <che...@us...> - 2007-06-24 07:22:10
|
Revision: 610 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=610&view=rev Author: chef_koch Date: 2007-06-24 00:22:08 -0700 (Sun, 24 Jun 2007) Log Message: ----------- huge code changes Modified Paths: -------------- trunk/plugins/FritzBox/FritzBox/Caller.cs trunk/plugins/FritzBox/FritzBox/FritzBox.cs trunk/plugins/FritzBox/FritzBox/FritzBox.csproj trunk/plugins/FritzBox/FritzBox/FritzBoxSetupFrom.Designer.cs trunk/plugins/FritzBox/FritzBox/FritzBoxSetupFrom.cs trunk/plugins/FritzBox/FritzBox/FritzBoxWatch.cs Added Paths: ----------- trunk/plugins/FritzBox/FritzBox/CallAction.cs trunk/plugins/FritzBox/FritzBox/bin/ trunk/plugins/FritzBox/FritzBox/bin/Release/ Added: trunk/plugins/FritzBox/FritzBox/CallAction.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/CallAction.cs (rev 0) +++ trunk/plugins/FritzBox/FritzBox/CallAction.cs 2007-06-24 07:22:08 UTC (rev 610) @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace FritzBox +{ + public class CallAction + { + public enum CallType + { + Incoming, + Outgoing, + ConnectionStarted, + ConnectionClosed, + } + + public CallType type; + public DateTime time = DateTime.MinValue; + public Caller caller = new Caller(); + public string msn = string.Empty; + } +} Modified: trunk/plugins/FritzBox/FritzBox/Caller.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/Caller.cs 2007-06-23 16:19:44 UTC (rev 609) +++ trunk/plugins/FritzBox/FritzBox/Caller.cs 2007-06-24 07:22:08 UTC (rev 610) @@ -39,7 +39,7 @@ { this._id = ""; this._name = ""; - this._show = false; + this._show = true; } public Caller(string id, string name, bool show) Modified: trunk/plugins/FritzBox/FritzBox/FritzBox.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBox.cs 2007-06-23 16:19:44 UTC (rev 609) +++ trunk/plugins/FritzBox/FritzBox/FritzBox.cs 2007-06-24 07:22:08 UTC (rev 610) @@ -54,13 +54,15 @@ public static int _lastVersion = 0; public static bool _extensiveLogging = false; - FritzBoxWatch FritzBoxWatch; - private bool _fritzBoxDisabled = false; + List<CallAction> actionList = new List<CallAction>(); + object tempNotify = null; + // notify settings private int _timeout = -1; // autoclose the dialog after the timeout expired private bool _closeOnTimeout = false; + private bool _closeOnConnectionClosed = false; public static bool _filterMSNs = false; public static List<String> _msnList = new List<String>(); @@ -72,7 +74,7 @@ private bool _resumeMedia = true; // resume media when notify is closed private bool _showNotify = true; - private List<String> notifyQueue = new List<String>(); + private List<CallAction> notifyQueue = new List<CallAction>(); // phonebook settings public static bool _usePhonebook = true; @@ -104,15 +106,16 @@ { _lastVersion = xmlreader.GetValueAsInt("fritzbox", "lastVersion", 0); - _extensiveLogging = xmlreader.GetValueAsBool("fritzbox", "extensiveLogging", false); - FritzBoxWatch.fritzBoxAddress = xmlreader.GetValueAsString("fritzbox", "address", "fritz.box"); - FritzBoxWatch.fritzBoxPort = xmlreader.GetValueAsString("fritzbox", "port", "1012"); + FritzBoxWatch.fritzBoxPort = xmlreader.GetValueAsInt("fritzbox", "port", 1012); + _extensiveLogging = xmlreader.GetValueAsBool("fritzbox", "extensiveLogging", false); + // notify settings FritzBoxWatch.maxNotifies = xmlreader.GetValueAsInt("fritzbox", "maxNotifies", 20); _closeOnTimeout = xmlreader.GetValueAsBool("fritzbox", "closeOnTimeout", false); _timeout = xmlreader.GetValueAsInt("fritzbox", "timeout", 10); + _closeOnConnectionClosed = xmlreader.GetValueAsBool("fritzbox", "closeOnConnectionClosed", true); if ((!_closeOnTimeout) || (_timeout == 0)) _timeout = -1; @@ -140,7 +143,7 @@ Log.Info("FRITZ!Box: closeOnTimeout = {0}", _closeOnTimeout.ToString()); Log.Info("FRITZ!Box: timeout = {0}", _timeout.ToString()); Log.Info("FRITZ!Box: showMsnOnHeading = {0}", _showMsnOnHeading.ToString()); - Log.Info("FRITZ!Box: maxNotifies = {0}", FritzBoxWatch.maxNotifies.ToString()); + //Log.Info("FRITZ!Box: maxNotifies = {0}", FritzBoxWatch.maxNotifies.ToString()); Log.Info("FRITZ!Box: stopMedia = {0}", _stopMedia.ToString()); Log.Info("FRITZ!Box: resumeMedia = {0}", _resumeMedia.ToString()); @@ -302,208 +305,192 @@ #region FritzBoxActions - private void OnFritzBoxEvent(string dataStream) + public void OnCallAction(CallAction callAction) { + LogAction(callAction); + if (!_showNotify) { Log.Info("External process is running. Notify is queued and will be shown later."); - notifyQueue.Add(dataStream); + notifyQueue.Add(callAction); return; } - string[] strList; // splitted 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 - - dataStream = dataStream.Replace("\n", ""); - if (FritzBox._extensiveLogging) - Log.Info("received data: {0}", dataStream); - strList = dataStream.Split(';'); - - switch (strList[1]) + switch (callAction.type) { - case "RING": - OnIncomingCall(strList[0], strList[3], strList[4]); + case CallAction.CallType.Incoming: + OnIncomingCall(callAction); break; - - case "CALL": - OnOutgoingCall(strList[0], strList[3], strList[4], strList[5]); + case CallAction.CallType.Outgoing: break; - - case "CONNECT": - OnConnectionStarted(strList[0], strList[3], strList[4]); + case CallAction.CallType.ConnectionStarted: break; - - case "DISCONNECT": - OnConnectionClosed(strList[0], int.Parse(strList[3])); + case CallAction.CallType.ConnectionClosed: + if (_closeOnConnectionClosed) + { + Log.Info("_closeOnConnectionClosed is enabled. try to close active notify."); + if (tempNotify != null) + { + Action act = new Action(); + act.wID = Action.ActionType.ACTION_CLOSE_DIALOG; + GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY).OnAction(act); + } + } break; } - FritzBoxWatch.notifyCount--; + } - private void OnIncomingCall(string dateTime, string callerId, string msn) + void OnIncomingCall(CallAction callAction) { - Log.Info("incoming call:"); - Log.Info(" DateTime: {0}", dateTime); - if (FritzBox._extensiveLogging) + if (tempNotify != null) { - Log.Info(" Caller: {0}", callerId); - Log.Info(" MSN: {0}", msn); + Log.Info("yet another dialog is active. action is sent to queue."); + if (actionList.Count < FritzBoxWatch.maxNotifies - 1) + actionList.Add(callAction); + return; } - if (!IsMsnEnabled(msn)) return; + //config settings for dialog + string strHeading = String.Empty; + string strImage = String.Empty; + string strText = String.Empty; + + // Set Heading for NotifyDialog + if (_showMsnOnHeading) + strHeading = GUILocalizeStrings.Get(1023) + " on " + callAction.msn; // ???? Incoming call on + else + strHeading = GUILocalizeStrings.Get(1023); // 1023 Incoming call - if (callerId == "") - { - Log.Info("Caller is not identified by CLIP."); - - if (FritzBox._showUnknownCaller) - DialogOnIncomingCall("", msn); - } + // Set Image for NotifyDialog + strImage = GetCallerImage(callAction.caller); + + // Set MessageText for NotifyDialog + if (callAction.caller.ID == "") + strText = GUILocalizeStrings.Get(2014); // 2014 = unknown + else if (callAction.caller.Name == "") + strText = callAction.caller.ID; else - { - if (FritzBox._usePhonebook) - { - bool foundCaller = false; + strText = callAction.caller.Name; - 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; + //config settings for dialog FINISHED + + //if msn is disabled, stop here + if (!IsMsnEnabled(callAction.msn)) return; - do - { - Caller caller = phonebook[i]; + //if notifies are disabled for this call, stop here + if (!IsCallerEnabled(callAction.caller)) return; - if (caller.ID.Equals(callerId)) - { - Log.Info("Caller is identified by phonebook as {0}.", caller.Name); - foundCaller = true; + ShowNotify(strHeading, strImage, strText); + } - if (caller.Show) - { - Log.Info("Caller is accepted by phonebook and dialog will be shown."); + #endregion - DialogOnIncomingCall(caller.Name, msn); - } - else - { - Log.Info("Caller is denied by phonebook and dialog won't be shown."); - } - } - i++; - } - while (!foundCaller && (i < phonebook.Count)); + #region Helper Methods - if (!foundCaller) - { - Log.Info("Caller is not identified by phonebook."); + Caller GetCallerFromPhonebook(Caller caller) + { + if (caller.ID == "") return caller; - 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); - } - - if (FritzBox._showUnknownCaller) - { - Log.Info("showUnknownCallers is ON - Caller is shown."); - - DialogOnIncomingCall(callerId, msn); - } - } - + if (phonebook.Count == 0) + { + Log.Info("Phonebook is empty. Caller is added to the phonebook."); + phonebook.Add(caller); + } + else + { + bool foundCaller = false; + for (int i = 0; i < phonebook.Count; i++) + { + Caller tempCaller = phonebook[i]; + if (tempCaller.ID == caller.ID) + { + Log.Info("Caller is identified by phonebook as {0}.", tempCaller.Name); + caller = tempCaller; + foundCaller = true; } + if (foundCaller) break; } - else - DialogOnIncomingCall(callerId, msn); - } - } - private void OnOutgoingCall(string dateTime, string nebenstelle, string msn, string callerId) - { - Log.Info("outgoing call:"); - Log.Info(" DateTime: {0}", dateTime); - if (FritzBox._extensiveLogging) - { - Log.Info(" Nebenstelle: {0}", nebenstelle); - Log.Info(" MSN: {0}", msn); - Log.Info(" Caller: {0}", callerId); - } - } + if (!foundCaller) + { + if (_showUnknownCaller) + caller.Show = true; + else + caller.Show = false; - private void OnConnectionStarted(string dateTime, string nebenstelle, string callerId) - { - Log.Info("connection started:"); - Log.Info(" DateTime: {0}", dateTime); - if (FritzBox._extensiveLogging) - { - Log.Info(" Nebenstelle: {0}", nebenstelle); - Log.Info(" Caller: {0}", callerId); + if (FritzBox._saveUnknownCaller) + phonebook.Add(caller); + } } - } - private void OnConnectionClosed(string dateTime, int connectedTime) - { - Log.Info("connection closed:"); - Log.Info(" DateTime: {0}", dateTime); - Log.Info(" conneted time (in s): {0}", connectedTime.ToString()); + return caller; } - #endregion - - void DialogOnIncomingCall(string strCallerId, string strMSN) + string GetCallerImage(Caller caller) { - string strImage = null; - string strHeading = null; - - if (strCallerId == "") - { - strCallerId = GUILocalizeStrings.Get(2014); // 2014 = unknown - strImage = MediaPortal.Util.Utils.GetCoverArt(Thumbs.Yac, "_unknown"); - } + if (caller.ID == "") + return MediaPortal.Util.Utils.GetCoverArt(Thumbs.Yac, "_unknown"); else { - //search image for caller - if (_extensiveLogging) - Log.Info("searching image: " + MediaPortal.Util.Utils.GetCoverArtName(Thumbs.Yac, strCallerId)); + string strImage = MediaPortal.Util.Utils.GetCoverArtName(Thumbs.Yac, caller.ID); - if (File.Exists(MediaPortal.Util.Utils.GetCoverArt(Thumbs.Yac, strCallerId))) + // search image for caller + if (_extensiveLogging) + Log.Info("searching image: " + strImage); + + if (File.Exists(strImage)) { if (_extensiveLogging) - Log.Info("found image for caller: " + MediaPortal.Util.Utils.GetCoverArt(Thumbs.Yac, strCallerId)); + Log.Info("found image for caller: " + strImage); else Log.Info("found image for caller"); - strImage = MediaPortal.Util.Utils.GetCoverArt(Thumbs.Yac, strCallerId); + return strImage; } else { Log.Info("found NO image for caller"); - strImage = MediaPortal.Util.Utils.GetCoverArt(Thumbs.Yac, "_noImage"); + return MediaPortal.Util.Utils.GetCoverArt(Thumbs.Yac, "_noImage"); } } + } - if (_showMsnOnHeading) - strHeading = GUILocalizeStrings.Get(1023) + " on " + strMSN; // ???? Incoming call on + 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 - strHeading = GUILocalizeStrings.Get(1023); // 1023 Incoming call + { + Log.Info("MSN is not on list. Notify won't be shown."); + return false; + } + } + bool IsCallerEnabled(Caller caller) + { + if (!_usePhonebook) + { + Log.Info("Phonebook is disabled. Notify will be shown."); + return true; + } + else if (caller.Show) return true; + else return false; + } + + void ShowNotify(string strHeading, string strImage, string strText) + { + if (FritzBoxWatch.notifyCount >= FritzBoxWatch.maxNotifies) return; + //show dialog if (g_Player.Playing && !g_Player.Paused && _stopMedia) g_Player.Pause(); @@ -515,52 +502,35 @@ dlgNotify.ClearAll(); dlgNotify.SetHeading(strHeading); dlgNotify.SetImage(strImage); - dlgNotify.SetText(strCallerId); + dlgNotify.SetText(strText); dlgNotify.TimeOut = _timeout; + tempNotify = dlgNotify; dlgNotify.DoModal(GUIWindowManager.ActiveWindow); if (g_Player.Playing && g_Player.Paused && _stopMedia && _resumeMedia) g_Player.Pause(); - } - #region Helper Methods - - public bool IsFritzBoxConnected(string fritzBoxAddress, string fritzBoxPort) - { - TcpClient TcpClient; - - try + tempNotify = null; + if (actionList.Count > 0) { - TcpClient = new TcpClient(fritzBoxAddress, Int32.Parse(fritzBoxPort)); + CallAction tmpAction = actionList[0]; + actionList.RemoveAt(0); + OnCallAction(tmpAction); } - catch (Exception) - { - return false; - } - - TcpClient.Close(); - return true; } - private bool IsMsnEnabled(string msn) + public void LogAction(CallAction action) { - if (!_filterMSNs) + Log.Info("CallAction Info:"); + Log.Info(" CallType: {0}", action.type.ToString()); + Log.Info(" Date: {0}", action.time.ToShortDateString()); + Log.Info(" Time: {0}", action.time.ToShortTimeString()); + if (_extensiveLogging) { - Log.Info("MSN filter is disabled."); - return true; + Log.Info(" Caller: {0}", action.caller.ID); + Log.Info(" MSN: {0}", action.msn); } - - 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 @@ -600,15 +570,16 @@ public void Start() { Log.Info("FRITZ!Box Plugin {0} starting.", _version); - - FritzBoxWatch = new FritzBoxWatch(); LoadSettings(); - FritzBoxWatch.Start(); - FritzBoxWatch.FritzBoxAction += new FritzBoxWatch.EventHandler(OnFritzBoxEvent); - Utils.OnStartExternal += new Utils.UtilEventHandler(OnStartExternal); Utils.OnStopExternal += new Utils.UtilEventHandler(OnStopExternal); + + FritzBoxWatch.FritzBoxAction += new FritzBoxWatch.EventHandler(OnCallAction); + Thread FBWatchThread = new Thread(new ThreadStart(FritzBoxWatch.WatchThread)); + FBWatchThread.Priority = ThreadPriority.BelowNormal; + FBWatchThread.Name = "FRITZ!Box Monitoring"; + FBWatchThread.Start(); } /// <summary> Modified: trunk/plugins/FritzBox/FritzBox/FritzBox.csproj =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBox.csproj 2007-06-23 16:19:44 UTC (rev 609) +++ trunk/plugins/FritzBox/FritzBox/FritzBox.csproj 2007-06-24 07:22:08 UTC (rev 610) @@ -70,6 +70,7 @@ </ItemGroup> <ItemGroup> <Compile Include="Caller.cs" /> + <Compile Include="CallAction.cs" /> <Compile Include="FritzBoxSetupFrom.cs"> <SubType>Form</SubType> </Compile> @@ -86,7 +87,6 @@ </ItemGroup> <ItemGroup> <EmbeddedResource Include="Properties\Resources.resx"> - <SubType>Designer</SubType> <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> Modified: trunk/plugins/FritzBox/FritzBox/FritzBoxSetupFrom.Designer.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBoxSetupFrom.Designer.cs 2007-06-23 16:19:44 UTC (rev 609) +++ trunk/plugins/FritzBox/FritzBox/FritzBoxSetupFrom.Designer.cs 2007-06-24 07:22:08 UTC (rev 610) @@ -33,8 +33,9 @@ this.tabGeneral = new System.Windows.Forms.TabPage(); this.checkBoxExtensiveLogging = new MediaPortal.UserInterface.Controls.MPCheckBox(); this.mpGroupBox1 = new MediaPortal.UserInterface.Controls.MPGroupBox(); + this.numericUpDownPort = new System.Windows.Forms.NumericUpDown(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.buttonTest = new MediaPortal.UserInterface.Controls.MPButton(); - this.textBoxPort = new MediaPortal.UserInterface.Controls.MPTextBox(); this.textBoxAddress = new MediaPortal.UserInterface.Controls.MPTextBox(); this.labelPort = new MediaPortal.UserInterface.Controls.MPLabel(); this.labelAddress = new MediaPortal.UserInterface.Controls.MPLabel(); @@ -46,6 +47,9 @@ this.checkBoxShowUnknownCaller = new MediaPortal.UserInterface.Controls.MPCheckBox(); this.checkBoxUsePhonebook = new MediaPortal.UserInterface.Controls.MPCheckBox(); this.groupBoxNotify = new MediaPortal.UserInterface.Controls.MPGroupBox(); + this.checkBoxCloseOnConnectionClosed = new MediaPortal.UserInterface.Controls.MPCheckBox(); + this.lblMaxNotifies = new MediaPortal.UserInterface.Controls.MPLabel(); + this.numericUpDownMaxNotifies = new MediaPortal.UserInterface.Controls.MPNumericUpDown(); this.checkBoxShowMsnOnHeading = new MediaPortal.UserInterface.Controls.MPCheckBox(); this.buttonMSNsRemove = new MediaPortal.UserInterface.Controls.MPButton(); this.checkBoxFilterMSNs = new MediaPortal.UserInterface.Controls.MPCheckBox(); @@ -57,6 +61,7 @@ this.checkBoxResumeMedia = new MediaPortal.UserInterface.Controls.MPCheckBox(); this.checkBoxStopMedia = new MediaPortal.UserInterface.Controls.MPCheckBox(); this.tabPhonebook = new System.Windows.Forms.TabPage(); + this.pictureBoxCaller = new System.Windows.Forms.PictureBox(); this.buttonCallerChange = new MediaPortal.UserInterface.Controls.MPButton(); this.checkBoxCallerShow = new MediaPortal.UserInterface.Controls.MPCheckBox(); this.textBoxCallerName = new MediaPortal.UserInterface.Controls.MPTextBox(); @@ -72,23 +77,20 @@ this.buttonSave = new MediaPortal.UserInterface.Controls.MPButton(); this.buttonCancel = new MediaPortal.UserInterface.Controls.MPButton(); this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.pictureBoxCaller = new System.Windows.Forms.PictureBox(); - this.upDownMaxNotifies = new MediaPortal.UserInterface.Controls.MPNumericUpDown(); - this.lblMaxNotifies = new MediaPortal.UserInterface.Controls.MPLabel(); this.tabControlFritzBoxSettings.SuspendLayout(); this.tabGeneral.SuspendLayout(); this.mpGroupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPort)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.tabIncoming.SuspendLayout(); this.groupBoxPhonebook.SuspendLayout(); this.groupBoxNotify.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxNotifies)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeout)).BeginInit(); this.groupBoxMedia.SuspendLayout(); this.tabPhonebook.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCaller)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCaller)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.upDownMaxNotifies)).BeginInit(); this.SuspendLayout(); // // tabControlFritzBoxSettings @@ -102,7 +104,7 @@ this.tabControlFritzBoxSettings.Location = new System.Drawing.Point(11, 12); this.tabControlFritzBoxSettings.Name = "tabControlFritzBoxSettings"; this.tabControlFritzBoxSettings.SelectedIndex = 0; - this.tabControlFritzBoxSettings.Size = new System.Drawing.Size(531, 337); + this.tabControlFritzBoxSettings.Size = new System.Drawing.Size(581, 383); this.tabControlFritzBoxSettings.TabIndex = 14; // // tabGeneral @@ -112,7 +114,7 @@ this.tabGeneral.Location = new System.Drawing.Point(4, 22); this.tabGeneral.Name = "tabGeneral"; this.tabGeneral.Padding = new System.Windows.Forms.Padding(3); - this.tabGeneral.Size = new System.Drawing.Size(523, 311); + this.tabGeneral.Size = new System.Drawing.Size(573, 357); this.tabGeneral.TabIndex = 0; this.tabGeneral.Text = "General"; this.tabGeneral.UseVisualStyleBackColor = true; @@ -132,9 +134,9 @@ // this.mpGroupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.mpGroupBox1.Controls.Add(this.numericUpDownPort); this.mpGroupBox1.Controls.Add(this.pictureBox1); this.mpGroupBox1.Controls.Add(this.buttonTest); - this.mpGroupBox1.Controls.Add(this.textBoxPort); this.mpGroupBox1.Controls.Add(this.textBoxAddress); this.mpGroupBox1.Controls.Add(this.labelPort); this.mpGroupBox1.Controls.Add(this.labelAddress); @@ -142,15 +144,43 @@ this.mpGroupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.mpGroupBox1.Location = new System.Drawing.Point(6, 6); this.mpGroupBox1.Name = "mpGroupBox1"; - this.mpGroupBox1.Size = new System.Drawing.Size(511, 125); + this.mpGroupBox1.Size = new System.Drawing.Size(561, 125); this.mpGroupBox1.TabIndex = 0; this.mpGroupBox1.TabStop = false; this.mpGroupBox1.Text = "connection"; // + // numericUpDownPort + // + this.numericUpDownPort.Location = new System.Drawing.Point(308, 47); + this.numericUpDownPort.Maximum = new decimal(new int[] { + 999999, + 0, + 0, + 0}); + this.numericUpDownPort.Name = "numericUpDownPort"; + this.numericUpDownPort.Size = new System.Drawing.Size(116, 21); + this.numericUpDownPort.TabIndex = 9; + this.numericUpDownPort.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.numericUpDownPort.Value = new decimal(new int[] { + 1012, + 0, + 0, + 0}); + // + // pictureBox1 + // + this.pictureBox1.Image = global::FritzBox.Properties.Resources.FritzBox; + this.pictureBox1.Location = new System.Drawing.Point(6, 20); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(97, 99); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pictureBox1.TabIndex = 2; + this.pictureBox1.TabStop = false; + // // buttonTest // this.buttonTest.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonTest.Location = new System.Drawing.Point(430, 20); + this.buttonTest.Location = new System.Drawing.Point(480, 20); this.buttonTest.Name = "buttonTest"; this.buttonTest.Size = new System.Drawing.Size(75, 21); this.buttonTest.TabIndex = 2; @@ -158,16 +188,6 @@ this.buttonTest.UseVisualStyleBackColor = true; this.buttonTest.Click += new System.EventHandler(this.buttonTest_Click); // - // textBoxPort - // - this.textBoxPort.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxPort.BorderColor = System.Drawing.Color.Empty; - this.textBoxPort.Location = new System.Drawing.Point(165, 47); - this.textBoxPort.Name = "textBoxPort"; - this.textBoxPort.Size = new System.Drawing.Size(259, 21); - this.textBoxPort.TabIndex = 1; - // // textBoxAddress // this.textBoxAddress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -175,7 +195,7 @@ this.textBoxAddress.BorderColor = System.Drawing.Color.Empty; this.textBoxAddress.Location = new System.Drawing.Point(165, 20); this.textBoxAddress.Name = "textBoxAddress"; - this.textBoxAddress.Size = new System.Drawing.Size(259, 21); + this.textBoxAddress.Size = new System.Drawing.Size(309, 21); this.textBoxAddress.TabIndex = 0; // // labelPort @@ -203,7 +223,7 @@ | System.Windows.Forms.AnchorStyles.Right))); this.labelHelp.Location = new System.Drawing.Point(165, 73); this.labelHelp.Name = "labelHelp"; - this.labelHelp.Size = new System.Drawing.Size(340, 49); + this.labelHelp.Size = new System.Drawing.Size(390, 49); this.labelHelp.TabIndex = 6; // // tabIncoming @@ -214,7 +234,7 @@ this.tabIncoming.Location = new System.Drawing.Point(4, 22); this.tabIncoming.Name = "tabIncoming"; this.tabIncoming.Padding = new System.Windows.Forms.Padding(3); - this.tabIncoming.Size = new System.Drawing.Size(523, 311); + this.tabIncoming.Size = new System.Drawing.Size(573, 357); this.tabIncoming.TabIndex = 1; this.tabIncoming.Text = "Incoming Call"; this.tabIncoming.UseVisualStyleBackColor = true; @@ -230,7 +250,7 @@ this.groupBoxPhonebook.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.groupBoxPhonebook.Location = new System.Drawing.Point(6, 208); this.groupBoxPhonebook.Name = "groupBoxPhonebook"; - this.groupBoxPhonebook.Size = new System.Drawing.Size(511, 95); + this.groupBoxPhonebook.Size = new System.Drawing.Size(561, 95); this.groupBoxPhonebook.TabIndex = 2; this.groupBoxPhonebook.TabStop = false; this.groupBoxPhonebook.Text = "phonebook settings"; @@ -238,7 +258,7 @@ // mpImportFBMonitor // this.mpImportFBMonitor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.mpImportFBMonitor.Location = new System.Drawing.Point(355, 20); + this.mpImportFBMonitor.Location = new System.Drawing.Point(405, 20); this.mpImportFBMonitor.Name = "mpImportFBMonitor"; this.mpImportFBMonitor.Size = new System.Drawing.Size(150, 23); this.mpImportFBMonitor.TabIndex = 3; @@ -284,8 +304,9 @@ // this.groupBoxNotify.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxNotify.Controls.Add(this.checkBoxCloseOnConnectionClosed); this.groupBoxNotify.Controls.Add(this.lblMaxNotifies); - this.groupBoxNotify.Controls.Add(this.upDownMaxNotifies); + this.groupBoxNotify.Controls.Add(this.numericUpDownMaxNotifies); this.groupBoxNotify.Controls.Add(this.checkBoxShowMsnOnHeading); this.groupBoxNotify.Controls.Add(this.buttonMSNsRemove); this.groupBoxNotify.Controls.Add(this.checkBoxFilterMSNs); @@ -296,16 +317,60 @@ this.groupBoxNotify.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.groupBoxNotify.Location = new System.Drawing.Point(6, 6); this.groupBoxNotify.Name = "groupBoxNotify"; - this.groupBoxNotify.Size = new System.Drawing.Size(511, 122); + this.groupBoxNotify.Size = new System.Drawing.Size(561, 122); this.groupBoxNotify.TabIndex = 0; this.groupBoxNotify.TabStop = false; this.groupBoxNotify.Text = "notify settings"; // + // checkBoxCloseOnConnectionClosed + // + this.checkBoxCloseOnConnectionClosed.AutoSize = true; + this.checkBoxCloseOnConnectionClosed.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.checkBoxCloseOnConnectionClosed.Location = new System.Drawing.Point(6, 43); + this.checkBoxCloseOnConnectionClosed.Name = "checkBoxCloseOnConnectionClosed"; + this.checkBoxCloseOnConnectionClosed.Size = new System.Drawing.Size(199, 17); + this.checkBoxCloseOnConnectionClosed.TabIndex = 9; + this.checkBoxCloseOnConnectionClosed.Text = "auto-close after connection is closed"; + this.checkBoxCloseOnConnectionClosed.UseVisualStyleBackColor = true; + this.checkBoxCloseOnConnectionClosed.CheckedChanged += new System.EventHandler(this.checkBoxCloseOnConnectionClosed_CheckedChanged); + // + // lblMaxNotifies + // + this.lblMaxNotifies.AutoSize = true; + this.lblMaxNotifies.Location = new System.Drawing.Point(21, 68); + this.lblMaxNotifies.Name = "lblMaxNotifies"; + this.lblMaxNotifies.Size = new System.Drawing.Size(94, 13); + this.lblMaxNotifies.TabIndex = 8; + this.lblMaxNotifies.Text = "maximum Notifies:"; + // + // numericUpDownMaxNotifies + // + this.numericUpDownMaxNotifies.Location = new System.Drawing.Point(206, 66); + this.numericUpDownMaxNotifies.Maximum = new decimal(new int[] { + 20, + 0, + 0, + 0}); + this.numericUpDownMaxNotifies.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numericUpDownMaxNotifies.Name = "numericUpDownMaxNotifies"; + this.numericUpDownMaxNotifies.Size = new System.Drawing.Size(53, 21); + this.numericUpDownMaxNotifies.TabIndex = 7; + this.numericUpDownMaxNotifies.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.numericUpDownMaxNotifies.Value = new decimal(new int[] { + 20, + 0, + 0, + 0}); + // // checkBoxShowMsnOnHeading // this.checkBoxShowMsnOnHeading.AutoSize = true; this.checkBoxShowMsnOnHeading.FlatStyle = System.Windows.Forms.FlatStyle.Popup; - this.checkBoxShowMsnOnHeading.Location = new System.Drawing.Point(6, 99); + this.checkBoxShowMsnOnHeading.Location = new System.Drawing.Point(6, 93); this.checkBoxShowMsnOnHeading.Name = "checkBoxShowMsnOnHeading"; this.checkBoxShowMsnOnHeading.Size = new System.Drawing.Size(161, 17); this.checkBoxShowMsnOnHeading.TabIndex = 6; @@ -315,7 +380,7 @@ // buttonMSNsRemove // this.buttonMSNsRemove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonMSNsRemove.Location = new System.Drawing.Point(275, 72); + this.buttonMSNsRemove.Location = new System.Drawing.Point(492, 95); this.buttonMSNsRemove.Name = "buttonMSNsRemove"; this.buttonMSNsRemove.Size = new System.Drawing.Size(63, 21); this.buttonMSNsRemove.TabIndex = 5; @@ -327,7 +392,7 @@ // this.checkBoxFilterMSNs.AutoSize = true; this.checkBoxFilterMSNs.FlatStyle = System.Windows.Forms.FlatStyle.Popup; - this.checkBoxFilterMSNs.Location = new System.Drawing.Point(6, 49); + this.checkBoxFilterMSNs.Location = new System.Drawing.Point(361, 43); this.checkBoxFilterMSNs.Name = "checkBoxFilterMSNs"; this.checkBoxFilterMSNs.Size = new System.Drawing.Size(194, 17); this.checkBoxFilterMSNs.TabIndex = 2; @@ -338,7 +403,7 @@ // buttonMSNsAdd // this.buttonMSNsAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonMSNsAdd.Location = new System.Drawing.Point(206, 72); + this.buttonMSNsAdd.Location = new System.Drawing.Point(423, 95); this.buttonMSNsAdd.Name = "buttonMSNsAdd"; this.buttonMSNsAdd.Size = new System.Drawing.Size(63, 21); this.buttonMSNsAdd.TabIndex = 4; @@ -352,9 +417,9 @@ | System.Windows.Forms.AnchorStyles.Right))); this.comboBoxMSNs.BorderColor = System.Drawing.Color.Empty; this.comboBoxMSNs.FormattingEnabled = true; - this.comboBoxMSNs.Location = new System.Drawing.Point(24, 72); + this.comboBoxMSNs.Location = new System.Drawing.Point(329, 68); this.comboBoxMSNs.Name = "comboBoxMSNs"; - this.comboBoxMSNs.Size = new System.Drawing.Size(176, 21); + this.comboBoxMSNs.Size = new System.Drawing.Size(226, 21); this.comboBoxMSNs.Sorted = true; this.comboBoxMSNs.TabIndex = 3; // @@ -398,7 +463,7 @@ this.groupBoxMedia.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.groupBoxMedia.Location = new System.Drawing.Point(6, 134); this.groupBoxMedia.Name = "groupBoxMedia"; - this.groupBoxMedia.Size = new System.Drawing.Size(511, 68); + this.groupBoxMedia.Size = new System.Drawing.Size(561, 68); this.groupBoxMedia.TabIndex = 1; this.groupBoxMedia.TabStop = false; this.groupBoxMedia.Text = "media settings"; @@ -440,11 +505,21 @@ this.tabPhonebook.Location = new System.Drawing.Point(4, 22); this.tabPhonebook.Name = "tabPhonebook"; this.tabPhonebook.Padding = new System.Windows.Forms.Padding(3); - this.tabPhonebook.Size = new System.Drawing.Size(523, 311); + this.tabPhonebook.Size = new System.Drawing.Size(573, 357); this.tabPhonebook.TabIndex = 2; this.tabPhonebook.Text = "Phonebook"; this.tabPhonebook.UseVisualStyleBackColor = true; // + // pictureBoxCaller + // + this.pictureBoxCaller.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBoxCaller.Location = new System.Drawing.Point(417, 38); + this.pictureBoxCaller.Name = "pictureBoxCaller"; + this.pictureBoxCaller.Size = new System.Drawing.Size(100, 122); + this.pictureBoxCaller.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBoxCaller.TabIndex = 13; + this.pictureBoxCaller.TabStop = false; + // // buttonCallerChange // this.buttonCallerChange.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); @@ -567,7 +642,7 @@ // labelVersion // this.labelVersion.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.labelVersion.Location = new System.Drawing.Point(295, 356); + this.labelVersion.Location = new System.Drawing.Point(345, 402); this.labelVersion.Name = "labelVersion"; this.labelVersion.Size = new System.Drawing.Size(85, 25); this.labelVersion.TabIndex = 17; @@ -576,7 +651,7 @@ // buttonSave // this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSave.Location = new System.Drawing.Point(386, 356); + this.buttonSave.Location = new System.Drawing.Point(436, 402); this.buttonSave.Name = "buttonSave"; this.buttonSave.Size = new System.Drawing.Size(75, 25); this.buttonSave.TabIndex = 15; @@ -587,7 +662,7 @@ // buttonCancel // this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.Location = new System.Drawing.Point(467, 356); + this.buttonCancel.Location = new System.Drawing.Point(517, 402); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(75, 25); this.buttonCancel.TabIndex = 16; @@ -595,63 +670,11 @@ this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); // - // pictureBox1 - // - this.pictureBox1.Image = global::FritzBox.Properties.Resources.FritzBox; - this.pictureBox1.Location = new System.Drawing.Point(6, 20); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(97, 99); - this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; - this.pictureBox1.TabIndex = 2; - this.pictureBox1.TabStop = false; - // - // pictureBoxCaller - // - this.pictureBoxCaller.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.pictureBoxCaller.Location = new System.Drawing.Point(417, 38); - this.pictureBoxCaller.Name = "pictureBoxCaller"; - this.pictureBoxCaller.Size = new System.Drawing.Size(100, 122); - this.pictureBoxCaller.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; - this.pictureBoxCaller.TabIndex = 13; - this.pictureBoxCaller.TabStop = false; - // - // upDownMaxNotifies - // - this.upDownMaxNotifies.Location = new System.Drawing.Point(465, 20); - this.upDownMaxNotifies.Maximum = new decimal(new int[] { - 20, - 0, - 0, - 0}); - this.upDownMaxNotifies.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.upDownMaxNotifies.Name = "upDownMaxNotifies"; - this.upDownMaxNotifies.Size = new System.Drawing.Size(40, 21); - this.upDownMaxNotifies.TabIndex = 7; - this.upDownMaxNotifies.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.upDownMaxNotifies.Value = new decimal(new int[] { - 20, - 0, - 0, - 0}); - // - // lblMaxNotifies - // - this.lblMaxNotifies.AutoSize = true; - this.lblMaxNotifies.Location = new System.Drawing.Point(365, 22); - this.lblMaxNotifies.Name = "lblMaxNotifies"; - this.lblMaxNotifies.Size = new System.Drawing.Size(94, 13); - this.lblMaxNotifies.TabIndex = 8; - this.lblMaxNotifies.Text = "maximum Notifies:"; - // // FritzBoxSetupFrom // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(552, 393); + this.ClientSize = new System.Drawing.Size(602, 439); this.Controls.Add(this.tabControlFritzBoxSettings); this.Controls.Add(this.labelVersion); this.Controls.Add(this.buttonSave); @@ -668,20 +691,21 @@ this.tabGeneral.PerformLayout(); this.mpGroupBox1.ResumeLayout(false); this.mpGroupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPort)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.tabIncoming.ResumeLayout(false); this.groupBoxPhonebook.ResumeLayout(false); this.groupBoxPhonebook.PerformLayout(); this.groupBoxNotify.ResumeLayout(false); this.groupBoxNotify.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxNotifies)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTimeout)).EndInit(); this.groupBoxMedia.ResumeLayout(false); this.groupBoxMedia.PerformLayout(); this.tabPhonebook.ResumeLayout(false); this.tabPhonebook.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCaller)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCaller)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.upDownMaxNotifies)).EndInit(); this.ResumeLayout(false); } @@ -694,7 +718,6 @@ private MediaPortal.UserInterface.Controls.MPGroupBox mpGroupBox1; private System.Windows.Forms.PictureBox pictureBox1; private MediaPortal.UserInterface.Controls.MPButton buttonTest; - private MediaPortal.UserInterface.Controls.MPTextBox textBoxPort; private MediaPortal.UserInterface.Controls.MPTextBox textBoxAddress; private MediaPortal.UserInterface.Controls.MPLabel labelPort; private MediaPortal.UserInterface.Controls.MPLabel labelAddress; @@ -733,7 +756,9 @@ private MediaPortal.UserInterface.Controls.MPButton buttonSave; private MediaPortal.UserInterface.Controls.MPButton buttonCancel; private System.Windows.Forms.OpenFileDialog openFileDialog; - private MediaPortal.UserInterface.Controls.MPNumericUpDown upDownMaxNotifies; + private MediaPortal.UserInterface.Controls.MPNumericUpDown numericUpDownMaxNotifies; private MediaPortal.UserInterface.Controls.MPLabel lblMaxNotifies; + private System.Windows.Forms.NumericUpDown numericUpDownPort; + private MediaPortal.UserInterface.Controls.MPCheckBox checkBoxCloseOnConnectionClosed; } } \ No newline at end of file Modified: trunk/plugins/FritzBox/FritzBox/FritzBoxSetupFrom.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBoxSetupFrom.cs 2007-06-23 16:19:44 UTC (rev 609) +++ trunk/plugins/FritzBox/FritzBox/FritzBoxSetupFrom.cs 2007-06-24 07:22:08 UTC (rev 610) @@ -38,14 +38,18 @@ checkBoxExtensiveLogging.Checked = xmlreader.GetValueAsBool("fritzbox", "extensiveLogging", false); + Log.Info("1111111111111"); textBoxAddress.Text = xmlreader.GetValueAsString("fritzbox", "address", "fritz.box"); - textBoxPort.Text = xmlreader.GetValueAsString("fritzbox", "port", "1012"); + numericUpDownPort.Value = xmlreader.GetValueAsInt("fritzbox", "port", 1012); + Log.Info("22222222222222"); // notify settings - upDownMaxNotifies.Value = xmlreader.GetValueAsInt("fritzbox", "maxNotifies", 20); + numericUpDownMaxNotifies.Value = xmlreader.GetValueAsInt("fritzbox", "maxNotifies", 20); checkBoxCloseOnTimout.Checked = xmlreader.GetValueAsBool("fritzbox", "closeOnTimeout", false); numericUpDownTimeout.Value = xmlreader.GetValueAsInt("fritzbox", "timeout", 10); + checkBoxCloseOnConnectionClosed.Checked = xmlreader.GetValueAsBool("fritzbox", "closeOnConnectionClosed", true); + Log.Info("3333333333333333"); numericUpDownTimeout.Enabled = checkBoxCloseOnTimout.Checked; checkBoxFilterMSNs.Checked = xmlreader.GetValueAsBool("fritzbox", "filterMSNs", false); @@ -57,6 +61,7 @@ if (strMSN != "") comboBoxMSNs.Items.AddRange(strMSN.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries)); + Log.Info("444444444444444444"); checkBoxShowMsnOnHeading.Checked = xmlreader.GetValueAsBool("fritzbox", "showMsnOnHeading", false); // media settings @@ -86,12 +91,13 @@ xmlwriter.SetValueAsBool("fritzbox", "extensiveLogging", checkBoxExtensiveLogging.Checked); xmlwriter.SetValue("fritzbox", "address", textBoxAddress.Text); - xmlwriter.SetValue("fritzbox", "port", textBoxPort.Text); + xmlwriter.SetValue("fritzbox", "port", numericUpDownPort.Value); // notify settings - xmlwriter.SetValue("fritzbox", "maxNotifies", upDownMaxNotifies.Value); + xmlwriter.SetValue("fritzbox", "maxNotifies", numericUpDownMaxNotifies.Value); xmlwriter.SetValueAsBool("fritzbox", "closeOnTimeout", checkBoxCloseOnTimout.Checked); xmlwriter.SetValue("fritzbox", "timeout", numericUpDownTimeout.Value); + xmlwriter.SetValueAsBool("fritzbox", "closeOnConnectionClosed", checkBoxCloseOnConnectionClosed.Checked); xmlwriter.SetValueAsBool("fritzbox", "filterMSNs", checkBoxFilterMSNs.Checked); string strMSN = ""; @@ -149,7 +155,7 @@ { labelHelp.Text = "Please wait..."; Application.DoEvents(); - myClient = new TcpClient(textBoxAddress.Text, Int32.Parse(textBoxPort.Text)); + myClient = new TcpClient(textBoxAddress.Text, int.Parse(numericUpDownPort.Value.ToString())); } catch (Exception) { @@ -362,5 +368,10 @@ { SaveDataGridView(); } + + private void checkBoxCloseOnConnectionClosed_CheckedChanged(object sender, EventArgs e) + { + numericUpDownMaxNotifies.Enabled = !checkBoxCloseOnConnectionClosed.Checked; + } } } \ No newline at end of file Modified: trunk/plugins/FritzBox/FritzBox/FritzBoxWatch.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBoxWatch.cs 2007-06-23 16:19:44 UTC (rev 609) +++ trunk/plugins/FritzBox/FritzBox/FritzBoxWatch.cs 2007-06-24 07:22:08 UTC (rev 610) @@ -37,39 +37,27 @@ using System.Threading; using MediaPortal.GUI.Library; +using MediaPortal.Configuration; namespace FritzBox { - /// <summary> - /// FritzBoxWatch class - /// </summary> - public class FritzBoxWatch + /// <summary> + /// FritzBoxWatch class + /// </summary> + class FritzBoxWatch { - public delegate void EventHandler(string strLine); - static public event EventHandler FritzBoxAction = null; + public delegate void EventHandler(CallAction callAction); + public static event EventHandler FritzBoxAction = null; - bool stopThread = false; - + public static bool stopThread = false; public static string fritzBoxAddress; // address for the connected fritzbox - public static string fritzBoxPort; // port for the connected fritzbox - + public static int fritzBoxPort; // port for the connected fritzbox public static int maxNotifies = 20; public static int notifyCount = 0; - - public void Start() - { - Thread watchThread = new Thread(new ThreadStart(WatchThread)); - watchThread.Priority = ThreadPriority.BelowNormal; - watchThread.Name = "FRITZ!Box Monitoring"; - watchThread.Start(); - } - public void Stop() - { - stopThread = true; - } + static CallAction currentCallAction; - private void WatchThread() + public static void WatchThread() { try { @@ -82,7 +70,7 @@ // 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, Int32.Parse(fritzBoxPort)); + tcpClient = new TcpClient(fritzBoxAddress, fritzBoxPort); tcpClient.ReceiveBufferSize = 1; NetworkStream networkStream = tcpClient.GetStream(); @@ -98,11 +86,11 @@ } if (cChar == '\n') { - if (notifyCount < maxNotifies) - { - FritzBoxAction(strLine); - notifyCount++; - } + CallAction callAction = ParseAction(strLine); + currentCallAction = callAction; + Thread actionThread = new Thread(new ThreadStart(DoAction)); + actionThread.Name = "FRITZ!Box Monitoring"; + actionThread.Start(); strLine = ""; cChar = '\0'; } @@ -116,5 +104,84 @@ return; } } + + static CallAction ParseAction(string dataStream) + { + string[] strList; // splitted data + + dataStream = dataStream.Replace("\n", ""); + if (FritzBox._extensiveLogging) + Log.Info("received data: {0}", dataStream); + strList = dataStream.Split(';'); + + // 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 + + CallAction callAction = new CallAction(); + + // time when action happens + callAction.time = DateTime.Parse(strList[0]); + + // 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; + } + + return callAction; + } + + static void DoAction() + { + FritzBoxAction(currentCallAction); + } + + public static void Stop() + { + stopThread = true; + } + + public static bool Test() + { + TcpClient TcpClient; + + try + { + TcpClient = new TcpClient(fritzBoxAddress, fritzBoxPort); + } + catch (Exception) + { + return false; + } + + TcpClient.Close(); + return true; + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |