sync updates

This commit is contained in:
Luke Pulverenti 2015-03-17 01:58:29 -04:00
parent 84244b8cac
commit 4915da4cdd
11 changed files with 75 additions and 4 deletions

View File

@ -73,6 +73,12 @@ namespace MediaBrowser.Api
public string ConnectUserId { get; set; } public string ConnectUserId { get; set; }
} }
[Route("/Connect/Supporters", "GET")]
[Authenticated(Roles = "Admin")]
public class GetConnectSupporterSummary : IReturn<ConnectSupporterSummary>
{
}
public class ConnectService : BaseApiService public class ConnectService : BaseApiService
{ {
private readonly IConnectManager _connectManager; private readonly IConnectManager _connectManager;
@ -84,6 +90,13 @@ namespace MediaBrowser.Api
_userManager = userManager; _userManager = userManager;
} }
public async Task<object> Get(GetConnectSupporterSummary request)
{
var result = await _connectManager.GetConnectSupporterSummary().ConfigureAwait(false);
return ToOptimizedResult(result);
}
public object Post(CreateConnectLink request) public object Post(CreateConnectLink request)
{ {
return _connectManager.LinkUser(request.Id, request.ConnectUsername); return _connectManager.LinkUser(request.Id, request.ConnectUsername);

View File

@ -0,0 +1,16 @@
using MediaBrowser.Model.Connect;
using System.Collections.Generic;
namespace MediaBrowser.Controller.Connect
{
public class ConnectSupporterSummary
{
public int MaxUsers { get; set; }
public List<ConnectUser> Users { get; set; }
public ConnectSupporterSummary()
{
Users = new List<ConnectUser>();
}
}
}

View File

@ -69,5 +69,11 @@ namespace MediaBrowser.Controller.Connect
/// <param name="token">The token.</param> /// <param name="token">The token.</param>
/// <returns><c>true</c> if [is authorization token valid] [the specified token]; otherwise, <c>false</c>.</returns> /// <returns><c>true</c> if [is authorization token valid] [the specified token]; otherwise, <c>false</c>.</returns>
bool IsAuthorizationTokenValid(string token); bool IsAuthorizationTokenValid(string token);
/// <summary>
/// Gets the connect supporter summary.
/// </summary>
/// <returns>Task&lt;ConnectSupporterSummary&gt;.</returns>
Task<ConnectSupporterSummary> GetConnectSupporterSummary();
} }
} }

View File

@ -99,6 +99,7 @@
<Compile Include="Collections\CollectionCreationOptions.cs" /> <Compile Include="Collections\CollectionCreationOptions.cs" />
<Compile Include="Collections\CollectionEvents.cs" /> <Compile Include="Collections\CollectionEvents.cs" />
<Compile Include="Collections\ICollectionManager.cs" /> <Compile Include="Collections\ICollectionManager.cs" />
<Compile Include="Connect\ConnectSupporterSummary.cs" />
<Compile Include="Connect\IConnectManager.cs" /> <Compile Include="Connect\IConnectManager.cs" />
<Compile Include="Connect\UserLinkResult.cs" /> <Compile Include="Connect\UserLinkResult.cs" />
<Compile Include="Devices\CameraImageUploadInfo.cs" /> <Compile Include="Devices\CameraImageUploadInfo.cs" />

View File

@ -1,5 +1,6 @@
using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Common.Security;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Connect; using MediaBrowser.Controller.Connect;
@ -38,6 +39,7 @@ namespace MediaBrowser.Server.Implementations.Connect
private readonly IServerConfigurationManager _config; private readonly IServerConfigurationManager _config;
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IProviderManager _providerManager; private readonly IProviderManager _providerManager;
private readonly ISecurityManager _securityManager;
private ConnectData _data = new ConnectData(); private ConnectData _data = new ConnectData();
@ -102,7 +104,7 @@ namespace MediaBrowser.Server.Implementations.Connect
IEncryptionManager encryption, IEncryptionManager encryption,
IHttpClient httpClient, IHttpClient httpClient,
IServerApplicationHost appHost, IServerApplicationHost appHost,
IServerConfigurationManager config, IUserManager userManager, IProviderManager providerManager) IServerConfigurationManager config, IUserManager userManager, IProviderManager providerManager, ISecurityManager securityManager)
{ {
_logger = logger; _logger = logger;
_appPaths = appPaths; _appPaths = appPaths;
@ -113,6 +115,7 @@ namespace MediaBrowser.Server.Implementations.Connect
_config = config; _config = config;
_userManager = userManager; _userManager = userManager;
_providerManager = providerManager; _providerManager = providerManager;
_securityManager = securityManager;
_userManager.UserConfigurationUpdated += _userManager_UserConfigurationUpdated; _userManager.UserConfigurationUpdated += _userManager_UserConfigurationUpdated;
_config.ConfigurationUpdated += _config_ConfigurationUpdated; _config.ConfigurationUpdated += _config_ConfigurationUpdated;
@ -1054,6 +1057,34 @@ namespace MediaBrowser.Server.Implementations.Connect
} }
} }
public async Task<ConnectSupporterSummary> GetConnectSupporterSummary()
{
if (!_securityManager.IsMBSupporter)
{
return new ConnectSupporterSummary();
}
var url = GetConnectUrl("keyAssociation");
url += "?serverId=" + ConnectServerId;
url += "&supporterKey=" + _securityManager.SupporterKey;
var options = new HttpRequestOptions
{
Url = url,
CancellationToken = CancellationToken.None
};
SetServerAccessToken(options);
SetApplicationHeader(options);
// No need to examine the response
using (var stream = (await _httpClient.SendAsync(options, "GET").ConfigureAwait(false)).Content)
{
return _json.DeserializeFromStream<ConnectSupporterSummary>(stream);
}
}
public async Task Authenticate(string username, string passwordMd5) public async Task Authenticate(string username, string passwordMd5)
{ {
if (string.IsNullOrWhiteSpace(username)) if (string.IsNullOrWhiteSpace(username))

View File

@ -36,6 +36,8 @@
"MessageKeyUpdated": "Thank you. Your supporter key has been updated.", "MessageKeyUpdated": "Thank you. Your supporter key has been updated.",
"MessageKeyRemoved": "Thank you. Your supporter key has been removed.", "MessageKeyRemoved": "Thank you. Your supporter key has been removed.",
"ErrorLaunchingChromecast": "There was an error launching chromecast. Please ensure your device is connected to your wireless network.", "ErrorLaunchingChromecast": "There was an error launching chromecast. Please ensure your device is connected to your wireless network.",
"MessageErrorLoadingSupporterInfo": "There was an error loading supporter information. Please try again later.",
"MessageLinkYourSupporterKey": "Link your supporter key with up to {0} Media Browser Connect members to enjoy free access to the following apps:",
"ValueTimeLimitSingleHour": "Time limit: 1 hour", "ValueTimeLimitSingleHour": "Time limit: 1 hour",
"ValueTimeLimitMultiHour": "Time limit: {0} hours", "ValueTimeLimitMultiHour": "Time limit: {0} hours",
"PluginCategoryGeneral": "General", "PluginCategoryGeneral": "General",

View File

@ -48,6 +48,8 @@
"LabelDashboardSourcePathHelp": "If running the server from source, specify the path to the dashboard-ui folder. All web client files will be served from this location.", "LabelDashboardSourcePathHelp": "If running the server from source, specify the path to the dashboard-ui folder. All web client files will be served from this location.",
"ButtonConvertMedia": "Convert media", "ButtonConvertMedia": "Convert media",
"ButtonOrganize": "Organize", "ButtonOrganize": "Organize",
"LinkedToMediaBrowserConnect": "Linked to Media Browser Connect",
"HeaderSupporterBenefits": "Supporter Benefits",
"LabelPinCode": "Pin code:", "LabelPinCode": "Pin code:",
"ButtonOk": "Ok", "ButtonOk": "Ok",
"ButtonCancel": "Cancel", "ButtonCancel": "Cancel",

View File

@ -59,7 +59,7 @@ namespace MediaBrowser.Server.Implementations.Sync
{ {
return new ITaskTrigger[] return new ITaskTrigger[]
{ {
new IntervalTrigger { Interval = TimeSpan.FromHours(6) } new IntervalTrigger { Interval = TimeSpan.FromHours(3) }
}; };
} }

View File

@ -15,7 +15,6 @@ using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Playlists; using MediaBrowser.Controller.Playlists;
using MediaBrowser.Controller.Sync; using MediaBrowser.Controller.Sync;
using MediaBrowser.Controller.TV; using MediaBrowser.Controller.TV;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Events; using MediaBrowser.Model.Events;

View File

@ -457,7 +457,7 @@ namespace MediaBrowser.Server.Startup.Common
var encryptionManager = new EncryptionManager(); var encryptionManager = new EncryptionManager();
RegisterSingleInstance<IEncryptionManager>(encryptionManager); RegisterSingleInstance<IEncryptionManager>(encryptionManager);
ConnectManager = new ConnectManager(LogManager.GetLogger("Connect"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager, ProviderManager); ConnectManager = new ConnectManager(LogManager.GetLogger("Connect"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager, ProviderManager, SecurityManager);
RegisterSingleInstance(ConnectManager); RegisterSingleInstance(ConnectManager);
DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, LogManager.GetLogger("DeviceManager"), FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ConfigurationManager, LogManager.GetLogger("DeviceManager")); DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, LogManager.GetLogger("DeviceManager"), FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ConfigurationManager, LogManager.GetLogger("DeviceManager"));

View File

@ -87,6 +87,7 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="dashboard-ui\css\images\clients\androidtv-tile.png" />
<Content Include="dashboard-ui\css\images\kids\bg.jpg"> <Content Include="dashboard-ui\css\images\kids\bg.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>