add connect linking

This commit is contained in:
Luke Pulverenti
2014-09-14 11:10:51 -04:00
parent 4f3ea6c6c3
commit 5c615fa024
42 changed files with 542 additions and 78 deletions

View File

@@ -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
}
}

View File

@@ -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; }
}
}

View File

@@ -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; }
}
}

View File

@@ -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);
}
}

View File

@@ -19,6 +19,12 @@ namespace MediaBrowser.Controller.Entities
public static IUserManager UserManager { get; set; }
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>
@@ -26,6 +32,10 @@ namespace MediaBrowser.Controller.Entities
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;
return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, safeFolderName);
// Legacy
if (!UsesIdForConfigurationPath)
{
var safeFolderName = FileSystem.GetValidFilename(username);
return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, safeFolderName);
}
return System.IO.Path.Combine(parentPath, Id.ToString("N"));
}
/// <summary>

View File

@@ -49,6 +49,13 @@ namespace MediaBrowser.Controller.Library
/// <exception cref="System.ArgumentNullException"></exception>
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>

View File

@@ -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" />

View File

@@ -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;