VLCOneDriveController.m 2.93 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*****************************************************************************
 * VLCOneDriveController.m
 * VLC for iOS
 *****************************************************************************
 * Copyright (c) 2014 VideoLAN. All rights reserved.
 * $Id$
 *
 * Authors: Felix Paul Kühne <fkuehne # videolan.org>
 *
 * Refer to the COPYING file of the official project for license.
 *****************************************************************************/


#import "VLCOneDriveController.h"
#import "VLCOneDriveConstants.h"

/* the Live SDK doesn't have an umbrella header so we need to import what we need */
#import <LiveSDK/LiveConnectClient.h>

/* include private API headers */
#import <LiveSDK/LiveApiHelper.h>

@interface VLCOneDriveController () <LiveAuthDelegate, LiveDownloadOperationDelegate, LiveOperationDelegate>
{
    LiveConnectClient *_liveClient;
    NSArray *_liveScopes;
27
    BOOL _activeSession;
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
}

@end

@implementation VLCOneDriveController

+ (VLCOneDriveController *)sharedInstance
{
    static VLCOneDriveController *sharedInstance = nil;
    static dispatch_once_t pred;

    dispatch_once(&pred, ^{
        sharedInstance = [[self alloc] init];
    });

    return sharedInstance;
}

- (instancetype)init
{
    self = [super init];

    if (!self)
        return self;

    _liveScopes = @[@"wl.signin",@"wl.basic",@"wl.skydrive"];

    _liveClient = [[LiveConnectClient alloc] initWithClientId:kVLCOneDriveClientID
56
                                                       scopes:_liveScopes
57 58 59 60 61 62 63 64
                                                     delegate:self
                                                    userState:@"init"];

    return self;
}

#pragma mark - authentication

65 66 67 68 69
- (BOOL)activeSession
{
    return _activeSession;
}

70 71 72
- (void)login
{
    [_liveClient login:self.delegate
73 74 75
                scopes:_liveScopes
              delegate:self
             userState:@"login"];
76 77 78 79 80
}

- (void)logout
{
    [_liveClient logoutWithDelegate:self userState:@"logout"];
81
    _activeSession = NO;
82 83 84 85
}

- (void)authCompleted:(LiveConnectSessionStatus)status session:(LiveConnectSession *)session userState:(id)userState
{
86 87 88 89
    if (status == 1 && session != NULL)
        _activeSession = YES;
    else
        _activeSession = NO;
90 91 92 93
}

- (void)authFailed:(NSError *)error userState:(id)userState
{
94 95
    APLog(@"OneDrive auth failed: %@, %@", error, userState);
    _activeSession = NO;
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
}

#pragma mark - listing

- (void)requestDirectoryListingAtPath:(NSString *)path
{
}

- (void)liveOperationSucceeded:(LiveOperation *)operation
{
}

- (void)liveOperationFailed:(NSError *)error operation:(LiveOperation *)operation
{
}

#pragma mark - file handling

- (void)downloadFileWithPath:(NSString *)path
{
}

- (void)liveDownloadOperationProgressed:(LiveOperationProgress *)progress
                                   data:(NSData *)receivedData
                              operation:(LiveDownloadOperation *)operation
{
}

- (void)streamFileWithPath:(NSString *)path
{
}

@end