VLCCloudServicesTVViewController.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 "VLCPlayerDisplayController.h"
  16. #import "VLCOneDriveController.h"
  17. #import "VLCOneDriveCollectionViewController.h"
  18. #import "VLCBoxCollectionViewController.h"
  19. #import "VLCBoxController.h"
  20. #import "MetaDataFetcherKit.h"
  21. @interface VLCCloudServicesTVViewController ()
  22. {
  23. VLCOneDriveController *_oneDriveController;
  24. VLCBoxController *_boxController;
  25. }
  26. @end
  27. @implementation VLCCloudServicesTVViewController
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. self.helpLabel.text = NSLocalizedString(@"CLOUD_LOGIN_LONG", nil);
  31. [self.helpLabel sizeToFit];
  32. NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
  33. [center addObserver:self selector:@selector(oneDriveSessionUpdated:) name:VLCOneDriveControllerSessionUpdated object:nil];
  34. [center addObserver:self selector:@selector(boxSessionUpdated:) name:VLCBoxControllerSessionUpdated object:nil];
  35. MDFMovieDBSessionManager *movieDBSessionManager = [MDFMovieDBSessionManager sharedInstance];
  36. movieDBSessionManager.apiKey = kVLCfortvOSMovieDBKey;
  37. [movieDBSessionManager fetchProperties];
  38. _oneDriveController = [VLCOneDriveController sharedInstance];
  39. _boxController = [VLCBoxController sharedInstance];
  40. [_boxController startSession];
  41. self.dropboxButton.enabled = self.gDriveButton.enabled = NO;
  42. [self oneDriveSessionUpdated:nil];
  43. [self boxSessionUpdated:nil];
  44. [self performSelector:@selector(updateDropbox) withObject:nil afterDelay:0.1];
  45. }
  46. - (void)dealloc
  47. {
  48. [[NSNotificationCenter defaultCenter] removeObserver:self];
  49. }
  50. - (NSString *)title
  51. {
  52. return NSLocalizedString(@"CLOUD_SERVICES", nil);
  53. }
  54. - (IBAction)dropbox:(id)sender
  55. {
  56. VLCDropboxCollectionViewController *targetViewController = [[VLCDropboxCollectionViewController alloc] initWithNibName:@"VLCRemoteBrowsingCollectionViewController" bundle:nil];
  57. [self.navigationController pushViewController:targetViewController animated:YES];
  58. }
  59. - (void)updateDropbox
  60. {
  61. self.dropboxButton.enabled = [[VLCDropboxController sharedInstance] restoreFromSharedCredentials];
  62. }
  63. - (void)oneDriveSessionUpdated:(NSNotification *)aNotification
  64. {
  65. self.oneDriveButton.enabled = _oneDriveController.activeSession;
  66. }
  67. - (void)boxSessionUpdated:(NSNotification *)aNotification
  68. {
  69. self.boxButton.enabled = YES;
  70. }
  71. - (IBAction)onedrive:(id)sender
  72. {
  73. VLCOneDriveCollectionViewController *targetViewController = [[VLCOneDriveCollectionViewController alloc] initWithOneDriveObject:nil];
  74. [self.navigationController pushViewController:targetViewController animated:YES];
  75. }
  76. - (IBAction)box:(id)sender
  77. {
  78. VLCBoxCollectionViewController *targetViewController = [[VLCBoxCollectionViewController alloc] initWithPath:@""];
  79. [self.navigationController pushViewController:targetViewController animated:YES];
  80. }
  81. - (IBAction)gdrive:(id)sender
  82. {
  83. // TODO
  84. }
  85. @end