|
From: <che...@us...> - 2007-04-08 11:08:00
|
Revision: 296
http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=296&view=rev
Author: chef_koch
Date: 2007-04-08 04:07:48 -0700 (Sun, 08 Apr 2007)
Log Message:
-----------
phonebook entries are now saved in own fritzbox.xml
Modified Paths:
--------------
trunk/plugins/FritzBox/FritzBox.cs
trunk/plugins/FritzBox/FritzBoxSetupFrom.cs
Modified: trunk/plugins/FritzBox/FritzBox.cs
===================================================================
--- trunk/plugins/FritzBox/FritzBox.cs 2007-04-07 14:39:22 UTC (rev 295)
+++ trunk/plugins/FritzBox/FritzBox.cs 2007-04-08 11:07:48 UTC (rev 296)
@@ -74,8 +74,9 @@
#endregion
#region public Variables
-
- public const string _version = "0.2f";
+
+ public const string _version = "0.2.2.0";
+ public static int _lastVersion = 0;
public static bool _extensiveLogging = false;
// phonebook settings
@@ -108,6 +109,8 @@
using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
{
+ _lastVersion = xmlreader.GetValueAsInt("fritzbox", "lastVersion", 0);
+
_extensiveLogging = xmlreader.GetValueAsBool("fritzbox", "extensiveLogging", false);
FritzBoxWatch.fritzBoxAddress = xmlreader.GetValueAsString("fritzbox", "address", "fritz.box");
@@ -117,7 +120,7 @@
_closeOnTimeout = xmlreader.GetValueAsBool("fritzbox", "closeOnTimeout", false);
_timeout = xmlreader.GetValueAsInt("fritzbox", "timeout", 10);
- if ( (!_closeOnTimeout) || (_timeout == 0) )
+ if ((!_closeOnTimeout) || (_timeout == 0))
_timeout = -1;
_filterMSNs = xmlreader.GetValueAsBool("fritzbox", "filterMSNs", false);
@@ -132,12 +135,12 @@
// media settings
_stopMedia = xmlreader.GetValueAsBool("fritzbox", "stopMedia", true);
_resumeMedia = xmlreader.GetValueAsBool("fritzbox", "resumeMedia", true);
-
+
// phonebook settings
_usePhonebook = xmlreader.GetValueAsBool("fritzbox", "usePhonebook", true);
_showUnknownCaller = xmlreader.GetValueAsBool("fritzbox", "showUnknownCaller", true);
_saveUnknownCaller = xmlreader.GetValueAsBool("fritzbox", "saveUnknownCaller", true);
-
+
if (_extensiveLogging)
{
Log.Info("FRITZ!Box: closeOnTimeout = {0}", _closeOnTimeout.ToString());
@@ -151,26 +154,55 @@
Log.Info("FRITZ!Box: showUnknownCaller = {0}", _showUnknownCaller.ToString());
Log.Info("FRITZ!Box: saveUnknownCaller = {0}", _saveUnknownCaller.ToString());
}
+ }
- if (_usePhonebook)
+ if ((_lastVersion < 0220) && (!File.Exists(Config.GetFile(Config.Dir.Config, "fritzbox.xml"))))
+ UpdateTo0220();
+ else
+ using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "fritzbox.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);
+ int countCaller = xmlreader.GetValueAsInt("phonebook", "count", 0);
- for (int i = 0; i <= strLCallerId.GetUpperBound(0); i++)
+ for (int i = 0; i < countCaller; i++)
{
- Caller caller = new Caller(strLCallerId[i], strLName[i], bool.Parse(strLShow[i]));
+ string strCallerId = xmlreader.GetValueAsString("phonebook", string.Format("callerID{0}", i.ToString()), "");
+ string strName = xmlreader.GetValueAsString("phonebook", string.Format("name{0}", i.ToString()), "");
+ bool bShow = xmlreader.GetValueAsBool("phonebook", string.Format("show{0}", i.ToString()), false);
+
+ if (strCallerId == "") continue;
+ if (strCallerId == null) continue;
+ if (strName == "") continue;
+ if (strName == null) continue;
+
+ Caller caller = new Caller(strCallerId, strName, bShow);
phonebook.Add(caller);
if (_extensiveLogging)
Log.Debug("FRITZ!Box: caller loaded: {0} {1} {2}", caller.callerId, caller.name, caller.show);
}
}
+ if (_extensiveLogging)
+ Log.Debug("FRITZ!Box: imported {0} callers", phonebook.Count.ToString());
+ }
- if (_extensiveLogging)
- Log.Debug("FRITZ!Box: imported {0} callers", phonebook.Count.ToString());
+ private 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]));
+ phonebook.Add(caller);
+
+ if (_extensiveLogging)
+ Log.Debug("FRITZ!Box: caller loaded: {0} {1} {2}", caller.callerId, caller.name, caller.show);
+ }
}
}
@@ -178,27 +210,23 @@
{
if (_extensiveLogging)
Log.Info("FRITZ!Box: SaveSettings");
-
+
using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
{
- if (_usePhonebook)
+ xmlwriter.SetValue("fritzbox", "lastVersion", _version.Replace(".", string.Empty));
+ }
+
+ using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "fritzbox.xml")))
+ {
+ xmlwriter.SetValue("phonebook", "count", phonebook.Count);
+
+ for (int i = 0; i < phonebook.Count; i++)
{
- string strCallerId = "";
- string strName = "";
- string strShow = "";
-
- for (int i = 0; i < phonebook.Count; i++)
- {
- Caller caller = phonebook[i];
+ Caller caller = phonebook[i];
- strCallerId += caller.callerId + ";";
- strName += caller.name + ";";
- strShow += caller.show + ";";
- }
-
- xmlwriter.SetValue("fritzbox", "phonebookCallerId", strCallerId);
- xmlwriter.SetValue("fritzbox", "phonebookName", strName);
- xmlwriter.SetValue("fritzbox", "phonebookShow", strShow);
+ xmlwriter.SetValue("phonebook", string.Format("callerID{0}", i.ToString()), caller.callerId);
+ xmlwriter.SetValue("phonebook", string.Format("name{0}", i.ToString()), caller.name);
+ xmlwriter.SetValueAsBool("phonebook", string.Format("show{0}", i.ToString()), caller.show);
}
}
}
Modified: trunk/plugins/FritzBox/FritzBoxSetupFrom.cs
===================================================================
--- trunk/plugins/FritzBox/FritzBoxSetupFrom.cs 2007-04-07 14:39:22 UTC (rev 295)
+++ trunk/plugins/FritzBox/FritzBoxSetupFrom.cs 2007-04-08 11:07:48 UTC (rev 296)
@@ -738,66 +738,97 @@
{
Log.Info("FRITZ!Box: LoadSettings");
- labelVersion.Text = "v" + FritzBox._version;
+ labelVersion.Text = "v" + FritzBox._version;
- using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
- {
- checkBoxExtensiveLogging.Checked = xmlreader.GetValueAsBool("fritzbox", "extensiveLogging", false);
+ using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
+ {
+ FritzBox._lastVersion = xmlreader.GetValueAsInt("fritzbox", "lastVersion", 0);
- textBoxAddress.Text = xmlreader.GetValueAsString("fritzbox", "address", "fritz.box");
- textBoxPort.Text = xmlreader.GetValueAsString("fritzbox", "port", "1012");
+ checkBoxExtensiveLogging.Checked = xmlreader.GetValueAsBool("fritzbox", "extensiveLogging", false);
- // notify settings
- checkBoxCloseOnTimout.Checked = xmlreader.GetValueAsBool("fritzbox", "closeOnTimeout", false);
- numericUpDownTimeout.Value = xmlreader.GetValueAsInt("fritzbox", "timeout", 10);
+ textBoxAddress.Text = xmlreader.GetValueAsString("fritzbox", "address", "fritz.box");
+ textBoxPort.Text = xmlreader.GetValueAsString("fritzbox", "port", "1012");
- numericUpDownTimeout.Enabled = checkBoxCloseOnTimout.Checked;
+ // notify settings
+ checkBoxCloseOnTimout.Checked = xmlreader.GetValueAsBool("fritzbox", "closeOnTimeout", false);
+ numericUpDownTimeout.Value = xmlreader.GetValueAsInt("fritzbox", "timeout", 10);
- checkBoxFilterMSNs.Checked = xmlreader.GetValueAsBool("fritzbox", "filterMSNs", false);
- comboBoxMSNs.Enabled = checkBoxFilterMSNs.Checked;
- buttonMSNsAdd.Enabled = checkBoxFilterMSNs.Checked;
- buttonMSNsRemove.Enabled = checkBoxFilterMSNs.Checked;
- string strMSN = xmlreader.GetValueAsString("fritzbox", "MSN", "");
- char[] charSeparators = new char[] { ';' };
- if (strMSN != "")
- comboBoxMSNs.Items.AddRange(strMSN.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries));
+ numericUpDownTimeout.Enabled = checkBoxCloseOnTimout.Checked;
- checkBoxShowMsnOnHeading.Checked = xmlreader.GetValueAsBool("fritzbox", "showMsnOnHeading", false);
+ checkBoxFilterMSNs.Checked = xmlreader.GetValueAsBool("fritzbox", "filterMSNs", false);
+ comboBoxMSNs.Enabled = checkBoxFilterMSNs.Checked;
+ buttonMSNsAdd.Enabled = checkBoxFilterMSNs.Checked;
+ buttonMSNsRemove.Enabled = checkBoxFilterMSNs.Checked;
+ string strMSN = xmlreader.GetValueAsString("fritzbox", "MSN", "");
+ char[] charSeparators = new char[] { ';' };
+ if (strMSN != "")
+ comboBoxMSNs.Items.AddRange(strMSN.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries));
- // media settings
- checkBoxStopMedia.Checked = xmlreader.GetValueAsBool("fritzbox", "stopMedia", true);
- checkBoxResumeMedia.Checked = xmlreader.GetValueAsBool("fritzbox", "resumeMedia", true);
+ checkBoxShowMsnOnHeading.Checked = xmlreader.GetValueAsBool("fritzbox", "showMsnOnHeading", false);
- // phonebook settings
- checkBoxUsePhonebook.Checked = xmlreader.GetValueAsBool("fritzbox", "usePhonebook", true);
- checkBoxShowUnknownCaller.Checked = xmlreader.GetValueAsBool("fritzbox", "showUnknownCaller", true);
- checkBoxSaveUnknownCaller.Checked = xmlreader.GetValueAsBool("fritzbox", "saveUnknownCaller", true);
+ // media settings
+ checkBoxStopMedia.Checked = xmlreader.GetValueAsBool("fritzbox", "stopMedia", true);
+ checkBoxResumeMedia.Checked = xmlreader.GetValueAsBool("fritzbox", "resumeMedia", true);
- checkBoxShowUnknownCaller.Enabled = checkBoxUsePhonebook.Checked;
- checkBoxSaveUnknownCaller.Enabled = checkBoxUsePhonebook.Checked;
+ // phonebook settings
+ checkBoxUsePhonebook.Checked = xmlreader.GetValueAsBool("fritzbox", "usePhonebook", true);
+ checkBoxShowUnknownCaller.Checked = xmlreader.GetValueAsBool("fritzbox", "showUnknownCaller", true);
+ checkBoxSaveUnknownCaller.Checked = xmlreader.GetValueAsBool("fritzbox", "saveUnknownCaller", true);
+ checkBoxShowUnknownCaller.Enabled = checkBoxUsePhonebook.Checked;
+ checkBoxSaveUnknownCaller.Enabled = checkBoxUsePhonebook.Checked;
+ }
- string strCallerId = xmlreader.GetValueAsString("fritzbox", "phonebookCallerId", "");
- string strName = xmlreader.GetValueAsString("fritzbox", "phonebookName", "");
- string strShow = xmlreader.GetValueAsString("fritzbox", "phonebookShow", "");
+ if ((FritzBox._lastVersion < 0220) && (!File.Exists(Config.GetFile(Config.Dir.Config, "fritzbox.xml"))))
+ UpdateTo0220();
+ else
+ using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "fritzbox.xml")))
+ {
+ int countCaller = xmlreader.GetValueAsInt("phonebook", "count", 0);
- if (strCallerId != "")
+ for (int i = 0; i < countCaller; i++)
{
- string[] strListCallerId = strCallerId.Split(';');
- string[] strListName = strName.Split(';');
- string[] strListShow = strShow.Split(';');
+ string strCallerId = xmlreader.GetValueAsString("phonebook", string.Format("callerID{0}", i.ToString()), "");
+ string strName = xmlreader.GetValueAsString("phonebook", string.Format("name{0}", i.ToString()), "");
+ bool bShow = xmlreader.GetValueAsBool("phonebook", string.Format("show{0}", i.ToString()), false);
- for (int i = 0; i < strListCallerId.GetUpperBound(0); i++)
- dataGridView.Rows.Add(strListCallerId[i], strListName[i], bool.Parse(strListShow[i]));
+ if (strCallerId == "") continue;
+ if (strCallerId == null) continue;
+ if (strName == "") continue;
+ if (strName == null) continue;
+
+ dataGridView.Rows.Add(strCallerId, strName, bShow);
}
}
}
+ private void UpdateTo0220()
+ {
+ using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
+ {
+ string strCallerId = xmlreader.GetValueAsString("fritzbox", "phonebookCallerId", "");
+ string strName = xmlreader.GetValueAsString("fritzbox", "phonebookName", "");
+ string strShow = xmlreader.GetValueAsString("fritzbox", "phonebookShow", "");
+
+ if (strCallerId != "")
+ {
+ string[] strListCallerId = strCallerId.Split(';');
+ string[] strListName = strName.Split(';');
+ string[] strListShow = strShow.Split(';');
+
+ for (int i = 0; i < strListCallerId.GetUpperBound(0); i++)
+ dataGridView.Rows.Add(strListCallerId[i], strListName[i], bool.Parse(strListShow[i]));
+ }
+ }
+ }
+
private void SaveSettings()
{
Log.Info("FRITZ!Box: SaveSettings");
using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
{
+ xmlwriter.SetValue("fritzbox", "lastVersion", FritzBox._version.Replace(".", string.Empty));
+
xmlwriter.SetValueAsBool("fritzbox", "extensiveLogging", checkBoxExtensiveLogging.Checked);
xmlwriter.SetValue("fritzbox", "address", textBoxAddress.Text);
@@ -825,22 +856,22 @@
xmlwriter.SetValueAsBool("fritzbox", "usePhonebook", checkBoxUsePhonebook.Checked);
xmlwriter.SetValueAsBool("fritzbox", "showUnknownCaller", checkBoxShowUnknownCaller.Checked);
xmlwriter.SetValueAsBool("fritzbox", "saveUnknownCaller", checkBoxSaveUnknownCaller.Checked);
+ }
+ using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "fritzbox.xml")))
+ {
+ xmlwriter.SetValue("phonebook", "count", dataGridView.RowCount - 1);
- string strCallerId = "";
- string strName = "";
- string strShow = "";
-
for (int i = 0; i < dataGridView.RowCount - 1; i++)
{
- strCallerId += dataGridView.Rows[i].Cells[0].Value.ToString() + ";";
- strName += dataGridView.Rows[i].Cells[1].Value.ToString() + ";";
- strShow += dataGridView.Rows[i].Cells[2].Value.ToString() + ";";
+ string strCallerId = dataGridView.Rows[i].Cells[0].Value.ToString();
+ string strName = dataGridView.Rows[i].Cells[1].Value.ToString();
+ bool strShow = bool.Parse(dataGridView.Rows[i].Cells[2].Value.ToString());
+
+ xmlwriter.SetValue("phonebook", string.Format("callerID{0}", i.ToString()), strCallerId);
+ xmlwriter.SetValue("phonebook", string.Format("name{0}", i.ToString()), strName);
+ xmlwriter.SetValueAsBool("phonebook", string.Format("show{0}", i.ToString()), strShow);
}
-
- xmlwriter.SetValue("fritzbox", "phonebookCallerId", strCallerId);
- xmlwriter.SetValue("fritzbox", "phonebookName", strName);
- xmlwriter.SetValue("fritzbox", "phonebookShow", strShow);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|