The Free Software Media System - Server Backend & API
Added protobuf support for serializing ServerConfiguration
LukePulverenti Luke Pulverenti luke pulverenti50f88997bab5
diff --git a/MediaBrowser.ApiInteraction.Portable/ApiClient.cs b/MediaBrowser.ApiInteraction.Portable/ApiClient.csindex cbd179b02e..eef73dd874 100644--- a/MediaBrowser.ApiInteraction.Portable/ApiClient.cs+++ b/MediaBrowser.ApiInteraction.Portable/ApiClient.cs@@ -269,10 +269,7 @@ namespace MediaBrowser.ApiInteraction.Portable{string url = ApiUrl + "/ServerConfiguration";- // At the moment this can't be retrieved in protobuf format- SerializationFormats format = DataSerializer.CanDeSerializeJsv ? SerializationFormats.Jsv : SerializationFormats.Json;-- GetDataAsync(url, callback, format);+ GetDataAsync(url, callback);}/// <summary>diff --git a/MediaBrowser.ApiInteraction/BaseHttpApiClient.cs b/MediaBrowser.ApiInteraction/BaseHttpApiClient.csindex f298e1f7ec..c3871514e9 100644--- a/MediaBrowser.ApiInteraction/BaseHttpApiClient.cs+++ b/MediaBrowser.ApiInteraction/BaseHttpApiClient.cs@@ -313,12 +313,9 @@ namespace MediaBrowser.ApiInteraction{string url = ApiUrl + "/ServerConfiguration";- // At the moment this can't be retrieved in protobuf format- SerializationFormats format = DataSerializer.CanDeSerializeJsv ? SerializationFormats.Jsv : SerializationFormats.Json;-- using (Stream stream = await GetSerializedStreamAsync(url, format).ConfigureAwait(false))+ using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)){- return DataSerializer.DeserializeFromStream<ServerConfiguration>(stream, format);+ return DeserializeFromStream<ServerConfiguration>(stream);}}diff --git a/MediaBrowser.Model/Configuration/BaseApplicationConfiguration.cs b/MediaBrowser.Model/Configuration/BaseApplicationConfiguration.csindex 17be9eaef6..41eb1da2c8 100644--- a/MediaBrowser.Model/Configuration/BaseApplicationConfiguration.cs+++ b/MediaBrowser.Model/Configuration/BaseApplicationConfiguration.cs@@ -1,12 +1,19 @@-+using ProtoBuf;+namespace MediaBrowser.Model.Configuration{/// <summary>/// Serves as a common base class for the Server and UI application Configurations+ /// ProtoInclude tells Protobuf about subclasses,+ /// The number 50 can be any number, so long as it doesn't clash with any of the ProtoMember numbers either here or in subclasses./// </summary>+ [ProtoContract, ProtoInclude(50, typeof(ServerConfiguration))]public class BaseApplicationConfiguration{+ [ProtoMember(1)]public bool EnableDebugLevelLogging { get; set; }++ [ProtoMember(2)]public int HttpServerPortNumber { get; set; }public BaseApplicationConfiguration()diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.csindex c229ca5568..5bcd09ef00 100644--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs@@ -1,13 +1,24 @@using MediaBrowser.Model.Weather;+using ProtoBuf;namespace MediaBrowser.Model.Configuration{+ /// <summary>+ /// Represents the server configuration.+ /// </summary>+ [ProtoContract]public class ServerConfiguration : BaseApplicationConfiguration{+ [ProtoMember(3)]public bool EnableInternetProviders { get; set; }++ [ProtoMember(4)]public bool EnableUserProfiles { get; set; }+ [ProtoMember(5)]public string WeatherZipCode { get; set; }++ [ProtoMember(6)]public WeatherUnits WeatherUnit { get; set; }public ServerConfiguration()