summaryrefslogtreecommitdiff
path: root/Juick/Classes/AccountManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/Classes/AccountManager.cs')
-rw-r--r--Juick/Classes/AccountManager.cs40
1 files changed, 9 insertions, 31 deletions
diff --git a/Juick/Classes/AccountManager.cs b/Juick/Classes/AccountManager.cs
index eb99d92..1f9ffe5 100644
--- a/Juick/Classes/AccountManager.cs
+++ b/Juick/Classes/AccountManager.cs
@@ -3,8 +3,6 @@ using System.IO.IsolatedStorage;
using System.Net;
using System.Windows;
using System.Windows.Controls;
-using RestSharp;
-using System.Diagnostics;
namespace Juick.Classes
{
@@ -12,14 +10,14 @@ namespace Juick.Classes
{
private string _userName;
private string _password;
-
+
public string UserName
{
get
{
if (_userName == null)
{
- IsolatedStorageSettings.ApplicationSettings.TryGetValue<string>("user", out _userName);
+ IsolatedStorageSettings.ApplicationSettings.TryGetValue<string>("user", out _userName);
}
return _userName;
}
@@ -36,7 +34,7 @@ namespace Juick.Classes
{
if (_password == null)
{
- IsolatedStorageSettings.ApplicationSettings.TryGetValue<string>("password", out _password);
+ IsolatedStorageSettings.ApplicationSettings.TryGetValue<string>("password", out _password);
}
return _password;
}
@@ -49,8 +47,7 @@ namespace Juick.Classes
public bool IsAuthenticated
{
- get
- {
+ get {
bool authenticated;
IsolatedStorageSettings.ApplicationSettings.TryGetValue<bool>("authenticated", out authenticated);
return authenticated;
@@ -58,45 +55,26 @@ namespace Juick.Classes
set { IsolatedStorageSettings.ApplicationSettings["authenticated"] = value; }
}
-
-
public string NotificationUri
{
get
{
- string _notificationUri;
- IsolatedStorageSettings.ApplicationSettings.TryGetValue<string>("notification_uri", out _notificationUri);
- return _notificationUri;
+ string savedUri;
+ IsolatedStorageSettings.ApplicationSettings.TryGetValue<string>("notification_uri", out savedUri);
+ return savedUri;
}
set
{
- var oldValue = NotificationUri;
- if (!string.IsNullOrEmpty(oldValue))
- UnregisterNotificationUrl(oldValue);
IsolatedStorageSettings.ApplicationSettings["notification_uri"] = value;
- if (!string.IsNullOrEmpty(value))
- RegisterNotificationUrl(value);
}
}
-
-
+
+
public void SignOut(Page page)
{
IsAuthenticated = false;
- App.AppContext.DisableNotifications();
page.NavigationService.Navigate(new Uri("/LoginView.xaml", UriKind.Relative));
page.Dispatcher.BeginInvoke(() => page.NavigationService.RemoveBackEntry());
}
-
- void RegisterNotificationUrl(string newUrl)
- {
- App.AppContext.Client.ExecuteAsync(new RestRequest("/winphone/register?url=" + newUrl),
- response => Debug.WriteLine("Registering push url, status {0}: {1}", response.Request.Resource, response.StatusCode));
- }
- void UnregisterNotificationUrl(string oldUrl)
- {
- App.AppContext.Client.ExecuteAsync(new RestRequest("/winphone/unregister?url=" + oldUrl),
- response => Debug.WriteLine("Unregistered push url, status {0}: {1}", response.Request.Resource, response.StatusCode));
- }
}
}