From: <che...@us...> - 2009-12-11 14:25:39
|
Revision: 3226 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3226&view=rev Author: chef_koch Date: 2009-12-11 14:24:43 +0000 (Fri, 11 Dec 2009) Log Message: ----------- first commit for merging FritzManager into FritzBoxCallMonitor Modified Paths: -------------- trunk/plugins/FritzBox/FritzBox/FritzBox.cs trunk/plugins/FritzBox/FritzBox/FritzBox.csproj trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.Designer.cs trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.cs trunk/plugins/FritzBox/FritzBox/Settings.cs trunk/plugins/FritzBox/FritzBox.sln Added Paths: ----------- trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/ trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/CallAction.cs trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/Caller.cs trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/FritzBoxClient.cs trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/PhoneBook.cs trunk/plugins/FritzBox/FritzBox/FritzManager/ trunk/plugins/FritzBox/FritzBox/FritzManager/ABReader.cs trunk/plugins/FritzBox/FritzBox/FritzManager/CallItem.cs trunk/plugins/FritzBox/FritzBox/FritzManager/Changes.txt trunk/plugins/FritzBox/FritzBox/FritzManager/Fritz.cs trunk/plugins/FritzBox/FritzBox/FritzManager/GCollections.cs trunk/plugins/FritzBox/FritzBox/FritzManager/Install.txt trunk/plugins/FritzBox/FritzBox/FritzManager/MyBinaryReader.cs trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/ trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/Black & White/ trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/Black & White/FritzManager.xml trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/Black & White/Media/ trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/Black & White/Media/callin.png trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/Black & White/Media/callout.png trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/Black & White/Media/rejected.png trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/Blue3/ trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/Blue3/FritzManager.xml trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/Blue3/Media/ trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/Blue3/Media/callin.png trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/Blue3/Media/callout.png trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/Blue3/Media/rejected.png trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/GenericSkin/ trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/GenericSkin/FritzManager.xml trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/GenericSkin/Media/ trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/GenericSkin/Media/callin.png trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/GenericSkin/Media/callout.png trunk/plugins/FritzBox/FritzBox/FritzManager/Skin/GenericSkin/Media/rejected.png trunk/plugins/FritzBox/FritzBox/FritzManager/VoiceboxItem.cs trunk/plugins/FritzBox/FritzBox/FritzManager/todo.txt trunk/plugins/FritzBox/FritzBox/Resources/ trunk/plugins/FritzBox/FritzBox/Resources/ContactImages/ trunk/plugins/FritzBox/FritzBox/Resources/MpeRelease/ trunk/plugins/FritzBox/FritzBox/Resources/fritzdial.sh trunk/plugins/FritzBox/FritzBox/Resources/gfx/ trunk/plugins/FritzBox/FritzBox/Resources/speexdec.exe Removed Paths: ------------- trunk/plugins/FritzBox/FritzBox/CallAction.cs trunk/plugins/FritzBox/FritzBox/Caller.cs trunk/plugins/FritzBox/FritzBox/ContactImages/ trunk/plugins/FritzBox/FritzBox/FritzBoxClient.cs trunk/plugins/FritzBox/FritzBox/MpeRelease/ trunk/plugins/FritzBox/FritzBox/PhoneBook.cs trunk/plugins/FritzBox/FritzBox/gfx/ Deleted: trunk/plugins/FritzBox/FritzBox/CallAction.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/CallAction.cs 2009-12-11 11:53:48 UTC (rev 3225) +++ trunk/plugins/FritzBox/FritzBox/CallAction.cs 2009-12-11 14:24:43 UTC (rev 3226) @@ -1,62 +0,0 @@ -#region Copyright (C) 2005-2009 Team MediaPortal - -// Copyright (C) 2005-2009 Team MediaPortal -// http://www.team-mediaportal.com -// -// This Program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2, or (at your option) -// any later version. -// -// This Program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GNU Make; see the file COPYING. If not, write to -// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -// http://www.gnu.org/copyleft/gpl.html - -#endregion - -using System; -using MediaPortal.ServiceImplementations; - -namespace FritzBox -{ - public class CallAction - { - public enum CallType - { - Incoming, - Outgoing, - ConnectionStarted, - ConnectionClosed, - } - - public CallType Type { get; set; } - public DateTime Time { get; set; } - public Caller Caller { get; set; } - public string MSN { get; set; } - - - public CallAction() - { - Time = DateTime.MinValue; - Caller = new Caller(); - MSN = string.Empty; - } - - - public void WriteToLog() - { - Log.Info("CallAction Info:"); - Log.Info(" CallType: {0}", Type.ToString()); - Log.Info(" Date: {0}", Time.ToShortDateString()); - Log.Info(" Time: {0}", Time.ToShortTimeString()); - Log.Info(" Caller: {0}", Caller.ID); - Log.Info(" MSN: {0}", MSN); - } - } -} \ No newline at end of file Deleted: trunk/plugins/FritzBox/FritzBox/Caller.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/Caller.cs 2009-12-11 11:53:48 UTC (rev 3225) +++ trunk/plugins/FritzBox/FritzBox/Caller.cs 2009-12-11 14:24:43 UTC (rev 3226) @@ -1,45 +0,0 @@ -#region Copyright (C) 2005-2009 Team MediaPortal - -// Copyright (C) 2005-2009 Team MediaPortal -// http://www.team-mediaportal.com -// -// This Program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2, or (at your option) -// any later version. -// -// This Program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GNU Make; see the file COPYING. If not, write to -// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -// http://www.gnu.org/copyleft/gpl.html - -#endregion - -namespace FritzBox -{ - public class Caller - { - public Caller() - { - ID = string.Empty; - Name = string.Empty; - Show = true; - } - - public Caller(string id, string name, bool show) - { - ID = id; - Name = name; - Show = show; - } - - public string ID { get; set; } - public string Name { get; set; } - public bool Show { get; set; } - } -} \ No newline at end of file Modified: trunk/plugins/FritzBox/FritzBox/FritzBox.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBox.cs 2009-12-11 11:53:48 UTC (rev 3225) +++ trunk/plugins/FritzBox/FritzBox/FritzBox.cs 2009-12-11 14:24:43 UTC (rev 3226) @@ -23,8 +23,11 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Reflection; +using FritzManager; +using GCollections; using MediaPortal.Configuration; using MediaPortal.Dialogs; using MediaPortal.GUI.Library; @@ -34,28 +37,30 @@ namespace FritzBox { [PluginIcons("FritzBox.FritzBox.png", "FritzBox.FritzBoxDisabled.png")] - public class FritzBox : ISetupForm, IPlugin + public class FritzBox : GUIWindow, ISetupForm, IPlugin { + #region CallMonitor + #region Constants - private static string ContactPicturesFolder = Config.GetSubFolder(Config.Dir.Thumbs, "FritzBox.Contacts"); + private static readonly string _contactPicturesFolder = Config.GetSubFolder(Config.Dir.Thumbs, "FritzBox.Contacts"); - private static string SkinMediaFolder = Path.Combine(GUIGraphicsContext.Skin, "Media"); + private static readonly string _skinMediaFolder = + Path.Combine(Config.GetSubFolder(Config.Dir.Skin, Settings.MediaPortalSkin), "Media"); - #endregion + #endregion Constants #region Variables private readonly List<CallAction> _actionList = new List<CallAction>(); - private object _tempNotify = null; + private readonly List<CallAction> _notifyQueue = new List<CallAction>(); + private bool _showNotify = true; + private object _tempNotify; - private int notifyCount = 0; + private int notifyCount; - private bool _showNotify = true; - private readonly List<CallAction> _notifyQueue = new List<CallAction>(); + #endregion Variables - #endregion - #region Properties public string UnknownCallerImage @@ -65,11 +70,11 @@ string filePath; // check if skin supports it's own images - filePath = Utils.GetCoverArt(SkinMediaFolder, "FritzBox.CallMonitor.Unknown"); + filePath = Utils.GetCoverArt(_skinMediaFolder, "FritzBox.CallMonitor.Unknown"); if (!String.IsNullOrEmpty(filePath)) return filePath; // use new default image - filePath = Utils.GetCoverArt(ContactPicturesFolder, "FritzBox.CallMonitor.Unknown"); + filePath = Utils.GetCoverArt(_contactPicturesFolder, "FritzBox.CallMonitor.Unknown"); if (!String.IsNullOrEmpty(filePath)) return filePath; // use old default image @@ -87,11 +92,11 @@ string filePath; // check if skin supports it's own images - filePath = Utils.GetCoverArt(SkinMediaFolder, "FritzBox.CallMonitor.Missing"); + filePath = Utils.GetCoverArt(_skinMediaFolder, "FritzBox.CallMonitor.Missing"); if (!String.IsNullOrEmpty(filePath)) return filePath; // use new default image - filePath = Utils.GetCoverArt(ContactPicturesFolder, "FritzBox.CallMonitor.Missing"); + filePath = Utils.GetCoverArt(_contactPicturesFolder, "FritzBox.CallMonitor.Missing"); if (!String.IsNullOrEmpty(filePath)) return filePath; // use old default image @@ -248,9 +253,9 @@ string filePath; // use new image path - filePath = Utils.GetCoverArt(ContactPicturesFolder, callerId); + filePath = Utils.GetCoverArt(_contactPicturesFolder, callerId); if (!String.IsNullOrEmpty(filePath)) return filePath; - Log.Info("found image not in: " + ContactPicturesFolder); + Log.Info("found image not in: " + _contactPicturesFolder); // use old image path filePath = Utils.GetCoverArt(Thumbs.Yac, callerId); @@ -355,6 +360,8 @@ #endregion + #endregion CallMonitor + #region <Interface> Implementations #region IPlugin Interface @@ -367,11 +374,11 @@ Log.Info("FRITZ!Box Plugin {0} starting.", Assembly.GetExecutingAssembly().GetName().Version); Settings.Load(); - Utils.OnStartExternal += new Utils.UtilEventHandler(OnStartExternal); - Utils.OnStopExternal += new Utils.UtilEventHandler(OnStopExternal); + Utils.OnStartExternal += OnStartExternal; + Utils.OnStopExternal += OnStopExternal; - FritzBoxClient.LogEvent += new FritzBoxClient.LogEventHandler(OnLogAction); - FritzBoxClient.CallEvent += new FritzBoxClient.CallEventHandler(OnCallAction); + FritzBoxClient.LogEvent += OnLogAction; + FritzBoxClient.CallEvent += OnCallAction; FritzBoxClient.StartClient(); } @@ -383,11 +390,11 @@ Log.Info("FRITZ!Box Plugin {0} stopping.", Assembly.GetExecutingAssembly().GetName().Version); FritzBoxClient.StopClient(); - FritzBoxClient.CallEvent -= new FritzBoxClient.CallEventHandler(OnCallAction); - FritzBoxClient.LogEvent -= new FritzBoxClient.LogEventHandler(OnLogAction); + FritzBoxClient.CallEvent -= OnCallAction; + FritzBoxClient.LogEvent -= OnLogAction; - Utils.OnStartExternal -= new Utils.UtilEventHandler(OnStartExternal); - Utils.OnStopExternal -= new Utils.UtilEventHandler(OnStopExternal); + Utils.OnStartExternal -= OnStartExternal; + Utils.OnStopExternal -= OnStopExternal; PhoneBook.SaveSettings(); } @@ -396,6 +403,16 @@ #region ISetupForm Member + /// <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 string PluginName() { return "FRITZ!Box CallMonitor"; @@ -403,12 +420,12 @@ public string Author() { - return "chefkoch"; + return "chefkoch, S.Rinke"; } public string Description() { - return "Displays FRITZ!Box calling information."; + return "Displays FRITZ!Box caller lists and voice box infos and notifies on incoming calls."; } public void ShowPlugin() @@ -431,7 +448,7 @@ public int GetWindowId() { - return -1; + return 464554871; } public bool DefaultEnabled() @@ -447,15 +464,612 @@ public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage) { - strButtonText = null; - strButtonImage = null; - strButtonImageFocus = null; - strPictureImage = null; - return false; + strButtonText = "Telefon"; + strButtonImage = String.Empty; + strButtonImageFocus = String.Empty; + strPictureImage = String.Empty; + return true; } #endregion #endregion + + #region FritzManager + + #region enums + + #region Nested type: Filter + + private enum Filter + { + All = 0, + Incoming = 1, + Outgoing = 2, + Rejected = 3 + } + + #endregion + + #region Nested type: Mode + + private enum Mode + { + CallList = 0, + Voicebox = 1 + } + + #endregion + + #region Nested type: View + + private enum View + { + List = 0, + Icons = 1, + LargeIcons = 2, + } + + #endregion + + #endregion + + #region skin + + [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; + + #endregion + + #region fields + + private string abpath; + private List<CallItem> callItemList; + private Filter currentFilter = Filter.All; + private Mode currentMode = Mode.Voicebox; + private View currentView = View.List; + private string dialport; + private Fritz fritz; + private DateTime lastCalllistUpdate = DateTime.Now.AddMinutes(-20.0); + private HashMap<string, string> msns = new HashMap<string, string>(); + + private string passwd; + private HashMap<string, string> phoneBook = new HashMap<string, string>(); + private List<VoiceboxItem> voiceboxItemList; + + #endregion + + private List<string> filesToDelete = new List<string>(); + + public override bool Init() + { + return Load(GUIGraphicsContext.Skin + @"\FritzManager.xml"); + } + + protected override void OnPageLoad() + { + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("MediaPortal.xml")) + { + passwd = xmlreader.GetValue("FritzManager", "passwd"); + abpath = xmlreader.GetValue("FritzManager", "abpath"); + dialport = xmlreader.GetValue("FritzManager", "dialport"); + string modestr = xmlreader.GetValue("FritzManager", "currentMode"); + if (modestr != null && modestr != "") + { + currentMode = (Mode) System.Enum.Parse(typeof (Mode), modestr); + } + } + fritz = new Fritz(); + initMsn(); + update(false); + ShowThumbPanel(); + } + + 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")) + { + while (!sr.EndOfStream) + { + string line = sr.ReadLine(); + string[] items = line.Split('='); + if (items.GetLength(0) > 1) msns.Add(items[0], items[1]); + } + } + } + } + + public override void DeInit() + { + cleanup(); + base.DeInit(); + } + + protected override void OnPageDestroy(int new_windowId) + { + cleanup(); + base.OnPageDestroy(new_windowId); + } + + private void cleanup() + { + // cleanup temp + foreach (string file in filesToDelete) + { + File.Delete(file); + } + filesToDelete.Clear(); + } + + protected void update(bool force) + { + if (currentMode == Mode.CallList) + { + if (force) + { + loadCallListFromFritzbox(); + } + else + { + if (DateTime.Now.Subtract(lastCalllistUpdate).Minutes > 2) + { + lastCalllistUpdate = DateTime.Now; + loadCallListFromFritzbox(); + } + } + populateCallItems(); + } + else if (currentMode == Mode.Voicebox) + { + if (abpath == null || abpath == "") + { + ShowError("Voicebox path not set"); + return; + } + voiceboxItemList = ABReader.loadVoiceboxDir(abpath); + populateVoiceboxItems(); + } + UpdateButtonStates(); + } + + protected void loadCallListFromFritzbox() + { + if (passwd == null) + { + ShowError("FritzBox Passwd nicht gesetzt"); + return; + } + try + { + Log.Debug("load callitem from fritzbox"); + GUIWaitCursor.Show(); + + + fritz.login(passwd); + fritz.refresh(); + + callItemList = CallItem.load(new MemoryStream(fritz.loadCallListData())); + // populate phonebook + foreach (CallItem i in callItemList) + { + if (i.name != "") + { + phoneBook[i.number] = i.name; + } + } + } + catch (Exception e) + { + Log.Debug("Exception {0}", e.Message); + } + GUIWaitCursor.Hide(); + } + + 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 = "\"" + abpath + "\\rec\\" + item.filename + "\" \"" + target + "\""; + proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + + proc.Start(); + proc.WaitForExit(); + proc.Close(); + filesToDelete.Add(target); + return target; + } + + /// <summary> + /// fill in voicebox items in facadeView + /// </summary> + protected void populateVoiceboxItems() + { + CultureInfo ci = CultureInfo.InvariantCulture; + string format = "dd.MM.yy HH:mm"; + facadeView.Clear(); + voiceboxItemList.Sort(VoiceboxItem.CompareByDate); + int i = 0; + foreach (VoiceboxItem item in voiceboxItemList) + { + if (item.type == 3) + { + GUIListItem elem = new GUIListItem(); + string caller = item.callerId; + if (phoneBook.Contains(caller)) + { + caller = phoneBook[caller]; + } + if (caller == "") + { + caller = "Unbekannt"; + } + string msnName = item.mynumber; + if (msns.Contains(item.mynumber)) + msnName = msns[item.mynumber]; + elem.Label = (item.isNew == 1 ? "* " : " ") + item.time.ToString(format, ci); + elem.Label2 = caller + " an " + msnName; + elem.Path = Convert.ToString(i); + elem.IconImageBig = "defaultAudioBig.png"; + elem.IconImage = "defaultAudio.png"; + elem.IsFolder = false; + string thumbDir = Config.GetFolder(Config.Dir.Thumbs) + "\\yac\\"; + if (File.Exists(thumbDir + caller + ".jpg")) + { + elem.ThumbnailImage = thumbDir + caller + ".jpg"; + } + else + { + elem.ThumbnailImage = thumbDir + "_noImage.png"; + } + facadeView.Add(elem); + } + i++; + } + } + + /// <summary> + /// fill in call items in facadeView + /// </summary> + protected void populateCallItems() + { + CultureInfo ci = CultureInfo.InvariantCulture; + string format = "dd.MM.yy HH:mm"; + facadeView.Clear(); + int i = 0; + foreach (CallItem item in callItemList) + { + GUIListItem elem = new GUIListItem(); + if (currentFilter == Filter.Rejected) + { + if (item.type != 2) continue; + } + if (currentFilter == Filter.Incoming) + { + if (item.type != 1) continue; + } + if (currentFilter == Filter.Outgoing) + { + if (item.type != 3) continue; + } + + elem.Label = item.timestamp.ToString(format, ci) + " - " + item.duration.ToString("HH:mm", ci); + if (item.name != "") + { + elem.Label2 = item.name; + } + else + { + elem.Label2 = item.number; + } + elem.Path = Convert.ToString(i); + + string thumbDir = Config.GetFolder(Config.Dir.Thumbs) + "\\yac\\"; + if (File.Exists(thumbDir + item.name + ".jpg")) + { + elem.ThumbnailImage = thumbDir + item.name + ".jpg"; + } + else + { + if (item.name == null || item.name == "") + { + elem.ThumbnailImage = thumbDir + "_unknown.png"; + } + else + { + elem.ThumbnailImage = thumbDir + "_noImage.png"; + } + } + string icon = "defaultAudioBig.png"; + if (item.type == 1) + { + icon = "callin.png"; + } + else if (item.type == 3) + { + icon = "callout.png"; + } + else if (item.type == 2) + { + icon = "rejected.png"; + } + elem.IconImageBig = icon; + elem.IconImage = icon; + + elem.IsFolder = false; + + facadeView.Add(elem); + i++; + } + } + + private void ShowThumbPanel() + { + int itemIndex = facadeView.SelectedListItemIndex; + if (currentView == View.LargeIcons) + { + facadeView.View = GUIFacadeControl.ViewMode.LargeIcons; + } + else if (currentView == View.Icons) + { + facadeView.View = GUIFacadeControl.ViewMode.SmallIcons; + } + else if (currentView == View.List) + { + facadeView.View = GUIFacadeControl.ViewMode.List; + } + + if (itemIndex > -1) + { + GUIControl.SelectItemControl(GetID, facadeView.GetID, itemIndex); + } + UpdateButtonStates(); + } + + protected override void OnShowContextMenu() + { + base.OnShowContextMenu(); + if (currentMode == Mode.Voicebox) + { + int r = ShowVoiceboxContextMenu(); + switch (r) + { + case 0: // play + g_Player.Play(decode(voiceboxItemList[Convert.ToInt16(facadeView.SelectedListItem.Path)])); + break; + case 1: + break; + } + } + else if (currentMode == Mode.CallList) + { + int r = ShowCallListContextMenu(); + switch (r) + { + case 0: // callback + CallItem item = callItemList[Convert.ToInt16(facadeView.SelectedListItem.Path)]; + fritz.dial(item.number, dialport); + break; + } + } + } + + protected override void OnClicked(int controlId, GUIControl control, + MediaPortal.GUI.Library.Action.ActionType actionType) + { + base.OnClicked(controlId, control, actionType); + + if (control == facadeView) + { + GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_SELECTED, GetID, 0, controlId, 0, 0, null); + OnMessage(msg); + int itemIndex = msg.Param1; + + if (actionType == MediaPortal.GUI.Library.Action.ActionType.ACTION_SELECT_ITEM) + { + GUIListItem actual = facadeView.SelectedListItem; + if (currentMode == Mode.Voicebox) + { + string tmp = decode(voiceboxItemList[Convert.ToInt16(actual.Path)]); + g_Player.Play(tmp); + } + } + } + + if (control == btnViewAs) + { + bool shouldContinue = false; + do + { + shouldContinue = false; + switch (currentView) + { + case View.List: + currentView = View.Icons; + if (facadeView.ThumbnailView == null) + shouldContinue = true; + else + facadeView.View = GUIFacadeControl.ViewMode.SmallIcons; + break; + + case View.Icons: + currentView = View.LargeIcons; + if (facadeView.ThumbnailView == null) + shouldContinue = true; + else + facadeView.View = GUIFacadeControl.ViewMode.LargeIcons; + break; + + case View.LargeIcons: + currentView = View.List; + if (facadeView.ListView == null) + shouldContinue = true; + else + facadeView.View = GUIFacadeControl.ViewMode.List; + break; + } + } while (shouldContinue); + + UpdateButtonStates(); + GUIControl.FocusControl(GetID, controlId); + return; + } + if (control == btnFilter) + { + switch (currentFilter) + { + case Filter.All: + currentFilter = Filter.Incoming; + break; + case Filter.Incoming: + currentFilter = Filter.Outgoing; + break; + case Filter.Outgoing: + currentFilter = Filter.Rejected; + break; + case Filter.Rejected: + currentFilter = Filter.All; + break; + } + populateCallItems(); + UpdateButtonStates(); + GUIControl.FocusControl(GetID, controlId); + } + if (control == btnUpdate) + { + update(true); + } + + if (control == btnModus) + { + switch (currentMode) + { + case Mode.CallList: + currentMode = Mode.Voicebox; + break; + case Mode.Voicebox: + currentMode = Mode.CallList; + break; + } + // TODO write currentMode + update(false); + } + } + + private int ShowCallListContextMenu() + { + GUIDialogMenu dlgMenu = (GUIDialogMenu) GUIWindowManager.GetWindow((int) GUIWindow.Window.WINDOW_DIALOG_MENU); + if (dlgMenu != null) + { + dlgMenu.Reset(); + dlgMenu.SetHeading("Anrufe"); + dlgMenu.Add("Zur\xFCckrufen"); + dlgMenu.DoModal(GetID); + + if (dlgMenu.SelectedLabel == -1) // Nothing was selected + return -1; + + return dlgMenu.SelectedLabel; + } + return -1; + } + + private int ShowVoiceboxContextMenu() + { + GUIDialogMenu dlgMenu = (GUIDialogMenu) GUIWindowManager.GetWindow((int) GUIWindow.Window.WINDOW_DIALOG_MENU); + if (dlgMenu != null) + { + dlgMenu.Reset(); + dlgMenu.SetHeading("Nachrichten"); + dlgMenu.Add("Nachricht abspielen"); + dlgMenu.Add("Nachricht als geh\xF6rt markieren"); + dlgMenu.Add("Nachricht l\xF6schen"); + dlgMenu.DoModal(GetID); + + if (dlgMenu.SelectedLabel == -1) // Nothing was selected + return -1; + + return dlgMenu.SelectedLabel; + } + return -1; + } + + private void UpdateButtonStates() + { + facadeView.IsVisible = false; + facadeView.IsVisible = true; + GUIControl.FocusControl(GetID, facadeView.GetID); + + string strLine = string.Empty; + View view = currentView; + switch (view) + { + case View.List: + strLine = GUILocalizeStrings.Get(101); + break; + case View.Icons: + strLine = GUILocalizeStrings.Get(100); + break; + case View.LargeIcons: + strLine = GUILocalizeStrings.Get(417); + break; + } + + if (btnViewAs != null) + { + btnViewAs.Label = strLine; + } + + switch (currentFilter) + { + case Filter.All: + strLine = "Alle"; //GUILocalizeStrings.Get(103); + break; + case Filter.Incoming: + strLine = "Eingehend"; //GUILocalizeStrings.Get(668); + break; + case Filter.Outgoing: + strLine = "Ausgehend"; //GUILocalizeStrings.Get(669); + break; + case Filter.Rejected: + strLine = "Abgelehnt"; + break; + } + + if (btnFilter != null) + { + btnFilter.Label = strLine; + btnFilter.IsAscending = true; + } + switch (currentMode) + { + case Mode.Voicebox: + btnModus.Label = "Anrufliste"; + break; + case Mode.CallList: + btnModus.Label = "Nachrichten"; + break; + } + } + + private void ShowError(string msg) + { + GUIDialogOK dlg = (GUIDialogOK) GUIWindowManager.GetWindow( + (int) GUIWindow.Window.WINDOW_DIALOG_OK); + dlg.SetHeading("Error"); + dlg.SetLine(1, msg); + dlg.SetLine(2, String.Empty); + dlg.SetLine(3, String.Empty); + dlg.DoModal(GUIWindowManager.ActiveWindow); + } + + #endregion FritzManager } } \ No newline at end of file Modified: trunk/plugins/FritzBox/FritzBox/FritzBox.csproj =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBox.csproj 2009-12-11 11:53:48 UTC (rev 3225) +++ trunk/plugins/FritzBox/FritzBox/FritzBox.csproj 2009-12-11 14:24:43 UTC (rev 3226) @@ -54,10 +54,16 @@ </Reference> </ItemGroup> <ItemGroup> - <Compile Include="FritzBoxClient.cs" /> + <Compile Include="FritzCallMonitor\FritzBoxClient.cs" /> + <Compile Include="FritzManager\ABReader.cs" /> + <Compile Include="FritzManager\CallItem.cs" /> + <Compile Include="FritzManager\Fritz.cs" /> + <Compile Include="FritzManager\GCollections.cs" /> + <Compile Include="FritzManager\MyBinaryReader.cs" /> + <Compile Include="FritzManager\VoiceboxItem.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="Caller.cs" /> - <Compile Include="CallAction.cs" /> + <Compile Include="FritzCallMonitor\Caller.cs" /> + <Compile Include="FritzCallMonitor\CallAction.cs" /> <Compile Include="FritzBoxConfig.cs"> <SubType>Form</SubType> </Compile> @@ -65,7 +71,7 @@ <DependentUpon>FritzBoxConfig.cs</DependentUpon> </Compile> <Compile Include="FritzBox.cs" /> - <Compile Include="PhoneBook.cs" /> + <Compile Include="FritzCallMonitor\PhoneBook.cs" /> <Compile Include="Properties\Resources.Designer.cs"> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> @@ -91,13 +97,30 @@ <EmbeddedResource Include="FritzBoxDisabled.png" /> </ItemGroup> <ItemGroup> - <Content Include="gfx\FritzBox.ico" /> - <Content Include="gfx\FritzBoxIconMadeByHarley.png" /> - <Content Include="ContactImages\FritzBox.CallMonitor.Missing.png" /> - <Content Include="ContactImages\FritzBox.CallMonitor.Unknown.png" /> + <None Include="FritzManager\Changes.txt" /> + <None Include="FritzManager\todo.txt" /> + <Content Include="FritzManager\Install.txt" /> + <Content Include="FritzManager\Skin\Black & White\FritzManager.xml" /> + <Content Include="FritzManager\Skin\Black & White\Media\callin.png" /> + <Content Include="FritzManager\Skin\Black & White\Media\callout.png" /> + <Content Include="FritzManager\Skin\Black & White\Media\rejected.png" /> + <Content Include="FritzManager\Skin\Blue3\FritzManager.xml" /> + <Content Include="FritzManager\Skin\Blue3\Media\callin.png" /> + <Content Include="FritzManager\Skin\Blue3\Media\callout.png" /> + <Content Include="FritzManager\Skin\Blue3\Media\rejected.png" /> + <Content Include="FritzManager\Skin\GenericSkin\FritzManager.xml" /> + <Content Include="FritzManager\Skin\GenericSkin\Media\callin.png" /> + <Content Include="FritzManager\Skin\GenericSkin\Media\callout.png" /> + <Content Include="FritzManager\Skin\GenericSkin\Media\rejected.png" /> + <Content Include="Resources\gfx\FritzBox.ico" /> + <Content Include="Resources\gfx\FritzBoxIconMadeByHarley.png" /> + <Content Include="Resources\ContactImages\FritzBox.CallMonitor.Missing.png" /> + <Content Include="Resources\ContactImages\FritzBox.CallMonitor.Unknown.png" /> + <Content Include="Resources\speexdec.exe" /> </ItemGroup> <ItemGroup> - <None Include="MpeRelease\FritzBox.xmp2" /> + <None Include="Resources\fritzdial.sh" /> + <None Include="Resources\MpeRelease\FritzBox.xmp2" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Deleted: trunk/plugins/FritzBox/FritzBox/FritzBoxClient.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBoxClient.cs 2009-12-11 11:53:48 UTC (rev 3225) +++ trunk/plugins/FritzBox/FritzBox/FritzBoxClient.cs 2009-12-11 14:24:43 UTC (rev 3226) @@ -1,401 +0,0 @@ -#region Copyright (C) 2005-2009 Team MediaPortal - -// Copyright (C) 2005-2009 Team MediaPortal -// http://www.team-mediaportal.com -// -// This Program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2, or (at your option) -// any later version. -// -// This Program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GNU Make; see the file COPYING. If not, write to -// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -// http://www.gnu.org/copyleft/gpl.html - -#endregion - -using System; -using System.Globalization; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Threading; - -namespace FritzBox -{ - public static class FritzBoxClient - { - #region class StateObject - - /// <summary> - /// State object for receiving data from remote device. - /// </summary> - private class StateObject - { - /// <summary> - /// Client socket. - /// </summary> - public Socket workSocket = null; - - /// <summary> - /// Size of receive buffer. - /// </summary> - public const int BufferSize = 256; - - /// <summary> - /// Receive buffer. - /// </summary> - public readonly byte[] buffer = new byte[BufferSize]; - - /// <summary> - /// Received data string. - /// </summary> - public StringBuilder sb = new StringBuilder(); - } - - public enum LogLevel - { - Info, - Warning, - Error, - Debug, - HeavyDebug, - } - - #endregion - - private static readonly TimeSpan minConnectWaitTime = new TimeSpan(0, 10, 0); - private static DateTime _connectionFailed; - - private static Socket _client; - - #region Properties - - public static string Address { get; set; } - public static int Port { get; set; } - - static FritzBoxClient() - { - Address = "fritz.box"; - Port = 1012; - } - - #endregion - - #region Public Events and Delegates - - public delegate void CallEventHandler(CallAction callAction); - - public static event CallEventHandler CallEvent; - - public delegate void LogEventHandler(LogLevel logLevel, string logMessage); - - public static event LogEventHandler LogEvent; - - #endregion - - #region Public methods - - public static void StartClient() - { - try - { - _connectionFailed = DateTime.MinValue; - - Thread thread = new Thread(new ThreadStart(Connect)); - thread.Start(); - } - catch (Exception ex) - { - Log(ex); - } - } - - public static void StopClient() - { - try - { - // Release the socket. - _client.Shutdown(SocketShutdown.Both); - _client.Close(); - } - catch (Exception ex) - { - Log(ex); - } - } - - public static bool TestConnection() - { - try - { - Log(LogLevel.Info, "Testing address ({0}) and port ({1})", Address, Port); - TcpClient tcpClient; - - try - { - tcpClient = new TcpClient(Address, Port); - } - catch (Exception) - { - Log(LogLevel.Error, - "Address&Port test failed! :(" + Environment.NewLine + - " Did you entered correct connection information?" + Environment.NewLine + - " Are you using the latest FRITZ!Box firmware?" + Environment.NewLine + - " Did you opened the port on your FRITZ!Box? If not, call #96*5* from your phone."); - return false; - } - - tcpClient.Close(); - Log(LogLevel.Info, "Testing Address&Port succeeded."); - return true; - } - catch (Exception ex) - { - Log(ex); - return false; - } - } - - #endregion - - #region Private methods - - private static void ReConnect() - { - try - { - _connectionFailed = DateTime.Now; - - Thread thread = new Thread(new ThreadStart(Connect)); - thread.Start(); - } - catch (Exception ex) - { - Log(ex); - } - } - - private static void Connect() - { - // Enforce a minimum wait time between connects. - DateTime nextconnect = _connectionFailed.Add(minConnectWaitTime); - if (DateTime.Now < nextconnect) - { - TimeSpan waittime = nextconnect - DateTime.Now; - Log(LogLevel.Debug, "Avoiding too much reconnects, sleeping until {0}.", nextconnect.ToString()); - Thread.Sleep(waittime); - } - - try - { - //Establish the remote endpoint for the socket. - //The name of the - //remote device is "host.contoso.com". - IPHostEntry ipHostInfo = Dns.GetHostEntry(Address); - IPAddress ipAddress = ipHostInfo.AddressList[0]; - IPEndPoint remoteEP = new IPEndPoint(ipAddress, Port); - - // Create a TCP/IP socket. - _client = new Socket(AddressFamily.InterNetwork, - SocketType.Stream, ProtocolType.Tcp); - - // Connect to the remote endpoint. - _client.BeginConnect(Address, Port, new AsyncCallback(ConnectCallback), _client); - } - catch (SocketException) - { - Log(LogLevel.Debug, "Connect: SocketException"); - Log(LogLevel.Info, "FRITZ!BOX connection lost, trying to reconnect."); - ReConnect(); - } - catch (Exception ex) - { - Log(ex); - } - } - - private static void ConnectCallback(IAsyncResult ar) - { - try - { - // Retrieve the socket from the state object. - Socket client = (Socket) ar.AsyncState; - - // Complete the connection. - client.EndConnect(ar); - - Log(LogLevel.Debug, "Socket connected to {0}", - client.RemoteEndPoint.ToString()); - - Receive(client); - } - catch (SocketException) - { - Log(LogLevel.Debug, "Connect: SocketException"); - Log(LogLevel.Info, "FRITZ!BOX connection lost, trying to reconnect."); - ReConnect(); - } - catch (Exception ex) - { - Log(ex); - } - } - - - private static void Receive(Socket client) - { - try - { - // Create the state object. - //Log(LogLevel.HeavyDebug, "StateObject state = new StateObject();"); - StateObject state = new StateObject(); - //Log(LogLevel.HeavyDebug, "state.workSocket = client;"); - state.workSocket = client; - - //Log(LogLevel.HeavyDebug, "Available {0}", client.Available); - //Log(LogLevel.HeavyDebug, "Connected {0}", client.Connected); - //Log(LogLevel.HeavyDebug, "IsBound {0}", client.IsBound); - //Log(LogLevel.HeavyDebug, "{0}", client.Connected); - - // Begin receiving the data from the remote device. - //Log(LogLevel.HeavyDebug, "client.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0,"); - client.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, - new AsyncCallback(ReceiveCallback), state); - } - catch (SocketException ex) - { - Log(LogLevel.HeavyDebug, "{0}", ex.NativeErrorCode); - Log(LogLevel.HeavyDebug, "{0}", ex.SocketErrorCode); - Log(LogLevel.HeavyDebug, "{0}", ex.Data); - Log(LogLevel.HeavyDebug, "{0}", ex.ErrorCode); - Log(LogLevel.HeavyDebug, "{0}", ex.InnerException); - Log(LogLevel.HeavyDebug, ex.Message); - Log(LogLevel.HeavyDebug, ex.Source); - Log(LogLevel.HeavyDebug, ex.StackTrace); - Log(LogLevel.Debug, "Receive: SocketException"); - Log(LogLevel.Info, "FRITZ!BOX connection lost, trying to reconnect."); - ReConnect(); - } - catch (Exception ex) - { - Log(ex); - } - } - - private static void ReceiveCallback(IAsyncResult ar) - { - try - { - // Retrieve the state object and the client socket - // from the asynchronous state object. - StateObject state = (StateObject) ar.AsyncState; - Socket client = state.workSocket; - - // Read data from the remote device. - int bytesRead = client.EndReceive(ar); - - if (bytesRead > 0) - { - // There might be more data, so store the data received so far. - string data = Encoding.ASCII.GetString(state.buffer, 0, bytesRead); - Log(LogLevel.HeavyDebug, "ReceiveCallback : received data: {0}", data); - //Log.Debug();"ReceiveCallback : received data: {0}", data - - // data-stream can be in following format: - // incoming calls: DateTime;RING;ConnectionID;CallerID;MSN;??POTS??; - // outgoing calls: DateTime;CALL;ConnectionID;??Nebenstelle??;MSN;CallerID;??POTS??; - // connection started: DateTime;CONNECT;ConnectionID;??Nebenstelle??;CallerID; - // connection closed: DateTime;DISCONNECT;ConnectionID;ConnectedTime; - - // DateTime format: - // 12.12.06 12:12:12 - // dd.MM.yy hh:mm:ss - - string[] strList = data.Trim().Split(';'); - CallAction callAction = new CallAction(); - - // time when action happens - callAction.Time = DateTime.Parse(strList[0], new CultureInfo("de-DE", false)); - - // set the type of the callAction - switch (strList[1]) - { - case "RING": - callAction.Type = CallAction.CallType.Incoming; - // sets the callerID - callAction.Caller.ID = strList[3]; - callAction.MSN = strList[4]; - break; - case "CALL": - callAction.Type = CallAction.CallType.Outgoing; - // sets the callerID - callAction.Caller.ID = strList[5]; - callAction.MSN = strList[4]; - break; - case "CONNECT": - callAction.Type = CallAction.CallType.ConnectionStarted; - // sets the callerID - callAction.Caller.ID = strList[4]; - break; - case "DISCONNECT": - callAction.Type = CallAction.CallType.ConnectionClosed; - break; - default: - callAction = null; - break; - } - - // continue to listen to the fb - client.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, - new AsyncCallback(ReceiveCallback), state); - - if (CallEvent != null) - CallEvent(callAction); - } - else - { - Log(LogLevel.Debug, "ReceiveCallback: no bytes to read"); - Log(LogLevel.Info, "FRITZ!BOX connection lost, trying to reconnect."); - ReConnect(); - } - } - catch (ObjectDisposedException) - { - Log(LogLevel.Debug, "ReceiveCallback: ObjectDisposedException"); - Log(LogLevel.Info, "FRITZ!BOX connection shut down."); - } - catch (SocketException) - { - Log(LogLevel.Debug, "ReceiveCallback: SocketException"); - Log(LogLevel.Info, "FRITZ!BOX connection lost, trying to reconnect."); - ReConnect(); - } - catch (Exception ex) - { - Log(ex); - } - } - - - private static void Log(LogLevel logLevel, string format, params object[] arg) - { - if (LogEvent != null) - LogEvent(logLevel, String.Format(format, arg)); - } - - private static void Log(Exception ex) - { - if (LogEvent != null) - LogEvent(LogLevel.Error, ex.ToString()); - } - - #endregion - } -} \ No newline at end of file Modified: trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.Designer.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.Designer.cs 2009-12-11 11:53:48 UTC (rev 3225) +++ trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.Designer.cs 2009-12-11 14:24:43 UTC (rev 3226) @@ -84,6 +84,13 @@ this.labelVersion = new MediaPortal.UserInterface.Controls.MPLabel(); this.okButton = new MediaPortal.UserInterface.Controls.MPButton(); this.cancelButton = new MediaPortal.UserInterface.Controls.MPButton(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.label3 = new System.Windows.Forms.Label(); + this.dialPort = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.abpath = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.passwd = new System.Windows.Forms.TextBox(); this.tabControlFritzBoxSettings.SuspendLayout(); this.tabGeneral.SuspendLayout(); this.mpGroupBox1.SuspendLayout(); @@ -99,6 +106,7 @@ this.tabPhonebook.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCaller)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.tabPage1.SuspendLayout(); this.SuspendLayout(); // // tabControlFritzBoxSettings @@ -109,6 +117,7 @@ this.tabControlFritzBoxSettings.Controls.Add(this.tabGeneral); this.tabControlFritzBoxSettings.Controls.Add(this.tabIncoming); this.tabControlFritzBoxSettings.Controls.Add(this.tabPhonebook); + this.tabControlFritzBoxSettings.Controls.Add(this.tabPage1); this.tabControlFritzBoxSettings.Location = new System.Drawing.Point(11, 12); this.tabControlFritzBoxSettings.Name = "tabControlFritzBoxSettings"; this.tabControlFritzBoxSettings.SelectedIndex = 0; @@ -767,6 +776,72 @@ this.cancelButton.UseVisualStyleBackColor = true; this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); // + // tabPage1 + // + this.tabPage1.Controls.Add(this.label3); + this.tabPage1.Controls.Add(this.dialPort); + this.tabPage1.Controls.Add(this.label2); + this.tabPage1.Controls.Add(this.abpath); + this.tabPage1.Controls.Add(this.label1); + this.tabPage1.Controls.Add(this.passwd); + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(573, 357); + this.tabPage1.TabIndex = 3; + this.tabPage1.Text = "FritzManager"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(187, 22); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(100, 23); + this.label3.TabIndex = 13; + this.label3.Text = "DialPort"; + this.label3.TextAlign = System.Drawing.ContentAlignment.BottomLeft; + // + // dialPort + // + this.dialPort.Location = new System.Drawing.Point(187, 51); + this.dialPort.Name = "dialPort"; + this.dialPort.Size = new System.Drawing.Size(100, 20); + this.dialPort.TabIndex = 12; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(26, 83); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(195, 23); + this.label2.TabIndex = 11; + this.label2.Text = "Pfad zum Anrufbeantworter"; + this.label2.TextAlign = System.Drawing.ContentAlignment.BottomLeft; + // + // abpath + // + this.abpath.Location = new System.Drawing.Point(26, 112); + this.abpath.Name = "abpath"; + this.abpath.Size = new System.Drawing.Size(236, 20); + this.abpath.TabIndex = 10; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(26, 22); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(100, 23); + this.label1.TabIndex = 9; + this.label1.Text = "Fritzbox-Passwd"; + this.label1.TextAlign = System.Drawing.ContentAlignment.BottomLeft; + // + // passwd + // + this.passwd.Location = new System.Drawing.Point(26, 51); + this.passwd.Name = "passwd"; + this.passwd.PasswordChar = '*'; + this.passwd.Size = new System.Drawing.Size(100, 20); + this.passwd.TabIndex = 8; + this.passwd.Text = "passwd"; + // // FritzBoxConfig // this.AcceptButton = this.okButton; @@ -808,6 +883,8 @@ this.tabPhonebook.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCaller)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.tabPage1.ResumeLayout(false); + this.tabPage1.PerformLayout(); this.ResumeLayout(false); } @@ -869,5 +946,12 @@ private MediaPortal.UserInterface.Controls.MPLabel labelSuffixHome; private MediaPortal.UserInterface.Controls.MPButton mpButton1; private System.Windows.Forms.TextBox labelHelp; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox dialPort; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox abpath; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox passwd; } } \ No newline at end of file Modified: trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.cs =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.cs 2009-12-11 11:53:48 UTC (rev 3225) +++ trunk/plugins/FritzBox/FritzBox/FritzBoxConfig.cs 2009-12-11 14:24:43 UTC (rev 3226) @@ -30,8 +30,6 @@ { public partial class FritzBoxConfig : Form { - private delegate void SetTextCallback(FritzBoxClient.LogLevel logLevel, string logMessage); - public FritzBoxConfig() { InitializeComponent(); @@ -86,6 +84,11 @@ textBoxSuffixMobile.Text = PhoneBook.SuffixMobile; RefreshDataGridView(); + + // fritzmanager settings + passwd.Text = Settings.FmPassword; + abpath.Text = Settings.FmABPath; + dialPort.Text = Settings.FmDialPort; } private void SaveSettings() @@ -124,6 +127,11 @@ SaveDataGridView(); + // fritzmanager settings + Settings.FmPassword = passwd.Text; + Settings.FmABPath = abpath.Text; + Settings.FmDialPort = dialPort.Text; + Settings.Save(); } @@ -135,14 +143,14 @@ { SaveSettings(); FritzBoxClient.StopClient(); - FritzBoxClient.LogEvent -= new FritzBoxClient.LogEventHandler(OnLogAction); + FritzBoxClient.LogEvent -= OnLogAction; Close(); } private void cancelButton_Click(object sender, EventArgs e) { FritzBoxClient.StopClient(); - FritzBoxClient.LogEvent -= new FritzBoxClient.LogEventHandler(OnLogAction); + FritzBoxClient.LogEvent -= OnLogAction; Close(); } @@ -170,10 +178,10 @@ checkBoxSaveUnknownCaller.Enabled = checkBoxUsePhonebook.Checked; } - + private void buttonMSNsAdd_Click(object sender, EventArgs e) { - if (isMSNvalid(comboBoxMSNs.Text) == true) + if (isMSNvalid(comboBoxMSNs.Text)) comboBoxMSNs.Items.Add(comboBoxMSNs.Text); } @@ -265,7 +273,7 @@ int count = PhoneBook.ImportFritzBoxMonitor(openFileDialog.FileName); RefreshDataGridView(); - MessageBox.Show("Import done!\nAdded " + count.ToString() + " new CallerIDs to phonebook."); + MessageBox.Show("Import done!\nAdded " + count + " new CallerIDs to phonebook."); } } @@ -293,8 +301,8 @@ private void mpButton1_Click(object sender, EventArgs e) { - FritzBoxClient.LogEvent -= new FritzBoxClient.LogEventHandler(OnLogAction); - FritzBoxClient.LogEvent += new FritzBoxClient.LogEventHandler(OnLogAction); + FritzBoxClient.LogEvent -= OnLogAction; + FritzBoxClient.LogEvent += OnLogAction; // stopping client FritzBoxClient.StopClient(); @@ -304,7 +312,7 @@ // set current used text FritzBoxClient.Address = textBoxAddress.Text; - FritzBoxClient.Port = (int)numericUpDownPort.Value; + FritzBoxClient.Port = (int) numericUpDownPort.Value; // port test if (!FritzBoxClient.TestConnection()) @@ -397,7 +405,7 @@ { if (labelHelp.InvokeRequired) { - SetTextCallback d = new SetTextCallback(OnLogAction); + SetTextCallback d = OnLogAction; Invoke(d, new object[] {logLevel, logMessage}); } else @@ -405,5 +413,11 @@ labelHelp.Text += logMessage + Environment.NewLine; } } + + #region Nested type: SetTextCallback + + private delegate void SetTextCallback(FritzBoxClient.LogLevel logLevel, string logMessage); + + #endregion } } \ No newline at end of file Copied: trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/CallAction.cs (from rev 3225, trunk/plugins/FritzBox/FritzBox/CallAction.cs) =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/CallAction.cs (rev 0) +++ trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/CallAction.cs 2009-12-11 14:24:43 UTC (rev 3226) @@ -0,0 +1,65 @@ +#region Copyright (C) 2005-2009 Team MediaPortal + +// Copyright (C) 2005-2009 Team MediaPortal +// http://www.team-mediaportal.com +// +// This Program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This Program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with GNU Make; see the file COPYING. If not, write to +// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +// http://www.gnu.org/copyleft/gpl.html + +#endregion + +using System; +using MediaPortal.ServiceImplementations; + +namespace FritzBox +{ + public class CallAction + { + #region CallType enum + + public enum CallType + { + Incoming, + Outgoing, + ConnectionStarted, + ConnectionClosed, + } + + #endregion + + public CallAction() + { + Time = DateTime.MinValue; + Caller = new Caller(); + MSN = string.Empty; + } + + public CallType Type { get; set; } + public DateTime Time { get; set; } + public Caller Caller { get; set; } + public string MSN { get; set; } + + + public void WriteToLog() + { + Log.Info("CallAction Info:"); + Log.Info(" CallType: {0}", Type.ToString()); + Log.Info(" Date: {0}", Time.ToShortDateString()); + Log.Info(" Time: {0}", Time.ToShortTimeString()); + Log.Info(" Caller: {0}", Caller.ID); + Log.Info(" MSN: {0}", MSN); + } + } +} \ No newline at end of file Copied: trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/Caller.cs (from rev 3225, trunk/plugins/FritzBox/FritzBox/Caller.cs) =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/Caller.cs (rev 0) +++ trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/Caller.cs 2009-12-11 14:24:43 UTC (rev 3226) @@ -0,0 +1,45 @@ +#region Copyright (C) 2005-2009 Team MediaPortal + +// Copyright (C) 2005-2009 Team MediaPortal +// http://www.team-mediaportal.com +// +// This Program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This Program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with GNU Make; see the file COPYING. If not, write to +// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +// http://www.gnu.org/copyleft/gpl.html + +#endregion + +namespace FritzBox +{ + public class Caller + { + public Caller() + { + ID = string.Empty; + Name = string.Empty; + Show = true; + } + + public Caller(string id, string name, bool show) + { + ID = id; + Name = name; + Show = show; + } + + public string ID { get; set; } + public string Name { get; set; } + public bool Show { get; set; } + } +} \ No newline at end of file Copied: trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/FritzBoxClient.cs (from rev 3225, trunk/plugins/FritzBox/FritzBox/FritzBoxClient.cs) =================================================================== --- trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/FritzBoxClient.cs (rev 0) +++ trunk/plugins/FritzBox/FritzBox/FritzCallMonitor/FritzBoxClient.cs 2009-12-11 14:24:43 UTC (rev 3226) @@ -0,0 +1,401 @@ +#region Copyright (C) 2005-2009 Team MediaPortal + +// Copyright (C) 2005-2009 Team MediaPortal +// http://www.team-mediaportal.com +// +// This Program is free software; you can re... [truncated message content] |