diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-09-14 11:10:51 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-09-14 11:10:51 -0400 |
| commit | 5c615fa02448813499ed87f2a1c2b937c7a7dcd5 (patch) | |
| tree | b96b07cb1d43006a8faa64649885fb808e18c43a /MediaBrowser.Controller | |
| parent | 4f3ea6c6c3cdde7f4b8d21dc97c711635d73b4e0 (diff) | |
add connect linking
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Connect/ConnectInvitationRequest.cs | 20 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Connect/ConnectUser.cs | 22 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Connect/ConnectUserLink.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Connect/IConnectManager.cs | 29 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/User.cs | 33 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Library/IUserManager.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaBrowser.Controller.csproj | 3 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Net/LoggedAttribute.cs | 2 |
8 files changed, 118 insertions, 8 deletions
diff --git a/MediaBrowser.Controller/Connect/ConnectInvitationRequest.cs b/MediaBrowser.Controller/Connect/ConnectInvitationRequest.cs new file mode 100644 index 000000000..91516723b --- /dev/null +++ b/MediaBrowser.Controller/Connect/ConnectInvitationRequest.cs @@ -0,0 +1,20 @@ + +namespace MediaBrowser.Controller.Connect +{ + public class ConnectInvitationRequest + { + public string LocalUserId { get; set; } + + public string Username { get; set; } + + public string RequesterUserId { get; set; } + + public ConnectUserType Type { get; set; } + } + + public enum ConnectUserType + { + LinkedUser = 1, + Guest = 2 + } +} diff --git a/MediaBrowser.Controller/Connect/ConnectUser.cs b/MediaBrowser.Controller/Connect/ConnectUser.cs new file mode 100644 index 000000000..c640f9095 --- /dev/null +++ b/MediaBrowser.Controller/Connect/ConnectUser.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.Connect +{ + public class ConnectUser + { + public string Id { get; set; } + public string Name { get; set; } + public string Email { get; set; } + } + + public class ConnectUserQuery + { + public string Id { get; set; } + public string Name { get; set; } + public string Email { get; set; } + } +} diff --git a/MediaBrowser.Controller/Connect/ConnectUserLink.cs b/MediaBrowser.Controller/Connect/ConnectUserLink.cs new file mode 100644 index 000000000..93de6d8b4 --- /dev/null +++ b/MediaBrowser.Controller/Connect/ConnectUserLink.cs @@ -0,0 +1,10 @@ + +namespace MediaBrowser.Controller.Connect +{ + public class ConnectUserLink + { + public string Username { get; set; } + public string UserId { get; set; } + public string LocalUserId { get; set; } + } +} diff --git a/MediaBrowser.Controller/Connect/IConnectManager.cs b/MediaBrowser.Controller/Connect/IConnectManager.cs index 2e52591f5..6c2128cd3 100644 --- a/MediaBrowser.Controller/Connect/IConnectManager.cs +++ b/MediaBrowser.Controller/Connect/IConnectManager.cs @@ -1,8 +1,35 @@ - +using System.Threading.Tasks; + namespace MediaBrowser.Controller.Connect { public interface IConnectManager { + /// <summary> + /// Gets the wan API address. + /// </summary> + /// <value>The wan API address.</value> string WanApiAddress { get; } + + /// <summary> + /// Gets the user information. + /// </summary> + /// <param name="userId">The user identifier.</param> + /// <returns>ConnectUserInfo.</returns> + ConnectUserLink GetUserInfo(string userId); + + /// <summary> + /// Links the user. + /// </summary> + /// <param name="userId">The user identifier.</param> + /// <param name="connectUsername">The connect username.</param> + /// <returns>Task.</returns> + Task LinkUser(string userId, string connectUsername); + + /// <summary> + /// Removes the link. + /// </summary> + /// <param name="userId">The user identifier.</param> + /// <returns>Task.</returns> + Task RemoveLink(string userId); } } diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index e4fd929ff..c0c7a6c53 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -20,12 +20,22 @@ namespace MediaBrowser.Controller.Entities public static IXmlSerializer XmlSerializer { get; set; } /// <summary> + /// From now on all user paths will be Id-based. + /// This is for backwards compatibility. + /// </summary> + public bool UsesIdForConfigurationPath { get; set; } + + /// <summary> /// Gets or sets the password. /// </summary> /// <value>The password.</value> public string Password { get; set; } public string LocalPassword { get; set; } + public string ConnectUserName { get; set; } + public string ConnectUserId { get; set; } + public string ConnectAccessKey { get; set; } + /// <summary> /// Gets or sets the path. /// </summary> @@ -136,12 +146,14 @@ namespace MediaBrowser.Controller.Entities { if (string.IsNullOrEmpty(newName)) { - throw new ArgumentNullException(); + throw new ArgumentNullException("newName"); } // If only the casing is changing, leave the file system alone - if (!newName.Equals(Name, StringComparison.OrdinalIgnoreCase)) + if (!UsesIdForConfigurationPath && !newName.Equals(Name, StringComparison.OrdinalIgnoreCase)) { + UsesIdForConfigurationPath = true; + // Move configuration var newConfigDirectory = GetConfigurationDirectoryPath(newName); var oldConfigurationDirectory = ConfigurationDirectoryPath; @@ -168,7 +180,8 @@ namespace MediaBrowser.Controller.Entities { ReplaceAllMetadata = true, ImageRefreshMode = ImageRefreshMode.FullRefresh, - MetadataRefreshMode = MetadataRefreshMode.FullRefresh + MetadataRefreshMode = MetadataRefreshMode.FullRefresh, + ForceSave = true }, CancellationToken.None); } @@ -183,7 +196,7 @@ namespace MediaBrowser.Controller.Entities /// </summary> /// <value>The configuration directory path.</value> [IgnoreDataMember] - public string ConfigurationDirectoryPath + private string ConfigurationDirectoryPath { get { @@ -203,9 +216,17 @@ namespace MediaBrowser.Controller.Entities throw new ArgumentNullException("username"); } - var safeFolderName = FileSystem.GetValidFilename(username); + var parentPath = ConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath; + + // Legacy + if (!UsesIdForConfigurationPath) + { + var safeFolderName = FileSystem.GetValidFilename(username); + + return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, safeFolderName); + } - return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, safeFolderName); + return System.IO.Path.Combine(parentPath, Id.ToString("N")); } /// <summary> diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs index a5d949c8a..3efdbea76 100644 --- a/MediaBrowser.Controller/Library/IUserManager.cs +++ b/MediaBrowser.Controller/Library/IUserManager.cs @@ -50,6 +50,13 @@ namespace MediaBrowser.Controller.Library User GetUserById(Guid id); /// <summary> + /// Gets the user by identifier. + /// </summary> + /// <param name="id">The identifier.</param> + /// <returns>User.</returns> + User GetUserById(string id); + + /// <summary> /// Authenticates a User and returns a result indicating whether or not it succeeded /// </summary> /// <param name="username">The username.</param> diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 1813d9f08..1d23a82a9 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -99,6 +99,9 @@ <Compile Include="Collections\CollectionCreationOptions.cs" /> <Compile Include="Collections\CollectionEvents.cs" /> <Compile Include="Collections\ICollectionManager.cs" /> + <Compile Include="Connect\ConnectInvitationRequest.cs" /> + <Compile Include="Connect\ConnectUser.cs" /> + <Compile Include="Connect\ConnectUserLink.cs" /> <Compile Include="Connect\IConnectManager.cs" /> <Compile Include="Dlna\ControlRequest.cs" /> <Compile Include="Dlna\ControlResponse.cs" /> diff --git a/MediaBrowser.Controller/Net/LoggedAttribute.cs b/MediaBrowser.Controller/Net/LoggedAttribute.cs index 6df72f7a7..ea07b1c7f 100644 --- a/MediaBrowser.Controller/Net/LoggedAttribute.cs +++ b/MediaBrowser.Controller/Net/LoggedAttribute.cs @@ -33,7 +33,7 @@ namespace MediaBrowser.Controller.Net { var userId = auth.UserId; - user = UserManager.GetUserById(new Guid(userId)); + user = UserManager.GetUserById(userId); } string deviceId = auth.DeviceId; |
