Commit d378ffc6 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

onedrive controller: implement credentials sharing

parent 01315ddf
......@@ -87,6 +87,7 @@
#define kVLCStoredServerList @"kVLCStoredServerList"
#define kVLCStoreDropboxCredentials @"kVLCStoreDropboxCredentials"
#define kVLCStoreOneDriveCredentials @"kVLCStoreOneDriveCredentials"
#define kVLCUserActivityPlaying @"org.videolan.vlc-ios.playing"
#define kVLCUserActivityLibrarySelection @"org.videolan.vlc-ios.libraryselection"
......
......@@ -19,6 +19,7 @@
/* include private API headers */
#import "LiveApiHelper.h"
#import "LiveAuthStorage.h"
@interface VLCOneDriveController () <LiveAuthDelegate, VLCOneDriveObjectDelegate, VLCOneDriveObjectDownloadDelegate>
{
......@@ -60,6 +61,8 @@
if (!self)
return self;
[self restoreFromSharedCredentials];
_liveScopes = @[@"wl.signin",@"wl.offline_access",@"wl.skydrive"];
_liveClient = [[LiveConnectClient alloc] initWithClientId:kVLCOneDriveClientID
......@@ -128,6 +131,8 @@
[self.delegate performSelector:@selector(sessionWasUpdated)];
}
[[NSNotificationCenter defaultCenter] postNotificationName:VLCOneDriveControllerSessionUpdated object:self];
[self shareCredentials];
}
- (void)authFailed:(NSError *)error userState:(id)userState
......@@ -144,6 +149,32 @@
[[NSNotificationCenter defaultCenter] postNotificationName:VLCOneDriveControllerSessionUpdated object:self];
}
- (void)shareCredentials
{
/* share our credentials */
LiveAuthStorage *authStorage = [[LiveAuthStorage alloc] initWithClientId:kVLCOneDriveClientID];
NSString *credentials = [authStorage refreshToken];
if (credentials == nil)
return;
NSUbiquitousKeyValueStore *ubiquitousStore = [NSUbiquitousKeyValueStore defaultStore];
[ubiquitousStore setString:credentials forKey:kVLCStoreOneDriveCredentials];
[ubiquitousStore synchronize];
}
- (BOOL)restoreFromSharedCredentials
{
LiveAuthStorage *authStorage = [[LiveAuthStorage alloc] initWithClientId:kVLCOneDriveClientID];
NSUbiquitousKeyValueStore *ubiquitousStore = [NSUbiquitousKeyValueStore defaultStore];
[ubiquitousStore synchronize];
NSString *credentials = [ubiquitousStore stringForKey:kVLCStoreOneDriveCredentials];
if (!credentials)
return NO;
[authStorage setRefreshToken:credentials];
return YES;
}
- (void)liveOperationSucceeded:(LiveDownloadOperation *)operation
{
APLog(@"ODC: liveOperationSucceeded (%@)", operation.userState);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment