From ce322a2d1b13c55b6b935c26d980c028702dc399 Mon Sep 17 00:00:00 2001 From: Rafal Galka Date: Mon, 16 Mar 2015 10:44:07 +0100 Subject: [PATCH] [tizen] WebAPI{Exception|Error} constructors exported into global scope. For compliance reasons constructors should not be exported into tizen namespace, but should be available internally to allow throwing exceptions from modules. Change related to http://168.219.209.56/gerrit/#/c/23472/ [Verification] TCT pass rate: - tizen 77/81 (all WebAPIException related TCs should pass) - other modules - results without change Change-Id: I58e5dc9932b24afc8516a37564ac1497618e709f --- src/account/account_api.js | 6 +- src/application/application_api.js | 8 +- src/archive/archive_api.js | 32 +++--- src/badge/badge_api.js | 10 +- src/bluetooth/bluetooth_api.js | 2 +- src/bookmark/bookmark_api.js | 28 ++--- src/calendar/js/calendar.js | 12 +- src/calendar/js/calendar_item.js | 14 +-- src/calendar/js/calendar_manager.js | 2 +- src/callhistory/callhistory_api.js | 6 +- src/contact/js/address_book.js | 12 +- src/contact/js/contact.js | 6 +- src/contact/js/contact_manager.js | 20 ++-- src/contact/js/person.js | 4 +- src/content/content_api.js | 162 +++++++++++++-------------- src/datacontrol/datacontrol_api.js | 20 ++-- src/download/download_api.js | 20 ++-- src/exif/exif_api.js | 22 ++-- src/filesystem/js/file.js | 104 ++++++++--------- src/filesystem/js/file_stream.js | 46 ++++---- src/filesystem/js/file_system_manager.js | 12 +- src/messageport/messageport_api.js | 36 +++--- src/messaging/messaging_api.js | 34 +++--- src/nfc/nfc_api.js | 36 +++--- src/notification/notification_api.js | 12 +- src/package/package_api.js | 4 +- src/power/power_api.js | 78 ++++++------- src/radio/radio_api.js | 4 +- src/sensor/sensor_api.js | 6 +- src/sound/sound_api.js | 2 +- src/systeminfo/systeminfo_api.js | 10 +- src/systemsetting/systemsetting_api.js | 2 +- src/time/time_api.js | 12 +- src/tizen/tizen_api.js | 186 ++----------------------------- src/tvaudio/tvaudio_api.js | 4 +- src/tvchannel/tvchannel_api.js | 4 +- src/tvdisplay/tvdisplay_api.js | 2 +- src/utils/utils_api.js | 77 +++++++------ 38 files changed, 450 insertions(+), 607 deletions(-) diff --git a/src/account/account_api.js b/src/account/account_api.js index 6472941..fde5a78 100644 --- a/src/account/account_api.js +++ b/src/account/account_api.js @@ -35,7 +35,7 @@ function AccountProvider(data) { displayName: { enumerable: true, writable: false, value: data.displayName }, iconUri: { enumerable: true, writable: false, value: data.iconUri }, smallIconUri: { enumerable: true, writable: false, value: data.smallIconUri }, - capabilities: { enumerable: true, + capabilities: { enumerable: true, set: function() {}, get: function() { return internal_; } }, @@ -125,7 +125,7 @@ Account.prototype.getExtendedData = function() { ]); var result = native_.callSync('Account_getExtendedDataSync', - { + { accountId: this.id, key: args.key } @@ -236,7 +236,7 @@ AccountManager.prototype.getAccounts = function() { // TODO handling exceptions native_.call('AccountManager_getAccounts', - { + { applicationId: args.applicationId }, function(result) { diff --git a/src/application/application_api.js b/src/application/application_api.js index 350cfe3..42b9950 100644 --- a/src/application/application_api.js +++ b/src/application/application_api.js @@ -28,7 +28,7 @@ function callNative(cmd, args) { var result = JSON.parse(resultString); if (typeof result !== 'object') { - throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR); + throw new WebAPIException(WebAPIException.UNKNOWN_ERR); } if (result['status'] === 'success') { @@ -39,7 +39,7 @@ function callNative(cmd, args) { } else if (result['status'] === 'error') { var err = result['error']; if (err) { - throw new tizen.WebAPIException(err.name, err.message); + throw new WebAPIException(err.name, err.message); } return false; } @@ -543,7 +543,7 @@ tizen.ApplicationControlData = function(key, value) { defineReadWriteNonNullProperty(this, 'key', key); defineReadWriteNonNullProperty(this, 'value', value); } else { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } }; @@ -558,7 +558,7 @@ tizen.ApplicationControl = function(operation, uri, mime, category, data) { defineReadWriteProperty(this, 'data', data); } else { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } }; diff --git a/src/archive/archive_api.js b/src/archive/archive_api.js index fd47659..76ce450 100644 --- a/src/archive/archive_api.js +++ b/src/archive/archive_api.js @@ -67,7 +67,7 @@ CommonFS.toRealPath = function(aPath) { } console.log("REAL PATH:" + _fileRealPath); if (_fileRealPath === "undefined" || _fileRealPath === "null") { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } return _fileRealPath; }; @@ -135,7 +135,7 @@ function propertyFactory_(that, name, value, flags, options) { function checkMode(mode, access) { if(access.indexOf(mode) == -1) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_ACCESS_ERR, 'Not allowed operation'); + throw new WebAPIException(WebAPIException.INVALID_ACCESS_ERR, 'Not allowed operation'); } } @@ -161,7 +161,7 @@ function ArchiveFileEntry(data, priv) { } if (data === null || typeof data !== 'object') { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } propertyFactory_(this, 'name', data.name || "", Property.E); @@ -172,7 +172,7 @@ function ArchiveFileEntry(data, priv) { function getHandle() { if(priv.handle) return priv.handle; - else throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR, 'Archive is not opened'); + else throw new WebAPIException(WebAPIException.UNKNOWN_ERR, 'Archive is not opened'); } /** @@ -190,7 +190,7 @@ function ArchiveFileEntry(data, priv) { opId = getNextOpId(); if (!CommonFS.isVirtualPath(args.destinationDirectory)) //TODO: add FileReferece validation - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, "Destination directory should be virtual path or file."); bridge.async({ cmd: 'ArchiveFileEntry_extract', @@ -212,7 +212,7 @@ function ArchiveFileEntry(data, priv) { if (args.onerror) { args.onerror.call( null, - new tizen.WebAPIException(e) + new WebAPIException(e) ); } }, @@ -248,7 +248,7 @@ function ArchiveFile(data) { } if (data === null || typeof data !== 'object') { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } propertyFactory_(this, 'mode' , data.mode || "r", Property.E); @@ -259,7 +259,7 @@ function ArchiveFile(data) { function getHandle() { if(priv.handle) return priv.handle; - else throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_STATE_ERR, 'ArchiveFile closed - operation not permitted'); + else throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'ArchiveFile closed - operation not permitted'); } /** @@ -276,7 +276,7 @@ function ArchiveFile(data) { opId = getNextOpId(); if (!CommonFS.isVirtualPath(args.sourceFile)) //TODO: add FileReferece validation - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, "sourceFile should be virtual path or file."); var optionsAttributes = ["destination", "stripSourceDirectory", "compressionLevel"], @@ -307,7 +307,7 @@ function ArchiveFile(data) { if (args.onerror) { args.onerror.call( null, - new tizen.WebAPIException(e) + new WebAPIException(e) ); } }, @@ -340,7 +340,7 @@ function ArchiveFile(data) { opId = getNextOpId(); if (!CommonFS.isVirtualPath(args.destinationDirectory)) //TODO: add FileReferece validation - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, "destinationDirectory should be virtual path or file."); checkMode(this.mode, ["r","rw"]); @@ -362,7 +362,7 @@ function ArchiveFile(data) { if (args.onerror) { args.onerror.call( null, - new tizen.WebAPIException(e) + new WebAPIException(e) ); } }, @@ -410,7 +410,7 @@ function ArchiveFile(data) { if (args.onerror) { args.onerror.call( null, - new tizen.WebAPIException(e) + new WebAPIException(e) ); } } @@ -446,7 +446,7 @@ function ArchiveFile(data) { if (args.onerror) { args.onerror.call( null, - new tizen.WebAPIException(e) + new WebAPIException(e) ); } } @@ -499,7 +499,7 @@ ArchiveManager.prototype.open = function () { } if (!CommonFS.isVirtualPath(args.file)) //TODO: add FileReferece validation - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, "file should be virtual path or file."); bridge.async({ @@ -518,7 +518,7 @@ ArchiveManager.prototype.open = function () { if (args.onerror) { args.onerror.call( null, - new tizen.WebAPIException(e) + new WebAPIException(e) ); } } diff --git a/src/badge/badge_api.js b/src/badge/badge_api.js index 7d49290..c154ce6 100644 --- a/src/badge/badge_api.js +++ b/src/badge/badge_api.js @@ -47,7 +47,7 @@ function BadgeManager() { */ BadgeManager.prototype.setBadgeCount = function() { if (arguments.length < 2) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'incorrect number of arguments'); var args = validator_.validateArgs(arguments, [ @@ -56,7 +56,7 @@ BadgeManager.prototype.setBadgeCount = function() { ]); if (args.count < 0) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Count parameter is negative!'); var ret = native_.callSync('BadgeManager_setBadgeCount', { @@ -76,7 +76,7 @@ BadgeManager.prototype.setBadgeCount = function() { */ BadgeManager.prototype.getBadgeCount = function() { if (arguments.length < 1) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'incorrect number of arguments'); var args = validator_.validateArgs(arguments, [ {name: 'appId', type: types_.STRING} @@ -99,7 +99,7 @@ BadgeManager.prototype.getBadgeCount = function() { */ BadgeManager.prototype.addChangeListener = function() { if (arguments.length < 2) - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'incorrect number of arguments'); var args = validator_.validateArgs(arguments, [ { @@ -141,7 +141,7 @@ BadgeManager.prototype.addChangeListener = function() { */ BadgeManager.prototype.removeChangeListener = function() { if (arguments.length < 1) - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'incorrect number of arguments'); var args = validator_.validateArgs(arguments, [ diff --git a/src/bluetooth/bluetooth_api.js b/src/bluetooth/bluetooth_api.js index 6b0628d..bebae7e 100644 --- a/src/bluetooth/bluetooth_api.js +++ b/src/bluetooth/bluetooth_api.js @@ -1401,7 +1401,7 @@ BluetoothAdapter.prototype.getBluetoothProfileHandler = function() { return new BluetoothHealthProfileHandler(callArgs); default: - throw new tizen.WebAPIException('NotSupportedError', 'Profile ' + args.profileType + ' is not supported.'); + throw new WebAPIException('NotSupportedError', 'Profile ' + args.profileType + ' is not supported.'); } } }; diff --git a/src/bookmark/bookmark_api.js b/src/bookmark/bookmark_api.js index 25e174c..0faf1ae 100644 --- a/src/bookmark/bookmark_api.js +++ b/src/bookmark/bookmark_api.js @@ -43,15 +43,15 @@ BookmarkManager.prototype.get = function() { if (arguments.length === 0 || args.parentFolder === null) { result = provider.getFolderItems(provider.getRootId(), args.recursive); if (!result) - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR); + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR); return result; } if (args.parentFolder.id === null || args.parentFolder.id === 0) - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR); + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR); result = provider.getFolderItems(args.parentFolder.id, args.recursive); if (!result) - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR); + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR); return result; }; @@ -74,18 +74,18 @@ BookmarkManager.prototype.add = function() { ]); if (arguments.length == 1 || args.parentFolder === null) { if (args.bookmark.id) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } if (!provider.addToFolder(args.bookmark, provider.getRootId())) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } return; } if (!args.parentFolder.id) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR); + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR); } if (!provider.addToFolder(args.bookmark, args.parentFolder.id)) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } }; @@ -102,14 +102,14 @@ BookmarkManager.prototype.remove = function() { if (!arguments.length || args.bookmark === null) { if (native_.isFailure(native_.callSync('Bookmark_removeAll'))) - throw new tizen.WebAPIException(tizen.WebAPIException.SECURITY_ERR); + throw new WebAPIException(WebAPIException.SECURITY_ERR); return; } if (!args.bookmark.id) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); if (native_.isFailure(native_.callSync('Bookmark_remove', { id: args.bookmark.id}))) - throw new tizen.WebAPIException(tizen.WebAPIException.SECURITY_ERR); + throw new WebAPIException(WebAPIException.SECURITY_ERR); _edit.allow(); args.bookmark.id = null; @@ -173,12 +173,12 @@ BookmarkProvider.prototype.getFolder = function() { }); if (native_.isFailure(ret)) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } var folder = native_.getResultObject(ret); if (folder === undefined || folder === null) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); var obj = new tizen.BookmarkFolder(folder[0].title); obj.id = folder[0].id; @@ -208,12 +208,12 @@ BookmarkProvider.prototype.getFolderItems = function() { }); if (native_.isFailure(ret)) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } var folder = native_.getResultObject(ret); if (folder === undefined) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); var item; var obj; diff --git a/src/calendar/js/calendar.js b/src/calendar/js/calendar.js index 9759072..0b18574 100644 --- a/src/calendar/js/calendar.js +++ b/src/calendar/js/calendar.js @@ -112,7 +112,7 @@ Calendar.prototype.get = function(id) { var args; if (this.type === CalendarType.TASK) { if (!parseInt(id) || parseInt(id) <= 0) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR); + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR); } args = validator_.validateArgs(arguments, [{ name: 'id', @@ -160,7 +160,7 @@ Calendar.prototype.add = function() { if ((this.type === CalendarType.EVENT && !(args.item instanceof CalendarEvent)) || (this.type === CalendarType.TASK && !(args.item instanceof CalendarTask))) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Invalid item type.'); } @@ -239,7 +239,7 @@ Calendar.prototype.addBatch = function() { for (var i = 0; i < args.items.length; i++) { if ((this.type === CalendarType.EVENT && !(args.items[i] instanceof CalendarEvent)) || (this.type === CalendarType.TASK && !(args.items[i] instanceof CalendarTask))) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Invalid item type.'); } tmpItem = _itemConverter.fromTizenObject(args.items[i]); @@ -271,7 +271,7 @@ Calendar.prototype.update = function() { if ((this.type === CalendarType.EVENT && !(args.item instanceof CalendarEvent)) || (this.type === CalendarType.TASK && !(args.item instanceof CalendarTask))) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Invalid item type.'); } @@ -345,7 +345,7 @@ Calendar.prototype.updateBatch = function() { for (var i = 0; i < args.items.length; i++) { if ((calendarType === CalendarType.EVENT && !(args.items[i] instanceof CalendarEvent)) || (calendarType === CalendarType.TASK && !(args.items[i] instanceof CalendarTask))) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Invalid item type.'); } tmpItem = _itemConverter.fromTizenObject(args.items[i]); @@ -366,7 +366,7 @@ Calendar.prototype.remove = function(id) { var args; if (this.type === CalendarType.TASK) { if (!parseInt(id) || parseInt(id) <= 0) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR); + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR); } args = validator_.validateArgs(arguments, [{ name: 'id', diff --git a/src/calendar/js/calendar_item.js b/src/calendar/js/calendar_item.js index 5e61217..a316e8b 100644 --- a/src/calendar/js/calendar_item.js +++ b/src/calendar/js/calendar_item.js @@ -588,7 +588,7 @@ var CalendarEventInit = function(data) { var _validateReccurence = function(v) { if (_isDetached && v !== null) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_SUPPORTED_ERR, + throw new WebAPIException(WebAPIException.NOT_SUPPORTED_ERR, 'Recurrence can\'t be set because event is detached'); } @@ -669,24 +669,24 @@ CalendarEvent.prototype.constructor = CalendarEvent; CalendarEvent.prototype.expandRecurrence = function(startDate, endDate, successCallback, errorCallback) { if (arguments.length < 3) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } if (!(startDate instanceof tizen.TZDate)) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } if (!(endDate instanceof tizen.TZDate)) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } if (typeof successCallback !== 'function') { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } if (errorCallback) { if (typeof errorCallback !== 'function') { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } } if (!(this.recurrenceRule instanceof tizen.CalendarRecurrenceRule)) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'The event is not recurring.'); } diff --git a/src/calendar/js/calendar_manager.js b/src/calendar/js/calendar_manager.js index 3484b97..144bb5b 100644 --- a/src/calendar/js/calendar_manager.js +++ b/src/calendar/js/calendar_manager.js @@ -88,7 +88,7 @@ CalendarManager.prototype.getCalendar = function() { ]); if (isNaN(Number(args.id))) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Calendar not found'); } diff --git a/src/callhistory/callhistory_api.js b/src/callhistory/callhistory_api.js index 9709820..c8cc12d 100644 --- a/src/callhistory/callhistory_api.js +++ b/src/callhistory/callhistory_api.js @@ -74,7 +74,7 @@ ListenerManager.prototype.addListener = function(callback) { ListenerManager.prototype.removeListener = function(watchId) { if (this.listeners[watchId] === null || this.listeners[watchId] === undefined) { - throw new tizen.WebAPIException(0, 'Watch id not found.', 'InvalidValuesError'); + throw new WebAPIException(0, 'Watch id not found.', 'InvalidValuesError'); } if (this.listeners.hasOwnProperty(watchId)) { @@ -162,8 +162,8 @@ CallHistory.prototype.remove = function() { var result = native_.callSync('CallHistory_remove', callArgs); if (native_.isFailure(result)) { - throw new tizen.WebAPIException( - tizen.WebAPIException.INVALID_VALUES_ERR, 'Watch id not found.'); + throw new WebAPIException( + WebAPIException.INVALID_VALUES_ERR, 'Watch id not found.'); } return; diff --git a/src/contact/js/address_book.js b/src/contact/js/address_book.js index 13544ee..4d3d0d6 100644 --- a/src/contact/js/address_book.js +++ b/src/contact/js/address_book.js @@ -159,7 +159,7 @@ AddressBook.prototype.get = function() { if (String(converter_.toLong(args.id)) !== args.id) { // TCT: AddressBook_get_id_invalid - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } var result = native_.callSync('AddressBook_get', { @@ -381,7 +381,7 @@ AddressBook.prototype.remove = function() { if (String(converter_.toLong(args.id)) !== args.id) { // TCT: AddressBook_remove_id_invalid - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } var result = native_.callSync('AddressBook_remove', { @@ -553,13 +553,13 @@ AddressBook.prototype.removeChangeListener = function(watchId) { ]); if (args.watchId <= 0) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Wrong watch id'); } if (!_contactCallbackMap.hasOwnProperty(this.id) || !_contactCallbackMap[this.id].hasOwnProperty(args.watchId)) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'watch id not found for this address book'); } @@ -591,7 +591,7 @@ AddressBook.prototype.getGroup = function() { if (String(converter_.toLong(args.groupId)) !== args.groupId) { // TCT: AddressBook_getGroup_groupId_invalid - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } var result = native_.callSync('AddressBook_getGroup', { @@ -659,7 +659,7 @@ AddressBook.prototype.removeGroup = function() { if (String(converter_.toLong(args.groupId)) !== args.groupId) { // TCT: AddressBook_removeGroup_groupId_invalid - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } var result = native_.callSync('AddressBook_removeGroup', diff --git a/src/contact/js/contact.js b/src/contact/js/contact.js index 228ac51..ad84fdb 100644 --- a/src/contact/js/contact.js +++ b/src/contact/js/contact.js @@ -504,15 +504,15 @@ Contact.prototype.convertToString = function(format) { format = format || TypeEnum[0]; if (!type_.isString(format)) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Invalid format'); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Invalid format'); } if (TypeEnum.indexOf(format) < 0) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Invalid format'); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Invalid format'); } if (this.id === '') { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Contact ID is empty.'); } diff --git a/src/contact/js/contact_manager.js b/src/contact/js/contact_manager.js index 5fdf6a9..639f690 100644 --- a/src/contact/js/contact_manager.js +++ b/src/contact/js/contact_manager.js @@ -73,7 +73,7 @@ ContactManager.prototype.getUnifiedAddressBook = function() { // TODO check privileges //var result = native_.callSync('CheckReadPrivileges', {}); //if (native_.isFailure(result)) { - // throw new tizen.WebAPIException(WebAPIException.SECURITY_ERR, + // throw new WebAPIException(WebAPIException.SECURITY_ERR, // 'You do not have privileges for this operation'); //} @@ -103,7 +103,7 @@ ContactManager.prototype.getAddressBook = function() { if (String(converter_.toLong(args.addressBookId)) !== args.addressBookId) { // TCT: ContactManager_getAddressBook_addressBookId_invalid - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR); + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR); } var result = native_.callSync('ContactManager_getAddressBook', { @@ -155,7 +155,7 @@ ContactManager.prototype.addAddressBook = function() { ContactManager.prototype.removeAddressBook = function() { // TCT: ContactManager_removeAddressBook_misarg if (type_.isNullOrUndefined(arguments[0])) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } var args = validator_.validateArgs(arguments, [{ @@ -166,12 +166,12 @@ ContactManager.prototype.removeAddressBook = function() { }]); if (args.addressBookId === UNIFIED_ADDRESSBOOK_ID) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Unified address book can not be deleted'); } if (args.addressBookId === DEFAULT_ADDRESSBOOK_ID) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Default address book can not be deleted'); } @@ -198,7 +198,7 @@ ContactManager.prototype.get = function() { if (String(converter_.toLong(args.personId)) !== args.personId) { // TCT: ContactManager_get_personId_invalid - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } var result = native_.callSync('ContactManager_get', { @@ -283,7 +283,7 @@ ContactManager.prototype.remove = function() { if (String(converter_.toLong(args.personId)) !== args.personId) { // TCT: ContactManager_remove_personId_invalid - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } var result = native_.callSync('ContactManager_remove', {personId: args.personId}); @@ -435,17 +435,17 @@ ContactManager.prototype.removeChangeListener = function() { // This makes UTC_contact_removeChangeListenerPerson_N_001 pass. // watch id's start at 1 if (args.watchId === 0) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'id is null or undefined'); } if (args.watchId < 0) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Negative watch id'); } if (!_personCallbackMap.hasOwnProperty(args.watchId)) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'watch id not found'); } diff --git a/src/contact/js/person.js b/src/contact/js/person.js index e8eb731..bc8e7c0 100644 --- a/src/contact/js/person.js +++ b/src/contact/js/person.js @@ -135,7 +135,7 @@ Person.prototype.link = function() { if (String(converter_.toLong(args.personId)) !== args.personId) { // TCT: Person_link_personId_invalid - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } var result = native_.callSync('Person_link', { @@ -163,7 +163,7 @@ Person.prototype.unlink = function(contactId) { if (String(converter_.toLong(args.contactId)) !== args.contactId) { // TCT: Person_unlink_contactId_invalid - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } var result = native_.callSync('Person_unlink', { diff --git a/src/content/content_api.js b/src/content/content_api.js index c18671f..5bd4882 100755 --- a/src/content/content_api.js +++ b/src/content/content_api.js @@ -19,18 +19,18 @@ function nextCallbackId() { var ExceptionMap = { - 'UnknownError' : tizen.WebAPIException.UNKNOWN_ERR , - 'TypeMismatchError' : tizen.WebAPIException.TYPE_MISMATCH_ERR , - 'InvalidValuesError' : tizen.WebAPIException.INVALID_VALUES_ERR , - 'IOError' : tizen.WebAPIException.IO_ERR , - 'ServiceNotAvailableError' : tizen.WebAPIException.SERVICE_NOT_AVAILABLE_ERR , - 'SecurityError' : tizen.WebAPIException.SECURITY_ERR , - 'NetworkError' : tizen.WebAPIException.NETWORK_ERR , - 'NotSupportedError' : tizen.WebAPIException.NOT_SUPPORTED_ERR , - 'NotFoundError' : tizen.WebAPIException.NOT_FOUND_ERR , - 'InvalidAccessError' : tizen.WebAPIException.INVALID_ACCESS_ERR , - 'AbortError' : tizen.WebAPIException.ABORT_ERR , - 'QuotaExceededError' : tizen.WebAPIException.QUOTA_EXCEEDED_ERR , + 'UnknownError' : WebAPIException.UNKNOWN_ERR , + 'TypeMismatchError' : WebAPIException.TYPE_MISMATCH_ERR , + 'InvalidValuesError' : WebAPIException.INVALID_VALUES_ERR , + 'IOError' : WebAPIException.IO_ERR , + 'ServiceNotAvailableError' : WebAPIException.SERVICE_NOT_AVAILABLE_ERR , + 'SecurityError' : WebAPIException.SECURITY_ERR , + 'NetworkError' : WebAPIException.NETWORK_ERR , + 'NotSupportedError' : WebAPIException.NOT_SUPPORTED_ERR , + 'NotFoundError' : WebAPIException.NOT_FOUND_ERR , + 'InvalidAccessError' : WebAPIException.INVALID_ACCESS_ERR , + 'AbortError' : WebAPIException.ABORT_ERR , + 'QuotaExceededError' : WebAPIException.QUOTA_EXCEEDED_ERR , } function callNative(cmd, args) { @@ -40,7 +40,7 @@ function callNative(cmd, args) { var result = JSON.parse(resultString); if (typeof result !== 'object') { - throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR); + throw new WebAPIException(WebAPIException.UNKNOWN_ERR); } if (result['status'] == 'success') { @@ -52,9 +52,9 @@ function callNative(cmd, args) { var err = result['error']; if(err) { if(ExceptionMap[err.name]) { - throw new tizen.WebAPIException(ExceptionMap[err.name], err.message); + throw new WebAPIException(ExceptionMap[err.name], err.message); } else { - throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR, err.message); + throw new WebAPIException(WebAPIException.UNKNOWN_ERR, err.message); } } return false; @@ -164,13 +164,13 @@ Playlist.prototype.removeBatch = function(items) { }); } catch(e) { throw e; - } + } } Playlist.prototype.get = function() { var args = validator_.validateArgs(arguments, [ - {'name' : 'successCallback', 'type': types_.FUNCTION}, + {'name' : 'successCallback', 'type': types_.FUNCTION}, {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true}, {'name' : 'count', 'type': types_.LONG, optional : true, nullable : true}, {'name' : 'offset', 'type': types_.LONG, optional : true, nullable : true} @@ -192,7 +192,7 @@ Playlist.prototype.get = function() { else { nativeParam['offset'] = -1; } - + try { var syncResult = callNativeWithCallback('ContentPlaylist_get', nativeParam, function(result) { if (result.status == 'success') { @@ -275,7 +275,7 @@ Playlist.prototype.setOrder = function() { }); } catch(e) { throw e; - } + } } Playlist.prototype.move = function(item, delta) { @@ -291,7 +291,7 @@ Playlist.prototype.move = function(item, delta) { 'member_id': args.item.member_id, 'delta' : args.delta }; - + try { var syncResult = callNativeWithCallback('ContentPlaylist_move', nativeParam, function(result) { @@ -311,7 +311,7 @@ Playlist.prototype.move = function(item, delta) { function ContentDirectory(id, uri, type, title, date) { Object.defineProperties(this, { - 'id': { writable: false, value: id, enumerable: true }, + 'id': { writable: false, value: id, enumerable: true }, 'directoryURI': { writable: false, value: uri, enumerable: true }, 'title': { writable: false, value: title, enumerable: true }, 'storageType': { writable: false, value: type, enumerable: true }, @@ -320,7 +320,7 @@ function ContentDirectory(id, uri, type, title, date) { } -function Content(id, name,type, mimeType, title, contentURI, thumbnailURIs, +function Content(id, name,type, mimeType, title, contentURI, thumbnailURIs, releaseDate, modifiedDate, size, description, rating, isFavorite) { var name_ = name; var rating_ = rating; @@ -334,82 +334,82 @@ function Content(id, name,type, mimeType, title, contentURI, thumbnailURIs, editableAttributes_.push("geolocation"); } Object.defineProperties(this, { - 'editableAttributes': + 'editableAttributes': { enumerable: true, get: function() { return editableAttributes_; } }, - 'id': + 'id': { writable: false, value: id, enumerable: true }, - 'name': + 'name': { enumerable: true, set: function(v) { if (v != null) name_ = v}, get: function() { return name_; } - }, - 'type': + }, + 'type': { writable: false, value: type, enumerable: true }, - 'mimeType': + 'mimeType': { writable: false, value: mimeType, enumerable: true }, - 'title': + 'title': { writable: false, value: title, enumerable: true }, - 'contentURI': + 'contentURI': { writable: false, value: contentURI, enumerable: true }, - 'thumbnailURIs': + 'thumbnailURIs': { writable: false, value: thumbnailURIs, enumerable: true }, - 'releaseDate': + 'releaseDate': { writable: false, value: releaseDate, enumerable: true }, - 'modifiedDate': + 'modifiedDate': { writable: false, value: modifiedDate, enumerable: true }, - 'size': + 'size': { writable: false, value: size, enumerable: true }, - 'description': + 'description': { writable: true, value: description, enumerable: true }, - 'rating': + 'rating': { enumerable: true, set: function(v) { if (v != null && v >= 0 && v <= 10) rating_ = v; }, get: function() { return rating_; } }, - 'isFavorite': + 'isFavorite': { writable: true, value: isFavorite, enumerable: true } }); } function ImageContent(obj, width, height, orientation, geolocation) { Object.defineProperties(obj, { - 'width': + 'width': { writable: false, value: width, enumerable: true }, - 'height': + 'height': { writable: false, value: height, enumerable: true }, - 'orientation': + 'orientation': { writable: true, value: orientation, enumerable: true }, - 'geolocation': + 'geolocation': { writable: true, value: geolocation, enumerable: true } }); } function VideoContent(obj, geolocation, album, artists, duration, width, height) { Object.defineProperties(obj, { - 'geolocation': + 'geolocation': { writable: true, value: geolocation, enumerable: true }, - 'album': + 'album': { writable: false, value: album, enumerable: true }, - 'artists': + 'artists': { writable: false, value: artists, enumerable: true }, - 'duration': + 'duration': { writable: false, value: duration, enumerable: true }, - 'width': + 'width': { writable: false, value: width, enumerable: true }, - 'height': + 'height': { writable: false, value: height, enumerable: true } }); } function AudioContentLyrics(type, timestamps, texts) { Object.defineProperties(this, { - 'type': + 'type': { writable: false, value: type, enumerable: true }, - 'timestamps': + 'timestamps': { writable: false, value: timestamps, enumerable: true }, - 'texts': + 'texts': { writable: false, value: texts, enumerable: true } }); } @@ -433,25 +433,25 @@ function AudioContent(obj, album, genres, artists, composers, copyright, } } Object.defineProperties(obj, { - 'album': + 'album': { writable: false, value: album, enumerable: true }, - 'genres': + 'genres': { writable: false, value: genres, enumerable: true }, - 'artists': + 'artists': { writable: false, value: artists, enumerable: true }, - 'composers': + 'composers': { writable: false, value: composers, enumerable: true }, - 'copyright': + 'copyright': { writable: false, value: copyright, enumerable: true }, - 'bitrate': + 'bitrate': { writable: false, value: bitrate, enumerable: true }, - 'trackNumber': + 'trackNumber': { writable: false, value: trackNumber, enumerable: true }, - 'duration': + 'duration': { writable: false, value: duration, enumerable: true }, - 'lyrics': + 'lyrics': { enumerable: true, - get: function() { + get: function() { if(lyrics_ === undefined) { getLyrics(obj.contentURI); } @@ -482,7 +482,7 @@ function createContent(c) { if (c.type === "IMAGE") { var image = new ImageContent(content, c.width, - c.height, + c.height, c.orientation, c.geolocation ); @@ -535,7 +535,7 @@ ContentManager.prototype.update = function(content) { ContentManager.prototype.updateBatch = function(contents) { var args = validator_.validateArgs(arguments, [ - {'name' : 'contents', 'type': types_.ARRAY}, + {'name' : 'contents', 'type': types_.ARRAY}, {'name' : 'successCallback', 'type': types_.FUNCTION, optional : true, nullable : true}, {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true} ]); @@ -561,8 +561,8 @@ ContentManager.prototype.updateBatch = function(contents) { ContentManager.prototype.getDirectories = function(successCallback) { var args = validator_.validateArgs(arguments, [ - {'name' : 'successCallback', 'type': types_.FUNCTION, optional : false, nullable : false}, - {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true} + {'name' : 'successCallback', 'type': types_.FUNCTION, optional : false, nullable : false}, + {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true} ]); var nativeParam = { @@ -582,7 +582,7 @@ ContentManager.prototype.getDirectories = function(successCallback) { res.storageType, res.modifiedDate ); - + dirs.push(dir); } args.successCallback(dirs); @@ -601,18 +601,18 @@ ContentManager.prototype.getDirectories = function(successCallback) { ContentManager.prototype.find = function(successCallback) { var args = validator_.validateArgs(arguments, [ - {'name' : 'successCallback', 'type': types_.FUNCTION, 'values' : ['onsuccess']}, - {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true}, - {'name' : 'directoryId', 'type': types_.STRING, optional : true, nullable : true}, - {'name' : 'filter', 'type': types_.DICTIONARY, optional : true, nullable : true}, - {'name' : 'sortMode', 'type': types_.DICTIONARY, optional : true, nullable : true}, + {'name' : 'successCallback', 'type': types_.FUNCTION, 'values' : ['onsuccess']}, + {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true}, + {'name' : 'directoryId', 'type': types_.STRING, optional : true, nullable : true}, + {'name' : 'filter', 'type': types_.DICTIONARY, optional : true, nullable : true}, + {'name' : 'sortMode', 'type': types_.DICTIONARY, optional : true, nullable : true}, {'name' : 'count', 'type': types_.UNSIGNED_LONG, optional : true}, {'name' : 'offset', 'type': types_.UNSIGNED_LONG, optional : true} ]); var nativeParam = { }; - + if (args['directoryId']) { nativeParam['directoryId'] = args.directoryId; } @@ -636,7 +636,7 @@ ContentManager.prototype.find = function(successCallback) { var c = result.value[i]; var content = createContent(c); - + contents.push(content); } args.successCallback(contents); @@ -644,7 +644,7 @@ ContentManager.prototype.find = function(successCallback) { else if(result.status == 'error') { var err = result['value']; args.errorCallback(err); - } + } }); // if you need synchronous result from native function using 'syncResult'. } catch(e) { @@ -655,7 +655,7 @@ ContentManager.prototype.find = function(successCallback) { ContentManager.prototype.scanFile = function(contentURI) { var args = validator_.validateArgs(arguments, [ - {'name' : 'contentURI', 'type': types_.STRING}, + {'name' : 'contentURI', 'type': types_.STRING}, {'name' : 'successCallback', 'type': types_.FUNCTION, optional : true, nullable : true}, {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true} ]); @@ -685,7 +685,7 @@ ContentManager.prototype.scanFile = function(contentURI) { ContentManager.prototype.setChangeListener = function(changeCallback) { var args = validator_.validateArgs(arguments, [ - {'name' : 'changeCallback', 'type': types_.LISTENER, 'values' : ['oncontentadded', 'oncontentupdated', 'oncontentremoved']} + {'name' : 'changeCallback', 'type': types_.LISTENER, 'values' : ['oncontentadded', 'oncontentupdated', 'oncontentremoved']} ]); var nativeParam = { @@ -725,8 +725,8 @@ ContentManager.prototype.unsetChangeListener = function() { ContentManager.prototype.getPlaylists = function(successCallback) { var args = validator_.validateArgs(arguments, [ - {'name' : 'successCallback', 'type': types_.FUNCTION}, - {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true} + {'name' : 'successCallback', 'type': types_.FUNCTION}, + {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true} ]); var nativeParam = { @@ -755,9 +755,9 @@ ContentManager.prototype.getPlaylists = function(successCallback) { ContentManager.prototype.createPlaylist = function(name, successCallback) { var args = validator_.validateArgs(arguments, [ - {'name' : 'name', 'type': types_.STRING}, - {'name' : 'successCallback', 'type': types_.FUNCTION}, - {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true}, + {'name' : 'name', 'type': types_.STRING}, + {'name' : 'successCallback', 'type': types_.FUNCTION}, + {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true}, {'name' : 'sourcePlaylist', 'type': types_.PLATFORM_OBJECT, optional : true, nullable : true} ]); @@ -788,7 +788,7 @@ ContentManager.prototype.createPlaylist = function(name, successCallback) { ContentManager.prototype.removePlaylist = function(id) { var args = validator_.validateArgs(arguments, [ - {'name' : 'id', 'type': types_.STRING}, + {'name' : 'id', 'type': types_.STRING}, {'name' : 'successCallback', 'type': types_.FUNCTION, optional : true, nullable : true}, {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true} ]); diff --git a/src/datacontrol/datacontrol_api.js b/src/datacontrol/datacontrol_api.js index 38ef05d..0294d42 100644 --- a/src/datacontrol/datacontrol_api.js +++ b/src/datacontrol/datacontrol_api.js @@ -30,7 +30,7 @@ function callNative(cmd, args) { var result = JSON.parse(resultString); if (typeof result !== 'object') { - throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR); + throw new WebAPIException(WebAPIException.UNKNOWN_ERR); } if (result['status'] == 'success') { @@ -41,7 +41,7 @@ function callNative(cmd, args) { } else if (result['status'] == 'error') { var err = result['error']; if (err) { - throw new tizen.WebAPIException(err.name, err.message); + throw new WebAPIException(err.name, err.message); } return false; } @@ -131,7 +131,7 @@ SQLDataControlConsumer.prototype.insert = function(reqId, insertionData) { if (result.status == 'error') { if (args.errorCallback) { var err = result['result']; - var e = new tizen.WebAPIException(err.name, err.message); + var e = new WebAPIException(err.name, err.message); args.errorCallback(result['requestId'], e); } } @@ -168,7 +168,7 @@ SQLDataControlConsumer.prototype.update = function(reqId, updateData, where) { if (result.status == 'error') { if (args.errorCallback) { var err = result['result']; - var e = new tizen.WebAPIException(err.name, err.message); + var e = new WebAPIException(err.name, err.message); args.errorCallback(result['requestId'], e); } } @@ -204,7 +204,7 @@ SQLDataControlConsumer.prototype.remove = function(reqId, where) { if (result.status == 'error') { if (args.errorCallback) { var err = result['result']; - var e = new tizen.WebAPIException(err.name, err.message); + var e = new WebAPIException(err.name, err.message); args.errorCallback(result['requestId'], e); } } @@ -248,7 +248,7 @@ SQLDataControlConsumer.prototype.select = function(reqId, columns, where, succes if (result.status == 'error') { if (args.errorCallback) { var err = result['result']; - var e = new tizen.WebAPIException(err.name, err.message); + var e = new WebAPIException(err.name, err.message); args.errorCallback(result['requestId'], e); } } @@ -295,7 +295,7 @@ MappedDataControlConsumer.prototype.addValue = function(reqId, key, value) { if (result.status == 'error') { if (args.errorCallback) { var err = result['result']; - var e = new tizen.WebAPIException(err.name, err.message); + var e = new WebAPIException(err.name, err.message); args.errorCallback(result['requestId'], e); } } @@ -331,7 +331,7 @@ MappedDataControlConsumer.prototype.removeValue = function(reqId, key, value, su if (result.status == 'error') { if (args.errorCallback) { var err = result['result']; - var e = new tizen.WebAPIException(err.name, err.message); + var e = new WebAPIException(err.name, err.message); args.errorCallback(result['requestId'], e); } } @@ -364,7 +364,7 @@ MappedDataControlConsumer.prototype.getValue = function(reqId, key, successCallb if (result.status == 'error') { if (args.errorCallback) { var err = result['result']; - var e = new tizen.WebAPIException(err.name, err.message); + var e = new WebAPIException(err.name, err.message); args.errorCallback(result['requestId'], e); } } @@ -403,7 +403,7 @@ MappedDataControlConsumer.prototype.updateValue = function( if (result.status == 'error') { if (args.errorCallback) { var err = result['result']; - var e = new tizen.WebAPIException(err.name, err.message); + var e = new WebAPIException(err.name, err.message); args.errorCallback(result['requestId'], e); } } diff --git a/src/download/download_api.js b/src/download/download_api.js index ff9869d..36a8fe7 100644 --- a/src/download/download_api.js +++ b/src/download/download_api.js @@ -48,7 +48,7 @@ function callNative(cmd, args) { var result = JSON.parse(resultString); if (typeof result !== 'object') { - throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR); + throw new WebAPIException(WebAPIException.UNKNOWN_ERR); } if (result['status'] == 'success') { @@ -59,7 +59,7 @@ function callNative(cmd, args) { } else if (result['status'] == 'error') { var err = result['error']; if (err) { - throw new tizen.WebAPIException(err.name, err.message); + throw new WebAPIException(err.name, err.message); } return false; } @@ -103,12 +103,12 @@ tizen.DownloadRequest = function(url, destination, fileName, networkType, httpHe {'name' : 'fileName', 'type': types_.STRING, 'nullable': true, 'optional': true}, {'name' : 'networkType', 'type': types_.ENUM, 'values': ['CELLULAR', 'WIFI', 'ALL'], 'nullable' : true, 'optional': true}, - {'name' : 'httpHeader', 'type': types_.Dictionary, 'nullable': true, 'optional': true} + {'name' : 'httpHeader', 'type': types_.Dictionary, 'nullable': true, 'optional': true} ]); var url_ = url; var networkType_; - + if (networkType === undefined) networkType_ = 'ALL'; else if (networkType in DownloadNetworkType) networkType_ = networkType; @@ -176,7 +176,7 @@ DownloadManager.prototype.cancel = function(downloadId) { }; if (typeof requests[downloadId] === 'undefined') - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'the identifier does not match any download operation in progress'); try { @@ -196,7 +196,7 @@ DownloadManager.prototype.pause = function(downloadId) { }; if (typeof requests[downloadId] === 'undefined') - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'the identifier does not match any download operation in progress'); try { @@ -216,7 +216,7 @@ DownloadManager.prototype.resume = function(downloadId) { }; if (typeof requests[downloadId] === 'undefined') - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'the identifier does not match any download operation in progress'); try { @@ -236,7 +236,7 @@ DownloadManager.prototype.getState = function(downloadId) { }; if (typeof requests[downloadId] === 'undefined') - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'the identifier does not match any download operation in progress'); try { @@ -254,7 +254,7 @@ DownloadManager.prototype.getDownloadRequest = function(downloadId) { ]); if (typeof requests[downloadId] === 'undefined') - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'the identifier does not match any download operation in progress'); return requests[args.downloadId]; @@ -270,7 +270,7 @@ DownloadManager.prototype.getMIMEType = function(downloadId) { }; if (typeof requests[downloadId] === 'undefined') - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'the identifier does not match any download operation in progress'); try { diff --git a/src/exif/exif_api.js b/src/exif/exif_api.js index c91b32d..afdaa8b 100644 --- a/src/exif/exif_api.js +++ b/src/exif/exif_api.js @@ -180,8 +180,8 @@ ExifManager.prototype.getExifInfo = function() { if (!_isValidAbsoluteURI(args.uri)) { setTimeout(function() { - native_.callIfPossible(args.errorCallback, new tizen.WebAPIException( - tizen.WebAPIException.INVALID_VALUES_ERR, + native_.callIfPossible(args.errorCallback, new WebAPIException( + WebAPIException.INVALID_VALUES_ERR, 'Invalid URI.')); }, 0); return; @@ -209,8 +209,8 @@ ExifManager.prototype.getExifInfo = function() { native_.call('ExifManager_getExifInfo', {'uri': args.uri}, callback); }, function() { - native_.callIfPossible(args.errorCallback, new tizen.WebAPIException( - tizen.WebAPIException.NOT_FOUND_ERR, + native_.callIfPossible(args.errorCallback, new WebAPIException( + WebAPIException.NOT_FOUND_ERR, 'File can not be found.')); }); }; @@ -240,8 +240,8 @@ ExifManager.prototype.saveExifInfo = function() { if (!_isValidAbsoluteURI(args.exifInfo.uri)) { setTimeout(function() { - native_.callIfPossible(args.errorCallback, new tizen.WebAPIException( - tizen.WebAPIException.INVALID_VALUES_ERR, + native_.callIfPossible(args.errorCallback, new WebAPIException( + WebAPIException.INVALID_VALUES_ERR, 'Invalid URI.')); }, 0); return; @@ -285,8 +285,8 @@ ExifManager.prototype.getThumbnail = function() { if (!_isValidAbsoluteURI(args.uri)) { setTimeout(function() { - native_.callIfPossible(args.errorCallback, new tizen.WebAPIException( - tizen.WebAPIException.INVALID_VALUES_ERR, + native_.callIfPossible(args.errorCallback, new WebAPIException( + WebAPIException.INVALID_VALUES_ERR, 'Invalid URI.')); }, 0); return; @@ -307,8 +307,8 @@ ExifManager.prototype.getThumbnail = function() { native_.call('ExifManager_getThumbnail', {'uri': args.uri}, _callback); }, function() { - native_.callIfPossible(args.errorCallback, new tizen.WebAPIException( - tizen.WebAPIException.NOT_FOUND_ERR, + native_.callIfPossible(args.errorCallback, new WebAPIException( + WebAPIException.NOT_FOUND_ERR, 'File can not be found.')); }); }; @@ -363,7 +363,7 @@ tizen.ExifInformation = function() { var exifInitDict = args.ExifInitDict; if (exifInitDict) { if (exifInitDict.uri === null) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Parameter "uri" is required.'); } } diff --git a/src/filesystem/js/file.js b/src/filesystem/js/file.js index f041d9e..7e77b49 100644 --- a/src/filesystem/js/file.js +++ b/src/filesystem/js/file.js @@ -98,7 +98,7 @@ function createFilter(fileFilter) { _fileFilter[i] = stringToRegex(fileFilter[i]); } else { if (!(fileFilter[i] instanceof Date)) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Invalid date'); } _fileFilter[i] = fileFilter[i]; @@ -151,13 +151,13 @@ File.prototype.listFiles = function(onsuccess, onerror, filter) { ]); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Arguments missing'); } if (!this.isDirectory) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, + new WebAPIException(WebAPIException.IO_ERR, 'File object which call this method is not directory')); }, 0); return; @@ -211,7 +211,7 @@ function _checkEncoding(encoding) { if (encoding) { var _validEncoding = Object.keys(Encoding); if (_validEncoding.indexOf((encoding.toLowerCase())) < 0) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "encoding" has invalid value'); } } @@ -226,13 +226,13 @@ File.prototype.openStream = function(mode, onsuccess, onerror, encoding) { ]); if (arguments.length < 2) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Arguments missing'); } if (this.mode === 'r' && args.mode !== 'r') { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, 'Read only mode')); + new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Read only mode')); }, 0); return; } @@ -240,7 +240,7 @@ File.prototype.openStream = function(mode, onsuccess, onerror, encoding) { if (this.isDirectory) { var directoryMessage = 'This method should be called on file, not directory'; setTimeout(function() { - native_.callIfPossible(args.onerror, new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, + native_.callIfPossible(args.onerror, new WebAPIException(WebAPIException.IO_ERR, directoryMessage)); }, 0); return; @@ -253,7 +253,7 @@ File.prototype.openStream = function(mode, onsuccess, onerror, encoding) { if (native_.isFailure(_result)) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'File does not exist')); + new WebAPIException(WebAPIException.IO_ERR, 'File does not exist')); }, 0); return; } @@ -272,13 +272,13 @@ File.prototype.readAsText = function(onsuccess, onerror, encoding) { ]); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Arguments missing'); } if (this.isDirectory) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, + new WebAPIException(WebAPIException.IO_ERR, 'File object which call this method is directory')); }, 0); return; @@ -325,14 +325,14 @@ File.prototype.copyTo = function(originFilePath, destinationFilePath, overwrite, ]); if (arguments.length < 3) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Invalid arguments given'); } if (this.isFile) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, + new WebAPIException(WebAPIException.IO_ERR, 'File object which call this method is not directory')); }, 0); return; @@ -353,7 +353,7 @@ File.prototype.copyTo = function(originFilePath, destinationFilePath, overwrite, if (!_realOriginalPath) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Source path is not valid')); }, 0); return; @@ -362,7 +362,7 @@ File.prototype.copyTo = function(originFilePath, destinationFilePath, overwrite, if (!_realDestinationPath) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Destination path is not valid')); }, 0); return; @@ -390,7 +390,7 @@ File.prototype.copyTo = function(originFilePath, destinationFilePath, overwrite, var callback = function(result) { if (native_.isFailure(result)) { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, result)); + new WebAPIException(WebAPIException.IO_ERR, result)); return; } native_.callIfPossible(args.onsuccess); @@ -409,13 +409,13 @@ File.prototype.moveTo = function(originFilePath, destinationFilePath, overwrite, ]); if (arguments.length < 3) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Arguments missing'); } if (this.isFile) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, + new WebAPIException(WebAPIException.IO_ERR, 'File object which call this method is not directory')); }, 0); return; @@ -427,7 +427,7 @@ File.prototype.moveTo = function(originFilePath, destinationFilePath, overwrite, if (!_realOriginalPath) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Source path is not valid')); }, 0); return; @@ -436,7 +436,7 @@ File.prototype.moveTo = function(originFilePath, destinationFilePath, overwrite, if (!_realDestinationPath) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Destination path is not valid')); }, 0); return; @@ -446,7 +446,7 @@ File.prototype.moveTo = function(originFilePath, destinationFilePath, overwrite, if (native_.isFailure(resultOldPath)) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Source file is not avalaible')); }, 0); return; @@ -457,7 +457,7 @@ File.prototype.moveTo = function(originFilePath, destinationFilePath, overwrite, if (native_.isSuccess(resultNewPath)) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Overwrite is not allowed')); + new WebAPIException(WebAPIException.IO_ERR, 'Overwrite is not allowed')); }, 0); return; } @@ -467,7 +467,7 @@ File.prototype.moveTo = function(originFilePath, destinationFilePath, overwrite, var m1 = 'Source file should be subdirectory of: ' + this.fullPath; setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, m1)); + new WebAPIException(WebAPIException.INVALID_VALUES_ERR, m1)); }, 0); return; } @@ -476,7 +476,7 @@ File.prototype.moveTo = function(originFilePath, destinationFilePath, overwrite, var m2 = 'Source/Destination is read only folder: ' + this.fullPath; setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, m2)); + new WebAPIException(WebAPIException.INVALID_VALUES_ERR, m2)); }, 0); return; } @@ -488,7 +488,7 @@ File.prototype.moveTo = function(originFilePath, destinationFilePath, overwrite, var callback = function(result) { if (native_.isFailure(result)) { - native_.callIfPossible(args.onerror, new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, + native_.callIfPossible(args.onerror, new WebAPIException(WebAPIException.IO_ERR, result)); return; } @@ -504,11 +504,11 @@ File.prototype.createDirectory = function(dirPath) { ]); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Invalid path'); } if (!args.dirPath.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Invalid path'); } @@ -520,7 +520,7 @@ File.prototype.createDirectory = function(dirPath) { if (!_realNewPath) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Path is not valid')); }, 0); return; @@ -528,19 +528,19 @@ File.prototype.createDirectory = function(dirPath) { if (this.isDirectory) { if (this.mode === 'r') { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Invalid path or readonly access'); } var _resultExist = native_.callSync('File_statSync', {location: _realNewPath}); if (native_.isSuccess(_resultExist)) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Directory already exist'); } var result = native_.callSync('FileSystemManager_mkdirSync', {location: _realNewPath}); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, native_.getErrorObject(result)); + throw new WebAPIException(WebAPIException.IO_ERR, native_.getErrorObject(result)); } var _result = native_.callSync('File_statSync', {location: _realNewPath}); @@ -549,7 +549,7 @@ File.prototype.createDirectory = function(dirPath) { _fileInfo = commonFS_.getFileInfo(_statObj, false, this.mode); return new File(_fileInfo); } else { - throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, + throw new WebAPIException(WebAPIException.IO_ERR, 'File object which call this method is not directory'); } }; @@ -560,16 +560,16 @@ File.prototype.createFile = function(relativeFilePath) { ]); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Argument "relativeFilePath" missing'); } if (this.isFile) { - throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, + throw new WebAPIException(WebAPIException.IO_ERR, 'File object which call this method is not directory'); } if (!commonFS_.f_isCorrectRelativePath(args.relativeFilePath) || this.mode === 'r') { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Invalid path or readonly acces'); } @@ -578,7 +578,7 @@ File.prototype.createFile = function(relativeFilePath) { if (!_outputRealPath) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Path is not valid')); }, 0); return; @@ -586,7 +586,7 @@ File.prototype.createFile = function(relativeFilePath) { var _resultExist = native_.callSync('File_statSync', {location: _outputRealPath}); if (native_.isSuccess(_resultExist)) { - throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Overwrite is not allowed'); + throw new WebAPIException(WebAPIException.IO_ERR, 'Overwrite is not allowed'); } var result = native_.callSync('File_createSync', {location: _outputRealPath}); @@ -608,16 +608,16 @@ File.prototype.resolve = function(filePath) { ]); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "filePath" missing'); } if (this.isFile) { - throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, + throw new WebAPIException(WebAPIException.IO_ERR, 'File object which call this method is not directory'); } if (!commonFS_.f_isCorrectRelativePath(args.filePath)) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, 'Invalid path'); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Invalid path'); } var _newPath = this.fullPath + '/' + args.filePath; @@ -625,14 +625,14 @@ File.prototype.resolve = function(filePath) { if (!_realPath) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Path is not valid')); }, 0); return; } var _result = native_.callSync('File_statSync', {location: _realPath}); if (native_.isFailure(_result)) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, native_.getErrorObject(_result)); + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR, native_.getErrorObject(_result)); } var _statObj = native_.getResultObject(_result); var _fileInfo = commonFS_.getFileInfo(_statObj, false, this.mode); @@ -649,13 +649,13 @@ File.prototype.deleteDirectory = function(directoryPath, recursive, onsuccess, o ]); if (arguments.length < 2) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Arguments missing'); } if (this.mode === 'r') { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Invalid path or readonly access')); }, 0); return; @@ -666,7 +666,7 @@ File.prototype.deleteDirectory = function(directoryPath, recursive, onsuccess, o if (native_.isFailure(_result)) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, 'Directory not found')); + new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Directory not found')); }, 0); return; } @@ -677,7 +677,7 @@ File.prototype.deleteDirectory = function(directoryPath, recursive, onsuccess, o if (!_node.isDirectory) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'It is file not directory')); }, 0); return; @@ -687,7 +687,7 @@ File.prototype.deleteDirectory = function(directoryPath, recursive, onsuccess, o if (files.length > 0) { if (!args.recursive) { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, + new WebAPIException(WebAPIException.IO_ERR, 'Non empty folder ' + _myPath + ' passed for non recursive delete')); return; } @@ -707,7 +707,7 @@ File.prototype.deleteDirectory = function(directoryPath, recursive, onsuccess, o }, function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, + new WebAPIException(WebAPIException.IO_ERR, 'List files failed for ' + _myPath)); } ); @@ -722,13 +722,13 @@ File.prototype.deleteFile = function(filePath, onsuccess, onerror) { ]); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "filePath" missing'); } if (this.isFile) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, + new WebAPIException(WebAPIException.IO_ERR, 'File object which call this method is not directory')); }, 0); return; @@ -740,7 +740,7 @@ File.prototype.deleteFile = function(filePath, onsuccess, onerror) { if (native_.isFailure(_result)) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, 'File is not avalaible')); + new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'File is not avalaible')); }, 0); return; } @@ -750,7 +750,7 @@ File.prototype.deleteFile = function(filePath, onsuccess, onerror) { var message = 'Requested object is a directory.'; setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, message)); + new WebAPIException(WebAPIException.INVALID_VALUES_ERR, message)); }, 0); return; } @@ -760,7 +760,7 @@ File.prototype.deleteFile = function(filePath, onsuccess, onerror) { 'and should be subdirectory of: [' + this.fullPath + ']'; setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, _message)); + new WebAPIException(WebAPIException.INVALID_VALUES_ERR, _message)); }, 0); return; } diff --git a/src/filesystem/js/file_stream.js b/src/filesystem/js/file_stream.js index 2cacb90..77f60f9 100644 --- a/src/filesystem/js/file_stream.js +++ b/src/filesystem/js/file_stream.js @@ -52,7 +52,7 @@ function FileStream(data, mode, encoding) { function _checkClosed(stream) { if (stream._closed) { - throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Stream is closed.'); + throw new WebAPIException(WebAPIException.IO_ERR, 'Stream is closed.'); } } @@ -62,13 +62,13 @@ FileStream.prototype.close = function() { function _checkReadAccess(mode) { if (mode !== 'r' && mode !== 'rw') { - throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Stream is not in read mode.'); + throw new WebAPIException(WebAPIException.IO_ERR, 'Stream is not in read mode.'); } } function _checkWriteAccess(mode) { if (mode !== 'a' && mode !== 'w' && mode !== 'rw') { - throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Stream is not in write mode.'); + throw new WebAPIException(WebAPIException.IO_ERR, 'Stream is not in write mode.'); } } @@ -84,15 +84,15 @@ FileStream.prototype.read = function() { _checkReadAccess(this._mode); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Argument "charCount" missing'); } if (!type_.isNumber(args.charCount)) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "charCount" must be a number'); } if (args.charCount <= 0) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Argument "charCount" must be greater than 0'); } @@ -106,7 +106,7 @@ FileStream.prototype.read = function() { var result = native_.callSync('File_readSync', data); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Could not read'); + throw new WebAPIException(WebAPIException.IO_ERR, 'Could not read'); } var encoded = native_.getResultObject(result); var decoded = Base64.decode(encoded); @@ -126,15 +126,15 @@ FileStream.prototype.readBytes = function() { _checkReadAccess(this._mode); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Argument "byteCount" missing'); } if (!type_.isNumber(args.byteCount)) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "byteCount" must be a number'); } if (args.byteCount <= 0) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "byteCount" must be greater than 0'); } @@ -148,7 +148,7 @@ FileStream.prototype.readBytes = function() { var result = native_.callSync('File_readSync', data); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, 'Could not read'); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Could not read'); } var encoded = native_.getResultObject(result); var decoded = Base64.decode(encoded); @@ -173,19 +173,19 @@ FileStream.prototype.readBase64 = function() { _checkReadAccess(this._mode); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "byteCount" missing'); } if (type_.isString(arguments[0]) && !arguments[0].length) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Argument "byteCount" must be a number'); } if (!type_.isNumber(arguments[0])) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "byteCount" must be a number'); } if (args.byteCount <= 0) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "byteCount" must be greater than 0'); } @@ -199,7 +199,7 @@ FileStream.prototype.readBase64 = function() { var result = native_.callSync('File_readSync', data); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, 'Could not read'); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Could not read'); } var encoded = native_.getResultObject(result); @@ -218,7 +218,7 @@ FileStream.prototype.write = function() { _checkWriteAccess(this._mode); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Argument "stringData" missing'); } @@ -231,7 +231,7 @@ FileStream.prototype.write = function() { var result = native_.callSync('File_writeSync', data); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Could not write'); + throw new WebAPIException(WebAPIException.IO_ERR, 'Could not write'); } this.position = args.stringData.length; }; @@ -249,7 +249,7 @@ FileStream.prototype.writeBytes = function() { _checkWriteAccess(this._mode); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "byteData" missing'); } @@ -262,7 +262,7 @@ FileStream.prototype.writeBytes = function() { var result = native_.callSync('File_writeSync', data); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Could not write'); + throw new WebAPIException(WebAPIException.IO_ERR, 'Could not write'); } }; @@ -283,11 +283,11 @@ FileStream.prototype.writeBase64 = function() { _checkWriteAccess(this._mode); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "base64Data" missing'); } if (!args.base64Data.length || !_isBase64(args.base64Data)) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Data is not base64'); } @@ -300,6 +300,6 @@ FileStream.prototype.writeBase64 = function() { var result = native_.callSync('File_writeSync', data); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Could not write'); + throw new WebAPIException(WebAPIException.IO_ERR, 'Could not write'); } }; diff --git a/src/filesystem/js/file_system_manager.js b/src/filesystem/js/file_system_manager.js index 5f0f5f3..5dd99d5 100644 --- a/src/filesystem/js/file_system_manager.js +++ b/src/filesystem/js/file_system_manager.js @@ -34,7 +34,7 @@ FileSystemManager.prototype.resolve = function(location, onsuccess, onerror, mod if (args.location[0] === '/') { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Global path without \'file://\' prefix is not valid.')); }, 0); return; @@ -45,7 +45,7 @@ FileSystemManager.prototype.resolve = function(location, onsuccess, onerror, mod if (args.mode !== 'r' && !_isLocationAllowed) { setTimeout(function() { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Provided arguments are not valid.')); }, 0); return; @@ -64,7 +64,7 @@ FileSystemManager.prototype.resolve = function(location, onsuccess, onerror, mod var aStatObj = native_.getResultObject(result); var _result = commonFS_.getFileInfo(aStatObj, false, args.mode); if (_result.readOnly && args.mode !== 'r') { - throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR); + throw new WebAPIException(WebAPIException.IO_ERR); } else { native_.callIfPossible(args.onsuccess, new File(_result)); } @@ -92,7 +92,7 @@ FileSystemManager.prototype.getStorage = function(label, onsuccess, onerror) { if (storage === undefined) { native_.callIfPossible(args.onerror, - new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, 'Storage not found.')); + new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Storage not found.')); } else { native_.callIfPossible(args.onsuccess, storage); } @@ -166,13 +166,13 @@ FileSystemManager.prototype.removeStorageStateChangeListener = function(watchId) ]); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Missing watchId'); } var id = args.watchId; if (type_.isNullOrUndefined(callbacks[id])) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, 'Watch ID not found.'); + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Watch ID not found.'); } delete callbacks[id]; diff --git a/src/messageport/messageport_api.js b/src/messageport/messageport_api.js index ea206da..0bc7c13 100644 --- a/src/messageport/messageport_api.js +++ b/src/messageport/messageport_api.js @@ -31,18 +31,18 @@ function nextCallbackId() { } var ExceptionMap = { - 'UnknownError' : tizen.WebAPIException.UNKNOWN_ERR, - 'TypeMismatchError' : tizen.WebAPIException.TYPE_MISMATCH_ERR, - 'InvalidValuesError' : tizen.WebAPIException.INVALID_VALUES_ERR, - 'IOError' : tizen.WebAPIException.IO_ERR, - 'ServiceNotAvailableError' : tizen.WebAPIException.SERVICE_NOT_AVAILABLE_ERR, - 'SecurityError' : tizen.WebAPIException.SECURITY_ERR, - 'NetworkError' : tizen.WebAPIException.NETWORK_ERR, - 'NotSupportedError' : tizen.WebAPIException.NOT_SUPPORTED_ERR, - 'NotFoundError' : tizen.WebAPIException.NOT_FOUND_ERR, - 'InvalidAccessError' : tizen.WebAPIException.INVALID_ACCESS_ERR, - 'AbortError' : tizen.WebAPIException.ABORT_ERR, - 'QuotaExceededError' : tizen.WebAPIException.QUOTA_EXCEEDED_ERR + 'UnknownError' : WebAPIException.UNKNOWN_ERR, + 'TypeMismatchError' : WebAPIException.TYPE_MISMATCH_ERR, + 'InvalidValuesError' : WebAPIException.INVALID_VALUES_ERR, + 'IOError' : WebAPIException.IO_ERR, + 'ServiceNotAvailableError' : WebAPIException.SERVICE_NOT_AVAILABLE_ERR, + 'SecurityError' : WebAPIException.SECURITY_ERR, + 'NetworkError' : WebAPIException.NETWORK_ERR, + 'NotSupportedError' : WebAPIException.NOT_SUPPORTED_ERR, + 'NotFoundError' : WebAPIException.NOT_FOUND_ERR, + 'InvalidAccessError' : WebAPIException.INVALID_ACCESS_ERR, + 'AbortError' : WebAPIException.ABORT_ERR, + 'QuotaExceededError' : WebAPIException.QUOTA_EXCEEDED_ERR }; function callNative(cmd, args) { @@ -52,7 +52,7 @@ function callNative(cmd, args) { var result = JSON.parse(resultString); if (typeof result !== 'object') { - throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR); + throw new WebAPIException(WebAPIException.UNKNOWN_ERR); } if (result['status'] == 'success') { @@ -65,9 +65,9 @@ function callNative(cmd, args) { var err = result['error']; if (err) { if (ExceptionMap[err.name]) { - throw new tizen.WebAPIException(ExceptionMap[err.name], err.message); + throw new WebAPIException(ExceptionMap[err.name], err.message); } else { - throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR, err.message); + throw new WebAPIException(WebAPIException.UNKNOWN_ERR, err.message); } } return false; @@ -233,7 +233,7 @@ LocalMessagePort.prototype.removeMessagePortListener = function(watchId) { } if (typeof to_delete === 'undefined') - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'The port of the target application is not found.'); listeners.splice(to_delete, 1); @@ -260,10 +260,10 @@ RemoteMessagePort.prototype.sendMessage = function(data) { for (var i = 0, j = data.length; i < j; i++) { if (Object.hasOwnProperty(data[i], 'key')) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'The input parameter contains an invalid value.'); if (Object.hasOwnProperty(data[i], 'value')) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'The input parameter contains an invalid value.'); filtered_data[i] = { key: data[i].key, value: data[i].value }; } diff --git a/src/messaging/messaging_api.js b/src/messaging/messaging_api.js index be6af16..fb0d771 100644 --- a/src/messaging/messaging_api.js +++ b/src/messaging/messaging_api.js @@ -10,7 +10,7 @@ var T_ = xwalk.utils.type; var bridge = xwalk.utils.NativeBridge(extension, true); function throwException_(err) { - throw new tizen.WebAPIException(err.code, err.name, err.message); + throw new WebAPIException(err.code, err.name, err.message); } var Property = { @@ -115,7 +115,7 @@ function Message(type, data) { throw new TypeError("Constructor called like a function"); } if (MessageServiceTag.indexOf(type) === -1) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } if ( !data || typeof data !== 'object') { // 'data' is optional data = {}; @@ -689,7 +689,7 @@ Messaging.prototype.getMessageServices = function () { if (args.errorCallback) { args.errorCallback.call( null, - new tizen.WebAPIException(e.code, e.message, e.name) + new WebAPIException(e.code, e.message, e.name) ) } } @@ -739,7 +739,7 @@ MessageService.prototype.sendMessage = function () { if (args.errorCallback) { args.errorCallback.call( null, - new tizen.WebAPIException(e.code, e.message, e.name) + new WebAPIException(e.code, e.message, e.name) ) } } @@ -777,7 +777,7 @@ MessageService.prototype.loadMessageBody = function () { if (args.errorCallback) { args.errorCallback.call( null, - new tizen.WebAPIException(e.code, e.message, e.name) + new WebAPIException(e.code, e.message, e.name) ) } } @@ -824,7 +824,7 @@ MessageService.prototype.loadMessageAttachment = function () { if (args.errorCallback) { args.errorCallback.call( null, - new tizen.WebAPIException(e.code, e.message, e.name) + new WebAPIException(e.code, e.message, e.name) ) } } @@ -849,7 +849,7 @@ MessageService.prototype.sync = function () { if (args.errorCallback) { args.errorCallback.call( null, - new tizen.WebAPIException(e.code, e.message, e.name) + new WebAPIException(e.code, e.message, e.name) ) } } @@ -886,7 +886,7 @@ MessageService.prototype.syncFolder = function () { if (args.errorCallback) { args.errorCallback.call( null, - new tizen.WebAPIException(e.code, e.message, e.name) + new WebAPIException(e.code, e.message, e.name) ) } } @@ -912,7 +912,7 @@ MessageService.prototype.stopSync = function () { // Additionally to pass the MessageService_email_stopSync_opId_TypeMismatch test if (!isFinite(arguments[0])) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } var self = this; @@ -969,7 +969,7 @@ MessageStorage.prototype.addDraftMessage = function () { if (args.errorCallback) { args.errorCallback.call( null, - new tizen.WebAPIException(e.code, e.message, e.name) + new WebAPIException(e.code, e.message, e.name) ) } } @@ -1011,7 +1011,7 @@ MessageStorage.prototype.findMessages = function () { if (args.errorCallback) { args.errorCallback.call( null, - new tizen.WebAPIException(e.code, e.message, e.name) + new WebAPIException(e.code, e.message, e.name) ) } } @@ -1044,7 +1044,7 @@ MessageStorage.prototype.removeMessages = function () { if (args.errorCallback) { args.errorCallback.call( null, - new tizen.WebAPIException(e.code, e.message, e.name) + new WebAPIException(e.code, e.message, e.name) ) } } @@ -1099,7 +1099,7 @@ MessageStorage.prototype.updateMessages = function () { if (args.errorCallback) { args.errorCallback.call( null, - new tizen.WebAPIException(e.code, e.message, e.name) + new WebAPIException(e.code, e.message, e.name) ) } } @@ -1140,7 +1140,7 @@ MessageStorage.prototype.findConversations = function () { if (args.errorCallback) { args.errorCallback.call( null, - new tizen.WebAPIException(e.code, e.message, e.name) + new WebAPIException(e.code, e.message, e.name) ) } } @@ -1156,7 +1156,7 @@ MessageStorage.prototype.removeConversations = function () { args.conversations.forEach(function (el) { if (!el || el.constructor !== MessageConversation) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } }); @@ -1179,7 +1179,7 @@ MessageStorage.prototype.removeConversations = function () { if (args.errorCallback) { args.errorCallback.call( null, - new tizen.WebAPIException(e.code, e.message, e.name) + new WebAPIException(e.code, e.message, e.name) ) } } @@ -1216,7 +1216,7 @@ MessageStorage.prototype.findFolders = function () { if (args.errorCallback) { args.errorCallback.call( null, - new tizen.WebAPIException(e.code, e.message, e.name) + new WebAPIException(e.code, e.message, e.name) ) } } diff --git a/src/nfc/nfc_api.js b/src/nfc/nfc_api.js index 9a526be..91567a4 100644 --- a/src/nfc/nfc_api.js +++ b/src/nfc/nfc_api.js @@ -116,7 +116,7 @@ NFCManager.prototype.getDefaultAdapter = function() { {} ); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(0, result.error.message, + throw new WebAPIException(0, result.error.message, result.error.name); } @@ -137,7 +137,7 @@ NFCManager.prototype.setExclusiveMode = function() { // If failed then exception should be thrown. if (native_.isFailure(result)) { - throw new tizen.WebAPIException(0, result.error.message, + throw new WebAPIException(0, result.error.message, result.error.name); // Uncoment line below (and remove line above) when problem // with error conversion is fixed: @@ -283,8 +283,8 @@ NFCAdapter.prototype.setTagListener = function() { if (!type_.isNullOrUndefined(args.tagType)) { for (var i = 0; i < args.tagType.length; i++) { if (NFCTagType[args.tagType[i]] === undefined) { - throw new tizen.WebAPIException( - tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Invalid tag type.'); + throw new WebAPIException( + WebAPIException.TYPE_MISMATCH_ERR, 'Invalid tag type.'); } } } @@ -382,7 +382,7 @@ NFCAdapter.prototype.addCardEmulationModeChangeListener = function() { var result = native_.callSync( 'NFCAdapter_addCardEmulationModeChangeListener'); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(0, result.error.message, + throw new WebAPIException(0, result.error.message, result.error.name); } } @@ -426,7 +426,7 @@ NFCAdapter.prototype.addTransactionEventListener = function() { result = native_.callSync('NFCAdapter_addTransactionEventListener', { type: args.type}); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(0, result.error.message, + throw new WebAPIException(0, result.error.message, result.error.name); } } @@ -436,7 +436,7 @@ NFCAdapter.prototype.addTransactionEventListener = function() { result = native_.callSync('NFCAdapter_addTransactionEventListener', { type: args.type}); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(0, result.error.message, + throw new WebAPIException(0, result.error.message, result.error.name); } } @@ -485,7 +485,7 @@ NFCAdapter.prototype.addActiveSecureElementChangeListener = function() { var result = native_.callSync( 'NFCAdapter_addActiveSecureElementChangeListener'); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(0, result.error.message, + throw new WebAPIException(0, result.error.message, result.error.name); } } @@ -850,7 +850,7 @@ var toByteArray = function(array, max_size, nullable) { var len = convertedArray.length; if (len > max_size) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); for (var i = 0; i < len; i++) { resultArray.push(converter_.toOctet(convertedArray[i])); } @@ -902,7 +902,7 @@ tizen.NDEFMessage = function(data) { } } } else { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } } } catch (e) { @@ -967,7 +967,7 @@ tizen.NDEFRecord = function(first, type, payload, id) { } ); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(0, result.error.message, + throw new WebAPIException(0, result.error.message, result.error.name); // throw native_.getErrorObject(result); } @@ -982,7 +982,7 @@ tizen.NDEFRecord = function(first, type, payload, id) { id_ = toByteArray(id, 255, true, []); } } else { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } } catch (e) { //constructor call failed - empty object should be created @@ -1020,14 +1020,14 @@ tizen.NDEFRecordText = function(text, languageCode, encoding) { } ); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(0, result.error.message, + throw new WebAPIException(0, result.error.message, result.error.name); // throw native_.getErrorObject(result); } tizen.NDEFRecord.call(this, result.result.tnf, result.result.type, result.result.payload, result.result.id); } else { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } } catch (e) { //constructor call failed - empty object should be created @@ -1061,14 +1061,14 @@ tizen.NDEFRecordURI = function(uri) { } ); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(0, result.error.message, + throw new WebAPIException(0, result.error.message, result.error.name); // throw native_.getErrorObject(result); } tizen.NDEFRecord.call(this, result.result.tnf, result.result.type, result.result.payload, result.result.id); } else { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } } catch (e) { //constructor call failed - empty object should be created @@ -1102,14 +1102,14 @@ tizen.NDEFRecordMedia = function(mimeType, data) { } ); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(0, result.error.message, + throw new WebAPIException(0, result.error.message, result.error.name); // throw native_.getErrorObject(result); } tizen.NDEFRecord.call(this, result.result.tnf, result.result.type, result.result.payload, result.result.id); } else { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } } catch (e) { //constructor call failed - empty object should be created diff --git a/src/notification/notification_api.js b/src/notification/notification_api.js index 218a3ba..f889023 100644 --- a/src/notification/notification_api.js +++ b/src/notification/notification_api.js @@ -71,7 +71,7 @@ NotificationManager.prototype.update = function(notification) { ]); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR); + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR); } var data = { @@ -81,7 +81,7 @@ NotificationManager.prototype.update = function(notification) { var result = native_.callSync('NotificationManager_update', data); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR, native_.getErrorObject(result)); } }; @@ -92,7 +92,7 @@ NotificationManager.prototype.remove = function(id) { ]); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR); + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR); } var data = { @@ -102,7 +102,7 @@ NotificationManager.prototype.remove = function(id) { var result = native_.callSync('NotificationManager_remove', data); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR, native_.getErrorObject(result)); } }; @@ -121,7 +121,7 @@ NotificationManager.prototype.get = function(id) { ]); if (!arguments.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR); + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR); } var data = { @@ -131,7 +131,7 @@ NotificationManager.prototype.get = function(id) { var result = native_.callSync('NotificationManager_get', data); if (native_.isFailure(result)) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, + throw new WebAPIException(WebAPIException.NOT_FOUND_ERR, native_.getErrorObject(result)); } diff --git a/src/package/package_api.js b/src/package/package_api.js index 9fc90bb..baade38 100644 --- a/src/package/package_api.js +++ b/src/package/package_api.js @@ -37,7 +37,7 @@ function callNative(cmd, args) { var result = JSON.parse(resultString); if (typeof result !== 'object') { - throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR); + throw new WebAPIException(WebAPIException.UNKNOWN_ERR); } if (result['status'] == 'success') { @@ -48,7 +48,7 @@ function callNative(cmd, args) { } else if (result['status'] == 'error') { var err = result['error']; if (err) { - throw new tizen.WebAPIException(err.name, err.message); + throw new WebAPIException(err.name, err.message); } return false; } diff --git a/src/power/power_api.js b/src/power/power_api.js index 18095f1..fe40aef 100755 --- a/src/power/power_api.js +++ b/src/power/power_api.js @@ -20,18 +20,18 @@ function nextCallbackId() { } var ExceptionMap = { - 'UnknownError' : tizen.WebAPIException.UNKNOWN_ERR , - 'TypeMismatchError' : tizen.WebAPIException.TYPE_MISMATCH_ERR , - 'InvalidValuesError' : tizen.WebAPIException.INVALID_VALUES_ERR , - 'IOError' : tizen.WebAPIException.IO_ERR , - 'ServiceNotAvailableError' : tizen.WebAPIException.SERVICE_NOT_AVAILABLE_ERR , - 'SecurityError' : tizen.WebAPIException.SECURITY_ERR , - 'NetworkError' : tizen.WebAPIException.NETWORK_ERR , - 'NotSupportedError' : tizen.WebAPIException.NOT_SUPPORTED_ERR , - 'NotFoundError' : tizen.WebAPIException.NOT_FOUND_ERR , - 'InvalidAccessError' : tizen.WebAPIException.INVALID_ACCESS_ERR , - 'AbortError' : tizen.WebAPIException.ABORT_ERR , - 'QuotaExceededError' : tizen.WebAPIException.QUOTA_EXCEEDED_ERR , + 'UnknownError' : WebAPIException.UNKNOWN_ERR , + 'TypeMismatchError' : WebAPIException.TYPE_MISMATCH_ERR , + 'InvalidValuesError' : WebAPIException.INVALID_VALUES_ERR , + 'IOError' : WebAPIException.IO_ERR , + 'ServiceNotAvailableError' : WebAPIException.SERVICE_NOT_AVAILABLE_ERR , + 'SecurityError' : WebAPIException.SECURITY_ERR , + 'NetworkError' : WebAPIException.NETWORK_ERR , + 'NotSupportedError' : WebAPIException.NOT_SUPPORTED_ERR , + 'NotFoundError' : WebAPIException.NOT_FOUND_ERR , + 'InvalidAccessError' : WebAPIException.INVALID_ACCESS_ERR , + 'AbortError' : WebAPIException.ABORT_ERR , + 'QuotaExceededError' : WebAPIException.QUOTA_EXCEEDED_ERR , } function callNative(cmd, args) { @@ -41,7 +41,7 @@ function callNative(cmd, args) { var result = JSON.parse(resultString); if (typeof result !== 'object') { - throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR); + throw new WebAPIException(WebAPIException.UNKNOWN_ERR); } if (result['status'] == 'success') { @@ -53,9 +53,9 @@ function callNative(cmd, args) { var err = result['error']; if(err) { if(ExceptionMap[err.name]) { - throw new tizen.WebAPIException(ExceptionMap[err.name], err.message); + throw new WebAPIException(ExceptionMap[err.name], err.message); } else { - throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR, err.message); + throw new WebAPIException(WebAPIException.UNKNOWN_ERR, err.message); } } return false; @@ -77,8 +77,8 @@ function SetReadOnlyProperty(obj, n, v){ } var PowerResource = { - 'SCREEN': 'SCREEN', - 'CPU': 'CPU' + 'SCREEN': 'SCREEN', + 'CPU': 'CPU' }; /** @@ -86,10 +86,10 @@ var PowerResource = { * @enum {string} */ var PowerScreenState = { - 'SCREEN_OFF': 'SCREEN_OFF', - 'SCREEN_DIM': 'SCREEN_DIM', - 'SCREEN_NORMAL': 'SCREEN_NORMAL', - 'SCREEN_BRIGHT': 'SCREEN_BRIGHT' + 'SCREEN_OFF': 'SCREEN_OFF', + 'SCREEN_DIM': 'SCREEN_DIM', + 'SCREEN_NORMAL': 'SCREEN_NORMAL', + 'SCREEN_BRIGHT': 'SCREEN_BRIGHT' }; /** @@ -97,7 +97,7 @@ var PowerScreenState = { * @enum {string} */ var PowerCpuState = { - 'CPU_AWAKE': 'CPU_AWAKE' + 'CPU_AWAKE': 'CPU_AWAKE' }; /** @@ -117,10 +117,10 @@ function PowerManager() { */ PowerManager.prototype.request = function(resource, state) { var args = validator_.validateArgs(arguments, [ - {'name' : 'resource', 'type': types_.ENUM, 'values' : ['SCREEN', 'CPU']}, - {'name' : 'state', 'type': types_.ENUM, 'values' : ['SCREEN_OFF', 'SCREEN_DIM', 'SCREEN_NORMAL', 'SCREEN_BRIGHT', 'CPU_AWAKE']} + {'name' : 'resource', 'type': types_.ENUM, 'values' : ['SCREEN', 'CPU']}, + {'name' : 'state', 'type': types_.ENUM, 'values' : ['SCREEN_OFF', 'SCREEN_DIM', 'SCREEN_NORMAL', 'SCREEN_BRIGHT', 'CPU_AWAKE']} ]); - + var nativeParam = { }; @@ -130,7 +130,7 @@ PowerManager.prototype.request = function(resource, state) { if (args['state']) { nativeParam['state'] = args.state; } - + try { var syncResult = callNative('PowerManager_request', nativeParam); // if you need synchronous result from native function using 'syncResult'. @@ -146,18 +146,18 @@ PowerManager.prototype.request = function(resource, state) { */ PowerManager.prototype.release = function(resource) { var args = validator_.validateArgs(arguments, [ - {'name' : 'resource', 'type': types_.ENUM, 'values' : ['SCREEN', 'CPU']} + {'name' : 'resource', 'type': types_.ENUM, 'values' : ['SCREEN', 'CPU']} ]); if (!PowerResource.hasOwnProperty(args.resource)) - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); - + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); + var nativeParam = { }; if (args['resource']) { nativeParam['resource'] = args.resource; - } + } try { var syncResult = callNative('PowerManager_release', nativeParam); // if you need synchronous result from native function using 'syncResult'. @@ -194,13 +194,13 @@ PowerManager.prototype.getScreenBrightness = function() { var nativeParam = { }; var syncResult = 0; - + try { syncResult = callNative('PowerManager_getScreenBrightness', nativeParam); // if you need synchronous result from native function using 'syncResult'. } catch(e) { throw e; - } + } return syncResult; } @@ -211,12 +211,12 @@ PowerManager.prototype.getScreenBrightness = function() { */ PowerManager.prototype.setScreenBrightness = function(brightness) { var args = validator_.validateArgs(arguments, [ - {'name' : 'brightness', 'type': types_.DOUBLE} + {'name' : 'brightness', 'type': types_.DOUBLE} ]); if (args.brightness < 0 || args.brightness > 1) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); - + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); + var nativeParam = { 'brightness': args.brightness }; @@ -236,8 +236,8 @@ PowerManager.prototype.isScreenOn = function() { var nativeParam = { }; var syncResult = 0; - - try { + + try { syncResult = callNative('PowerManager_isScreenOn', nativeParam); // if you need synchronous result from native function using 'syncResult'. } catch(e) { @@ -253,7 +253,7 @@ PowerManager.prototype.isScreenOn = function() { PowerManager.prototype.restoreScreenBrightness = function() { var nativeParam = { }; - + try { var syncResult = callNative('PowerManager_restoreScreenBrightness', nativeParam); // if you need synchronous result from native function using 'syncResult'. @@ -268,7 +268,7 @@ PowerManager.prototype.restoreScreenBrightness = function() { PowerManager.prototype.turnScreenOn = function() { var nativeParam = { }; - + try { var syncResult = callNative('PowerManager_turnScreenOn', nativeParam); // if you need synchronous result from native function using 'syncResult'. diff --git a/src/radio/radio_api.js b/src/radio/radio_api.js index c33f925..672f4ca 100644 --- a/src/radio/radio_api.js +++ b/src/radio/radio_api.js @@ -213,8 +213,8 @@ FMRadioManager.prototype.start = function() { if (args.frequency) { if (args.frequency < this.frequencyLowerBound || args.frequency > this.frequencyUpperBound) - throw new tizen.WebAPIException( - tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException( + WebAPIException.INVALID_VALUES_ERR, 'Frequency out of bounds'); } var result = native_.callSync('FMRadio_Start', { diff --git a/src/sensor/sensor_api.js b/src/sensor/sensor_api.js index 3aa8317..d9e4d66 100644 --- a/src/sensor/sensor_api.js +++ b/src/sensor/sensor_api.js @@ -104,8 +104,8 @@ SensorListener.prototype.getData = function (successCallback, errorCallback) { if (!thisObj.isStarted) { setTimeout(function() { if (!T_.isNullOrUndefined(errorCallback)) { - errorCallback(new tizen.WebAPIException( - tizen.WebAPIException.SERVICE_NOT_AVAILABLE_ERR, + errorCallback(new WebAPIException( + WebAPIException.SERVICE_NOT_AVAILABLE_ERR, 'Service is not available.')); } }, 0); @@ -169,7 +169,7 @@ SensorService.prototype.getDefaultSensor = function() { var index = _supportedSensors.indexOf(args.type); if (index === -1) { - throw new tizen.WebAPIException(tizen.WebAPIException.NOT_SUPPORTED_ERR, 'Not supported.'); + throw new WebAPIException(WebAPIException.NOT_SUPPORTED_ERR, 'Not supported.'); } else if (_supportedSensors[index] === SensorType.LIGHT) { return new LightSensor(); } else if (_supportedSensors[index] === SensorType.MAGNETIC) { diff --git a/src/sound/sound_api.js b/src/sound/sound_api.js index cbf94c8..3e2ebd9 100644 --- a/src/sound/sound_api.js +++ b/src/sound/sound_api.js @@ -100,7 +100,7 @@ SoundManager.prototype.setVolume = function(type, volume) { ]); if (args.volume < 0 || args.volume > 1) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); } var result = native_.callSync('SoundManager_setVolume', args); if (native_.isFailure(result)) { diff --git a/src/systeminfo/systeminfo_api.js b/src/systeminfo/systeminfo_api.js index d1551a2..0d00195 100644 --- a/src/systeminfo/systeminfo_api.js +++ b/src/systeminfo/systeminfo_api.js @@ -649,7 +649,7 @@ var _createProperty = function (property, data) { if (_propertyContainer[property]){ return new _propertyContainer[property].constructor(data); } else { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + property + ' is not supported.'); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + property + ' is not supported.'); } }; @@ -662,7 +662,7 @@ var _createPropertyArray = function (property, data) { propertyArray.push(new _propertyContainer[property].constructor(jsonArray[i])); } } else { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + property + ' is not supported.'); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + property + ' is not supported.'); } return propertyArray; }; @@ -689,7 +689,7 @@ var getPropertyFunction = function(cppLabel, objectCreateFunction) { ]); var propObject = _propertyContainer[args.property]; if (!propObject) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + args.property + ' is not supported.'); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + args.property + ' is not supported.'); } var callback = function(result) { if (native_.isFailure(result)) { @@ -1037,7 +1037,7 @@ var _registerListener = function (property, listener, errorCallback) { var propObject = _propertyContainer[property]; if (!propObject) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + property + ' is not supported.'); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + property + ' is not supported.'); } var callbackBroadcastFunction = propObject.broadcastFunction; var signalLabel = propObject.signalLabel; @@ -1070,7 +1070,7 @@ var _identifyListener = function (watchId) { return p; } } - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, 'Listener with id: ' + watchId + ' does not exist.'); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Listener with id: ' + watchId + ' does not exist.'); }; var _unregisterListener = function (watchId, isTimeout) { diff --git a/src/systemsetting/systemsetting_api.js b/src/systemsetting/systemsetting_api.js index ed6d608..50c0134 100644 --- a/src/systemsetting/systemsetting_api.js +++ b/src/systemsetting/systemsetting_api.js @@ -11,7 +11,7 @@ var types_ = validator_.Types; var native_ = new xwalk.utils.NativeManager(extension); function throwException_(err) { - throw new tizen.WebAPIException(err.code, err.name, err.message); + throw new WebAPIException(err.code, err.name, err.message); } function callSync_(msg) { diff --git a/src/time/time_api.js b/src/time/time_api.js index 846e1af..aba4258 100644 --- a/src/time/time_api.js +++ b/src/time/time_api.js @@ -69,7 +69,7 @@ exports.getTimeFormat = function() { exports.isLeapYear = function(year) { if (year === undefined) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); }; @@ -141,11 +141,11 @@ exports.unsetTimezoneChangeListener = function() { function _throwProperTizenException(e) { if (e instanceof TypeError) - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); else if (e instanceof RangeError) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); else - throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR); + throw new WebAPIException(WebAPIException.UNKNOWN_ERR); } var TimeDurationUnit = { @@ -305,7 +305,7 @@ tizen.TZDate = function(year, month, day, hours, minutes, seconds, milliseconds, this.date_ = new Date(year, month, day, hours, minutes, seconds, milliseconds); if (tizen.time.getAvailableTimezones().indexOf(this.timezone_) < 0) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); }; function getTimezoneOffset(_timezone, _timeInMs) { @@ -548,7 +548,7 @@ tizen.TZDate.prototype.toTimezone = function() { }]); if (!args.timezone) - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR); + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR); var d = new tizen.TZDate(new Date(this.date_.getTime()), args.timezone); return d.addDuration(new tizen.TimeDuration((getTimezoneOffset(args.timezone) * 1) + (getTimezoneOffset(this.timezone_) * -1))); diff --git a/src/tizen/tizen_api.js b/src/tizen/tizen_api.js index f75486d..5263e2c 100644 --- a/src/tizen/tizen_api.js +++ b/src/tizen/tizen_api.js @@ -6,179 +6,9 @@ // Tizen API Specification: // https://developer.tizen.org/dev-guide/2.3.0/org.tizen.mobile.web.device.apireference/tizen/tizen.html -function __isObject(object) { - return object instanceof Object; -} - -function __isUndefined(object) { - return object === void 0; -} - -function __isNumber(object) { - return typeof object === 'number'; -} - -// WARNING! This list should be in sync with the equivalent enum -// located at tizen.h. Remember to update tizen.h if you change -// something here. -var errors = { - NO_ERROR: 0, - UNKNOWN_ERR: -1, - - INDEX_SIZE_ERR: 1, - DOMSTRING_SIZE_ERR: 2, - HIERARCHY_REQUEST_ERR: 3, - WRONG_DOCUMENT_ERR: 4, - INVALID_CHARACTER_ERR: 5, - NO_DATA_ALLOWED_ERR: 6, - NO_MODIFICATION_ALLOWED_ERR: 7, - NOT_FOUND_ERR: 8, - NOT_SUPPORTED_ERR: 9, - INUSE_ATTRIBUTE_ERR: 10, - INVALID_STATE_ERR: 11, - SYNTAX_ERR: 12, - INVALID_MODIFICATION_ERR: 13, - NAMESPACE_ERR: 14, - INVALID_ACCESS_ERR: 15, - VALIDATION_ERR: 16, - TYPE_MISMATCH_ERR: 17, - SECURITY_ERR: 18, - NETWORK_ERR: 19, - ABORT_ERR: 20, - URL_MISMATCH_ERR: 21, - QUOTA_EXCEEDED_ERR: 22, - TIMEOUT_ERR: 23, - INVALID_NODE_TYPE_ERR: 24, - DATA_CLONE_ERR: 25, - - // Error codes for these errors are not really defined anywhere. - INVALID_VALUES_ERR: 100, - IO_ERR: 101, - PERMISSION_DENIED_ERR: 102, - SERVICE_NOT_AVAILABLE_ERR: 103, - DATABASE_ERR: 104 -}; - -var code_to_name = {}; -code_to_name[errors['NO_ERROR']] = 'NoError'; -code_to_name[errors['UNKNOWN_ERR']] = 'UnknownError'; -code_to_name[errors['INDEX_SIZE_ERR']] = 'IndexSizeError'; -code_to_name[errors['DOMSTRING_SIZE_ERR']] = 'DOMStringSizeError'; -code_to_name[errors['HIERARCHY_REQUEST_ERR']] = 'HierarchyRequestError'; -code_to_name[errors['WRONG_DOCUMENT_ERR']] = 'WrongDocumentError'; -code_to_name[errors['INVALID_CHARACTER_ERR']] = 'InvalidCharacterError'; -code_to_name[errors['NO_DATA_ALLOWED_ERR']] = 'NoDataAllowedError'; -code_to_name[errors['NO_MODIFICATION_ALLOWED_ERR']] = 'NoModificationAllowedError'; -code_to_name[errors['NOT_FOUND_ERR']] = 'NotFoundError'; -code_to_name[errors['NOT_SUPPORTED_ERR']] = 'NotSupportedError'; -code_to_name[errors['INUSE_ATTRIBUTE_ERR']] = 'InuseAttributeError'; -code_to_name[errors['INVALID_STATE_ERR']] = 'InvalidStateError'; -code_to_name[errors['SYNTAX_ERR']] = 'SyntaxError'; -code_to_name[errors['INVALID_MODIFICATION_ERR']] = 'InvalidModificationError'; -code_to_name[errors['NAMESPACE_ERR']] = 'NamespaceError'; -code_to_name[errors['INVALID_ACCESS_ERR']] = 'InvalidAccessError'; -code_to_name[errors['VALIDATION_ERR']] = 'ValidationError'; -code_to_name[errors['TYPE_MISMATCH_ERR']] = 'TypeMismatchError'; -code_to_name[errors['SECURITY_ERR']] = 'SecurityError'; -code_to_name[errors['NETWORK_ERR']] = 'NetworkError'; -code_to_name[errors['ABORT_ERR']] = 'AbortError'; -code_to_name[errors['URL_MISMATCH_ERR']] = 'URLMismatchError'; -code_to_name[errors['QUOTA_EXCEEDED_ERR']] = 'QuotaExceededError'; -code_to_name[errors['TIMEOUT_ERR']] = 'TimeoutError'; -code_to_name[errors['INVALID_NODE_TYPE_ERR']] = 'InvalidNodeTypeError'; -code_to_name[errors['DATA_CLONE_ERR']] = 'DataCloneError'; - -code_to_name[errors['INVALID_VALUES_ERR']] = 'InvalidValuesError'; -code_to_name[errors['IO_ERR']] = 'IOError'; -code_to_name[errors['PERMISSION_DENIED_ERR']] = 'PermissionDeniedError'; -code_to_name[errors['SERVICE_NOT_AVAILABLE_ERR']] = 'ServiceNotAvailableError'; -code_to_name[errors['DATABASE_ERR']] = 'DatabaseError'; - -var name_to_code = {}; -Object.keys(errors).forEach(function(key) { - name_to_code[code_to_name[errors[key]]] = errors[key]; -}); - - -/** - * Generic exception interface. - * - * @param {number} code 16-bit error code. - * @param {string} message An error message that describes the details of an encountered error. - * @param {string} name An error type. - */ -var WebAPIException = function(code, message, name) { - var code_ = 0; - var name_ = code_to_name[code]; - var message_ = 'Unknown error'; - - switch (arguments.length) { - case 1: - var error = arguments[0]; - if (__isObject(error)) { - code_ = error.code; - name_ = error.name; - message_ = error.message; - if (__isUndefined(code_) && !__isUndefined(name_)) - code_ = name_to_code[name_]; - if (__isUndefined(name_) && !__isUndefined(code_)) - name_ = code_to_name[code_]; - } else if (__isNumber(error)) { - // backward compatibility with crosswalk implementation - code_ = error; - name_ = code_to_name[code]; - message_ = name_; - } - break; - case 2: - if (__isNumber(arguments[0])) { - code_ = arguments[0]; - if (!__isUndefined(code_to_name[code_])) { - name_ = code_to_name[code_]; - } - } else { - name_ = String(arguments[0]); - if (!__isUndefined(name_to_code[name_])) { - code_ = name_to_code[name_]; - } - } - message_ = String(arguments[1]); - break; - case 3: - // backward compatibility with crosswalk implementation - code_ = Number(arguments[0]); - message_ = String(arguments[1]); - name_ = String(arguments[2]); - break; - default: - return; - } - - // attributes - Object.defineProperties(this, { - code: {value: code_, writable: false, enumerable: true}, - name: {value: name_, writable: false, enumerable: true}, - message: {value: message_, writable: false, enumerable: true} - }); - - this.constructor.prototype.__proto__ = Error.prototype; - Error.captureStackTrace(this, this.constructor); -}; - -WebAPIException.prototype.toString = function() { - return this.name + ': ' + this.message; -}; - - -var error_constants = {}; -for (var prop in errors) { - error_constants[prop] = {value: errors[prop], writable: false, enumerable: true}; -} -Object.defineProperties(WebAPIException, error_constants); -Object.defineProperties(WebAPIException.prototype, error_constants); -exports.WebAPIException = WebAPIException; -exports.WebAPIError = WebAPIException; +// WebAPIException and WebAPIError definition moved to src/utils/utils_api.js +// for compliance reasons. You can find more info there. /** @@ -236,7 +66,7 @@ function _extractProperty(obj, attributeName) { } if (!obj.hasOwnProperty(props[i])) { if (i === props.length - 1) { - throw new tizen.WebAPIException('InvalidValuesError', 'Property "' + attributeName + + throw new WebAPIException('InvalidValuesError', 'Property "' + attributeName + '" is not valid'); } return null; @@ -250,7 +80,7 @@ function _extractProperty(obj, attributeName) { /** * This is a common interface used by different types of object filters. */ -exports.AbstractFilter = function() {}; +var AbstractFilter = function() {}; /** @@ -312,7 +142,7 @@ exports.AttributeFilter = function(attrName, matchFlag, matchValue) { } }); }; -exports.AttributeFilter.prototype = new exports.AbstractFilter(); +exports.AttributeFilter.prototype = new AbstractFilter(); //TODO: Move filtering to native code exports.AttributeFilter.prototype._filter = function(element) { @@ -417,7 +247,7 @@ exports.AttributeRangeFilter = function(attrName, start, end) { }); }; -exports.AttributeRangeFilter.prototype = new exports.AbstractFilter(); +exports.AttributeRangeFilter.prototype = new AbstractFilter(); //TODO: Move filtering to native code exports.AttributeRangeFilter.prototype._filter = function(element) { @@ -496,7 +326,7 @@ exports.CompositeFilter = function(type, filters) { return; for (var i in filterList) { - var valid = (filterList[i] instanceof tizen.AbstractFilter); + var valid = (filterList[i] instanceof AbstractFilter); if (!valid) return; } @@ -525,7 +355,7 @@ exports.CompositeFilter = function(type, filters) { }); }; -exports.CompositeFilter.prototype = new exports.AbstractFilter(); +exports.CompositeFilter.prototype = new AbstractFilter(); //TODO: Move filtering to native code exports.CompositeFilter.prototype._filter = function(element) { diff --git a/src/tvaudio/tvaudio_api.js b/src/tvaudio/tvaudio_api.js index 216b56e..52ff514 100644 --- a/src/tvaudio/tvaudio_api.js +++ b/src/tvaudio/tvaudio_api.js @@ -79,12 +79,12 @@ AudioControlManager.prototype.setVolume = function(volume) { ]); if (args.volume < 0 || args.volume > 100) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Volume is out of range: ' + args.volume, 'InvalidValuesError'); } if (arguments.length < 1) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'no volume argument: ' + arguments.length, 'InvalidValuesError'); } diff --git a/src/tvchannel/tvchannel_api.js b/src/tvchannel/tvchannel_api.js index 08b49cc..a36b987 100644 --- a/src/tvchannel/tvchannel_api.js +++ b/src/tvchannel/tvchannel_api.js @@ -310,11 +310,11 @@ TVChannelManager.prototype.getChannelList = function(successCallback, } ]); if (args.nStart < 0) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, "nStart is lower than 0"); } if (args.number < 0) { - throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, + throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, "number is lower than 0"); } native.call('TVChannelManager_getChannelList', { diff --git a/src/tvdisplay/tvdisplay_api.js b/src/tvdisplay/tvdisplay_api.js index 3e3048a..ccb26b4 100644 --- a/src/tvdisplay/tvdisplay_api.js +++ b/src/tvdisplay/tvdisplay_api.js @@ -80,7 +80,7 @@ TVDisplay.prototype.get3DEffectMode = function() { var mode = Display3DEffectMode[native.getResultObject(ret)]; if (!mode) { var error_msg = 'Unknown 3D effect mode (' + reply.result + ')'; - throw new tizen.WebAPIException(0, error_msg, UNKNOWN_ERROR); + throw new WebAPIException(0, error_msg, UNKNOWN_ERROR); } return mode; }; diff --git a/src/utils/utils_api.js b/src/utils/utils_api.js index 01e0e5e..36b9225 100644 --- a/src/utils/utils_api.js +++ b/src/utils/utils_api.js @@ -217,7 +217,7 @@ Converter.prototype.toOctet = function(val, nullable) { function _toDouble(val) { var ret = Number(val); if (isNaN(ret) || !isFinite(ret)) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Cannot convert ' + String(val) + ' to double.'); } return ret; @@ -259,7 +259,7 @@ function _toPlatformObject(val, types) { return val; } - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Cannot convert ' + String(val) + ' to ' + String(t[0].name) + '.'); } @@ -272,7 +272,7 @@ function _toFunction(val) { return val; } - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Cannot convert ' + String(val) + ' to function.'); } @@ -285,7 +285,7 @@ function _toArray(val) { return val; } - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Cannot convert ' + String(val) + ' to array.'); } @@ -298,7 +298,7 @@ function _toDictionary(val) { return val; } - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Cannot convert ' + String(val) + ' to dictionary.'); } @@ -312,7 +312,7 @@ function _toEnum(val, e) { return v; } - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Cannot convert ' + v + ' to enum.'); } @@ -519,18 +519,18 @@ Validator.prototype.validateArgs = function(a, d) { case this.Types.LISTENER: if (_type.isNull(val)) { if (!nullable) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "' + name + '" cannot be null.'); } } else { if (!_type.isFunction(val)) { if (_type.isEmptyObject(val)) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "' + name + '" shouldn\'t be an empty object.'); } } if (!_type.isObject(val)) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "' + name + '" should be an object.'); } for (var ii = 0; ii < values.length; ++ii) { @@ -586,7 +586,7 @@ Validator.prototype.validateArgs = function(a, d) { default: func = function(val) { if (!(val instanceof values)) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Items of array "' + name + '" should be of type: ' + values + '.'); } return val; @@ -604,14 +604,14 @@ Validator.prototype.validateArgs = function(a, d) { break; default: - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Unknown type: "' + type + '".'); } var _validator = d[i].validator; if (_type.isFunction(_validator) && !_validator(val)) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Argument "' + name + '" did not pass additional validation.'); } @@ -641,7 +641,7 @@ Validator.prototype.isConstructorCall = function(obj, instance) { if (!(obj instanceof instance) || obj._previouslyConstructed) { // There is no TypeError exception in Tizen 2.3.0 API spec but it's required by current TCTs. // For Tizen compliance it's wrapped into WebAPIException. - throw new tizen.WebAPIException('TypeError', 'Constructor cannot be called as function.'); + throw new WebAPIException('TypeError', 'Constructor cannot be called as function.'); } Object.defineProperty(obj, '_previouslyConstructed', { @@ -714,7 +714,7 @@ var NativeManager = function(extension) { !_type.isFunction(extension.postMessage) || !_type.isFunction(extension.internal.sendSyncMessage) || !_type.isFunction(extension.setMessageListener)) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Wrong extension object passed'); } @@ -792,7 +792,7 @@ NativeManager.prototype.callSync = function(cmd, args) { NativeManager.prototype.addListener = function(name, callback) { if (!_type.isString(name) || !name.length) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR); + throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } this.listeners_[name] = callback; @@ -821,7 +821,7 @@ NativeManager.prototype.getResultObject = function(result) { }; NativeManager.prototype.getErrorObject = function(result) { - return new tizen.WebAPIException(result.error); + return new WebAPIException(result.error); }; NativeManager.prototype.callIfPossible = function(callback) { @@ -1024,7 +1024,7 @@ var NativeBridge = (function (extension, debug) { var result = extension.internal.sendSyncMessage(json); var obj = JSON.parse(result); if (obj.error) - throw new tizen.WebAPIException(obj.code, obj.name, obj.message); + throw new WebAPIException(obj.code, obj.name, obj.message); return obj.result; }, async: function (data) { @@ -1077,8 +1077,12 @@ var NativeBridge = (function (extension, debug) { return new Bridge; }); -// WebAPIException and WebAPIError - +// WebAPIException and WebAPIError definition moved to Utils for compliance +// reasons with blink-wrt environment. +// In blink-wrt the original Tizen module is loaded, which is not providing exception constructor. +// As modules needs exceptions internally so they are loaded here for now. +// See http://168.219.209.56/gerrit/#/c/23472/ for more details. +// In future exception definition could be moved back to Tizen module. function __isObject(object) { return object instanceof Object; } @@ -1228,17 +1232,11 @@ var WebAPIException = function(code, message, name) { } // attributes - var attributes = { + Object.defineProperties(this, { code: {value: code_, writable: false, enumerable: true}, name: {value: name_, writable: false, enumerable: true}, message: {value: message_, writable: false, enumerable: true} - }; - - for (var error in errors) { - attributes[error] = { value: errors[error], writable: false, enumerable: true} - } - - Object.defineProperties(this, attributes); + }); this.constructor.prototype.__proto__ = Error.prototype; Error.captureStackTrace(this, this.constructor); @@ -1248,12 +1246,27 @@ WebAPIException.prototype.toString = function() { return this.name + ': ' + this.message; }; -function getExceptionClass() { - return WebAPIException; -} -Utils.prototype.getExceptionClass = getExceptionClass; -Utils.prototype.getErrorClass = getExceptionClass; +var error_constants = {}; +for (var prop in errors) { + error_constants[prop] = {value: errors[prop], writable: false, enumerable: true}; +} +Object.defineProperties(WebAPIException, error_constants); +Object.defineProperties(WebAPIException.prototype, error_constants); + + +// Export WebAPIException and WebAPIError into global scope. +// For compliance reasons their constructors should not be exported in tizen namespace, +// but should be available internally to allow throwing exceptions from modules. +var scope; +if (typeof window !== 'undefined') { + scope = window; +} else if(typeof global !== 'undefined') { + scope = global; +} +scope = scope || {}; +scope.WebAPIException = WebAPIException; +scope.WebAPIError = WebAPIException; Utils.prototype.type = _type; Utils.prototype.converter = _converter; -- 2.7.4