summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2013-10-09 00:44:15 +0400
committerGravatar Vitaly Takmazov2013-10-09 00:44:15 +0400
commita9a2c4d856dea88697e688f990144bee0448af2c (patch)
treebc61fa646929f8597583fec967787a6d2fd7e57e
parentfa1170247a93bdbc6f9656b1d6f3be7b732d22af (diff)
HTTPS for WP8
-rw-r--r--Juick/Classes/HttpsHelper.cs12
-rw-r--r--Juick/Juick.csproj1
-rw-r--r--Juick/ViewModels/AppViewModel.cs19
3 files changed, 20 insertions, 12 deletions
diff --git a/Juick/Classes/HttpsHelper.cs b/Juick/Classes/HttpsHelper.cs
new file mode 100644
index 0000000..18689fd
--- /dev/null
+++ b/Juick/Classes/HttpsHelper.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Juick.Classes
+{
+ static class HttpsHelper
+ {
+ public static bool CanUseHttps
+ {
+ get { return Environment.OSVersion.Version.Major >= 8; }
+ }
+ }
+}
diff --git a/Juick/Juick.csproj b/Juick/Juick.csproj
index c89c775..5270c65 100644
--- a/Juick/Juick.csproj
+++ b/Juick/Juick.csproj
@@ -86,6 +86,7 @@
<Compile Include="Classes\DateHelper.cs" />
<Compile Include="Classes\DelegateCommand.cs" />
<Compile Include="Classes\ExpressionHelper.cs" />
+ <Compile Include="Classes\HttpsHelper.cs" />
<Compile Include="Classes\InvokeDelegateCommandAction.cs" />
<Compile Include="Classes\LowProfileImageLoader.cs" />
<Compile Include="Classes\TileHelper.cs" />
diff --git a/Juick/ViewModels/AppViewModel.cs b/Juick/ViewModels/AppViewModel.cs
index e3a58bb..2aff819 100644
--- a/Juick/ViewModels/AppViewModel.cs
+++ b/Juick/ViewModels/AppViewModel.cs
@@ -38,13 +38,8 @@ namespace Juick.ViewModels
pushChannel = new HttpNotificationChannel(channelName);
// Register for all the events before attempting to open the channel.
- pushChannel.ChannelUriUpdated += (sender, e) => {
- EnableNotifications();
- };
- pushChannel.ErrorOccurred += (sender, e) =>
- {
- DisableNotifications();
- };
+ pushChannel.ChannelUriUpdated += (sender, e) => EnableNotifications();
+ pushChannel.ErrorOccurred += (sender, e) => DisableNotifications();
// Register for this notification only if you need to receive the notifications while your application is running.
// Register for this notification only if you need to receive the notifications while your application is running.
@@ -76,10 +71,7 @@ namespace Juick.ViewModels
else
{
// The channel was already open, so just register for all the events.
- pushChannel.ChannelUriUpdated += (sender, e) =>
- {
- EnableNotifications();
- };
+ pushChannel.ChannelUriUpdated += (sender, e) => EnableNotifications();
pushChannel.ErrorOccurred += (sender, e) => DisableNotifications();
// Register for this notification only if you need to receive the notifications while your application is running.
@@ -149,11 +141,14 @@ namespace Juick.ViewModels
}
private RestClient _cl;
+
+ private readonly string _juickUri = HttpsHelper.CanUseHttps ? "https://api.juick.com" : "http://api.juick.com";
+
public RestClient Client
{
get
{
- return _cl ?? (_cl = new RestClient("http://api.juick.com")
+ return _cl ?? (_cl = new RestClient(_juickUri)
{
UserAgent = "Juick 1.1/Windows Phone " + Environment.OSVersion.Version
});