aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ApiInteraction/ApiClient.cs
diff options
context:
space:
mode:
authorLukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com>2012-09-03 17:56:30 -0400
committerLukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com>2012-09-03 17:56:30 -0400
commitfc735e918723f5bfdd64979afa4995a6fec80e7c (patch)
tree7777e8f0954a29953ed64beb79f4f58c5bda6aab /MediaBrowser.ApiInteraction/ApiClient.cs
parent7f8a4772786ed32781eab011cedb3260c9e2dd33 (diff)
Tweaked plugin downloading a bit
Diffstat (limited to 'MediaBrowser.ApiInteraction/ApiClient.cs')
-rw-r--r--MediaBrowser.ApiInteraction/ApiClient.cs39
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>