Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
VLC-iOS
Commits
8bb0d9b0
Commit
8bb0d9b0
authored
Jun 19, 2015
by
Felix Paul Kühne
Browse files
more App Delegate cleanup
parent
4b9996e8
Changes
18
Hide whitespace changes
Inline
Side-by-side
Sources/VLCActivityManager.h
0 → 100644
View file @
8bb0d9b0
/*****************************************************************************
* VLCActivityManager.h
* 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 <Foundation/Foundation.h>
@interface
VLCActivityManager
:
NSObject
+
(
instancetype
)
defaultManager
;
-
(
void
)
activateIdleTimer
;
-
(
void
)
disableIdleTimer
;
-
(
void
)
networkActivityStarted
;
-
(
BOOL
)
haveNetworkActivity
;
-
(
void
)
networkActivityStopped
;
@end
Sources/VLCActivityManager.m
0 → 100644
View file @
8bb0d9b0
/*****************************************************************************
* VLCActivityManager.m
* 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 "VLCActivityManager.h"
@interface
VLCActivityManager
()
{
int
_idleCounter
;
int
_networkActivityCounter
;
}
@end
@implementation
VLCActivityManager
+
(
instancetype
)
defaultManager
{
static
VLCActivityManager
*
sharedInstance
=
nil
;
static
dispatch_once_t
pred
;
dispatch_once
(
&
pred
,
^
{
sharedInstance
=
[
VLCActivityManager
new
];
});
return
sharedInstance
;
}
-
(
void
)
activateIdleTimer
{
_idleCounter
--
;
if
(
_idleCounter
<
1
)
[
UIApplication
sharedApplication
].
idleTimerDisabled
=
NO
;
}
-
(
void
)
disableIdleTimer
{
_idleCounter
++
;
if
([
UIApplication
sharedApplication
].
idleTimerDisabled
==
NO
)
[
UIApplication
sharedApplication
].
idleTimerDisabled
=
YES
;
}
-
(
void
)
networkActivityStarted
{
_networkActivityCounter
++
;
if
([
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
==
NO
)
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
YES
;
}
-
(
BOOL
)
haveNetworkActivity
{
return
_networkActivityCounter
>=
1
;
}
-
(
void
)
networkActivityStopped
{
_networkActivityCounter
--
;
if
(
_networkActivityCounter
<
1
)
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
NO
;
}
@end
Sources/VLCAppDelegate.h
View file @
8bb0d9b0
...
...
@@ -24,16 +24,6 @@ extern NSString *const VLCDropboxSessionWasAuthorized;
@interface
VLCAppDelegate
:
UIResponder
<
UIApplicationDelegate
>
-
(
void
)
updateMediaList
;
-
(
void
)
disableIdleTimer
;
-
(
void
)
activateIdleTimer
;
-
(
void
)
networkActivityStarted
;
-
(
BOOL
)
haveNetworkActivity
;
-
(
void
)
networkActivityStopped
;
-
(
void
)
cleanCache
;
@property
(
nonatomic
,
readonly
)
VLCPlaylistViewController
*
playlistViewController
;
@property
(
nonatomic
,
readonly
)
VLCPlayerDisplayController
*
playerDisplayController
;
...
...
Sources/VLCAppDelegate.m
View file @
8bb0d9b0
...
...
@@ -34,6 +34,7 @@
#import <HockeySDK/HockeySDK.h>
#import "VLCSidebarController.h"
#import "VLCKeychainCoordinator.h"
#import "VLCActivityManager.h"
NSString
*
const
VLCDropboxSessionWasAuthorized
=
@"VLCDropboxSessionWasAuthorized"
;
...
...
@@ -41,8 +42,6 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize
@interface
VLCAppDelegate
()
<
VLCMediaFileDiscovererDelegate
>
{
int
_idleCounter
;
int
_networkActivityCounter
;
BOOL
_passcodeValidated
;
BOOL
_isRunningMigration
;
BOOL
_isComingFromHandoff
;
...
...
@@ -115,13 +114,8 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize
[[
UISwitch
appearance
]
setOnTintColor
:[
UIColor
VLCOrangeTintColor
]];
/* clean caches on launch (since those are used for wifi upload only) */
[
self
cleanCache
];
[
VLCLibrary
sharedLibrary
];
// Init the HTTP Server
[
VLCHTTPUploaderController
sharedInstance
];
// Init the HTTP Server and clean its cache
[[
VLCHTTPUploaderController
sharedInstance
]
cleanCache
];
self
.
window
=
[[
UIWindow
alloc
]
initWithFrame
:[[
UIScreen
mainScreen
]
bounds
]];
// enable crash preventer
...
...
@@ -143,7 +137,7 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize
VLCMediaFileDiscoverer
*
discoverer
=
[
VLCMediaFileDiscoverer
sharedInstance
];
[
discoverer
addObserver
:
self
];
[
discoverer
startDiscovering
:[
self
directoryPath
]
];
[
discoverer
startDiscovering
];
};
NSError
*
error
=
nil
;
...
...
@@ -158,7 +152,7 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize
setupBlock
();
_isRunningMigration
=
NO
;
[[
MLMediaLibrary
sharedMediaLibrary
]
updateMediaDatabase
];
[
self
updateMediaList
];
[
[
VLCMediaFileDiscoverer
sharedInstance
]
updateMediaList
];
};
self
.
window
.
rootViewController
=
migrationController
;
...
...
@@ -252,7 +246,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
if
(
theError
.
code
!=
noErr
)
APLog
(
@"saving the file failed (%li): %@"
,
(
long
)
theError
.
code
,
theError
.
localizedDescription
);
[
self
updateMediaList
];
[
[
VLCMediaFileDiscoverer
sharedInstance
]
updateMediaList
];
}
else
if
([
url
.
scheme
isEqualToString
:
@"vlc-x-callback"
]
||
[
url
.
host
isEqualToString
:
@"x-callback-url"
])
{
// URL confirmes to the x-callback-url specification
// vlc-x-callback://x-callback-url/action?param=value&x-success=callback
...
...
@@ -346,7 +340,7 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
{
if
(
!
_isRunningMigration
&&
!
_isComingFromHandoff
)
{
[[
MLMediaLibrary
sharedMediaLibrary
]
updateMediaDatabase
];
[
self
updateMediaList
];
[
[
VLCMediaFileDiscoverer
sharedInstance
]
updateMediaList
];
}
else
if
(
_isComingFromHandoff
)
{
_isComingFromHandoff
=
NO
;
}
...
...
@@ -382,72 +376,6 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
[
_playlistViewController
updateViewContents
];
}
-
(
void
)
cleanCache
{
if
([
self
haveNetworkActivity
])
return
;
NSArray
*
searchPaths
=
NSSearchPathForDirectoriesInDomains
(
NSCachesDirectory
,
NSUserDomainMask
,
YES
);
NSString
*
uploadDirPath
=
[
searchPaths
[
0
]
stringByAppendingPathComponent
:
@"Upload"
];
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
if
([
fileManager
fileExistsAtPath
:
uploadDirPath
])
[
fileManager
removeItemAtPath
:
uploadDirPath
error
:
nil
];
}
#pragma mark - media list methods
-
(
NSString
*
)
directoryPath
{
NSArray
*
searchPaths
=
NSSearchPathForDirectoriesInDomains
(
NSDocumentDirectory
,
NSUserDomainMask
,
YES
);
NSString
*
directoryPath
=
searchPaths
[
0
];
return
directoryPath
;
}
-
(
void
)
updateMediaList
{
NSString
*
directoryPath
=
[
self
directoryPath
];
NSMutableArray
*
foundFiles
=
[
NSMutableArray
arrayWithArray
:[[
NSFileManager
defaultManager
]
contentsOfDirectoryAtPath
:
directoryPath
error
:
nil
]];
NSMutableArray
*
filePaths
=
[
NSMutableArray
array
];
NSURL
*
fileURL
;
while
(
foundFiles
.
count
)
{
NSString
*
fileName
=
foundFiles
.
firstObject
;
NSString
*
filePath
=
[
directoryPath
stringByAppendingPathComponent
:
fileName
];
[
foundFiles
removeObject
:
fileName
];
if
([
fileName
isSupportedMediaFormat
]
||
[
fileName
isSupportedAudioMediaFormat
])
{
[
filePaths
addObject
:
filePath
];
/* exclude media files from backup (QA1719) */
fileURL
=
[
NSURL
fileURLWithPath
:
filePath
];
[
fileURL
setResourceValue
:
@YES
forKey
:
NSURLIsExcludedFromBackupKey
error
:
nil
];
}
else
{
BOOL
isDirectory
=
NO
;
BOOL
exists
=
[[
NSFileManager
defaultManager
]
fileExistsAtPath
:
filePath
isDirectory
:
&
isDirectory
];
// add folders
if
(
exists
&&
isDirectory
)
{
NSArray
*
files
=
[[
NSFileManager
defaultManager
]
contentsOfDirectoryAtPath
:
filePath
error
:
nil
];
for
(
NSString
*
file
in
files
)
{
NSString
*
fullFilePath
=
[
directoryPath
stringByAppendingPathComponent
:
file
];
isDirectory
=
NO
;
exists
=
[[
NSFileManager
defaultManager
]
fileExistsAtPath
:
fullFilePath
isDirectory
:
&
isDirectory
];
//only add folders or files in folders
if
((
exists
&&
isDirectory
)
||
!
[
filePath
.
lastPathComponent
isEqualToString
:
@"Documents"
])
{
NSString
*
folderpath
=
[
filePath
stringByReplacingOccurrencesOfString
:
directoryPath
withString
:
@""
];
if
(
!
[
folderpath
isEqualToString
:
@""
])
{
folderpath
=
[
folderpath
stringByAppendingString
:
@"/"
];
}
NSString
*
path
=
[
folderpath
stringByAppendingString
:
file
];
[
foundFiles
addObject
:
path
];
}
}
}
}
}
[[
MLMediaLibrary
sharedMediaLibrary
]
addFilePaths
:
filePaths
];
[
_playlistViewController
updateViewContents
];
}
#pragma mark - pass code validation
-
(
void
)
passcodeWasValidated
:(
NSNotification
*
)
aNotifcation
...
...
@@ -471,40 +399,6 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
_passcodeValidated
=
YES
;
}
#pragma mark - idle timer preventer
-
(
void
)
disableIdleTimer
{
_idleCounter
++
;
if
([
UIApplication
sharedApplication
].
idleTimerDisabled
==
NO
)
[
UIApplication
sharedApplication
].
idleTimerDisabled
=
YES
;
}
-
(
void
)
activateIdleTimer
{
_idleCounter
--
;
if
(
_idleCounter
<
1
)
[
UIApplication
sharedApplication
].
idleTimerDisabled
=
NO
;
}
-
(
void
)
networkActivityStarted
{
_networkActivityCounter
++
;
if
([
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
==
NO
)
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
YES
;
}
-
(
BOOL
)
haveNetworkActivity
{
return
_networkActivityCounter
>=
1
;
}
-
(
void
)
networkActivityStopped
{
_networkActivityCounter
--
;
if
(
_networkActivityCounter
<
1
)
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
NO
;
}
#pragma mark - download handling
-
(
void
)
downloadMovieFromURL
:(
NSURL
*
)
url
...
...
Sources/VLCBoxController.m
View file @
8bb0d9b0
...
...
@@ -13,7 +13,7 @@
#import "VLCBoxController.h"
#import "NSString+SupportedMedia.h"
#import "VLCPlaybackController.h"
#import "VLC
AppDelegate
.h"
#import "VLC
MediaFileDiscoverer
.h"
#import <SSKeychain/SSKeychain.h>
@interface
VLCBoxController
()
<
NSURLConnectionDataDelegate
>
...
...
@@ -306,8 +306,7 @@
{
/* update library now that we got a file */
APLog
(
@"BoxFile download was successful"
);
VLCAppDelegate
*
appDelegate
=
(
VLCAppDelegate
*
)
[
UIApplication
sharedApplication
].
delegate
;
[
appDelegate
performSelectorOnMainThread
:
@selector
(
updateMediaList
)
withObject
:
nil
waitUntilDone
:
NO
];
[[
VLCMediaFileDiscoverer
sharedInstance
]
performSelectorOnMainThread
:
@selector
(
updateMediaList
)
withObject
:
nil
waitUntilDone
:
NO
];
if
([
self
.
delegate
respondsToSelector
:
@selector
(
operationWithProgressInformationStopped
)])
[
self
.
delegate
operationWithProgressInformationStopped
];
...
...
Sources/VLCDocumentPickerController.m
View file @
8bb0d9b0
...
...
@@ -12,7 +12,7 @@
#import "VLCDocumentPickerController.h"
#import <MobileCoreServices/MobileCoreServices.h>
#import "VLC
AppDelegate
.h"
#import "VLC
MediaFileDiscoverer
.h"
#import "VLCPlaylistViewController.h"
@interface
VLCDocumentPickerController
()
<
UIDocumentMenuDelegate
,
UIDocumentPickerDelegate
>
...
...
@@ -74,11 +74,10 @@
if
(
!
[
fileManager
fileExistsAtPath
:
filePath
])
{
NSError
*
error
=
nil
;
BOOL
succes
=
[
fileManager
moveItemAtPath
:[
url
path
]
toPath
:
filePath
error
:&
error
];
BOOL
succes
s
=
[
fileManager
moveItemAtPath
:[
url
path
]
toPath
:
filePath
error
:&
error
];
if
(
succes
)
{
VLCAppDelegate
*
appDelegate
=
[
UIApplication
sharedApplication
].
delegate
;
[
appDelegate
updateMediaList
];
if
(
success
)
{
[[
VLCMediaFileDiscoverer
sharedInstance
]
updateMediaList
];
}
}
}
...
...
Sources/VLCDownloadViewController.m
View file @
8bb0d9b0
...
...
@@ -14,7 +14,7 @@
#import "VLCDownloadViewController.h"
#import "VLCHTTPFileDownloader.h"
#import "VLCA
ppDelegate
.h"
#import "VLCA
ctivityManager
.h"
#import "WhiteRaccoon.h"
#import "NSString+SupportedMedia.h"
#import "VLCHTTPFileDownloader.h"
...
...
@@ -241,9 +241,11 @@
-
(
void
)
downloadStarted
{
[
self
.
activityIndicator
stopAnimating
];
VLCAppDelegate
*
appDelegate
=
[
UIApplication
sharedApplication
].
delegate
;
[
appDelegate
networkActivityStopped
];
[
appDelegate
networkActivityStarted
];
VLCActivityManager
*
activityManager
=
[
VLCActivityManager
defaultManager
];
[
activityManager
networkActivityStopped
];
[
activityManager
networkActivityStarted
];
self
.
currentDownloadLabel
.
text
=
_humanReadableFilename
;
self
.
progressView
.
progress
=
0
.;
[
self
.
progressPercent
setText
:
@"0%%"
];
...
...
@@ -257,7 +259,7 @@
-
(
void
)
downloadEnded
{
[
(
VLCA
ppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
networkActivityStopped
];
[
[
VLCA
ctivityManager
defaultManager
]
networkActivityStopped
];
_currentDownloadType
=
0
;
APLog
(
@"download ended"
);
self
.
progressContainer
.
hidden
=
YES
;
...
...
Sources/VLCDropboxController.m
View file @
8bb0d9b0
...
...
@@ -14,7 +14,8 @@
#import "VLCDropboxController.h"
#import "NSString+SupportedMedia.h"
#import "VLCPlaybackController.h"
#import "VLCAppDelegate.h"
#import "VLCActivityManager.h"
#import "VLCMediaFileDiscoverer.h"
@interface
VLCDropboxController
()
{
...
...
@@ -163,8 +164,7 @@
-
(
void
)
restClient
:(
DBRestClient
*
)
client
loadedFile
:(
NSString
*
)
localPath
{
/* update library now that we got a file */
VLCAppDelegate
*
appDelegate
=
[
UIApplication
sharedApplication
].
delegate
;
[
appDelegate
performSelectorOnMainThread
:
@selector
(
updateMediaList
)
withObject
:
nil
waitUntilDone
:
NO
];
[[
VLCMediaFileDiscoverer
sharedInstance
]
performSelectorOnMainThread
:
@selector
(
updateMediaList
)
withObject
:
nil
waitUntilDone
:
NO
];
if
([
self
.
delegate
respondsToSelector
:
@selector
(
operationWithProgressInformationStopped
)])
[
self
.
delegate
operationWithProgressInformationStopped
];
...
...
@@ -218,8 +218,9 @@
{
_outstandingNetworkRequests
++
;
if
(
_outstandingNetworkRequests
==
1
)
{
[(
VLCAppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
networkActivityStarted
];
[(
VLCAppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
disableIdleTimer
];
VLCActivityManager
*
activityManager
=
[
VLCActivityManager
defaultManager
];
[
activityManager
networkActivityStarted
];
[
activityManager
disableIdleTimer
];
}
}
...
...
@@ -227,8 +228,9 @@
{
_outstandingNetworkRequests
--
;
if
(
_outstandingNetworkRequests
==
0
)
{
[(
VLCAppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
networkActivityStopped
];
[(
VLCAppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
activateIdleTimer
];
VLCActivityManager
*
activityManager
=
[
VLCActivityManager
defaultManager
];
[
activityManager
networkActivityStopped
];
[
activityManager
activateIdleTimer
];
}
}
...
...
Sources/VLCFTPServerListViewController.m
View file @
8bb0d9b0
...
...
@@ -13,11 +13,12 @@
#import "VLCFTPServerListViewController.h"
#import "VLCNetworkListCell.h"
#import "VLCA
ppDelegate
.h"
#import "VLCA
ctivityManager
.h"
#import "NSString+SupportedMedia.h"
#import "UIDevice+VLC.h"
#import "VLCStatusLabel.h"
#import "VLCPlaybackController.h"
#import "VLCDownloadViewController.h"
#import "WhiteRaccoon.h"
...
...
@@ -78,7 +79,7 @@
_FTPListDirRequest
.
path
=
_ftpServerPath
;
_FTPListDirRequest
.
passive
=
YES
;
[
(
VLCA
ppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
networkActivityStarted
];
[
[
VLCA
ctivityManager
defaultManager
]
networkActivityStarted
];
[
_FTPListDirRequest
start
];
}
...
...
@@ -219,7 +220,7 @@
[
super
tableView
:
tableView
willDisplayCell
:
cell
forRowAtIndexPath
:
indexPath
];
if
([
indexPath
row
]
==
((
NSIndexPath
*
)[[
tableView
indexPathsForVisibleRows
]
lastObject
]).
row
)
[
(
VLCA
ppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
networkActivityStopped
];
[
[
VLCA
ctivityManager
defaultManager
]
networkActivityStopped
];
}
...
...
Sources/VLCGoogleDriveController.m
View file @
8bb0d9b0
...
...
@@ -14,7 +14,7 @@
#import "VLCGoogleDriveController.h"
#import "NSString+SupportedMedia.h"
#import "VLCPlaybackController.h"
#import "VLC
AppDelegate
.h"
#import "VLC
MediaFileDiscoverer
.h"
@interface
VLCGoogleDriveController
()
{
...
...
@@ -293,8 +293,7 @@
{
/* update library now that we got a file */
APLog
(
@"DriveFile download was successful"
);
VLCAppDelegate
*
appDelegate
=
(
VLCAppDelegate
*
)
[
UIApplication
sharedApplication
].
delegate
;
[
appDelegate
performSelectorOnMainThread
:
@selector
(
updateMediaList
)
withObject
:
nil
waitUntilDone
:
NO
];
[[
VLCMediaFileDiscoverer
sharedInstance
]
performSelectorOnMainThread
:
@selector
(
updateMediaList
)
withObject
:
nil
waitUntilDone
:
NO
];
if
([
self
.
delegate
respondsToSelector
:
@selector
(
operationWithProgressInformationStopped
)])
[
self
.
delegate
operationWithProgressInformationStopped
];
...
...
Sources/VLCHTTPConnection.m
View file @
8bb0d9b0
...
...
@@ -13,7 +13,7 @@
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCA
ppDelegate
.h"
#import "VLCA
ctivityManager
.h"
#import "VLCHTTPConnection.h"
#import "MultipartFormDataParser.h"
#import "HTTPMessage.h"
...
...
@@ -440,9 +440,10 @@
APLog
(
@"Could not create file at path: %@"
,
_filepath
);
_storeFile
=
[
NSFileHandle
fileHandleForWritingAtPath
:
_filepath
];
VLCAppDelegate
*
appDelegate
=
[
UIApplication
sharedApplication
].
delegate
;
[
appDelegate
networkActivityStarted
];
[
appDelegate
disableIdleTimer
];
VLCActivityManager
*
activityManager
=
[
VLCActivityManager
defaultManager
];
[
activityManager
networkActivityStarted
];
[
activityManager
disableIdleTimer
];
}
-
(
void
)
notifyUserAboutEndOfFreeStorage
:(
NSString
*
)
filename
...
...
Sources/VLCHTTPFileDownloader.m
View file @
8bb0d9b0
...
...
@@ -13,8 +13,9 @@
#import "VLCHTTPFileDownloader.h"
#import "NSString+SupportedMedia.h"
#import "VLCA
ppDelegate
.h"
#import "VLCA
ctivityManager
.h"
#import "UIDevice+VLC.h"
#import "VLCMediaFileDiscoverer.h"
@interface
VLCHTTPFileDownloader
()
{
...
...
@@ -63,9 +64,9 @@
_downloadInProgress
=
NO
;
}
else
{
_downloadInProgress
=
YES
;
VLCA
ppDelegate
*
appDelegate
=
[
UIApplication
sharedApplication
].
delegate
;
[
a
ppDelegate
networkActivityStarted
];
[
a
ppDelegate
disableIdleTimer
];
VLCA
ctivityManager
*
activityManager
=
[
VLCActivityManager
defaultManager
]
;
[
a
ctivityManager
networkActivityStarted
];
[
a
ctivityManager
disableIdleTimer
];
}
}
...
...
@@ -199,9 +200,9 @@
-
(
void
)
_downloadEnded
{
_downloadInProgress
=
NO
;
VLCA
ppDelegate
*
appDelegate
=
[
UIApplication
sharedApplication
].
delegate
;
[
a
ppDelegate
networkActivityStopped
];
[
a
ppDelegate
activateIdleTimer
];
VLCA
ctivityManager
*
activityManager
=
[
VLCActivityManager
defaultManager
]
;
[
a
ctivityManager
networkActivityStopped
];
[
a
ctivityManager
activateIdleTimer
];
NSArray
*
searchPaths
=
NSSearchPathForDirectoriesInDomains
(
NSDocumentDirectory
,
NSUserDomainMask
,
YES
);
NSString
*
libraryPath
=
searchPaths
[
0
];
...
...
@@ -211,7 +212,7 @@
if
([
fileManager
fileExistsAtPath
:
_filePath
])
{
[
fileManager
moveItemAtPath
:
_filePath
toPath
:
finalFilePath
error
:
nil
];
[
appDelegate
performSelectorOnMainThread
:
@selector
(
updateMediaList
)
withObject
:
nil
waitUntilDone
:
NO
];
[
[
VLCMediaFileDiscoverer
sharedInstance
]
performSelectorOnMainThread
:
@selector
(
updateMediaList
)
withObject
:
nil
waitUntilDone
:
NO
];
}
[
self
.
delegate
downloadEnded
];
...
...
Sources/VLCHTTPUploaderController.h
View file @
8bb0d9b0
...
...
@@ -27,5 +27,6 @@
-
(
NSString
*
)
hostname
;
-
(
void
)
moveFileFrom
:(
NSString
*
)
filepath
;
-
(
void
)
cleanCache
;
@end
Sources/VLCHTTPUploaderController.m
View file @
8bb0d9b0
...
...
@@ -13,10 +13,10 @@
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCAppDelegate.h"
#import "VLCHTTPUploaderController.h"
#import "VLCHTTPConnection.h"
#import "VLCActivityManager.h"
#import "VLCMediaFileDiscoverer.h"
#import "HTTPServer.h"
#import <ifaddrs.h>
...
...
@@ -88,7 +88,7 @@
return
true
;
}
// clean cache before accepting new stuff
[
(
VLCAppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
cleanCache
];
[
self
cleanCache
];
// Initialize our http server
_httpServer
=
[[
HTTPServer
alloc
]
init
];
...
...
@@ -206,10 +206,22 @@
}
/* update media library when file upload was completed */
VLCAppDelegate
*
appDelegate
=
[
UIApplication
sharedApplication
].
delegate
;
[
appDelegate
networkActivityStopped
];
[
appDelegate
activateIdleTimer
];
[
appDelegate
performSelectorOnMainThread
:
@selector
(
updateMediaList
)
withObject
:
nil
waitUntilDone
:
NO
];
VLCActivityManager
*
activityManager
=
[
VLCActivityManager
defaultManager
];
[
activityManager
networkActivityStopped
];
[
activityManager
activateIdleTimer
];
[[
VLCMediaFileDiscoverer
sharedInstance
]
performSelectorOnMainThread
:
@selector
(
updateMediaList
)
withObject
:
nil
waitUntilDone
:
NO
];
}
-
(
void
)
cleanCache
{
if
([[
VLCActivityManager
defaultManager
]
haveNetworkActivity
])
return
;
NSArray
*
searchPaths
=
NSSearchPathForDirectoriesInDomains
(
NSCachesDirectory
,
NSUserDomainMask
,
YES
);
NSString
*
uploadDirPath
=
[
searchPaths
[
0
]
stringByAppendingPathComponent
:
@"Upload"
];
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
if
([
fileManager
fileExistsAtPath
:
uploadDirPath
])
[
fileManager
removeItemAtPath
:
uploadDirPath
error
:
nil
];
}
@end
Sources/VLCKeychainCoordinator.m
View file @
8bb0d9b0
...
...
@@ -41,7 +41,6 @@ NSString *const VLCPasscode = @"org.videolan.vlc-ios.passcode";
return
sharedInstance
;
}
-
(
NSString
*
)
_obtainPasscode
{
NSString
*
passcode
=
[
SSKeychain
passwordForService
:
VLCPasscode
account
:
VLCPasscode
];
...
...
Sources/VLCMediaFileDiscoverer.h
View file @
8bb0d9b0
...
...
@@ -28,9 +28,11 @@
-
(
void
)
addObserver
:(
id
<
VLCMediaFileDiscovererDelegate
>
)
delegate
;
-
(
void
)
removeObserver
:(
id
<
VLCMediaFileDiscovererDelegate
>
)
delegate
;
-
(
void
)
startDiscovering
:(
NSString
*
)
directoryPath
;
-
(
void
)
startDiscovering
;
-
(
void
)
stopDiscovering
;
-
(
void
)
updateMediaList
;
+
(
instancetype
)
sharedInstance
;
@end
Sources/VLCMediaFileDiscoverer.m