VLCOneDriveController.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*****************************************************************************
  2. * VLCOneDriveController.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2014 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. #import "VLCOneDriveController.h"
  13. #import "VLCOneDriveConstants.h"
  14. /* the Live SDK doesn't have an umbrella header so we need to import what we need */
  15. #import <LiveSDK/LiveConnectClient.h>
  16. /* include private API headers */
  17. #import <LiveSDK/LiveApiHelper.h>
  18. @interface VLCOneDriveController () <LiveAuthDelegate, LiveDownloadOperationDelegate, LiveOperationDelegate>
  19. {
  20. LiveConnectClient *_liveClient;
  21. NSArray *_liveScopes;
  22. BOOL _activeSession;
  23. }
  24. @end
  25. @implementation VLCOneDriveController
  26. + (VLCOneDriveController *)sharedInstance
  27. {
  28. static VLCOneDriveController *sharedInstance = nil;
  29. static dispatch_once_t pred;
  30. dispatch_once(&pred, ^{
  31. sharedInstance = [[self alloc] init];
  32. });
  33. return sharedInstance;
  34. }
  35. - (instancetype)init
  36. {
  37. self = [super init];
  38. if (!self)
  39. return self;
  40. _liveScopes = @[@"wl.signin",@"wl.basic",@"wl.skydrive"];
  41. _liveClient = [[LiveConnectClient alloc] initWithClientId:kVLCOneDriveClientID
  42. scopes:_liveScopes
  43. delegate:self
  44. userState:@"init"];
  45. return self;
  46. }
  47. #pragma mark - authentication
  48. - (BOOL)activeSession
  49. {
  50. return _activeSession;
  51. }
  52. - (void)login
  53. {
  54. [_liveClient login:self.delegate
  55. scopes:_liveScopes
  56. delegate:self
  57. userState:@"login"];
  58. }
  59. - (void)logout
  60. {
  61. [_liveClient logoutWithDelegate:self userState:@"logout"];
  62. _activeSession = NO;
  63. }
  64. - (void)authCompleted:(LiveConnectSessionStatus)status session:(LiveConnectSession *)session userState:(id)userState
  65. {
  66. if (status == 1 && session != NULL)
  67. _activeSession = YES;
  68. else
  69. _activeSession = NO;
  70. }
  71. - (void)authFailed:(NSError *)error userState:(id)userState
  72. {
  73. APLog(@"OneDrive auth failed: %@, %@", error, userState);
  74. _activeSession = NO;
  75. }
  76. #pragma mark - listing
  77. - (void)requestDirectoryListingAtPath:(NSString *)path
  78. {
  79. }
  80. - (void)liveOperationSucceeded:(LiveOperation *)operation
  81. {
  82. }
  83. - (void)liveOperationFailed:(NSError *)error operation:(LiveOperation *)operation
  84. {
  85. }
  86. #pragma mark - file handling
  87. - (void)downloadFileWithPath:(NSString *)path
  88. {
  89. }
  90. - (void)liveDownloadOperationProgressed:(LiveOperationProgress *)progress
  91. data:(NSData *)receivedData
  92. operation:(LiveDownloadOperation *)operation
  93. {
  94. }
  95. - (void)streamFileWithPath:(NSString *)path
  96. {
  97. }
  98. @end