VLCCloudServicesTVViewController.m 2.95 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/*****************************************************************************
 * VLC for iOS
 *****************************************************************************
 * Copyright (c) 2015 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 "VLCCloudServicesTVViewController.h"
13 14
#import <DropboxTVSDK/DropboxSDK.h>
#import "VLCDropboxController.h"
15 16 17
#import "VLCDropboxTableViewController.h"
#import "SSKeychain.h"
#import "VLCPlayerDisplayController.h"
18 19
#import "VLCOneDriveController.h"
#import "VLCOneDriveTableViewController2.h"
Felix Paul Kühne's avatar
Felix Paul Kühne committed
20
#import "VLCBoxTableViewController.h"
21
#import "VLCBoxController.h"
22 23

@interface VLCCloudServicesTVViewController ()
24 25
{
    VLCOneDriveController *_oneDriveController;
26
    VLCBoxController *_boxController;
27
}
28 29 30 31 32 33
@end

@implementation VLCCloudServicesTVViewController

- (void)viewDidLoad {
    [super viewDidLoad];
34

35 36
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center addObserver:self selector:@selector(oneDriveSessionUpdated:) name:VLCOneDriveControllerSessionUpdated object:nil];
37
    [center addObserver:self selector:@selector(boxSessionUpdated:) name:VLCBoxControllerSessionUpdated object:nil];
38 39

    _oneDriveController = [VLCOneDriveController sharedInstance];
40 41 42 43
    _boxController = [VLCBoxController sharedInstance];
    [_boxController startSession];

    self.dropboxButton.enabled = self.gDriveButton.enabled = NO;
44
    [self oneDriveSessionUpdated:nil];
45 46 47
    [self boxSessionUpdated:nil];

    [self performSelector:@selector(updateDropbox) withObject:nil afterDelay:0.1];
48 49 50 51 52
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
53 54 55 56
}

- (NSString *)title
{
Felix Paul Kühne's avatar
Felix Paul Kühne committed
57
    return NSLocalizedString(@"CLOUD_SERVICES", nil);
58 59
}

Felix Paul Kühne's avatar
Felix Paul Kühne committed
60
- (IBAction)dropbox:(id)sender
61
{
62 63
    VLCDropboxTableViewController *targetViewController = [[VLCDropboxTableViewController alloc] initWithPath:nil];
    [self.navigationController pushViewController:targetViewController animated:YES];
64 65 66 67 68
}

- (void)updateDropbox
{
    self.dropboxButton.enabled = [[VLCDropboxController sharedInstance] restoreFromSharedCredentials];
69 70
}

71 72 73 74 75
- (void)oneDriveSessionUpdated:(NSNotification *)aNotification
{
    self.oneDriveButton.enabled = _oneDriveController.activeSession;
}

76 77 78 79 80
- (void)boxSessionUpdated:(NSNotification *)aNotification
{
    self.boxButton.enabled = YES;
}

Felix Paul Kühne's avatar
Felix Paul Kühne committed
81
- (IBAction)onedrive:(id)sender
Felix Paul Kühne's avatar
Felix Paul Kühne committed
82
{
83 84
    VLCOneDriveTableViewController2 *newKid = [[VLCOneDriveTableViewController2 alloc] initWithOneDriveObject:nil];
    [self.navigationController pushViewController:newKid animated:YES];
Felix Paul Kühne's avatar
Felix Paul Kühne committed
85 86
}

Felix Paul Kühne's avatar
Felix Paul Kühne committed
87 88
- (IBAction)box:(id)sender
{
89 90 91 92 93 94 95
    VLCBoxTableViewController *targetViewController = [[VLCBoxTableViewController alloc] initWithPath:@""];
    [self.navigationController pushViewController:targetViewController animated:YES];
}

- (IBAction)gdrive:(id)sender
{
    // TODO
Felix Paul Kühne's avatar
Felix Paul Kühne committed
96 97
}

98
@end