2
0

ServerInfo.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using MediaBrowser.Model.Connect;
  2. using MediaBrowser.Model.System;
  3. using System;
  4. using System.Collections.Generic;
  5. namespace MediaBrowser.Model.ApiClient
  6. {
  7. public class ServerInfo
  8. {
  9. public String Name { get; set; }
  10. public String Id { get; set; }
  11. public String LocalAddress { get; set; }
  12. public String RemoteAddress { get; set; }
  13. public String ManualAddress { get; set; }
  14. public String UserId { get; set; }
  15. public String AccessToken { get; set; }
  16. public List<WakeOnLanInfo> WakeOnLanInfos { get; set; }
  17. public DateTime DateLastAccessed { get; set; }
  18. public String ExchangeToken { get; set; }
  19. public UserLinkType? UserLinkType { get; set; }
  20. public ConnectionMode? LastConnectionMode { get; set; }
  21. public ServerInfo()
  22. {
  23. WakeOnLanInfos = new List<WakeOnLanInfo>();
  24. }
  25. public void ImportInfo(PublicSystemInfo systemInfo)
  26. {
  27. Name = systemInfo.ServerName;
  28. Id = systemInfo.Id;
  29. if (!string.IsNullOrEmpty(systemInfo.LocalAddress))
  30. {
  31. LocalAddress = systemInfo.LocalAddress;
  32. }
  33. if (!string.IsNullOrEmpty(systemInfo.WanAddress))
  34. {
  35. RemoteAddress = systemInfo.WanAddress;
  36. }
  37. var fullSystemInfo = systemInfo as SystemInfo;
  38. if (fullSystemInfo != null)
  39. {
  40. WakeOnLanInfos = new List<WakeOnLanInfo>();
  41. if (!string.IsNullOrEmpty(fullSystemInfo.MacAddress))
  42. {
  43. WakeOnLanInfos.Add(new WakeOnLanInfo
  44. {
  45. MacAddress = fullSystemInfo.MacAddress
  46. });
  47. }
  48. }
  49. }
  50. public string GetAddress(ConnectionMode mode)
  51. {
  52. switch (mode)
  53. {
  54. case ConnectionMode.Local:
  55. return LocalAddress;
  56. case ConnectionMode.Manual:
  57. return ManualAddress;
  58. case ConnectionMode.Remote:
  59. return RemoteAddress;
  60. default:
  61. throw new ArgumentException("Unexpected ConnectionMode");
  62. }
  63. }
  64. }
  65. }