VLCCloudServicesTVViewController.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*****************************************************************************
  2. * VLC for iOS
  3. *****************************************************************************
  4. * Copyright (c) 2015 VideoLAN. All rights reserved.
  5. * $Id$
  6. *
  7. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  8. *
  9. * Refer to the COPYING file of the official project for license.
  10. *****************************************************************************/
  11. #import "VLCCloudServicesTVViewController.h"
  12. #import <DropboxTVSDK/DropboxSDK.h>
  13. #import "VLCDropboxController.h"
  14. #import "VLCDropboxCollectionViewController.h"
  15. #import "SSKeychain.h"
  16. #import "VLCPlayerDisplayController.h"
  17. #import "VLCOneDriveController.h"
  18. #import "VLCOneDriveCollectionViewController.h"
  19. #import "VLCBoxCollectionViewController.h"
  20. #import "VLCBoxController.h"
  21. #import "MetaDataFetcherKit.h"
  22. @interface VLCCloudServicesTVViewController ()
  23. {
  24. VLCOneDriveController *_oneDriveController;
  25. VLCBoxController *_boxController;
  26. }
  27. @end
  28. @implementation VLCCloudServicesTVViewController
  29. - (void)viewDidLoad {
  30. [super viewDidLoad];
  31. self.helpLabel.text = NSLocalizedString(@"CLOUD_LOGIN_LONG", nil);
  32. [self.helpLabel sizeToFit];
  33. NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
  34. [center addObserver:self selector:@selector(oneDriveSessionUpdated:) name:VLCOneDriveControllerSessionUpdated object:nil];
  35. [center addObserver:self selector:@selector(boxSessionUpdated:) name:VLCBoxControllerSessionUpdated object:nil];
  36. MDFMovieDBSessionManager *movieDBSessionManager = [MDFMovieDBSessionManager sharedInstance];
  37. movieDBSessionManager.apiKey = kVLCfortvOSMovieDBKey;
  38. [movieDBSessionManager fetchProperties];
  39. _oneDriveController = [VLCOneDriveController sharedInstance];
  40. _boxController = [VLCBoxController sharedInstance];
  41. [_boxController startSession];
  42. self.dropboxButton.enabled = self.gDriveButton.enabled = NO;
  43. [self oneDriveSessionUpdated:nil];
  44. [self boxSessionUpdated:nil];
  45. [self performSelector:@selector(updateDropbox) withObject:nil afterDelay:0.1];
  46. }
  47. - (void)dealloc
  48. {
  49. [[NSNotificationCenter defaultCenter] removeObserver:self];
  50. }
  51. - (NSString *)title
  52. {
  53. return NSLocalizedString(@"CLOUD_SERVICES", nil);
  54. }
  55. - (IBAction)dropbox:(id)sender
  56. {
  57. VLCDropboxCollectionViewController *targetViewController = [[VLCDropboxCollectionViewController alloc] initWithNibName:@"VLCRemoteBrowsingCollectionViewController" bundle:nil];
  58. [self.navigationController pushViewController:targetViewController animated:YES];
  59. }
  60. - (void)updateDropbox
  61. {
  62. self.dropboxButton.enabled = [[VLCDropboxController sharedInstance] restoreFromSharedCredentials];
  63. }
  64. - (void)oneDriveSessionUpdated:(NSNotification *)aNotification
  65. {
  66. self.oneDriveButton.enabled = _oneDriveController.activeSession;
  67. }
  68. - (void)boxSessionUpdated:(NSNotification *)aNotification
  69. {
  70. self.boxButton.enabled = YES;
  71. }
  72. - (IBAction)onedrive:(id)sender
  73. {
  74. VLCOneDriveCollectionViewController *targetViewController = [[VLCOneDriveCollectionViewController alloc] initWithOneDriveObject:nil];
  75. [self.navigationController pushViewController:targetViewController animated:YES];
  76. }
  77. - (IBAction)box:(id)sender
  78. {
  79. VLCBoxCollectionViewController *targetViewController = [[VLCBoxCollectionViewController alloc] initWithPath:@""];
  80. [self.navigationController pushViewController:targetViewController animated:YES];
  81. }
  82. - (IBAction)gdrive:(id)sender
  83. {
  84. // TODO
  85. }
  86. @end