1/* 2 * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free 16 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301 USA 18 */ 19 20#include "config.h" 21#if ENABLE(FILE_SYSTEM) 22#include "AsyncFileSystemBlackBerry.h" 23 24#include "AsyncFileSystemCallbacks.h" 25#include "AsyncFileWriterBlackBerry.h" 26#include "AsyncFileWriterClient.h" 27#include "DOMFileSystemBase.h" 28#include "ExceptionCode.h" 29#include "KURL.h" 30#include "NotImplemented.h" 31#include "PlatformAsyncFileSystemCallbacks.h" 32#include "ScriptExecutionContext.h" 33#include "SecurityOrigin.h" 34 35#include <wtf/text/CString.h> 36#include <wtf/text/StringBuilder.h> 37 38namespace WebCore { 39 40bool AsyncFileSystem::isAvailable() 41{ 42 return true; 43} 44 45// We don't use this one! 46PassOwnPtr<AsyncFileSystem> AsyncFileSystem::create() 47{ 48 ASSERT_NOT_REACHED(); 49 return PassOwnPtr<AsyncFileSystem>(); 50} 51 52// We don't use this one! 53void AsyncFileSystem::openFileSystem(const String& basePath, const String& storageIdentifier, FileSystemType, bool, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 54{ 55 UNUSED_PARAM(basePath); 56 UNUSED_PARAM(storageIdentifier); 57 UNUSED_PARAM(callbacks); 58 ASSERT_NOT_REACHED(); 59} 60 61void AsyncFileSystemBlackBerry::openFileSystem(const KURL& rootURL, const String& basePath, const String& storageIdentifier, FileSystemType type, long long size, bool create, int playerId, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 62{ 63 BlackBerry::Platform::WebFileSystem::openFileSystem(BlackBerry::Platform::webKitThreadMessageClient(), basePath, storageIdentifier, static_cast<BlackBerry::Platform::WebFileSystem::Type>(type), size, create, new PlatformAsyncFileSystemCallbacks(callbacks, rootURL), playerId); 64} 65 66void AsyncFileSystem::deleteFileSystem(const String& basePath, const String& storageIdentifier, FileSystemType type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 67{ 68 BlackBerry::Platform::WebFileSystem::deleteFileSystem(BlackBerry::Platform::webKitThreadMessageClient(), basePath, storageIdentifier, static_cast<BlackBerry::Platform::WebFileSystem::Type>(type), new PlatformAsyncFileSystemCallbacks(callbacks)); 69} 70 71AsyncFileSystemBlackBerry::AsyncFileSystemBlackBerry(PassOwnPtr<BlackBerry::Platform::WebFileSystem> platformFileSystem) 72 : AsyncFileSystem() // FIXME: type ??? 73 , m_platformFileSystem(platformFileSystem) 74{ 75} 76 77AsyncFileSystemBlackBerry::~AsyncFileSystemBlackBerry() 78{ 79} 80 81void AsyncFileSystemBlackBerry::move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 82{ 83 m_platformFileSystem->move(fileSystemURLToPath(sourcePath), fileSystemURLToPath(destinationPath), new PlatformAsyncFileSystemCallbacks(callbacks)); 84} 85 86void AsyncFileSystemBlackBerry::copy(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 87{ 88 m_platformFileSystem->copy(fileSystemURLToPath(sourcePath), fileSystemURLToPath(destinationPath), new PlatformAsyncFileSystemCallbacks(callbacks)); 89} 90 91void AsyncFileSystemBlackBerry::remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 92{ 93 m_platformFileSystem->remove(fileSystemURLToPath(path), new PlatformAsyncFileSystemCallbacks(callbacks)); 94} 95 96void AsyncFileSystemBlackBerry::removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 97{ 98 m_platformFileSystem->removeRecursively(fileSystemURLToPath(path), new PlatformAsyncFileSystemCallbacks(callbacks)); 99} 100 101void AsyncFileSystemBlackBerry::readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 102{ 103 m_platformFileSystem->readMetadata(fileSystemURLToPath(path), new PlatformAsyncFileSystemCallbacks(callbacks)); 104} 105 106void AsyncFileSystemBlackBerry::createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 107{ 108 m_platformFileSystem->createFile(fileSystemURLToPath(path), exclusive, new PlatformAsyncFileSystemCallbacks(callbacks)); 109} 110 111void AsyncFileSystemBlackBerry::createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 112{ 113 m_platformFileSystem->createDirectory(fileSystemURLToPath(path), exclusive, new PlatformAsyncFileSystemCallbacks(callbacks)); 114} 115 116void AsyncFileSystemBlackBerry::fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 117{ 118 m_platformFileSystem->fileExists(fileSystemURLToPath(path), new PlatformAsyncFileSystemCallbacks(callbacks)); 119} 120 121void AsyncFileSystemBlackBerry::directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 122{ 123 m_platformFileSystem->directoryExists(fileSystemURLToPath(path), new PlatformAsyncFileSystemCallbacks(callbacks)); 124} 125 126void AsyncFileSystemBlackBerry::readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 127{ 128 m_platformFileSystem->readDirectory(fileSystemURLToPath(path), new PlatformAsyncFileSystemCallbacks(callbacks)); 129} 130 131void AsyncFileSystemBlackBerry::createWriter(AsyncFileWriterClient* client, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 132{ 133 BlackBerry::Platform::WebFileWriter::createWriter(m_platformFileSystem.get(), fileSystemURLToPath(path), new PlatformAsyncFileSystemCallbacks(callbacks, client)); 134} 135 136void AsyncFileSystemBlackBerry::createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 137{ 138 m_platformFileSystem->createSnapshotFileAndReadMetadata(fileSystemURLToPath(path), new PlatformAsyncFileSystemCallbacks(callbacks)); 139} 140 141String AsyncFileSystemBlackBerry::fileSystemURLToPath(const KURL& url) 142{ 143 FileSystemType type; 144 String fullPath; 145 bool result = DOMFileSystemBase::crackFileSystemURL(url, type, fullPath); 146 ASSERT_UNUSED(result, result); 147 return fullPath; 148} 149 150} // namespace WebCore 151 152#endif // ENABLE(FILE_SYSTEM) 153