From: <bl...@us...> - 2008-01-07 10:53:22
|
Revision: 1221 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1221&view=rev Author: blaxwan Date: 2008-01-07 02:53:19 -0800 (Mon, 07 Jan 2008) Log Message: ----------- Added Paths: ----------- trunk/plugins/MySkype/ trunk/plugins/MySkype/MPInstaller/ trunk/plugins/MySkype/MPInstaller/MySkype.mpi trunk/plugins/MySkype/MySkype/ trunk/plugins/MySkype/MySkype/MySkype-Icon.png trunk/plugins/MySkype/MySkype/MySkype.cs trunk/plugins/MySkype/MySkype/MySkype.csproj trunk/plugins/MySkype/MySkype/MySkype.csproj.user trunk/plugins/MySkype/MySkype/Properties/ trunk/plugins/MySkype/MySkype/Properties/AssemblyInfo.cs trunk/plugins/MySkype/MySkype/Properties/Resources.Designer.cs trunk/plugins/MySkype/MySkype/Properties/Resources.resx trunk/plugins/MySkype/MySkype/SkypeConnector.cs trunk/plugins/MySkype/MySkype/SkypeControl/ trunk/plugins/MySkype/MySkype/SkypeControl/Common.cs trunk/plugins/MySkype/MySkype/SkypeControl/Platform.cs trunk/plugins/MySkype/MySkype/SkypeControl/Properties/ trunk/plugins/MySkype/MySkype/SkypeControl/Properties/AssemblyInfo.cs trunk/plugins/MySkype/MySkype/SkypeControl/SkypeClient.Designer.cs trunk/plugins/MySkype/MySkype/SkypeControl/SkypeClient.cs trunk/plugins/MySkype/MySkype/SkypeControl/SkypeControl.csproj trunk/plugins/MySkype/MySkype/SkypeControl/SkypeControl.suo trunk/plugins/MySkype/MySkype/SkypeControl/SkypeProxy.cs trunk/plugins/MySkype/MySkype.sln trunk/plugins/MySkype/MySkype.suo trunk/plugins/MySkype/skin/ trunk/plugins/MySkype/skin/BlueTwo/ trunk/plugins/MySkype/skin/BlueTwo/Media/ trunk/plugins/MySkype/skin/BlueTwo/Media/MySkype-ContactStatusAway.png trunk/plugins/MySkype/skin/BlueTwo/Media/MySkype-ContactStatusDoNotDisturb.png trunk/plugins/MySkype/skin/BlueTwo/Media/MySkype-ContactStatusNotAvailable.png trunk/plugins/MySkype/skin/BlueTwo/Media/MySkype-ContactStatusOffline.png trunk/plugins/MySkype/skin/BlueTwo/Media/MySkype-ContactStatusOnline.png trunk/plugins/MySkype/skin/BlueTwo/Media/MySkype-Icon.png trunk/plugins/MySkype/skin/BlueTwo/Media/MySkype-SettingsIcon.png trunk/plugins/MySkype/skin/BlueTwo/Media/MySkype-UserStatusAway.png trunk/plugins/MySkype/skin/BlueTwo/Media/MySkype-UserStatusDoNotDisturb.png trunk/plugins/MySkype/skin/BlueTwo/Media/MySkype-UserStatusInvisible.png trunk/plugins/MySkype/skin/BlueTwo/Media/MySkype-UserStatusNotAvailable.png trunk/plugins/MySkype/skin/BlueTwo/Media/MySkype-UserStatusOffline.png trunk/plugins/MySkype/skin/BlueTwo/Media/MySkype-UserStatusOnline.png trunk/plugins/MySkype/skin/BlueTwo/MySkype.xml Added: trunk/plugins/MySkype/MPInstaller/MySkype.mpi =================================================================== (Binary files differ) Property changes on: trunk/plugins/MySkype/MPInstaller/MySkype.mpi ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/plugins/MySkype/MySkype/MySkype-Icon.png =================================================================== (Binary files differ) Property changes on: trunk/plugins/MySkype/MySkype/MySkype-Icon.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/plugins/MySkype/MySkype/MySkype.cs =================================================================== --- trunk/plugins/MySkype/MySkype/MySkype.cs (rev 0) +++ trunk/plugins/MySkype/MySkype/MySkype.cs 2008-01-07 10:53:19 UTC (rev 1221) @@ -0,0 +1,1343 @@ +#region Copyright (C) 2005-2007 Team MediaPortal + +/* + * Copyright (C) 2005-2007 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.Collections; +using System.Text; +using System.Xml; +using System.Windows.Forms; + +using MediaPortal.GUI.Library; +using MediaPortal.Dialogs; +using MediaPortal.Configuration; +using MediaPortal.Util; +using MediaPortal.Player; + +namespace MySkype +{ + #region Structs + + // This is to hold the plugin settings + public struct Settings + { + public bool PauseMediaOnCall; + public bool ShowIncomingCall; + public bool StartWebcamAutomatically; + public bool ShowOfflineContacts; + } + + #endregion + [PluginIcons("MySkype.MySkype-Icon.png", "MySkype.MySkype-Icon.png")] + public class GUIWindowSkype : GUIWindow, ISetupForm + { + #region Vars + + // This will hold the plugin settings + Settings MySkypeSettings; + + // This is the instance of the class that acts as Skype interface + SkypeConnector SkypeConn = new SkypeConnector(); + + // This indicates what is actually showing the plugin page + string Displaying; + + // Self-explaining + string ViewAs = "View as list"; + + // This will flag if the plugin is currently notifying an incoming call + bool NotifyingIncoming = false; + + // This is to setup a timer that will check every 1 second if there are incoming calls + // the timer is needed because we want to be warned of new call also when not displaying + // the skype plugin page + private System.Windows.Forms.Timer SleepTimer = new System.Windows.Forms.Timer(); + + // This is used by OnPageLoad to know if this is the first time it get invoked + bool MySkypeGUIInitialized = false; + + // This is used to know if the media has to be resumed after the incoming call + bool MySkypePausedMedia = false; + + #endregion + + # region Control definitions + + // Main Page + [SkinControlAttribute(2)] + protected GUIButtonControl buttonStatus = null; + [SkinControlAttribute(3)] + protected GUIButtonControl buttonHistory = null; + [SkinControlAttribute(4)] + protected GUIButtonControl buttonSettings = null; + [SkinControlAttribute(5)] + protected GUIButtonControl buttonViewAs = null; + [SkinControlAttribute(50)] + protected GUIListControl ContactList = null; + [SkinControlAttribute(51)] + protected GUIThumbnailPanel ContactIcon = null; + + // Settings Page + [SkinControlAttribute(60)] + protected GUIButtonControl buttonSettingsBack = null; + [SkinControlAttribute(62)] + protected GUICheckMarkControl checkShowIncomingCalls = null; + [SkinControlAttribute(63)] + protected GUICheckMarkControl checkDontShowIncomingCalls = null; + [SkinControlAttribute(65)] + protected GUICheckMarkControl checkOnCallPauseMedia = null; + [SkinControlAttribute(66)] + protected GUICheckMarkControl checkOnCallNoAction = null; + [SkinControlAttribute(68)] + protected GUICheckMarkControl checkAutomaticallyStartWebcam = null; + [SkinControlAttribute(69)] + protected GUICheckMarkControl checkDontStartWebcamAutomatically = null; + [SkinControlAttribute(71)] + protected GUICheckMarkControl checkShowOfflineContact = null; + [SkinControlAttribute(72)] + protected GUICheckMarkControl checkDontShowOfflineContact = null; + + // Call Page + [SkinControlAttribute(82)] + protected GUIButtonControl buttonPauseCall = null; + [SkinControlAttribute(83)] + protected GUIButtonControl buttonHangupCall = null; + [SkinControlAttribute(90)] + + // History Page + protected GUIListControl RecentCallList = null; + [SkinControlAttribute(91)] + protected GUIButtonControl buttonMissedCalls = null; + [SkinControlAttribute(92)] + protected GUIButtonControl buttonReceivedCalls = null; + [SkinControlAttribute(93)] + protected GUIButtonControl buttonCallsDone = null; + [SkinControlAttribute(94)] + protected GUIButtonControl buttonCallsBack = null; + + #endregion + + #region ISetupForm Members + + public GUIWindowSkype() + { + // get ID of windowplugin belonging to this setup + // enter your own unique code + GetID = 109144; + } + + // Returns the name of the plugin which is shown in the plugin menu + public string PluginName() + { + return "My Skype"; + } + + // Returns the description of the plugin is shown in the plugin menu + public string Description() + { + return "Skype plugin for MediaPortal"; + } + + // Returns the author of the plugin which is shown in the plugin menu + public string Author() + { + return "BlaXwan (Fabio Di Niro)"; + } + + // show the setup dialog + public void ShowPlugin() + { + MessageBox.Show("Nothing to configure. When starting MediaPortal make sure to authorize PERMANENTLY MediaPortal to access Skype and to put it in silent mode while running"); + } + + // Indicates whether plugin can be enabled/disabled + public bool CanEnable() + { + return true; + } + + // get ID of windowplugin belonging to this setup + public int GetWindowId() + { + return 109144; + } + + // Indicates if plugin is enabled by default; + public bool DefaultEnabled() + { + return true; + } + + // indicates if a plugin has it's own setup screen + public bool HasSetup() + { + return true; + } + + /// <summary> + /// If the plugin should have it's own button on the main menu of Mediaportal then it + /// should return true to this method, otherwise if it should not be on home + /// it should return false + /// </summary> + /// <param name="strButtonText">text the button should have</param> + /// <param name="strButtonImage">image for the button, or empty for default</param> + /// <param name="strButtonImageFocus">image for the button, or empty for default</param> + /// <param name="strPictureImage">subpicture for the button or empty for none</param> + /// <returns>true : plugin needs it's own button on home + /// false : plugin does not need it's own button on home</returns> + + public bool GetHome(out string strButtonText, out string strButtonImage, + out string strButtonImageFocus, out string strPictureImage) + { + strButtonText = PluginName(); + strButtonImage = ""; + strButtonImageFocus = ""; + strPictureImage = @"MySkype-Icon.png"; + return true; + } + + #endregion + + #region Init and Shutdown + + // Plugin initialization + public override bool Init() + { + Log.Info("MySkype: initializing"); + LoadSettings(); + // Initialize the class SkypeConnector + SkypeConn.Initialize(); + + // Nothing is displayed so... + Displaying = "None"; + + // We're not notifying anything yet + NotifyingIncoming = false; + + // Setup the timer needed to check the incoming calls periodically + SleepTimer.Tick += new EventHandler(OnTimer); + SleepTimer.Interval = 1000; // every 1 second + SleepTimer.Enabled = true; + SleepTimer.Start(); + + // Success if the skin file is found + return Load(GUIGraphicsContext.Skin + @"\MySkype.xml"); + } + + // Plugin shutdown + public override void DeInit() + { + // Shutdown the class SkypeConnector + SkypeConn.Shutdown(); + } + + protected override void OnPageLoad() + { + Log.Info("MySkype page load"); + if (!MySkypeGUIInitialized) + InitializeGUI(); + + HideSettingsPage(); + HideRecentCallPage(); + + // If there's a call already running, we want to go directly to the call page + // as the plugin is shown + if (SkypeConn.Call.IsCalling) + { + Displaying = "Call"; + ShowCallPage(); + } + else + { + Displaying = "Contacts"; + HideCallPage(); + } + RefreshWindow(); + } + + protected override void OnPageDestroy(int new_windowId) + { + Displaying = "None"; + } + + void LoadSettings() + { + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) + { + // Load the saved settings filling the MySkypeSettings struct + MySkypeSettings.PauseMediaOnCall = xmlreader.GetValueAsBool("MySkype", "PauseMediaOnCall", true); + MySkypeSettings.ShowIncomingCall = xmlreader.GetValueAsBool("MySkype", "ShowIncomingCall", true); + MySkypeSettings.StartWebcamAutomatically = xmlreader.GetValueAsBool("MySkype", "StartWebcamAutomatically", true); + MySkypeSettings.ShowOfflineContacts = xmlreader.GetValueAsBool("MySkype", "ShowOfflineContacts", true); + } + } + + void SaveSettings() + { + using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) + { + // Save the settings from the MySkypeSettings struct + xmlwriter.SetValueAsBool("MySkype", "PauseMediaOnCall", MySkypeSettings.PauseMediaOnCall); + xmlwriter.SetValueAsBool("MySkype", "ShowIncomingCall", MySkypeSettings.ShowIncomingCall); + xmlwriter.SetValueAsBool("MySkype", "StartWebcamAutomatically", MySkypeSettings.StartWebcamAutomatically); + xmlwriter.SetValueAsBool("MySkype", "ShowOfflineContacts", MySkypeSettings.ShowOfflineContacts); + } + } + + #endregion + + #region Process + + public override void Process() + { + // Invoke RefreshWindow() if there are new data to be shown + if (SkypeConn.NewData) + { + RefreshWindow(); + } + } + + // Once the timer has been setup, this function is invoked every second + private void OnTimer(Object sender, EventArgs e) + { + // Prepare next run + SleepTimer.Enabled = true; + + // If there's a new incoming call ringing and we're not warning yet... + if (SkypeConn.Call.CallStatus == "RINGING" && + SkypeConn.Call.CallDirection == "INCOMING" && + MySkypeSettings.ShowIncomingCall + && !NotifyingIncoming) + { + // This flag is used to avoid to notify again when the + // incoming call menu is already shown + NotifyingIncoming = true; + + // Put in pause the currently playing media if the user + // choose it + if (g_Player.Playing && !g_Player.Paused && MySkypeSettings.PauseMediaOnCall) + { + MediaPortal.Player.g_Player.Pause(); + MySkypePausedMedia = true; + } + IncomingCall(); + } + // Reset the flag if there's no call ringing + if (SkypeConn.Call.CallStatus != "RINGING") + NotifyingIncoming = false; + } + + #endregion + + #region Button Control + + // Here we define what to do on every button press + protected override void OnClicked(int controlId, GUIControl control, + MediaPortal.GUI.Library.Action.ActionType actionType) + { + if (control == buttonStatus) + OnButtonStatus(); + if (control == buttonHistory) + OnButtonHistory(); + if (control == buttonSettings) + OnButtonSettings(); + if (control == buttonViewAs) + OnButtonViewAs(); + if (control == ContactList) + CallContact(); + if (control == ContactIcon) + CallContact(); + if (control == buttonSettingsBack) + OnButtonSettingsBack(); + if (control == checkShowIncomingCalls) + SetShowIncomingCalls(); + if (control == checkDontShowIncomingCalls) + SetDontShowIncomingCalls(); + if (control == checkOnCallPauseMedia) + SetOnCallPauseMedia(); + if (control == checkOnCallNoAction) + SetOnCallNoAction(); + if (control == checkAutomaticallyStartWebcam) + SetAutomaticallyStartWebcam(); + if (control == checkDontStartWebcamAutomatically) + SetDontStartWebcamAutomatically(); + if (control == checkShowOfflineContact) + SetShowOfflineContact(); + if (control == checkDontShowOfflineContact) + SetDontShowOfflineContact(); + if (control == buttonPauseCall) + PauseTheCall(); + if (control == buttonHangupCall) + HangupTheCall(); + if (control == RecentCallList) + ShowCallDetails(); + if (control == buttonMissedCalls) + OnButtonMissedCalls(); + if (control == buttonReceivedCalls) + OnButtonReceivedCalls(); + if (control == buttonCallsDone) + OnButtonCallsDone(); + if (control == buttonCallsBack) + OnButtonCallsBack(); + base.OnClicked(controlId, control, actionType); + } + + // When the buttonStatus is pressed we will show a menu in which the user can + // choose which new status he wants to go in + private void OnButtonStatus() + { + GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); + if (dlg == null) return; + dlg.Reset(); + dlg.SetHeading("Set status"); + dlg.Add("Online"); + dlg.Add("Away"); + dlg.Add("Do not disturb"); + dlg.Add("Not available"); + dlg.Add("Invisible"); + dlg.Add("Offline"); + dlg.DoModal(GetID); + if (dlg.SelectedLabelText == null) return; + switch (dlg.SelectedLabelText) + { + case "Online": + SkypeConn.SetStatus("ONLINE"); + break; + case "Away": + SkypeConn.SetStatus("AWAY"); + break; + case "Do not disturb": + SkypeConn.SetStatus("DND"); + break; + case "Not available": + SkypeConn.SetStatus("NA"); + break; + case "Invisible": + SkypeConn.SetStatus("INVISIBLE"); + break; + case "Offline": + SkypeConn.SetStatus("OFFLINE"); + break; + } + } + + // When the buttonHistory is pressed we go to the history page, + // missed calls are shown as default + private void OnButtonHistory() + { + Displaying = "MissedCalls"; + ShowRecentCallPage(); + } + + private void OnButtonSettings() + { + ShowSettingsPage(); + } + + // If the button "View as list" is pressed, the button itself changes in "View as icon" + // and the variable ViewAs is set as "View as list" + // If the button "View as icons" is pressed, the button itself changes in "View as list" + // and the variable ViewAs is set as "View as icons" + private void OnButtonViewAs() + { + if (ViewAs == "View as list") + { + // Button label = View as list + GUIControl.SetControlLabel(GetID, buttonViewAs.GetID, GUILocalizeStrings.Get(101)); + ViewAs = "View as icons"; + } + else + { + // Button label = View as icons + GUIControl.SetControlLabel(GetID, buttonViewAs.GetID, GUILocalizeStrings.Get(100)); + ViewAs = "View as list"; + } + RefreshWindow(); + } + + // If the user click on a shown contact, a confirm dialog is shown, if the user + // choose Yes the call will be done through the method PlaceACall of the + // SkypeConnector class + private void CallContact() + { + GUIListItem item = GUIControl.GetSelectedListItem(GetID, ContactList.GetID); + GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow( + (int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); + dlg.SetHeading("Call confirmation"); + dlg.SetLine(1, string.Format("Call {0}?", item.Label, item.Label2)); + dlg.DoModal(GUIWindowManager.ActiveWindow); + if (dlg.IsConfirmed) + { + // Let's call the contact + SkypeConn.PlaceACall(item.Label2); + ShowCallPage(); + } + } + + // Go back to the Contacts page + private void OnButtonSettingsBack() + { + HideSettingsPage(); + SaveSettings(); + } + + // As this is a RadioButton, when selected it will deselect the other choice + private void SetShowIncomingCalls() + { + checkShowIncomingCalls.Selected = true; + checkDontShowIncomingCalls.Selected = false; + MySkypeSettings.ShowIncomingCall = true; + // In addition, if the user choose to be notified about incoming call, + // he will have also the option to automatically put in pause the playing + // media, so let's enable the checkmark where he will make this choice + GUIControl.EnableControl(GetID, checkOnCallPauseMedia.GetID); + GUIControl.EnableControl(GetID, checkOnCallNoAction.GetID); + } + + // As this is a RadioButton, when selected it will deselect the other choice + private void SetDontShowIncomingCalls() + { + checkShowIncomingCalls.Selected = false; + checkDontShowIncomingCalls.Selected = true; + MySkypeSettings.ShowIncomingCall = false; + // In addition, when the user choose to not to be notified about incoming call, + // the option to pause media on call is deselected and disabled + MySkypeSettings.PauseMediaOnCall = false; + checkOnCallPauseMedia.Selected = false; + checkOnCallNoAction.Selected = true; + GUIControl.DisableControl(GetID, checkOnCallPauseMedia.GetID); + GUIControl.DisableControl(GetID, checkOnCallNoAction.GetID); + } + + // As this is a RadioButton, when selected it will deselect the other choice + private void SetOnCallPauseMedia() + { + checkOnCallPauseMedia.Selected = true; + checkOnCallNoAction.Selected = false; + MySkypeSettings.PauseMediaOnCall = true; + } + + // As this is a RadioButton, when selected it will deselect the other choice + private void SetOnCallNoAction() + { + checkOnCallPauseMedia.Selected = false; + checkOnCallNoAction.Selected = true; + MySkypeSettings.PauseMediaOnCall = false; + } + + // As this is a RadioButton, when selected it will deselect the other choice + private void SetAutomaticallyStartWebcam() + { + checkAutomaticallyStartWebcam.Selected = true; + checkDontStartWebcamAutomatically.Selected = false; + MySkypeSettings.StartWebcamAutomatically = true; + } + + // As this is a RadioButton, when selected it will deselect the other choice + private void SetDontStartWebcamAutomatically() + { + checkAutomaticallyStartWebcam.Selected = false; + checkDontStartWebcamAutomatically.Selected = true; + MySkypeSettings.StartWebcamAutomatically = false; + } + + // As this is a RadioButton, when selected it will deselect the other choice + private void SetShowOfflineContact() + { + checkShowOfflineContact.Selected = true; + checkDontShowOfflineContact.Selected = false; + MySkypeSettings.ShowOfflineContacts = true; + } + + // As this is a RadioButton, when selected it will deselect the other choice + private void SetDontShowOfflineContact() + { + checkShowOfflineContact.Selected = false; + checkDontShowOfflineContact.Selected = true; + MySkypeSettings.ShowOfflineContacts = false; + } + + // This will put a running call in pause or resume it if it was already "ONHOLD" + // then it changes the button label accordingly + private void PauseTheCall() + { + // Check if the call was already paused + if (SkypeConn.Call.CallStatus == "ONHOLD") + { + GUIControl.SetControlLabel(GetID, buttonPauseCall.GetID, "Pause call"); + SkypeConn.ResumeCall(); + return; + } + // Change the PauseCall button in ResumeCall button + GUIControl.SetControlLabel(GetID, buttonPauseCall.GetID, "Resume call"); + SkypeConn.PauseCall(); + } + + private void HangupTheCall() + { + SkypeConn.HangupCall(); + HideCallPage(); + // If the user was watching something and got here for an incoming call + // then resume the media he was looking at + if (g_Player.Playing && g_Player.Paused && MySkypePausedMedia) + { + MediaPortal.Player.g_Player.Pause(); + GUIWindowManager.ShowPreviousWindow(); + MySkypePausedMedia = false; + } + else + // Otherwise, if it was playing and was not paused by MySkype, then just + // go back in the previous window + if (g_Player.Playing) + GUIWindowManager.ShowPreviousWindow(); + } + + // This will popup the details of the selected call + private void ShowCallDetails() + { + // We need some variable to fill with data that needs to be shown + CallStruct SelectedCall = new CallStruct(); + string NameToShow; + DateTime ConvertedTimeStamp; + int minutes, seconds; + + // Let's get which call was selected + GUIListItem item = GUIControl.GetSelectedListItem(GetID, RecentCallList.GetID); + + // Prepare an ok dialog + GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow( + (int)GUIWindow.Window.WINDOW_DIALOG_OK); + + // Let's find the right call in the call history list + for (int x = 0; x < SkypeConn.CallHistory.Count; x++) + { + if (((CallStruct)SkypeConn.CallHistory[x]).CallId == Convert.ToInt32(item.AlbumInfoTag)) + { + SelectedCall.CallId = ((CallStruct)SkypeConn.CallHistory[x]).CallId; + SelectedCall.CallTimeStamp = ((CallStruct)SkypeConn.CallHistory[x]).CallTimeStamp; + SelectedCall.CallDuration = ((CallStruct)SkypeConn.CallHistory[x]).CallDuration; + SelectedCall.CallDirection = ((CallStruct)SkypeConn.CallHistory[x]).CallDirection; + SelectedCall.CallStatus = ((CallStruct)SkypeConn.CallHistory[x]).CallStatus; + SelectedCall.ContactCalledName = ((CallStruct)SkypeConn.CallHistory[x]).ContactCalledName; + SelectedCall.ContactCalledFullName = ((CallStruct)SkypeConn.CallHistory[x]).ContactCalledFullName; + break; + } + } + + // Now that we have the selected call, let's get the name to show which is + // just the Skype name if the user has not filled in the Skype full name + // or in the "Fullname (name)" + if (SelectedCall.ContactCalledFullName == "") + NameToShow = SelectedCall.ContactCalledName; + else + NameToShow = SelectedCall.ContactCalledFullName + " (" + SelectedCall.ContactCalledName + ")"; + + // Let's get an human readable version of the call time + ConvertedTimeStamp = DateTime.Parse("01/01/1970 00:00"); + ConvertedTimeStamp = (DateTime)ConvertedTimeStamp.AddSeconds(SelectedCall.CallTimeStamp); + + dlg.SetHeading("Call details"); + if (SelectedCall.CallDirection == "INCOMING") + { + dlg.SetLine(1, "Call from " + NameToShow); + dlg.SetLine(2, "received on " + ConvertedTimeStamp.ToString()); + } + else + { + dlg.SetLine(1, "Call to " + NameToShow); + dlg.SetLine(2, "done on " + ConvertedTimeStamp.ToString()); + } + + // Print the call duration if there was any + minutes = SelectedCall.CallDuration / 60; + seconds = SelectedCall.CallDuration % 60; + + if (SelectedCall.CallStatus == "FINISHED") + if (minutes > 0) + dlg.SetLine(3, "call duration: " + Convert.ToString(minutes) + ":" + Convert.ToString(seconds)); + else + dlg.SetLine(3, "call duration: " + Convert.ToString(seconds) + " seconds"); + + if (SelectedCall.CallStatus == "MISSED") + dlg.SetLine(3, "the call was missed"); + + if (SelectedCall.CallStatus == "FAILED") + dlg.SetLine(3, "failed call."); + + dlg.DoModal(GUIWindowManager.ActiveWindow); + } + + // Sets what needs to be shown at the next refresh + private void OnButtonMissedCalls() + { + Displaying = "MissedCalls"; + RefreshWindow(); + } + + // Sets what needs to be shown at the next refresh + private void OnButtonReceivedCalls() + { + Displaying = "ReceivedCalls"; + RefreshWindow(); + } + + // Sets what needs to be shown at the next refresh + private void OnButtonCallsDone() + { + Displaying = "CallsDone"; + RefreshWindow(); + } + + // Go back to the Contacts page + private void OnButtonCallsBack() + { + Displaying = "Contacts"; + HideRecentCallPage(); + } + + #endregion + + #region Window control + + private void InitializeGUI() + { + // Main (Contacts) Page + GUIControl.SetControlLabel(GetID, buttonStatus.GetID, GUILocalizeStrings.Get(126)); + //GUIControl.SetControlLabel(GetID, buttonHistory.GetID, GUILocalizeStrings.Get + GUIControl.SetControlLabel(GetID, buttonSettings.GetID, GUILocalizeStrings.Get(1048)); + GUIControl.SetControlLabel(GetID, buttonViewAs.GetID, GUILocalizeStrings.Get(100)); + + // Settings Page + GUIControl.SetControlLabel(GetID, buttonSettingsBack.GetID, GUILocalizeStrings.Get(712)); + + // Recent Call Page + GUIControl.SetControlLabel(GetID, buttonCallsBack.GetID, GUILocalizeStrings.Get(712)); + + MySkypeGUIInitialized = true; + } + + private void ShowSettingsPage() + { + // Set the Displaying var + Displaying = "Settings"; + // Change the page title + GUIPropertyManager.SetProperty("#PageTitle", "My Skype settings"); + // Hide buttons + GUIControl.HideControl(GetID, buttonStatus.GetID); + GUIControl.HideControl(GetID, buttonHistory.GetID); + GUIControl.HideControl(GetID, buttonSettings.GetID); + GUIControl.HideControl(GetID, buttonViewAs.GetID); + // Hide Contacts + GUIControl.HideControl(GetID, ContactList.GetID); + GUIControl.HideControl(GetID, ContactIcon.GetID); + GUIPropertyManager.SetProperty("#NumberOfContacts", ""); + // Hide user status + GUIPropertyManager.SetProperty("#UserFullName", ""); + GUIPropertyManager.SetProperty("#UserOnline", ""); + GUIPropertyManager.SetProperty("#UserStatusIcon", @"\MySkype-SettingsIcon.png"); + // Show Settings + GUIControl.ShowControl(GetID, buttonSettingsBack.GetID); + GUIControl.ShowControl(GetID, 61); + GUIControl.ShowControl(GetID, checkOnCallPauseMedia.GetID); + GUIControl.ShowControl(GetID, checkOnCallNoAction.GetID); + GUIControl.ShowControl(GetID, 64); + GUIControl.ShowControl(GetID, checkShowIncomingCalls.GetID); + GUIControl.ShowControl(GetID, checkDontShowIncomingCalls.GetID); + // disabled for now... + // GUIControl.ShowControl(GetID, 67); + // GUIControl.ShowControl(GetID, AutomaticallyStartWebcam.GetID); + // GUIControl.ShowControl(GetID, DontStartWebcamAutomatically.GetID); + GUIControl.ShowControl(GetID, 70); + GUIControl.ShowControl(GetID, checkShowOfflineContact.GetID); + GUIControl.ShowControl(GetID, checkDontShowOfflineContact.GetID); + GUIControl.FocusControl(GetID, buttonSettingsBack.GetID); + RefreshWindow(); + } + + private void HideSettingsPage() + { + // Set the Displaying var + Displaying = "Contacts"; + // Change the page title + GUIPropertyManager.SetProperty("#PageTitle", "My Skype main"); + // Show buttons + GUIControl.ShowControl(GetID, buttonStatus.GetID); + GUIControl.ShowControl(GetID, buttonHistory.GetID); + GUIControl.ShowControl(GetID, buttonSettings.GetID); + GUIControl.ShowControl(GetID, buttonViewAs.GetID); + // Show Contacts + if (ViewAs == "View as list") + GUIControl.ShowControl(GetID, ContactList.GetID); + else + GUIControl.ShowControl(GetID, ContactIcon.GetID); + // Hide Settings + GUIControl.HideControl(GetID, buttonSettingsBack.GetID); + GUIControl.HideControl(GetID, 61); + GUIControl.HideControl(GetID, checkOnCallPauseMedia.GetID); + GUIControl.HideControl(GetID, checkOnCallNoAction.GetID); + GUIControl.HideControl(GetID, 64); + GUIControl.HideControl(GetID, checkShowIncomingCalls.GetID); + GUIControl.HideControl(GetID, checkDontShowIncomingCalls.GetID); + GUIControl.HideControl(GetID, 67); + GUIControl.HideControl(GetID, checkAutomaticallyStartWebcam.GetID); + GUIControl.HideControl(GetID, checkDontStartWebcamAutomatically.GetID); + GUIControl.HideControl(GetID, 70); + GUIControl.HideControl(GetID, checkShowOfflineContact.GetID); + GUIControl.HideControl(GetID, checkDontShowOfflineContact.GetID); + GUIControl.FocusControl(GetID, buttonStatus.GetID); + RefreshWindow(); + } + + private void ShowCallPage() + { + // Set the Displaying var + Displaying = "Call"; + // Change the page title + GUIPropertyManager.SetProperty("#PageTitle", "Calling..."); + // Hide buttons + GUIControl.HideControl(GetID, buttonStatus.GetID); + GUIControl.HideControl(GetID, buttonHistory.GetID); + GUIControl.HideControl(GetID, buttonSettings.GetID); + GUIControl.HideControl(GetID, buttonViewAs.GetID); + // Hide Contacts + GUIControl.HideControl(GetID, ContactList.GetID); + GUIControl.HideControl(GetID, ContactIcon.GetID); + GUIPropertyManager.SetProperty("#NumberOfContacts", ""); + // Hide user status + //GUIPropertyManager.SetProperty("#UserFullName", ""); + //GUIPropertyManager.SetProperty("#UserOnline", ""); + //GUIPropertyManager.SetProperty("#UserStatusIcon", @"\MySkype-SettingsIcon.png"); + // Show Call controls + GUIControl.ShowControl(GetID, 80); + GUIControl.ShowControl(GetID, 81); + GUIControl.ShowControl(GetID, buttonPauseCall.GetID); + GUIControl.DisableControl(GetID, buttonPauseCall.GetID); + GUIControl.ShowControl(GetID, buttonHangupCall.GetID); + GUIControl.FocusControl(GetID, buttonHangupCall.GetID); + RefreshWindow(); + } + + private void HideCallPage() + { + // Set the Displaying var + Displaying = "Contacts"; + // Change the page title + GUIPropertyManager.SetProperty("#PageTitle", "My Skype main"); + // Show buttons + GUIControl.ShowControl(GetID, buttonStatus.GetID); + GUIControl.ShowControl(GetID, buttonHistory.GetID); + GUIControl.ShowControl(GetID, buttonSettings.GetID); + GUIControl.ShowControl(GetID, buttonViewAs.GetID); + // Show Contacts + if (ViewAs == "View as list") + GUIControl.ShowControl(GetID, ContactList.GetID); + else + GUIControl.ShowControl(GetID, ContactIcon.GetID); + // Hide Call control + GUIControl.HideControl(GetID, 80); + GUIControl.HideControl(GetID, 81); + GUIControl.HideControl(GetID, buttonPauseCall.GetID); + GUIControl.HideControl(GetID, buttonHangupCall.GetID); + GUIControl.FocusControl(GetID, buttonStatus.GetID); + RefreshWindow(); + } + + private void ShowRecentCallPage() + { + // Hide buttons + GUIControl.HideControl(GetID, buttonStatus.GetID); + GUIControl.HideControl(GetID, buttonHistory.GetID); + GUIControl.HideControl(GetID, buttonSettings.GetID); + GUIControl.HideControl(GetID, buttonViewAs.GetID); + // Hide Contacts + GUIControl.HideControl(GetID, ContactList.GetID); + GUIControl.HideControl(GetID, ContactIcon.GetID); + GUIPropertyManager.SetProperty("#NumberOfContacts", ""); + // Show recent call list and buttons + GUIControl.ShowControl(GetID, RecentCallList.GetID); + GUIControl.ShowControl(GetID, buttonMissedCalls.GetID); + GUIControl.ShowControl(GetID, buttonReceivedCalls.GetID); + GUIControl.ShowControl(GetID, buttonCallsDone.GetID); + GUIControl.ShowControl(GetID, buttonCallsBack.GetID); + GUIControl.ShowControl(GetID, buttonCallsBack.GetID); + GUIControl.FocusControl(GetID, buttonCallsBack.GetID); + RefreshWindow(); + } + + private void HideRecentCallPage() + { + // Set the Displaying var + Displaying = "Contacts"; + // Change the page title + GUIPropertyManager.SetProperty("#PageTitle", "My Skype main"); + // Show buttons + GUIControl.ShowControl(GetID, buttonStatus.GetID); + GUIControl.ShowControl(GetID, buttonHistory.GetID); + GUIControl.ShowControl(GetID, buttonSettings.GetID); + GUIControl.ShowControl(GetID, buttonViewAs.GetID); + // Show Contacts + if (ViewAs == "View as list") + GUIControl.ShowControl(GetID, ContactList.GetID); + else + GUIControl.ShowControl(GetID, ContactIcon.GetID); + // Hide recent call list and button + GUIControl.HideControl(GetID, RecentCallList.GetID); + GUIControl.HideControl(GetID, buttonMissedCalls.GetID); + GUIControl.HideControl(GetID, buttonReceivedCalls.GetID); + GUIControl.HideControl(GetID, buttonCallsDone.GetID); + GUIControl.HideControl(GetID, buttonCallsBack.GetID); + GUIControl.FocusControl(GetID, buttonStatus.GetID); + RefreshWindow(); + } + + // This is launched by the timer handler when there's a new incoming call + private void IncomingCall() + { + // Who is calling? + string NameToShow; + if (SkypeConn.Call.ContactCalledFullName == "") + NameToShow = SkypeConn.Call.ContactCalledName; + else + NameToShow = SkypeConn.Call.ContactCalledFullName + " (" + SkypeConn.Call.ContactCalledName + ")"; + + // Warns about an incoming call with a bottom right menu + GUIDialogMenuBottomRight IncomingCallMenu = (GUIDialogMenuBottomRight)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU_BOTTOM_RIGHT); + IncomingCallMenu.Reset(); + IncomingCallMenu.SetHeading("Call from " + NameToShow); + IncomingCallMenu.Add("Accept"); + IncomingCallMenu.Add("Reject"); + IncomingCallMenu.Add("Do nothing"); + // If the user close the dialog, the last option highlighted will be the result, + // so this is to give "Do nothing" result as default option + IncomingCallMenu.selectOption("Do nothing"); + IncomingCallMenu.DoModal(GetID); + switch (IncomingCallMenu.SelectedLabelText) + { + case "Accept": + SkypeConn.AcceptCall(); + GUIWindowManager.ActivateWindow(GetWindowId()); + break; + case "Reject": + SkypeConn.HangupCall(); + // If the user was watching something and MySkype paused the media for the + // incoming call then resume the media he was looking at + if (g_Player.Playing && g_Player.Paused && MySkypePausedMedia) + { + // If MySkype paused it then resume it + MediaPortal.Player.g_Player.Pause(); + MySkypePausedMedia = false; + } + break; + case "Do nothing": + // If the user was watching something and MySkype paused the media for the + // incoming call then resume the media he was looking at + if (g_Player.Playing && g_Player.Paused && MySkypePausedMedia) + { + // If MySkype paused it then resume it + MediaPortal.Player.g_Player.Pause(); + MySkypePausedMedia = false; + } + break; + } + } + + // This is the longest function, it has the hard task of redraw the plugin screen + // on every condition, for all the four main pages: Settings, Call, History and Contacts + private void RefreshWindow() + { + + #region Settings Page + + // If the Settings page is shown just the settings control will be refreshed + if (Displaying == "Settings") + { + // Sets the option flagged accordingly to what is stored in the MySkypeSettings + // variables + if (MySkypeSettings.PauseMediaOnCall) + SetOnCallPauseMedia(); + else + SetOnCallNoAction(); + + if (MySkypeSettings.ShowIncomingCall) + SetShowIncomingCalls(); + else + SetDontShowIncomingCalls(); + + if (MySkypeSettings.StartWebcamAutomatically) + SetAutomaticallyStartWebcam(); + else + SetDontStartWebcamAutomatically(); + + if (MySkypeSettings.ShowOfflineContacts) + SetShowOfflineContact(); + else + SetDontShowOfflineContact(); + + return; + } + #endregion + + #region Call Page + + // If the Call page is shown just the call controls will be refreshed + if (Displaying == "Call") + { + // Shows the "Fullname (name)" of the called contact + string CalledNameToShow; + if (SkypeConn.Call.ContactCalledFullName == "") + CalledNameToShow = SkypeConn.Call.ContactCalledName; + else + CalledNameToShow = SkypeConn.Call.ContactCalledFullName + " (" + SkypeConn.Call.ContactCalledName + ")"; + GUIPropertyManager.SetProperty("#Calling", "Calling " + CalledNameToShow); + + // Enables the PauseCall button if the call is in progress + if (!buttonPauseCall.IsEnabled && SkypeConn.Call.CallDuration > 0) + GUIControl.EnableControl(GetID, buttonPauseCall.GetID); + + // Get the call duration (if any) + string CallDurationToShow; + int minutes = SkypeConn.Call.CallDuration / 60; + int seconds = SkypeConn.Call.CallDuration % 60; + if (minutes > 0) + CallDurationToShow = Convert.ToString(minutes) + ":" + Convert.ToString(seconds); + else + CallDurationToShow = Convert.ToString(seconds); + + /* This was actually to experiment what I could do with Skype video + * unfortunately actually there is no video support at all in the + * Skype API, so, basically we can enable video in and out but there + * is no way to get the video out of the Skype window, so we cannot + * show it in a MediaPortal window..... :-S + if (SkypeConn.Call.CallDuration == 5) + SkypeConn.StartVideo(); + if (SkypeConn.Call.CallDuration == 25) + SkypeConn.StopVideo();*/ + + // Shows the call status + GUIDialogOK guidialogCall; + switch (SkypeConn.Call.CallStatus) + { + case "RINGING": + GUIPropertyManager.SetProperty("#CallStatus", "Ringing..."); + break; + case "INPROGRESS": + GUIPropertyManager.SetProperty("#CallStatus", "Call duration " + CallDurationToShow); + break; + case "ONHOLD": + GUIPropertyManager.SetProperty("#CallStatus", "Call on hold (" + CallDurationToShow + ")"); + break; + // If the call has been refused, it will pop-up a message and go back to main page + case "REFUSED": + HideCallPage(); + guidialogCall = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); + guidialogCall.SetHeading("Call refused"); + guidialogCall.SetLine(1, CalledNameToShow + " refused the call."); + guidialogCall.DoModal(GUIWindowManager.ActiveWindow); + break; + // If the call has failed, it will pop-up a message and go back to main page + case "FAILED": + HideCallPage(); + guidialogCall = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); + guidialogCall.SetHeading("Call failed"); + guidialogCall.SetLine(1, "Failed to call " + CalledNameToShow + "."); + guidialogCall.SetLine(2, SkypeConn.GetFailureReason()); + guidialogCall.DoModal(GUIWindowManager.ActiveWindow); + break; + // If the call is finished go back to the main page + case "FINISHED": + case "MISSED": + HideCallPage(); + break; + // If the status is undefining (sometimes Skype says ROUTING) + // we will lie waiting for a good status statement :o) + default: + GUIPropertyManager.SetProperty("#CallStatus", "Connecting..."); + break; + } + // We have shown the data so we can reset the flag + SkypeConn.NewData = false; + return; + } + + #endregion + + #region Recent Calls Page + + // Here we will refresh the call history page. This page may show MissedCalls, + // ReceivedCalls or CallsDone. + DateTime ConvertedTimeStamp; + GUIControl.ClearControl(GetID, RecentCallList.GetID); + string NameToShow; + + if (Displaying == "MissedCalls") + { + // Change the page title + GUIPropertyManager.SetProperty("#PageTitle", "Missed calls"); + + // Sort the list before showing it + SkypeConn.SortCallHistory(); + + // Let's go through the whole call history list to find the right calls to show + foreach (CallStruct MissedCall in SkypeConn.CallHistory) + { + if (MissedCall.CallStatus == "MISSED") + { + GUIListItem item = new GUIListItem(); + // Compose the name to show + if (MissedCall.ContactCalledFullName == "") + NameToShow = MissedCall.ContactCalledName; + else + NameToShow = MissedCall.ContactCalledFullName + " (" + MissedCall.ContactCalledName + ")"; + item.Label = NameToShow; + ConvertedTimeStamp = DateTime.Parse("01/01/1970 00:00"); + ConvertedTimeStamp = (DateTime)ConvertedTimeStamp.AddSeconds(MissedCall.CallTimeStamp); + + if (ConvertedTimeStamp.Date == DateTime.Today) + item.Label2 = "Today at " + ConvertedTimeStamp.ToShortTimeString(); + else + item.Label2 = ConvertedTimeStamp.ToString(); + item.IsFolder = false; + + // This will be used for retrieving call details if the user choose to see them + item.AlbumInfoTag = MissedCall.CallId; + // As this is the missed call list, we will show them all with the red flag on + item.IconImage = "MySkype-ContactStatusDoNotDisturb.png"; + item.IconImageBig = "MySkype-ContactStatusDoNotDisturb.png"; + GUIControl.AddListItemControl(GetID, RecentCallList.GetID, item); + } + } + SkypeConn.NewData = false; + return; + } + + if (Displaying == "ReceivedCalls") + { + // Change the page title + GUIPropertyManager.SetProperty("#PageTitle", "Received calls"); + + // Sort the list before showing it + SkypeConn.SortCallHistory(); + + // Let's go through the whole call history list to find the right calls to show + foreach (CallStruct ReceivedCall in SkypeConn.CallHistory) + { + if (ReceivedCall.CallStatus == "FINISHED" && ReceivedCall.CallDirection == "INCOMING") + { + GUIListItem item = new GUIListItem(); + // Compose the name to show + if (ReceivedCall.ContactCalledFullName == "") + NameToShow = ReceivedCall.ContactCalledName; + else + NameToShow = ReceivedCall.ContactCalledFullName + " (" + ReceivedCall.ContactCalledName + ")"; + item.Label = NameToShow; + + ConvertedTimeStamp = DateTime.Parse("01/01/1970 00:00"); + ConvertedTimeStamp = (DateTime)ConvertedTimeStamp.AddSeconds(ReceivedCall.CallTimeStamp); + if (ConvertedTimeStamp.Date == DateTime.Today) + item.Label2 = "Today at " + ConvertedTimeStamp.ToShortTimeString(); + else + item.Label2 = ConvertedTimeStamp.ToString(); + item.IsFolder = false; + + // This will be used for retrieving call details if the user choose to see them + item.AlbumInfoTag = ReceivedCall.CallId; + + // As this is the successfully received call list, we will show them all with + // the green icon + item.IconImage = "MySkype-ContactStatusOnline.png"; + item.IconImageBig = "MySkype-ContactStatusOnline.png"; + GUIControl.AddListItemControl(GetID, RecentCallList.GetID, item); + } + } + SkypeConn.NewData = false; + return; + } + if (Displaying == "CallsDone") + { + // Change the page title + GUIPropertyManager.SetProperty("#PageTitle", "Calls done"); + SkypeConn.SortCallHistory(); + foreach (CallStruct CallDone in SkypeConn.CallHistory) + { + if ((CallDone.CallStatus == "FINISHED" || CallDone.CallStatus == "FAILED") && CallDone.CallDirection == "OUTGOING") + { + GUIListItem item = new GUIListItem(); + // Compose the name to show + if (CallDone.ContactCalledFullName == "") + NameToShow = CallDone.ContactCalledName; + else + NameToShow = CallDone.ContactCalledFullName + " (" + CallDone.ContactCalledName + ")"; + item.Label = NameToShow; + + ConvertedTimeStamp = DateTime.Parse("01/01/1970 00:00"); + ConvertedTimeStamp = (DateTime)ConvertedTimeStamp.AddSeconds(CallDone.CallTimeStamp); + + if (ConvertedTimeStamp.Date == DateTime.Today) + item.Label2 = "Today at " + ConvertedTimeStamp.ToShortTimeString(); + else + item.Label2 = ConvertedTimeStamp.ToString(); + item.IsFolder = false; + + // This will be used for retrieving call details if the user choose to see them + item.AlbumInfoTag = CallDone.CallId; + + // The calls done may be successfully done or failed (for example calls made to + // guys that were offline), so we will put an icon with the red flag on those calls + if (CallDone.CallStatus == "FAILED") + { + item.IconImage = "MySkype-ContactStatusDoNotDisturb.png"; + item.IconImageBig = "MySkype-ContactStatusDoNotDisturb.png"; + } + else + { + item.IconImage = "MySkype-ContactStatusOnline.png"; + item.IconImageBig = "MySkype-ContactStatusOnline.png"; + } + GUIControl.AddListItemControl(GetID, RecentCallList.GetID, item); + } + } + SkypeConn.NewData = false; + return; + } + + #endregion + + #region Contacts Page + + // If it reaches this point it means that the Contacts page is shown, so we will refresh it + // Refresh user name + GUIPropertyManager.SetProperty("#UserFullName", "User " + SkypeConn.Myself.FullName); + // Refresh user status + switch (SkypeConn.Myself.OnlineStatus) + { + case "ONLINE": + GUIPropertyManager.SetProperty("#UserOnline", "is online"); + GUIPropertyManager.SetProperty("#UserStatusIcon", @"\MySkype-UserStatusOnline.png"); + break; + case "AWAY": + GUIPropertyManager.SetProperty("#UserOnline", "is away"); + GUIPropertyManager.SetProperty("#UserStatusIcon", @"\MySkype-UserStatusAway.png"); + break; + case "DND": + GUIPropertyManager.SetProperty("#UserOnline", "don't want to be disturbed"); + GUIPropertyManager.SetProperty("#UserStatusIcon", @"\MySkype-UserStatusDoNotDisturb.png"); + break; + case "NA": + GUIPropertyManager.SetProperty("#UserOnline", "is not available"); + GUIPropertyManager.SetProperty("#UserStatusIcon", @"\MySkype-UserStatusNotAvailable.png"); + break; + case "INVISIBLE": + GUIPropertyManager.SetProperty("#UserOnline", "is invisible"); + GUIPropertyManager.SetProperty("#UserStatusIcon", @"\MySkype-UserStatusInvisible.png"); + break; + case "OFFLINE": + GUIPropertyManager.SetProperty("#UserOnline", "is offline"); + GUIPropertyManager.SetProperty("#UserStatusIcon", @"\MySkype-UserStatusOffline.png"); + break; + case "NotAvailable": + GUIPropertyManager.SetProperty("#UserOnline", "can't get status"); + GUIPropertyManager.SetProperty("#UserStatusIcon", null); + break; + } + // Refresh contact list + GUIControl.ClearControl(GetID, ContactList.GetID); + GUIControl.ClearControl(GetID, ContactIcon.GetID); + + foreach (Contact buddy in SkypeConn.MyContacts) + { + // If the settings is to not show offline contacts and this is an offline + // contact then jump to the next contact + if (!MySkypeSettings.ShowOfflineContacts && buddy.OnlineStatus == "OFFLINE") + continue; + GUIListItem item = new GUIListItem(); + if (buddy.FullName == "") + { + item.Label = buddy.Name; + item.Label2 = buddy.Name; + } + else + { + item.Label = buddy.FullName; //+ " (" + buddy.Name + ")"; + item.Label2 = buddy.Name; + } + item.IsFolder = false; + item.AlbumInfoTag = buddy; + + // Put the right icon near the username + switch (buddy.OnlineStatus) + { + case "ONLINE": + item.IconImage = "MySkype-ContactStatusOnline.png"; + item.IconImageBig = "MySkype-ContactStatusOnline.png"; + break; + case "AWAY": + item.IconImage = "MySkype-ContactStatusAway.png"; + item.IconImageBig = "MySkype-ContactStatusAway.png"; + break; + case "DND": + item.IconImage = "MySkype-ContactStatusDoNotDisturb.png"; + item.IconImageBig = "MySkype-ContactStatusDoNotDisturb.png"; + break; + case "NA": + item.IconImage = "MySkype-ContactStatusNotAvailable.png"; + item.IconImageBig = "MySkype-ContactStatusNotAvailable.png"; + break; + case "OFFLINE": + item.IconImage = "MySkype-ContactStatusOffline.png"; + item.IconImageBig = "MySkype-ContactStatusOffline.png"; + break; + default: + item.IconImage = "MySkype-ContactStatusOffline.png"; + item.IconImageBig = "MySkype-ContactStatusOffline.png"; + break; + } + GUIControl.AddListItemControl(GetID, ContactList.GetID, item); + GUIControl.AddListItemControl(GetID, ContactIcon.GetID, item); + + // Show the right view: list or thumbs icons? + if (ViewAs == "View as list") + { + GUIControl.HideControl(GetID, ContactIcon.GetID); + GUIControl.ShowControl(GetID, ContactList.GetID); + } + else + { + GUIControl.HideControl(GetID, ContactList.GetID); + GUIControl.ShowControl(GetID, ContactIcon.GetID); + } + } + // Update addressbook stats + GUIPropertyManager.SetProperty("#NumberOfContacts", string.Format("Found {0} contacts, {1} may be called", SkypeConn.AddressBookStats.ContactsCount, SkypeConn.AddressBookStats.OnlineCount)); + + #endregion + + // We've done, no more data to be shown + SkypeConn.NewData = false; + } + + #endregion + + } + +} Added: trunk/plugins/MySkype/MySkype/MySkype.csproj =================================================================== --- trunk/plugins/MySkype/MySkype/MySkype.csproj (rev 0) +++ trunk/plugins/MySkype/MySkype/MySkype.csproj 2008-01-07 10:53:19 UTC (rev 1221) @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.21022</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{FD5DFBBB-FDA6-4D1A-81B5-181DD0E01DEF}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>MySkype</RootNamespace> + <AssemblyName>MySkype</AssemblyName> + <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Core, Version=0.2.3.0, Culture=neutral, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <HintPath>C:\Program Files\Team MediaPortal\MediaPortal\Core.dll</HintPath> + </Reference> + <Reference Include="Dialogs, Version=0.2.3.0, Culture=neutral, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <HintPath>C:\Program Files\Team MediaPortal\MediaPortal\plugins\Windows\Dialogs.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + <Reference Include="Utils, Version=2.2.2.0, Culture=neutral, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <HintPath>C:\Program Files\Team MediaPortal\MediaPortal\Utils.dll</HintPath> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> + <Compile Include="SkypeConnector.cs" /> + <Compile Include="MySkype.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="SkypeControl\SkypeControl.csproj"> + <Project>{7929F278-3A47-4FF1-A96F-44121E759261}</Project> + <Name>SkypeControl</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="MySkype-Icon.png" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Added: trunk/plugins/MySkype/MySkype/MySkype.csproj.user =================================================================== --- trunk/plugins/MySkype/MySkype/MySkype.csproj.user (rev 0) +++ trunk/plugins/MySkype/MySkype/MySkype.csproj.user 2008-01-07 10:53:19 UTC (rev 1221) @@ -0,0 +1,5 @@ +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <ProjectView>ShowAllFiles</ProjectView> + </PropertyGroup> +</Project> \ No newline at end of file Added: trunk/plugins/MySkype/MySkype/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/MySkype/MySkype/Properties/AssemblyInfo.cs (rev 0) +++ trunk/plugins/MySkype/MySkype/Properties/AssemblyInfo.cs 2008-01-07 10:53:19 UTC (rev 1221) @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled t... [truncated message content] |