From 253cfcd64bf7454517b130994f9072e483c0c8c1 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Tue, 22 Sep 2015 12:39:53 -0400 Subject: Reroute some calls --- .../Security/PluginSecurityManager.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index 39dd41356b..ec36132980 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -158,9 +158,14 @@ namespace MediaBrowser.Common.Implementations.Security return new SupporterInfo(); } - var url = MbAdmin.HttpsUrl + "/service/supporter/retrieve?key=" + key; + var data = new Dictionary + { + { "key", key }, + }; + + var url = MbAdmin.HttpsUrl + "/service/supporter/retrieve"; - using (var stream = await _httpClient.Get(url, CancellationToken.None).ConfigureAwait(false)) + using (var stream = await _httpClient.Post(url, data, CancellationToken.None).ConfigureAwait(false)) { var response = _jsonSerializer.DeserializeFromStream(stream); -- cgit v1.2.3 From 7404114fee8a06983261bb7a8e361c00ed8b3d7a Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Sat, 26 Sep 2015 16:27:13 -0400 Subject: Add store registration endpoint (pointing to test) --- MediaBrowser.Api/PluginService.cs | 30 +++++++++++++++++ .../Security/PluginSecurityManager.cs | 39 ++++++++++++++++++++++ .../Security/RegRecord.cs | 1 + MediaBrowser.Common/Security/ISecurityManager.cs | 8 +++++ MediaBrowser.ServerApplication/App.config | 2 +- 5 files changed, 79 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index eb49914eb1..224a88881b 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -118,6 +118,30 @@ namespace MediaBrowser.Api public string Name { get; set; } } + [Route("/Appstore/Register", "POST", Summary = "Registers an appstore sale")] + [Authenticated] + public class RegisterAppstoreSale + { + [ApiMember(Name = "Store", Description = "Store Name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Store { get; set; } + [ApiMember(Name = "Application", Description = "Application id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Application { get; set; } + [ApiMember(Name = "Product", Description = "Product id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Product { get; set; } + [ApiMember(Name = "Type", Description = "Type of product (Product or Subscription)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Type { get; set; } + [ApiMember(Name = "StoreId", Description = "Store User Id (if needed)", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] + public string StoreId { get; set; } + [ApiMember(Name = "StoreToken", Description = "Unique ID for this purchase in the store", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string StoreToken { get; set; } + [ApiMember(Name = "Feature", Description = "Emby Feature Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Feature { get; set; } + [ApiMember(Name = "Email", Description = "Email address for purchase", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Email { get; set; } + [ApiMember(Name = "Amount", Description = "String representation of price (can have currency sign)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Amount { get; set; } + } + /// /// Class PluginsService /// @@ -265,6 +289,12 @@ namespace MediaBrowser.Api return ToOptimizedSerializedResultUsingCache(result); } + public async Task Post(RegisterAppstoreSale request) + { + var success = await _securityManager.RegisterAppStoreSale(request.Store, request.Application, request.Product, request.Type, request.StoreId, request.StoreToken, request.Email, request.Amount); + if (!success) throw new ApplicationException("Error registering store sale"); + } + /// /// Posts the specified request. /// diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index ec36132980..4880b326e0 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -18,6 +18,7 @@ namespace MediaBrowser.Common.Implementations.Security public class PluginSecurityManager : ISecurityManager { private const string MBValidateUrl = MbAdmin.HttpsUrl + "service/registration/validate"; + private const string AppstoreRegUrl = /*MbAdmin.HttpsUrl*/ "https://wwwm.mb3admin.com/test/admin/" + "service/appstore/register"; /// /// The _is MB supporter @@ -185,6 +186,44 @@ namespace MediaBrowser.Common.Implementations.Security } } + public async Task RegisterAppStoreSale(string store, string application, string product, + string type, string storeId, string storeToken, string email, string amt) + { + var data = new Dictionary() + { + {"store", store}, + {"application", application}, + {"product", product}, + {"type", type}, + {"storeId", storeId}, + {"token", storeToken}, + {"email", email}, + {"amt", amt} + }; + + try + { + using (var json = await _httpClient.Post(AppstoreRegUrl, data, CancellationToken.None).ConfigureAwait(false)) + { + var reg = _jsonSerializer.DeserializeFromStream(json); + if (!String.IsNullOrEmpty(reg.key)) + { + SupporterKey = reg.key; + } + + return true; + } + + } + catch (Exception e) + { + _logger.ErrorException("Error registering appstore purchase {0}", e, _jsonSerializer.SerializeToString(data)); + //TODO - really need to write this to a file so we can re-try it automatically + return false; + } + + } + private async Task GetRegistrationStatusInternal(string feature, string mb2Equivalent = null, string version = null) diff --git a/MediaBrowser.Common.Implementations/Security/RegRecord.cs b/MediaBrowser.Common.Implementations/Security/RegRecord.cs index f4e4337bfa..ece70b7726 100644 --- a/MediaBrowser.Common.Implementations/Security/RegRecord.cs +++ b/MediaBrowser.Common.Implementations/Security/RegRecord.cs @@ -7,5 +7,6 @@ namespace MediaBrowser.Common.Implementations.Security public string featId { get; set; } public bool registered { get; set; } public DateTime expDate { get; set; } + public string key { get; set; } } } \ No newline at end of file diff --git a/MediaBrowser.Common/Security/ISecurityManager.cs b/MediaBrowser.Common/Security/ISecurityManager.cs index 9354543532..17bd88b65f 100644 --- a/MediaBrowser.Common/Security/ISecurityManager.cs +++ b/MediaBrowser.Common/Security/ISecurityManager.cs @@ -1,3 +1,4 @@ +using System; using MediaBrowser.Model.Entities; using System.Threading.Tasks; @@ -40,6 +41,13 @@ namespace MediaBrowser.Common.Security /// Task LoadAllRegistrationInfo(); + /// + /// Register an appstore sale + /// + /// true if successful + Task RegisterAppStoreSale(string store, string application, string product, + string type, string storeId, string storeToken, string email, string amt); + /// /// Gets the supporter information. /// diff --git a/MediaBrowser.ServerApplication/App.config b/MediaBrowser.ServerApplication/App.config index 14ce35a965..709b6de926 100644 --- a/MediaBrowser.ServerApplication/App.config +++ b/MediaBrowser.ServerApplication/App.config @@ -12,7 +12,7 @@ - + -- cgit v1.2.3 From e761d8141833dabc076a3a0c5f41505452ae2e2a Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Sat, 26 Sep 2015 16:57:38 -0400 Subject: Fix test url --- MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index 4880b326e0..18a0cf856b 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Common.Implementations.Security public class PluginSecurityManager : ISecurityManager { private const string MBValidateUrl = MbAdmin.HttpsUrl + "service/registration/validate"; - private const string AppstoreRegUrl = /*MbAdmin.HttpsUrl*/ "https://wwwm.mb3admin.com/test/admin/" + "service/appstore/register"; + private const string AppstoreRegUrl = /*MbAdmin.HttpsUrl*/ "http://mb3admin.com/test/admin/" + "service/appstore/register"; /// /// The _is MB supporter -- cgit v1.2.3 From 33ab78155fd2442e275ec64a8390251fde1a139d Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Sat, 26 Sep 2015 17:14:13 -0400 Subject: Add missing param --- MediaBrowser.Api/PluginService.cs | 2 +- .../Security/PluginSecurityManager.cs | 12 ++++++++++-- MediaBrowser.Common/Security/ISecurityManager.cs | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index 224a88881b..1c81d8e259 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -291,7 +291,7 @@ namespace MediaBrowser.Api public async Task Post(RegisterAppstoreSale request) { - var success = await _securityManager.RegisterAppStoreSale(request.Store, request.Application, request.Product, request.Type, request.StoreId, request.StoreToken, request.Email, request.Amount); + var success = await _securityManager.RegisterAppStoreSale(request.Store, request.Application, request.Product, request.Feature, request.Type, request.StoreId, request.StoreToken, request.Email, request.Amount); if (!success) throw new ApplicationException("Error registering store sale"); } diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index 18a0cf856b..410611c8af 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -186,7 +186,7 @@ namespace MediaBrowser.Common.Implementations.Security } } - public async Task RegisterAppStoreSale(string store, string application, string product, + public async Task RegisterAppStoreSale(string store, string application, string product, string feature, string type, string storeId, string storeToken, string email, string amt) { var data = new Dictionary() @@ -194,6 +194,7 @@ namespace MediaBrowser.Common.Implementations.Security {"store", store}, {"application", application}, {"product", product}, + {"feature", feature}, {"type", type}, {"storeId", storeId}, {"token", storeToken}, @@ -201,9 +202,16 @@ namespace MediaBrowser.Common.Implementations.Security {"amt", amt} }; + var options = new HttpRequestOptions() + { + Url = AppstoreRegUrl, + CancellationToken = CancellationToken.None + }; + options.RequestHeaders.Add("X-Emby-Token", /*_appHost.SystemId*/ "08606E86D043"); + try { - using (var json = await _httpClient.Post(AppstoreRegUrl, data, CancellationToken.None).ConfigureAwait(false)) + using (var json = await _httpClient.Post(options, data).ConfigureAwait(false)) { var reg = _jsonSerializer.DeserializeFromStream(json); if (!String.IsNullOrEmpty(reg.key)) diff --git a/MediaBrowser.Common/Security/ISecurityManager.cs b/MediaBrowser.Common/Security/ISecurityManager.cs index 17bd88b65f..b82159aa6c 100644 --- a/MediaBrowser.Common/Security/ISecurityManager.cs +++ b/MediaBrowser.Common/Security/ISecurityManager.cs @@ -45,7 +45,7 @@ namespace MediaBrowser.Common.Security /// Register an appstore sale /// /// true if successful - Task RegisterAppStoreSale(string store, string application, string product, + Task RegisterAppStoreSale(string store, string application, string product, string feature, string type, string storeId, string storeToken, string email, string amt); /// -- cgit v1.2.3 From 9f138d86b1f1dd24d02cdf0a24148a280615a0fa Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Sun, 27 Sep 2015 12:45:53 -0400 Subject: Revert "Add missing param" This reverts commit 41715f145d1ff47b95d870ff8f224e778b25e695. --- MediaBrowser.Api/PluginService.cs | 2 +- .../Security/PluginSecurityManager.cs | 12 ++---------- MediaBrowser.Common/Security/ISecurityManager.cs | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index 1c81d8e259..224a88881b 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -291,7 +291,7 @@ namespace MediaBrowser.Api public async Task Post(RegisterAppstoreSale request) { - var success = await _securityManager.RegisterAppStoreSale(request.Store, request.Application, request.Product, request.Feature, request.Type, request.StoreId, request.StoreToken, request.Email, request.Amount); + var success = await _securityManager.RegisterAppStoreSale(request.Store, request.Application, request.Product, request.Type, request.StoreId, request.StoreToken, request.Email, request.Amount); if (!success) throw new ApplicationException("Error registering store sale"); } diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index 410611c8af..18a0cf856b 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -186,7 +186,7 @@ namespace MediaBrowser.Common.Implementations.Security } } - public async Task RegisterAppStoreSale(string store, string application, string product, string feature, + public async Task RegisterAppStoreSale(string store, string application, string product, string type, string storeId, string storeToken, string email, string amt) { var data = new Dictionary() @@ -194,7 +194,6 @@ namespace MediaBrowser.Common.Implementations.Security {"store", store}, {"application", application}, {"product", product}, - {"feature", feature}, {"type", type}, {"storeId", storeId}, {"token", storeToken}, @@ -202,16 +201,9 @@ namespace MediaBrowser.Common.Implementations.Security {"amt", amt} }; - var options = new HttpRequestOptions() - { - Url = AppstoreRegUrl, - CancellationToken = CancellationToken.None - }; - options.RequestHeaders.Add("X-Emby-Token", /*_appHost.SystemId*/ "08606E86D043"); - try { - using (var json = await _httpClient.Post(options, data).ConfigureAwait(false)) + using (var json = await _httpClient.Post(AppstoreRegUrl, data, CancellationToken.None).ConfigureAwait(false)) { var reg = _jsonSerializer.DeserializeFromStream(json); if (!String.IsNullOrEmpty(reg.key)) diff --git a/MediaBrowser.Common/Security/ISecurityManager.cs b/MediaBrowser.Common/Security/ISecurityManager.cs index b82159aa6c..17bd88b65f 100644 --- a/MediaBrowser.Common/Security/ISecurityManager.cs +++ b/MediaBrowser.Common/Security/ISecurityManager.cs @@ -45,7 +45,7 @@ namespace MediaBrowser.Common.Security /// Register an appstore sale /// /// true if successful - Task RegisterAppStoreSale(string store, string application, string product, string feature, + Task RegisterAppStoreSale(string store, string application, string product, string type, string storeId, string storeToken, string email, string amt); /// -- cgit v1.2.3 From d330ec997a5efd46374e320425be4c83e9e8f517 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Sun, 27 Sep 2015 12:46:01 -0400 Subject: Revert "Fix test url" This reverts commit 5ddc439ac02ad270e219769654572b71b9c9b8fe. --- MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index 18a0cf856b..4880b326e0 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Common.Implementations.Security public class PluginSecurityManager : ISecurityManager { private const string MBValidateUrl = MbAdmin.HttpsUrl + "service/registration/validate"; - private const string AppstoreRegUrl = /*MbAdmin.HttpsUrl*/ "http://mb3admin.com/test/admin/" + "service/appstore/register"; + private const string AppstoreRegUrl = /*MbAdmin.HttpsUrl*/ "https://wwwm.mb3admin.com/test/admin/" + "service/appstore/register"; /// /// The _is MB supporter -- cgit v1.2.3 From 8146361ac766dced749c324d058f05fc3811c108 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Sun, 27 Sep 2015 12:46:15 -0400 Subject: Revert "Add store registration endpoint (pointing to test)" This reverts commit 42ddf1cd86b5a5b50f8023e492ce6d7fcadc0fe1. --- MediaBrowser.Api/PluginService.cs | 30 ----------------- .../Security/PluginSecurityManager.cs | 39 ---------------------- .../Security/RegRecord.cs | 1 - MediaBrowser.Common/Security/ISecurityManager.cs | 8 ----- 4 files changed, 78 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index 224a88881b..eb49914eb1 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -118,30 +118,6 @@ namespace MediaBrowser.Api public string Name { get; set; } } - [Route("/Appstore/Register", "POST", Summary = "Registers an appstore sale")] - [Authenticated] - public class RegisterAppstoreSale - { - [ApiMember(Name = "Store", Description = "Store Name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Store { get; set; } - [ApiMember(Name = "Application", Description = "Application id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Application { get; set; } - [ApiMember(Name = "Product", Description = "Product id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Product { get; set; } - [ApiMember(Name = "Type", Description = "Type of product (Product or Subscription)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Type { get; set; } - [ApiMember(Name = "StoreId", Description = "Store User Id (if needed)", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] - public string StoreId { get; set; } - [ApiMember(Name = "StoreToken", Description = "Unique ID for this purchase in the store", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string StoreToken { get; set; } - [ApiMember(Name = "Feature", Description = "Emby Feature Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Feature { get; set; } - [ApiMember(Name = "Email", Description = "Email address for purchase", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Email { get; set; } - [ApiMember(Name = "Amount", Description = "String representation of price (can have currency sign)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Amount { get; set; } - } - /// /// Class PluginsService /// @@ -289,12 +265,6 @@ namespace MediaBrowser.Api return ToOptimizedSerializedResultUsingCache(result); } - public async Task Post(RegisterAppstoreSale request) - { - var success = await _securityManager.RegisterAppStoreSale(request.Store, request.Application, request.Product, request.Type, request.StoreId, request.StoreToken, request.Email, request.Amount); - if (!success) throw new ApplicationException("Error registering store sale"); - } - /// /// Posts the specified request. /// diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index 4880b326e0..ec36132980 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -18,7 +18,6 @@ namespace MediaBrowser.Common.Implementations.Security public class PluginSecurityManager : ISecurityManager { private const string MBValidateUrl = MbAdmin.HttpsUrl + "service/registration/validate"; - private const string AppstoreRegUrl = /*MbAdmin.HttpsUrl*/ "https://wwwm.mb3admin.com/test/admin/" + "service/appstore/register"; /// /// The _is MB supporter @@ -186,44 +185,6 @@ namespace MediaBrowser.Common.Implementations.Security } } - public async Task RegisterAppStoreSale(string store, string application, string product, - string type, string storeId, string storeToken, string email, string amt) - { - var data = new Dictionary() - { - {"store", store}, - {"application", application}, - {"product", product}, - {"type", type}, - {"storeId", storeId}, - {"token", storeToken}, - {"email", email}, - {"amt", amt} - }; - - try - { - using (var json = await _httpClient.Post(AppstoreRegUrl, data, CancellationToken.None).ConfigureAwait(false)) - { - var reg = _jsonSerializer.DeserializeFromStream(json); - if (!String.IsNullOrEmpty(reg.key)) - { - SupporterKey = reg.key; - } - - return true; - } - - } - catch (Exception e) - { - _logger.ErrorException("Error registering appstore purchase {0}", e, _jsonSerializer.SerializeToString(data)); - //TODO - really need to write this to a file so we can re-try it automatically - return false; - } - - } - private async Task GetRegistrationStatusInternal(string feature, string mb2Equivalent = null, string version = null) diff --git a/MediaBrowser.Common.Implementations/Security/RegRecord.cs b/MediaBrowser.Common.Implementations/Security/RegRecord.cs index ece70b7726..f4e4337bfa 100644 --- a/MediaBrowser.Common.Implementations/Security/RegRecord.cs +++ b/MediaBrowser.Common.Implementations/Security/RegRecord.cs @@ -7,6 +7,5 @@ namespace MediaBrowser.Common.Implementations.Security public string featId { get; set; } public bool registered { get; set; } public DateTime expDate { get; set; } - public string key { get; set; } } } \ No newline at end of file diff --git a/MediaBrowser.Common/Security/ISecurityManager.cs b/MediaBrowser.Common/Security/ISecurityManager.cs index 17bd88b65f..9354543532 100644 --- a/MediaBrowser.Common/Security/ISecurityManager.cs +++ b/MediaBrowser.Common/Security/ISecurityManager.cs @@ -1,4 +1,3 @@ -using System; using MediaBrowser.Model.Entities; using System.Threading.Tasks; @@ -41,13 +40,6 @@ namespace MediaBrowser.Common.Security /// Task LoadAllRegistrationInfo(); - /// - /// Register an appstore sale - /// - /// true if successful - Task RegisterAppStoreSale(string store, string application, string product, - string type, string storeId, string storeToken, string email, string amt); - /// /// Gets the supporter information. /// -- cgit v1.2.3 From 8809b76a4f2b932f2e7255517e0ae4cd6088e42b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 30 Sep 2015 00:13:48 -0400 Subject: 3.0.5724.6 --- .../Security/PluginSecurityManager.cs | 2 +- .../MediaInfo/FFProbeVideoInfo.cs | 6 ++-- MediaBrowser.ServerApplication/MainStartup.cs | 2 +- MediaBrowser.ServerApplication/ServerNotifyIcon.cs | 41 ++++++++++++++++++++++ SharedVersion.cs | 4 +-- 5 files changed, 48 insertions(+), 7 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index ec36132980..c2725e9bf6 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -274,4 +274,4 @@ namespace MediaBrowser.Common.Implementations.Security _isMbSupporterInitialized = false; } } -} +} \ No newline at end of file diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 05756bba2d..9725d7b06c 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -190,8 +190,8 @@ namespace MediaBrowser.Providers.MediaInfo var mediaStreams = mediaInfo.MediaStreams; video.TotalBitrate = mediaInfo.Bitrate; - //video.FormatName = (mediaInfo.Container ?? string.Empty) - // .Replace("matroska", "mkv", StringComparison.OrdinalIgnoreCase); + video.FormatName = (mediaInfo.Container ?? string.Empty) + .Replace("matroska", "mkv", StringComparison.OrdinalIgnoreCase); // For dvd's this may not always be accurate, so don't set the runtime if the item already has one var needToSetRuntime = video.VideoType != VideoType.Dvd || video.RunTimeTicks == null || video.RunTimeTicks.Value == 0; @@ -707,7 +707,7 @@ namespace MediaBrowser.Providers.MediaInfo // Try to eliminate menus and intros by skipping all files at the front of the list that are less than the minimum size // Once we reach a file that is at least the minimum, return all subsequent ones - var allVobs = _fileSystem.GetFiles(root) + var allVobs = new DirectoryInfo(root).EnumerateFiles("*", SearchOption.AllDirectories) .Where(file => string.Equals(file.Extension, ".vob", StringComparison.OrdinalIgnoreCase)) .OrderBy(i => i.FullName) .ToList(); diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 80b7d230ab..d7b8b2aed4 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -214,7 +214,7 @@ namespace MediaBrowser.ServerApplication fileSystem, "MBServer", nativeApp); - + var initProgress = new Progress(); if (!runService) diff --git a/MediaBrowser.ServerApplication/ServerNotifyIcon.cs b/MediaBrowser.ServerApplication/ServerNotifyIcon.cs index dd9e5d5f00..ad0bd8a1af 100644 --- a/MediaBrowser.ServerApplication/ServerNotifyIcon.cs +++ b/MediaBrowser.ServerApplication/ServerNotifyIcon.cs @@ -21,6 +21,9 @@ namespace MediaBrowser.ServerApplication private ToolStripMenuItem cmdRestart; private ToolStripSeparator toolStripSeparator1; private ToolStripMenuItem cmdCommunity; + private ToolStripMenuItem cmdApiDocs; + private ToolStripMenuItem cmdSwagger; + private ToolStripMenuItem cmdGtihub; private readonly ILogger _logger; private readonly IServerApplicationHost _appHost; @@ -63,6 +66,9 @@ namespace MediaBrowser.ServerApplication toolStripSeparator2 = new ToolStripSeparator(); cmdConfigure = new ToolStripMenuItem(); cmdBrowse = new ToolStripMenuItem(); + cmdApiDocs = new ToolStripMenuItem(); + cmdSwagger = new ToolStripMenuItem(); + cmdGtihub = new ToolStripMenuItem(); // // notifyIcon1 @@ -80,6 +86,7 @@ namespace MediaBrowser.ServerApplication toolStripSeparator2, cmdRestart, toolStripSeparator1, + cmdApiDocs, cmdCommunity, cmdExit}); contextMenuStrip1.Name = "contextMenuStrip1"; @@ -121,6 +128,24 @@ namespace MediaBrowser.ServerApplication // cmdBrowse.Name = "cmdBrowse"; cmdBrowse.Size = new System.Drawing.Size(208, 22); + // + // cmdApiDocs + // + cmdApiDocs.DropDownItems.AddRange(new ToolStripItem[] { + cmdSwagger, + cmdGtihub}); + cmdApiDocs.Name = "cmdApiDocs"; + cmdApiDocs.Size = new System.Drawing.Size(208, 22); + // + // cmdSwagger + // + cmdSwagger.Name = "cmdSwagger"; + cmdSwagger.Size = new System.Drawing.Size(136, 22); + // + // cmdGtihub + // + cmdGtihub.Name = "cmdGtihub"; + cmdGtihub.Size = new System.Drawing.Size(136, 22); cmdExit.Click += cmdExit_Click; cmdRestart.Click += cmdRestart_Click; @@ -128,6 +153,9 @@ namespace MediaBrowser.ServerApplication cmdCommunity.Click += cmdCommunity_Click; cmdBrowse.Click += cmdBrowse_Click; + cmdSwagger.Click += cmdSwagger_Click; + cmdGtihub.Click += cmdGtihub_Click; + _configurationManager.ConfigurationUpdated += Instance_ConfigurationUpdated; LocalizeText(); @@ -166,6 +194,9 @@ namespace MediaBrowser.ServerApplication cmdExit.Text = _localization.GetLocalizedString("LabelExit"); cmdCommunity.Text = _localization.GetLocalizedString("LabelVisitCommunity"); + cmdGtihub.Text = _localization.GetLocalizedString("LabelGithub"); + cmdSwagger.Text = _localization.GetLocalizedString("LabelApiDocumentation"); + cmdApiDocs.Text = _localization.GetLocalizedString("LabelDeveloperResources"); cmdBrowse.Text = _localization.GetLocalizedString("LabelBrowseLibrary"); cmdConfigure.Text = _localization.GetLocalizedString("LabelConfigureServer"); cmdRestart.Text = _localization.GetLocalizedString("LabelRestartServer"); @@ -211,6 +242,16 @@ namespace MediaBrowser.ServerApplication _appHost.Shutdown(); } + void cmdGtihub_Click(object sender, EventArgs e) + { + BrowserLauncher.OpenGithub(_logger); + } + + void cmdSwagger_Click(object sender, EventArgs e) + { + BrowserLauncher.OpenSwagger(_appHost, _logger); + } + ~ServerNotifyIcon() { Dispose(); diff --git a/SharedVersion.cs b/SharedVersion.cs index 5b09ef0841..30ce35ee17 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("3.0.*")] -//[assembly: AssemblyVersion("3.0.5724.5")] +//[assembly: AssemblyVersion("3.0.*")] +[assembly: AssemblyVersion("3.0.5724.6")] -- cgit v1.2.3 From 0ed2fed529102eaf4b644c65aaa28ef9edcdf89b Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Fri, 16 Oct 2015 10:29:02 -0400 Subject: Restore appstore registration end point --- MediaBrowser.Api/PluginService.cs | 35 +++++++++++++ .../Security/PluginSecurityManager.cs | 61 ++++++++++++++++++++++ .../Security/RegRecord.cs | 1 + MediaBrowser.Common/Security/ISecurityManager.cs | 17 ++++++ 4 files changed, 114 insertions(+) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index eb49914eb1..c1d29681c6 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -118,6 +118,30 @@ namespace MediaBrowser.Api public string Name { get; set; } } + [Route("/Appstore/Register", "POST", Summary = "Registers an appstore sale")] + [Authenticated] + public class RegisterAppstoreSale + { + [ApiMember(Name = "Store", Description = "Store Name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Store { get; set; } + [ApiMember(Name = "Application", Description = "Application id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Application { get; set; } + [ApiMember(Name = "Product", Description = "Product id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Product { get; set; } + [ApiMember(Name = "Type", Description = "Type of product (Product or Subscription)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Type { get; set; } + [ApiMember(Name = "StoreId", Description = "Store User Id (if needed)", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] + public string StoreId { get; set; } + [ApiMember(Name = "StoreToken", Description = "Unique ID for this purchase in the store", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string StoreToken { get; set; } + [ApiMember(Name = "Feature", Description = "Emby Feature Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Feature { get; set; } + [ApiMember(Name = "Email", Description = "Email address for purchase", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Email { get; set; } + [ApiMember(Name = "Amount", Description = "String representation of price (can have currency sign)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Amount { get; set; } + } + /// /// Class PluginsService /// @@ -265,6 +289,17 @@ namespace MediaBrowser.Api return ToOptimizedSerializedResultUsingCache(result); } + /// + /// Post app store sale + /// + /// + /// + public async Task Post(RegisterAppstoreSale request) + { + var success = await _securityManager.RegisterAppStoreSale(request.Store, request.Application, request.Product, request.Feature, request.Type, request.StoreId, request.StoreToken, request.Email, request.Amount); + if (!success) throw new ApplicationException("Error registering store sale"); + } + /// /// Posts the specified request. /// diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index c2725e9bf6..861d638f2c 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -18,6 +18,7 @@ namespace MediaBrowser.Common.Implementations.Security public class PluginSecurityManager : ISecurityManager { private const string MBValidateUrl = MbAdmin.HttpsUrl + "service/registration/validate"; + private const string AppstoreRegUrl = /*MbAdmin.HttpsUrl*/ "http://mb3admin.com/test/admin/" + "service/appstore/register"; /// /// The _is MB supporter @@ -185,6 +186,66 @@ namespace MediaBrowser.Common.Implementations.Security } } + /// + /// Register an app store sale with our back-end. It will validate the transaction with the store + /// and then register the proper feature and then fill in the supporter key on success. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// true if successful + public async Task RegisterAppStoreSale(string store, string application, string product, string feature, + string type, string storeId, string storeToken, string email, string amt) + { + var data = new Dictionary() + { + {"store", store}, + {"application", application}, + {"product", product}, + {"feature", feature}, + {"type", type}, + {"storeId", storeId}, + {"token", storeToken}, + {"email", email}, + {"amt", amt} + }; + + var options = new HttpRequestOptions() + { + Url = AppstoreRegUrl, + CancellationToken = CancellationToken.None + }; + options.RequestHeaders.Add("X-Emby-Token", /*_appHost.SystemId*/ "08606E86D043"); + + try + { + using (var json = await _httpClient.Post(options, data).ConfigureAwait(false)) + { + var reg = _jsonSerializer.DeserializeFromStream(json); + if (!String.IsNullOrEmpty(reg.key)) + { + SupporterKey = reg.key; + } + + return true; + } + + } + catch (Exception e) + { + _logger.ErrorException("Error registering appstore purchase {0}", e, _jsonSerializer.SerializeToString(data)); + //TODO - really need to write this to a file so we can re-try it automatically + return false; + } + + } + private async Task GetRegistrationStatusInternal(string feature, string mb2Equivalent = null, string version = null) diff --git a/MediaBrowser.Common.Implementations/Security/RegRecord.cs b/MediaBrowser.Common.Implementations/Security/RegRecord.cs index f4e4337bfa..ece70b7726 100644 --- a/MediaBrowser.Common.Implementations/Security/RegRecord.cs +++ b/MediaBrowser.Common.Implementations/Security/RegRecord.cs @@ -7,5 +7,6 @@ namespace MediaBrowser.Common.Implementations.Security public string featId { get; set; } public bool registered { get; set; } public DateTime expDate { get; set; } + public string key { get; set; } } } \ No newline at end of file diff --git a/MediaBrowser.Common/Security/ISecurityManager.cs b/MediaBrowser.Common/Security/ISecurityManager.cs index 9354543532..5d15808da5 100644 --- a/MediaBrowser.Common/Security/ISecurityManager.cs +++ b/MediaBrowser.Common/Security/ISecurityManager.cs @@ -1,3 +1,4 @@ +using System; using MediaBrowser.Model.Entities; using System.Threading.Tasks; @@ -45,5 +46,21 @@ namespace MediaBrowser.Common.Security /// /// Task<SupporterInfo>. Task GetSupporterInfo(); + + /// + /// Register and app store sale with our back-end + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// true if successful + Task RegisterAppStoreSale(string store, string application, string product, string feature, + string type, string storeId, string storeToken, string email, string amt); } } \ No newline at end of file -- cgit v1.2.3 From cd42bce822453e4860430989de5b75f379c11e6b Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Fri, 16 Oct 2015 10:54:53 -0400 Subject: Move exception to SecurityManager --- MediaBrowser.Api/PluginService.cs | 3 +-- .../Security/PluginSecurityManager.cs | 7 ++----- MediaBrowser.Common/Security/ISecurityManager.cs | 3 +-- 3 files changed, 4 insertions(+), 9 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index c1d29681c6..dc3d103eb5 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -296,8 +296,7 @@ namespace MediaBrowser.Api /// public async Task Post(RegisterAppstoreSale request) { - var success = await _securityManager.RegisterAppStoreSale(request.Store, request.Application, request.Product, request.Feature, request.Type, request.StoreId, request.StoreToken, request.Email, request.Amount); - if (!success) throw new ApplicationException("Error registering store sale"); + await _securityManager.RegisterAppStoreSale(request.Store, request.Application, request.Product, request.Feature, request.Type, request.StoreId, request.StoreToken, request.Email, request.Amount); } /// diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index 861d638f2c..facaaeff9b 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -199,8 +199,7 @@ namespace MediaBrowser.Common.Implementations.Security /// /// /// - /// true if successful - public async Task RegisterAppStoreSale(string store, string application, string product, string feature, + public async Task RegisterAppStoreSale(string store, string application, string product, string feature, string type, string storeId, string storeToken, string email, string amt) { var data = new Dictionary() @@ -232,8 +231,6 @@ namespace MediaBrowser.Common.Implementations.Security { SupporterKey = reg.key; } - - return true; } } @@ -241,7 +238,7 @@ namespace MediaBrowser.Common.Implementations.Security { _logger.ErrorException("Error registering appstore purchase {0}", e, _jsonSerializer.SerializeToString(data)); //TODO - really need to write this to a file so we can re-try it automatically - return false; + throw new ApplicationException("Error registering store sale"); } } diff --git a/MediaBrowser.Common/Security/ISecurityManager.cs b/MediaBrowser.Common/Security/ISecurityManager.cs index 5d15808da5..1b2e22a78c 100644 --- a/MediaBrowser.Common/Security/ISecurityManager.cs +++ b/MediaBrowser.Common/Security/ISecurityManager.cs @@ -59,8 +59,7 @@ namespace MediaBrowser.Common.Security /// /// /// - /// true if successful - Task RegisterAppStoreSale(string store, string application, string product, string feature, + Task RegisterAppStoreSale(string store, string application, string product, string feature, string type, string storeId, string storeToken, string email, string amt); } } \ No newline at end of file -- cgit v1.2.3 From 5d74fcbb87e20fb1a52b6ad2650ced97e8ad12e7 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Fri, 16 Oct 2015 13:53:49 -0400 Subject: Re-work appstore registration to pass-thru parameters --- MediaBrowser.Api/PluginService.cs | 22 ++------------ .../Security/PluginSecurityManager.cs | 34 +++++----------------- MediaBrowser.Common/Security/ISecurityManager.cs | 13 ++------- 3 files changed, 12 insertions(+), 57 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index dc3d103eb5..a7fd14bf07 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -122,24 +122,8 @@ namespace MediaBrowser.Api [Authenticated] public class RegisterAppstoreSale { - [ApiMember(Name = "Store", Description = "Store Name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Store { get; set; } - [ApiMember(Name = "Application", Description = "Application id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Application { get; set; } - [ApiMember(Name = "Product", Description = "Product id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Product { get; set; } - [ApiMember(Name = "Type", Description = "Type of product (Product or Subscription)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Type { get; set; } - [ApiMember(Name = "StoreId", Description = "Store User Id (if needed)", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] - public string StoreId { get; set; } - [ApiMember(Name = "StoreToken", Description = "Unique ID for this purchase in the store", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string StoreToken { get; set; } - [ApiMember(Name = "Feature", Description = "Emby Feature Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Feature { get; set; } - [ApiMember(Name = "Email", Description = "Email address for purchase", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Email { get; set; } - [ApiMember(Name = "Amount", Description = "String representation of price (can have currency sign)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Amount { get; set; } + [ApiMember(Name = "Parameters", Description = "Java representation of parameters to pass through to admin server", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string Parameters { get; set; } } /// @@ -296,7 +280,7 @@ namespace MediaBrowser.Api /// public async Task Post(RegisterAppstoreSale request) { - await _securityManager.RegisterAppStoreSale(request.Store, request.Application, request.Product, request.Feature, request.Type, request.StoreId, request.StoreToken, request.Email, request.Amount); + await _securityManager.RegisterAppStoreSale(request.Parameters); } /// diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index facaaeff9b..d953012f10 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -190,43 +190,23 @@ namespace MediaBrowser.Common.Implementations.Security /// Register an app store sale with our back-end. It will validate the transaction with the store /// and then register the proper feature and then fill in the supporter key on success. /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public async Task RegisterAppStoreSale(string store, string application, string product, string feature, - string type, string storeId, string storeToken, string email, string amt) + /// Json parameters to send to admin server + public async Task RegisterAppStoreSale(string parameters) { - var data = new Dictionary() - { - {"store", store}, - {"application", application}, - {"product", product}, - {"feature", feature}, - {"type", type}, - {"storeId", storeId}, - {"token", storeToken}, - {"email", email}, - {"amt", amt} - }; - var options = new HttpRequestOptions() { Url = AppstoreRegUrl, CancellationToken = CancellationToken.None }; options.RequestHeaders.Add("X-Emby-Token", /*_appHost.SystemId*/ "08606E86D043"); + options.RequestContent = parameters; + options.RequestContentType = "application/json"; try { - using (var json = await _httpClient.Post(options, data).ConfigureAwait(false)) + using (var response = await _httpClient.Post(options).ConfigureAwait(false)) { - var reg = _jsonSerializer.DeserializeFromStream(json); + var reg = _jsonSerializer.DeserializeFromStream(response.Content); if (!String.IsNullOrEmpty(reg.key)) { SupporterKey = reg.key; @@ -236,7 +216,7 @@ namespace MediaBrowser.Common.Implementations.Security } catch (Exception e) { - _logger.ErrorException("Error registering appstore purchase {0}", e, _jsonSerializer.SerializeToString(data)); + _logger.ErrorException("Error registering appstore purchase {0}", e, parameters); //TODO - really need to write this to a file so we can re-try it automatically throw new ApplicationException("Error registering store sale"); } diff --git a/MediaBrowser.Common/Security/ISecurityManager.cs b/MediaBrowser.Common/Security/ISecurityManager.cs index 1b2e22a78c..729de911b7 100644 --- a/MediaBrowser.Common/Security/ISecurityManager.cs +++ b/MediaBrowser.Common/Security/ISecurityManager.cs @@ -50,16 +50,7 @@ namespace MediaBrowser.Common.Security /// /// Register and app store sale with our back-end /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - Task RegisterAppStoreSale(string store, string application, string product, string feature, - string type, string storeId, string storeToken, string email, string amt); + /// Json parameters to pass to admin server + Task RegisterAppStoreSale(string parameters); } } \ No newline at end of file -- cgit v1.2.3 From 1261f51412fe6c3ddab12f615026b2c4ecc4b62b Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Fri, 16 Oct 2015 18:36:34 -0400 Subject: Avoid null ref in logger --- MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index d953012f10..6cb9161bce 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -216,7 +216,7 @@ namespace MediaBrowser.Common.Implementations.Security } catch (Exception e) { - _logger.ErrorException("Error registering appstore purchase {0}", e, parameters); + _logger.ErrorException("Error registering appstore purchase {0}", e, parameters ?? "NO PARMS SENT"); //TODO - really need to write this to a file so we can re-try it automatically throw new ApplicationException("Error registering store sale"); } -- cgit v1.2.3 From eb106a9d797ac04213c5d092a0489cb267f5bd78 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Tue, 20 Oct 2015 16:37:22 -0400 Subject: Save transaction data on error --- .../Security/PluginSecurityManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index 6cb9161bce..28c3bbb7be 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Configuration; +using System.IO; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Net; using MediaBrowser.Common.Security; using MediaBrowser.Model.Entities; @@ -217,7 +218,9 @@ namespace MediaBrowser.Common.Implementations.Security catch (Exception e) { _logger.ErrorException("Error registering appstore purchase {0}", e, parameters ?? "NO PARMS SENT"); - //TODO - really need to write this to a file so we can re-try it automatically + //Save all transaction information to a file + File.WriteAllText(Path.Combine(_appPaths.ProgramDataPath, "apptrans-error.txt"), parameters); + //TODO - could create a re-try routine on start-up if this file is there. For now we can handle manually. throw new ApplicationException("Error registering store sale"); } -- cgit v1.2.3 From 11c5bd4a74a3e2bb9eeb10157fd80da5e9f8c7af Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 23 Oct 2015 12:04:33 -0400 Subject: update mouse handler --- .../Security/PluginSecurityManager.cs | 6 ++++++ MediaBrowser.Controller/Entities/TV/Episode.cs | 11 +++++++++-- MediaBrowser.Providers/Manager/MetadataService.cs | 15 ++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index 28c3bbb7be..e3a00efb5b 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -208,6 +208,12 @@ namespace MediaBrowser.Common.Implementations.Security using (var response = await _httpClient.Post(options).ConfigureAwait(false)) { var reg = _jsonSerializer.DeserializeFromStream(response.Content); + + if (reg == null) + { + _logger.Warn("Result from appstore registration was null. Defaulting to empty."); + reg = new RegRecord(); + } if (!String.IsNullOrEmpty(reg.key)) { SupporterKey = reg.key; diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 5163c3de4a..92ca9e9703 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -296,9 +296,16 @@ namespace MediaBrowser.Controller.Entities.TV { var hasChanges = base.BeforeMetadataRefresh(); - if (LibraryManager.FillMissingEpisodeNumbersFromPath(this)) + try { - hasChanges = true; + if (LibraryManager.FillMissingEpisodeNumbersFromPath(this)) + { + hasChanges = true; + } + } + catch (Exception ex) + { + Logger.ErrorException("Error in FillMissingEpisodeNumbersFromPath. Episode: {0}", ex, Path ?? Name ?? Id.ToString()); } return hasChanges; diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 1dc29cdde2..6860aeff32 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -144,7 +144,8 @@ namespace MediaBrowser.Providers.Manager if (providers.Count > 0) { var id = itemOfType.GetLookupInfo(); - await ItemIdentifier.FindIdentities(id, ProviderManager, cancellationToken); + + await FindIdentities(id, cancellationToken).ConfigureAwait(false); var result = await RefreshWithProviders(metadataResult, id, refreshOptions, providers, itemImageProvider, cancellationToken).ConfigureAwait(false); @@ -216,6 +217,18 @@ namespace MediaBrowser.Providers.Manager return updateType; } + private async Task FindIdentities(TIdType id, CancellationToken cancellationToken) + { + try + { + await ItemIdentifier.FindIdentities(id, ProviderManager, cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) + { + Logger.ErrorException("Error in FindIdentities", ex); + } + } + private DateTime GetLastRefreshDate(IHasMetadata item) { if (item.DateLastRefreshed != default(DateTime)) -- cgit v1.2.3 From b6f019b7f2d16d5c3ba4e51a4f7cd6f58b877c0a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 23 Oct 2015 13:58:03 -0400 Subject: update store exception --- .../Security/PluginSecurityManager.cs | 27 ++++++++++++++++++---- SharedVersion.cs | 4 ++-- 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index e3a00efb5b..ae3c43d7e7 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -211,8 +211,9 @@ namespace MediaBrowser.Common.Implementations.Security if (reg == null) { - _logger.Warn("Result from appstore registration was null. Defaulting to empty."); - reg = new RegRecord(); + var msg = "Result from appstore registration was null."; + _logger.Error(msg); + throw new ApplicationException(msg); } if (!String.IsNullOrEmpty(reg.key)) { @@ -221,17 +222,35 @@ namespace MediaBrowser.Common.Implementations.Security } } + catch (ApplicationException) + { + SaveAppStoreInfo(parameters); + throw; + } catch (Exception e) { _logger.ErrorException("Error registering appstore purchase {0}", e, parameters ?? "NO PARMS SENT"); - //Save all transaction information to a file - File.WriteAllText(Path.Combine(_appPaths.ProgramDataPath, "apptrans-error.txt"), parameters); + SaveAppStoreInfo(parameters); //TODO - could create a re-try routine on start-up if this file is there. For now we can handle manually. throw new ApplicationException("Error registering store sale"); } } + private void SaveAppStoreInfo(string info) + { + // Save all transaction information to a file + + try + { + File.WriteAllText(Path.Combine(_appPaths.ProgramDataPath, "apptrans-error.txt"), info); + } + catch (IOException) + { + + } + } + private async Task GetRegistrationStatusInternal(string feature, string mb2Equivalent = null, string version = null) diff --git a/SharedVersion.cs b/SharedVersion.cs index 8ac45ca4eb..ab168e6eaf 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; -//[assembly: AssemblyVersion("3.0.*")] -[assembly: AssemblyVersion("3.0.5768.5")] +[assembly: AssemblyVersion("3.0.*")] +//[assembly: AssemblyVersion("3.0.5768.5")] -- cgit v1.2.3 From 492f897f818abc1a1eee0352864ce4c06de4de1c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 25 Oct 2015 11:48:44 -0400 Subject: 3.0.5768.6 --- .../ScheduledTasks/ScheduledTaskWorker.cs | 6 +++++- .../ScheduledTasks/TaskManager.cs | 25 +++++++++++++++++++++- .../Security/PluginSecurityManager.cs | 4 ++-- .../ScheduledTasks/IScheduledTaskWorker.cs | 5 +++++ Nuget/MediaBrowser.Common.Internal.nuspec | 4 ++-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Model.Signed.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- SharedVersion.cs | 4 ++-- 9 files changed, 44 insertions(+), 12 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index 52612c4c11..95f29915db 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -13,7 +13,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using CommonIO; -using MediaBrowser.Common.IO; namespace MediaBrowser.Common.Implementations.ScheduledTasks { @@ -304,6 +303,11 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks } } + public void ReloadTriggerEvents() + { + ReloadTriggerEvents(false); + } + /// /// Reloads the trigger events. /// diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs index 6c72441aa8..845c984fb7 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs @@ -12,6 +12,7 @@ using System.Linq; using System.Threading.Tasks; using CommonIO; using MediaBrowser.Common.IO; +using Microsoft.Win32; namespace MediaBrowser.Common.Implementations.ScheduledTasks { @@ -69,6 +70,28 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks _fileSystem = fileSystem; ScheduledTasks = new IScheduledTaskWorker[] { }; + + BindToSystemEvent(); + } + + private void BindToSystemEvent() + { + try + { + SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; + } + catch + { + + } + } + + void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e) + { + foreach (var task in ScheduledTasks) + { + task.ReloadTriggerEvents(); + } } /// @@ -127,7 +150,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks { QueueScheduledTask(new TaskExecutionOptions()); } - + /// /// Queues the scheduled task. /// diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index ae3c43d7e7..e36ff99501 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -19,7 +19,7 @@ namespace MediaBrowser.Common.Implementations.Security public class PluginSecurityManager : ISecurityManager { private const string MBValidateUrl = MbAdmin.HttpsUrl + "service/registration/validate"; - private const string AppstoreRegUrl = /*MbAdmin.HttpsUrl*/ "http://mb3admin.com/test/admin/" + "service/appstore/register"; + private const string AppstoreRegUrl = /*MbAdmin.HttpsUrl*/ "http://mb3admin.com/admin/" + "service/appstore/register"; /// /// The _is MB supporter @@ -199,7 +199,7 @@ namespace MediaBrowser.Common.Implementations.Security Url = AppstoreRegUrl, CancellationToken = CancellationToken.None }; - options.RequestHeaders.Add("X-Emby-Token", /*_appHost.SystemId*/ "08606E86D043"); + options.RequestHeaders.Add("X-Emby-Token", _appHost.SystemId); options.RequestContent = parameters; options.RequestContentType = "application/json"; diff --git a/MediaBrowser.Common/ScheduledTasks/IScheduledTaskWorker.cs b/MediaBrowser.Common/ScheduledTasks/IScheduledTaskWorker.cs index f50bd9e76e..0b9a5e276a 100644 --- a/MediaBrowser.Common/ScheduledTasks/IScheduledTaskWorker.cs +++ b/MediaBrowser.Common/ScheduledTasks/IScheduledTaskWorker.cs @@ -69,5 +69,10 @@ namespace MediaBrowser.Common.ScheduledTasks /// /// The unique id. string Id { get; } + + /// + /// Reloads the trigger events. + /// + void ReloadTriggerEvents(); } } \ No newline at end of file diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 1c14f95446..8fa5b665d5 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.637 + 3.0.638 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Emby Theater and Emby Server. Not intended for plugin developer consumption. Copyright © Emby 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 166ece453f..cec3f63d50 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.637 + 3.0.638 MediaBrowser.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index 33a0c5edff..6f778882ad 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.637 + 3.0.638 MediaBrowser.Model - Signed Edition Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 53476dc1f6..b6edd8719e 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.637 + 3.0.638 Media Browser.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - + diff --git a/SharedVersion.cs b/SharedVersion.cs index ab168e6eaf..b826a98f10 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("3.0.*")] -//[assembly: AssemblyVersion("3.0.5768.5")] +//[assembly: AssemblyVersion("3.0.*")] +[assembly: AssemblyVersion("3.0.5768.6")] -- cgit v1.2.3 From c99d6c89971b34ac85852f0068f113bb49a25b22 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 25 Oct 2015 14:16:36 -0400 Subject: add ie delay --- .../Security/PluginSecurityManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index e36ff99501..544e2e9241 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -19,7 +19,7 @@ namespace MediaBrowser.Common.Implementations.Security public class PluginSecurityManager : ISecurityManager { private const string MBValidateUrl = MbAdmin.HttpsUrl + "service/registration/validate"; - private const string AppstoreRegUrl = /*MbAdmin.HttpsUrl*/ "http://mb3admin.com/admin/" + "service/appstore/register"; + private const string AppstoreRegUrl = /*MbAdmin.HttpsUrl*/ "http://mb3admin.com/test/admin/" + "service/appstore/register"; /// /// The _is MB supporter @@ -199,7 +199,7 @@ namespace MediaBrowser.Common.Implementations.Security Url = AppstoreRegUrl, CancellationToken = CancellationToken.None }; - options.RequestHeaders.Add("X-Emby-Token", _appHost.SystemId); + options.RequestHeaders.Add("X-Emby-Token", /*_appHost.SystemId*/ "08606E86D043"); options.RequestContent = parameters; options.RequestContentType = "application/json"; @@ -247,7 +247,7 @@ namespace MediaBrowser.Common.Implementations.Security } catch (IOException) { - + } } -- cgit v1.2.3 From 3cd774189302123dbd4091572202c38feb248b62 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 26 Oct 2015 14:55:46 -0400 Subject: fix list avatars --- MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs') diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index 544e2e9241..c17a637fed 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -19,7 +19,7 @@ namespace MediaBrowser.Common.Implementations.Security public class PluginSecurityManager : ISecurityManager { private const string MBValidateUrl = MbAdmin.HttpsUrl + "service/registration/validate"; - private const string AppstoreRegUrl = /*MbAdmin.HttpsUrl*/ "http://mb3admin.com/test/admin/" + "service/appstore/register"; + private const string AppstoreRegUrl = /*MbAdmin.HttpsUrl*/ "http://mb3admin.com/admin/" + "service/appstore/register"; /// /// The _is MB supporter @@ -199,7 +199,7 @@ namespace MediaBrowser.Common.Implementations.Security Url = AppstoreRegUrl, CancellationToken = CancellationToken.None }; - options.RequestHeaders.Add("X-Emby-Token", /*_appHost.SystemId*/ "08606E86D043"); + options.RequestHeaders.Add("X-Emby-Token", _appHost.SystemId); options.RequestContent = parameters; options.RequestContentType = "application/json"; -- cgit v1.2.3