Commit 24415f57 authored by Felix Paul Kühne's avatar Felix Paul Kühne

dropbox: fix login (close #14835)

parent cfb6ed8c
......@@ -14,7 +14,6 @@
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCDropboxTableViewController.h"
#import "VLCHTTPUploaderController.h"
#import "GHRevealViewController.h"
#import "VLCMenuTableViewController.h"
......@@ -22,6 +21,9 @@
@class VLCPlaylistViewController;
@class VLCPlayerDisplayController;
extern NSString *const VLCDropboxSessionWasAuthorized;
@interface VLCAppDelegate : UIResponder <UIApplicationDelegate>
- (void)updateMediaList;
......@@ -39,7 +41,6 @@
- (void)openMovieWithExternalSubtitleFromURL:(NSURL *)url externalSubURL:(NSString *)SubtitlePath;
@property (nonatomic, readonly) VLCPlaylistViewController *playlistViewController;
@property (nonatomic, readonly) VLCDropboxTableViewController *dropboxTableViewController;
@property (nonatomic, readonly) VLCDownloadViewController *downloadViewController;
@property (nonatomic, readonly) VLCPlayerDisplayController *playerDisplayController;
......
......@@ -34,11 +34,13 @@
#import "VLCPlaybackController+MediaLibrary.h"
#import "VLCPlayerDisplayController.h"
#import <MediaPlayer/MediaPlayer.h>
#import <DropboxSDK/DropboxSDK.h>
NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorized";
@interface VLCAppDelegate () <PAPasscodeViewControllerDelegate, VLCMediaFileDiscovererDelegate> {
PAPasscodeViewController *_passcodeLockController;
VLCDownloadViewController *_downloadViewController;
VLCDropboxTableViewController *_dropboxTableViewController;
int _idleCounter;
int _networkActivityCounter;
BOOL _passcodeValidated;
......@@ -212,7 +214,7 @@ continueUserActivity:(NSUserActivity *)userActivity
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([[DBSession sharedSession] handleOpenURL:url]) {
[self.dropboxTableViewController updateViewAfterSessionChange];
[[NSNotificationCenter defaultCenter] postNotificationName:VLCDropboxSessionWasAuthorized object:nil];
return YES;
}
......@@ -329,13 +331,6 @@ continueUserActivity:(NSUserActivity *)userActivity
}
#pragma mark - properties
- (VLCDropboxTableViewController *)dropboxTableViewController
{
if (_dropboxTableViewController == nil)
_dropboxTableViewController = [[VLCDropboxTableViewController alloc] initWithNibName:@"VLCCloudStorageTableViewController" bundle:nil];
return _dropboxTableViewController;
}
- (VLCDownloadViewController *)downloadViewController
{
......
......@@ -2,10 +2,11 @@
* VLCCloudServicesTableViewController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2014 VideoLAN. All rights reserved.
* Copyright (c) 2014-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Carola Nitz <nitz.carola # googlemail.com>
* Felix Paul Kühne <fkuehne # videolan.org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
......@@ -101,7 +102,7 @@
switch (indexPath.row) {
case 0: {
//Dropbox
BOOL isAuthorized = [[DBSession sharedSession] isLinked];
BOOL isAuthorized = [[VLCDropboxController sharedInstance] isAuthorized];
cell.icon.image = [UIImage imageNamed:@"Dropbox"];
cell.cloudTitle.text = @"Dropbox";
cell.cloudInformation.text = isAuthorized ? NSLocalizedString(@"LOGGED_IN", "") : NSLocalizedString(@"LOGIN", "");
......
......@@ -2,7 +2,7 @@
* VLCCloudStorageTableViewController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013 VideoLAN. All rights reserved.
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
......@@ -91,6 +91,7 @@
{
[_activityIndicator startAnimating];
[self.controller requestDirectoryListingAtPath:self.currentPath];
[_activityIndicator stopAnimating];
}
- (void)mediaListUpdated
......@@ -172,11 +173,12 @@
self.navigationItem.rightBarButtonItem = _logoutButton;
if(_authorizationInProgress) {
if (self.loginToCloudStorageView.superview) {
[self.loginToCloudStorageView removeFromSuperview];
}
return;
[self.loginToCloudStorageView removeFromSuperview];
}
}
if (![self.controller isAuthorized]) {
[_activityIndicator stopAnimating];
[self _showLoginPanel];
return;
}
......
......@@ -2,7 +2,7 @@
* VLCDropboxController.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013 VideoLAN. All rights reserved.
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
......@@ -17,6 +17,8 @@
@property (nonatomic, readonly) NSInteger numberOfFilesWaitingToBeDownloaded;
+ (instancetype)sharedInstance;
- (void)downloadFileToDocumentFolder:(DBMetadata *)file;
- (void)streamFile:(DBMetadata *)file;
......
......@@ -2,7 +2,7 @@
* VLCDropboxController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013 VideoLAN. All rights reserved.
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
......@@ -37,8 +37,21 @@
#pragma mark - session handling
+ (instancetype)sharedInstance
{
static VLCDropboxController *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [self new];
});
return sharedInstance;
}
- (void)startSession
{
[[DBSession sharedSession] isLinked];
}
- (void)logout
......@@ -48,7 +61,7 @@
- (BOOL)isAuthorized
{
return [[DBSession sharedSession] isLinked];
return [[DBSession sharedSession] isLinked];
}
- (DBRestClient *)restClient {
......
......@@ -30,14 +30,24 @@
@implementation VLCDropboxTableViewController
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewDidLoad
{
[super viewDidLoad];
_dropboxController = [[VLCDropboxController alloc] init];
_dropboxController = [VLCDropboxController sharedInstance];
self.controller = _dropboxController;
self.controller.delegate = self;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(sessionWasUpdated:)
name:VLCDropboxSessionWasAuthorized
object:nil];
DBSession* dbSession = [[DBSession alloc] initWithAppKey:kVLCDropboxAppKey appSecret:kVLCDropboxPrivateKey root:kDBRootDropbox];
[DBSession setSharedSession:dbSession];
[DBRequest setNetworkRequestDelegate:_dropboxController];
......@@ -53,6 +63,10 @@
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.controller = _dropboxController;
self.controller.delegate = self;
[self updateViewAfterSessionChange];
}
......@@ -118,6 +132,11 @@
[_dropboxController logout];
}
- (void)sessionWasUpdated:(NSNotification *)aNotification
{
self.authorizationInProgress = YES;
[self updateViewAfterSessionChange];
}
#pragma mark - VLCCloudStorageTableViewCell delegation
......
......@@ -19,7 +19,6 @@
@interface VLCGoogleDriveTableViewController () <VLCCloudStorageTableViewCell>
{
VLCGoogleDriveController *_googleDriveController;
GTLDriveFile *_selectedFile;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment