diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index 38232a1fd5..abd2f05bf0 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -74,6 +74,9 @@ ApiClient\ApiClientExtensions.cs + + ApiClient\ConnectionResult.cs + ApiClient\GeneralCommandEventArgs.cs @@ -83,12 +86,18 @@ ApiClient\IApiClient.cs + + ApiClient\IConnectionManager.cs + ApiClient\IServerEvents.cs ApiClient\ServerDiscoveryInfo.cs + + ApiClient\ServerInfo.cs + ApiClient\SessionUpdatesEventArgs.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index acd463f591..a3d92db4ae 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -67,6 +67,9 @@ ApiClient\ServerDiscoveryInfo.cs + + ApiClient\ServerInfo.cs + ApiClient\SessionUpdatesEventArgs.cs diff --git a/MediaBrowser.Model/ApiClient/ConnectionResult.cs b/MediaBrowser.Model/ApiClient/ConnectionResult.cs new file mode 100644 index 0000000000..12f89d9307 --- /dev/null +++ b/MediaBrowser.Model/ApiClient/ConnectionResult.cs @@ -0,0 +1,23 @@ + +namespace MediaBrowser.Model.ApiClient +{ + public class ConnectionResult + { + public ConnectionState State { get; set; } + public ServerInfo ServerInfo { get; set; } + public IApiClient ApiClient { get; set; } + } + + public enum ConnectionState + { + Unavailable = 1, + ServerSignIn = 2, + SignedIn = 3 + } + + public enum ConnectionMode + { + Local = 1, + Remote = 2 + } +} diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index 8b7681c845..3efdea70d4 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.Model.ApiClient /// /// Interface IApiClient /// - public interface IApiClient : IDisposable + public interface IApiClient : IServerEvents, IDisposable { /// /// Occurs when [HTTP response received]. @@ -1288,5 +1288,17 @@ namespace MediaBrowser.Model.ApiClient /// options [Obsolete] string GetHlsVideoStreamUrl(VideoStreamOptions options); + + /// + /// Sends the context message asynchronous. + /// + /// Type of the item. + /// The item identifier. + /// Name of the item. + /// The context. + /// The cancellation token. + /// Task. + Task SendContextMessageAsync(string itemType, string itemId, string itemName, string context, + CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/MediaBrowser.Model/ApiClient/IConnectionManager.cs b/MediaBrowser.Model/ApiClient/IConnectionManager.cs new file mode 100644 index 0000000000..6a2d5c8cf3 --- /dev/null +++ b/MediaBrowser.Model/ApiClient/IConnectionManager.cs @@ -0,0 +1,62 @@ +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Events; +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Model.ApiClient +{ + public interface IConnectionManager + { + /// + /// Occurs when [connected]. + /// + event EventHandler> Connected; + + /// + /// Gets the API client. + /// + /// The item. + /// MediaBrowser.Model.ApiClient.IApiClient. + IApiClient GetApiClient(BaseItemDto item); + + /// + /// Connects the specified cancellation token. + /// + /// The cancellation token. + /// Task<ConnectionResult>. + Task Connect(CancellationToken cancellationToken); + + /// + /// Connects the specified server. + /// + /// The server. + /// The cancellation token. + /// Task<ConnectionResult>. + Task Connect(ServerInfo server, CancellationToken cancellationToken); + + /// + /// Connects the specified server. + /// + /// The address. + /// The cancellation token. + /// Task<ConnectionResult>. + Task Connect(string address, CancellationToken cancellationToken); + + /// + /// Logouts this instance. + /// + /// Task<ConnectionResult>. + Task Logout(); + + /// + /// Authenticates the specified server. + /// + /// The server. + /// The username. + /// The hash. + /// if set to true [remember login]. + /// Task. + Task Authenticate(ServerInfo server, string username, byte[] hash, bool rememberLogin); + } +} diff --git a/MediaBrowser.Model/ApiClient/ServerInfo.cs b/MediaBrowser.Model/ApiClient/ServerInfo.cs new file mode 100644 index 0000000000..9662637267 --- /dev/null +++ b/MediaBrowser.Model/ApiClient/ServerInfo.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Model.ApiClient +{ + public class ServerInfo + { + public String Name { get; set; } + public String Id { get; set; } + public String LocalAddress { get; set; } + public String RemoteAddress { get; set; } + public String UserId { get; set; } + public String AccessToken { get; set; } + public List MacAddresses { get; set; } + + public ServerInfo() + { + MacAddresses = new List(); + + LocalAddress = "http://localhost:8096"; + } + } +} diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 6273ce87f6..e51edae1b0 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -29,7 +29,7 @@ namespace MediaBrowser.Model.Dto /// /// The id. public string Id { get; set; } - + /// /// Gets or sets the playlist item identifier. /// diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 1055041212..484b0969ef 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -60,12 +60,15 @@ Properties\SharedVersion.cs + + + diff --git a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs index 02d6434776..bd845ef4a7 100644 --- a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs +++ b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs @@ -33,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.Library { IEnumerable inputItems; - if (string.IsNullOrEmpty(query.UserId)) + if (string.IsNullOrWhiteSpace(query.UserId)) { inputItems = _libraryManager.RootFolder.RecursiveChildren; } @@ -91,7 +91,7 @@ namespace MediaBrowser.Server.Implementations.Library { var searchTerm = query.SearchTerm; - if (string.IsNullOrEmpty(searchTerm)) + if (string.IsNullOrWhiteSpace(searchTerm)) { throw new ArgumentNullException("searchTerm"); } @@ -105,7 +105,7 @@ namespace MediaBrowser.Server.Implementations.Library if (query.IncludeMedia) { // Add search hints based on item name - hints.AddRange(items.Where(i => !string.IsNullOrEmpty(i.Name)).Select(item => + hints.AddRange(items.Where(i => !string.IsNullOrWhiteSpace(i.Name)).Select(item => { var index = GetIndex(item.Name, searchTerm, terms); @@ -118,6 +118,7 @@ namespace MediaBrowser.Server.Implementations.Library // Find artists var artists = items.OfType