From: Pawel Andruszkiewicz Date: Fri, 30 Oct 2015 10:50:26 +0000 (+0100) Subject: [File] Added stubs for all methods that need to be implemented. X-Git-Tag: submit/tizen/20151221.111205^2~73 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f1f0817f1f44b6af44300831f37b35697aaf495b;p=platform%2Fcore%2Fapi%2Fcordova-plugins.git [File] Added stubs for all methods that need to be implemented. Change-Id: Iff1871157e30502011fb876227a913cee6eb3f3e Signed-off-by: Pawel Andruszkiewicz --- diff --git a/src/file/cordova_file_api.js b/src/file/cordova_file_api.js index bd704f6..0df4c7a 100755 --- a/src/file/cordova_file_api.js +++ b/src/file/cordova_file_api.js @@ -14,33 +14,14 @@ * limitations under the License. */ -// TODO: remove when added to public cordova repository -> begin -var plugin_name = 'cordova-plugin-file.tizen.File'; - -cordova.define(plugin_name, function(require, exports, module) { -// TODO: remove -> end - -var pathsPrefix = { - // TODO: add other directories - // Read-only directory where the application is installed. - applicationDirectory: 'wgt-package/' -}; - -exports.requestAllPaths = function(successCallback) { - successCallback(pathsPrefix); -}; - -require("cordova/exec/proxy").add("File", exports); - -console.log('Loaded cordova.file API'); - -// TODO: remove when added to public cordova repository -> begin -}); - -exports = function(require) { - // this plugin is not loaded via cordova_plugins.js, we need to manually add - // it to module mapper - var mm = require('cordova/modulemapper'); - mm.runs(plugin_name); -}; -//TODO: remove -> end +//= require('DirectoryEntry.js'); +//= require('DirectoryReader.js'); +//= require('Entry.js'); +//= require('FileReader.js'); +//= require('fileSystemPaths.js'); +//= require('fileSystems-roots.js'); +//= require('FileWriter.js'); +//= require('requestFileSystem.js'); +//= require('resolveLocalFileSystemURI.js'); + +//= require('File.js'); diff --git a/src/file/js/DirectoryEntry.js b/src/file/js/DirectoryEntry.js new file mode 100644 index 0000000..f52ebc6 --- /dev/null +++ b/src/file/js/DirectoryEntry.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: remove when added to public cordova repository -> begin +cordova.define('cordova-plugin-file.tizen.DirectoryEntry', function(require, exports, module) { +// TODO: remove -> end + +module.exports = { + getDirectory: function(successCallback, errorCallback, args) {}, + removeRecursively: function(successCallback, errorCallback, args) {}, + getFile: function(successCallback, errorCallback, args) {} +}; + +//TODO: remove when added to public cordova repository -> begin +}); +//TODO: remove -> end diff --git a/src/file/js/DirectoryReader.js b/src/file/js/DirectoryReader.js new file mode 100644 index 0000000..0446ce4 --- /dev/null +++ b/src/file/js/DirectoryReader.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: remove when added to public cordova repository -> begin +cordova.define('cordova-plugin-file.tizen.DirectoryReader', function(require, exports, module) { +// TODO: remove -> end + +module.exports = { + readEntries: function(successCallback, errorCallback, args) {} +}; + +//TODO: remove when added to public cordova repository -> begin +}); +//TODO: remove -> end diff --git a/src/file/js/Entry.js b/src/file/js/Entry.js new file mode 100644 index 0000000..1d044c3 --- /dev/null +++ b/src/file/js/Entry.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: remove when added to public cordova repository -> begin +cordova.define('cordova-plugin-file.tizen.Entry', function(require, exports, module) { +// TODO: remove -> end + +module.exports = { + getFileMetadata: function(successCallback, errorCallback, args) {}, + setMetadata: function(successCallback, errorCallback, args) {}, + moveTo: function(successCallback, errorCallback, args) {}, + copyTo: function(successCallback, errorCallback, args) {}, + remove: function(successCallback, errorCallback, args) {}, + getParent: function(successCallback, errorCallback, args) {} +}; + +//TODO: remove when added to public cordova repository -> begin +}); +//TODO: remove -> end diff --git a/src/file/js/File.js b/src/file/js/File.js new file mode 100644 index 0000000..b342f45 --- /dev/null +++ b/src/file/js/File.js @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: remove when added to public cordova repository -> begin +var plugin_name = 'cordova-plugin-file.tizen.File'; + +cordova.define(plugin_name, function(require, exports, module) { +// TODO: remove -> end + +var modules = [ + 'DirectoryEntry', + 'DirectoryReader', + 'Entry', + 'FileReader', + 'fileSystemPaths', + 'fileSystems-roots', + 'FileWriter', + 'requestFileSystem', + 'resolveLocalFileSystemURI' +]; + +// merge methods from submodules into this one +for (var i = 0; i < modules.length; ++i) { + var m = require('cordova-plugin-file.tizen.' + modules[i]); + for (var prop in m) { + if (m.hasOwnProperty(prop)) { + exports[prop] = m[prop]; + } + } +} + +require("cordova/exec/proxy").add("File", exports); + +console.log('Loaded cordova.file API'); + +//TODO: remove when added to public cordova repository -> begin +}); + +exports = function(require) { + // this plugin is not loaded via cordova_plugins.js, we need to manually add + // it to module mapper + var mm = require('cordova/modulemapper'); + mm.runs(plugin_name); +}; +//TODO: remove -> end diff --git a/src/file/js/FileReader.js b/src/file/js/FileReader.js new file mode 100644 index 0000000..5a90dad --- /dev/null +++ b/src/file/js/FileReader.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: remove when added to public cordova repository -> begin +cordova.define('cordova-plugin-file.tizen.FileReader', function(require, exports, module) { +// TODO: remove -> end + +module.exports = { + readAsText: function(successCallback, errorCallback, args) {}, + readAsDataURL: function(successCallback, errorCallback, args) {}, + readAsBinaryString: function(successCallback, errorCallback, args) {}, + readAsArrayBuffer: function(successCallback, errorCallback, args) {}, +}; + +//TODO: remove when added to public cordova repository -> begin +}); +//TODO: remove -> end diff --git a/src/file/js/FileWriter.js b/src/file/js/FileWriter.js new file mode 100644 index 0000000..7782fef --- /dev/null +++ b/src/file/js/FileWriter.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: remove when added to public cordova repository -> begin +cordova.define('cordova-plugin-file.tizen.FileWriter', function(require, exports, module) { +// TODO: remove -> end + +module.exports = { + write: function(successCallback, errorCallback, args) {}, + truncate: function(successCallback, errorCallback, args) {} +}; + +//TODO: remove when added to public cordova repository -> begin +}); +//TODO: remove -> end diff --git a/src/file/js/fileSystemPaths.js b/src/file/js/fileSystemPaths.js new file mode 100644 index 0000000..9de990c --- /dev/null +++ b/src/file/js/fileSystemPaths.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: remove when added to public cordova repository -> begin +cordova.define('cordova-plugin-file.tizen.fileSystemPaths', function(require, exports, module) { +// TODO: remove -> end + +var pathsPrefix = { + // TODO: add other directories + // Read-only directory where the application is installed. + applicationDirectory: 'wgt-package/' +}; + +module.exports = { + requestAllPaths: function(successCallback, errorCallback, args) { + successCallback(pathsPrefix); + } +}; + +//TODO: remove when added to public cordova repository -> begin +}); +//TODO: remove -> end diff --git a/src/file/js/fileSystems-roots.js b/src/file/js/fileSystems-roots.js new file mode 100644 index 0000000..6b85f63 --- /dev/null +++ b/src/file/js/fileSystems-roots.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: remove when added to public cordova repository -> begin +cordova.define('cordova-plugin-file.tizen.fileSystems-roots', function(require, exports, module) { +// TODO: remove -> end + +var info = (function() { + var roots_to_resolve = [ + { + filesystemName: 'temporary', + name: '', + fullPath: '', + nativeURL: 'wgt-private-tmp' + }, + { + filesystemName: 'persistent', + name: '', + fullPath: '', + nativeURL: 'wgt-private' + } + ]; + + var roots = [ + { + filesystemName: 'root', + name: '', + fullPath: 'file:///', + nativeURL: '/' + } + ]; + + function getRoots(successCallback) { + if (roots_to_resolve.length > 0) { + tizen.filesystem.resolve(roots_to_resolve[0].nativeURL, function(dir) { + roots_to_resolve[0].fullPath = dir.toURI(); + roots_to_resolve[0].name = roots_to_resolve[0].fullPath.replace(/^.*(\\|\/|\:)/, ''); // extract name of the directory + roots.push(roots_to_resolve[0]); + roots_to_resolve.splice(0, 1); // remove first item + + // we've resolved one root, check if there are any other + getRoots(successCallback); + }, function(e) { + console.error(e); + // in case of an error, return the roots we have so far + successCallback(roots); + }); + } else { + successCallback(roots.slice()); + } + } + + return { + getRoots: getRoots + }; +})(); + +module.exports = { + requestAllFileSystems: function(successCallback, errorCallback, args) { + info.getRoots(successCallback); + } +}; + +//TODO: remove when added to public cordova repository -> begin +}); +//TODO: remove -> end diff --git a/src/file/js/requestFileSystem.js b/src/file/js/requestFileSystem.js new file mode 100644 index 0000000..6c3e774 --- /dev/null +++ b/src/file/js/requestFileSystem.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: remove when added to public cordova repository -> begin +cordova.define('cordova-plugin-file.tizen.requestFileSystem', function(require, exports, module) { +// TODO: remove -> end + +module.exports = { + requestFileSystem: function(successCallback, errorCallback, args) {} +}; + +//TODO: remove when added to public cordova repository -> begin +}); +//TODO: remove -> end diff --git a/src/file/js/resolveLocalFileSystemURI.js b/src/file/js/resolveLocalFileSystemURI.js new file mode 100644 index 0000000..1918101 --- /dev/null +++ b/src/file/js/resolveLocalFileSystemURI.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO: remove when added to public cordova repository -> begin +cordova.define('cordova-plugin-file.tizen.resolveLocalFileSystemURI', function(require, exports, module) { +// TODO: remove -> end + +module.exports = { + resolveLocalFileSystemURI: function(successCallback, errorCallback, args) {} +}; + +//TODO: remove when added to public cordova repository -> begin +}); +//TODO: remove -> end