From: <hor...@us...> - 2011-11-29 19:40:11
|
Revision: 4356 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4356&view=rev Author: horned-reaper Date: 2011-11-29 19:40:00 +0000 (Tue, 29 Nov 2011) Log Message: ----------- Modified Paths: -------------- trunk/plugins/FritzBox/Build/Build FritzBoxManager.bat trunk/plugins/FritzBox/FritzBox/FritzBox.cs trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.Designer.cs trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.cs trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/FritzBoxClient.cs trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/PhoneBook.cs trunk/plugins/FritzBox/FritzBox/FritzManager/BackGroundWorker.cs trunk/plugins/FritzBox/FritzBox/FritzManager/CallItem.cs trunk/plugins/FritzBox/FritzBox/FritzManager/Fritz.cs trunk/plugins/FritzBox/FritzBox/FritzManager/PhonebookItem.cs trunk/plugins/FritzBox/FritzBox/FritzManager/VBReader.cs trunk/plugins/FritzBox/FritzBox/Languages/strings_en-US.xml trunk/plugins/FritzBox/FritzBox/Languages/strings_en.xml trunk/plugins/FritzBox/FritzBox/Settings.cs trunk/plugins/FritzBox/FritzBox/bin/Release/FritzBox.dll trunk/plugins/FritzBox/FritzBox/bin/Release/FritzBox.pdb trunk/plugins/FritzBox/FritzBox/obj/Debug/FritzBox.dll trunk/plugins/FritzBox/FritzBox/obj/Debug/FritzBox.pdb trunk/plugins/FritzBox/FritzBox/obj/Release/FritzBox.csproj.GenerateResource.Cache trunk/plugins/FritzBox/FritzBox/obj/Release/FritzBox.dll trunk/plugins/FritzBox/FritzBox/obj/Release/FritzBox.pdb trunk/plugins/FritzBox/MpeRelease/FritzBox.mpe1 trunk/plugins/FritzBox/MpeRelease/FritzBox.xmp2 trunk/plugins/FritzBox/Tools/FritzBoxConfigTester/bin/Debug/FritzBox.dll trunk/plugins/FritzBox/Tools/FritzBoxConfigTester/bin/Debug/FritzBox.pdb trunk/plugins/FritzBox/Tools/FritzBoxConfigTester/bin/Debug/FritzBoxConfigTester.exe trunk/plugins/FritzBox/Tools/FritzBoxConfigTester/bin/Debug/FritzBoxConfigTester.pdb trunk/plugins/FritzBox/Tools/FritzBoxConfigTester/bin/Release/FritzBoxConfigTester.exe trunk/plugins/FritzBox/Tools/FritzBoxConfigTester/bin/Release/FritzBoxConfigTester.pdb trunk/plugins/FritzBox/Tools/FritzBoxConfigTester/obj/Debug/FritzBoxConfigTester.exe trunk/plugins/FritzBox/Tools/FritzBoxConfigTester/obj/Debug/FritzBoxConfigTester.pdb trunk/plugins/FritzBox/Tools/FritzBoxConfigTester/obj/Debug/ResolveAssemblyReference.cache trunk/plugins/FritzBox/Tools/FritzBoxConfigTester/obj/Release/FritzBoxConfigTester.exe trunk/plugins/FritzBox/Tools/FritzBoxConfigTester/obj/Release/FritzBoxConfigTester.pdb trunk/plugins/FritzBox/Tools/FritzBoxConfigTester/obj/Release/ResolveAssemblyReference.cache trunk/plugins/FritzBox/Tools/FritzBoxDebugger/bin/Debug/FritzBox.dll trunk/plugins/FritzBox/Tools/FritzBoxDebugger/bin/Debug/FritzBox.pdb trunk/plugins/FritzBox/Tools/FritzBoxDebugger/bin/Debug/FritzBoxDebugger.exe trunk/plugins/FritzBox/Tools/FritzBoxDebugger/bin/Debug/FritzBoxDebugger.pdb trunk/plugins/FritzBox/Tools/FritzBoxDebugger/bin/Release/FritzBoxDebugger.exe trunk/plugins/FritzBox/Tools/FritzBoxDebugger/bin/Release/FritzBoxDebugger.pdb trunk/plugins/FritzBox/Tools/FritzBoxDebugger/obj/Debug/FritzBoxDebugger.exe trunk/plugins/FritzBox/Tools/FritzBoxDebugger/obj/Debug/FritzBoxDebugger.pdb trunk/plugins/FritzBox/Tools/FritzBoxDebugger/obj/Release/FritzBoxDebugger.exe trunk/plugins/FritzBox/Tools/FritzBoxDebugger/obj/Release/FritzBoxDebugger.pdb Modified: trunk/plugins/FritzBox/Build/Build FritzBoxManager.bat =================================================================== --- trunk/plugins/FritzBox/Build/Build FritzBoxManager.bat 2011-11-29 11:06:08 UTC (rev 4355) +++ trunk/plugins/FritzBox/Build/Build FritzBoxManager.bat 2011-11-29 19:40:00 UTC (rev 4356) @@ -1,3 +1,6 @@ +D: +cd \FritzBox\Build + @echo off REM Select program path based on current machine environment @@ -5,7 +8,7 @@ if not "%ProgramFiles(x86)%".=="". set ProgramDir=%ProgramFiles(x86)% REM set logfile where the infos are written to, and clear that file -set LOG=build_%BUILD_TYPE%.log +set LOG=Build.log echo. > %LOG% echo. Modified: trunk/plugins/FritzBox/FritzBox/FritzBox.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBox.cs 2011-11-29 11:06:08 UTC (rev 4355) +++ trunk/plugins/FritzBox/FritzBox/FritzBox.cs 2011-11-29 19:40:00 UTC (rev 4356) @@ -39,1385 +39,1398 @@ namespace FritzBox { - internal enum FritzBoxGuiMode - { - CallList = 0, - VoiceBox = 1, - PhoneBook = 2 - } + internal enum FritzBoxGuiMode + { + CallList = 0, + VoiceBox = 1, + PhoneBook = 2 + } - [PluginIcons("FritzBox.FritzBox.png", "FritzBox.FritzBoxDisabled.png")] - public class FritzBox : GUIWindow, ISetupForm, IPlugin - { - static Logger Log = LoggerFactory.getLogger("FritzBox"); - - #region CallMonitor + [PluginIcons("FritzBox.FritzBox.png", "FritzBox.FritzBoxDisabled.png")] + public class FritzBox : GUIWindow, ISetupForm, IPlugin + { + static Logger Log = LoggerFactory.getLogger("FritzBox"); - #region Variables + #region CallMonitor - private readonly List<CallAction> _actionList = new List<CallAction>(); - private readonly List<CallAction> _notifyQueue = new List<CallAction>(); - private bool _showNotify = true; - private object _tempNotify; + #region Variables - private int notifyCount = 0; + private readonly List<CallAction> _actionList = new List<CallAction>(); + private readonly List<CallAction> _notifyQueue = new List<CallAction>(); + private bool _showNotify = true; + private object _tempNotify; - #endregion Variables + private int notifyCount = 0; - #region Properties + #endregion Variables - public string ContactPicturesFolder - { - get { return Config.GetSubFolder(Config.Dir.Thumbs, "FritzBox.Contacts"); } - } - - public string YacFolder - { - get { return Config.GetSubFolder(Config.Dir.Thumbs, "yac"); } - } + #region Properties - public string SkinMediaFolder - { - get { return Path.Combine(Config.GetSubFolder(Config.Dir.Skin, Settings.MediaPortalSkin), "Media"); } - } + public string ContactPicturesFolder + { + get { return Config.GetSubFolder(Config.Dir.Thumbs, "FritzBox.Contacts"); } + } - public string UnknownCallerImage - { - get - { - string filePath; + public string YacFolder + { + get { return Config.GetSubFolder(Config.Dir.Thumbs, "yac"); } + } - // check if skin supports it's own images - filePath = Utils.GetCoverArt(SkinMediaFolder, @"FritzBox\CallMonitor.Unknown"); - if (!String.IsNullOrEmpty(filePath)) return filePath; + public string SkinMediaFolder + { + get { return Path.Combine(Config.GetSubFolder(Config.Dir.Skin, Settings.MediaPortalSkin), "Media"); } + } - // use new default image - filePath = Utils.GetCoverArt(ContactPicturesFolder, @"FritzBox\CallMonitor.Unknown"); - if (!String.IsNullOrEmpty(filePath)) return filePath; + public string UnknownCallerImage + { + get + { + string filePath; - // use old default image - filePath = Utils.GetCoverArt(YacFolder, "_unknown"); - if (!String.IsNullOrEmpty(filePath)) return filePath; + // check if skin supports it's own images + filePath = Utils.GetCoverArt(SkinMediaFolder, @"FritzBox\CallMonitor.Unknown"); + if (!String.IsNullOrEmpty(filePath)) return filePath; - return String.Empty; - } - } + // use new default image + filePath = Utils.GetCoverArt(ContactPicturesFolder, @"FritzBox\CallMonitor.Unknown"); + if (!String.IsNullOrEmpty(filePath)) return filePath; - public string MissingCallerImage - { - get - { - string filePath; + // use old default image + filePath = Utils.GetCoverArt(YacFolder, "_unknown"); + if (!String.IsNullOrEmpty(filePath)) return filePath; - // check if skin supports it's own images - filePath = Utils.GetCoverArt(SkinMediaFolder, @"FritzBox\CallMonitor.Missing"); - if (!String.IsNullOrEmpty(filePath)) return filePath; + return String.Empty; + } + } - // use new default image - filePath = Utils.GetCoverArt(ContactPicturesFolder, @"FritzBox\CallMonitor.Missing"); - if (!String.IsNullOrEmpty(filePath)) return filePath; + public string MissingCallerImage + { + get + { + string filePath; - // use old default image - filePath = Utils.GetCoverArt(YacFolder, "_noImage"); - if (!String.IsNullOrEmpty(filePath)) return filePath; + // check if skin supports it's own images + filePath = Utils.GetCoverArt(SkinMediaFolder, @"FritzBox\CallMonitor.Missing"); + if (!String.IsNullOrEmpty(filePath)) return filePath; - return String.Empty; - } - } + // use new default image + filePath = Utils.GetCoverArt(ContactPicturesFolder, @"FritzBox\CallMonitor.Missing"); + if (!String.IsNullOrEmpty(filePath)) return filePath; - #endregion + // use old default image + filePath = Utils.GetCoverArt(YacFolder, "_noImage"); + if (!String.IsNullOrEmpty(filePath)) return filePath; - #region Private Functions/Methods + return String.Empty; + } + } - private void OnStartExternal(Process proc, bool waitForExit) - { - if (waitForExit) _showNotify = false; - else _showNotify = true; - } + #endregion - private void OnStopExternal(Process proc, bool waitForExit) - { - _showNotify = true; + #region Private Functions/Methods - //for (int i = 0; i < _notifyQueue.Count; i++) - // OnFritzBoxEvent(_notifyQueue[i]); + private void OnStartExternal(Process proc, bool waitForExit) + { + if (waitForExit) _showNotify = false; + else _showNotify = true; + } - _notifyQueue.Clear(); - } + private void OnStopExternal(Process proc, bool waitForExit) + { + _showNotify = true; - private void OnCallAction(CallAction callAction) - { - Log.Info("FRITZ!Box: OnCallAction()"); - callAction.WriteToLog(); + //for (int i = 0; i < _notifyQueue.Count; i++) + // OnFritzBoxEvent(_notifyQueue[i]); - if (!_showNotify) - { - Log.Info("External process is running. Notify is queued and will be shown later."); - _notifyQueue.Add(callAction); - return; - } + _notifyQueue.Clear(); + } - switch (callAction.Type) - { - case CallAction.CallType.Incoming: - if (PhoneBook.Enabled) callAction.Caller = PhoneBook.GetCaller(phoneBook, callAction.Caller); - OnCall(callAction); - break; - case CallAction.CallType.Outgoing: - if (PhoneBook.Enabled) callAction.Caller = PhoneBook.GetCaller(phoneBook, callAction.Caller); - OnCall(callAction); - break; - case CallAction.CallType.ConnectionStarted: - break; - case CallAction.CallType.ConnectionClosed: - if (Settings.CloseOnConnectionClosed) - { - Log.Info("_closeOnConnectionClosed is enabled. Try to close active notify."); + private 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."); + _notifyQueue.Add(callAction); + return; + } + + switch (callAction.Type) + { + case CallAction.CallType.Incoming: + if (PhoneBook.Enabled) callAction.Caller = PhoneBook.GetCaller(phoneBook, callAction.Caller); + OnCall(callAction); + break; + case CallAction.CallType.Outgoing: + if (PhoneBook.Enabled) callAction.Caller = PhoneBook.GetCaller(phoneBook, callAction.Caller); + OnCall(callAction); + break; + case CallAction.CallType.ConnectionStarted: + break; + case CallAction.CallType.ConnectionClosed: + if (Settings.CloseOnConnectionClosed) + { + Log.Info("_closeOnConnectionClosed is enabled. Try to close active notify."); + if (_tempNotify != null) + { + MediaPortal.GUI.Library.Action act = new MediaPortal.GUI.Library.Action(); + act.wID = MediaPortal.GUI.Library.Action.ActionType.ACTION_CLOSE_DIALOG; + GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY).OnAction(act); + } + } + break; + default: + Log.Error("incorrect callAction.Type"); + break; + } + } + + private void OnLogAction(FritzBoxClient.LogLevel logLevel, string logMessage) + { + switch (logLevel) + { + case FritzBoxClient.LogLevel.Debug: + Log.Debug(logMessage); + break; + case FritzBoxClient.LogLevel.Error: + Log.Error(logMessage); + break; + case FritzBoxClient.LogLevel.Warning: + Log.Warn(logMessage); + break; + case FritzBoxClient.LogLevel.Info: + Log.Info(logMessage); + break; + default: + break; + } + } + + private void OnCall(CallAction callAction) + { + Log.Info("FRITZ!Box: OnCall()"); + if (_tempNotify != null) { - MediaPortal.GUI.Library.Action act = new MediaPortal.GUI.Library.Action(); - act.wID = MediaPortal.GUI.Library.Action.ActionType.ACTION_CLOSE_DIALOG; - GUIWindowManager.GetWindow((int) GUIWindow.Window.WINDOW_DIALOG_NOTIFY).OnAction(act); + Log.Info("yet another dialog is active. action is sent to queue."); + + if (_actionList.Count < Settings.MaxNotifies - 1) _actionList.Add(callAction); + + return; } - } - break; - default: - Log.Error("incorrect callAction.Type"); - break; - } - } - private void OnLogAction(FritzBoxClient.LogLevel logLevel, string logMessage) - { - switch (logLevel) - { - case FritzBoxClient.LogLevel.Debug: - Log.Debug(logMessage); - break; - case FritzBoxClient.LogLevel.Error: - Log.Error(logMessage); - break; - case FritzBoxClient.LogLevel.Warning: - Log.Warn(logMessage); - break; - case FritzBoxClient.LogLevel.Info: - Log.Info(logMessage); - break; - default: - break; - } - } + // config settings for dialog + string strHeading = string.Empty; + string strImage = string.Empty; + string strText = string.Empty; - private void OnCall(CallAction callAction) - { - Log.Info("FRITZ!Box: OnCall()"); + // set heading for NotifyDialog + switch (callAction.Type) + { + case CallAction.CallType.Incoming: + strHeading = GUILocalizeStrings.Get(1); // 1 = Incoming call + break; + case CallAction.CallType.Outgoing: + strHeading = GUILocalizeStrings.Get(2); // 2 = Outgoing call + break; + } - if (_tempNotify != null) - { - Log.Info("yet another dialog is active. action is sent to queue."); - if (_actionList.Count < Settings.MaxNotifies - 1) _actionList.Add(callAction); - return; - } + // set Image for NotifyDialog + strImage = GetCallerImage(callAction.Caller); - // config settings for dialog - string strHeading = string.Empty; - string strImage = string.Empty; - string strText = string.Empty; - - // set heading for NotifyDialog - switch (callAction.Type) - { - case CallAction.CallType.Incoming: - strHeading = GUILocalizeStrings.Get(1); // 1 = Incoming call - break; - case CallAction.CallType.Outgoing: - strHeading = GUILocalizeStrings.Get(2); // 2 = Outgoing call - break; - } + // set message text for NotifyDialog + strText = Environment.NewLine; - // set Image for NotifyDialog - strImage = GetCallerImage(callAction.Caller); + if (callAction.Caller.ID == "") strText += GUILocalizeStrings.Get(3); // 3 = Unknown + else if (callAction.Caller.Name == "") strText += callAction.Caller.ID; + else + { + strText += callAction.Caller.Name; - // set message text for NotifyDialog - strText = Environment.NewLine; - if (callAction.Caller.ID == "") strText += GUILocalizeStrings.Get(3); // 3 = Unknown - else if (callAction.Caller.Name == "") strText += callAction.Caller.ID; - else - { - strText += callAction.Caller.Name; - if (Settings.ShowMSNOnNotify) strText += Environment.NewLine + callAction.Caller.ID; - } + if (Settings.ShowMSNOnNotify) strText += Environment.NewLine + callAction.Caller.ID; + } - // config settings for dialog FINISHED + // config settings for dialog FINISHED - // if MSN is disabled, stop here - if (!IsMsnEnabled(callAction.MSN)) return; + // if MSN is disabled, stop here + if (!IsMSNEnabled(callAction.MSN)) return; - // if notifies are disabled for this call, stop here - if (!IsCallerEnabled(callAction.Caller)) return; - - if (callAction.Type == CallAction.CallType.Incoming && Settings.IncomingSound != null && Settings.IncomingSound.Length > 0 ) Utils.PlaySound(Settings.IncomingSound, false, true); + // if notifies are disabled for this call, stop here + if (!IsCallerEnabled(callAction.Caller)) return; - ShowNotify(strHeading, strImage, strText); - } + if (callAction.Type == CallAction.CallType.Incoming && Settings.IncomingSound != null && Settings.IncomingSound.Length > 0) Utils.PlaySound(Settings.IncomingSound, false, true); - #endregion + ShowNotify(strHeading, strImage, strText); + } - #region Helper Methods + #endregion - private string GetCallerImage(string callerId) - { - // search image for caller - if (Settings.ExtensiveLogging) - Log.Info("searching image for callerId: " + callerId); + #region Helper Methods - string filePath; + private string GetCallerImage(string callerId) + { + // search image for caller + if (Settings.ExtensiveLogging) + Log.Info("searching image for callerId: " + callerId); - // use new image path - filePath = Utils.GetCoverArt(ContactPicturesFolder, callerId); - if (!String.IsNullOrEmpty(filePath)) return filePath; - Log.Info("found image not in: " + ContactPicturesFolder); + string filePath; - // use old image path - filePath = Utils.GetCoverArt(YacFolder, callerId); - if (!String.IsNullOrEmpty(filePath)) return filePath; - Log.Info("found image not in: " + YacFolder); + // use new image path + filePath = Utils.GetCoverArt(ContactPicturesFolder, callerId); + if (!String.IsNullOrEmpty(filePath)) return filePath; + Log.Info("found image not in: " + ContactPicturesFolder); - return String.Empty; - } + // use old image path + filePath = Utils.GetCoverArt(YacFolder, callerId); + if (!String.IsNullOrEmpty(filePath)) return filePath; + Log.Info("found image not in: " + YacFolder); - private string GetCallerImage(Caller caller) - { - if (caller.ID == "") - return UnknownCallerImage; - else - { - string strImage = GetCallerImage(caller.Name); + return String.Empty; + } - if (File.Exists(strImage)) + private string GetCallerImage(Caller caller) { - if (Settings.ExtensiveLogging) Log.Info("found image for caller: " + strImage); - else Log.Info("found image for caller"); + if (caller.ID == "") + return UnknownCallerImage; + else + { + string strImage = GetCallerImage(caller.Name); - return strImage; + if (File.Exists(strImage)) + { + if (Settings.ExtensiveLogging) Log.Info("found image for caller: " + strImage); + else Log.Info("found image for caller"); + + return strImage; + } + else + { + Log.Info("found NO image for caller"); + return MissingCallerImage; + } + } } - else + + private bool IsMSNEnabled(string mSN) { - Log.Info("found NO image for caller"); - return MissingCallerImage; + if (!Settings.FilterMSN) + { + Log.Info("MSN filter is disabled."); + return true; + } + + if (Settings.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; + } } - } - } - private bool IsMsnEnabled(string msn) - { - if (!Settings.FilterMSN) - { - Log.Info("MSN filter is disabled."); - return true; - } + private bool IsCallerEnabled(Caller caller) + { + if (!PhoneBook.Enabled) + { + Log.Info("Phone book is disabled. Notify will be shown."); + return true; + } + else if (caller.Show) return true; + else return false; + } - if (Settings.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; - } - } + private void ShowNotify(string strHeading, string strImage, string strText) + { + bool resumePlayer = false; - private bool IsCallerEnabled(Caller caller) - { - if (!PhoneBook.Enabled) - { - Log.Info("Phone book is disabled. Notify will be shown."); - return true; - } - else if (caller.Show) return true; - else return false; - } + if (notifyCount >= Settings.MaxNotifies) return; - private void ShowNotify(string strHeading, string strImage, string strText) - { - bool resumePlayer = false; + // pause player + if (g_Player.Playing && !g_Player.Paused && Settings.StopMedia) + { + g_Player.Pause(); + resumePlayer = true; + } - if (notifyCount >= Settings.MaxNotifies) return; + // show dialog + GUIDialogNotify dlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); + if (dlgNotify == null) return; - // pause player - if (g_Player.Playing && !g_Player.Paused && Settings.StopMedia) - { - g_Player.Pause(); - resumePlayer = true; + dlgNotify.Reset(); + dlgNotify.ClearAll(); + dlgNotify.SetHeading(strHeading); + dlgNotify.SetImage(strImage); + dlgNotify.SetText(strText); + if (Settings.CloseOnTimeout) dlgNotify.TimeOut = Settings.NotifyTimeout; + else dlgNotify.TimeOut = -1; + + _tempNotify = dlgNotify; + dlgNotify.DoModal(GUIWindowManager.ActiveWindow); + + // resume player + if (resumePlayer && g_Player.Playing && g_Player.Paused && Settings.StopMedia && Settings.ResumeMedia) g_Player.Pause(); + + _tempNotify = null; + if (_actionList.Count > 0) + { + CallAction tmpAction = _actionList[0]; + _actionList.RemoveAt(0); + OnCallAction(tmpAction); + } } - // show dialog - GUIDialogNotify dlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); - if (dlgNotify == null) return; + #endregion - dlgNotify.Reset(); - dlgNotify.ClearAll(); - dlgNotify.SetHeading(strHeading); - dlgNotify.SetImage(strImage); - dlgNotify.SetText(strText); - if (Settings.CloseOnTimeout) dlgNotify.TimeOut = Settings.NotifyTimeout; - else dlgNotify.TimeOut = -1; + #endregion CallMonitor - _tempNotify = dlgNotify; - dlgNotify.DoModal(GUIWindowManager.ActiveWindow); + #region <Interface> Implementations - // resume player - if (resumePlayer && g_Player.Playing && g_Player.Paused && Settings.StopMedia && Settings.ResumeMedia) g_Player.Pause(); + #region IPlugin Interface - _tempNotify = null; - if (_actionList.Count > 0) + /// <summary> + /// This method will be called by mediaportal to start your process plugin + /// </summary> + public void Start() { - CallAction tmpAction = _actionList[0]; - _actionList.RemoveAt(0); - OnCallAction(tmpAction); + Log.Info("FRITZ!Box Plugin {0} starting.", Assembly.GetExecutingAssembly().GetName().Version); + Settings.Load(); + + Utils.OnStartExternal += OnStartExternal; + Utils.OnStopExternal += OnStopExternal; + + FritzBoxClient.LogEvent += OnLogAction; + FritzBoxClient.CallEvent += OnCallAction; + FritzBoxClient.StartClient(); + + // start monitoring Windows power mode changes (Standby & Hibernate) + SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged); } - } - #endregion + /// <summary> + /// this method will be called by mediaportal to stop your process plugin + /// </summary> + public void Stop() + { + Log.Info("FRITZ!Box Plugin {0} stopping.", Assembly.GetExecutingAssembly().GetName().Version); - #endregion CallMonitor + FritzBoxClient.StopClient(); + FritzBoxClient.CallEvent -= OnCallAction; + FritzBoxClient.LogEvent -= OnLogAction; - #region <Interface> Implementations + Utils.OnStartExternal -= OnStartExternal; + Utils.OnStopExternal -= OnStopExternal; - #region IPlugin Interface + // stop monitoring power changes + SystemEvents.PowerModeChanged -= new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged); - /// <summary> - /// This method will be called by mediaportal to start your process plugin - /// </summary> - public void Start() - { - Log.Info("FRITZ!Box Plugin {0} starting.", Assembly.GetExecutingAssembly().GetName().Version); - Settings.Load(); + PhoneBook.SaveSettings(); + } - Utils.OnStartExternal += OnStartExternal; - Utils.OnStopExternal += OnStopExternal; + #endregion - FritzBoxClient.LogEvent += OnLogAction; - FritzBoxClient.CallEvent += OnCallAction; - FritzBoxClient.StartClient(); + #region ISetupForm Member - // start monitoring Windows power mode changes (Standby & Hibernate) - SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged); - } + /// <summary> + /// With GetID it will be an window-plugin / otherwise a process-plugin + /// Enter the id number here again + /// </summary> + public override int GetID + { + get { return GetWindowId(); } + set { } + } - /// <summary> - /// this method will be called by mediaportal to stop your process plugin - /// </summary> - public void Stop() - { - Log.Info("FRITZ!Box Plugin {0} stopping.", Assembly.GetExecutingAssembly().GetName().Version); + public string PluginName() + { + return "FRITZ!Box Manager"; + } - FritzBoxClient.StopClient(); - FritzBoxClient.CallEvent -= OnCallAction; - FritzBoxClient.LogEvent -= OnLogAction; + public string Author() + { + return "chefkoch, S.Rinke"; + } - Utils.OnStartExternal -= OnStartExternal; - Utils.OnStopExternal -= OnStopExternal; + public string Description() + { + return "Displays FRITZ!Box caller lists and voice box infos and notifies on incoming calls."; + } - // stop monitoring power changes - SystemEvents.PowerModeChanged -= new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged); + public void ShowPlugin() + { + try + { + FritzBoxConfig config = new FritzBoxConfig(); + config.ShowDialog(); + } + catch (Exception ex) + { + Log.Error(ex.ToString()); + } + } - PhoneBook.SaveSettings(); - } + public bool CanEnable() + { + return true; + } - #endregion + public int GetWindowId() + { + return 464554871; + } - #region ISetupForm Member + public bool DefaultEnabled() + { + return true; + } - /// <summary> - /// With GetID it will be an window-plugin / otherwise a process-plugin - /// Enter the id number here again - /// </summary> - public override int GetID - { - get { return GetWindowId(); } - set { } - } + public bool HasSetup() + { + return true; + } - public string PluginName() - { - return "FRITZ!Box Manager"; - } + public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage) + { + strButtonText = GUILocalizeStrings.Get(28); // 28 = Telefon + strButtonImage = String.Empty; + strButtonImageFocus = String.Empty; + strPictureImage = "hover_FritzBox.png"; - public string Author() - { - return "chefkoch, S.Rinke"; - } + return true; + } - public string Description() - { - return "Displays FRITZ!Box caller lists and voice box infos and notifies on incoming calls."; - } + #endregion - public void ShowPlugin() - { - try - { - FritzBoxConfig config = new FritzBoxConfig(); - config.ShowDialog(); - } - catch (Exception ex) - { - Log.Error(ex.ToString()); - } - } + #endregion - public bool CanEnable() - { - return true; - } + #region FritzManager - public int GetWindowId() - { - return 464554871; - } + #region enums - public bool DefaultEnabled() - { - return true; - } + #region Nested type: Filter - public bool HasSetup() - { - return true; - } + private enum Filter + { + All = 0, + Incoming = 1, + Outgoing = 2, + Rejected = 3 + } - public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage) - { - strButtonText = GUILocalizeStrings.Get(28); // 28 = Telefon - strButtonImage = String.Empty; - strButtonImageFocus = String.Empty; - strPictureImage = "hover_FritzBox.png"; + #endregion - return true; - } + #region Nested type: View - #endregion + private enum View + { + List = 0, + Icons = 1, + LargeIcons = 2, + } - #endregion + #endregion - #region FritzManager + #endregion - #region enums + #region skin - #region Nested type: Filter + [SkinControl(3)] + protected GUISortButtonControl btnFilter; + [SkinControl(4)] + protected GUIButtonControl btnModus; + [SkinControl(9)] + protected GUIButtonControl btnUpdate; + [SkinControl(2)] + protected GUIButtonControl btnViewAs; + [SkinControl(50)] + protected GUIFacadeControl facadeView; + [SkinControl(4711)] + protected GUIFadeLabel headerLabel; - private enum Filter - { - All = 0, - Incoming = 1, - Outgoing = 2, - Rejected = 3 - } + #endregion - #endregion + #region fields - #region Nested type: View + // update timer for background thread + private static System.Timers.Timer updateTimer = new System.Timers.Timer(); + // path to voice box files + private string vBPath; + // FRITZBox password + private string passwd; + // list of call items (callers) + private List<CallItem> callItemList; + // filter on callitems used in list view + private Filter currentFilter = Filter.All; + // what kind of items is shown (callers, phoneBook, voicebox) + private FritzBoxGuiMode currentMode = FritzBoxGuiMode.CallList; + // state of facede view + private View currentView = View.List; + // list of tmp files to delete when deinit + // TODO should called in timer callback also + private List<string> filesToDelete = new List<string>(); + // FritzBox WebGUI Client + private Fritz fritz; + // stores mapped msns + private HashMap<string, string> msns = new HashMap<string, string>(); + // phone book + public HashMap<string, PhonebookItem> phoneBook = new HashMap<string, PhonebookItem>(); + // dirty marker, if set the timer task will save phoneBook + private volatile bool phoneBookDirty; + // stores pathname for internal pb save file + private string phoneBookPath; + private string mediaPortalLanguage; + // if set true, use revers lookup + private bool useInversSearch; + // list of voivebox messages + private List<VoiceBoxItem> voiceboxItemList; + // worker for task + private BackGroundWorker worker; + // and the thread + private Thread workerThread; - private enum View - { - List = 0, - Icons = 1, - LargeIcons = 2, - } + #endregion - #endregion + // the instance + private static FritzBox thePlugin; + // fritz phoneBook + protected FritzPhonebooks fritzPhonebooks = new FritzPhonebooks(); + // sync the access to phoneBook / calllist + private System.Object sync = new System.Object(); - #endregion + public override bool Init() + { + Start(); + updateGUIProperties(0, 0, ""); + loadConfig(); + GUILocalizeStrings.ChangeLanguage(mediaPortalLanguage); - #region skin + return Load(GUIGraphicsContext.Skin + @"\FritzManager.xml"); + } - [SkinControl(3)] protected GUISortButtonControl btnFilter; - [SkinControl(4)] protected GUIButtonControl btnModus; - [SkinControl(9)] protected GUIButtonControl btnUpdate; - [SkinControl(2)] protected GUIButtonControl btnViewAs; - [SkinControl(50)] protected GUIFacadeControl facadeView; - [SkinControl(4711)] protected GUIFadeLabel headerLabel; + private void startBackGroundWorker(InversSearch search) + { + if (worker == null) + { + worker = new BackGroundWorker(fritz, this, search); + workerThread = new Thread(worker.Run); + workerThread.Start(); + } + } - #endregion + public override void DeInit() + { + cleanup(); - #region fields + if (worker != null) + { + worker.stop(); + workerThread.Abort(); + } - // update timer for background thread - private static System.Timers.Timer updateTimer = new System.Timers.Timer(); - // path to voice box files - private string vBPath; - // FRITZBox password - private string passwd; - // list of call items (callers) - private List<CallItem> callItemList; - // filter on callitems used in list view - private Filter currentFilter = Filter.All; - // what kind of items is shown (callers, phoneBook, voicebox) - private FritzBoxGuiMode currentMode = FritzBoxGuiMode.CallList; - // state of facede view - private View currentView = View.List; - // list of tmp files to delete when deinit - // TODO should called in timer callback also - private List<string> filesToDelete = new List<string>(); - // FritzBox WebGUI Client - private Fritz fritz; - // stores mapped msns - private HashMap<string, string> msns = new HashMap<string, string>(); - // phone book - public HashMap<string, PhonebookItem> phoneBook = new HashMap<string, PhonebookItem>(); - // dirty marker, if set the timer task will save phoneBook - private volatile bool phoneBookDirty; - // stores pathname for internal pb save file - private string phoneBookPath; - private string mediaPortalLanguage; - // if set true, use revers lookup - private bool useInversSearch; - // list of voivebox messages - private List<VoiceBoxItem> voiceboxItemList; - // worker for task - private BackGroundWorker worker; - // and the thread - private Thread workerThread; + Stop(); - #endregion + // persist some props for next time + Log.Debug("DeInit called: persisting current props"); + using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) + { + xmlwriter.SetValue("FritzManager", "currentMode", (int)currentFilter); + xmlwriter.SetValue("FritzManager", "currentFilter", (int)currentMode); + } - // the instance - private static FritzBox thePlugin; - // fritz phoneBook - protected FritzPhonebooks fritzPhonebooks = new FritzPhonebooks(); - // sync the access to phoneBook / calllist - private System.Object sync = new System.Object(); + base.DeInit(); + } - public override bool Init() - { - Start(); - updateGUIProperties(0,0,""); - loadConfig(); - GUILocalizeStrings.ChangeLanguage(mediaPortalLanguage); + protected void loadConfig() + { + string dialport = "0"; + string areacode = ""; - return Load(GUIGraphicsContext.Skin + @"\FritzManager.xml"); - } + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("MediaPortal.xml")) + { + phoneBookPath = Config.GetFolder(Config.Dir.Config) + "\\fritzmanagerPhonebook.xml"; + mediaPortalLanguage = xmlreader.GetValue("gui", "language"); - private void startBackGroundWorker(InversSearch search) - { - if (worker == null) - { - worker = new BackGroundWorker(fritz, this, search); - workerThread = new Thread(worker.Run); - workerThread.Start(); - } - } + passwd = xmlreader.GetValue("FritzManager", "passwd"); + vBPath = xmlreader.GetValue("FritzManager", "vBPath"); + dialport = xmlreader.GetValue("FritzManager", "dialport"); + useInversSearch = xmlreader.GetValueAsBool("FritzManager", "useInversSearch", true); + areacode = xmlreader.GetValue("FritzManager", "defaultAreacode"); - public override void DeInit() - { - cleanup(); + string str = xmlreader.GetValue("FritzManager", "currentMode"); - if (worker != null) - { - worker.stop(); - workerThread.Abort(); - } + if (str != null && str != "") currentMode = (FritzBoxGuiMode)System.Enum.Parse(typeof(FritzBoxGuiMode), str); - Stop(); + str = xmlreader.GetValue("FritzManager", "currentFilter"); - // persist some props for next time - Log.Debug("DeInit called: persisting current props" ); - using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) - { - xmlwriter.SetValue("FritzManager", "currentMode", (int)currentFilter); - xmlwriter.SetValue("FritzManager", "currentFilter", (int)currentMode); - } - - base.DeInit(); - } - - protected void loadConfig() - { - string dialport = "0"; - string areacode = ""; + if (str != null && str != "") currentFilter = (Filter)System.Enum.Parse(typeof(Filter), str); - using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("MediaPortal.xml")) - { - phoneBookPath = Config.GetFolder(Config.Dir.Config) + "\\fritzmanagerPhonebook.xml"; - mediaPortalLanguage = xmlreader.GetValue("gui", "language"); + int interval = xmlreader.GetValueAsInt("FritzManager", "updateInterval", 0); - passwd = xmlreader.GetValue("FritzManager", "passwd"); - vBPath = xmlreader.GetValue("FritzManager", "vBPath"); - dialport = xmlreader.GetValue("FritzManager", "dialport"); - useInversSearch = xmlreader.GetValueAsBool("FritzManager", "useInversSearch", true); - areacode = xmlreader.GetValue("FritzManager", "defaultAreacode"); + if (interval != 0) + { + thePlugin = this; + updateTimer.Interval = interval * 1000; // interval is in sec + updateTimer.Elapsed += OnTimedEvent; + updateTimer.Enabled = true; + } + } - string str = xmlreader.GetValue("FritzManager", "currentMode"); + fritz = new Fritz(passwd, Config.GetFolder(Config.Dir.Config), FritzBoxClient.Address, dialport); - if (str != null && str != "") currentMode = (FritzBoxGuiMode)System.Enum.Parse(typeof(FritzBoxGuiMode), str); - - str = xmlreader.GetValue("FritzManager", "currentFilter"); + initMSN(); - if (str != null && str != "") currentFilter = (Filter)System.Enum.Parse(typeof(Filter), str); + InversSearch search = new InversSearchOert(areacode); - int interval = xmlreader.GetValueAsInt("FritzManager", "updateInterval", 0); + startBackGroundWorker(search); + } - if (interval != 0) + protected override void OnPageLoad() { - thePlugin = this; - updateTimer.Interval = interval * 1000; // interval is in sec - updateTimer.Elapsed += OnTimedEvent; - updateTimer.Enabled = true; - } - } - - fritz = new Fritz(passwd, Config.GetFolder(Config.Dir.Config), FritzBoxClient.Address, dialport); + phoneBook = InternalPhoneBook.loadPhoneBook(phoneBookPath); - initMSN(); + update(false); - InversSearch search = new InversSearchOert(areacode); + if (currentMode == FritzBoxGuiMode.VoiceBox) worker.queue.Enqueue(new Task(Task.TaskAction.LoadCallItems, null)); - startBackGroundWorker(search); - } + ShowThumbPanel(); - protected override void OnPageLoad() - { - phoneBook = InternalPhoneBook.loadPhoneBook(phoneBookPath); - - update(false); - - if (currentMode == FritzBoxGuiMode.VoiceBox) worker.queue.Enqueue(new Task(Task.TaskAction.LoadCallItems, null)); - - ShowThumbPanel(); - } + if (String.IsNullOrEmpty(passwd) && String.IsNullOrEmpty(vBPath)) ShowError(GUILocalizeStrings.Get(24)); // 24 = "Could not load phone book" + } - private static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e) - { - Log.Debug("FritzBox Manager processing timer event"); + private static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e) + { + Log.Debug("FritzBox Manager processing timer event"); - if (thePlugin.phoneBookDirty) - { - thePlugin.phoneBookDirty = false; - InternalPhoneBook.savePhonebook(thePlugin.phoneBook.Values, thePlugin.phoneBookPath); - } + if (thePlugin.phoneBookDirty) + { + thePlugin.phoneBookDirty = false; + InternalPhoneBook.savePhonebook(thePlugin.phoneBook.Values, thePlugin.phoneBookPath); + } - thePlugin.fritz.keepAlive(); + thePlugin.fritz.keepAlive(); - List<VoiceBoxItem> items = VBReader.loadVoiceBoxDir(thePlugin.vBPath); + List<VoiceBoxItem> items = VBReader.loadVoiceBoxDir(thePlugin.vBPath); - int newItems = 0; - string caller = null; + int newItems = 0; + string caller = null; - foreach(VoiceBoxItem item in items) - { - if (item.isNew != 0 && item.type == 3) + foreach (VoiceBoxItem item in items) + { + if (item.isNew != 0 && item.type == 3) + { + if (caller == null) caller = thePlugin.lookupCaller(item.callerId); + newItems++; + } + } + + thePlugin.updateGUIProperties(newItems, items.Count, caller); + } + + protected void initMSN() { - if (caller == null ) caller = thePlugin.lookupCaller(item.callerId); - newItems++; + // populate MSNs + if (File.Exists(Config.GetFolder(Config.Dir.Config) + "\\fritzmanager_msns.txt")) + { + using (StreamReader sr = new StreamReader(Config.GetFolder(Config.Dir.Config) + "\\fritzmanager_msns.txt")) + { + while (!sr.EndOfStream) + { + string line = sr.ReadLine(); + string[] items = line.Split('='); + if (items.GetLength(0) > 1) msns.Add(items[0], items[1]); + } + } + } } - } - thePlugin.updateGUIProperties(newItems, items.Count, caller); - } + protected override void OnPageDestroy(int new_windowId) + { + cleanup(); + base.OnPageDestroy(new_windowId); + } - protected void initMSN() - { - // populate MSNs - if (File.Exists(Config.GetFolder(Config.Dir.Config) + "\\fritzmanager_msns.txt")) - { - using (StreamReader sr = new StreamReader(Config.GetFolder(Config.Dir.Config) + "\\fritzmanager_msns.txt")) + /// <summary> + /// deletes temp files (decoded voicebox messages) + /// </summary> + private void cleanup() { - while (!sr.EndOfStream) - { - string line = sr.ReadLine(); - string[] items = line.Split('='); - if (items.GetLength(0) > 1) msns.Add(items[0], items[1]); - } + // cleanup temp + foreach (string file in filesToDelete) + { + File.Delete(file); + } + + filesToDelete.Clear(); } - } - } - protected override void OnPageDestroy(int new_windowId) - { - cleanup(); - base.OnPageDestroy(new_windowId); - } + /// <summary> + /// update data for the views. + /// </summary> + /// <param name="forceReload">if set the update is forced, and data will be fetched in + /// any case.</param> + protected void update(bool forceReload) + { + if (currentMode == FritzBoxGuiMode.CallList) loadCallListFromFritzbox(forceReload); + else if (currentMode == FritzBoxGuiMode.VoiceBox) voiceboxItemList = VBReader.loadVoiceBoxDir(vBPath); + else if (currentMode == FritzBoxGuiMode.PhoneBook) + { + string str = fritz.loadPhoneBook(); - /// <summary> - /// deletes temp files (decoded voicebox messages) - /// </summary> - private void cleanup() - { - // cleanup temp - foreach (string file in filesToDelete) - { - File.Delete(file); - } + if (str != "") + { + XmlSerializer s = new XmlSerializer(typeof(FritzPhonebooks)); + fritzPhonebooks = (FritzPhonebooks)s.Deserialize(new StringReader(str)); + } + } - filesToDelete.Clear(); - } + refreshView(); - /// <summary> - /// update data for the views. - /// </summary> - /// <param name="forceReload">if set the update is forced, and data will be fetched in - /// any case.</param> - protected void update(bool forceReload) - { - if (currentMode == FritzBoxGuiMode.CallList) loadCallListFromFritzbox(forceReload); - else if (currentMode == FritzBoxGuiMode.VoiceBox) - { - if (!String.IsNullOrEmpty(vBPath)) voiceboxItemList = VBReader.loadVoiceBoxDir(vBPath); - else - { - Log.Debug("voice box path is not set"); - return; - } - } - else if (currentMode == FritzBoxGuiMode.PhoneBook) - { - string str = fritz.loadPhoneBook(); + UpdateButtonStates(); + } - if (str == "") ShowError(GUILocalizeStrings.Get(24)); // 24 = "Could not load phone book" - else + /// <summary> + /// refreshes the view. call when backing lists / maps have changed + /// </summary> + protected void refreshView() { - XmlSerializer s = new XmlSerializer(typeof (FritzPhonebooks)); - fritzPhonebooks = (FritzPhonebooks) s.Deserialize(new StringReader(str)); + if (currentMode == FritzBoxGuiMode.CallList) populateCallItems(); + else if (currentMode == FritzBoxGuiMode.VoiceBox) populateVoiceBoxItems(); + else if (currentMode == FritzBoxGuiMode.PhoneBook) populatePhonebookItems(); } - } - refreshView(); + /// <summary> + /// load internal callers list from csv contained in data + /// </summary> + /// <param name="data">holds csv list</param> + public void refreshCallData(byte[] data) + { + lock (sync) + { + callItemList = CallItem.load(new MemoryStream(data)); - UpdateButtonStates(); - } + // populate phone book + bool updatePhonebook = false; + int idx = 0; - /// <summary> - /// refreshes the view. call when backing lists / maps have changed - /// </summary> - protected void refreshView() - { - if (currentMode == FritzBoxGuiMode.CallList) populateCallItems(); - else if (currentMode == FritzBoxGuiMode.VoiceBox) populateVoiceBoxItems(); - else if (currentMode == FritzBoxGuiMode.PhoneBook) populatePhonebookItems(); - } + foreach (CallItem i in callItemList) + { + PhonebookItem pi = phoneBook[i.number]; - /// <summary> - /// load internal callers list from csv contained in data - /// </summary> - /// <param name="data">holds csv list</param> - public void refreshCallData(byte[] data) - { - lock (sync) - { - callItemList = CallItem.load(new MemoryStream(data)); + if (pi == null) + { + pi = new PhonebookItem(); + pi.number = i.number; + phoneBook[i.number] = pi; + } - // populate phoneBook - bool updatePhonebook = false; - int idx = 0; + if (i.name != "" && pi.name != i.name) + { + pi.name = i.name; + pi.fritzEntry = true; + pi.inverseLookupDone = false; + updatePhonebook = true; + } + else if (useInversSearch && !pi.inverseLookupDone && !pi.fritzEntry && i.number != "") worker.queue.Enqueue(new Task(Task.TaskAction.InversLookup, new object[] { i.number, idx })); - foreach (CallItem i in callItemList) - { - PhonebookItem pi = phoneBook[i.number]; + idx++; + } - if (pi == null) - { - pi = new PhonebookItem(); - pi.number = i.number; - phoneBook[i.number] = pi; - } + if (updatePhonebook) InternalPhoneBook.savePhonebook(phoneBook.Values, phoneBookPath); + } - if (i.name != "" && pi.name != i.name) - { - pi.name = i.name; - pi.fritzEntry = true; - pi.inverseLookupDone = false; - updatePhonebook = true; - } - else if (useInversSearch && !pi.inverseLookupDone && !pi.fritzEntry && i.number != "") worker.queue.Enqueue(new Task(Task.TaskAction.InversLookup, new object[] { i.number, idx })); - - idx++; + refreshView(); } - if (updatePhonebook) InternalPhoneBook.savePhonebook(phoneBook.Values, phoneBookPath); - } - - refreshView(); - } - - public void updatePhonebook(string number, string name, int index) - { - if (name != null && name != "" && phoneBook.Contains(number)) - { - lock (sync) + public void updatePhonebook(string number, string name, int index) { - phoneBook[number].inverseLookupDone = true; - phoneBookDirty = true; + if (name != null && name != "" && phoneBook.Contains(number)) + { + lock (sync) + { + phoneBook[number].inverseLookupDone = true; + phoneBookDirty = true; - if (name != number) - { - // search without result - phoneBook[number].name = name; + if (name != number) + { + // search without result + phoneBook[number].name = name; - if (currentMode == FritzBoxGuiMode.CallList) - { - GUIListItem item = facadeView[index]; + if (currentMode == FritzBoxGuiMode.CallList) + { + GUIListItem item = facadeView[index]; - if (item != null) - { - Log.Debug("replacing label {0} with {1}", item.Label2, name); - string l = name; + if (item != null) + { + Log.Debug("replacing label {0} with {1}", item.Label2, name); + string l = name; - if (l.Length > 30) l = name.Substring(0, 30); + if (l.Length > 30) l = name.Substring(0, 30); - item.Label2 = l; - } + item.Label2 = l; + } + } + } + } } - } } - } - } - protected void loadCallListFromFritzbox(bool forceReload) - { - GUIWaitCursor.Show(); - try - { - Log.Debug("load callitem from fritzbox"); - byte[] data = fritz.loadCallListData(forceReload); - refreshCallData(data); - } - catch (Exception e) - { - Log.Debug("Exception {0}", e.Message); - } - GUIWaitCursor.Hide(); - } + protected void loadCallListFromFritzbox(bool forceReload) + { + if (!String.IsNullOrEmpty(passwd)) + { + GUIWaitCursor.Show(); - protected string decode(VoiceBoxItem item) - { - System.Diagnostics.Process proc = new System.Diagnostics.Process(); - proc.EnableRaisingEvents = false; - proc.StartInfo.FileName = "speexdec"; - string target = Path.GetTempPath() + item.seq + ".wav"; - proc.StartInfo.Arguments = "\"" + vBPath + "\\rec\\" + item.filename + "\" \"" + target + "\""; - proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + try + { + Log.Debug("load call list from FritzBox"); - proc.Start(); - proc.WaitForExit(); - proc.Close(); + byte[] data = fritz.loadCallListData(forceReload); - filesToDelete.Add(target); + refreshCallData(data); + } + catch (Exception e) + { + Log.Debug("Exception {0}", e.Message); + } - return target; - } + GUIWaitCursor.Hide(); + } + else Log.Debug("FritzBox password is not set. Call list cannot be loaded"); + } - protected void populatePhonebookItems() - { - facadeView.Clear(); - - if (fritzPhonebooks.Items == null || fritzPhonebooks.Items.GetLength(0) == 0) - { - Log.Debug("no fritz phone book items found"); + protected string decode(VoiceBoxItem item) + { + System.Diagnostics.Process proc = new System.Diagnostics.Process(); + proc.EnableRaisingEvents = false; + proc.StartInfo.FileName = "speexdec"; + string target = Path.GetTempPath() + item.seq + ".wav"; + proc.StartInfo.Arguments = "\"" + vBPath + "\\rec\\" + item.filename + "\" \"" + target + "\""; + proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; - return; - } - - Phonebook p = fritzPhonebooks.Items[0]; // always choose first phone book - int i = 0; - string thumbDir = Config.GetFolder(Config.Dir.Thumbs) + "\\yac\\"; + proc.Start(); + proc.WaitForExit(); + proc.Close(); - foreach (Contact c in p.contact) - { - string name = c.person[0].realName; + filesToDelete.Add(target); - foreach (TelephonyNumber number in c.telephony) - { - GUIListItem elem = new GUIListItem(); - elem.Label = name; - elem.Label2 = number.Value; - - if (elem.Label2.Length > 0) - { - if (File.Exists(thumbDir + c.person[0].realName + ".jpg")) elem.ThumbnailImage = thumbDir + c.person[0].realName + ".jpg"; - else elem.ThumbnailImage = thumbDir + "_noImage.png"; - - elem.Path = Convert.ToString(i++); - - facadeView.Add(elem); - } + return target; } - } - } - /// <summary> - /// fill in voice box i... [truncated message content] |