diff options
Diffstat (limited to 'MediaBrowser.ApiInteraction/ApiClient.cs')
| -rw-r--r-- | MediaBrowser.ApiInteraction/ApiClient.cs | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/MediaBrowser.ApiInteraction/ApiClient.cs b/MediaBrowser.ApiInteraction/ApiClient.cs index 6384f3df9..18d6ddc21 100644 --- a/MediaBrowser.ApiInteraction/ApiClient.cs +++ b/MediaBrowser.ApiInteraction/ApiClient.cs @@ -590,15 +590,34 @@ namespace MediaBrowser.ApiInteraction }
/// <summary>
- /// Gets weather information for the default location as set in configuration
+ /// Gets the current server configuration
/// </summary>
public async Task<ServerConfiguration> GetServerConfigurationAsync()
{
string url = ApiUrl + "/ServerConfiguration";
- using (Stream stream = await GetSerializedStreamAsync(url, ApiInteraction.SerializationFormat.Json).ConfigureAwait(false))
+ // At the moment this can't be retrieved in protobuf format
+ SerializationFormat format = DataSerializer.CanDeserializeJsv ? SerializationFormat.Jsv : ApiInteraction.SerializationFormat.Json;
+
+ using (Stream stream = await GetSerializedStreamAsync(url, format).ConfigureAwait(false))
+ {
+ return DeserializeFromStream<ServerConfiguration>(stream, format);
+ }
+ }
+
+ /// <summary>
+ /// Gets weather information for the default location as set in configuration
+ /// </summary>
+ public async Task<object> GetPluginConfigurationAsync(PluginInfo plugin, Type configurationType)
+ {
+ string url = ApiUrl + "/PluginConfiguration?assemblyfilename=" + plugin.AssemblyFileName;
+
+ // At the moment this can't be retrieved in protobuf format
+ SerializationFormat format = DataSerializer.CanDeserializeJsv ? SerializationFormat.Jsv : ApiInteraction.SerializationFormat.Json;
+
+ using (Stream stream = await GetSerializedStreamAsync(url, format).ConfigureAwait(false))
{
- return DeserializeFromStream<ServerConfiguration>(stream, ApiInteraction.SerializationFormat.Json);
+ return DeserializeFromStream(stream, format, configurationType);
}
}
@@ -685,6 +704,20 @@ namespace MediaBrowser.ApiInteraction return DataSerializer.DeserializeJsonFromStream<T>(stream);
}
+ private object DeserializeFromStream(Stream stream, SerializationFormat format, Type type)
+ {
+ if (format == ApiInteraction.SerializationFormat.Protobuf)
+ {
+ return DataSerializer.DeserializeProtobufFromStream(stream, type);
+ }
+ if (format == ApiInteraction.SerializationFormat.Jsv)
+ {
+ return DataSerializer.DeserializeJsvFromStream(stream, type);
+ }
+
+ return DataSerializer.DeserializeJsonFromStream(stream, type);
+ }
+
/// <summary>
/// This is just a helper around HttpClient
/// </summary>
|
