VLCCloudServicesTVViewController.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 "VLCDropboxTableViewController.h"
  15. #import "SSKeychain.h"
  16. #import "VLCPlayerDisplayController.h"
  17. #import "VLCOneDriveController.h"
  18. #import "VLCOneDriveTableViewController2.h"
  19. #import "VLCBoxTableViewController.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.textColor = [UIColor VLCDarkTextShadowColor];
  32. self.helpLabel.shadowColor = [UIColor VLCLightTextColor];
  33. self.helpLabel.text = NSLocalizedString(@"CLOUD_LOGIN_LONG", nil);
  34. [self.helpLabel sizeToFit];
  35. NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
  36. [center addObserver:self selector:@selector(oneDriveSessionUpdated:) name:VLCOneDriveControllerSessionUpdated object:nil];
  37. [center addObserver:self selector:@selector(boxSessionUpdated:) name:VLCBoxControllerSessionUpdated object:nil];
  38. MDFMovieDBSessionManager *movieDBSessionManager = [MDFMovieDBSessionManager sharedInstance];
  39. movieDBSessionManager.apiKey = kVLCfortvOSMovieDBKey;
  40. [movieDBSessionManager fetchProperties];
  41. _oneDriveController = [VLCOneDriveController sharedInstance];
  42. _boxController = [VLCBoxController sharedInstance];
  43. [_boxController startSession];
  44. self.dropboxButton.enabled = self.gDriveButton.enabled = NO;
  45. [self oneDriveSessionUpdated:nil];
  46. [self boxSessionUpdated:nil];
  47. [self performSelector:@selector(updateDropbox) withObject:nil afterDelay:0.1];
  48. }
  49. - (void)dealloc
  50. {
  51. [[NSNotificationCenter defaultCenter] removeObserver:self];
  52. }
  53. - (NSString *)title
  54. {
  55. return NSLocalizedString(@"CLOUD_SERVICES", nil);
  56. }
  57. - (IBAction)dropbox:(id)sender
  58. {
  59. VLCDropboxTableViewController *targetViewController = [[VLCDropboxTableViewController alloc] initWithPath:nil];
  60. [self.navigationController pushViewController:targetViewController animated:YES];
  61. }
  62. - (void)updateDropbox
  63. {
  64. self.dropboxButton.enabled = [[VLCDropboxController sharedInstance] restoreFromSharedCredentials];
  65. }
  66. - (void)oneDriveSessionUpdated:(NSNotification *)aNotification
  67. {
  68. self.oneDriveButton.enabled = _oneDriveController.activeSession;
  69. }
  70. - (void)boxSessionUpdated:(NSNotification *)aNotification
  71. {
  72. self.boxButton.enabled = YES;
  73. }
  74. - (IBAction)onedrive:(id)sender
  75. {
  76. VLCOneDriveTableViewController2 *newKid = [[VLCOneDriveTableViewController2 alloc] initWithOneDriveObject:nil];
  77. [self.navigationController pushViewController:newKid animated:YES];
  78. }
  79. - (IBAction)box:(id)sender
  80. {
  81. VLCBoxTableViewController *targetViewController = [[VLCBoxTableViewController alloc] initWithPath:@""];
  82. [self.navigationController pushViewController:targetViewController animated:YES];
  83. }
  84. - (IBAction)gdrive:(id)sender
  85. {
  86. // TODO
  87. }
  88. @end