summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm
Commit message (Collapse)AuthorAgeFilesLines
* iOS: only force-finish start-up from file engine when on main threadRichard Moe Gustavsen2015-11-091-14/+26
| | | | | | | | | | | | | | | | | | The authorization dialog that grants the application access to the assets will only show after returning back from applicationDidFinishLaunching. Therefore, trying to load an asset from main before qApp->exec() would normally fail. To remedy that, we added a path that starts a QEventLoop for a split second to force the application init process to finish. But this can only work if we start it from the main thread. A bug with this is seen in QML FileDialog, since it (clumsy enough) starts to iterate, in a separate thread, all the files in its currently set directory upon start-up construction (which should be fixed as well). The result is that the application gets dead-locked on start-up. Change-Id: I0047272d53314752903960b33f88b33dc0d7e78d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* iOS: add missing Q_DECL_OVERRIDERichard Moe Gustavsen2015-07-271-1/+1
| | | | | | | Add missing Q_DECL_OVERRIDE to silence clang. Change-Id: I57261a39f0dcf4e0ffd8d9c079a95f2d3347d34a Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
* iOS: handle loading assets with different format than jpgRichard Moe Gustavsen2015-06-101-2/+2
| | | | | | | | | | | | The current implementation assumed that the image format of the file loaded would be jpg. This has proven not to be correct, e.g sometimes the format is png. This patch will change how the image url is reconstructed so we doesn't loose/hard code the format. Change-Id: I22d8ca0108e52d3670c2601f0bb9255406b896cf Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* ios: change file engine caching logic for loading assetsRichard Moe Gustavsen2015-05-101-18/+9
| | | | | | | | | | | | | | | | The current caching strategy had a flaw in that it tried to lazy-lock the mutex only if g_currentAssetData was non-zero. For this to be somewhat reliable, g_currentAssetData would have to be volatile. But that would still not be enough since thread-unaware code optimizations might also happen on the CPU level. Instead of complicating the current logic more, change it to only do caching per thread. Since QThreadStorage will take ownership of its data, we can't let it store a pointer to QIOSAssetData directly since we need to control the life time of QIOSAssetData using deleteLater. Change-Id: I2c3ffb3257ec2bdec8be71a3d63f666ab33b5277 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* ios: factor out authorization checkRichard Moe Gustavsen2015-05-061-29/+32
| | | | | | | | | | | | | Factor out the check since it's needed both when loading assets and when creating an entry list. Note that the file flags returned from the file engine will report if the asset is not readable due to authorization status, so we don't need to check this again when trying to load. Change-Id: I77ebbc370f0a7a6020ed484e53ece32bc7fa51bd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* ios: add support for fetching entry list in QIOSFileEngineAssetsLibraryRichard Moe Gustavsen2015-05-061-4/+72
| | | | | | | | | | | This patch will implement support for listing all available pictures on the device by e.g doing: QDir dir(QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).last()); QStringList list = dir.entryList(); Change-Id: I52a07ba48e074bc6e509f2ed3afc3dfea17abc5d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* ios: add fallback in QIOSFileEngineAssetsLibrary for loading assets from ↵Richard Moe Gustavsen2015-05-061-0/+20
| | | | | | | | | | | | | | | | | | ALAssetsGroupPhotoStream [ALAssetsLibrary assetForUrl:] will not load assets coming from ALAssetsGroupPhotoStream. Such assets can be stored in the cloud and might need to be downloaded first. Unfortunately, forcing that to happen is hidden behind private APIs ([ALAsset requestDefaultRepresentation]). So if the user through QIOSFileDialog opens the photo stream folder and chooses a photo inside it, QIOSFileEngineAssetsLibrary will fail loading it. This patch implements a work-around that basically asks ALAssetLibrary to enumerate all assets in the photo library, and stop once we find an asset with the correct url. At that point we also have a pointer to a ALAsset that can be used for loading. This is off course a slow way of loading an asset, but at least better than not being able to load it at all. Change-Id: Ie50344974f043f909ee94fa12e7eb4a40a666c7f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* ios: add helper class for enumerating all available assetsRichard Moe Gustavsen2015-05-061-0/+116
| | | | | | | | | | | Add support for enumerating all available assets on the device. Trailing patches will use the class to fetch a list of all available assets for directory listing, and to search for assets that cannot be loaded by [ALAssetsLibrary assetForURL:]. Change-Id: I319721b536b14424fc8f54f683513aa7ca64e7f0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* ios: report correct file flags for assets 'directory'Richard Moe Gustavsen2015-05-061-2/+5
| | | | | | | | | | If the asset url indicates that this file engine points to the asset folder, report the file as a directory. Also, if the app is authorized to access assets, report that the directory has read access. Change-Id: Ic8f656fa30a1b2a0ec6402e8b19256bdf5f7345e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* ios: don't report read access to assets if unauthorized accessRichard Moe Gustavsen2015-05-061-2/+5
| | | | | | | | | | Don't report read access to assets if we know that we are unauthorized to load them. Note that if authorization is ALAuthorizationStatusNotDetermined we continue to report read access, since we don't really know the permissions until we try to load. Change-Id: If51cfe9f5c57f8f33f463bddf81a77fade5fb89d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* ios: resolve m_assetUrl already in QIOSFileEngineAssetsLibrary::setFileName()Richard Moe Gustavsen2015-05-061-14/+12
| | | | | | | | | | | | | Resolve m_assetUrl already when setting file name. The variable will be used several places in patches that follows. At the same time, change the logic to be more robust to work around QDir removing slashes (both single a double) after the scheme. In the end, what matters is that we still recognize the file name as an asset url, and that we can restore the original url based on the hash-tag contained inside the file name. Change-Id: I988c6a73b2484e46d63917b442c13aa5a3666787 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* iOS: return file urls rather than asset urls from file dialogRichard Moe Gustavsen2015-03-151-7/+17
| | | | | | | | | | | | We need to pass the asset url around as a file url in the application, so that QUrl::fromLocalFile()/toLocalFile() works. Note that QUrl::fromLocalFile() will remove double slashes. We therefore need to check for this, and restore missing slashes, when loading files in the file engine. Change-Id: I2de6b91d7a112354590cf2981f7b403eacf92a59 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* Fix license headersSergio Ahumada2015-02-161-22/+14
| | | | | Change-Id: I964ca9d3aff1a1cbe39dc53d04a408c754e96a77 Reviewed-by: Jani Heikkinen <jani.heikkinen@theqtcompany.com>
* iOS: add a file engine to support loading assets/photosRichard Moe Gustavsen2015-02-151-0/+253
This patch will add a new file engine that lets the app load images from the asset library using QFile. The engine will recognize file names with the scheme 'assets-library', which is the same scheme returned by UIImagePickerController. This patch will be the first of a set of patches that lets the user open a native image picker dialog by using a QFileDialog with directory set to QStandardPaths::PictureLocation. This patch will ensure that the url returned from the dialog can be loaded using QFile. AssetsLibrary, which is used in this patch, is actually deprecated in favor of the new Photos framework. But since the latter is only supported from iOS8, we choose to use the former framework for now. Change-Id: If2a6eb394ae4df55fb4e9e1dc245a1574d38618a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>