/MediaPortal/Source/Core/MediaPortal.UI/Services/ServerCommunication/UPnPServerControllerServiceProxy.cs

https://github.com/Thorsten1982/MediaPortal-2 · C# · 79 lines · 46 code · 10 blank · 23 comment · 1 complexity · 4fe5e92695543f33eaff7a7c55fa6a4b MD5 · raw file

  1. #region Copyright (C) 2007-2011 Team MediaPortal
  2. /*
  3. Copyright (C) 2007-2011 Team MediaPortal
  4. http://www.team-mediaportal.com
  5. This file is part of MediaPortal 2
  6. MediaPortal 2 is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. MediaPortal 2 is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with MediaPortal 2. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #endregion
  18. using System.Collections.Generic;
  19. using MediaPortal.Common.ClientCommunication;
  20. using MediaPortal.Common.General;
  21. using MediaPortal.Common.UPnP;
  22. using MediaPortal.UI.ServerCommunication;
  23. using UPnP.Infrastructure.CP.DeviceTree;
  24. namespace MediaPortal.UI.Services.ServerCommunication
  25. {
  26. /// <summary>
  27. /// Encapsulates the MediaPortal 2 UPnP client's proxy for the ServerController service.
  28. /// </summary>
  29. public class UPnPServerControllerServiceProxy : UPnPServiceProxyBase, IServerController
  30. {
  31. public UPnPServerControllerServiceProxy(CpService serviceStub) : base(serviceStub, "ServerController") { }
  32. public bool IsClientAttached(string clientSystemId)
  33. {
  34. CpAction action = GetAction("IsClientAttached");
  35. IList<object> outParams = action.InvokeAction(new List<object> {clientSystemId});
  36. return (bool) outParams[0];
  37. }
  38. public void AttachClient(string clientSystemId)
  39. {
  40. CpAction action = GetAction("AttachClient");
  41. action.InvokeAction(new List<object> {clientSystemId});
  42. }
  43. public void DetachClient(string clientSystemId)
  44. {
  45. CpAction action = GetAction("DetachClient");
  46. action.InvokeAction(new List<object> {clientSystemId});
  47. }
  48. public ICollection<MPClientMetadata> GetAttachedClients()
  49. {
  50. CpAction action = GetAction("GetAttachedClients");
  51. IList<object> outParams = action.InvokeAction(new List<object> {});
  52. return (ICollection<MPClientMetadata>) outParams[0];
  53. }
  54. public SystemName GetSystemNameForSystemId(string systemId)
  55. {
  56. CpAction action = GetAction("GetSystemNameForSystemId");
  57. IList<object> outParams = action.InvokeAction(new List<object> {systemId});
  58. string hostName = (string) outParams[0];
  59. if (string.IsNullOrEmpty(hostName))
  60. return null;
  61. return new SystemName(hostName);
  62. }
  63. // TODO: State variables, if present
  64. }
  65. }