/*!
- Ripple Mobile Environment Emulator v0.9.8 :: Built On Mon Jul 15 2013 16:17:21 GMT+0800 (CST)
+ Ripple Mobile Environment Emulator v0.9.8 :: Built On Tue Sep 17 2013 16:10:39 GMT+0800 (CST)
Apache License
Version 2.0, January 2004
if (viewportTag !== undefined) {
if (viewportTag['width'] !== undefined) {
- viewportWidth = parseInt(viewportTag['width'], 10);
- if (isNaN(viewportWidth)) {
- viewportWidth = viewportWidth = device.viewPort[layout].width;
+ if (viewportTag['width'] === "device-width") {
+ viewportWidth = device.viewPort[layout].width;
+ } else if (viewportTag['width'] === "device-height") {
+ viewportWidth = device.viewPort[layout].height;
+ }
+ else {
+ viewportWidth = parseInt(viewportTag['width'], 10);
+ if (isNaN(viewportWidth)) {
+ viewportWidth = device.viewPort[layout].width;
+ }
}
db.saveObject("viewport_width", viewportWidth);
db.saveObject("viewport_height", viewportHeight);
}
} else if(viewportTag['height'] !== undefined) {
- viewportHeight = parseInt(viewportTag['height'], 10);
- if (isNaN(viewportHeight)) {
- viewportHeight = viewportHeight = device.viewPort[layout].height;
+ if (viewportTag['height'] === "device-height") {
+ viewportHeight = device.viewPort[layout].height;
+ } else if (viewportTag['height'] === "device-width") {
+ viewportHeight = device.viewPort[layout].width;
+ }
+ else {
+ viewportHeight = parseInt(viewportTag['height'], 10);
+ if (isNaN(viewportHeight)) {
+ viewportHeight = device.viewPort[layout].height;
+ }
}
db.saveObject("viewport_height", viewportHeight);
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
var utils = require('ripple/utils'),
- db = require('ripple/db'),
- app = require('ripple/app'),
- constants = require('ripple/constants');
+ app = require('ripple/app');
function _objectFactory(context, objects/*, allowed*/) {
utils.forEach(objects, function (obj, key) {
_objectFactory(result, obj.children/*, allowed*/);
}
+ context.__defineGetter__(key, function () {
+ return result;
+ });
// inject into the context if it is allowed or it has children that were allowed
// if (allowed(obj) || utils.count(result)) {
- context[key] = result;
+// context[key] = result;
// }
// else {
// if (context.hasOwnProperty(key))
* limitations under the License.
*/
-var utils = require('ripple/utils'),
- tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils'),
- errorcode = require('ripple/platform/tizen/2.0/errorcode'),
- WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
- AlarmBase = require('ripple/platform/tizen/2.0/AlarmBase'),
+var AlarmBase = require('ripple/platform/tizen/2.0/AlarmBase'),
+ t = require('ripple/platform/tizen/2.0/typecast'),
_byDayValue = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"],
PERIOD_WEEK = (7 * 24 * 60 * 60), MILLI_SECOND = 1000,
AlarmAbsolute;
-AlarmAbsolute = function (date, frequency) {
- var alarm, period = null, daysOfTheWeek = [], ascDays = [];
-
- function checkDayValue(days) {
- var isDayType = false, i;
- for (i in days) {
- isDayType = utils.arrayContains(_byDayValue, days[i]);
- if (!isDayType)
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
- return days;
- }
+AlarmAbsolute = function () {
+ var alarm, period = null, daysOfTheWeek = [], ascDays = [], voc, date;
function getScheduleDateByPeriod(current, date, period) {
var diff = period * MILLI_SECOND,
}
alarm = new AlarmBase(this);
- date = new Date(date);
- if (frequency !== undefined) {
- if (tizen1_utils.isValidArray(frequency)) {
- daysOfTheWeek = checkDayValue(frequency);
- if (daysOfTheWeek.length !== 0) {
- period = PERIOD_WEEK;
- }
- } else {
- period = frequency;
+
+ voc = [
+ function (_date, _daysOfTheWeek) {
+ date = _date;
+ daysOfTheWeek = _daysOfTheWeek;
+ period = PERIOD_WEEK;
+ },
+ function (_date, _period) {
+ date = _date;
+ period = _period;
+ },
+ function (_date) {
+ date = _date;
}
- }
+ ];
+
+ t.AlarmAbsolute(arguments, this, voc);
this.getNextScheduledDate = function () {
var current = new Date(),
};
this.__defineGetter__("date", function () {
- return date;
+ return new Date(date);
});
this.__defineGetter__("period", function () {
*/
var AlarmBase = require('ripple/platform/tizen/2.0/AlarmBase'),
+ t = require('ripple/platform/tizen/2.0/typecast'),
AlarmRelative;
AlarmRelative = function (delay, period) {
var alarm, date;
+ t.AlarmRelative(arguments, this);
+
alarm = new AlarmBase(this);
- delay = delay || 0;
period = period || null;
date = new Date(); // Alarm settime
* limitations under the License.
*/
-var t = require('ripple/platform/tizen/2.0/typecast');
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ ApplicationControlData = require('ripple/platform/tizen/2.0/ApplicationControlData');
var ApplicationControl = function (operation, uri, mime, category, data) {
- var _data = [];
+ var i, _data = [];
- this.operation = t.DOMString(operation);
- this.uri = t.DOMString(uri, "?") || null;
- this.mime = t.DOMString(mime, "?");
- this.category = t.DOMString(category, "?");
+ t.ApplicationControl(arguments, this);
+
+ this.operation = operation;
+ this.uri = uri || null;
+ this.mime = mime || null;
+ this.category = category || null;
if (data) {
- _data = t.ApplicationControlData(data, "[]?");
+ for (i in data) {
+ _data[i] = new ApplicationControlData(data[i].key,
+ data[i].value);
+ }
}
this.__defineGetter__("data", function () {
});
this.__defineSetter__("data", function (data) {
+ var i;
+
data = data || [];
- _data = t.ApplicationControlData(data, "[]");
+ data = t.ApplicationControlData(data, "[]");
+
+ for (i in data) {
+ _data[i] = new ApplicationControlData(data[i].key,
+ data[i].value);
+ }
});
};
var t = require('ripple/platform/tizen/2.0/typecast');
var ApplicationControlData = function (key, value) {
- var val = [];
+ var val;
- this.key = t.DOMString(key);
- val = t.DOMString(value, '[]');
+ t.ApplicationControlData(arguments, this);
+
+ this.key = key;
+ val = value || [];
this.__defineGetter__("value", function () {
return val;
* limitations under the License.
*/
-module.exports = function (title) {
- this.parent = undefined;
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ BookmarkFolder;
+
+BookmarkFolder = function (title) {
+ t.BookmarkFolder(arguments, this);
+
+ this.__defineGetter__("parent", function () {
+ return undefined;
+ });
+
this.__defineGetter__("title", function () {
return title;
});
-
- title = title ? String(title).trim() : "";
};
+module.exports = BookmarkFolder;
+
});
define('ripple/platform/tizen/2.0/BookmarkItem', function (require, exports, module) {
/*
* limitations under the License.
*/
-module.exports = function (title, url) {
- this.parent = undefined;
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ BookmarkItem;
+
+BookmarkItem = function (title, url) {
+ t.BookmarkItem(arguments, this);
+
+ this.__defineGetter__("parent", function () {
+ return undefined;
+ });
this.__defineGetter__("title", function () {
return title;
});
this.__defineGetter__("url", function () {
return url;
});
-
- title = title ? String(title).trim() : "";
- url = url ? String(url).trim() : "";
};
+module.exports = BookmarkItem;
+
});
define('ripple/platform/tizen/2.0/CalendarAlarm', function (require, exports, module) {
/*
var utils = require('ripple/utils'),
errorcode = require('ripple/platform/tizen/2.0/errorcode'),
TZDate = require('ripple/platform/tizen/2.0/TZDate'),
+ TDur = require('ripple/platform/tizen/2.0/TimeDuration'),
CalendarItem = require('ripple/platform/tizen/2.0/CalendarItem'),
tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils'),
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
_self = new CalendarItem("EVENT");
if ((eventInitDict !== undefined) && (eventInitDict !== null)) {
- _self.endDate = tizen1_utils.isValidTZDate(eventInitDict.endDate) ? (new TZDate(new Date(eventInitDict.endDate))) : null;
+ _self.endDate = tizen1_utils.isValidTZDate(eventInitDict.endDate) ? eventInitDict.endDate.addDuration(new TDur(0, "MSECS")) : null;
_self.availability = (eventInitDict.availability) ? String(eventInitDict.availability) : "BUSY";
_self.recurrenceRule = utils.copy(eventInitDict.recurrenceRule);
if (eventInitDict.description) {
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
WebAPIException = require('ripple/platform/tizen/2.0/WebAPIException'),
TZDate = require('ripple/platform/tizen/2.0/TZDate'),
+ TDur = require('ripple/platform/tizen/2.0/TimeDuration'),
SimpleCoordinates = require('ripple/platform/tizen/2.0/SimpleCoordinates'),
CalendarItemInit,
CalendarEventInit,
CalendarItem;
CalendarItem = function (type, id, lastModificationDate, _security) {
- var _self;
+ var _self, _id;
function _2digital(number) {
return ((number >= 10) ? '' : '0') + number;
if (type === "EVENT") {
_self = new CalendarEventInit();
- id = {
- uid: id || Math.uuid(null, 16),
- rid: null
- };
+ _id = id ? {uid: id, rid: null} : null;
} else {
_self = new CalendarTaskInit();
- id = id || Math.uuid(null, 16);
+ _id = id || null;
}
- lastModificationDate = (lastModificationDate) ? utils.copy(lastModificationDate) : null;
+ lastModificationDate = tizen1_utils.isValidTZDate(lastModificationDate) ? lastModificationDate.addDuration(new TDur(0, 'MSECS')): null;
_self.status = (type === "EVENT") ? "CONFIRMED" : "NEEDS_ACTION";
_self.__defineGetter__("calendarId", function () {
});
_self.__defineGetter__("id", function () {
- return id;
+ return _id;
});
_self.__defineGetter__("lastModificationDate", function () {
description: "",
summary: "",
isAllDay: false,
- startDate: null,
+ startDate: undefined,
duration: null,
location: "",
geolocation: new SimpleCoordinates(),
var utils = require('ripple/utils'),
tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils'),
+ TDur = require('ripple/platform/tizen/2.0/TimeDuration'),
TZDate = require('ripple/platform/tizen/2.0/TZDate');
module.exports = function (frequency, ruleInitDict) {
if ((ruleInitDict !== undefined) && (ruleInitDict !== null)) {
_self.interval = ((ruleInitDict.interval > 0) && (ruleInitDict.interval === parseInt(ruleInitDict.interval, 10))) ? Number(ruleInitDict.interval) : 1;
- _self.untilDate = tizen1_utils.isValidTZDate(ruleInitDict.untilDate) ? (new TZDate(new Date(ruleInitDict.untilDate))) : null;
+ _self.untilDate = tizen1_utils.isValidTZDate(ruleInitDict.untilDate) ? (ruleInitDict.untilDate.addDuration(new TDur(0, 'MSECS'))) : null;
_self.occurrenceCount = (ruleInitDict.occurrenceCount === parseInt(ruleInitDict.occurrenceCount, 10)) ? Number(ruleInitDict.occurrenceCount) : -1;
_self.daysOfTheWeek = tizen1_utils.isValidArray(ruleInitDict.daysOfTheWeek) ? utils.copy(ruleInitDict.daysOfTheWeek) : [];
_self.setPositions = tizen1_utils.isValidArray(ruleInitDict.setPositions) ? utils.copy(ruleInitDict.setPositions) : [];
*/
var TZDate = require('ripple/platform/tizen/2.0/TZDate'),
+ TDur = require('ripple/platform/tizen/2.0/TimeDuration'),
CalendarItem = require('ripple/platform/tizen/2.0/CalendarItem'),
tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils'),
SimpleCoordinates = require('ripple/platform/tizen/2.0/SimpleCoordinates');
_self = new CalendarItem("TASK");
if ((taskInitDict !== undefined) && (taskInitDict !== null)) {
- _self.dueDate = tizen1_utils.isValidTZDate(taskInitDict.dueDate) ? (new TZDate(new Date(taskInitDict.dueDate))) : undefined;
- _self.completedDate = tizen1_utils.isValidTZDate(taskInitDict.completedDate) ? (new TZDate(new Date(taskInitDict.completedDate))) : undefined;
+ _self.dueDate = tizen1_utils.isValidTZDate(taskInitDict.dueDate) ? taskInitDict.dueDate.addDuration(new TDur(0, 'MSECS')) : undefined;
+ _self.completedDate = tizen1_utils.isValidTZDate(taskInitDict.completedDate) ? taskInitDict.completedDate.addDuration(new TDur(0, 'MSECS')) : undefined;
_self.progress = ((0 <= taskInitDict.progress) && (taskInitDict.progress <= 100)) ? Number(taskInitDict.progress) : 0;
if (taskInitDict.description) {
});
-define('ripple/platform/tizen/2.0/ContactAccount', function (require, exports, module) {
-/*
- * Copyright 2012 Intel Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-module.exports = function (id, accountURI) {
- var _self, _id, _uri;
-
- if (id) {
- _id = String(id);
- }
-
- if (accountURI) {
- _uri = String(accountURI);
- }
-
- _self = {
- accountServiceId : _id,
- contactURI : _uri
- };
-
- return _self;
-};
-
-});
define('ripple/platform/tizen/2.0/ContactAddress', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation.
+ * Copyright 2013 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-var tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils');
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ ContactAddress;
-module.exports = function (addressInitDict) {
- var _self, type, i;
-
- _self = {
- country: undefined,
- region: undefined,
- city: undefined,
- streetAddress: undefined,
- additionalInformation: undefined,
- postalCode: undefined,
- isDefault: false,
- types: undefined
- };
+ContactAddress = function (addressInitDict) {
+ var i;
- if (addressInitDict) {
- if (addressInitDict.country !== null && addressInitDict.country !== undefined) {
- _self.country = String(addressInitDict.country);
- }
- if (addressInitDict.region !== null && addressInitDict.region !== undefined) {
- _self.region = String(addressInitDict.region);
- }
- if (addressInitDict.city !== null && addressInitDict.city !== undefined) {
- _self.city = String(addressInitDict.city);
- }
- if (addressInitDict.streetAddress !== null && addressInitDict.streetAddress !== undefined) {
- _self.streetAddress = String(addressInitDict.streetAddress);
- }
- if (addressInitDict.additionalInformation !== null && addressInitDict.additionalInformation !== undefined) {
- _self.additionalInformation = String(addressInitDict.additionalInformation);
- }
- if (addressInitDict.postalCode !== null && addressInitDict.postalCode !== undefined) {
- _self.postalCode = String(addressInitDict.postalCode);
- }
- if (typeof addressInitDict.isDefault === "boolean") {
- _self.isDefault = addressInitDict.isDefault;
- }
- if (tizen1_utils.isValidArray(addressInitDict.types)) {
- _self.types = [];
+ t.ContactAddress(arguments, this);
- for (i in addressInitDict.types) {
- type = String(addressInitDict.types[i]).toUpperCase();
- _self.types.push(type);
- }
+ this.country = null;
+ this.region = null;
+ this.city = null;
+ this.streetAddress = null;
+ this.additionalInformation = null;
+ this.postalCode = null;
+ this.isDefault = false;
+ this.types = ["HOME"];
+
+ if (addressInitDict) {
+ for (i in addressInitDict) {
+ this[i] = addressInitDict[i];
}
}
-
- return _self;
};
+module.exports = ContactAddress;
+
});
define('ripple/platform/tizen/2.0/ContactAnniversary', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation.
+ * Copyright 2013 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-var tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils');
-
-module.exports = function (date, label) {
- var _self;
-
- _self = {
- date: null,
- label: null
- };
-
- _self.date = tizen1_utils.isValidDate(date) ? new Date(date) : new Date();
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ ContactAnniversary;
- if (label) {
- _self.label = String(label);
- }
+ContactAnniversary = function (date, label) {
+ t.ContactAnniversary(arguments, this);
- return _self;
+ this.date = date;
+ this.label = label || null;
};
+module.exports = ContactAnniversary;
+
});
define('ripple/platform/tizen/2.0/ContactBase', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation.
+ * Copyright 2013 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-var utils = require('ripple/utils'),
- errorcode = require('ripple/platform/tizen/2.0/errorcode'),
- WebAPIException = require('ripple/platform/tizen/2.0/WebAPIException'),
- tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils'),
+var decorator = require('ripple/platform/tizen/2.0/decorator'),
+ t = require('ripple/platform/tizen/2.0/typecast'),
ContactName = require('ripple/platform/tizen/2.0/ContactName'),
- ContactOrganization = require('ripple/platform/tizen/2.0/ContactOrganization'),
- ContactWebSite = require('ripple/platform/tizen/2.0/ContactWebSite'),
- ContactAnniversary = require('ripple/platform/tizen/2.0/ContactAnniversary'),
ContactAddress = require('ripple/platform/tizen/2.0/ContactAddress'),
ContactPhoneNumber = require('ripple/platform/tizen/2.0/ContactPhoneNumber'),
- ContactEmailAddress = require('ripple/platform/tizen/2.0/ContactEmailAddress');
-
-function Contact(prop, _security) {
- var _self = this;
+ ContactEmailAddress = require('ripple/platform/tizen/2.0/ContactEmailAddress'),
+ ContactAnniversary = require('ripple/platform/tizen/2.0/ContactAnniversary'),
+ ContactOrganization = require('ripple/platform/tizen/2.0/ContactOrganization'),
+ ContactWebSite = require('ripple/platform/tizen/2.0/ContactWebSite'),
+ Contact;
- // constructor
- function init_ContactInitDict(contactInitDict) {
- var i;
+Contact = function () {
+ var voc;
- if (contactInitDict.name) {
- _self.name = new ContactName(contactInitDict.name);
- }
- if (tizen1_utils.isValidArray(contactInitDict.addresses)) {
- for (i in contactInitDict.addresses) {
- _self.addresses.push(new ContactAddress(contactInitDict.addresses[i]));
- }
- }
- if (contactInitDict.photoURI) {
- _self.photoURI = String(contactInitDict.photoURI);
- }
- if (tizen1_utils.isValidArray(contactInitDict.phoneNumbers)) {
- _self.phoneNumbers = [];
- for (i in contactInitDict.phoneNumbers) {
- _self.phoneNumbers.push(new ContactPhoneNumber(
- contactInitDict.phoneNumbers[i].number, contactInitDict.phoneNumbers[i].types));
- }
- }
- if (tizen1_utils.isValidArray(contactInitDict.emails)) {
- _self.emails = [];
- for (i in contactInitDict.emails) {
- _self.emails.push(new ContactEmailAddress(
- contactInitDict.emails[i].email, contactInitDict.emails[i].types));
- }
- }
- if (tizen1_utils.isValidDate(contactInitDict.birthday)) {
- _self.birthday = new Date(contactInitDict.birthday);
- }
- if (tizen1_utils.isValidArray(contactInitDict.anniversaries)) {
- _self.anniversaries = [];
- for (i in contactInitDict.anniversaries) {
- _self.anniversaries.push(new ContactAnniversary(
- contactInitDict.anniversaries[i].date, contactInitDict.anniversaries[i].label));
- }
- }
- if (tizen1_utils.isValidArray(contactInitDict.organizations)) {
- for (i in contactInitDict.organizations) {
- _self.organizations.push(new ContactOrganization(
- contactInitDict.organizations[i]));
- }
- }
- if (tizen1_utils.isValidArray(contactInitDict.notes)) {
- for (i in contactInitDict.notes) {
- _self.notes.push(String(contactInitDict.notes[i]));
- }
- }
- if (tizen1_utils.isValidArray(contactInitDict.urls)) {
- for (i in contactInitDict.urls) {
- _self.urls.push(new ContactWebSite(
- contactInitDict.urls[i].url, contactInitDict.urls[i].type));
- }
- }
- if (contactInitDict.ringtoneURI) {
- _self.ringtoneURI = String(contactInitDict.ringtoneURI);
- }
- if (tizen1_utils.isValidArray(contactInitDict.groupIds)) {
- for (i in contactInitDict.groupIds) {
- _self.groupIds.push(String(contactInitDict.groupIds[i]));
- }
- }
- }
-
- function init_stringRepresentation(stringRepresentation) {
- //TODO: parse stringRepresentation
- }
+ // private
+ function construct() {
+ this.name = null;
+ this.addresses = [];
+ this.photoURI = null;
+ this.phoneNumbers = [];
+ this.emails = [];
+ this.birthday = null;
+ this.anniversaries = [];
+ this.organizations = [];
+ this.notes = [];
+ this.urls = [];
+ this.ringtoneURI = null;
+ this.groupIds = [];
+ }
+
+ // Constructor
+ function Contact_ContactInit(contactInitDict) {
+ var i, attr, arr;
+
+ construct.apply(this);
+
+ for (attr in contactInitDict) {
+ switch (attr) {
+ case "name":
+ this[attr] = new ContactName(contactInitDict[attr]);
+ break;
- // public
- function convertToString(format) {
- //TODO: convert content accord to Vcard protocal
- if (format !== 'VCARD_30') {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
- return "";
- }
+ case "addresses":
+ arr = contactInitDict[attr];
+ if (arr) {
+ for (i in arr) {
+ this[attr][i] = new ContactAddress(arr[i]);
+ }
+ }
+ break;
- function clone(obj) {
- var copy = new Contact(), attr,
- ignoreProp = ["id", "personId", "addressBookId", "lastUpdated", "isFavorite"];
+ case "phoneNumbers":
+ arr = contactInitDict[attr];
+ if (arr) {
+ for (i in arr) {
+ this[attr][i] = new ContactPhoneNumber(arr[i].number,
+ arr[i].types || null, arr[i].isDefault || null);
+ }
+ }
+ break;
- if (_security instanceof Object && !_security.clone) {
- throw new WebAPIException(errorcode.SECURITY_ERR);
- }
- for (attr in obj) {
- if ((ignoreProp.indexOf(attr) === -1) &&
- obj.hasOwnProperty(attr) &&
- (typeof obj[attr] !== "function")) {
- copy[attr] = utils.copy(obj[attr]);
- }
- }
+ case "emails":
+ arr = contactInitDict[attr];
+ if (arr) {
+ for (i in arr) {
+ this[attr][i] = new ContactEmailAddress(arr[i].email,
+ arr[i].types || null, arr[i].isDefault || null);
+ }
+ }
+ break;
- return copy;
- }
+ case "birthday":
+ this[attr] = new Date(contactInitDict[attr]);
+ break;
- _self.name = null;
- _self.addresses = [];
- _self.photoURI = null;
- _self.phoneNumbers = [];
- _self.emails = [];
- _self.birthday = null;
- _self.anniversaries = [];
- _self.organizations = [];
- _self.notes = [];
- _self.urls = [];
- _self.ringtoneURI = null;
- _self.groupIds = [];
- _self.convertToString = convertToString;
- _self.clone = function () {
- return clone(_self);
- };
+ case "anniversaries":
+ arr = contactInitDict[attr];
+ if (arr) {
+ for (i in arr) {
+ this[attr][i] = new ContactAnniversary(arr[i].date,
+ arr[i].label || null);
+ }
+ }
+ break;
- _self.__defineGetter__("id", function () {
- return null;
- });
+ case "organizations":
+ arr = contactInitDict[attr];
+ if (arr) {
+ for (i in arr) {
+ this[attr][i] = new ContactOrganization(arr[i]);
+ }
+ }
+ break;
- _self.__defineGetter__("personId", function () {
- return null;
- });
+ case "notes":
+ case "groupIds":
+ arr = contactInitDict[attr];
+ if (arr) {
+ for (i in arr) {
+ this[attr][i] = arr[i];
+ }
+ }
+ break;
- _self.__defineGetter__("addressBookId", function () {
- return null;
- });
+ case "urls":
+ arr = contactInitDict[attr];
+ if (arr) {
+ for (i in arr) {
+ this[attr][i] = new ContactWebSite(arr[i].url,
+ arr[i].type || null);
+ }
+ }
+ break;
- _self.__defineGetter__("lastUpdated", function () {
- return null;
- });
+ default:
+ this[attr] = contactInitDict[attr];
+ break;
+ }
+ }
- _self.__defineGetter__("isFavorite", function () {
- return false;
- });
+ decorator.Contact(this);
+ }
- if (typeof prop === "string") {
- init_stringRepresentation(String(prop));
- } else if (prop) {
- init_ContactInitDict(prop);
+ function Contact_DOMString(stringRepresentation) {
}
- return _self;
-}
+ voc = [Contact_ContactInit, Contact_DOMString];
+ t.Contact(arguments, this, voc);
+};
module.exports = Contact;
});
define('ripple/platform/tizen/2.0/ContactEmailAddress', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation.
+ * Copyright 2013 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-var tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils');
-
-module.exports = function (email, types, isDefault) {
- var _self, i, type;
-
- _self = {
- email: undefined,
- isDefault: false,
- types: undefined
- };
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ ContactEmailAddress;
- _self.email = email ? String(email) : "";
+ContactEmailAddress = function (email, types, isDefault) {
+ t.ContactEmailAddress(arguments, this);
- if (tizen1_utils.isValidArray(types)) {
- _self.types = [];
-
- for (i in types) {
- type = String(types[i]).toUpperCase();
- _self.types.push(type);
- }
- }
-
- if (typeof isDefault === "boolean") {
- _self.isDefault = isDefault;
- }
-
- return _self;
+ this.email = email;
+ this.isDefault = isDefault || false;
+ this.types = (types && types[0]) ? types : ["WORK"];
};
+module.exports = ContactEmailAddress;
+
});
define('ripple/platform/tizen/2.0/ContactGroup', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation.
+ * Copyright 2013 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-module.exports = function (name, ringtoneURI, photoURI) {
- var _self = {};
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ ContactGroup;
- _self.__defineGetter__("id", function () {
+ContactGroup = function (name, ringtoneURI, photoURI) {
+ t.ContactGroup(arguments, this);
+
+ this.__defineGetter__("id", function () {
return null;
});
- _self.__defineGetter__("addressBookId", function () {
+ this.__defineGetter__("addressBookId", function () {
return null;
});
- _self.__defineGetter__("readOnly", function () {
+ this.__defineGetter__("readOnly", function () {
return false;
});
- _self.name = name ? String(name) : "";
- _self.ringtoneURI = ringtoneURI ? String(ringtoneURI) : null;
- _self.photoURI = photoURI ? String(photoURI) : null;
-
- return _self;
+ this.name = name;
+ this.ringtoneURI = ringtoneURI || null;
+ this.photoURI = photoURI || null;
};
+module.exports = ContactGroup;
+
});
define('ripple/platform/tizen/2.0/ContactName', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation.
+ * Copyright 2013 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-var tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils');
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ ContactName;
-module.exports = function (nameInitDict) {
- var self, i;
+ContactName = function (nameInitDict) {
+ var i;
- self = {
- prefix: null,
- suffix: null,
- firstName: null,
- middleName: null,
- lastName: null,
- nicknames: [],
- phoneticFirstName: null,
- phoneticLastName: null
- };
+ t.ContactName(arguments, this);
- if (nameInitDict) {
- if (nameInitDict.prefix !== null && nameInitDict.prefix !== undefined) {
- self.prefix = String(nameInitDict.prefix);
- }
- if (nameInitDict.suffix !== null && nameInitDict.suffix !== undefined) {
- self.suffix = String(nameInitDict.suffix);
- }
- if (nameInitDict.firstName !== null && nameInitDict.firstName !== undefined) {
- self.firstName = String(nameInitDict.firstName);
- }
- if (nameInitDict.middleName !== null && nameInitDict.middleName !== undefined) {
- self.middleName = String(nameInitDict.middleName);
- }
- if (nameInitDict.lastName !== null && nameInitDict.lastName !== undefined) {
- self.lastName = String(nameInitDict.lastName);
- }
- if (tizen1_utils.isValidArray(nameInitDict.nicknames)) {
- for (i in nameInitDict.nicknames) {
- self.nicknames.push(String(nameInitDict.nicknames[i]));
- }
- }
- if (nameInitDict.phoneticFirstName !== null && nameInitDict.phoneticFirstName !== undefined) {
- self.phoneticFirstName = String(nameInitDict.phoneticFirstName);
- }
- if (nameInitDict.phoneticLastName !== null && nameInitDict.phoneticLastName !== undefined) {
- self.phoneticLastName = String(nameInitDict.phoneticLastName);
- }
- }
+ this.prefix = null;
+ this.suffix = null;
+ this.firstName = null;
+ this.middleName = null;
+ this.lastName = null;
+ this.nicknames = [];
+ this.phoneticFirstName = null;
+ this.phoneticLastName = null;
- self.__defineGetter__("displayName", function () {
+ this.__defineGetter__("displayName", function () {
return null;
});
- return self;
+ if (nameInitDict) {
+ for (i in nameInitDict) {
+ this[i] = nameInitDict[i];
+ }
+ }
};
+module.exports = ContactName;
+
});
define('ripple/platform/tizen/2.0/ContactOrganization', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation.
+ * Copyright 2013 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-module.exports = function (orgInitDict) {
- var _self;
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ ContactOrganization;
- _self = {
- name: null,
- department: null,
- title: null,
- role: null,
- logoURI: null
- };
+ContactOrganization = function (orgInitDict) {
+ var i;
+
+ t.ContactOrganization(arguments, this);
+
+ this.name = null;
+ this.department = null;
+ this.title = null;
+ this.role = null;
+ this.logoURI = null;
if (orgInitDict) {
- if (orgInitDict.name !== null && orgInitDict.name !== undefined) {
- _self.name = String(orgInitDict.name);
- }
- if (orgInitDict.department !== null && orgInitDict.department !== undefined) {
- _self.department = String(orgInitDict.department);
- }
- if (orgInitDict.title !== null && orgInitDict.title !== undefined) {
- _self.title = String(orgInitDict.title);
- }
- if (orgInitDict.role !== null && orgInitDict.role !== undefined) {
- _self.role = String(orgInitDict.role);
- }
- if (orgInitDict.logoURI !== null && orgInitDict.logoURI !== undefined) {
- _self.logoURI = String(orgInitDict.logoURI);
+ for (i in orgInitDict) {
+ this[i] = orgInitDict[i];
}
}
-
- return _self;
};
+module.exports = ContactOrganization;
+
});
define('ripple/platform/tizen/2.0/ContactPhoneNumber', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation.
+ * Copyright 2013 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-var tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils');
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ ContactPhoneNumber;
-module.exports = function (number, types, isDefault) {
- var _self, i, type;
+ContactPhoneNumber = function (number, types, isDefault) {
+ t.ContactPhoneNumber(arguments, this);
- _self = {
- number: undefined,
- isDefault: false,
- types: undefined
- };
-
- _self.number = number ? String(number) : "";
-
- if (tizen1_utils.isValidArray(types)) {
- _self.types = [];
-
- for (i in types) {
- type = String(types[i]).toUpperCase();
- _self.types.push(type);
- }
- } else {
- _self.types = ["VOICE"];
- }
-
- if (typeof isDefault === "boolean") {
- _self.isDefault = isDefault;
- }
-
- return _self;
+ this.number = number;
+ this.isDefault = isDefault || false;
+ this.types = (types && types[0]) ? types : ["VOICE"];
};
+module.exports = ContactPhoneNumber;
+
});
define('ripple/platform/tizen/2.0/ContactRef', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation.
+ * Copyright 2013 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-var ContactRef = function (addressBookId, contactId) {
- if (!addressBookId || (typeof addressBookId !== "string") ||
- !contactId || (typeof contactId !== "string")) {
- return this;
- }
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ ContactRef;
+
+ContactRef = function (addressBookId, contactId) {
+ t.ContactRef(arguments, this);
this.addressBookId = addressBookId;
this.contactId = contactId;
});
define('ripple/platform/tizen/2.0/ContactWebSite', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation.
+ * Copyright 2013 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-module.exports = function (url, type) {
- var _self;
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ ContactWebSite;
- _self = {
- url: undefined,
- type: null
- };
+ContactWebSite = function (url, type) {
+ t.ContactWebSite(arguments, this);
- if (url) {
- _self.url = String(url);
- }
- if (type) {
- _self.type = String(type).toUpperCase();
- }
-
- return _self;
+ this.url = url;
+ this.type = type || "HOMEPAGE";
};
+module.exports = ContactWebSite;
+
});
define('ripple/platform/tizen/2.0/Conversation', function (require, exports, module) {
/*
* limitations under the License.
*/
-module.exports = function (url, destination, fileName) {
- var _self;
- _self = {
- url: url || null,
- destination: destination || null,
- fileName: fileName || null,
- networkType: null,
- httpHeader: null
- };
+module.exports = function (url, destination, fileName, networkType, httpHeader) {
+ var _self = this;
+
+ _self.url = url || null;
+ _self.destination = destination || "";
+ _self.fileName = fileName || "";
+ _self.networkType = networkType || null;
+ _self.httpHeader = httpHeader || null;
+
return _self;
};
});
define('ripple/platform/tizen/2.0/NDEFMessage', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation
+ * Copyright 2013 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use _self file except in compliance with the License.
+ * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* limitations under the License.
*/
-module.exports = function (ndefRecords) {
- //TODO: NDEFMessage doesn't support rawData constructor
- var _self,
- _ndefRecords = ndefRecords || [],
- space = " ",
- _recordCount;
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ NDEFRecord = require('ripple/platform/tizen/2.0/NDEFRecord'),
+ NDEFRecordText = require('ripple/platform/tizen/2.0/NDEFRecordText'),
+ NDEFRecordURI = require('ripple/platform/tizen/2.0/NDEFRecordURI'),
+ NDEFRecordMedia = require('ripple/platform/tizen/2.0/NDEFRecordMedia'),
+ NDEFRecordFactory,
+ NDEFMessage;
+
+NDEFRecordFactory = function (ndefRecord) {
+ var record;
+
+ if (ndefRecord instanceof NDEFRecordText) {
+ record = new NDEFRecordText(ndefRecord.text, ndefRecord.languageCode,
+ ndefRecord.encoding || null);
+ } else if (ndefRecord instanceof NDEFRecordURI) {
+ record = new NDEFRecordURI(ndefRecord.url);
+ } else if (ndefRecord instanceof NDEFRecordMedia) {
+ record = new NDEFRecordMedia(ndefRecord.mimeType, ndefRecord.payload);
+ } else {
+ record = new NDEFRecord(ndefRecord.tnf, ndefRecord.type,
+ ndefRecord.payload, ndefRecord.id || null);
+ }
+
+ return record;
+};
- _recordCount = _ndefRecords.length;
+NDEFMessage = function () {
+ var voc, records = [];
+
+ // private
+ function construct() {
+ this.__defineGetter__("recordCount", function () {
+ return this.records.length;
+ });
+
+ this.__defineGetter__("records", function () {
+ return records;
+ });
+
+ this.__defineSetter__("records", function (val) {
+ try {
+ t.NDEFRecord(val, "[]");
+ records = val;
+ } catch (e) {
+ }
+ });
+
+ this.toByte = function () {
+ var result = [], i, j, space = " ".charCodeAt(0);
- _self = {
- records : _ndefRecords,
- toByte : function () {
- var result = [], i, j;
for (i in this.records) {
for (j = 0; j < this.records[i].payload.length; j++) {
result.push(this.records[i].payload.charCodeAt(j));
}
if (i < this.records.length - 1) {
- result.push(space.charCodeAt(0));
+ result.push(space);
}
}
+
return result;
+ };
+ }
+
+ // constructor
+ function NDEFMessage_NDEFRecords(ndefRecords) {
+ var i;
+
+ construct.apply(this);
+
+ for (i = 0; i < ndefRecords.length; i++) {
+ records[i] = new NDEFRecordFactory(ndefRecords[i]);
}
- };
+ }
- _self.__defineGetter__("recordCount", function () {
- return _recordCount;
- });
+ function NDEFMessage_bytes(rawData) {
+ //TODO: NDEFMessage doesn't support rawData constructor
+ construct.apply(this);
+ }
- return _self;
+ function NDEFMessage_void() {
+ construct.apply(this);
+ }
+
+ voc = [NDEFMessage_NDEFRecords, NDEFMessage_bytes, NDEFMessage_void];
+ t.NDEFMessage(arguments, this, voc);
};
+module.exports = NDEFMessage;
+
});
define('ripple/platform/tizen/2.0/NDEFRecord', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation
+ * Copyright 2013 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use _self file except in compliance with the License.
+ * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-var errorcode = require('ripple/platform/tizen/2.0/errorcode'),
- WebAPIException = require('ripple/platform/tizen/2.0/WebAPIException');
-module.exports = function (tnf, type, payload, id) {
- var _self = {},
- _tnf = tnf,
- _type = type,
- _id = id || [],
- _payload = payload;
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ NDEFRecordInternal = require('ripple/platform/tizen/2.0/NDEFRecordInternal'),
+ NDEFRecord;
- if (arguments.length < 3) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
- _self.__defineGetter__("tnf", function () {
- return _tnf;
+NDEFRecord = function () {
+ var voc = [
+ function (tnf, type, payload, id) {
+ NDEFRecordInternal.call(this, tnf, type, payload, id || []);
+ },
+ function (raw_data) {
+ NDEFRecordInternal.call(this, 0, [], [], []);
+ }
+ ];
+
+ t.NDEFRecord(arguments, this, voc);
+};
+
+module.exports = NDEFRecord;
+
+});
+define('ripple/platform/tizen/2.0/NDEFRecordInternal', function (require, exports, module) {
+/*
+ * Copyright 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+module.exports = function (tnf, type, payload, id) {
+ this.__defineGetter__("tnf", function () {
+ return tnf;
});
- _self.__defineGetter__("type", function () {
- return _type;
+ this.__defineGetter__("type", function () {
+ return type;
});
- _self.__defineGetter__("id", function () {
- return _id;
+ this.__defineGetter__("id", function () {
+ return id;
});
- _self.__defineGetter__("payload", function () {
- return _payload;
+ this.__defineGetter__("payload", function () {
+ return payload;
});
- return _self;
};
});
define('ripple/platform/tizen/2.0/NDEFRecordMedia', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation
+ * Copyright 2013 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use _self file except in compliance with the License.
+ * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* limitations under the License.
*/
-var NDEFRecord = require('ripple/platform/tizen/2.0/NDEFRecord'),
- errorcode = require('ripple/platform/tizen/2.0/errorcode'),
- WebAPIException = require('ripple/platform/tizen/2.0/WebAPIException');
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ NDEFRecordInternal = require('ripple/platform/tizen/2.0/NDEFRecordInternal'),
+ NDEFRecordMedia;
-module.exports = function (mimeType, data) {
- var _self = {},
- _mimeType = mimeType,
- _data = data;
+NDEFRecordMedia = function (mimeType, data) {
+ var i, type = [], payload;
- if (arguments.length < 2) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
+ t.NDEFRecordMedia(arguments, this);
- _self = new NDEFRecord(2, [], [], []);
+ for (i = 0; i < mimeType.length; i++) {
+ type[i] = mimeType.charCodeAt(i);
+ }
+ payload = t.byte(data, "[]");
- _self.__defineGetter__("mimeType", function () {
- return _mimeType;
- });
+ // Normally, we can use prototype to inherit a class, for example:
+ // NDEFRecordMedia.prototype = new NDEFRecord(2, [...], [...], [...]);
+ // But the test case thinks that all the inherited property should be
+ // the object's own property. So, we can only change the "this" point
+ // of NDEFRecord constructor here.
+ NDEFRecordInternal.call(this, tizen.nfc.NFC_RECORD_TNF_MIME_MEDIA, type,
+ payload, []);
- _self.__defineGetter__("data", function () {
- return _data;
+ this.__defineGetter__("mimeType", function () {
+ return mimeType;
});
- return _self;
};
+module.exports = NDEFRecordMedia;
+
});
define('ripple/platform/tizen/2.0/NDEFRecordText', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation
+ * Copyright 2013 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use _self file except in compliance with the License.
+ * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* limitations under the License.
*/
-var NDEFRecord = require('ripple/platform/tizen/2.0/NDEFRecord');
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ NDEFRecordInternal = require('ripple/platform/tizen/2.0/NDEFRecordInternal'),
+ NDEFRecordText;
-module.exports = function (text, languageCode, encoding) {
- var _self = {},
- _text = text,
- _languageCode = languageCode,
- _encoding = encoding;
+NDEFRecordText = function (text, languageCode, encoding) {
+ var payload = [], i;
- _self = new NDEFRecord(1, [], [], []);
+ t.NDEFRecordText(arguments, this);
- _self.__defineGetter__("text", function () {
- return _text;
- });
+ encoding = encoding || "UTF8";
+
+ // Store languageCode in payload
+ payload.push(languageCode.length);
+ for (i = 0; i < languageCode.length; i++) {
+ payload.push(languageCode.charCodeAt(i));
+ }
- _self.__defineGetter__("languageCode", function () {
- return _languageCode;
+ // Store text in payload
+ for (i = 0; i < text.length; i++) {
+ payload.push(text.charCodeAt(i));
+ }
+
+ NDEFRecordInternal.call(this, tizen.nfc.NFC_RECORD_TNF_WELL_KNOWN,
+ ["T".charCodeAt(0)], payload, []);
+
+ this.__defineGetter__("text", function () {
+ return text;
});
- _self.__defineGetter__("encoding", function () {
- return _encoding;
+ this.__defineGetter__("languageCode", function () {
+ return languageCode;
});
- return _self;
+ this.__defineGetter__("encoding", function () {
+ return encoding;
+ });
};
+module.exports = NDEFRecordText;
+
});
define('ripple/platform/tizen/2.0/NDEFRecordURI', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation
+ * Copyright 2013 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use _self file except in compliance with the License.
+ * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* limitations under the License.
*/
-var NDEFRecord = require('ripple/platform/tizen/2.0/NDEFRecord');
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ NDEFRecordInternal = require('ripple/platform/tizen/2.0/NDEFRecordInternal'),
+ NDEFRecordURI;
-module.exports = function (uri) {
- var _self = {},
- _uri = uri;
+NDEFRecordURI = function (uri) {
+ var payload = [], i;
- _self = new NDEFRecord(3, [], [], []);
+ t.NDEFRecordURI(arguments, this);
- _self.__defineGetter__("uri", function () {
- return _uri;
- });
+ // Store uri in payload
+ payload.push(0);
+ for (i = 0; i < uri.length; i++) {
+ payload.push(uri.charCodeAt(i));
+ }
- return _self;
+ NDEFRecordInternal.call(this, tizen.nfc.NFC_RECORD_TNF_WELL_KNOWN,
+ ["U".charCodeAt(0)], payload, []);
+
+ this.__defineGetter__("uri", function () {
+ return uri;
+ });
};
+module.exports = NDEFRecordURI;
+
});
define('ripple/platform/tizen/2.0/NotificationBase', function (require, exports, module) {
/*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+var t = require('ripple/platform/tizen/2.0/typedef'),
+ TypeCoerce = require('ripple/platform/tizen/2.0/typecoerce');
module.exports = function (_title) {
- var id = Math.uuid(null, 16),
+ var id = undefined,
type = "STATUS",
- postedTime,
+ postedTime = null,
title = _title,
- content,
- _self = {};
+ content = null,
+ _self = this;
_self.__defineGetter__("id", function () {
return id;
return title;
});
_self.__defineSetter__("title", function (_title) {
+ if (!(new TypeCoerce(t.DOMString)).match(_title))
+ return;
title = _title;
});
_self.__defineGetter__("content", function () {
return _self;
};
+
});
define('ripple/platform/tizen/2.0/NotificationDetailInfo', function (require, exports, module) {
/*
* limitations under the License.
*/
+var t = require('ripple/platform/tizen/2.0/typedef'),
+ TypeCoerce = require('ripple/platform/tizen/2.0/typecoerce');
+
module.exports = function (mainText, subText) {
- var _self;
- _self = {
- mainText: mainText,
- subText: subText || null
- };
+ var _self = this, _mainText = undefined;
+
+ _self.__defineGetter__("mainText", function () {
+ return _mainText;
+ });
+
+ _self.__defineSetter__("mainText", function (mainText) {
+ if (!(new TypeCoerce(t.DOMString)).match(mainText))
+ return;
+
+ _mainText = mainText;
+ });
+
+ _self.mainText = mainText;
+ _self.subText = subText || undefined;
return _self;
};
* limitations under the License.
*/
-var event = require('ripple/event');
+var event = require('ripple/event'),
+ t = require('ripple/platform/tizen/2.0/typecast');
module.exports = function (appControl) {
var _self, _appControl = appControl;
_self = {
replyResult: function (data) {
+ t.RequestedApplicationControl("replyResult", arguments);
+
event.trigger("appServiceReplied", "Result: " + data);
},
replyFailure: function () {
this.latitude = _latitude || 0;
this.longitude = _longitude || 0;
return this;
-};
+}
module.exports = SimpleCoordinates;
});
define('ripple/platform/tizen/2.0/SortMode', function (require, exports, module) {
-/*
+/*
* Copyright 2012 Intel Corporation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* limitations under the License.
*/
-var errorcode = require('ripple/platform/tizen/2.0/errorcode'),
- WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError');
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ SortMode;
-module.exports = function (_attributeName, _order) {
- var _self;
- if (_attributeName !== null && _attributeName !== undefined) {
- if (typeof _attributeName !== "string") {
- throw (new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
- }
- }
- if (_order !== null && _order !== undefined) {
- if (_order !== "ASC" && _order !== "DESC") {
- throw (new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
- }
- }
- _self = {
- attributeName: _attributeName,
- order: _order,
- };
+SortMode = function (attributeName, order) {
+ t.SortMode(arguments, this);
- return _self;
+ this.attributeName = attributeName;
+ this.order = order;
};
+module.exports = SortMode;
});
define('ripple/platform/tizen/2.0/StatusNotification', function (require, exports, module) {
*/
var utils = require('ripple/utils'),
- NotificationBase = require('ripple/platform/tizen/2.0/NotificationBase'),
+ tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils'),
errorcode = require('ripple/platform/tizen/2.0/errorcode'),
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
- tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils'),
+ t = require('ripple/platform/tizen/2.0/typedef'),
+ TypeCoerce = require('ripple/platform/tizen/2.0/typecoerce'),
+ NotificationBase = require('ripple/platform/tizen/2.0/NotificationBase'),
+ NotificationDetailInfo = require('ripple/platform/tizen/2.0/NotificationDetailInfo'),
+
_self;
function _checkServiceProperties(service) {
}
}
+ if (dict.ledColor && typeof dict.ledColor !== "string") {
+ return false;
+ }
+
+ if (dict.ledOnPeriod && typeof dict.ledOnPeriod !== "number") {
+ return false;
+ }
+
+ if (dict.ledOffPeriod && typeof dict.ledOffPeriod !== "number") {
+ return false;
+ }
+
if (dict.backgroundImagePath && typeof dict.backgroundImagePath !== "string") {
return false;
}
}
_self = function (_statusType, title, notificationInitDict) {
- var statusType,
- notification;
+ var statusType, _progressType, _progressValue, _vibrationG, _ledOnPeriod, _ledOffPeriod, _info,
+ notification = this;
- if (typeof _statusType !== "string" || !(_statusType === "SIMPLE" || _statusType === "THUMBNAIL" || _statusType === "ONGOING" || _statusType === "PROGRESS") || typeof title !== "string" || !_checkDictProperties(notificationInitDict)) {
+ if (typeof _statusType !== "string" || !(_statusType === "SIMPLE" || _statusType === "THUMBNAIL" || _statusType === "ONGOING" || _statusType === "PROGRESS")
+ || typeof title !== "string" || !_checkDictProperties(notificationInitDict)) {
throw (new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
}
- if (notificationInitDict && _statusType === "PROGRESS" && notificationInitDict.progressValue &&
- (notificationInitDict.progressValue < 1 || notificationInitDict.progressValue > 100)) {
+ if (notificationInitDict && _statusType === "PROGRESS" && "progressValue" in notificationInitDict && notificationInitDict.progressType === "PERCENTAGE" &&
+ (notificationInitDict.progressValue < 0 || notificationInitDict.progressValue > 100)) {
throw (new WebAPIError(errorcode.INVALID_VALUES_ERR));
}
statusType = _statusType;
- notification = new NotificationBase(title);
+ notification = NotificationBase.call(notification, title);
notification.__defineGetter__("statusType", function () {
return statusType;
});
+ notification.__defineGetter__("vibration", function () {
+ return _vibration;
+ });
+
+ notification.__defineSetter__("vibration", function (vibration) {
+ if (!(new TypeCoerce(t.boolean)).match(vibration))
+ return;
+
+ _vibration = vibration;
+ });
+
+ notification.__defineGetter__("ledOnPeriod", function () {
+ return _ledOnPeriod;
+ });
+
+ notification.__defineSetter__("ledOnPeriod", function (ledOnPeriod) {
+ if (!(new TypeCoerce(t["unsigned long"])).match(ledOnPeriod))
+ return;
+
+ _ledOnPeriod = ledOnPeriod;
+ });
+
+ notification.__defineGetter__("ledOffPeriod", function () {
+ return _ledOffPeriod;
+ });
+
+ notification.__defineSetter__("ledOffPeriod", function (ledOffPeriod) {
+ if (!(new TypeCoerce(t["unsigned long"])).match(ledOffPeriod))
+ return;
+
+ _ledOffPeriod = ledOffPeriod;
+ });
+
+ notification.__defineGetter__("progressType", function () {
+ return _progressType;
+ });
+
+ notification.__defineSetter__("progressType", function (progressType) {
+ if (!(new TypeCoerce(t.NotificationProgressType)).match(progressType))
+ return;
+
+ _progressType = progressType;
+ });
+
+ notification.__defineGetter__("progressValue", function () {
+ return _progressValue;
+ });
+
+ notification.__defineSetter__("progressValue", function (progressValue) {
+ if (!(new TypeCoerce(t["unsigned long"])).match(progressValue))
+ return;
+
+ progressValue = (new TypeCoerce(t["unsigned long"])).copy(progressValue);
+ if ((_progressType === "PERCENTAGE") && (progressValue > 100))
+ return;
+
+ _progressValue = progressValue;
+ });
+
+ notification.content = null;
+ notification.iconPath = null;
+ notification.subIconPath = null;
+ notification.number = null;
+ notification.detailInfo = [];
+ notification.ledColor = null;
+ notification.ledOnPeriod = 0;
+ notification.ledOffPeriod = 0;
+ notification.backgroundImagePath = null;
+ notification.thumbnails = [];
+ notification.soundPath = null;
+ notification.appControl = null;
+ notification.appId = null;
+ _progressType = "PERCENTAGE";
+ _progressValue = null;
+ _vibration = false;
+
if (notificationInitDict) {
- notification.content = notificationInitDict.content ? notificationInitDict.content : undefined;
- notification.iconPath = notificationInitDict.iconPath ? notificationInitDict.iconPath : undefined;
- notification.number = notificationInitDict.number ? notificationInitDict.number: undefined;
- notification.detailInfo = notificationInitDict.detailInfo ? notificationInitDict.detailInfo : undefined;
- notification.backgroundImagePath = notificationInitDict.backgroundImagePath ? notificationInitDict.backgroundImagePath : undefined;
- notification.thumbnails = notificationInitDict.thumbnails ? notificationInitDict.thumbnails : undefined;
- notification.soundPath = notificationInitDict.soundPath ? notificationInitDict.soundPath : undefined;
- notification.vibration = notificationInitDict.vibration !== undefined ? notificationInitDict.vibration : false;
- notification.appControl = notificationInitDict.appControl ? notificationInitDict.appControl : undefined;
- notification.appId = notificationInitDict.appId ? notificationInitDict.appId : undefined;
- if (statusType === "PROGRESS") {
- notification.progressType = notificationInitDict.progressType ? notificationInitDict.progressType : "PERCENTAGE";
- notification.progressValue = notificationInitDict.progressValue ? notificationInitDict.progressValue : undefined;
+ notification.content = notificationInitDict.content ? notificationInitDict.content : null;
+ notification.iconPath = notificationInitDict.iconPath ? notificationInitDict.iconPath : null;
+ notification.subIconPath = notificationInitDict.subIconPath ? notificationInitDict.subIconPath : null;
+ notification.number = notificationInitDict.number ? notificationInitDict.number: null;
+ if (notificationInitDict.detailInfo) {
+ utils.forEach(notificationInitDict.detailInfo, function (info) {
+ if(info.subText) {
+ _info = new NotificationDetailInfo(info.mainText, info.subText);
+ } else {
+ _info = new NotificationDetailInfo(info.mainText, info.subText);
+ }
+ notification.detailInfo.push(_info);
+
+ });
+ }
+ notification.ledColor = "ledColor" in notificationInitDict ? notificationInitDict.ledColor : null;
+ notification.ledOnPeriod = "ledOnPeriod" in notificationInitDict ? notificationInitDict.ledOnPeriod : 0;
+ notification.ledOffPeriod = "ledOffPeriod" in notificationInitDict ? notificationInitDict.ledOffPeriod : 0;
+ notification.backgroundImagePath = "backgroundImagePath" in notificationInitDict ? notificationInitDict.backgroundImagePath : null;
+ notification.thumbnails = "thumbnails" in notificationInitDict ? notificationInitDict.thumbnails : [];
+ notification.soundPath = "soundPath" in notificationInitDict ? notificationInitDict.soundPath : null;
+ notification.appControl = "appControl" in notificationInitDict ? notificationInitDict.appControl : null;
+ notification.appId = "appId" in notificationInitDict ? notificationInitDict.appId : null;
+ _progressType = "progressType" in notificationInitDict ? notificationInitDict.progressType : "PERCENTAGE";
+ if("progressValue" in notificationInitDict) {
+ _progressValue = (new TypeCoerce(t["unsigned long"])).copy(notificationInitDict.progressValue);
}
+ _vibration = "vibration" in notificationInitDict ? notificationInitDict.vibration : false;
}
-
return notification;
};
});
define('ripple/platform/tizen/2.0/SyncInfo', function (require, exports, module) {
-/*
+/*
* Copyright 2013 Intel Corporation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
var db = require('ripple/db'),
t = require('ripple/platform/tizen/2.0/typecast'),
- _counter = 0,
- _accounts = {};
+ SyncInfo,
+ _accounts = {},
+ _counter = 0;
-function SyncInfo(url, id, password, mode, arg) {
- var syncInfo, _id, _password, _internal_id;
- syncInfo = this;
+SyncInfo = function () {
+ var voc, syncInfo = {}, index;
function save() {
- _accounts[_internal_id] = {id: _id, password: _password};
+ _accounts[index] = {
+ id: syncInfo.id,
+ password: syncInfo.password
+ };
db.saveObject("save-syncinfo", _accounts);
}
- _id = id;
- _password = password;
- _internal_id = _counter++;
+ function construct(url, id, password, mode) {
+ syncInfo.url = url;
+ syncInfo.id = id;
+ syncInfo.password = password;
+ syncInfo.mode = mode;
+ syncInfo.type = null;
+ syncInfo.interval = null;
- t.SyncMode(mode);
+ this.__defineGetter__("url", function () {
+ return syncInfo.url;
+ });
+ this.__defineSetter__("url", function (url) {
+ try {
+ syncInfo.url = t.DOMString(url);
+ } catch (e) {
+ }
+ });
- syncInfo.url = url;
- syncInfo.mode = mode;
+ this.__defineGetter__("id", function () {
+ return null;
+ });
+ this.__defineSetter__("id", function (id) {
+ try {
+ syncInfo.id = t.DOMString(id);
+ save();
+ } catch (e) {
+ }
+ });
- syncInfo.__defineSetter__("id", function (id) {
- _id = id;
- save();
- });
- syncInfo.__defineGetter__("id", function () {
- return null;
- });
- syncInfo.__defineSetter__("password", function (password) {
- _password = password;
- save();
- });
- syncInfo.__defineGetter__("password", function () {
- return null;
- });
+ this.__defineGetter__("password", function () {
+ return null;
+ });
+ this.__defineSetter__("password", function (password) {
+ try {
+ syncInfo.password = t.DOMString(password);
+ save();
+ } catch (e) {
+ }
+ });
+
+ this.__defineGetter__("mode", function () {
+ return syncInfo.mode;
+ });
+ this.__defineSetter__("mode", function (mode) {
+ try {
+ syncInfo.mode = t.SyncMode(mode);
+ } catch (e) {
+ }
+ });
+
+ this.__defineGetter__("type", function () {
+ return syncInfo.type;
+ });
+ this.__defineSetter__("type", function (type) {
+ if (mode !== "MANUAL") {
+ return;
+ }
+ try {
+ syncInfo.type = t.SyncType(type);
+ } catch (e) {
+ }
+ });
+
+ this.__defineGetter__("interval", function () {
+ return syncInfo.interval;
+ });
+ this.__defineSetter__("interval", function (interval) {
+ if (mode !== "PERIODIC") {
+ return;
+ }
+ try {
+ syncInfo.interval = t.SyncInterval(interval);
+ } catch (e) {
+ }
+ });
+ }
+
+ voc = [
+ function (url, id, password, mode, type) {
+ construct.apply(this, arguments);
+
+ if (mode === "MANUAL") {
+ syncInfo.type = type;
+ }
+ },
+ function (url, id, password, mode, interval) {
+ construct.apply(this, arguments);
+
+ if (mode === "PERIODIC") {
+ syncInfo.interval = interval;
+ }
+ },
+ function (url, id, password, mode) {
+ construct.apply(this, arguments);
+ }
+ ];
+
+ t.SyncInfo(arguments, this, voc);
- Object.defineProperty(syncInfo, "__syncInfoID__", {
+ index = _counter++;
+ Object.defineProperty(this, "__syncInfoID__", {
"configurable": false,
"enumerable": false,
"get": (function (_id_) {
return function () { return _id_; };
- })(_internal_id)
+ })(index)
});
-
- switch (mode) {
- case "MANUAL":
- if (arguments.length >= 5) {
- t.SyncType(arg);
- }
- syncInfo.type = arg;
- break;
- case "PERIODIC":
- t.SyncInterval(arg);
- syncInfo.interval = arg;
- break;
- }
save();
-
- return syncInfo;
-}
+};
module.exports = SyncInfo;
});
define('ripple/platform/tizen/2.0/SyncProfileInfo', function (require, exports, module) {
-/*
+/*
* Copyright 2013 Intel Corporation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* limitations under the License.
*/
-function SyncProfileInfo(profileName, syncInfo, serviceInfo) {
- var profile = this;
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ SyncProfileInfo;
- profile.profileName = profileName;
- profile.syncInfo = syncInfo;
- profile.serviceInfo = serviceInfo;
+SyncProfileInfo = function (profileName, syncInfo, serviceInfo) {
+ var syncProfileInfo = {};
- return profile;
-}
+ t.SyncProfileInfo(arguments, this);
+
+ syncProfileInfo.profileName = profileName;
+ syncProfileInfo.syncInfo = syncInfo;
+ syncProfileInfo.serviceInfo = serviceInfo;
+
+ this.__defineGetter__("profileId", function () {
+ return null;
+ });
+
+ this.__defineGetter__("profileName", function () {
+ return syncProfileInfo.profileName;
+ });
+ this.__defineSetter__("profileName", function (profileName) {
+ try {
+ syncProfileInfo.profileName = t.DOMString(profileName);
+ } catch (e) {
+ }
+ });
+
+ this.__defineGetter__("syncInfo", function () {
+ return syncProfileInfo.syncInfo;
+ });
+ this.__defineSetter__("syncInfo", function (syncInfo) {
+ try {
+ t.SyncInfo(syncInfo);
+ syncProfileInfo.syncInfo = syncInfo;
+ } catch (e) {
+ }
+ });
+
+ this.__defineGetter__("serviceInfo", function () {
+ return syncProfileInfo.serviceInfo;
+ });
+ this.__defineSetter__("serviceInfo", function (serviceInfo) {
+ try {
+ t.SyncServiceInfo(serviceInfo, "[]?");
+ syncProfileInfo.serviceInfo = serviceInfo;
+ } catch (e) {
+ }
+ });
+};
module.exports = SyncProfileInfo;
});
define('ripple/platform/tizen/2.0/SyncServiceInfo', function (require, exports, module) {
-/*
+/*
* Copyright 2013 Intel Corporation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
var db = require('ripple/db'),
t = require('ripple/platform/tizen/2.0/typecast'),
- _counter = 0,
- _accounts = {};
+ SyncServiceInfo,
+ _accounts = {},
+ _counter = 0;
-function SyncServiceInfo(enable, serviceType, serverDatabaseUri, id, password) {
- var _id, _password, syncServiceInfo, _internal_id;
- syncServiceInfo = this;
+SyncServiceInfo = function (enable, serviceType, serverDatabaseUri, id,
+ password) {
+ var syncServiceInfo = {}, index;
function save() {
- _accounts[_internal_id] = {id: _id, password: _password};
+ _accounts[index] = {
+ id: syncServiceInfo.id,
+ password: syncServiceInfo.password
+ };
db.saveObject("save-syncserviceinfo", _accounts);
}
- t.SyncServiceType(serviceType);
-
- if (id) {
- _id = id;
- }
-
- if (password) {
- _password = password;
- }
-
- _internal_id = _counter++;
+ t.SyncServiceInfo(arguments, this);
- syncServiceInfo.enable = enable;
- syncServiceInfo.serviceType = serviceType;
+ syncServiceInfo.enable = enable;
+ syncServiceInfo.serviceType = serviceType;
syncServiceInfo.serverDatabaseUri = serverDatabaseUri;
+ syncServiceInfo.id = id || null;
+ syncServiceInfo.password = password || null;
+
+ this.__defineGetter__("enable", function () {
+ return syncServiceInfo.enable;
+ });
+ this.__defineSetter__("enable", function (enable) {
+ try {
+ syncServiceInfo.enable = t.boolean(enable);
+ } catch (e) {
+ }
+ });
- syncServiceInfo.__defineSetter__("id", function (id) {
- _id = id;
- save();
+ this.__defineGetter__("serviceType", function () {
+ return syncServiceInfo.serviceType;
+ });
+ this.__defineSetter__("serviceType", function (serviceType) {
+ try {
+ syncServiceInfo.serviceType = t.SyncServiceType(serviceType);
+ } catch (e) {
+ }
});
- syncServiceInfo.__defineSetter__("password", function (password) {
- _password = password;
- save();
+ this.__defineGetter__("serverDatabaseUri", function () {
+ return syncServiceInfo.serverDatabaseUri;
+ });
+ this.__defineSetter__("serverDatabaseUri", function (serverDatabaseUri) {
+ try {
+ syncServiceInfo.serverDatabaseUri = t.DOMString(serverDatabaseUri);
+ } catch (e) {
+ }
});
- syncServiceInfo.__defineGetter__("id", function () {
+ this.__defineGetter__("id", function () {
return null;
});
+ this.__defineSetter__("id", function (id) {
+ try {
+ syncServiceInfo.id = t.DOMString(id);
+ save();
+ } catch (e) {
+ }
+ });
- syncServiceInfo.__defineGetter__("password", function () {
+ this.__defineGetter__("password", function () {
return null;
});
+ this.__defineSetter__("password", function (password) {
+ try {
+ syncServiceInfo.password = t.DOMString(password);
+ save();
+ } catch (e) {
+ }
+ });
- Object.defineProperty(syncServiceInfo, "__syncServiceInfoID__", {
+ index = _counter++;
+ Object.defineProperty(this, "__syncServiceInfoID__", {
"configurable": false,
"enumerable": false,
"get": (function (_id_) {
return function () { return _id_; };
- })(_internal_id)
+ })(index)
});
-
save();
-
- return syncServiceInfo;
-}
+};
module.exports = SyncServiceInfo;
});
define('ripple/platform/tizen/2.0/SyncStatistics', function (require, exports, module) {
-/*
+/*
* Copyright 2013 Intel Corporation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* limitations under the License.
*/
-module.exports = function (syncStatus, serviceType, lastSyncTime,
- serverToClientTotal, serverToClientAdded, serverToClientUpdated, serverToClientRemoved,
- clientToServerTotal, clientToServerAdded, clientToServerUpdated, clientToServerRemoved) {
-
- var statistics = {};
-
- statistics.__defineGetter__("syncStatus", function () {
+var SyncStatistics = function (syncStatus, serviceType, lastSyncTime,
+ serverToClientTotal, serverToClientAdded, serverToClientUpdated,
+ serverToClientRemoved, clientToServerTotal, clientToServerAdded,
+ clientToServerUpdated, clientToServerRemoved) {
+ this.__defineGetter__("syncStatus", function () {
return syncStatus;
});
- statistics.__defineGetter__("serviceType", function () {
+ this.__defineGetter__("serviceType", function () {
return serviceType;
});
- statistics.__defineGetter__("lastSyncTime", function () {
+ this.__defineGetter__("lastSyncTime", function () {
return lastSyncTime;
});
- statistics.__defineGetter__("serverToClientTotal", function () {
+ this.__defineGetter__("serverToClientTotal", function () {
return serverToClientTotal;
});
- statistics.__defineGetter__("serverToClientAdded", function () {
+ this.__defineGetter__("serverToClientAdded", function () {
return serverToClientAdded;
});
- statistics.__defineGetter__("serverToClientUpdated", function () {
+ this.__defineGetter__("serverToClientUpdated", function () {
return serverToClientUpdated;
});
- statistics.__defineGetter__("serverToClientRemoved", function () {
+ this.__defineGetter__("serverToClientRemoved", function () {
return serverToClientRemoved;
});
- statistics.__defineGetter__("clientToServerTotal", function () {
+ this.__defineGetter__("clientToServerTotal", function () {
return clientToServerTotal;
});
- statistics.__defineGetter__("clientToServerAdded", function () {
+ this.__defineGetter__("clientToServerAdded", function () {
return clientToServerAdded;
});
- statistics.__defineGetter__("clientToServerUpdated", function () {
+ this.__defineGetter__("clientToServerUpdated", function () {
return clientToServerUpdated;
});
- statistics.__defineGetter__("clientToServerRemoved", function () {
+ this.__defineGetter__("clientToServerRemoved", function () {
return clientToServerRemoved;
});
-
- return statistics;
};
+module.exports = SyncStatistics;
});
define('ripple/platform/tizen/2.0/TZDate', function (require, exports, module) {
_Day = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
function TZDate (dt) {
- var d, UTCd, UTC_diff, tzid = "", target_diff, temp_date,
+ var d, UTCd, UTC_diff, tzid = "", target_diff, temp_date, localeTime_fmt = 'h:m:s', localeDate_fmt = 'D, d M y',
time = require('ripple/platform/tizen/2.0/time'),
hour = arguments[3] || 0, min = arguments[4] || 0,
sec = arguments[5] || 0, msec = arguments[6] || 0,
o.getUTCHours(), o.getUTCMinutes(), o.getUTCSeconds(), o.getUTCMilliseconds());
return other.valueOf();
},
- _int_range_check = function (val, _min, _max) {
- var v = Number(val);
-
- if (v > _max || v < _min) {
- return false;
+ _formatDateString = function (fmt) {
+ var i, ret = '';
+ for (i = 0; i < fmt.length; i++) {
+ switch (fmt.charAt(i)) {
+ case 'd':
+ ret = ret + d.getDate();
+ break;
+ case 'y':
+ ret = ret + d.getFullYear();
+ break;
+ case 'm':
+ ret = ret + (d.getMonth() + 1);
+ break;
+ case 'M':
+ ret = ret + _Month[d.getMonth()];
+ break;
+ case 'D':
+ ret = ret + _Day[d.getDay()];
+ break;
+ default:
+ ret = ret + fmt.charAt(i);
+ }
}
- return true;
+ return ret;
+ },
+ _formatTimeString = function (fmt) {
+ var i, hh, mm, ss, AP, ret = "";
+ if (fmt.search(/ap/) === -1) {
+ AP = false;
+ } else {
+ AP = true;
+ if (d.getHours() > 11) {
+ fmt = fmt.replace("ap", "PM");
+ } else {
+ fmt = fmt.replace("ap", "AM");
+ }
+ }
+ for (i = 0; i < fmt.length; i++) {
+ switch (fmt.charAt(i)) {
+ case 'h':
+ hh = d.getHours();
+ if (AP) {
+ hh = (hh > 12) ? hh - 12 : hh;
+ }
+ ret = ret + hh;
+ break;
+ case 'm':
+ mm = d.getMinutes();
+ mm = (mm < 10 ? "0" : "") + mm;
+ ret = ret + mm;
+ break;
+ case 's':
+ ss = d.getSeconds();
+ ss = (ss < 10 ? "0" : "") + ss;
+ ret = ret + ss;
+ break;
+ default:
+ ret = ret + fmt.charAt(i);
+ }
+ }
+ return ret;
};
if (arguments[7] !== undefined) {
if (dt === null || dt === undefined) {
temp_date = new Date();
- tzid = time.getLocalTimezone();
+ if (arguments[1] !== undefined) {
+ if (typeof arguments[1] !== 'string') {
+ throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
+ }
+ if (tz.isValidTimezone(arguments[1]) === false) {
+ throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
+ }
+ tzid = arguments[1];
+ } else {
+ tzid = time.getLocalTimezone();
+ }
target_diff = tz.getTimezoneDiff(tzid);
d = new Date(temp_date.valueOf() + (target_diff + temp_date.getTimezoneOffset() / 60) * 1000 * 60 * 60);
} else {
d = new Date(dt);
if (arguments[1] !== undefined) {
tzid = arguments[1];
+ } else {
+ tzid = time.getLocalTimezone();
}
} else {
if (arguments.length === 1) {
return d.getDate();
};
this.setDate = function (dt) {
- if (_int_range_check(dt, 1, 31)) {
- d.setDate(dt);
- _d2UTCd_sync();
- }
+ d.setDate(dt);
+ _d2UTCd_sync();
};
this.getDay = function () {
return d.getDay();
return d.getFullYear();
};
this.setFullYear = function (yr) {
- if (_int_range_check(yr, 1000, 9999)) {
- d.setFullYear(yr);
- _d2UTCd_sync();
- }
+ d.setFullYear(yr);
+ _d2UTCd_sync();
};
this.getHours = function () {
return d.getHours();
};
this.setHours = function (hr) {
- if (_int_range_check(hr, 0, 23)) {
- d.setHours(hr);
- _d2UTCd_sync();
- }
+ d.setHours(hr);
+ _d2UTCd_sync();
};
this.getMilliseconds = function () {
return d.getMilliseconds();
};
this.setMilliseconds = function (msec) {
- if (_int_range_check(msec, 0, 999)) {
- d.setMilliseconds(msec);
- _d2UTCd_sync();
- }
+ d.setMilliseconds(msec);
+ _d2UTCd_sync();
};
this.getMinutes = function () {
return d.getMinutes();
};
this.setMinutes = function (min) {
- if (_int_range_check(min, 0, 59)) {
- d.setMinutes(min);
- _d2UTCd_sync();
- }
+ d.setMinutes(min);
+ _d2UTCd_sync();
};
this.getMonth = function () {
return d.getMonth();
};
this.setMonth = function (m) {
- if (_int_range_check(m, 0, 11)) {
- d.setMonth(m);
- _d2UTCd_sync();
- }
+ d.setMonth(m);
+ _d2UTCd_sync();
};
this.getSeconds = function () {
return d.getSeconds();
};
this.setSeconds = function (s) {
- if (_int_range_check(s, 0, 59)) {
- d.setSeconds(s);
- _d2UTCd_sync();
- }
+ d.setSeconds(s);
+ _d2UTCd_sync();
};
this.getUTCDate = function () {
return UTCd.getDate();
};
this.setUTCDate = function (dt) {
- if (_int_range_check(dt, 1, 31)) {
- UTCd.setDate(dt);
- _UTCd2d_sync();
- }
+ UTCd.setDate(dt);
+ _UTCd2d_sync();
};
this.getUTCDay = function () {
return UTCd.getDay();
return UTCd.getFullYear();
};
this.setUTCFullYear = function (yr) {
- if (_int_range_check(yr, 1000, 9999)) {
- UTCd.setFullYear(yr);
- _UTCd2d_sync();
- }
+ UTCd.setFullYear(yr);
+ _UTCd2d_sync();
};
this.getUTCHours = function () {
return UTCd.getHours();
};
this.setUTCHours = function (hr) {
- if (_int_range_check(hr, 0, 23)) {
- UTCd.setHours(hr);
- _UTCd2d_sync();
- }
+ UTCd.setHours(hr);
+ _UTCd2d_sync();
};
this.getUTCMilliseconds = function () {
return UTCd.getMilliseconds();
};
this.setUTCMilliseconds = function (msec) {
- if (_int_range_check(msec, 0, 999)) {
- UTCd.setMilliseconds(msec);
- _UTCd2d_sync();
- }
+ UTCd.setMilliseconds(msec);
+ _UTCd2d_sync();
};
this.getUTCMinutes = function () {
return UTCd.getMinutes();
};
this.setUTCMinutes = function (min) {
- if (_int_range_check(min, 0, 59)) {
- UTCd.setMinutes(min);
- _UTCd2d_sync();
- }
+ UTCd.setMinutes(min);
+ _UTCd2d_sync();
};
this.getUTCMonth = function () {
return UTCd.getMonth();
};
this.setUTCMonth = function (m) {
- if (_int_range_check(m, 0, 11)) {
- UTCd.setMonth(m);
- _UTCd2d_sync();
- }
+ UTCd.setMonth(m);
+ _UTCd2d_sync();
};
this.getUTCSeconds = function () {
return UTCd.getSeconds();
};
this.setUTCSeconds = function (s) {
- if (_int_range_check(s, 0, 59)) {
- UTCd.setSeconds(s);
- _UTCd2d_sync();
- }
+ UTCd.setSeconds(s);
+ _UTCd2d_sync();
};
this.getTimezone = function () {
return tzid;
if (d.toString() === "Invalid Date") {
return d.toString();
} else {
- return this.toDateString() + " (" + tz.getTimezoneAbbr(tzid) + ")";
+ return _formatDateString(localeDate_fmt);
}
};
this.toLocaleTimeString = function () {
if (d.toString() === "Invalid Date") {
return d.toString();
} else {
- return this.toTimeString() + " (" + tz.getTimezoneAbbr(tzid) + ")";
+ return _formatTimeString(localeTime_fmt);
}
};
this.toLocaleString = function () {
if (d.toString() === "Invalid Date") {
return d.toString();
} else {
- return this.toString() + " (" + tz.getTimezoneAbbr(tzid) + ")";
+ return (this.toLocaleDateString() + " " + this.toLocaleTimeString());
}
};
this.toDateString = function () {
- var i, ret = "", fmt = time.getDateFormat();
+ var ret = "", fmt = time.getDateFormat();
if (d.toString() === "Invalid Date") {
return d.toString();
}
- for (i = 0; i < fmt.length; i++) {
- switch (fmt.charAt(i)) {
- case 'd':
- ret = ret + d.getDate();
- break;
- case 'y':
- ret = ret + d.getFullYear();
- break;
- case 'm':
- ret = ret + (d.getMonth() + 1);
- break;
- case 'M':
- ret = ret + _Month[d.getMonth()];
- break;
- case 'D':
- ret = ret + _Day[d.getDay()];
- break;
- default:
- ret = ret + fmt.charAt(i);
- }
- }
+ ret = _formatDateString(fmt);
return ret;
};
this.toTimeString = function () {
- var i, hh, mm, ss, AP,
- ret = "", fmt = time.getTimeFormat();
+ var ret, fmt = time.getTimeFormat();
if (d.toString() === "Invalid Date") {
return d.toString();
}
- if (fmt.search(/ap/) === -1) {
- AP = false;
+ ret = _formatTimeString(fmt);
+ if (tz.getTimezoneDesc(tzid) !== null) {
+ return ret + " " + tz.getTimezoneDesc(tzid);
} else {
- AP = true;
- if (d.getHours() > 11) {
- fmt = fmt.replace("ap", "PM");
- } else {
- fmt = fmt.replace("ap", "AM");
- }
- }
- for (i = 0; i < fmt.length; i++) {
- switch (fmt.charAt(i)) {
- case 'h':
- hh = d.getHours();
- if (AP) {
- hh = (hh > 12) ? hh - 12 : hh;
- }
- hh = (hh < 10 ? "0" : "") + hh;
- ret = ret + hh;
- break;
- case 'm':
- mm = d.getMinutes();
- mm = (mm < 10 ? "0" : "") + mm;
- ret = ret + mm;
- break;
- case 's':
- ss = d.getSeconds();
- ss = (ss < 10 ? "0" : "") + ss;
- ret = ret + ss;
- break;
- default:
- ret = ret + fmt.charAt(i);
- }
+ return ret + " " + tz.getTimezoneAbbr(tzid);
}
return ret;
};
function _initialize() {
_alarms = db.retrieveObject(_DB_ALARMS_KEY);
utils.forEach(_alarms, function (alarmStore) {
+ alarmStore.date = new Date(alarmStore.date);
_alarmStack.push(alarmStore);
});
_isInitialized = true;
alarm = {
add: function (alarm, applicationId, appControl) {
- var alarmStore, external = alarm;
+ var id, alarmStore;
if (!_security.add) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- alarm = t.Alarm(alarm);
- applicationId = t.ApplicationId(applicationId);
- appControl = t.ApplicationControl(appControl, "?");
+ t.AlarmManager("add", arguments);
- alarm.id = Math.uuid(null, 16);
+ alarm.__defineGetter__("id", function () {
+ return id;
+ });
+
+ id = Math.uuid(null, 16);
currentAppId = _getCurrentAppId(); // Update The Current URL.
alarmStore = new AlarmStore(alarm, applicationId, currentAppId, appControl);
_updateDB(alarmStore);
-
- external.__defineGetter__("id", function () {
- return alarm.id;
- });
},
remove: function (id) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- id = t.AlarmId(id);
+ t.AlarmManager("remove", arguments);
for (i in _alarmStack) {
if (_alarmStack[i].id !== id)
if (!_security.removeAll)
throw new WebAPIException(errorcode.SECURITY_ERR);
+ t.AlarmManager("removeAll", arguments);
+
for (i in _alarmStack) {
if (_alarmStack[i].currentAppId === currentAppId)
continue;
get: function (id) {
var isFound = false, item, isExpired, alarm;
- id = t.AlarmId(id);
+ t.AlarmManager("get", arguments);
for (item in _alarmStack) {
if (_alarmStack[item].id === id) {
getAll: function () {
var availableStack = [], backAlarms = [], isExpired, alarm, i;
+ t.AlarmManager("getAll", arguments);
+
for (i in _alarmStack) {
alarm = _convertToAlarm(_alarmStack[i]); // alarmStore --> alarm
isExpired = _checkTriggerAlarm(alarm); // Check if the alarm is expired
event = require('ripple/event'),
app = require('ripple/app'),
db = require('ripple/db'),
+ t = require('ripple/platform/tizen/2.0/typecast'),
errorcode = require('ripple/platform/tizen/2.0/errorcode'),
- tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils'),
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
+ WebAPIException = require('ripple/platform/tizen/2.0/WebAPIException'),
Application = require('ripple/platform/tizen/2.0/ApplicationBase'),
ApplicationInformation = require('ripple/platform/tizen/2.0/ApplicationInformation'),
ApplicationContext = require('ripple/platform/tizen/2.0/ApplicationContext'),
ApplicationCertificate = require('ripple/platform/tizen/2.0/ApplicationCertificate'),
_DB_APPLICATION_KEY = "tizen1-db-application",
+ PSEUDO_PACKAGE_ID = "pseudopack00",
+ PSEUDO_APP_ID = "pseudoapp00",
_security = {
"http://tizen.org/privilege/application.launch": ["launch", "launchAppControl"],
"http://tizen.org/privilege/appmanager.kill": ["kill"],
_appDialogTemplate = jQuery("#app-dialog-template").html(),
_appDialogTemplate_short = jQuery("#app-dialog2-template").html(),
_appDialogTemplate_exit_hide = jQuery("#app-dialog3-template").html(),
+ reasonable_mimetype = {
+ "application" : true,
+ "text" : true,
+ "video" : true,
+ "audio" : true,
+ "image" : true
+ },
_self;
function _setupCurrentApp() {
- var info, contextId;
+ var info, contextId, packageId, appId;
info = app.getInfo();
+ packageId = info.tizenPackageId || PSEUDO_PACKAGE_ID;
+ appId = info.tizenAppId || PSEUDO_APP_ID;
contextId = Math.uuid(null, 16);
- _data.applications[info.id] = {
- id: info.id,
+ _data.applications[appId] = {
+ id: appId,
name: info.name,
iconPath: info.icon,
version: info.version,
categories: [],
installDate: new Date(),
size: 1024,
- packageId: "sample0123",
+ packageId: packageId,
sharedURI: "/usr/local/share/",
operation: "",
appControl: {
data: ""
},
type: "AUTHOR_ROOT",
- value: []
+ value: ""
};
- _data.applicationContexts[contextId] = {id: contextId, appId: info.id};
+ event.trigger("install-current-app", [_data.applications[appId]]);
+ _data.applicationContexts[contextId] = {id: contextId, appId: appId};
_data.activeApp = _data.applicationContexts[contextId];
}
activeApp : null,
listeners : {}
};
+
+ if (!db.retrieveObject(_DB_APPLICATION_KEY))
+ return;
+
_data.applications = _translate(db.retrieveObject(_DB_APPLICATION_KEY).installedAppList);
_setupCurrentApp();
$("#app-dialog").dialog({
// public
function getCurrentApplication() {
var application, innerApp;
+
+ t.ApplicationManager("getCurrentApplication", arguments);
+
/* activeApp update (by WidgetInformationUpdate event) sometime will late after user calling getCurrentApplication()
for example: load other application by omnibar */
if (app.getInfo().id !== _data.activeApp.appId) {
_data.applications = db.retrieveObject(_DB_APPLICATION_KEY).installedAppList;
+ utils.forEach(_data.applications, function(item) {
+ item.installDate = new Date(item.installDate);
+ });
_setupCurrentApp();
}
innerApp = _data.applications[_data.activeApp.appId];
function kill(contextId, successCallback, errorCallback) {
if (!_security.kill) {
- throw new WebAPIError(errorcode.SECURITY_ERR);
- }
-
- if (typeof contextId !== "string") {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(errorcode.SECURITY_ERR);
}
- tizen1_utils.validateCallbackType(successCallback, errorCallback);
+ t.ApplicationManager("kill", arguments);
if (!_data.applicationContexts[contextId]) {
if (errorCallback) {
var htmlContent;
if (!_security.launch) {
- throw new WebAPIError(errorcode.SECURITY_ERR);
- }
-
- if (typeof id !== "string") {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(errorcode.SECURITY_ERR);
}
- tizen1_utils.validateCallbackType(successCallback, errorCallback);
+ t.ApplicationManager("launch", arguments);
if (!_data.applications[id]) {
if (errorCallback) {
var isFound, appId, htmlContent;
if (!_security.launchAppControl) {
- throw new WebAPIError(errorcode.SECURITY_ERR);
- }
-
- if ((typeof appControl !== "object") ||
- (typeof appControl.operation !== "string") ||
- (appControl.uri && (typeof appControl.uri !== "string")) ||
- (appControl.mime && (typeof appControl.mime !== "string")) ||
- (appControl.category && (typeof appControl.category !== "string")) ||
- (!appControl.data instanceof Array)) {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
-
- if (id && (typeof id !== "string")) {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(errorcode.SECURITY_ERR);
}
- tizen1_utils.validateCallbackType(successCallback, errorCallback);
-
- if (replyCallback && ((typeof replyCallback !== "object") ||
- (replyCallback.onsuccess && (typeof replyCallback.onsuccess !== "function")) ||
- (replyCallback.onfailure && (typeof replyCallback.onfailure !== "function")))) {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
+ t.ApplicationManager("launchAppControl", arguments);
if (id) {
if (!_data.applications[id]) {
isFound = false;
utils.forEach(_data.applications, function (application) {
if (application.operation === appControl.operation) {
+ if (appControl.mime && (typeof appControl.mime === "string")) {
+ if (!reasonable_mimetype[appControl.mime.split("/")[0]]) {
+ return;
+ }
+ }
appId = application.id;
isFound = true;
}
function findAppControl(appControl, successCallback, errorCallback) {
var informationArray = [];
- if ((typeof appControl !== "object") ||
- (typeof appControl.operation !== "string") ||
- (appControl.uri && (typeof appControl.uri !== "string")) ||
- (appControl.mime && (typeof appControl.mime !== "string")) ||
- (appControl.category && (typeof appControl.category !== "string")) ||
- (!appControl.data instanceof Array)) {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
-
- tizen1_utils.validateArgumentType(successCallback, "function",
- new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
+ t.ApplicationManager("findAppControl", arguments);
- if (errorCallback) {
- tizen1_utils.validateArgumentType(errorCallback, "function",
- new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
- }
utils.forEach(_data.applications, function (application) {
if (application.operation === appControl.operation) {
informationArray.push(new ApplicationInformation(
application.packageId));
}
});
- if (informationArray.length === 0) {
- if (errorCallback) {
- setTimeout(errorCallback(new WebAPIError(errorcode.NOT_FOUND_ERR)), 1);
- }
- } else {
- setTimeout(successCallback(informationArray, appControl), 1);
- }
+ setTimeout(successCallback(informationArray, appControl), 1);
}
function getAppsContext(successCallback, errorCallback) {
var array = [];
- tizen1_utils.validateArgumentType(successCallback, "function",
- new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
-
- if (errorCallback) {
- tizen1_utils.validateArgumentType(errorCallback, "function",
- new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
- }
+ t.ApplicationManager("getAppsContext", arguments);
utils.forEach(_data.applicationContexts, function (context) {
array.push(new ApplicationContext(context.id, context.appId));
appContext = new ApplicationContext(_data.activeApp.id, _data.activeApp.appId);
return (appContext);
}
- if (contextId && (typeof contextId !== "string")) {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
+
+ t.ApplicationManager("getAppContext", arguments);
+
if (_data.applicationContexts[contextId]) {
appContext = new ApplicationContext(contextId, _data.applicationContexts[contextId].appId);
return (appContext);
}
- throw new WebAPIError(errorcode.NOT_FOUND_ERR);
+ throw new WebAPIException(errorcode.NOT_FOUND_ERR);
}
function getAppsInfo(successCallback, errorCallback) {
var appsInfo = [];
- tizen1_utils.validateArgumentType(successCallback, "function",
- new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
-
- if (errorCallback) {
- tizen1_utils.validateArgumentType(errorCallback, "function",
- new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
- }
+ t.ApplicationManager("getAppsInfo", arguments);
utils.forEach(_data.applications, function (application) {
appsInfo.push(new ApplicationInformation(
function getAppInfo(id) {
var appId, appInfo, theApp;
+ t.ApplicationManager("getAppInfo", arguments);
+
if (arguments.length === 0) {
appId = _data.activeApp.appId;
theApp = _data.applications[appId];
return appInfo;
}
- if (id && (typeof id !== "string")) {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
-
if (!_data.applications[id]) {
- throw new WebAPIError(errorcode.NOT_FOUND_ERR);
+ throw new WebAPIException(errorcode.NOT_FOUND_ERR);
}
theApp = _data.applications[id];
var certs = [];
if (!_security.getAppCerts) {
- throw new WebAPIError(errorcode.SECURITY_ERR);
+ throw new WebAPIException(errorcode.SECURITY_ERR);
}
- if (id === null) {
+ t.ApplicationManager("getAppCerts", arguments);
+
+ if (arguments.length === 0) {
id = _data.activeApp.appId;
certs.push(new ApplicationCertificate(_data.applications[id].type, _data.applications[id].value));
return certs;
}
- if (id && typeof id !== "string") {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
-
if (!_data.applications[id]) {
- throw new WebAPIError(errorcode.NOT_FOUND_ERR);
+ throw new WebAPIException(errorcode.NOT_FOUND_ERR);
}
certs.push(new ApplicationCertificate(_data.applications[id].type, _data.applications[id].value));
return certs;
function getAppSharedURI(id) {
var appId;
+ t.ApplicationManager("getAppSharedURI", arguments);
+
if (id === null || id === undefined) {
appId = _data.activeApp.appId;
return _data.applications[appId].sharedURI;
}
- if (id && (typeof id !== "string")) {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
-
if (!_data.applications[id]) {
- throw new WebAPIError(errorcode.NOT_FOUND_ERR);
+ throw new WebAPIException(errorcode.NOT_FOUND_ERR);
}
return _data.applications[id].sharedURI;
function addAppInfoEventListener(eventCallback) {
var handle;
- if (!eventCallback ||
- (typeof eventCallback.oninstalled !== "function") ||
- (typeof eventCallback.onupdated !== "function") ||
- (typeof eventCallback.onuninstalled !== "function")) {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
+ t.ApplicationManager("addAppInfoEventListener", arguments);
handle = getHandle();
_data.listeners[handle] = eventCallback;
}
function removeAppInfoEventListener(listenerID) {
- if (typeof listenerID !== "number") {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
+ t.ApplicationManager("removeAppInfoEventListener", arguments);
if (!_data.listeners[listenerID]) {
- throw new WebAPIError(errorcode.NOT_FOUND_ERR);
+ throw new WebAPIException(errorcode.NOT_FOUND_ERR);
}
delete _data.listeners[listenerID];
.replace(/#application-id/, _data.applications[_data.activeApp.appId].id)
.replace(/#application-operation/g, "exit")
.replace(/#application-verb/, "launch")
- .replace(/#next-command/, "Launch")
+ .replace(/#next-command/g, "Launch")
.replace(/#application-btn/, "app-dialog-reload-btn");
jQuery("#app-dialog-box").html(htmlContent);
$("#app-dialog").dialog("open");
.replace(/#application-id/, _data.applications[_data.activeApp.appId].id)
.replace(/#application-operation/g, "hide")
.replace(/#application-verb/, "show")
- .replace(/#next-command/, "Show")
+ .replace(/#next-command/g, "Show")
.replace(/#application-btn/, "app-dialog-return-btn");
jQuery("#app-dialog-box").html(htmlContent);
$("#app-dialog").dialog("open");
event.on("programChanged", function (status, id) {
var callback, data, innerApp;
_data.applications = db.retrieveObject(_DB_APPLICATION_KEY).installedAppList;
+ utils.forEach(_data.applications, function(item) {
+ item.installDate = new Date(item.installDate);
+ });
_setupCurrentApp();
switch (status) {
case "installed":
_self;
function _initialize() {
- var adapterName;
+ var adapterName, devs;
_data.bluetoothClassDeviceMajor = new BluetoothClassDeviceMajor();
_data.bluetoothClassDeviceMinor = new BluetoothClassDeviceMinor();
_data.bluetoothClassDeviceService = new BluetoothClassDeviceService();
adapterName = db.retrieveObject(_data.DB_BLUETOOTH_KEY) || _data.DEFAULT_ADAPTER_NAME;
_data.adapter = new BluetoothAdapter(adapterName, _data.DEFAULT_ADAPTER_ADDRESS);
+
+ //get defalt nearby devices
+ devs = db.retrieveObject("bt-simulated-devices");
+ utils.forEach(devs, function (item) {
+ if (!_data.availableDevs[item.address]) {
+ _data.availableDevs[item.address] = new BluetoothDevice({
+ name: item.name,
+ address: item.address,
+ deviceClass: item.deviceClass,
+ isBonded: false,
+ isTrusted: item.isTrusted,
+ isConnected: false,
+ services: item.services,
+ metaData: _security
+ });
+ }
+ });
}
function _validateDiscoverDevicesType(onSuccess, onError) {
return;
}
utils.forEach(_data.historyDevs, function (item) {
- devs.push(utils.copy(item));
+ devs.push(new BluetoothDevice({
+ name: item.name,
+ address: item.address,
+ deviceClass: item.deviceClass,
+ isBonded: false,
+ isTrusted: item.isTrusted,
+ isConnected: false,
+ services: item.services,
+ metaData: _security
+ }));
});
successCallback(devs);
}
bookmarkExternal = trace.pop();
peers = null;
+ if (it.length === 0)
+ break;
+
for (i in it) {
if (it[i].external === bookmarkExternal) {
peers = it;
}
}
+ function findUrl(bookmarks, url) {
+ var i, isFound = false;
+
+ for (i in bookmarks) {
+ if (_isFolder(bookmarks[i])) {
+ isFound = findUrl(bookmarks[i].children, url);
+ } else {
+ isFound = (bookmarks[i].url === url);
+ }
+
+ if (isFound)
+ break;
+ }
+
+ return isFound;
+ }
+
function isExisting(bookmark, peers) {
var i;
+ if (!_isFolder(bookmark)) {
+ return findUrl(_data.bookmarks, bookmark.url);
+ }
+
for (i in peers) {
- if ((peers[i].title === bookmark.title) &&
- (_isFolder(peers[i]) === _isFolder(bookmark))) {
+ if (_isFolder(peers[i]) && (peers[i].title === bookmark.title)) {
return true;
}
}
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- parentFolder = t.BookmarkFolder(parentFolder, "?");
- recursive = t.boolean(recursive, "?");
+ t.BookmarkManager("get", arguments);
parent = map(parentFolder);
if ((parent === undefined) || (parent && !_isFolder(parent))) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- bookmark = t.Bookmark(bookmark);
- parentFolder = t.BookmarkFolder(parentFolder, "?");
+ t.BookmarkManager("add", arguments);
parent = map(parentFolder);
if ((parent === undefined) || (parent && !_isFolder(parent))) {
}
peers = parent ? parent.children : _data.bookmarks;
if (isExisting(bookmark, peers)) {
- throw new WebAPIException(errorcode.UNKNOWN_ERR);
+ throw new WebAPIException(errorcode.INVALID_VALUES_ERR);
}
peers.push(new BookmarkInternal(bookmark));
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- bookmark = t.Bookmark(bookmark, "?");
+ t.BookmarkManager("remove", arguments);
if (!bookmark) {
_data.bookmarks = [];
}
peers.splice(index, 1);
});
+
+ bookmark.__defineGetter__("parent", function () {
+ return undefined;
+ });
}
_persist();
var utils = require('ripple/utils'),
db = require('ripple/db'),
+ t = require('ripple/platform/tizen/2.0/typecast'),
tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils'),
errorcode = require('ripple/platform/tizen/2.0/errorcode'),
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
WebAPIException = require('ripple/platform/tizen/2.0/WebAPIException'),
TZDate = require('ripple/platform/tizen/2.0/TZDate'),
+ TDur = require('ripple/platform/tizen/2.0/TimeDuration'),
CalendarItem = require('ripple/platform/tizen/2.0/CalendarItem'),
CalendarEvent = require('ripple/platform/tizen/2.0/CalendarEvent'),
CalendarTask = require('ripple/platform/tizen/2.0/CalendarTask'),
calendarItem.description = utils.copy(storageItem.description);
calendarItem.summary = utils.copy(storageItem.summary);
calendarItem.isAllDay = utils.copy(storageItem.isAllDay);
- calendarItem.startDate = new TZDate(new Date(storageItem.startDate));
+ calendarItem.startDate = storageItem.startDate;
+ if (storageItem.startDate instanceof TZDate) {
+ calendarItem.startDate = storageItem.startDate.addDuration(new TDur(0, 'MSECS'));
+ }
+ if (typeof storageItem.startDate === 'string') {
+ calendarItem.startDate = new TZDate(new Date(storageItem.startDate));
+ }
+
calendarItem.duration = utils.copy(storageItem.duration);
calendarItem.location = utils.copy(storageItem.location);
calendarItem.geolocation = utils.copy(storageItem.geolocation);
function loadCalendarEventInit(calendarItem, storageItem) {
loadCalendarItemInit(calendarItem, storageItem);
- calendarItem.endDate = new TZDate(new Date(storageItem.endDate));
+ calendarItem.endDate = storageItem.endDate;
+ if (storageItem.endDate instanceof TZDate) {
+ calendarItem.endDate = storageItem.endDate.addDuration(new TDur(0, 'MSECS'));
+ }
+ if (typeof storageItem.endDate === 'string') {
+ calendarItem.endDate = new TZDate(new Date(storageItem.endDate));
+ }
calendarItem.availability = utils.copy(storageItem.availability);
calendarItem.recurrenceRule = utils.copy(storageItem.recurrenceRule);
calendarItem.expandRecurrence = function (startDate, endDate, successCallback, errorCallback) {
};
calendarItem.frequency = utils.copy(storageItem.frequency);
calendarItem.interval = utils.copy(storageItem.interval);
- calendarItem.untilDate = storageItem.untilDate ? new TZDate(new Date(storageItem.untilDate)):storageItem.untilDate;
+ calendarItem.untilDate = storageItem.untilDate;
+ if (storageItem.untilDate instanceof TZDate) {
+ calendarItem.untilDate = storageItem.untilDate.addDuration(new TDur(0, 'MSECS'));
+ }
+ if (typeof storageItem.untilDate === 'string') {
+ calendarItem.untilDate = new TZDate(new Date(storageItem.untilDate));
+ }
calendarItem.occurrenceCount = utils.copy(storageItem.occurrenceCount);
calendarItem.daysOfTheWeek = utils.copy(storageItem.daysOfTheWeek);
calendarItem.setPositions = utils.copy(storageItem.setPositions);
function loadCalendarTaskInit(calendarItem, storageItem) {
loadCalendarItemInit(calendarItem, storageItem);
- calendarItem.dueDate = new TZDate(new Date(storageItem.dueDate));
- calendarItem.completedDate = storageItem.completedDate ? new TZDate(new Date(storageItem.completedDate)):storageItem.completedDate;
+ calendarItem.dueDate = storageItem.dueDate;
+ if (storageItem.dueDate instanceof TZDate) {
+ calendarItem.dueDate = storageItem.dueDate.addDuration(new TDur(0, 'MSECS'));
+ }
+ if (typeof storageItem.dueDate === 'string') {
+ calendarItem.dueDate = new TZDate(new Date(storageItem.dueDate));
+ }
+ calendarItem.completeDate = storageItem.completeDate;
+ if (storageItem.completeDate instanceof TZDate) {
+ calendarItem.completeDate = storageItem.completeDate.addDuration(new TDur(0, 'MSECS'));
+ }
+ if (typeof storageItem.completeDate === 'string') {
+ calendarItem.completeDate = new TZDate(new Date(storageItem.completeDate));
+ }
calendarItem.progress = utils.copy(storageItem.progress);
}
return;
for (i in storageItems) {
- calendarItem = new CalendarItem(type, i, new TZDate(new Date(storageItems[i].lastModificationDate)), _security);
+ calendarItem = new CalendarItem(type, i, storageItems[i].lastModificationDate? new TZDate(new Date(storageItems[i].lastModificationDate)) : null, _security);
if (type === "EVENT") {
loadCalendarEventInit(calendarItem, storageItems[i]);
if (!_security.add) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
+
+ uid = Math.uuid(null, 16);
+ privateItems[uid] = utils.copy(item);
+ if (type === "EVENT") {
+ privateItems[uid].id = {uid: uid, rid: null};
+ } else {
+ privateItems[uid].id = uid;
+ }
+
+ saveCalendarItems();
+
// set the calendarId of the item
item.__defineGetter__("calendarId", function () {
return id;
});
- // typecoerce
- uid = (type === "EVENT") ? item.id.uid : item.id;
- privateItems[uid] = utils.copy(item);
-
- saveCalendarItems();
+ item.__defineGetter__("id", function () {
+ return privateItems[uid].id;
+ });
window.setTimeout(function () {
for (var i in _watchers) {
var i, uid;
for (i in items) {
- uid = (type === "EVENT") ? items[i].id.uid : items[i].id;
+ uid = Math.uuid(null, 16);
privateItems[uid] = utils.copy(items[i]);
+
+ if (type === "EVENT") {
+ privateItems[uid].id = {uid: uid, rid: null};
+ } else {
+ privateItems[uid].id = uid;
+ }
+
+ items[i].__defineGetter__("calendarId", function () {
+ return id;
+ });
+
+ items[i].__defineGetter__("id", function () {
+ return privateItems[uid].id;
+ });
}
saveCalendarItems();
if (successCallback) {
- successCallback(utils.copy(items));
+ successCallback(items);
}
for (i in _watchers) {
- _watchers[i].onitemsadded(utils.copy(items));
+ _watchers[i].onitemsadded(items);
}
}, 1);
}
if (!_security.addChangeListener) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- if ((typeof successCallback !== "object") ||
- (typeof successCallback.onitemsadded !== "function") ||
- (typeof successCallback.onitemsupdated !== "function") ||
- (typeof successCallback.onitemsremoved !== "function"))
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
+
+ successCallback = t.CalendarChangeCallback(successCallback);
watchId = ++defaultWatchId;
_watchers[watchId] = successCallback;
if (!_security.removeChangeListener) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- if (!_isValidId(watchId))
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
+
+ watchId = t.long(watchId);
if (!_watchers[watchId])
- throw new WebAPIException(errorcode.NOT_FOUND_ERR);
+ return;
delete _watchers[watchId];
}
_data.callHistory = [];
_save();
- if (successCallback) {
- successCallback();
- }
utils.forEach(_data.observers, function (observer) {
observer.onchanged(rtn);
});
+ if (successCallback) {
+ setTimeout(function () {
+ successCallback();
+ }, 1);
+ }
+
};
this.addChangeListener = function (observerObj) {
var handle = Number(Math.uuid(8, 10));
*/
var db = require('ripple/db'),
- utils = require('ripple/utils'),
- tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils'),
- t = require('ripple/platform/tizen/2.0/typecast'),
+ decorator = require('ripple/platform/tizen/2.0/decorator'),
errorcode = require('ripple/platform/tizen/2.0/errorcode'),
+ t = require('ripple/platform/tizen/2.0/typecast'),
+ tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils'),
+ utils = require('ripple/utils'),
+ ContactName = require('ripple/platform/tizen/2.0/ContactName'),
+ ContactAddress = require('ripple/platform/tizen/2.0/ContactAddress'),
+ ContactPhoneNumber = require('ripple/platform/tizen/2.0/ContactPhoneNumber'),
+ ContactEmailAddress = require('ripple/platform/tizen/2.0/ContactEmailAddress'),
+ ContactAnniversary = require('ripple/platform/tizen/2.0/ContactAnniversary'),
+ ContactOrganization = require('ripple/platform/tizen/2.0/ContactOrganization'),
+ ContactWebSite = require('ripple/platform/tizen/2.0/ContactWebSite'),
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
WebAPIException = require('ripple/platform/tizen/2.0/WebAPIException'),
- Contact = require('ripple/platform/tizen/2.0/ContactBase'),
AddressBook,
AddressBookData,
AddressBookStorage,
- ContactPublic,
+ Contact,
ContactData,
- ContactPrivate,
+ ContactInternal,
ContactGroup,
Person,
PersonBuilder,
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- t.ContactManager("updateBatch", arguments);
+ t.ContactManager("updateBatch", arguments, true);
window.setTimeout(function () {
var i, updated;
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- t.ContactManager("removeBatch", arguments);
+ t.ContactManager("removeBatch", arguments, true);
window.setTimeout(function () {
var i;
// private
function addNewContact(contact, external) {
var added, person;
- added = new ContactPrivate(contact, true);
+
+ added = new ContactInternal(contact);
privateData.contacts[added.id] = added;
person = new PersonBuilder(added);
dbContacts[added.id] = _serialize(added);
_data.dbStorage.persons[person.id] = _serialize(_data.persons[person.id]);
- external.__defineGetter__("id", function () {
- return added.id;
- });
- external.__defineGetter__("personId", function () {
- return added.personId;
- });
- external.__defineGetter__("addressBookId", function () {
- return added.addressBookId;
- });
- external.__defineGetter__("lastUpdated", function () {
- return added.lastUpdated;
- });
- if (external.name !== null) {
- external.name.__defineGetter__("displayName", function () {
- return added.name.displayName;
- });
- }
+ decorator.Contact(external, added);
}
// public
if (privateData.contacts[id] === undefined) {
throw new WebAPIException(errorcode.NOT_FOUND_ERR);
}
- return new ContactPublic(privateData.contacts[id]);
+ return new Contact(privateData.contacts[id]);
}
function add(contact) {
- var added, external = contact;
+ var external = contact;
if (!_security.add) {
throw new WebAPIException(errorcode.SECURITY_ERR);
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- t.AddressBook("add", arguments);
+ t.AddressBook("add", arguments, true);
addNewContact(contact, external);
_save();
window.setTimeout(function () {
utils.forEach(privateData.listeners, function (listener) {
- listener.oncontactsadded([new ContactPublic(added)]);
+ listener.oncontactsadded([new Contact(external)]);
});
utils.forEach(_data.contactData.listeners, function (listener) {
listener.onpersonsadded([new Person(_data.persons[external.personId])]);
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- t.AddressBook("addBatch", arguments);
+ t.AddressBook("addBatch", arguments, true);
window.setTimeout(function () {
var i, personIds = [];
var i, watched = [];
for (i in contacts) {
- watched.push(new ContactPublic(external[i]));
+ watched.push(new Contact(external[i]));
}
listener.oncontactsadded(watched);
});
throw new WebAPIException(errorcode.NOT_FOUND_ERR);
}
- updated = new ContactPrivate(contact, false);
+ updated = new ContactInternal(contact);
privateData.contacts[updated.id] = updated;
dbContacts[updated.id] = _serialize(updated);
window.setTimeout(function () {
utils.forEach(privateData.listeners, function (listener) {
- listener.oncontactsupdated([new ContactPublic(updated)]);
+ listener.oncontactsupdated([new Contact(updated)]);
});
}, 1);
}
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- t.AddressBook("updateBatch", arguments);
+ t.AddressBook("updateBatch", arguments, true);
window.setTimeout(function () {
var i, updated;
}
}
for (i in contacts) {
- updated = new ContactPrivate(contacts[i], false);
+ updated = new ContactInternal(contacts[i]);
privateData.contacts[updated.id] = updated;
dbContacts[updated.id] = _serialize(updated);
var i, watched = [];
for (i in contacts) {
- watched.push(new ContactPublic(
+ watched.push(new Contact(
privateData.contacts[contacts[i].id]));
}
listener.oncontactsupdated(watched);
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- t.AddressBook("removeBatch", arguments);
+ t.AddressBook("removeBatch", arguments, true);
window.setTimeout(function () {
var i;
/* return all contacts if no filter argument */
if (filter === null || filter === undefined) {
utils.forEach(privateData.contacts, function (contact) {
- result.push(new ContactPublic(contact));
+ result.push(new Contact(contact));
});
- successCallback(result);
+ window.setTimeout(function () {
+ successCallback(result);
+ }, 1);
return;
}
}
for (i in matched) {
- result.push(new ContactPublic(matched[i]));
+ result.push(new Contact(matched[i]));
}
- successCallback(result);
+
+ window.setTimeout(function () {
+ successCallback(result);
+ }, 1);
}
function addChangeListener(successCallback, errorCallback) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- t.AddressBook("addGroup", arguments);
+ t.AddressBook("addGroup", arguments, true);
group.id = Math.uuid(null, 16);
group.addressBookId = id;
// private
function loadContacts() {
for (var i in contacts) {
- addressBookData.contacts[i] = new ContactPrivate(contacts[i], false);
+ addressBookData.contacts[i] = new ContactInternal(contacts[i]);
}
}
this.groups = groups;
};
-ContactData = function () {
- this.listeners = {};
- this.nListener = 0;
-};
+Contact = function (contact) {
+ var i, attr, arr;
+
+ this.name = null;
+ this.addresses = [];
+ this.photoURI = null;
+ this.phoneNumbers = [];
+ this.emails = [];
+ this.birthday = null;
+ this.anniversaries = [];
+ this.organizations = [];
+ this.notes = [];
+ this.urls = [];
+ this.ringtoneURI = null;
+ this.groupIds = [];
+
+ for (attr in contact) {
+ switch (attr) {
+ case "name":
+ this[attr] = new ContactName(contact[attr]);
+ break;
-ContactPublic = function (prop) {
- var _self;
+ case "addresses":
+ arr = contact[attr];
+ if (arr) {
+ for (i in arr) {
+ this[attr][i] = new ContactAddress(arr[i]);
+ }
+ }
+ break;
- _self = new Contact(prop, _security);
+ case "phoneNumbers":
+ arr = contact[attr];
+ if (arr) {
+ for (i in arr) {
+ this[attr][i] = new ContactPhoneNumber(arr[i].number,
+ arr[i].types || null, arr[i].isDefault || null);
+ }
+ }
+ break;
- _self.__defineGetter__("id", function () {
- return prop.id;
- });
- _self.__defineGetter__("personId", function () {
- return prop.personId;
- });
- _self.__defineGetter__("addressBookId", function () {
- return prop.addressBookId;
- });
- _self.__defineGetter__("lastUpdated", function () {
- return prop.lastUpdated;
- });
- _self.__defineGetter__("isFavorite", function () {
- return prop.isFavorite;
- });
- if (_self.name !== null) {
- _self.name.__defineGetter__("displayName", function () {
- return prop.name.displayName;
- });
- }
+ case "emails":
+ arr = contact[attr];
+ if (arr) {
+ for (i in arr) {
+ this[attr][i] = new ContactEmailAddress(arr[i].email,
+ arr[i].types || null, arr[i].isDefault || null);
+ }
+ }
+ break;
- return _self;
-};
+ case "birthday":
+ this[attr] = new Date(contact[attr]);
+ break;
-ContactPrivate = function (prop, newID) {
- var _self;
+ case "anniversaries":
+ arr = contact[attr];
+ if (arr) {
+ for (i in arr) {
+ if (!tizen1_utils.isValidDate(arr[i].date)) {
+ arr[i].date = new Date(arr[i].date);
+ }
+ this[attr][i] = new ContactAnniversary(arr[i].date,
+ arr[i].label || null);
+ }
+ }
+ break;
- _self = utils.copy(new Contact(prop, _security));
-
- if (newID) {
- _self.id = Math.uuid(null, 16);
- _self.lastUpdated = new Date();
-
- if (_self.name !== null) {
- _self.name.__defineGetter__("displayName", function () {
- var displayName = "";
-
- if ((_self.name.firstName !== null) &&
- (_self.name.lastName !== null)) {
- displayName = [_self.name.firstName, _self.name.middleName,
- _self.name.lastName];
- displayName = displayName.join(" ").replace(/ +/g, " ").trim();
- } else if (_self.name.nicknames.length !== 0) {
- _self.name.nicknames.some(function (nickname) {
- displayName = nickname;
- return displayName;
- });
+ case "organizations":
+ arr = contact[attr];
+ if (arr) {
+ for (i in arr) {
+ this[attr][i] = new ContactOrganization(arr[i]);
}
+ }
+ break;
- return displayName;
- });
+ case "notes":
+ case "groupIds":
+ arr = contact[attr];
+ if (arr) {
+ for (i in arr) {
+ this[attr][i] = arr[i];
+ }
+ }
+ break;
+
+ case "urls":
+ arr = contact[attr];
+ if (arr) {
+ for (i in arr) {
+ this[attr][i] = new ContactWebSite(arr[i].url,
+ arr[i].type || null);
+ }
+ }
+ break;
+
+ default:
+ this[attr] = contact[attr];
+ break;
}
+ }
+
+ decorator.Contact(this, contact);
+ this.__proto__ = tizen.Contact.prototype;
+};
+
+ContactInternal = function (contact) {
+ var attr;
+
+ for (attr in contact) {
+ this[attr] = contact[attr];
+ }
+
+ if (!contact.id) {
+ this.id = Math.uuid(null, 16);
+ this.lastUpdated = new Date();
} else {
- _self.id = prop.id;
- _self.personId = prop.personId;
- _self.addressBookId = prop.addressBookId;
- _self.lastUpdated = new Date(prop.lastUpdated);
+ this.lastUpdated = new Date(contact.lastUpdated);
}
- return _self;
+ if (this.name) {
+ this.name.__defineGetter__("displayName", function () {
+ var displayName = "";
+
+ if (!this)
+ return "";
+
+ if ((this.firstName !== null) &&
+ (this.lastName !== null)) {
+ displayName = [this.firstName, this.middleName, this.lastName];
+ displayName = displayName.join(" ").replace(/ +/g, " ").trim();
+ } else if (this.nicknames.length !== 0) {
+ this.nicknames.some(function (nickname) {
+ displayName = nickname;
+ return displayName;
+ });
+ }
+
+ return displayName;
+ });
+ }
+};
+
+ContactData = function () {
+ this.listeners = {};
+ this.nListener = 0;
};
ContactGroup = function (groupInitDict) {
this.name = groupInitDict.name || "";
this.ringtoneURI = groupInitDict.ringtoneURI || null;
this.photoURI = groupInitDict.photoURI || null;
+
+ this.__proto__ = tizen.ContactGroup.prototype;
};
Person = function (personInitDict) {
for (idab in _data.contacts) {
contact = _data.contacts[idab][this.displayContactId];
+
if (contact !== undefined) {
if (contact.name && contact.name.displayName) {
displayName = contact.name.displayName;
});
define('ripple/platform/tizen/2.0/content', function (require, exports, module) {
/*
- * Copyright 2012 Intel Corporation
+ * Copyright 2013 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
var db = require('ripple/db'),
utils = require('ripple/utils'),
dbfs = require('ripple/platform/tizen/2.0/dbfs'),
+ dbinit = require('ripple/platform/tizen/2.0/dbinit'),
+ errorcode = require('ripple/platform/tizen/2.0/errorcode'),
t = require('ripple/platform/tizen/2.0/typecast'),
tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils'),
- errorcode = require('ripple/platform/tizen/2.0/errorcode'),
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
WebAPIException = require('ripple/platform/tizen/2.0/WebAPIException'),
- ContentDirectory,
Content,
- VideoContent,
+ ContentDirectory,
+ ContentFactory,
+ ContentStorage,
AudioContent,
ImageContent,
- ContentFactory,
+ VideoContent,
+ ContentInternal,
+ ContentDirectoryInternal,
+ AudioContentInternal,
+ ImageContentInternal,
+ VideoContentInternal,
+ AudioContentLyrics,
_data = {
DB_CONTENT_KEY: "tizen1-db-content",
- directories: [],
- contents: [],
+ content: {},
listener: null,
- dbStorage: {}
+ dbStorage: null
},
_security = {
"http://tizen.org/privilege/content.read": ["find",
_self;
function _get() {
- _data.dbStorage = db.retrieveObject(_data.DB_CONTENT_KEY) || require('ripple/platform/tizen/2.0/dbinit').Content;
+ _data.dbStorage = db.retrieveObject(_data.DB_CONTENT_KEY) || dbinit.Content;
}
function _save() {
if (!_data.dbStorage)
return;
- utils.forEach(_data.dbStorage.directories, function (directory) {
- _data.directories.push(new ContentDirectory(directory, true));
- });
- utils.forEach(_data.dbStorage.contents, function (content) {
- _data.contents.push(new ContentFactory(content, true));
+ utils.forEach(_data.dbStorage, function (content) {
+ _data.content[content.directoryURI] = new ContentStorage(content);
});
- _data.dbStorage.directories = _data.directories;
- _data.dbStorage.contents = _data.contents;
-
+ _data.dbStorage = _data.content;
_save();
}
var content;
// private
- function updateContents(contents, successCallback, errorCallback) {
- var i, j, isFound = false, matched = [];
-
- if (tizen1_utils.isValidArray(contents)) {
- for (i in contents) {
- for (j in _data.contents) {
- if (contents[i].id === _data.contents[j].id) {
- matched.push(j);
- break;
- }
- }
- }
-
- if (matched.length === contents.length) {
- for (i in matched) {
- _data.contents[matched[i]] = new ContentFactory(contents[i]);
- }
- isFound = true;
- }
- } else {
- for (i in _data.contents) {
- if (_data.contents[i].id === contents.id) {
- _data.contents[i] = new ContentFactory(contents);
- matched.push(i);
- isFound = true;
- break;
- }
- }
- }
-
- if (isFound) {
- _save();
-
- if (successCallback) {
- successCallback();
- }
- if (_data.listener !== null) {
- utils.forEach(matched, function (i) {
- _data.listener.oncontentupdated(new ContentFactory(_data.contents[i]));
- });
- }
- } else if (errorCallback) {
- errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
- }
- }
-
function getType(file) {
var extName, type;
return title;
}
+ function getDirectoryURI(contentURI) {
+ return contentURI.slice(0, contentURI.lastIndexOf("/") + 1)
+ .replace(/file:\/\//, "");
+ }
+
function extractProperties(entry) {
var contentInitDict = {};
- contentInitDict.editableAttributes = ["name", "title", "description", "rating"];
+ contentInitDict.editableAttributes = ["name", "title", "description",
+ "rating"];
contentInitDict.name = entry.name;
contentInitDict.type = getType(entry.name);
contentInitDict.mimeType = getMimeType(entry.name);
contentInitDict.title = getTitle(entry.name);
- contentInitDict.contentURI = entry.fullPath;
+ contentInitDict.contentURI = entry.fullPath ?
+ "file://" + entry.fullPath : entry.fullPath;
contentInitDict.thumbnailURIs = [entry.fullPath];
contentInitDict.releaseDate = entry.lastModifiedDate;
contentInitDict.modifiedDate = entry.lastModifiedDate;
return contentInitDict;
}
+ function updateContents(contents, successCallback, errorCallback) {
+ var i, isFound = false, dir, matched = [];
+
+ for (i in contents) {
+ dir = getDirectoryURI(contents[i].contentURI);
+
+ isFound = ((dir in _data.content) && (contents[i].contentURI in
+ _data.content[dir].contents));
+
+ if (!isFound)
+ break;
+
+ matched.push(dir);
+ }
+
+ if (!isFound) {
+ if (errorCallback) {
+ errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
+ }
+ return;
+ }
+
+ for (i in matched) {
+ _data.content[matched[i]].contents[contents[i].contentURI] =
+ new ContentFactory(contents[i], true);
+ }
+
+ _save();
+
+ if (successCallback) {
+ successCallback();
+ }
+
+ if (_data.listener !== null) {
+ for (i in matched) {
+ _data.listener.oncontentupdated(new ContentFactory(_data
+ .content[matched[i]].contents[contents[i].contentURI],
+ false));
+ }
+ }
+ }
+
// public
function update(content) {
if (!_security.update) {
t.ContentManager("update", arguments);
- updateContents(content);
+ updateContents([content]);
}
function updateBatch(contents, successCallback, errorCallback) {
}
function getDirectories(successCallback, errorCallback) {
- var result = [];
-
t.ContentManager("getDirectories", arguments);
- if (_data.directories.length === 0) {
- if (errorCallback) {
- setTimeout(function () {
- errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
- }, 1);
+ window.setTimeout(function () {
+ var i, directories = [];
+
+ for (i in _data.content) {
+ directories.push(new ContentDirectory(_data.content[i]));
}
- return;
- }
- utils.forEach(_data.directories, function (directory) {
- result.push(new ContentDirectory(directory));
- });
+ if (directories.length === 0) {
+ if (errorCallback) {
+ errorCallback(new WebAPIError(errorcode.NOT_FOUND_ERR));
+ }
+ return;
+ }
- setTimeout(function () {
- successCallback(result);
+ successCallback(directories);
}, 1);
}
- function find(successCallback, errorCallback, directoryId, filter, sortMode, count, offset) {
- var src = [], result = [], i, directoryURI, parentURI, contents;
-
+ function find(successCallback, errorCallback, directoryId, filter, sortMode,
+ count, offset) {
if (!_security.find) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
t.ContentManager("find", arguments);
- if (!directoryId) {
- src = _data.contents;
- } else {
- if (_data.directories.length === 0) {
- if (errorCallback) {
- setTimeout(function () {
- errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
- }, 1);
- }
- return;
- }
+ window.setTimeout(function () {
+ var i, dir, contents = [], results = [], matchedDir;
- for (i in _data.directories) {
- if (_data.directories[i].id === directoryId) {
- directoryURI = _data.directories[i].directoryURI;
- break;
+ if (!directoryId) {
+ for (dir in _data.content) {
+ for (i in _data.content[dir].contents) {
+ contents.push(_data.content[dir].contents[i]);
+ }
+ }
+ } else {
+ for (dir in _data.content) {
+ if (_data.content[dir].id === directoryId) {
+ matchedDir = dir;
+ break;
+ }
}
- }
- if (!directoryURI) {
- if (errorCallback) {
- setTimeout(function () {
+ if (!matchedDir) {
+ if (errorCallback) {
errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
- }, 1);
+ }
+ return;
}
- return;
- }
- for (i in _data.contents) {
- parentURI = _data.contents[i].contentURI;
- parentURI = parentURI.slice(0, parentURI.lastIndexOf('/') + 1);
- if (parentURI === directoryURI) {
- src.push(_data.contents[i]);
+ for (i in _data.content[matchedDir].contents) {
+ contents.push(_data.content[matchedDir].contents[i]);
}
}
- }
- if (src.length === 0) {
- if (errorCallback) {
- setTimeout(function () {
+ if (contents.length === 0) {
+ if (errorCallback) {
errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
- }, 1);
+ }
+ return;
}
- return;
- }
- contents = tizen1_utils.query(src, filter, sortMode, count, offset);
+ contents = tizen1_utils.query(contents, filter, sortMode, count,
+ offset);
- utils.forEach(contents, function (content) {
- result.push(new ContentFactory(content));
- });
+ contents.forEach(function (content) {
+ results.push(new ContentFactory(content, false));
+ });
- successCallback(result);
+ successCallback(results);
+ }, 1);
}
function scanFile(contentURI, successCallback, errorCallback) {
- var i, index, isFound = false;
+ var dir, isFound;
function onStatSuccess(entry) {
- var contentInitDict, content, directoryURI;
+ var contentInitDict, content;
if (isFound) {
- content = new ContentFactory(_data.contents[index], true);
+ content = new ContentFactory(_data.content[dir]
+ .contents[contentURI], true);
} else {
contentInitDict = extractProperties(entry);
content = new ContentFactory(contentInitDict, true);
- _data.contents.push(content);
+ _data.content[dir].contents[contentURI] = content;
}
+
_save();
if (successCallback) {
- directoryURI = contentURI.slice(0,
- contentURI.lastIndexOf('/') + 1);
-
- successCallback(directoryURI);
+ successCallback(contentURI);
}
+
if (_data.listener !== null) {
if (isFound) {
- _data.listener.oncontentupdated(new ContentFactory(content));
+ _data.listener.oncontentupdated(
+ new ContentFactory(content, false));
} else {
- _data.listener.oncontentadded(new ContentFactory(content));
+ _data.listener.oncontentadded(
+ new ContentFactory(content, false));
}
}
}
function onStatError() {
- var directoryURI;
-
if (isFound) {
- _data.contents.splice(index, 1);
+ delete _data.content[dir].contents[contentURI];
_save();
if (successCallback) {
- directoryURI = contentURI.slice(0,
- contentURI.lastIndexOf('/') + 1);
-
- successCallback(directoryURI);
+ successCallback(contentURI);
}
+
if (_data.listener !== null) {
- _data.listener.oncontentremoved(_data.contents[index].id);
+ _data.listener.oncontentremoved(_data.content[dir]
+ .contents[contentURI].id);
}
} else if (errorCallback) {
- window.setTimeout(function () {
- errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
- }, 1);
+ errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
}
}
t.ContentManager("scanFile", arguments);
- for (i in _data.contents) {
- if (_data.contents[i].contentURI === contentURI) {
- isFound = true;
- index = i;
- break;
- }
- }
+ window.setTimeout(function () {
+ dir = getDirectoryURI(contentURI);
- dbfs.stat(contentURI, onStatSuccess, onStatError);
+ isFound = ((dir in _data.content) &&
+ (contentURI in _data.content[dir].contents));
+
+ dbfs.stat(contentURI.replace(/file:\/\//, ""), onStatSuccess,
+ onStatError);
+ }, 1);
}
function setChangeListener(changeCallback) {
return content;
};
-ContentDirectory = function (contentDirectoryInitDict, isInternal) {
+ContentDirectoryInternal = function (contentDirectoryInitDict) {
+ this.id = contentDirectoryInitDict.id || null;
+ this.directoryURI = contentDirectoryInitDict.directoryURI || null;
+ this.title = contentDirectoryInitDict.title || "";
+ this.storageType = contentDirectoryInitDict.storageType || "INTERNAL";
+ this.modifiedDate = contentDirectoryInitDict.modifiedDate ?
+ new Date(contentDirectoryInitDict.modifiedDate) : null;
+};
+
+ContentDirectory = function (contentDirectoryInitDict) {
var id, directoryURI, title, storageType, modifiedDate;
id = contentDirectoryInitDict.id || null;
directoryURI = contentDirectoryInitDict.directoryURI || null;
title = contentDirectoryInitDict.title || "";
storageType = contentDirectoryInitDict.storageType || "INTERNAL";
- modifiedDate = new Date(contentDirectoryInitDict.modifiedDate);
+ modifiedDate = contentDirectoryInitDict.modifiedDate ?
+ new Date(contentDirectoryInitDict.modifiedDate) : null;
- if (!isInternal) {
- this.__defineGetter__("id", function () {
- return id;
- });
+ this.__defineGetter__("id", function () {
+ return id;
+ });
- this.__defineGetter__("directoryURI", function () {
- return directoryURI;
- });
+ this.__defineGetter__("directoryURI", function () {
+ return directoryURI;
+ });
- this.__defineGetter__("title", function () {
- return title;
- });
+ this.__defineGetter__("title", function () {
+ return title;
+ });
- this.__defineGetter__("storageType", function () {
- return storageType;
- });
+ this.__defineGetter__("storageType", function () {
+ return storageType;
+ });
- this.__defineGetter__("modifiedDate", function () {
- return modifiedDate;
- });
- } else {
- this.id = id;
- this.directoryURI = directoryURI;
- this.title = title;
- this.storageType = storageType;
- this.modifiedDate = modifiedDate;
- }
+ this.__defineGetter__("modifiedDate", function () {
+ return modifiedDate;
+ });
+};
+
+ContentInternal = function (contentInitDict) {
+ this.editableAttributes = contentInitDict.editableAttributes || [];
+ this.id = contentInitDict.id || Math.uuid(null, 16);
+ this.type = contentInitDict.type || "IMAGE";
+ this.mimeType = contentInitDict.mimeType || "";
+ this.title = contentInitDict.title || "";
+ this.contentURI = contentInitDict.contentURI || "";
+ this.thumbnailURIs = contentInitDict.thumbnailURIs || null;
+ this.releaseDate = contentInitDict.releaseDate ?
+ new Date(contentInitDict.releaseDate) : null;
+ this.modifiedDate = contentInitDict.modifiedDate ?
+ new Date(contentInitDict.modifiedDate) : null;
+ this.size = contentInitDict.size || 0;
+ this.name = contentInitDict.name || "";
+ this.description = contentInitDict.description || null;
+ this.rating = contentInitDict.rating || 0;
};
-Content = function (contentInitDict, isInternal) {
+Content = function (contentInitDict) {
var editableAttributes, id, type, mimeType, title, contentURI,
thumbnailURIs, releaseDate, modifiedDate, size;
title = contentInitDict.title || "";
contentURI = contentInitDict.contentURI || "";
thumbnailURIs = contentInitDict.thumbnailURIs || null;
- releaseDate = new Date(contentInitDict.releaseDate);
- modifiedDate = new Date(contentInitDict.modifiedDate);
- size = contentInitDict.size || null;
+ releaseDate = contentInitDict.releaseDate ?
+ new Date(contentInitDict.releaseDate) : null;
+ modifiedDate = contentInitDict.modifiedDate ?
+ new Date(contentInitDict.modifiedDate) : null;
+ size = contentInitDict.size || 0;
this.name = contentInitDict.name || "";
- this.description = contentInitDict.description || "";
+ this.description = contentInitDict.description || null;
this.rating = contentInitDict.rating || 0;
- if (!isInternal) {
- this.__defineGetter__("editableAttributes", function () {
- return editableAttributes;
- });
+ this.__defineGetter__("editableAttributes", function () {
+ return editableAttributes;
+ });
- this.__defineGetter__("id", function () {
- return id;
- });
+ this.__defineGetter__("id", function () {
+ return id;
+ });
- this.__defineGetter__("type", function () {
- return type;
- });
+ this.__defineGetter__("type", function () {
+ return type;
+ });
- this.__defineGetter__("mimeType", function () {
- return mimeType;
- });
+ this.__defineGetter__("mimeType", function () {
+ return mimeType;
+ });
- this.__defineGetter__("title", function () {
- return title;
- });
+ this.__defineGetter__("title", function () {
+ return title;
+ });
- this.__defineGetter__("contentURI", function () {
- return contentURI;
- });
+ this.__defineGetter__("contentURI", function () {
+ return contentURI;
+ });
- this.__defineGetter__("thumbnailURIs", function () {
- return thumbnailURIs;
- });
+ this.__defineGetter__("thumbnailURIs", function () {
+ return thumbnailURIs;
+ });
- this.__defineGetter__("releaseDate", function () {
- return releaseDate;
- });
+ this.__defineGetter__("releaseDate", function () {
+ return releaseDate;
+ });
- this.__defineGetter__("modifiedDate", function () {
- return modifiedDate;
- });
+ this.__defineGetter__("modifiedDate", function () {
+ return modifiedDate;
+ });
- this.__defineGetter__("size", function () {
- return size;
- });
- } else {
- this.editableAttributes = editableAttributes;
- this.id = id;
- this.type = type;
- this.mimeType = mimeType;
- this.title = title;
- this.contentURI = contentURI;
- this.thumbnailURIs = thumbnailURIs;
- this.releaseDate = releaseDate;
- this.modifiedDate = modifiedDate;
- this.size = size;
- }
-};
-
-VideoContent = function (vidioContentInitDict, isInternal) {
- var _self, album, artists, duration, width, height;
-
- _self = new Content(vidioContentInitDict, isInternal);
-
- album = vidioContentInitDict.album || null;
- artists = vidioContentInitDict.artists || null;
- duration = vidioContentInitDict.duration || 0;
- width = vidioContentInitDict.width || 0;
- height = vidioContentInitDict.height || 0;
- _self.geolocation = vidioContentInitDict.geolocation || null;
-
- if (!isInternal) {
- _self.__defineGetter__("album", function () {
- return album;
- });
+ this.__defineGetter__("size", function () {
+ return size;
+ });
+};
- _self.__defineGetter__("artists", function () {
- return artists;
- });
+VideoContentInternal = function (videoContentInitDict) {
+ ContentInternal.call(this, videoContentInitDict);
- _self.__defineGetter__("duration", function () {
- return duration;
- });
+ this.geolocation = videoContentInitDict.geolocation || null;
+ this.album = videoContentInitDict.album || null;
+ this.artists = videoContentInitDict.artists || null;
+ this.duration = videoContentInitDict.duration || 0;
+ this.width = videoContentInitDict.width || 0;
+ this.height = videoContentInitDict.height || 0;
+};
- _self.__defineGetter__("width", function () {
- return width;
- });
+VideoContent = function (videoContentInitDict) {
+ var album, artists, duration, width, height;
+
+ Content.call(this, videoContentInitDict);
+
+ album = videoContentInitDict.album || null;
+ artists = videoContentInitDict.artists || null;
+ duration = videoContentInitDict.duration || 0;
+ width = videoContentInitDict.width || 0;
+ height = videoContentInitDict.height || 0;
+ this.geolocation = videoContentInitDict.geolocation || null;
+
+ this.__defineGetter__("album", function () {
+ return album;
+ });
+
+ this.__defineGetter__("artists", function () {
+ return artists;
+ });
+
+ this.__defineGetter__("duration", function () {
+ return duration;
+ });
+
+ this.__defineGetter__("width", function () {
+ return width;
+ });
+
+ this.__defineGetter__("height", function () {
+ return height;
+ });
+};
+
+AudioContentInternal = function (audioContentInitDict) {
+ ContentInternal.call(this, audioContentInitDict);
+
+ this.album = audioContentInitDict.album || null;
+ this.genres = audioContentInitDict.genres || null;
+ this.artists = audioContentInitDict.artists || null;
+ this.composers = audioContentInitDict.composers || null;
+ this.lyrics = audioContentInitDict.lyrics || null;
+ this.copyright = audioContentInitDict.copyright || null;
+ this.bitrate = audioContentInitDict.bitrate || 0;
+ this.trackNumber = audioContentInitDict.trackNumber || null;
+ this.duration = audioContentInitDict.duration || 0;
+};
+
+AudioContentLyrics = function (lyrics) {
+ var type, texts, timestamps;
+
+ type = lyrics.type;
+ texts = lyrics.texts;
+ if (lyrics.type === "UNSYNCHRONIZED")
+ timestamps = lyrics.timestamps;
+
+ this.__defineGetter__("type", function () {
+ return type;
+ });
- _self.__defineGetter__("height", function () {
- return height;
+ this.__defineGetter__("texts", function () {
+ return texts;
+ });
+
+ if (timestamps) {
+ this.__defineGetter__("timestamps", function () {
+ return timestamps;
});
- } else {
- _self.album = album;
- _self.artists = artists;
- _self.duration = duration;
- _self.width = width;
- _self.height = height;
}
-
- return _self;
};
-AudioContent = function (audioContentInitDict, isInternal) {
- var _self, album, genres, artists, composers, lyrics, copyright, bitrate,
+AudioContent = function (audioContentInitDict) {
+ var album, genres, artists, composers, lyrics, copyright, bitrate,
trackNumber, duration;
- _self = new Content(audioContentInitDict, isInternal);
+ Content.call(this, audioContentInitDict);
album = audioContentInitDict.album || null;
genres = audioContentInitDict.genres || null;
artists = audioContentInitDict.artists || null;
composers = audioContentInitDict.composers || null;
- lyrics = audioContentInitDict.lyrics || null;
+ lyrics = audioContentInitDict.lyrics ?
+ new AudioContentLyrics(audioContentInitDict.lyrics) : null;
copyright = audioContentInitDict.copyright || null;
bitrate = audioContentInitDict.bitrate || 0;
- trackNumber = audioContentInitDict.trackNumber || 0;
+ trackNumber = audioContentInitDict.trackNumber || null;
duration = audioContentInitDict.duration || 0;
- if (!isInternal) {
- _self.__defineGetter__("album", function () {
- return album;
- });
-
- _self.__defineGetter__("genres", function () {
- return genres;
- });
+ this.__defineGetter__("album", function () {
+ return album;
+ });
- _self.__defineGetter__("artists", function () {
- return artists;
- });
+ this.__defineGetter__("genres", function () {
+ return genres;
+ });
- _self.__defineGetter__("composers", function () {
- return composers;
- });
+ this.__defineGetter__("artists", function () {
+ return artists;
+ });
- _self.__defineGetter__("lyrics", function () {
- return lyrics;
- });
+ this.__defineGetter__("composers", function () {
+ return composers;
+ });
- _self.__defineGetter__("copyright", function () {
- return copyright;
- });
+ this.__defineGetter__("lyrics", function () {
+ return lyrics;
+ });
- _self.__defineGetter__("bitrate", function () {
- return bitrate;
- });
+ this.__defineGetter__("copyright", function () {
+ return copyright;
+ });
- _self.__defineGetter__("trackNumber", function () {
- return trackNumber;
- });
+ this.__defineGetter__("bitrate", function () {
+ return bitrate;
+ });
- _self.__defineGetter__("duration", function () {
- return duration;
- });
- } else {
- _self.album = album;
- _self.genres = genres;
- _self.artists = artists;
- _self.composers = composers;
- _self.lyrics = lyrics;
- _self.copyright = copyright;
- _self.bitrate = bitrate;
- _self.trackNumber = trackNumber;
- _self.duration = duration;
- }
+ this.__defineGetter__("trackNumber", function () {
+ return trackNumber;
+ });
- return _self;
+ this.__defineGetter__("duration", function () {
+ return duration;
+ });
};
-ImageContent = function (imageContentInitDict, isInternal) {
- var _self, width, height;
+ImageContentInternal = function (imageContentInitDict) {
+ ContentInternal.call(this, imageContentInitDict);
- _self = new Content(imageContentInitDict, isInternal);
+ this.geolocation = imageContentInitDict.geolocation || null;
+ this.width = imageContentInitDict.width || 0;
+ this.height = imageContentInitDict.height || 0;
+ this.orientation = imageContentInitDict.orientation || "NORMAL";
+};
- width = imageContentInitDict.width || 0;
- height = imageContentInitDict.height || 0;
- _self.geolocation = imageContentInitDict.geolocation || null;
- _self.orientation = imageContentInitDict.orientation || null;
+ImageContent = function (imageContentInitDict) {
+ var width, height;
- if (!isInternal) {
- _self.__defineGetter__("width", function () {
- return width;
- });
+ Content.call(this, imageContentInitDict);
- _self.__defineGetter__("height", function () {
- return height;
- });
- } else {
- _self.width = width;
- _self.height = height;
- }
+ width = imageContentInitDict.width || 0;
+ height = imageContentInitDict.height || 0;
+ this.geolocation = imageContentInitDict.geolocation || null;
+ this.orientation = imageContentInitDict.orientation || "NORMAL";
- return _self;
+ this.__defineGetter__("width", function () {
+ return width;
+ });
+
+ this.__defineGetter__("height", function () {
+ return height;
+ });
};
ContentFactory = function (contentInitDict, isInternal) {
- var _self;
+ var ContentType;
switch (contentInitDict.type) {
case "IMAGE":
- _self = new ImageContent(contentInitDict, isInternal);
+ ContentType = isInternal ? ImageContentInternal : ImageContent;
break;
case "VIDEO":
- _self = new VideoContent(contentInitDict, isInternal);
+ ContentType = isInternal ? VideoContentInternal : VideoContent;
break;
case "AUDIO":
- _self = new AudioContent(contentInitDict, isInternal);
+ ContentType = isInternal ? AudioContentInternal : AudioContent;
break;
default:
- _self = new Content(contentInitDict, isInternal);
+ ContentType = isInternal ? ContentInternal : Content;
break;
}
- return _self;
+ return new ContentType(contentInitDict);
+};
+
+ContentStorage = function (content) {
+ var i;
+
+ ContentDirectoryInternal.call(this, content);
+ this.contents = {};
+
+ for (i in content.contents) {
+ this.contents[i] = new ContentFactory(content.contents[i], true);
+ }
};
_initialize();
}
function update(key, oldValue, newValue) {
- var tree, count;
+ var tree, count, countNew;
if (!(key in data))
return false;
if (count === null)
return false;
+ countNew = tree.get(newValue);
+ count += (countNew === null) ? 0 : countNew;
tree.delete(oldValue);
tree.insert(newValue, count);
persist();
service_accounts: {},
item_counter: 1000,
type_table: {
- "TWO_WAY": 1,
- "SLOW": 2,
+ "TWO_WAY": 1,
+ "SLOW": 2,
"ONE_WAY_FROM_CLIENT": 3,
"REFRESH_FROM_CLIENT": 4,
"ONE_WAY_FROM_SERVER": 5,
"REFRESH_FROM_SERVER": 6
},
mode_table: {
- "TWO_WAY": 200,
- "SLOW": 201,
+ "TWO_WAY": 200,
+ "SLOW": 201,
"ONE_WAY_FROM_CLIENT": 202,
"REFRESH_FROM_CLIENT": 203,
"ONE_WAY_FROM_SERVER": 204,
_security = {
"http://tizen.org/privilege/datasync":
["add", "update", "remove", "getMaxProfilesNum", "getProfilesNum",
- "get", "getAll", "startSync", "stopSync", "getLastSyncStatistics"]
+ "get", "getAll", "startSync", "stopSync", "getLastSyncStatistics"]
},
_self,
syncml = {
return cb(null);
}
});
+
function _initialize() {
_data.agent = new TizenAgent();
_get();
var datasync;
// private
- function checkProfile(profile) {
- var sync_account;
-
- if (!profile || Object.prototype.toString.call(profile) !== "[object Object]") {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
-
-
- t.SyncProfileInfo(profile);
-
- if (profile.serviceInfo &&
- Object.prototype.toString.call(profile.serviceInfo) !== "[object Array]") {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
-
- // check "type" if mode is "MANUAL"
- // check "interval" if mode is "PERIODIC"
- switch (profile.syncInfo.mode) {
- case "MANUAL":
- // (syncInfo.type) null is acceptable due to spec
- // Spec:
- // ...the sync type 'SHOULD' be specified. The default value is TWO_WAY
- if (profile.syncInfo.type) {
- profile.syncInfo.type = t.SyncType(profile.syncInfo.type);
- }
- break;
- case "PERIODIC":
- // (syncInfo.interval) null is acceptable
- // Spec:
- // .. The sync interval 'SHOULD' be provided.
- // Question: Spec don't tell the default value when interval is null
- if (profile.syncInfo.interval) {
- profile.syncInfo.interval = t.SyncInterval(profile.syncInfo.interval);
- }
- break;
- }
- // check unreadable parameter: syncInfo (id/password)
- if (typeof profile.syncInfo.__syncInfoID__ !== "number") {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
- sync_account = db.retrieveObject("save-syncinfo")[profile.syncInfo.__syncInfoID__];
- sync_account.id = t.DOMString(sync_account.id);
- sync_account.password = t.DOMString(sync_account.password);
- }
-
function createInternalProfile(profile) {
var _profile, sync_account, service_accounts;
var info;
info = new SyncServiceInfoMod(p.serviceInfo[i].enable,
p.serviceInfo[i].serviceType, p.serviceInfo[i].serverDatabaseUri,
- p.serviceInfo[i].id, p.serviceInfo[i].password);
+ p.serviceInfo[i].id || null, p.serviceInfo[i].password || null);
_serviceinfo.push(info);
}
}
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- checkProfile(profile);
+ t.DataSynchronizationManager("add", arguments);
+
_profile = createInternalProfile(profile);
if (_data.profile_num > _data.MAX_PROFILE_NUMBER) {
function update(profile) {
var _profile;
+
if (!_security.update) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- checkProfile(profile);
+ t.DataSynchronizationManager("update", arguments);
+
_profile = createInternalProfile(profile);
if (!profile.profileId || !_data.profiles[profile.profileId]) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- profileId = t.DOMString(profileId);
+ t.DataSynchronizationManager("remove", arguments);
if (!_data.profiles[profileId]) {
throw new WebAPIException(errorcode.NOT_FOUND_ERR);
function get(profileId) {
var profile;
+
if (!_security.get) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- profileId = t.DOMString(profileId);
+ t.DataSynchronizationManager("get", arguments);
if (!_data.profiles[profileId]) {
throw new WebAPIException(errorcode.NOT_FOUND_ERR);
function getAll() {
var profiles = [], i;
+
if (!_security.getAll) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
function startSync(profileId, progressCallback) {
var _profile, _stores, _routes, sync_peer;
+
if (!_security.startSync) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- profileId = t.DOMString(profileId);
- if (arguments.length >= 2) {
- if (Object.prototype.toString.call(progressCallback) !== "[object Object]" ||
- (progressCallback.hasOwnProperty("onprogress") &&
- typeof progressCallback.onprogress !== "function") ||
- (progressCallback.hasOwnProperty("oncompleted") &&
- typeof progressCallback.oncompleted !== "function") ||
- (progressCallback.hasOwnProperty("onstopped") &&
- typeof progressCallback.onstopped !== "function") ||
- (progressCallback.hasOwnProperty("onfailed") &&
- typeof progressCallback.onfailed !== "function") ||
- (!progressCallback.hasOwnProperty("onprogress") &&
- !progressCallback.hasOwnProperty("oncompleted") &&
- !progressCallback.hasOwnProperty("onstopped") &&
- !progressCallback.hasOwnProperty("onfailed"))
- ) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
- }
+ t.DataSynchronizationManager("startSync", arguments);
if (!_data.profiles[profileId]) {
throw new WebAPIException(errorcode.NOT_FOUND_ERR);
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- profileId = t.DOMString(profileId);
+ t.DataSynchronizationManager("stopSync", arguments);
if (!_data.profiles[profileId]) {
throw new WebAPIException(errorcode.NOT_FOUND_ERR);
function getLastSyncStatistics(profileId) {
var s, statistics = [], i;
+
if (!_security.getLastSyncStatistics) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- profileId = t.DOMString(profileId);
+ t.DataSynchronizationManager("getLastSyncStatistics", arguments);
if (!_data.profiles[profileId]) {
throw new WebAPIException(errorcode.NOT_FOUND_ERR);
*/
var utils = require('ripple/utils'),
- dbfs = require('ripple/platform/tizen/2.0/dbfs'),
exception = require('ripple/exception'),
+ dbfs = require('ripple/platform/tizen/2.0/dbfs'),
filesystem = require('ripple/platform/tizen/2.0/filesystem'),
DBBuilder,
Content,
function _initialize() {
_data.dbBuilder = new DBBuilder();
- _data.dbBuilder.register("FileSystem", FileSystem);
- _data.dbBuilder.register("Content", Content, "dbcontent.xml");
+ _data.dbBuilder.register("FileSystem", "", FileSystem);
+ _data.dbBuilder.register("Content", "dbcontent.xml", Content);
+ _data.dbBuilder.register("Package", "dbpackage.xml");
+ _data.dbBuilder.register("Application", "dbapplication.xml");
+
+ _data.FileSystem.initdb();
}
DBBuilder = function () {
// private
function formatString(str) {
- return str.replace(/^\s+|[\t\n\r\v]+|\s+$/g, '').replace(/\s+/g, ' ');
+ return str.replace(/^\s+|[\t\n\r\v]+|\s+$/g, "").replace(/\s+/g, " ");
}
- function getAttributeValue(attr, type) {
- var i, value;
+ function getType(node) {
+ var type, reNum, reDate;
- if (("childNodes" in attr) && (typeof type !== 'object')) {
- value = [];
+ if (node.childNodes) {
+ return (node.childNodes[0].nodeName === "i") ? "Array" : "Object";
+ }
- for (i in attr.childNodes) {
- value.push(getAttributeValue(attr.childNodes[i], type));
- }
+ // Special case
+ if (node.nodeName === "version") {
+ return "DOMString";
+ }
- return value;
+ reNum = /^(-?\d+)(\.\d+)?$/;
+ reDate = /^(\d{4})\-(\d{2})\-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})$/;
+
+ if (reNum.test(node.textContent)) {
+ type = "Number";
+ } else if (reDate.test(node.textContent)) {
+ type = "Date";
+ } else if (node.textContent === "true" || node.textContent === "false") {
+ type = "Boolean";
+ } else {
+ type = "DOMString";
}
- switch (type) {
- case "Date":
- value = new Date(formatString(attr.textContent));
+ return type;
+ }
+
+ function build(node) {
+ var i, value;
+
+ switch (getType(node)) {
+ case "Boolean":
+ value = (formatString(node.textContent) === "true");
break;
- case "DOMString":
- value = formatString(attr.textContent);
+ case "Date":
+ value = new Date(formatString(node.textContent));
break;
case "Number":
- value = Number(formatString(attr.textContent));
+ value = Number(formatString(node.textContent));
break;
- default:
- if (("childNodes" in attr) && (typeof type === 'object')) {
- value = {};
-
- for (i in attr.childNodes) {
- value[attr.childNodes[i].nodeName] = getAttributeValue(
- attr.childNodes[i], type[attr.childNodes[i].nodeName]);
- }
+ case "Object":
+ value = {};
+ for (i in node.childNodes) {
+ value[node.childNodes[i].nodeName] = build(node.childNodes[i]);
}
break;
- }
- return value;
- }
-
- // public
- function register(type, Module, xmlFile) {
- _data[type] = new Module();
- _self[type] = _data[type].initdb(xmlFile);
- }
-
- function build(obj, pattern) {
- var i, type, self = {};
-
- for (i in obj.childNodes) {
- type = pattern[obj.childNodes[i].nodeName];
-
- if (type && obj.childNodes[i]) {
- self[obj.childNodes[i].nodeName] = getAttributeValue(
- obj.childNodes[i], type);
+ case "Array":
+ value = [];
+ for (i in node.childNodes) {
+ value.push(build(node.childNodes[i]));
}
+ break;
+
+ default: // "DOMString"
+ value = formatString(node.textContent);
+ break;
}
- return self;
+ return value;
}
- function parseXml(obj) {
+ function parse(obj) {
var i, res = {};
- res.nodeName = obj.nodeName;
+ res.nodeName = ("name" in obj.attributes) ?
+ obj.attributes["name"].value : obj.nodeName;
if (obj.childElementCount === 0) {
res.textContent = obj.textContent;
for (i in obj.childNodes) {
if (obj.childNodes[i].attributes) {
- res.childNodes.push(parseXml(obj.childNodes[i]));
+ res.childNodes.push(parse(obj.childNodes[i]));
}
}
}
return res;
}
+ // public
+ function register(type, dbXml, Extension) {
+ _data[type] = Extension ? new Extension() : {};
+
+ if (!dbXml)
+ return;
+
+ _self.__defineGetter__(type, function () {
+ var fnInit;
+
+ if (!_data[type].db) {
+ fnInit = _data[type].initdb || initdb;
+ _data[type].db = fnInit(dbXml);
+ }
+
+ return _data[type].db;
+ });
+ }
+
+ function initdb(dbXml) {
+ var db = {}, xmlHttp, res;
+
+ try {
+ xmlHttp = new XMLHttpRequest();
+ xmlHttp.open("GET", "dbsamples/" + dbXml, false);
+ xmlHttp.send();
+ } catch (e) {
+ exception.handle(e);
+ }
+
+ if (!xmlHttp.responseXML) {
+ return null;
+ }
+
+ res = parse(xmlHttp.responseXML.documentElement);
+ res.childNodes.forEach(function (node) {
+ db[node.nodeName] = build(node);
+ });
+
+ return db;
+ }
+
self = {
register: register,
- build: build,
- parseXml: parseXml
+ initdb: initdb
};
return self;
// private
function createPath(path) {
- var parts = path.replace(/^\//, '').split("/"),
+ var parts = path.replace(/^\//, "").split("/"),
workflow = jWorkflow.order();
parts.forEach(function (part, index) {
filesystem.resolve("images", function () {});
filesystem.resolve("videos", function () {});
filesystem.resolve("music", function () {});
-
- return null;
}
function createFile(uri) {
var directoryURI;
- directoryURI = uri.slice(0, uri.lastIndexOf('/') + 1);
+ directoryURI = uri.slice(0, uri.lastIndexOf("/") + 1)
+ .replace(/file:\/\//, "");
+
dbfs.stat(directoryURI, function () {}, function () {
createPath(directoryURI);
});
+ uri = uri.replace(/file:\/\//, "");
dbfs.touch(uri, function () {});
}
*/
Content = function () {
- var self, ImageContent, VideoContent, AudioContent,
- DirectoryContent, ContentFactory;
-
- VideoContent = {
- editableAttributes: "DOMString",
- id: "DOMString",
- name: "DOMString",
- type: "DOMString",
- mimeType: "DOMString",
- title: "DOMString",
- contentURI: "DOMString",
- thumbnailURIs: "DOMString",
- releaseDate: "Date",
- modifiedDate: "Date",
- size: "Number",
- description: "DOMString",
- rating: "Number",
-
- geolocation: {latitude: "Number", longtitude: "Number"},
- album: "DOMString",
- artists: "DOMString",
- duration: "Number",
- width: "Number",
- height: "Number"
- };
-
- AudioContent = {
- editableAttributes: "DOMString",
- id: "DOMString",
- name: "DOMString",
- type: "DOMString",
- mimeType: "DOMString",
- title: "DOMString",
- contentURI: "DOMString",
- thumbnailURIs: "DOMString",
- releaseDate: "Date",
- modifiedDate: "Date",
- size: "Number",
- description: "DOMString",
- rating: "Number",
-
- album: "DOMString",
- genres: "DOMString",
- artists: "DOMString",
- composers: "DOMString",
- lyrics: {
- type: "DOMString",
- timestamps: "DOMString",
- texts: "DOMString"
- },
- copyright: "DOMString",
- bitrate: "Number",
- trackNumber: "Number",
- duration: "Number"
- };
-
- ImageContent = {
- editableAttributes: "DOMString",
- id: "DOMString",
- name: "DOMString",
- type: "DOMString",
- mimeType: "DOMString",
- title: "DOMString",
- contentURI: "DOMString",
- thumbnailURIs: "DOMString",
- releaseDate: "Date",
- modifiedDate: "Date",
- size: "Number",
- description: "DOMString",
- rating: "Number",
-
- geolocation: {latitude: "Number", longtitude: "Number"},
- width: "Number",
- height: "Number",
- orientation: "DOMString"
- };
-
- DirectoryContent = {
- id: "DOMString",
- directoryURI: "DOMString",
- title: "DOMString",
- storageType: "DOMString",
- modifiedDate: "Date"
- };
-
- ContentFactory = function (type) {
- var pattern;
+ var self, ContentStorage;
- switch (type) {
- case "video":
- pattern = VideoContent;
- break;
+ ContentStorage = function (contents, directories) {
+ var i, parentURI;
- case "audio":
- pattern = AudioContent;
- break;
+ for (i in directories) {
+ directories[i].contents = {};
+ this[directories[i].directoryURI] = directories[i];
+ }
- case "image":
- pattern = ImageContent;
- break;
+ for (i in contents) {
+ parentURI = contents[i].contentURI.slice(0,
+ contents[i].contentURI.lastIndexOf("/") + 1)
+ .replace(/file:\/\//, "");
- case "directory":
- pattern = DirectoryContent;
- break;
+ if (parentURI in this) {
+ this[parentURI].contents[contents[i].contentURI] = contents[i];
+ }
}
-
- return pattern;
};
// public
- function initdb(dbFileName) {
- var i, db, results, xmlHttp;
+ function initdb(dbXml) {
+ var i, db;
- db = {
- contents: [],
- directories: []
- };
-
- try {
- if (!utils.appLocation())
- return null;
-
- xmlHttp = new XMLHttpRequest();
- xmlHttp.open("GET", utils.appLocation() + dbFileName, false);
- xmlHttp.send();
+ db = _data.dbBuilder.initdb(dbXml);
- if (!xmlHttp.responseXML) {
- xmlHttp.open("GET", "dbsamples/" + dbFileName, false);
- xmlHttp.send();
- }
- } catch (e) {
- exception.handle(e);
- }
-
- if (!xmlHttp.responseXML) {
- return db;
- }
-
- results = _data.dbBuilder.parseXml(xmlHttp.responseXML.documentElement);
- results.childNodes[0].childNodes.forEach(function (node) {
- db.contents.push(_data.dbBuilder.build(node,
- new ContentFactory(node.nodeName)));
- });
- results.childNodes[1].childNodes.forEach(function (node) {
- db.directories.push(_data.dbBuilder.build(node,
- new ContentFactory(node.nodeName)));
- });
+ if (!db)
+ return null;
for (i in db.contents) {
_data.FileSystem.createFile(db.contents[i].contentURI);
}
- return db;
+ return new ContentStorage(db.contents, db.directories);
}
self = {
module.exports = _self;
});
+define('ripple/platform/tizen/2.0/decorator', function (require, exports, module) {
+/*
+ * Copyright 2013 Intel Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var t = require('ripple/platform/tizen/2.0/typecast'),
+ ContactDecorator,
+ _self;
+
+ContactDecorator = function (contact, overlap) {
+ var raw = {};
+
+ // private
+ function clone(obj) {
+ return function () {
+ var Contact = require('ripple/platform/tizen/2.0/ContactBase'),
+ duplicate;
+
+ duplicate = new Contact(obj);
+
+ duplicate.__defineGetter__("id", function () {
+ return null;
+ });
+
+ duplicate.__defineGetter__("addressBookId", function () {
+ return null;
+ });
+
+ return duplicate;
+ };
+ }
+
+ // public
+ function convertToString(format) {
+ t.Contact("convertToString", arguments);
+
+ // TODO: Convert contact according to VCard protocal
+ return "";
+ }
+
+ raw.id = overlap ? overlap.id : null;
+ raw.personId = overlap ? overlap.personId : null;
+ raw.addressBookId = overlap ? overlap.addressBookId : null;
+ raw.lastUpdated = overlap ? overlap.lastUpdated : null;
+ raw.isFavorite = overlap ? overlap.isFavorite : false;
+
+ contact.__defineGetter__("id", function () {
+ return raw.id;
+ });
+
+ contact.__defineGetter__("personId", function () {
+ return raw.personId;
+ });
+
+ contact.__defineGetter__("addressBookId", function () {
+ return raw.addressBookId;
+ });
+
+ contact.__defineGetter__("lastUpdated", function () {
+ return raw.lastUpdated;
+ });
+
+ contact.__defineGetter__("isFavorite", function () {
+ return raw.isFavorite;
+ });
+
+ if (contact.name) {
+ contact.name.__defineGetter__("displayName", function () {
+ return ((overlap && overlap.name) ? overlap.name.displayName :
+ null);
+ });
+ }
+
+ contact.convertToString = convertToString;
+ contact.clone = clone(contact);
+};
+
+_self = {
+ Contact: ContactDecorator
+};
+
+module.exports = _self;
+
+});
define('ripple/platform/tizen/2.0/download', function (require, exports, module) {
/*
* Copyright 2012 Intel Corporation.
*/
var db = require('ripple/db'),
event = require('ripple/event'),
+ t = require('ripple/platform/tizen/2.0/typecast'),
errorcode = require('ripple/platform/tizen/2.0/errorcode'),
filesystem = require('ripple/platform/tizen/2.0/filesystem'),
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
DownloadItem, _isInitialized = false, INTERVAL = 1000,
_downloads = [], _resources = [], _self;
-function _checkDownloadParamters(download, callback) {
- if (!download || !download.url) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
- _checkDownloadCallback (callback);
-}
-
-function _checkDownloadCallback (callback) {
- var func = ['onprogress', 'onpaused', 'oncanceled',
- 'oncompleted', 'onfailed'];
-
- if (callback) {
- func.forEach(function (name) {
- if (callback.hasOwnProperty(name) &&
- typeof callback[name] !== 'function') {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
- });
- }
-}
-
function _initDownloadItem(download) {
var url, index, isExist = false;
url = download.url;
function _getDownloadObjById(id) {
var isFound = false, backObj;
- if (typeof id !== "number") {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
id = Number(id);
_downloads.some(function (obj) {
if (obj.id === id) {
}
});
if (!isFound) {
- throw new WebAPIError(errorcode.NOT_FOUND_ERR);
+ throw new WebAPIException(errorcode.NOT_FOUND_ERR);
}
return backObj;
}
_self = function () {
function start(downloadRequest, downloadCallback) {
+ var downloadObj, fileSize, increment, receivedSize = 0, intervalId;
if (!_security.all && !_security.start) {
- throw new WebAPIError(errorcode.SECURITY_ERR);
+ throw new WebAPIException(errorcode.SECURITY_ERR);
}
- var downloadObj, fileSize, increment, receivedSize = 0, intervalId;
+ if (!(downloadRequest instanceof tizen.DownloadRequest)) {
+ throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
+ }
+ t.DownloadManager("start", arguments);
- _checkDownloadParamters(downloadRequest, downloadCallback);
downloadObj = new DownloadItem(downloadRequest, downloadCallback);
_downloads.push(downloadObj);
downloadObj = _initDownloadItem(downloadObj);
}
function cancel(downloadId) {
- var downloadObj = _getDownloadObjById(downloadId);
+ var downloadObj;
+ t.DownloadManager("cancel", arguments);
+
+ downloadObj = _getDownloadObjById(downloadId);
clearInterval(downloadObj.intervalId);
if (downloadObj.state !== DownloadState.DOWNLOADING &&
downloadObj.state !== DownloadState.PAUSED) {
}
function pause(downloadId) {
- var downloadObj = _getDownloadObjById(downloadId);
+ var downloadObj;
+ t.DownloadManager("pause", arguments);
+
+ downloadObj = _getDownloadObjById(downloadId);
clearInterval(downloadObj.intervalId);
if (downloadObj.state !== DownloadState.DOWNLOADING) {
_exec(downloadObj.callback, 'onfailed', downloadObj.id, new WebAPIError(errorcode.INVALID_VALUES_ERR));
function resume(downloadId) {
var downloadObj, fileSize, receivedSize, increment, intervalId;
+ t.DownloadManager("resume", arguments);
downloadObj = _getDownloadObjById(downloadId);
fileSize = downloadObj.size;
}
function getState(downloadId) {
- var downloadObj = _getDownloadObjById(downloadId);
+ var downloadObj;
+ t.DownloadManager("getState", arguments);
+
+ downloadObj = _getDownloadObjById(downloadId);
return downloadObj.state;
}
function getDownloadRequest(downloadId) {
var req, downloadObj;
+ t.DownloadManager("getDownloadRequest", arguments);
+
downloadObj = _getDownloadObjById(downloadId);
req = new DownloadRequest(downloadObj.url, downloadObj.destination, downloadObj.fileName);
return req;
}
function getMIMEType(downloadId) {
- var downloadObj = _getDownloadObjById(downloadId);
+ var downloadObj;
+ t.DownloadManager("getMIMEType", arguments);
+
+ downloadObj = _getDownloadObjById(downloadId);
return downloadObj.MIMEType;
}
function setListener(downloadId, callback) {
- var downloadObj = _getDownloadObjById(downloadId);
+ var downloadObj;
+ t.DownloadManager("setListener", arguments);
+
+ downloadObj = _getDownloadObjById(downloadId);
if (downloadObj) {
- _checkDownloadCallback (callback);
downloadObj.callback = callback;
}
}
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- networkType = t.NetworkType(networkType);
- domainName = t.DOMString(domainName);
- successCallback = t.NetworkSuccessCallback(successCallback);
- errorCallback = t.ErrorCallback(errorCallback, "?");
-
+ t.NetworkBearerSelection("requestRouteToHost", arguments);
+
if (!domainName) {
if (errorCallback) {
errorCallback(new WebAPIError(errorcode.INVALID_VALUES_ERR));
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- networkType = t.NetworkType(networkType);
- domainName = t.DOMString(domainName);
- successCallback = t.SuccessCallback(successCallback);
- errorCallback = t.ErrorCallback(errorCallback, "?");
-
+ t.NetworkBearerSelection("releaseRouteToHost", arguments);
+
if (!domainName) {
if (errorCallback) {
errorCallback(new WebAPIError(errorcode.INVALID_VALUES_ERR));
var db = require('ripple/db'),
event = require('ripple/event'),
errorcode = require('ripple/platform/tizen/2.0/errorcode'),
+ t = require('ripple/platform/tizen/2.0/typecast'),
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
- tizen1_utils = require('ripple/platform/tizen/2.0/tizen1_utils'),
- NDEFRecord = require('ripple/platform/tizen/2.0/NDEFRecord'),
+ NDEFRecord = require('ripple/platform/tizen/2.0/NDEFRecordInternal'),
NDEFMessage = require('ripple/platform/tizen/2.0/NDEFMessage'),
- _NFC_TAG = "tizen1.0-nfc-tag",
- _NFC_PEER = "tizen1.0-nfc-peer",
- _NFC_OUTPUT_MESSAGE = "tizen1.0-nfc-output-message",
- NFCAdapter, NFCTag, NFCPeer,
- tag,
- peer,
- isPeerConnected = false,
+ NFCAdapter,
+ NFCAdapterPrototype,
+ NFCTag,
+ NFCPeer,
_data = {
+ DB_NFC_TAG : "tizen1.0-nfc-tag",
+ DB_NFC_PEER : "tizen1.0-nfc-peer",
+ DB_NFC_OUTPUT_MESSAGE : "tizen1.0-nfc-output-message",
INTERVAL : 1000,
listener : {
onCardEmulationChanged : null,
nfcTags : [],
nfcTag: {},
nfcPeer : {},
- isNear : false, // Identify the device is whether near
+ isNear : false, // Identify the device is whether near
isDetectTag : false, // Identify NFC tag is detected
+ isPeerConnected : false,
connectedState : false
},
_security = {
"http://tizen.org/privilege/nfc.admin": ["setPowered"],
- "http://tizen.org/privilege/nfc.common": ["getDefaultAdapter", "setExclusiveMode", "getCachedMessage"],
- "http://tizen.org/privilege/nfc.p2p": ["setPeerListener", "unsetPeerListener", "setReceiveNDEFListener", "unsetReceiveNDEFListener", "sendNDEF"],
- "http://tizen.org/privilege/nfc.tag": ["setTagListener", "unsetTagListener", "readNDEF", "writeNDEF", "transceive"]
+ "http://tizen.org/privilege/nfc.common": ["getDefaultAdapter",
+ "setExclusiveMode", "getCachedMessage"],
+ "http://tizen.org/privilege/nfc.p2p": ["setPeerListener",
+ "unsetPeerListener", "setReceiveNDEFListener",
+ "unsetReceiveNDEFListener", "sendNDEF"],
+ "http://tizen.org/privilege/nfc.tag": ["setTagListener",
+ "unsetTagListener", "readNDEF", "writeNDEF", "transceive"]
},
_self;
-//validate the type match
-function _validateCallbackType(onSuccess) {
- if (onSuccess &&
- typeof onSuccess !== "function" &&
- typeof onSuccess !== "object") {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
- tizen1_utils.validateArgumentType(onSuccess.onattach, "function",
- new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
- tizen1_utils.validateArgumentType(onSuccess.ondetach, "function",
- new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
-}
-
_self = function () {
var nfc, _exclusiveMode = false;
+
function getDefaultAdapter() {
if (!_security.getDefaultAdapter) {
throw new WebAPIError(errorcode.SECURITY_ERR);
}
- if (arguments.length > 0) {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
+
+ t.NFCManager("getDefaultAdapter", arguments);
if (!_data.nfcAdapter) {
throw new WebAPIError(errorcode.UNKNOWN_ERR);
throw new WebAPIError(errorcode.SECURITY_ERR);
}
- if (typeof mode !== "boolean") {
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
+ t.NFCManager("setExclusiveMode", arguments);
+
_exclusiveMode = mode;
jQuery("#NFCExclusiveModeValue").text(_exclusiveMode);
}
return nfc;
};
-
-NFCAdapter = function () {
- var nfcAdapter,
+NFCAdapterPrototype = function () {
+ var nfcAdapterPrototype,
interval,
powered = false, // Identify the device on or off
- polling = false, // Identify the device is polled
- seType = "NONE"; // Identify card emulation type
-
+ polling = false; // Identify the device is polled
+
event.trigger("nfc-power-changed", [powered]);
event.on("nfc-power-setting", function (status) {
- _updatePowerStatus(status);
+ updatePowerStatus(status);
});
event.on("nfc-attach-setting", function (type, isAttached) {
var isDetectTag;
- isDetectTag = type === "Tag" ? true : false;
- _updateIsNear(isDetectTag, isAttached);
+
+ isDetectTag = (type === "Tag");
+ updateIsNear(isDetectTag, isAttached);
});
event.on("nfc-tag-send", function (status) {
+ var tag;
+
if (status) {
- tag = db.retrieveObject(_NFC_TAG);
+ tag = db.retrieveObject(_data.DB_NFC_TAG);
if (tag.isSupportedNDEF) {
- _data.nfcTag = new NFCTag(tag.type, tag.isSupportedNDEF, tag.ndefSize, null, true, tag.ndefs);
+ _data.nfcTag = new NFCTag(tag.type, tag.isSupportedNDEF,
+ tag.ndefSize, null, true, tag.ndefs);
} else {
- _data.nfcTag = new NFCTag(tag.type, tag.isSupportedNDEF, tag.ndefSize, null, true, tag.rawData);
+ _data.nfcTag = new NFCTag(tag.type, tag.isSupportedNDEF,
+ tag.ndefSize, null, true, tag.rawData);
}
if (_data.listener.onTagDetected) {
_data.listener.onTagDetected.onattach(_data.nfcTag);
if (_data.listener.onPeerDetected) {
_data.listener.onPeerDetected.onattach(_data.nfcPeer);
}
- isPeerConnected = true;
+ _data.isPeerConnected = true;
} else {
if (_data.listener.onPeerDetected) {
_data.listener.onPeerDetected.ondetach();
}
- isPeerConnected = false;
+ _data.isPeerConnected = false;
}
});
event.on("nfc-peer-sending-ndef", function () {
- var _records = [], rec, _ndef, i;
- if (isPeerConnected) {
- peer = db.retrieveObject(_NFC_PEER);
+ var peer, _records = [], rec, _ndef, i;
+
+ if (_data.isPeerConnected) {
+ peer = db.retrieveObject(_data.DB_NFC_PEER);
for (i in peer.ndef.records) {
rec = peer.ndef.records[i];
- _records.push(new NDEFRecord(rec.tnf, rec.type, rec.payload, rec.id));
+ _records.push(new NDEFRecord(rec.tnf, rec.type, rec.payload,
+ rec.id));
}
_ndef = new NDEFMessage(_records);
if (_data.listener.onNDEFReceived) {
});
// private
- function _updatePowerStatus(status) {
+ function updatePowerStatus(status) {
if (powered === status) {
return;
}
if (!status) {
- _updateIsNear(_data.isDetectTag, false);
+ updateIsNear(_data.isDetectTag, false);
_data.listener.onTagDetected = null;
_data.listener.onPeerDetected = null;
_data.listener.onNDEFReceived = null;
_data.listener.onCardEmulationChanged = null;
}
powered = status;
- _updatePollingStatus(status);
+ updatePollingStatus(status);
event.trigger("nfc-power-changed", [powered]);
}
- function _updatePollingStatus(status) {
+
+ function updatePollingStatus(status) {
if (!powered)
return;
if (polling === status) {
clearInterval(interval);
}
}
- function _updateIsNear(isDetectTag, isAttached) {
+
+ function updateIsNear(isDetectTag, isAttached) {
_data.isDetectTag = isDetectTag;
_data.isNear = isAttached;
if (!_data.isNear) {
event.trigger("nfc-connectedState-changed", [false]);
}
}
+
function poll() {
if (!_data.isNear) {
return;
if (!_data.connectedState) {
_data.connectedState = true;
event.trigger("nfc-connectedState-changed", [true]);
-
}
}
throw new WebAPIError(errorcode.SECURITY_ERR);
}
- tizen1_utils.validateArgumentType(state, "boolean",
- new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
-
- tizen1_utils.validateCallbackType(successCallback, errorCallback);
+ t.NFCAdapter("setPowered", arguments);
- _updatePowerStatus(state);
+ updatePowerStatus(state);
if (successCallback) {
successCallback();
}
}
-/*
- function setCardEmulation(_seType, successCallback, errorCallback) {
- var originalType;
- if (!_security.all && !_security.setCardEmulation) {
- throw new WebAPIError(errorcode.SECURITY_ERR);
- }
- tizen1_utils.validateCallbackType(successCallback, errorCallback);
-
- switch (_seType) {
- case "NONE":
- case "UICC":
- break;
- default:
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- }
-
- if (!powered) {
- return;
- }
-
- originalType = seType;
- seType = _seType;
-
- if (_data.listener.onCardEmulationChanged && originalType !== seType) {
- _data.listener.onCardEmulationChanged(seType);
- }
- if (successCallback) {
- successCallback();
- }
- }
- function setCardEmulationChangeListener(changeCallback) {
- if (!_security.all && !_security.setCardEmulationChangeListener) {
- throw new WebAPIError(errorcode.SECURITY_ERR);
- }
- tizen1_utils.validateArgumentType(changeCallback, "function",
- new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
- if (!powered) {
- return;
- }
- _data.listener.onCardEmulationChanged = changeCallback;
- }
-
- function unsetCardEmulationChangeListener() {
- if (!_security.all && !_security.unsetCardEmulationChangeListener) {
- throw new WebAPIError(errorcode.SECURITY_ERR);
- }
- if (!powered || !_data.listener.onCardEmulationChanged) {
- return;
- }
-
- _data.listener.onCardEmulationChanged = null;
- }
-*/
// Registers a callback function to invoke when NFC tag is detected.
function setTagListener(detectCallback, tagFilter) {
throw new WebAPIError(errorcode.SECURITY_ERR);
}
- _validateCallbackType(detectCallback);
+ t.NFCAdapter("setTagListener", arguments);
- if (tagFilter) {
- tizen1_utils.validateArgumentType(tagFilter, "array",
- new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
- }
//TODO: tagFilter support
if (!powered) {
return;
throw new WebAPIError(errorcode.SECURITY_ERR);
}
- _validateCallbackType(detectCallback);
+ t.NFCAdapter("setPeerListener", arguments);
if (!powered) {
return;
throw new WebAPIError(errorcode.SECURITY_ERR);
}
+ t.NFCAdapter("getCachedMessage", arguments);
+
return _data.pairedNFC || new NDEFMessage([]);
}
- nfcAdapter = {
+ nfcAdapterPrototype = {
setPowered : setPowered,
- //setCardEmulation: setCardEmulation,
- //setCardEmulationChangeListener: setCardEmulationChangeListener,
- //unsetCardEmulationChangeListener: unsetCardEmulationChangeListener,
setTagListener : setTagListener,
setPeerListener : setPeerListener,
unsetTagListener : unsetTagListener,
getCachedMessage : getCachedMessage
};
- nfcAdapter.__defineGetter__("powered", function () {
+ nfcAdapterPrototype.__defineGetter__("powered", function () {
return powered;
});
- nfcAdapter.__defineGetter__("seType", function () {
- return seType;
- });
+ return nfcAdapterPrototype;
+};
- return nfcAdapter;
+NFCAdapter = function () {
+ this.__defineGetter__("powered", function () {
+ return this.__proto__.powered;
+ });
};
+NFCAdapter.prototype = new NFCAdapterPrototype();
+
NFCTag = function (type, isSupportedNDEF, ndefSize, properties, isConnected, ndefs) {
- var nfcTag, i, j,
- _ndefs,
- rec,
- _records,
- _ndefs_index = 0;
-
+ var nfcTag, i, j, _ndefs, rec, _records, _ndefs_index = 0;
+
type = type || null;
isSupportedNDEF = isSupportedNDEF || false;
ndefSize = ndefSize || 1;
_records = [];
for (j in ndefs[i].records) {
rec = ndefs[i].records[j];
- _records.push(new NDEFRecord(rec.tnf, rec.type, rec.payload, rec.id));
+ _records.push(new NDEFRecord(rec.tnf, rec.type, rec.payload,
+ rec.id));
}
_ndefs.push(new NDEFMessage(_records));
}
if (!_security.readNDEF) {
throw new WebAPIError(errorcode.SECURITY_ERR);
}
- function _readNDEF() {
- if (!isConnected || !isSupportedNDEF) {
- if (errorCallback) {
- errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
- }
- return;
- }
- if (_ndefs_index >= ndefSize) {
+
+ t.NFCTag("readNDEF", arguments);
+
+ if (!isConnected || !isSupportedNDEF) {
+ if (errorCallback) {
errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
- } else {
- _data.pairedNFC = _ndefs[_ndefs_index];
- readCallback(_ndefs[_ndefs_index]);
- _ndefs_index++;
}
+ return;
+ }
+ if (_ndefs_index >= ndefSize) {
+ errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
+ } else {
+ _data.pairedNFC = _ndefs[_ndefs_index];
+ readCallback(_ndefs[_ndefs_index]);
+ _ndefs_index++;
}
-
- tizen1_utils.validateTypeMismatch(readCallback, errorCallback, "nfc:readNDEF", _readNDEF);
}
// Writes NDEF data.
throw new WebAPIError(errorcode.SECURITY_ERR);
}
- tizen1_utils.validateCallbackType(successCallback, errorCallback);
-
- tizen1_utils.validateArgumentType(ndefMessage, "object",
- new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
+ t.NFCTag("writeNDEF", arguments);
if (!isConnected || !isSupportedNDEF) {
if (errorCallback) {
}
return;
}
- db.saveObject(_NFC_OUTPUT_MESSAGE, ndefMessage);
+ db.saveObject(_data.DB_NFC_OUTPUT_MESSAGE, ndefMessage);
event.trigger("nfc-output-msg", []);
if (successCallback) {
successCallback();
if (!_security.transceive) {
throw new WebAPIError(errorcode.SECURITY_ERR);
}
- function _transceive() {
- if (!tizen1_utils.isValidArray(data))
- throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
- if (!isConnected || isSupportedNDEF) {
- if (errorCallback) {
- errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
- }
- return;
+ t.NFCTag("transceive", arguments);
+
+ if (!isConnected || isSupportedNDEF) {
+ if (errorCallback) {
+ errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
}
- db.saveObject(_NFC_OUTPUT_MESSAGE, data);
- event.trigger("nfc-output-msg", []);
- dataCallback(ndefs);
+ return;
}
-
- tizen1_utils.validateTypeMismatch(dataCallback, errorCallback, "nfc:transceive", _transceive);
+ db.saveObject(_data.DB_NFC_OUTPUT_MESSAGE, data);
+ event.trigger("nfc-output-msg", []);
+ dataCallback(ndefs);
}
// Formats the detected tag that can store NDEF messages.
nfcTag = {
readNDEF : readNDEF,
writeNDEF : writeNDEF,
- transceive : transceive,
+ transceive : transceive
//formatNDEF : formatNDEF
};
isConnected = isConnected || false;
// Registers a callback function to be invoked when NDEF message is received from NFC peer-to-peer target connected.
- function setReceiveNDEFListener(successCallback, errorCallback) {
+ function setReceiveNDEFListener(successCallback) {
if (!_security.setReceiveNDEFListener) {
throw new WebAPIError(errorcode.SECURITY_ERR);
}
- function _setReceiveNDEFListener() {
- if (!isConnected) {
- if (errorCallback) {
- errorCallback(new WebAPIError(errorcode.UNKNOWN_ERR));
- }
- return;
- }
- _data.listener.onNDEFReceived = successCallback;
- }
- tizen1_utils.validateTypeMismatch(successCallback, errorCallback, "nfc:setReceiveNDEFListener", _setReceiveNDEFListener);
+ t.NFCPeer("setReceiveNDEFListener", arguments);
+
+ if (!isConnected) {
+ return;
+ }
+ _data.listener.onNDEFReceived = successCallback;
}
// Unregisters the listener for receiving NDEFMessage from NFC peer-to-peer target connected.
throw new WebAPIError(errorcode.SECURITY_ERR);
}
- tizen1_utils.validateCallbackType(successCallback, errorCallback);
-
- tizen1_utils.validateArgumentType(ndefMessage, "object",
- new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
+ t.NFCPeer("sendNDEF", arguments);
if (!isConnected) {
if (errorCallback) {
return;
}
- db.saveObject(_NFC_OUTPUT_MESSAGE, ndefMessage);
+ db.saveObject(_data.DB_NFC_OUTPUT_MESSAGE, ndefMessage);
event.trigger("nfc-output-msg", []);
if (successCallback) {
successCallback();
function _initialize() {
_data.nfcAdapter = new NFCAdapter();
}
+
_initialize();
module.exports = _self;
-
});
define('ripple/platform/tizen/2.0/notification', function (require, exports, module) {
/*
event = require('ripple/event'),
errorcode = require('ripple/platform/tizen/2.0/errorcode'),
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
+ StatusNotification = require('ripple/platform/tizen/2.0/StatusNotification'),
+ t = require('ripple/platform/tizen/2.0/typecast'),
_notificationStack,
_security = {
"http://tizen.org/privilege/notification": ["post", "update", "remove", "removeAll"]
},
_self;
-function _validateNotification(notification) {
- if (typeof notification !== "object") {
- return false;
- }
-
- if (typeof notification.id !== "string") {
- return false;
- }
-
- if (typeof notification.type !== "string" || notification.type !== "STATUS") {
- return false;
- }
-
- if (typeof notification.title !== "string") {
- return false;
- }
-
- if (notification.content && typeof notification.content !== "string") {
- return false;
- }
-
- return true;
-}
-
_self = function () {
function post(notification) {
+ var _id;
if (!_security.post) {
throw new WebAPIError(errorcode.SECURITY_ERR);
}
- if (!_validateNotification(notification)) {
- throw (new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
+
+ t.NotificationManager("post", arguments);
+
+ if (notification.id !== undefined) {
+ return;
}
+ _id = Math.uuid(null, 16);
+ Object.defineProperty(notification, "id", {value: _id, writable: false});
- if (notification.statusType === "PROGRESS" && notification.progressValue &&
+ if (notification.statusType === "PROGRESS" &&
+ notification.progressType === "PERCENTAGE" &&
+ notification.progressValue &&
(notification.progressValue < 1 || notification.progressValue > 100)) {
throw new WebAPIError(errorcode.INVALID_VALUES_ERR);
}
if (!_notificationStack[notification.id]) {
- Object.defineProperty(notification, "postedTime", {value: new Date().toString(), writable: false});
+ Object.defineProperty(notification, "postedTime", {value: new Date(), writable: false});
_notificationStack[notification.id] = utils.copy(notification);
db.saveObject("posted-notifications", _notificationStack);
event.trigger("refreshNotificationUI", [], true);
if (!_security.update) {
throw new WebAPIError(errorcode.SECURITY_ERR);
}
- if (!_validateNotification(notification)) {
- throw (new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
+
+ t.NotificationManager("update", arguments);
+
+ if (typeof notification.id !== "string") {
+ throw new WebAPIError(errorcode.UNKNOWN_ERR);
}
- if (notification.statusType === "PROGRESS" && notification.progressValue &&
+ if (notification.statusType === "PROGRESS" &&
+ notification.progressType === "PERCENTAGE" &&
+ notification.progressValue &&
(notification.progressValue < 1 || notification.progressValue > 100)) {
throw new WebAPIError(errorcode.INVALID_VALUES_ERR);
}
_notificationStack[notification.id] = utils.copy(notification);
db.saveObject("posted-notifications", _notificationStack);
event.trigger("refreshNotificationUI", [], true);
+ } else {
+ throw new WebAPIError(errorcode.UNKNOWN_ERR);
}
}
if (!_security.remove) {
throw new WebAPIError(errorcode.SECURITY_ERR);
}
- if (typeof id !== "string") {
- throw (new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
- }
if (!_notificationStack[id]) {
throw (new WebAPIError(errorcode.NOT_FOUND_ERR));
if (!_security.removeAll) {
throw new WebAPIError(errorcode.SECURITY_ERR);
}
+
+ t.NotificationManager("removeAll", arguments);
+
_notificationStack = {};
db.saveObject("posted-notifications", _notificationStack);
event.trigger('refreshNotificationUI', [], true);
}
function get(id) {
- if (typeof id !== "string") {
- throw (new WebAPIError(errorcode.TYPE_MISMATCH_ERR));
- }
+ var n, ret;
if (!_notificationStack[id]) {
throw (new WebAPIError(errorcode.NOT_FOUND_ERR));
}
+ n = _notificationStack[id];
+ ret = new StatusNotification(n.statusType, n.title, n);
+ Object.defineProperty(ret, "id", {value: n.id, writable: false});
+ Object.defineProperty(ret, "postedTime", {value: new Date(n.postedTime), writable: false});
- return utils.copy(_notificationStack[id]);
+ return ret;
}
function getAll() {
- var notifications = [];
- utils.forEach(_notificationStack, function (item) {
- notifications.push(utils.copy(item));
- });
+ var notifications = [], ret;
+
+ t.NotificationManager("getAll", arguments);
+
+ utils.forEach(_notificationStack, function (n) {
+ ret = new StatusNotification(n.statusType, n.title, n);
+ Object.defineProperty(ret, "id", {value: n.id, writable: false});
+ Object.defineProperty(ret, "postedTime", {value: new Date(n.postedTime), writable: false});
+
+ notifications.push(ret);
+ }, this);
return notifications;
}
* limitations under the License.
*/
var db = require('ripple/db'),
+ app = require('ripple/app'),
event = require('ripple/event'),
utils = require('ripple/utils'),
errorcode = require('ripple/platform/tizen/2.0/errorcode'),
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
WebAPIException = require('ripple/platform/tizen/2.0/WebAPIException'),
- TypeCoerce = require('ripple/platform/tizen/2.0/typecoerce'),
PackageInformation = require('ripple/platform/tizen/2.0/PackageInformation'),
- t = require('ripple/platform/tizen/2.0/typedef'),
+ t = require('ripple/platform/tizen/2.0/typecast'),
_security = {
"http://tizen.org/privilege/packagemanager.install": ["install", "uninstall"],
"http://tizen.org/privilege/package.info": ["getPackagesInfo", "getPackageInfo",
},
INTERVAL = 1000, // INTERVAL = 1sec
INSTALL_AMOUNT = 3072, // installation speed amount = 3072 (KB/sec)
+ PSEUDO_PACKAGE_ID = "pseudopack00",
+ PSEUDO_APP_ID = "pseudoapp00",
_self;
+function _setupCurrentPackage() {
+ var info, id, item, tizenAppId;
+ info = app.getInfo();
+ tizenAppId = info.tizenAppId || PSEUDO_APP_ID;
+ id = info.tizenPackageId;
+ if (id !== undefined) {
+ if (_data.installedList[id]) {
+ // already installed
+ return;
+ }
+
+ item = null;
+ utils.forEach(_data.packageList, function (p) {
+ if (p.id === id) {
+ item = p;
+ }
+ });
+
+ if (item) {
+ _data.installedList[item.id] = new PackageInformation(
+ item.id, item.name, item.iconPath, item.version,
+ item.totalSize, item.dataSize, new Date(),
+ item.author, item.description, item.appIds
+ );
+ event.trigger("install-current-package", [_data.installedList[item.id]]);
+ } else {
+ _data.installedList[id] = new PackageInformation(
+ id, "Tizen pseudo package", "icon.png", "2.2",
+ 8264, 50, new Date(),
+ "TizenDev", "This is a description which is used in tests.", [tizenAppId]
+ );
+ event.trigger("install-current-package", [_data.installedList[id]]);
+ }
+ } else {
+ _data.installedList[PSEUDO_PACKAGE_ID] = new PackageInformation(
+ PSEUDO_PACKAGE_ID, "Tizen pseudo package", "icon.png", "2.2",
+ 8264, 50, new Date(),
+ "TizenDev", "This is a description which is used in tests.", [tizenAppId]
+ );
+ event.trigger("install-current-package", [_data.installedList[PSEUDO_PACKAGE_ID]]);
+ }
+}
+
function _get() {
_data = db.retrieveObject(DB_PACKAGE_KEY);
+ if (!_data)
+ return;
utils.forEach(_data.installedList, function (item) {
item.lastModified = new Date(item.lastModified);
});
if (!_security.install) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- if (!(new TypeCoerce(t.DOMString)).match(path) ||
- !(new TypeCoerce(t.PackageProgressCallback)).match(progressCallback) ||
- (errorCallback && !(new TypeCoerce(t.ErrorCallback)).match(errorCallback))) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
+
+ t.PackageManager("install", arguments);
+
if (!_data.packageList[path]) {
if (errorCallback) {
errorCallback(new WebAPIError(errorcode.NOT_FOUND_ERR));
if (!_security.uninstall) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- if (!(new TypeCoerce(t.PackageId)).match(id) ||
- !(new TypeCoerce(t.PackageProgressCallback)).match(progressCallback) ||
- (errorCallback && !(new TypeCoerce(t.ErrorCallback)).match(errorCallback))) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
+
+ t.PackageManager("uninstall", arguments);
+
if (!_data.installedList[id]) {
if (errorCallback) {
errorCallback(new WebAPIError(errorcode.NOT_FOUND_ERR));
if (!_security.getPackagesInfo) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- if (!(new TypeCoerce(t.PackageInformationArraySuccessCallback)).match(successCallback) ||
- (errorCallback && !(new TypeCoerce(t.ErrorCallback)).match(errorCallback))) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
+
+ t.PackageManager("getPackagesInfo", arguments);
+
utils.forEach(_data.installedList, function (item) {
var i;
i = new PackageInformation(
id = "api1pack00";
}
- if (!(new TypeCoerce(t.PackageId)).match(id)) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
+ t.PackageManager("getPackageInfo", arguments);
+
if (!_data.installedList[id]) {
throw new WebAPIException(errorcode.NOT_FOUND_ERR);
}
if (!_security.setPackageInfoEventListener) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- if (!(new TypeCoerce(t.PackageInfomationEventCallback)).match(eventCallback)) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
+
+ t.PackageManager("setPackageInfoEventListener", arguments);
+
_listeners.push(eventCallback);
}
if (!_security.unsetPackageInfoEventListener) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
+
+ t.PackageManager("unsetPackageInfoEventListener", arguments);
+
_listeners = [];
}
function _initialize() {
_get();
+ if (!_data)
+ return;
+ _setupCurrentPackage();
}
_initialize();
module.exports = _self;
-
});
define('ripple/platform/tizen/2.0/pendingObject', function (require, exports, module) {
/*
var event = require('ripple/event'),
errorcode = require('ripple/platform/tizen/2.0/errorcode'),
- t = require('ripple/platform/tizen/2.0/typedef'),
+ t = require('ripple/platform/tizen/2.0/typecast'),
Notification = require('ripple/platform/tizen/2.0/notification'),
StatusNotification = require('ripple/platform/tizen/2.0/StatusNotification'),
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
if (!_security.registerService) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- if (!(new TypeCoerce(t.ApplicationControl)).match(appControl) ||
- !(new TypeCoerce(t.PushRegisterSuccessCallback)).match(successCallback) ||
- (errorCallback && !(new TypeCoerce(t.ErrorCallback)).match(errorCallback))) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
+
+ t.PushManager("registerService", arguments);
appId = _getCurrentApplicationId();
appService = {
if (!_security.unregisterService) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- if ((successCallback && !(new TypeCoerce(t.SuccessCallback)).match(successCallback)) ||
- (errorCallback && !(new TypeCoerce(t.ErrorCallback)).match(errorCallback))) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
+
+ t.PushManager("unregisterService", arguments);
appId = _getCurrentApplicationId();
delete _data.service[appId];
if (!_security.connectService) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
- if (!(new TypeCoerce(t.PushNotificationCallback)).match(notificationCallback)) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
+
+ t.PushManager("connectService", arguments);
appId = _getCurrentApplicationId();
appService = _data.service[appId];
throw new WebAPIException(errorcode.SECURITY_ERR);
}
+ t.PushManager("disconnectService", arguments);
+
appId = _getCurrentApplicationId();
appService = _data.service[appId];
if (!appService || !appService.isRegistered) {
throw new WebAPIException(errorcode.SECURITY_ERR);
}
+ t.PushManager("getRegistrationId", arguments);
+
appService = _data.service[_getCurrentApplicationId()];
if (!appService || !appService.isRegistered) {
return null;
widgetInfo.name = configValidationObject.widget.children.name.validationResult[0].value;
widgetInfo.icon = configValidationObject.widget.children.icon.validationResult[0].attributes.src.value;
widgetInfo.version = configValidationObject.widget.validationResult[0].attributes.version.value;
+ if (configValidationObject.widget.children.application.validationResult[0].valid) {
+ widgetInfo.tizenAppId = configValidationObject.widget.children.application.validationResult[0].attributes.id.value;
+ widgetInfo.tizenPackageId = configValidationObject.widget.children.application.validationResult[0].attributes.package.value;
+ }
widgetInfo.features = {};
"value": "PORTRAIT_PRIMARY"
},
"event": "LayoutChanged"
+ },
+ "isAutoRotation": {
+ "name": "Is Auto Rotation",
+ "control": {
+ "type": "label",
+ "value": false
+ }
}
},
"CPU": {
}())
},
"capacity": {
- "name": "Capacity",
+ "name": "Capacity(bytes)",
"control": {
"type": "label",
"value": 16000000000
},
},
"availableCapacity": {
- "name": "AvailableCapacity",
+ "name": "AvailableCapacity(bytes)",
"control": {
"type": "number",
"value": 12000000000
"innertext": "Tizen",
"value": "Tizen"
}
+ },
+ "buildVersion": {
+ "name": "Build Version",
+ "control": {
+ "type": "label",
+ "innertext": "TIZEN_WEB_SIMULATOR_000001",
+ "value": "TIZEN_WEB_SIMULATOR_000001"
+ }
}
},
"LOCALE": {
},
"DISPLAY": {
"resolutionWidth": {
- "name": "Resolution Width",
+ "name": "Resolution Width(pixels)",
"control": {
"type": "label",
"value": 0
}
},
"resolutionHeight": {
- "name": "Resolution Height",
+ "name": "Resolution Height(pixels)",
"control": {
"type": "label",
"value": 0
}
},
"physicalWidth": {
- "name": "Physical Width",
+ "name": "Physical Width(millimeters)",
"control": {
"type": "label",
"value": 0
}
},
"physicalHeight": {
- "name": "Physical Height",
+ "name": "Physical Height(millimeters)",
"control": {
"type": "label",
"value": 0
_propertyMap = {}, // Object like: {"BATTERY": ["level", "isCharging"], ...}
_batteryEvent = ["BatteryLevelChanged", "BatteryChargingChanged"],
_watches = {},
+ _firstCall_watches = {},
_powerData = {},
_security = {
"http://tizen.org/privilege/system": ["SystemInfoSIM", "webApiVersion", "nativeApiVersion", "platformVersion"],
_self.__defineGetter__("inputKeyMenu", function () {
return true;
});
+ _self.__defineGetter__("profile", function () {
+ return "MOBILE_WEB";
+ });
return _self;
}
setTimeout(_getValue(propertyId, successCallback, errorCallback), 1); // Simulate a async operation
- return null;
});
}
};
return tizen_utils.validateTypeMismatch(successCallback, null, "addPropertyValueChangeListener", function () {
- var watchId = (new Date()).getTime(),
+ var watchId = Number(Math.uuid(8, 10)),
_options = new Object(options),
- properties, property, index = 0, deviceEventType, watchObj;
+ properties, property, index = 0, deviceEventType, watchObj, firstCallWatchObj;
// A listener will listen all the properties of one aspect, each of the property
// will have an internal watchObj to record the information.
}
}
- setTimeout(function () {
+ firstCallWatchObj = setTimeout(function () {
_getValue(propertyId, successCallback, null);
+ delete(_firstCall_watches[watchId]);
}, 1);
+ _firstCall_watches[watchId] = firstCallWatchObj;
return watchId;
});
}
}
delete(_watches[_handler]);
}
- return null;
+
+ if (_firstCall_watches[_handler]) {
+ clearTimeout(_firstCall_watches[_handler]);
+ delete(_firstCall_watches[_handler]);
+ }
}
function handleSubFeatures(subFeatures) {
db = require('ripple/db'),
tz = require('ripple/platform/tizen/2.0/timezone_info'),
_timeFormat = "h:m:s ap", _shortDateFormat = "d/m/y",
- _longDateFormat = "D, M d y", _self;
+ _longDateFormat = "D, M d, y", _self;
_self = {
getCurrentDateTime: function () {
"Asia/Bangkok": {diff: 7, abbr: "ICT"},
"Asia/Beirut": {diff: 2, abbr: "EET"},
"Asia/Chungking": {diff: 8, abbr: "CST"},
- "Asia/Dubai": {diff: 4, abbr: "GST"},
+ "Asia/Dubai": {diff: 4, abbr: "GST", desc:"GMT\+0400 United Arab Emirates Time"},
"Asia/Harbin": {diff: 8, abbr: "CST"},
"Asia/Ho_Chi_Minh": {diff: 7, abbr: "IST"},
"Asia/Hong_Kong": {diff: 8, abbr: "HKT"},
"Asia/Pyongyang": {diff: 9, abbr: "KST"},
"Asia/Qatar": {diff: 3, abbr: "AST"},
"Asia/Saigon": {diff: 7, abbr: "ICT"},
- "Asia/Seoul": {diff: 9, abbr: "KST"},
+ "Asia/Seoul": {diff: 9, abbr: "KST", desc:"GMT+0900 South Korea Time"},
"Asia/Shanghai": {diff: 8, abbr: "CST"},
"Asia/Singapore": {diff: 8, abbr: "SGT"},
"Asia/Taipei": {diff: 8, abbr: "CST"},
getTimezoneAbbr: function (zone) {
return _timezone_data[zone].abbr;
},
+ getTimezoneDesc: function (zone) {
+ if (_timezone_data[zone].desc) {
+ return _timezone_data[zone].desc;
+ } else {
+ return null;
+ }
+ },
isValidTimezone: function (zone) {
return (_timezone_data[zone] === undefined) ? false : true;
}
return !isNaN(d.getTime());
},
isValidTZDate: function (d) {
- if (Object.prototype.toString.call(d) !== "[object Object]")
- return false;
- return d.getTimezone && !isNaN(d.getDate());//getTimezone() belongs to TZDate
+ if (d && (d instanceof tizen.TZDate)) {
+ return true;
+ }
+ return false;
},
isValidArray: function (a) {
return (Object.prototype.toString.call(a) === "[object Array]");
if (atr.length === 2) {
_booleanMatch = function (obj, index) {
+ if (!obj[atr[0]])
+ return false;
+
return (obj[atr[0]][atr[1]] === value);
};
} else {
if (atr.length === 2) {
_existMatch = function (obj, index) {
+ if (!obj[atr[0]])
+ return false;
+
return (obj[atr[0]][atr[1]] !== undefined);
};
} else {
if (atr.length === 2) {
_arrayMatch = function (obj, index) {
+ if (!obj[atr[0]])
+ return false;
+
return (obj[atr[0]][atr[1]] && obj[atr[0]][atr[1]].some(function (o) {
return (o.search(_re) !== -1);
}));
if (atr.length === 2) {
_rangeMatch = function (obj, index) {
var matched = true;
+
+ if (!obj[atr[0]])
+ return false;
+
if (low !== null && low !== undefined) {
matched = (obj[atr[0]][atr[1]] >= low);
}
} else {
_rangeMatch = function (obj, index) {
var matched = true;
+
if (low !== null && low !== undefined) {
matched = (obj[attr] >= low);
}
if (atr.length === 2) {
_existMatch = function (obj, index) {
+ if (!obj[atr[0]])
+ return false;
+
return (obj[atr[0]][atr[1]] !== undefined);
};
} else {
}
if (atr.length === 2) {
_stringMatch = function (obj, index) {
+ if (!obj[atr[0]])
+ return false;
+
if (matchFlag === "EXACTLY") {
return (obj[atr[0]][atr[1]] === value);
} else if (typeof obj[atr[0]][atr[1]] !== 'string') {
errorcode = require('ripple/platform/tizen/2.0/errorcode'),
WebAPIException = require('ripple/platform/tizen/2.0/WebAPIException'),
TypeCoerce = require('ripple/platform/tizen/2.0/typecoerce'),
- _self;
+ _self = {};
+
+function _cast(pattern, obj, isDuplicate) {
+ var tc, tcFunc;
+
+ if (pattern === null)
+ return;
-function cast(pattern) {
+ tc = new TypeCoerce(pattern);
+ tcFunc = isDuplicate ? tc.copy : tc.cast;
+
+ if (tcFunc(obj) === null) {
+ throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
+ }
+}
+
+function _castType(pattern) {
/*
* Type cast for each known type. The function name is the exact name of the
* corresponding type.
* strings, or ignored in most cases.
*
* "?" Nullable types
- * "[]" Arrays
- *
- * arbitrary
- * A boolean parameter, which indicates that whether obj requires to be
- * verified. It can be ignored in most cases.
- *
- * true Indicates obj may contain invalid values
- * false Indicates obj must be verified constrainedly
+ * "[]" Array
*
* Return
* Casted object.
*/
- return function (obj, aux, arbitrary) {
+ return function (obj, aux) {
var tc, isNullable;
aux = aux ? String(aux) : "";
tc = new TypeCoerce((aux.indexOf("[]") !== -1) ? [pattern] : pattern);
isNullable = (aux.indexOf("?") !== -1);
- if ((isNullable && obj) || !isNullable) {
- if ((obj = tc.cast(obj)) === null) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
+ if (isNullable && !obj) {
+ return null;
}
- if (!arbitrary) {
- if (((isNullable && obj) || !isNullable) && !tc.validate(obj)) {
- throw new WebAPIException(errorcode.INVALID_VALUES_ERR);
+ if ((isNullable && obj) || !isNullable) {
+ if ((obj = tc.copy(obj)) === null) {
+ throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
}
}
};
}
-function castArgs(pattern) {
+function _castConstructor(name) {
+ var constructors, hook, vtc, isOverloaded, castConstructor;
+
/*
- * Type cast for each known method of interface. The function name is the
- * exact name of the corresponding interface.
+ * Type cast for constructor. The function name is the exact name of the
+ * object type.
*
- * method
- * String of method name
+ * argv
+ * arguments. The keyword 'arguments' will always be passed in.
+ */
+
+ function castUnique(argv) {
+ _cast(constructors, argv, false);
+ }
+
+ /*
+ * Type cast for overloaded constructors. The function name is the exact
+ * name of the object type.
*
* argv
- * arguments. The keyword 'arguments' will be always passed in.
+ * arguments. The keyword 'arguments' will always be passed in.
+ *
+ * scope
+ * 'this' of the original constructor.
+ *
+ * voc
+ * Array of overloaded constructors callback
*/
- return function (method, argv) {
- var argvType, argvTypeLength, argc, i, tc, isNullable;
+ function castOverload(argv, scope, voc) {
+ var iOverload;
- argvType = pattern[method];
+ if (!vtc) {
+ vtc = [];
+ constructors.forEach(function (c) {
+ vtc.push((c === null) ? null : new TypeCoerce(c));
+ });
+ }
- if (argvType === null)
- return;
+ vtc.some(function (tc, index) {
+ if (tc && (tc.cast(argv) === null))
+ return false;
- argvTypeLength = argv.callee.length;
- argc = (argv.length < argvTypeLength) ? argv.length : argvTypeLength;
+ iOverload = index;
+ return true;
+ });
- for (i = 0; i < argvTypeLength; ++i) {
- isNullable = !!(argvType._optional && argvType._optional[i]);
+ if (iOverload === undefined) {
+ throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
+ }
- if (i > argc - 1) {
- if (!isNullable) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
- argv[i] = null;
- continue;
- }
+ return (voc && voc[iOverload].apply(scope, argv));
+ }
- tc = new TypeCoerce(argvType[i]);
+ constructors = typedef.constructor[name];
- if ((argv[i] === null) || (argv[i] === undefined)) {
- if (!isNullable || (argv[i] !== null)) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
- } else if ((argv[i] = tc.cast(argv[i])) === null) {
- throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR);
- }
+ if (name in _self) {
+ hook = _self[name];
+ }
+
+ isOverloaded = (Object.prototype.toString.call(constructors) ===
+ "[object Array]");
+ castConstructor = isOverloaded ? castOverload : castUnique;
+
+ return function (argv, scope) {
+ if (Object.prototype.toString.call(argv) !== "[object Arguments]") {
+ return (hook && hook.apply(this, arguments));
+ }
+
+ if (!(scope instanceof argv.callee)) {
+ throw new WebAPIException(errorcode.TYPE_MISMATCH_ERR, null, "TypeError");
}
+
+ castConstructor.apply(this, arguments);
};
}
-_self = (function () {
- var typecast = {}, i;
+function _castInterface(name) {
+ var interface, hook;
+
+ interface = typedef.interface[name];
+
+ if (name in _self) {
+ hook = _self[name];
+ }
+
+ /*
+ * Type cast for each known method of interface. The function name is the
+ * exact name of the corresponding interface.
+ *
+ * method
+ * String of method name
+ *
+ * argv
+ * arguments. The keyword 'arguments' will be always passed in.
+ *
+ * isDuplicate
+ * A boolean value to indicate whether arguments will be copied or not.
+ */
+
+ return function (method, argv, isDuplicate) {
+ if ((typeof method !== "string") || (typeof argv !== "object")) {
+ return (hook && hook.apply(this, arguments));
+ }
+
+ _cast(interface[method], argv, isDuplicate);
+ };
+}
+
+(function () {
+ var i;
for (i in typedef) {
- typecast[i] = cast(typedef[i]);
+ _self[i] = _castType(typedef[i]);
}
- for (i in typedef.interface) {
- typecast[i] = castArgs(typedef.interface[i]);
+ for (i in typedef.constructor) {
+ _self[i] = _castConstructor(i);
+ typedef[i]._constructor = i;
}
- return typecast;
+ for (i in typedef.interface) {
+ _self[i] = _castInterface(i);
+ }
}());
module.exports = _self;
// private
function getExtendedType(val) {
- var type;
+ var type, attr;
+
+ if (typeof val === "object") {
+ if ("_dictionary" in val) {
+ return "dictionary";
+ }
+
+ for (attr in val) {
+ if (attr === "0") {
+ type = "Arguments";
+ } else if (val[attr] === "Callback") {
+ type = "Callback";
+ } else {
+ type = "Object";
+ }
+ break;
+ }
+
+ return type;
+ }
switch (val) {
+ case "Callback":
+ type = "Function";
+ break;
+
case "any": // Any type
- type = "any";
+ case "byte":
+ case "octet":
+ case "unsigned long":
+ type = val;
break;
case "double":
(typeof val[0] === "string")) ? "enum" : "Array";
break;
+ case "[object Arguments]":
+ type = "Arguments";
+ break;
+
case "[object Boolean]":
type = "boolean";
break;
break;
case "[object Object]":
- type = "Object";
+ type = isPattern ? getExtendedType(val) : "Object";
break;
case "[object String]":
return type;
}
- function isInstance(base, derived, obj) {
- var attr;
+ function instanceOfPattern(pattern, obj) {
+ var i, derived;
- for (attr in derived) {
- switch (attr) {
- case "_optional":
- case "_derived":
- break;
-
- default:
- if ((!derived._optional || !derived._optional[attr]) &&
- !(attr in obj)) {
- return false;
- }
- break;
- }
+ if (("_constructor" in pattern) &&
+ (obj instanceof window.tizen[pattern._constructor])) {
+ return -1;
}
- for (attr in obj) {
- if (!(attr in base) && !(attr in derived)) {
- return false;
+ for (i in pattern._derived) {
+ derived = pattern._derived[i];
+
+ if (("_constructor" in derived) &&
+ (obj instanceof window.tizen[derived._constructor])) {
+ return i;
}
}
- return true;
+ return NaN;
+ }
+
+ function toInteger(x) {
+ x = Number(x);
+ return (x < 0) ? Math.ceil(x) : Math.floor(x);
+ }
+
+ function modulo(a, b) {
+ return a - Math.floor(a / b) * b;
+ }
+
+ function toUInt32(x) {
+ return modulo(toInteger(x), Math.pow(2, 32));
}
// public
typeOfObj = getType(obj, false);
typeMap = {
+ "Arguments": function () {
+ var i, isNullable, ret;
+
+ for (i in pattern) {
+ if (i === "_optional")
+ continue;
+
+ isNullable = !!(pattern._optional && pattern._optional[i]);
+
+ if (i > obj.length - 1) {
+ if (!isNullable) {
+ return null;
+ }
+ obj[i] = null;
+ continue;
+ }
+
+ if ((obj[i] === null) || (obj[i] === undefined)) {
+ if (!isNullable || ((i in obj) && (obj[i] !== null))) {
+ return null;
+ }
+ } else {
+ ret = _self(pattern[i]).cast(obj[i]);
+ if (ret === null) {
+ return null;
+ }
+ obj[i] = ret;
+ }
+ }
+
+ return obj;
+ },
+
"Array": function () {
- var arr = [], elementType, i;
+ var elementType, i, ret;
if (typeOfObj !== typeOfPattern) {
return null;
elementType = _self(pattern[0]);
for (i in obj) {
- arr[i] = elementType.cast(obj[i]);
- if (arr[i] === null)
+ ret = elementType.cast(obj[i]);
+ if (ret === null) {
return null;
+ }
+ obj[i] = ret;
}
- return arr;
+ return obj;
+ },
+
+ "Callback": function () {
+ var attr;
+
+ if (typeOfObj !== "Object") {
+ return null;
+ }
+
+ for (attr in pattern) {
+ if (attr in obj) {
+ obj[attr] = _self(pattern[attr]).cast(obj[attr]);
+ if (obj[attr] === null) {
+ return null;
+ }
+ }
+ }
+
+ return obj;
},
"DOMString": function () {
},
"Number": function () {
- var n = parseInt(obj, 10);
+ var n = toInteger(obj);
if (isNaN(n))
return null;
},
"Object": function () {
- var ret = {}, attr, i, isMatched = false;
+ var attr, iInstance, ret;
if (typeOfObj !== typeOfPattern) {
return null;
}
+ iInstance = instanceOfPattern(pattern, obj);
+ if (isNaN(iInstance)) {
+ return null;
+ }
+
for (attr in pattern) {
switch (attr) {
case "_optional":
+ case "_constructor":
break;
case "_derived":
- for (i in pattern._derived) {
- if (isInstance(pattern, pattern._derived[i], obj)) {
- isMatched = true;
- break;
+ if (iInstance !== -1) {
+ ret = _self(pattern._derived[iInstance]).cast(obj);
+ if (ret === null) {
+ return null;
}
}
- ret = _self(pattern._derived[isMatched ? i : 0])
- .cast(obj);
break;
default:
if (!pattern._optional || !pattern._optional[attr] ||
- (obj[attr] !== undefined) && (obj[attr] !== null)) {
- ret[attr] = _self(pattern[attr]).cast(obj[attr]);
- if (ret[attr] === null) {
+ (obj[attr] !== undefined) &&
+ (obj[attr] !== null)) {
+ ret = _self(pattern[attr]).cast(obj[attr]);
+ if (ret === null) {
return null;
}
+ obj[attr] = ret;
}
break;
}
}
- return ret;
+ return obj;
},
"any": function () {
return (typeOfObj === typeOfPattern) ? obj : null;
},
+ "dictionary": function () {
+ var attr, ret;
+
+ if (typeOfObj !== "Object") {
+ return null;
+ }
+
+ for (attr in pattern) {
+ if ((attr in obj) && (obj[attr] !== null) &&
+ (obj[attr] !== undefined)) {
+ ret = _self(pattern[attr]).cast(obj[attr]);
+ if (ret === null) {
+ return null;
+ }
+ obj[attr] = ret;
+ }
+ }
+
+ return obj;
+ },
+
"enum": function () {
var i;
return (isNaN(f) ? null : f);
},
+ "unsigned long": function () {
+ var n;
+
+ n = toUInt32(obj);
+
+ return isNaN(n) ? null : n;
+ },
+
+ "octet": function () {
+ var n;
+
+ try {
+ n = Number(obj);
+
+ return ((!isNaN(n) && (n == obj) &&
+ (0 <= n) && (n <= 0xff)) ? n : null);
+ } catch (e) {
+ return null;
+ }
+ },
+
+ "byte": function () {
+ var n, ch;
+
+ switch (typeOfObj) {
+ case "Number":
+ try {
+ n = Number(obj);
+
+ return ((!isNaN(n) && (n == obj) &&
+ (0 <= n) && (n <= 0xff)) ? n : null);
+ } catch (e) {
+ return null;
+ }
+ break;
+
+ case "DOMString":
+ if (obj.length > 1)
+ return null;
+
+ try {
+ ch = obj.charCodeAt();
+
+ return ((!isNaN(ch) && (0 <= ch) &&
+ (ch <= 0xff)) ? String(obj) : null);
+ } catch (e) {
+ return null;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return null;
+ },
+
"": function () {
return _self(t[pattern]).cast(obj);
}
return typeMap[typeOfPattern]();
}
+ function copy(obj) {
+ var typeMap,
+ typeOfObj = getType(obj, false);
+
+ typeMap = {
+ "Arguments": function () {
+ var i, isNullable, ret = [];
+
+ for (i in pattern) {
+ if (i === "_optional")
+ continue;
+
+ isNullable = !!(pattern._optional && pattern._optional[i]);
+
+ if (i > obj.length - 1) {
+ if (!isNullable) {
+ return null;
+ }
+ ret[i] = null;
+ continue;
+ }
+
+ if ((obj[i] === null) || (obj[i] === undefined)) {
+ if (!isNullable || ((i in obj) && (obj[i] !== null))) {
+ return null;
+ }
+ } else if ((ret[i] = _self(pattern[i])
+ .copy(obj[i])) === null) {
+ return null;
+ }
+ }
+
+ for (i in ret) {
+ obj[i] = ret[i];
+ }
+
+ return obj;
+ },
+
+ "Array": function () {
+ var arr = [], elementType, i;
+
+ if (typeOfObj !== typeOfPattern) {
+ return null;
+ }
+
+ elementType = _self(pattern[0]);
+ for (i in obj) {
+ if (obj[i]) {
+ arr[i] = elementType.copy(obj[i]);
+ if (arr[i] === null)
+ return null;
+ }
+ }
+
+ return arr;
+ },
+
+ "Callback": function () {
+ var ret = {}, attr;
+
+ if (typeOfObj !== "Object") {
+ return null;
+ }
+
+ for (attr in pattern) {
+ if (attr in obj) {
+ ret[attr] = _self(pattern[attr]).copy(obj[attr]);
+ if (ret[attr] === null) {
+ return null;
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ "Object": function () {
+ var ret = {}, iInstance, attr, derived, i;
+
+ if (typeOfObj !== typeOfPattern) {
+ return null;
+ }
+
+ iInstance = instanceOfPattern(pattern, obj);
+ if (isNaN(iInstance)) {
+ return null;
+ }
+
+ for (attr in pattern) {
+ switch (attr) {
+ case "_optional":
+ case "_constructor":
+ break;
+
+ case "_derived":
+ if (iInstance !== -1) {
+ derived = _self(pattern._derived[iInstance])
+ .copy(obj);
+
+ for (i in derived) {
+ ret[i] = derived[i];
+ }
+ }
+ break;
+
+ default:
+ if (!pattern._optional || !pattern._optional[attr] ||
+ (obj[attr] !== undefined) &&
+ (obj[attr] !== null)) {
+ ret[attr] = _self(pattern[attr]).copy(obj[attr]);
+ if (ret[attr] === null) {
+ return null;
+ }
+ }
+ break;
+ }
+ }
+
+ return ret;
+ },
+
+ "dictionary": function () {
+ var ret = {}, attr;
+
+ if (typeOfObj !== "Object") {
+ return null;
+ }
+
+ for (attr in pattern) {
+ if ((attr in obj) && (obj[attr] !== null) &&
+ (obj[attr] !== undefined)) {
+ ret[attr] = _self(pattern[attr]).copy(obj[attr]);
+ if (ret[attr] === null) {
+ return null;
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ "": function () {
+ return _self(t[pattern]).copy(obj);
+ }
+ };
+
+ return (typeOfPattern in typeMap) ? typeMap[typeOfPattern]() :
+ cast(obj);
+ }
+
function match(obj) {
var typeMap,
typeOfObj = getType(obj, false);
return true;
},
+ "Callback": function () {
+ var attr, isMatched = true;
+
+ if (typeOfObj !== "Object") {
+ return false;
+ }
+
+ for (attr in pattern) {
+ if (attr in obj) {
+ isMatched = _self(pattern[attr]).match(obj[attr]);
+ if (!isMatched) {
+ break;
+ }
+ }
+ }
+
+ return isMatched;
+ },
+
"DOMString": function () {
return (typeOfObj === typeOfPattern);
},
},
"Object": function () {
- var attr, i, isMatched = false;
+ var iInstance, attr, isMatched = false;
if (typeOfObj !== typeOfPattern)
return false;
+ iInstance = instanceOfPattern(pattern, obj);
+ if (isNaN(iInstance)) {
+ return false;
+ }
+
for (attr in pattern) {
switch (attr) {
case "_optional":
+ case "_constructor":
break;
case "_derived":
- isMatched = false;
-
- for (i in pattern._derived) {
- isMatched = _self(pattern._derived[i]).match(obj);
- if (isMatched)
- break;
+ if (iInstance !== -1) {
+ isMatched = _self(pattern._derived[iInstance])
+ .match(obj);
}
break;
default:
if (pattern._optional && pattern._optional[attr]) {
isMatched = ((obj[attr] === null) ||
- (obj[attr] === undefined) ||
- _self(pattern[attr]).match(obj[attr]));
+ (obj[attr] === undefined) ||
+ _self(pattern[attr]).match(obj[attr]));
} else {
isMatched = (obj[attr] !== undefined) &&
- _self(pattern[attr]).match(obj[attr]);
+ _self(pattern[attr]).match(obj[attr]);
}
break;
}
return (typeOfObj === typeOfPattern);
},
+ "dictionary": function () {
+ var attr, isMatched = true;
+
+ if (typeOfObj !== "Object") {
+ return false;
+ }
+
+ for (attr in pattern) {
+ if ((attr in obj) && (obj[attr] !== null) &&
+ (obj[attr] !== undefined)) {
+ isMatched = _self(pattern[attr]).match(obj[attr]);
+ if (!isMatched)
+ break;
+ }
+ }
+
+ return isMatched;
+ },
+
"enum": function () {
for (var i in pattern) {
if (obj === pattern[i]) {
return (typeOfObj === "Number");
},
- "": function () {
- return _self(t[pattern]).match(obj);
- }
- };
-
- return typeMap[typeOfPattern]();
- }
-
- function validate(obj) {
- var typeMap,
- typeOfObj = getType(obj, false);
-
- typeMap = {
- "Array": function () {
- var elementType, i;
-
- if (typeOfObj !== typeOfPattern)
- return false;
+ "unsigned long": function () {
+ var n;
- elementType = _self(pattern[0]);
- for (i in obj) {
- if (!elementType.validate(obj[i])) {
- return false;
- }
- }
+ n = toUInt32(obj);
- return true;
+ return !isNaN(n);
},
- "DOMString": function () {
- return (obj !== "");
- },
+ "octet": function () {
+ var n;
- "Number": function () {
- return (obj !== 0);
- },
-
- "Object": function () {
- var attr, i, isValid = false, isMatched = false;
+ try {
+ n = Number(obj);
- if (typeOfObj !== typeOfPattern)
+ return (!isNaN(n) && (n == obj) &&
+ (0 <= n) && (n <= 0xff));
+ } catch (e) {
return false;
+ }
+ },
- for (attr in pattern) {
- switch (attr) {
- case "_optional":
- break;
+ "byte": function () {
+ var n, ch;
- case "_derived":
- for (i in pattern._derived) {
- if (isInstance(pattern, pattern._derived[i], obj)) {
- isMatched = true;
- break;
- }
- }
- isValid = _self(pattern._derived[isMatched ? i : 0])
- .validate(obj);
- break;
+ switch (typeOfObj) {
+ case "Number":
+ try {
+ n = Number(obj);
- default:
- if (pattern._optional && pattern._optional[attr]) {
- isValid = true;
- } else {
- isValid = _self(pattern[attr]).validate(obj[attr]);
- }
- break;
+ return (!isNaN(n) && (n == obj) &&
+ (0 <= n) && (n <= 0xff));
+ } catch (e) {
+ return false;
}
+ break;
- if (!isValid)
- break;
- }
+ case "DOMString":
+ if (obj.length > 1)
+ return false;
- return isValid;
- },
+ try {
+ ch = obj.charCodeAt();
- "enum": function () {
- for (var i in pattern) {
- if (obj === pattern[i]) {
- return true;
+ return (!isNaN(ch) && (0 <= ch) && (ch <= 0xff));
+ } catch (e) {
+ return false;
}
+ break;
+
+ default:
+ break;
}
return false;
},
- "float": function () {
- return (obj !== 0);
+ "Arguments": function () {
+ return true;
},
"": function () {
- return _self(t[pattern]).validate(obj);
+ return _self(t[pattern]).match(obj);
}
};
- return !typeMap[typeOfPattern] || typeMap[typeOfPattern]();
+ return typeMap[typeOfPattern]();
}
typeOfPattern = getType(pattern, true);
typeCoerce = {
- cast: cast,
- match: match,
- validate: validate
+ cast: cast,
+ copy: copy,
+ match: match
};
return typeCoerce;
* limitations under the License.
*/
-var _t, _i;
+var _t, _c, _i;
/*
* Primitive type definition
_t = {
// Basic
- DOMString: "",
- Date: new Date(),
- Function: function () {},
- any: "any",
- boolean: false,
- double: "double",
- float: "float",
- long: 0,
- "unsigned long": 0,
- "unsigned long long": 0,
- "unsigned short": 0,
+ Callback: "Callback",
+ DOMString: "",
+ Date: new Date(),
+ Function: function () {},
+ any: "any",
+ boolean: false,
+ byte: "byte",
+ double: "double",
+ float: "float",
+ long: 0,
+ octet: "octet",
+ short: 0,
+ "unsigned long": "unsigned long",
+ "unsigned long long": 0,
+ "unsigned short": 0,
// Common
- FilterMatchFlag: ["EXACTLY", "FULLSTRING", "CONTAINS",
- "STARTSWITH", "ENDSWITH", "EXISTS"],
- SortModeOrder: ["ASC", "DESC"],
- CompositeFilterType: ["UNION", "INTERSECTION"],
+ FilterMatchFlag: ["EXACTLY", "FULLSTRING", "CONTAINS",
+ "STARTSWITH", "ENDSWITH", "EXISTS"],
+ SortModeOrder: ["ASC", "DESC"],
+ CompositeFilterType: ["UNION", "INTERSECTION"],
// Calendar
- ByDayValue: ["MO", "TU", "WE", "TH", "FR", "SA", "SU"],
+ ByDayValue: ["MO", "TU", "WE", "TH", "FR", "SA", "SU"],
// Contact
- ContactTextFormat: ["VCARD_30", "VCARD_30"], // Enum must has more than one value
+ ContactTextFormat: ["VCARD_30", "VCARD_30"], // Enum must has more than one value
// Content
- ContentDirectoryStorageType: ["INTERNAL", "EXTERNAL"],
- ContentType: ["IMAGE", "VIDEO", "AUDIO", "OTHER"],
- AudioContentLyricsType: ["SYNCHRONIZED", "UNSYNCHRONIZED"],
- ImageContentOrientation: ["NORMAL", "FLIP_HORIZONTAL", "ROTATE_180",
- "FLIP_VERTICAL", "TRANSPOSE", "ROTATE_90",
- "TRANSVERSE", "ROTATE_270"],
+ ContentDirectoryStorageType: ["INTERNAL", "EXTERNAL"],
+ ContentType: ["IMAGE", "VIDEO", "AUDIO", "OTHER"],
+ AudioContentLyricsType: ["SYNCHRONIZED", "UNSYNCHRONIZED"],
+ ImageContentOrientation: ["NORMAL", "FLIP_HORIZONTAL", "ROTATE_180",
+ "FLIP_VERTICAL", "TRANSPOSE", "ROTATE_90",
+ "TRANSVERSE", "ROTATE_270"],
// Data Control
- DataType: ["MAP", "SQL"],
-
- // Data Sync
- SyncMode: ["MANUAL", "PERIODIC", "PUSH"],
- SyncType: ["TWO_WAY", "SLOW", "ONE_WAY_FROM_CLIENT", "REFRESH_FROM_CLIENT", "ONE_WAY_FROM_SERVER", "REFRESH_FROM_SERVER"],
- SyncInterval: ["5_MINUTES", "15_MINUTES", "1_HOUR", "4_HOURS", "12_HOURS", "1_DAY", "1_WEEK", "1_MONTH"],
- SyncServiceType: ["CONTACT", "EVENT"],
- SyncStatus: ["SUCCESS", "FAIL", "STOP", "NONE"],
+ DataType: ["MAP", "SQL"],
+
+ // Data Synchronization
+ SyncMode: ["MANUAL", "PERIODIC", "PUSH"],
+ SyncType: ["TWO_WAY", "SLOW",
+ "ONE_WAY_FROM_CLIENT",
+ "REFRESH_FROM_CLIENT",
+ "ONE_WAY_FROM_SERVER",
+ "REFRESH_FROM_SERVER"],
+ SyncInterval: ["5_MINUTES", "15_MINUTES", "1_HOUR",
+ "4_HOURS", "12_HOURS", "1_DAY",
+ "1_WEEK", "1_MONTH"],
+ SyncServiceType: ["CONTACT", "EVENT"],
+ SyncStatus: ["SUCCESS", "FAIL", "STOP", "NONE"],
+
+ // Download
+ DownloadState: ["QUEUED", "DOWNLOADING", "PAUSED", "CANCELED", "COMPLETED", "FAILED"],
+ DownloadNetworkType: ["CELLULAR", "WIFI", "ALL"],
// Messaging
- MessageServiceTag: ["messaging.sms", "messaging.mms", "messaging.email"],
+ MessageServiceTag: ["messaging.sms", "messaging.mms", "messaging.email"],
// Network Bearer Selection
- NetworkType: ["CELLULAR", "UNKNOWN"]
+ NetworkType: ["CELLULAR", "UNKNOWN"],
+
+ // NFC
+ NDEFRecordTextEncoding: ["UTF8", "UTF16"],
+ NFCTagType: ["GENERIC_TARGET", "ISO14443_A",
+ "ISO14443_4A", "ISO14443_3A", "MIFARE_MINI",
+ "MIFARE_1K", "MIFARE_4K", "MIFARE_ULTRA",
+ "MIFARE_DESFIRE", "ISO14443_B",
+ "ISO14443_4B", "ISO14443_BPRIME", "FELICA",
+ "JEWEL", "ISO15693", "UNKNOWN_TARGET"],
+
+ // Notification
+ NotificationType: ["STATUS", "STATUS"],
+ StatusNotificationType: ["SIMPLE", "THUMBNAIL", "ONGOING",
+ "PROGRESS"],
+ NotificationProgressType: ["PERCENTAGE", "BYTE"]
};
/*
* Union types
* An array consists of member types. It exists in the definition of
* a union type.
+ *
+ * _dictionary
+ * Dictionary type, which indicates that the object is a dictionary type.
*/
/*
* Application
*/
-_t.ApplicationId = _t.DOMString;
+_t.ApplicationId = _t.DOMString;
+_t.ApplicationContextId = _t.DOMString;
+_t.ApplicationInformationArraySuccessCallback = _t.Function;
+_t.FindAppControlSuccessCallback = _t.Function;
+_t.ApplicationContextArraySuccessCallback = _t.Function;
_t.ApplicationControlData = {
key: _t.DOMString,
}
};
+_t.ApplicationControlDataArrayReplyCallback = {
+ onsuccess: _t.Callback,
+ onfailure: _t.Callback
+};
+
+_t.ApplicationInformationEventCallback = {
+ oninstalled: _t.Callback,
+ onupdated: _t.Callback,
+ onuninstalled: _t.Callback
+};
+
/*
* Bookmark
*/
};
/*
+ * Calendar
+ */
+
+_t.CalendarChangeCallback = {
+ onitemsadded: _t.Callback,
+ onitemsupdated: _t.Callback,
+ onitemsremoved: _t.Callback
+};
+
+/*
* Contact
*/
_t.AddressBookArraySuccessCallback = _t.Function;
_t.AddressBookChangeCallback = {
- oncontactsadded: _t.Function,
- oncontactsupdated: _t.Function,
- oncontactsremoved: _t.Function
+ oncontactsadded: _t.Callback,
+ oncontactsupdated: _t.Callback,
+ oncontactsremoved: _t.Callback
};
_t.PersonsChangeCallback = {
- onpersonsadded: _t.Function,
- onpersonsupdated: _t.Function,
- onpersonsremoved: _t.Function
+ onpersonsadded: _t.Callback,
+ onpersonsupdated: _t.Callback,
+ onpersonsremoved: _t.Callback
+};
+
+_t.ContactInit = {
+ name: _t.ContactName,
+ addresses: [_t.ContactAddress],
+ photoURI: _t.DOMString,
+ phoneNumbers: [_t.ContactPhoneNumber],
+ emails: [_t.ContactEmailAddress],
+ birthday: _t.Date,
+ anniversaries: [_t.ContactAnniversary],
+ organizations: [_t.ContactOrganization],
+ notes: [_t.DOMString],
+ urls: [_t.ContactWebSite],
+ ringtoneURI: _t.DOMString,
+ groupIds: [_t.ContactGroupId],
+
+ _dictionary: true
+};
+
+_t.ContactNameInit = {
+ prefix: _t.DOMString,
+ suffix: _t.DOMString,
+ firstName: _t.DOMString,
+ middleName: _t.DOMString,
+ lastName: _t.DOMString,
+ nicknames: [_t.DOMString],
+ phoneticFirstName: _t.DOMString,
+ phoneticLastName: _t.DOMString,
+
+ _dictionary: true
+};
+
+_t.ContactOrganizationInit = {
+ name: _t.DOMString,
+ department: _t.DOMString,
+ title: _t.DOMString,
+ role: _t.DOMString,
+ logoURI: _t.DOMString,
+
+ _dictionary: true
+};
+
+_t.ContactAddressInit = {
+ country: _t.DOMString,
+ region: _t.DOMString,
+ city: _t.DOMString,
+ streetAddress: _t.DOMString,
+ additionalInformation: _t.DOMString,
+ postalCode: _t.DOMString,
+ isDefault: _t.boolean,
+ types: [_t.DOMString],
+
+ _dictionary: true
};
/*
_t.ContentScanSuccessCallback = _t.Function;
_t.ContentChangeCallback = {
- oncontentadded: _t.Function,
- oncontentupdated: _t.Function,
- oncontentremoved: _t.Function
+ oncontentadded: _t.Callback,
+ oncontentupdated: _t.Callback,
+ oncontentremoved: _t.Callback
};
_t.VideoContent = {
};
/*
- * Data Sync
+ * Data Synchronization
*/
_t.SyncProfileId = _t.DOMString;
_t.SyncInfo = {
- url: _t.DOMString,
- mode: _t.SyncMode,
- type: _t.SyncType,
- interval: _t.SyncInterval,
+ url: _t.DOMString,
+ id: _t.DOMString,
+ password: _t.DOMString,
+ mode: _t.SyncMode,
+ type: _t.SyncType,
+ interval: _t.SyncInterval,
_optional: {
// nullable
- type: true,
- interval: true
+ id: true,
+ password: true,
+ type: true,
+ interval: true
}
};
_t.SyncServiceInfo = {
- enable: _t.boolean,
- serviceType: _t.SyncServiceType,
- serverDatabaseUri: _t.DOMString
+ enable: _t.boolean,
+ serviceType: _t.SyncServiceType,
+ serverDatabaseUri: _t.DOMString,
+ id: _t.DOMString,
+ password: _t.DOMString,
+
+ _optional: {
+ // nullable
+ id: true,
+ password: true
+ }
};
_t.SyncProfileInfo = {
- profileName: _t.DOMString,
- syncInfo: _t.SyncInfo,
- serviceInfo: [_t.SyncServiceInfo],
+ profileId: _t.SyncProfileId,
+ profileName: _t.DOMString,
+ syncInfo: _t.SyncInfo,
+ serviceInfo: [_t.SyncServiceInfo],
_optional: {
// nullable
- serviceInfo: true
+ profileId: true,
+ serviceInfo: true
}
};
+_t.SyncProgressCallback = {
+ onprogress: _t.Callback,
+ oncompleted: _t.Callback,
+ onstopped: _t.Callback,
+ onfailed: _t.Callback
+};
+
+/*
+ * Download
+ */
+
+_t.DownloadHTTPHeaderFields = {};
+
+_t.DownloadRequest = {
+ url: _t.DOMString,
+ destination: _t.DOMString,
+ fileName: _t.DOMString,
+ networkType: _t.DownloadNetworkType,
+ httpHeader: _t.DownloadHTTPHeaderFields,
+
+ _optional: {
+ destination: true,
+ fileName: true,
+ networkType: true,
+ httpHeader: true
+ }
+};
+
+_t.DownloadCallback = {
+ onprogress: _t.Callback,
+ onpaused: _t.Callback,
+ oncanceled: _t.Callback,
+ oncompleted: _t.Callback,
+ onfailed: _t.Callback,
+};
+
/*
* Messaging
*/
};
_t.MessagesChangeCallback = {
- messagesadded: _t.Function,
- messagesupdated: _t.Function,
- messagesremoved: _t.Function
+ messagesadded: _t.Callback,
+ messagesupdated: _t.Callback,
+ messagesremoved: _t.Callback
};
_t.MessageConversationsChangeCallback = {
- conversationsadded: _t.Function,
- conversationsupdated: _t.Function,
- conversationsremoved: _t.Function
+ conversationsadded: _t.Callback,
+ conversationsupdated: _t.Callback,
+ conversationsremoved: _t.Callback
};
_t.MessageFoldersChangeCallback = {
- foldersadded: _t.Function,
- foldersupdated: _t.Function,
- foldersremoved: _t.Function
+ foldersadded: _t.Callback,
+ foldersupdated: _t.Callback,
+ foldersremoved: _t.Callback
};
/*
*/
_t.NetworkSuccessCallback = {
- onsuccess: _t.Function,
- ondisconnected: _t.Function
+ onsuccess: _t.Callback,
+ ondisconnected: _t.Callback
+};
+
+/*
+ * NFC
+ */
+
+_t.NDEFMessageReadCallback = _t.Function;
+_t.ByteArraySuccessCallback = _t.Function;
+
+_t.NFCTagDetectCallback = {
+ onattach: _t.Callback,
+ ondetach: _t.Callback
+};
+
+_t.NFCPeerDetectCallback = {
+ onattach: _t.Callback,
+ ondetach: _t.Callback
+};
+
+_t.NDEFRecordText = {
+ text: _t.DOMString,
+ languageCode: _t.DOMString,
+ encoding: _t.NDEFRecordTextEncoding
+};
+
+_t.NDEFRecordURI = {
+ uri: _t.DOMString
+};
+
+_t.NDEFRecordMedia = {
+ mimeType: _t.DOMString
+};
+
+_t.NDEFRecord = {
+ tnf: _t.short,
+ type: [_t.byte],
+ id: [_t.byte],
+ payload: [_t.byte],
+
+ _derived: [_t.NDEFRecordText, _t.NDEFRecordURI, _t.NDEFRecordMedia]
+};
+
+_t.NDEFMessage = {
+ recordCount: _t.long,
+ records: [_t.NDEFRecord],
+ toByte: _t.Function
+};
+
+/*
+ * Notification
+ */
+
+_t.NotificationId = _t.DOMString;
+
+_t.NotificationDetailInfo = {
+ mainText: _t.DOMString,
+ subText: _t.DOMString,
+
+ _optional: {
+ // nullable
+ subText: true
+ }
+};
+
+_t.StatusNotification = {
+ statusType: _t.StatusNotificationType,
+ iconPath: _t.DOMString,
+ subIconPath: _t.DOMString,
+ number: _t.long,
+ detailInfo: [_t.NotificationDetailInfo],
+ ledColor: _t.DOMString,
+ ledOnPeriod: _t["unsigned long"],
+ ledOffPeriod: _t["unsigned long"],
+ backgroundImagePath: _t.DOMString,
+ thumbnails: [_t.DOMString],
+ soundPath: _t.DOMString,
+ vibration: _t.boolean,
+ appControl: _t.ApplicationControl,
+ appId: _t.ApplicationId,
+ progressType: _t.NotificationProgressType,
+ progressValue: _t["unsigned long"],
+
+ _optional: {
+ // nullable
+ iconPath: true,
+ subIconPath: true,
+ number: true,
+ detailInfo: true,
+ ledColor: true,
+ backgroundImagePath: true,
+ thumbnails: true,
+ soundPath: true,
+ appControl: true,
+ appId: true,
+ progressValue: true
+ }
+};
+
+_t.Notification = {
+ id: _t.NotificationId,
+ type: _t.NotificationType,
+ postedTime: _t.Date,
+ title: _t.DOMString,
+ content: _t.DOMString,
+
+ _optional: {
+ // nullable
+ id: true,
+ postedTime: true,
+ content: true
+ },
+
+ _derived: [_t.StatusNotification]
};
/*
*/
_t.PackageId = _t.DOMString;
+_t.PackageInformationArraySuccessCallback = _t.Function;
+
_t.PackageProgressCallback = {
- onprogress: _t.Function,
- oncomplete: _t.Function,
+ onprogress: _t.Callback,
+ oncomplete: _t.Callback
+};
+
+_t.PackageInfomationEventCallback = {
+ oninstalled: _t.Callback,
+ onupdated: _t.Callback,
+ onuninstalled: _t.Callback
+};
+
+/*
+ * Constructor list definition
+ */
+
+/*
+ * Generic constructor
+ * Construct a prototype of constructor. A fake array of arguments type is
+ * specified for constructor.
+ *
+ * Overloaded constructors
+ * Construct an array of prototype of constructor. Each array element is
+ * specified for one of constructors. The constructor with extra arguments
+ * are recommended to be defined ahead of the one with fewer same arguments
+ * for exact match.
+ */
+
+_c = {
+ // Alarm
+ AlarmAbsolute: [],
+
+ // Contact
+ Contact: [],
+
+ // NFC
+ NDEFMessage: [],
+ NDEFRecord: [],
+
+ // Data Synchronization
+ SyncInfo: []
+};
+
+/*
+ * Common
+ */
+
+// SortMode
+_c.SortMode = {
+ 0: _t.DOMString,
+ 1: _t.SortModeOrder,
_optional: {
- onprogress: true,
- oncomplete: true
+ 1: true
}
};
-_t.PackageInformationArraySuccessCallback = _t.Function;
-_t.PackageInfomationEventCallback = {
- oninstalled: _t.Function,
- onupdated: _t.Function,
- onuninstalled: _t.Function,
+
+/*
+ * Alarm
+ */
+
+// AlarmRelative
+_c.AlarmRelative = {
+ 0: _t.long,
+ 1: _t.long,
+
+ _optional: {
+ 1: true
+ }
+};
+
+// AlarmAbsolute
+_c.AlarmAbsolute[0] = {
+ 0: _t.Date,
+ 1: [_t.ByDayValue]
+};
+
+_c.AlarmAbsolute[1] = {
+ 0: _t.Date,
+ 1: _t.long
+};
+
+_c.AlarmAbsolute[2] = {
+ 0: _t.Date
+};
+
+/*
+ * Application
+ */
+
+// ApplicationControlData
+_c.ApplicationControlData = {
+ 0: _t.DOMString,
+ 1: [_t.DOMString]
+};
+
+// ApplicationControl
+_c.ApplicationControl = {
+ 0: _t.DOMString,
+ 1: _t.DOMString,
+ 2: _t.DOMString,
+ 3: _t.DOMString,
+ 4: [_t.ApplicationControlData],
+
+ _optional: {
+ 1: true,
+ 2: true,
+ 3: true,
+ 4: true
+ }
+};
+
+/*
+ * Bookmark
+ */
+
+// BookmarkItem
+_c.BookmarkItem = {
+ 0: _t.DOMString,
+ 1: _t.DOMString
+};
+
+// BookmarkFolder
+_c.BookmarkFolder = {
+ 0: _t.DOMString
+};
+
+/*
+ * Contact
+ */
+
+// Contact
+_c.Contact[0] = {
+ 0: _t.ContactInit,
+
+ _optional: {
+ 0: true
+ }
+};
+
+_c.Contact[1] = {
+ 0: _t.DOMString
+};
+
+// ContactRef
+_c.ContactRef = {
+ 0: _t.AddressBookId,
+ 1: _t.ContactId
+};
+
+// ContactName
+_c.ContactName = {
+ 0: _t.ContactNameInit,
+
+ _optional: {
+ 0: true
+ }
+};
+
+// ContactOrganization
+_c.ContactOrganization = {
+ 0: _t.ContactOrganizationInit,
+
+ _optional: {
+ 0: true
+ }
+};
+
+// ContactWebSite
+_c.ContactWebSite = {
+ 0: _t.DOMString,
+ 1: _t.DOMString,
+
+ _optional: {
+ 1: true
+ }
+};
+
+// ContactAnniversary
+_c.ContactAnniversary = {
+ 0: _t.Date,
+ 1: _t.DOMString,
+
+ _optional: {
+ 1: true
+ }
+};
+
+// ContactAddress
+_c.ContactAddress = {
+ 0: _t.ContactAddressInit,
+
+ _optional: {
+ 0: true
+ }
+};
+
+// ContactPhoneNumber
+_c.ContactPhoneNumber = {
+ 0: _t.DOMString,
+ 1: [_t.DOMString],
+ 2: _t.boolean,
+
+ _optional: {
+ 1: true,
+ 2: true
+ }
+};
+
+// ContactEmailAddress
+_c.ContactEmailAddress = {
+ 0: _t.DOMString,
+ 1: [_t.DOMString],
+ 2: _t.boolean,
+
+ _optional: {
+ 1: true,
+ 2: true
+ }
+};
+
+// ContactGroup
+_c.ContactGroup = {
+ 0: _t.DOMString,
+ 1: _t.DOMString,
+ 2: _t.DOMString,
+
+ _optional: {
+ 1: true,
+ 2: true
+ }
+};
+
+/*
+ * Data Synchronization
+ */
+
+// SyncInfo
+_c.SyncInfo[0] = {
+ 0: _t.DOMString,
+ 1: _t.DOMString,
+ 2: _t.DOMString,
+ 3: _t.SyncMode,
+ 4: _t.SyncType
+};
+
+_c.SyncInfo[1] = {
+ 0: _t.DOMString,
+ 1: _t.DOMString,
+ 2: _t.DOMString,
+ 3: _t.SyncMode,
+ 4: _t.SyncInterval
+};
+
+_c.SyncInfo[2] = {
+ 0: _t.DOMString,
+ 1: _t.DOMString,
+ 2: _t.DOMString,
+ 3: _t.SyncMode
+};
+
+// SyncServiceInfo
+_c.SyncServiceInfo = {
+ 0: _t.boolean,
+ 1: _t.SyncServiceType,
+ 2: _t.DOMString,
+ 3: _t.DOMString,
+ 4: _t.DOMString,
+
+ _optional: {
+ 3: true,
+ 4: true
+ }
+};
+
+// SyncProfileInfo
+_c.SyncProfileInfo = {
+ 0: _t.DOMString,
+ 1: _t.SyncInfo,
+ 2: [_t.SyncServiceInfo],
+
+ _optional: {
+ 2: true
+ }
+};
+
+/*
+ * NFC
+ */
+
+// NDEFMessage
+_c.NDEFMessage[0] = {
+ 0: [_t.NDEFRecord]
+};
+
+_c.NDEFMessage[1] = {
+ 0: [_t.byte]
+};
+
+_c.NDEFMessage[2] = null;
+
+// NDEFRecord
+_c.NDEFRecord[0] = {
+ 0: _t.short,
+ 1: [_t.byte],
+ 2: [_t.byte],
+ 3: [_t.byte],
_optional: {
- oninstalled: true,
- onupdated: true,
- onuninstalled: true
+ 3: true
}
};
+_c.NDEFRecord[1] = {
+ 0: [_t.byte]
+};
+
+// NDEFRecordText
+_c.NDEFRecordText = {
+ 0: _t.DOMString,
+ 1: _t.DOMString,
+ 2: _t.DOMString,
+
+ _optional: {
+ 2: true
+ }
+};
+
+// NDEFRecordURI
+_c.NDEFRecordURI = {
+ 0: _t.DOMString
+};
+
+// NDEFRecordMedia
+_c.NDEFRecordMedia = {
+ 0: _t.DOMString,
+ 1: [_t.byte]
+};
+
/*
* Interface prototype definition
*/
_i = {
+ // Alarm
+ AlarmManager: {},
+
+ // Application
+ ApplicationManager: {},
+ Application: {},
+ RequestedApplicationControl: {},
+
+ // Bookmark
+ BookmarkManager: {},
+
// Contact
- ContactManager: {},
- AddressBook: {},
- Person: {},
+ ContactManager: {},
+ AddressBook: {},
+ Person: {},
+ Contact: {},
// Content
- ContentManager: {},
+ ContentManager: {},
// Data Control
- DataControlManager: {},
- SQLDataControlConsumer: {},
- MappedDataControlConsumer: {}
+ DataControlManager: {},
+ SQLDataControlConsumer: {},
+ MappedDataControlConsumer: {},
+
+ // Data Synchronization
+ DataSynchronizationManager: {},
+
+ // Download
+ DownloadManager: {},
+
+ // Network Bearer Selection
+ NetworkBearerSelection: {},
+
+ // NFC
+ NFCManager: {},
+ NFCAdapter: {},
+ NFCTag: {},
+ NFCPeer: {},
+ NDEFMessage: {},
+
+ // Notification
+ NotificationManager: {},
+
+ // Message
+ Messaging: {},
+ MessageService: {},
+ MessageStorage: {},
+
+ // Package
+ PackageManager: {},
+
+ // Push
+ PushManager: {}
+};
+
+/*
+ * Alarm
+ */
+
+// AlarmManager
+_i.AlarmManager.add = {
+ 0: _t.Alarm,
+ 1: _t.ApplicationId,
+ 2: _t.ApplicationControl,
+
+ _optional: {
+ 2: true
+ }
+};
+
+_i.AlarmManager.remove = {
+ 0: _t.AlarmId
+};
+
+_i.AlarmManager.removeAll = null;
+
+_i.AlarmManager.get = {
+ 0: _t.AlarmId
+};
+
+_i.AlarmManager.getAll = null;
+
+/*
+ * Application
+ */
+
+// ApplicationManager
+_i.ApplicationManager.getCurrentApplication = null;
+
+_i.ApplicationManager.kill = {
+ 0: _t.ApplicationContextId,
+ 1: _t.SuccessCallback,
+ 2: _t.ErrorCallback,
+
+ _optional: {
+ 1: true,
+ 2: true
+ }
+};
+
+_i.ApplicationManager.launch = {
+ 0: _t.ApplicationId,
+ 1: _t.SuccessCallback,
+ 2: _t.ErrorCallback,
+
+ _optional: {
+ 1: true,
+ 2: true
+ }
+};
+
+_i.ApplicationManager.launchAppControl = {
+ 0: _t.ApplicationControl,
+ 1: _t.ApplicationId,
+ 2: _t.SuccessCallback,
+ 3: _t.ErrorCallback,
+ 4: _t.ApplicationControlDataArrayReplyCallback,
+
+ _optional: {
+ 1: true,
+ 2: true,
+ 3: true,
+ 4: true
+ }
+};
+
+_i.ApplicationManager.findAppControl = {
+ 0: _t.ApplicationControl,
+ 1: _t.FindAppControlSuccessCallback,
+ 2: _t.ErrorCallback,
+
+ _optional: {
+ 2: true
+ }
+};
+
+_i.ApplicationManager.getAppsContext = {
+ 0: _t.ApplicationContextArraySuccessCallback,
+ 1: _t.ErrorCallback,
+
+ _optional: {
+ 1: true
+ }
+};
+
+_i.ApplicationManager.getAppContext = {
+ 0: _t.ApplicationContextId,
+
+ _optional: {
+ 0: true
+ }
+};
+
+_i.ApplicationManager.getAppsInfo = {
+ 0: _t.ApplicationInformationArraySuccessCallback,
+ 1: _t.ErrorCallback,
+
+ _optional: {
+ 1: true
+ }
+};
+
+_i.ApplicationManager.getAppInfo = {
+ 0: _t.ApplicationId,
+
+ _optional: {
+ 0: true
+ }
+};
+
+_i.ApplicationManager.getAppCerts = {
+ 0: _t.ApplicationId,
+
+ _optional: {
+ 0: true
+ }
+};
+
+_i.ApplicationManager.getAppSharedURI = {
+ 0: _t.ApplicationId,
+
+ _optional: {
+ 0: true
+ }
+};
+
+_i.ApplicationManager.getAppMetaData = {
+ 0: _t.ApplicationId,
+
+ _optional: {
+ 0: true
+ }
+};
+
+_i.ApplicationManager.addAppInfoEventListener = {
+ 0: _t.ApplicationInformationEventCallback
+};
+
+_i.ApplicationManager.removeAppInfoEventListener = {
+ 0: _t.long
+};
+
+// Application
+_i.Application.exit = null;
+_i.Application.hide = null;
+_i.Application.getRequestedAppControl = null;
+
+// RequestedApplicationControl
+_i.RequestedApplicationControl.replyResult = {
+ 0: [_t.ApplicationControlData],
+
+ _optional: {
+ 0: true
+ }
+};
+
+_i.RequestedApplicationControl.replyFailure = null;
+
+/*
+ * Bookmark
+ */
+
+// BookmarkManager
+_i.BookmarkManager.get = {
+ 0: _t.BookmarkFolder,
+ 1: _t.boolean,
+
+ _optional: {
+ 0: true,
+ 1: true
+ }
+};
+
+_i.BookmarkManager.add = {
+ 0: _t.Bookmark,
+ 1: _t.BookmarkFolder,
+
+ _optional: {
+ 1: true
+ }
+};
+
+_i.BookmarkManager.remove = {
+ 0: _t.Bookmark,
+
+ _optional: {
+ 0: true
+ }
};
/*
0: _t.ContactId
};
+// Contact
+_i.Contact.convertToString = {
+ 0: _t.ContactTextFormat,
+
+ _optional: {
+ 0: true
+ }
+};
+
+_i.Contact.clone = null;
+
/*
* Content
*/
}
};
-_t.interface = _i;
+/*
+ * Data Synchronization
+ */
+
+// DataSynchronizationManager
+_i.DataSynchronizationManager.getMaxProfilesNum = null;
+_i.DataSynchronizationManager.getProfilesNum = null;
+_i.DataSynchronizationManager.getAll = null;
+
+_i.DataSynchronizationManager.add = {
+ 0: _t.SyncProfileInfo
+};
+
+_i.DataSynchronizationManager.update = {
+ 0: _t.SyncProfileInfo
+};
+
+_i.DataSynchronizationManager.remove = {
+ 0: _t.SyncProfileId
+};
+
+_i.DataSynchronizationManager.get = {
+ 0: _t.SyncProfileId
+};
+
+_i.DataSynchronizationManager.startSync = {
+ 0: _t.SyncProfileId,
+ 1: _t.SyncProgressCallback,
+
+ _optional: {
+ 1: true
+ }
+};
+
+_i.DataSynchronizationManager.stopSync = {
+ 0: _t.SyncProfileId
+};
+
+_i.DataSynchronizationManager.getLastSyncStatistics = {
+ 0: _t.SyncProfileId
+};
+
+/*
+ * Download
+ */
+
+// DownloadManager
+_i.DownloadManager.start = {
+ 0: _t.DownloadRequest,
+ 1: _t.DownloadCallback,
+
+ _optional: {
+ 1: true
+ }
+};
+
+_i.DownloadManager.cancel = {
+ 0: _t["unsigned long"]
+};
+
+_i.DownloadManager.pause = {
+ 0: _t["unsigned long"]
+};
+
+_i.DownloadManager.resume = {
+ 0: _t["unsigned long"]
+};
+
+_i.DownloadManager.getState = {
+ 0: _t["unsigned long"]
+};
+
+_i.DownloadManager.getDownloadRequest = {
+ 0: _t["unsigned long"]
+};
+
+_i.DownloadManager.getMIMEType = {
+ 0: _t["unsigned long"]
+};
+
+_i.DownloadManager.setListener = {
+ 0: _t["unsigned long"],
+ 1: _t.DownloadCallback
+};
+
+/*
+ * Network Bearer Selection
+ */
+
+// NetworkBearerSelection
+_i.NetworkBearerSelection.requestRouteToHost = {
+ 0: _t.NetworkType,
+ 1: _t.DOMString,
+ 2: _t.NetworkSuccessCallback,
+ 3: _t.ErrorCallback,
+
+ _optional: {
+ 3: true
+ }
+};
+
+_i.NetworkBearerSelection.releaseRouteToHost = {
+ 0: _t.NetworkType,
+ 1: _t.DOMString,
+ 2: _t.SuccessCallback,
+ 3: _t.ErrorCallback,
+
+ _optional: {
+ 3: true
+ }
+};
+
+/*
+ * NFC
+ */
+
+// NFCManager
+_i.NFCManager.getDefaultAdapter = null;
+_i.NFCManager.setExclusiveMode = {
+ 0: _t.boolean
+};
+
+// NFCAdapter
+_i.NFCAdapter.setPowered = {
+ 0: _t.boolean,
+ 1: _t.SuccessCallback,
+ 2: _t.ErrorCallback,
+
+ _optional: {
+ 1: true,
+ 2: true
+ }
+};
+
+_i.NFCAdapter.setTagListener = {
+ 0: _t.NFCTagDetectCallback,
+ 1: [_t.NFCTagType],
+
+ _optional: {
+ 1: true
+ }
+};
+
+_i.NFCAdapter.setPeerListener = {
+ 0: _t.NFCPeerDetectCallback
+};
+
+_i.NFCAdapter.unsetTagListener = null;
+_i.NFCAdapter.unsetPeerListener = null;
+_i.NFCAdapter.getCachedMessage = null;
+
+// NFCTag
+_i.NFCTag.readNDEF = {
+ 0: _t.NDEFMessageReadCallback,
+ 1: _t.ErrorCallback,
+
+ _optional: {
+ 1: true
+ }
+};
+
+_i.NFCTag.writeNDEF = {
+ 0: _t.NDEFMessage,
+ 1: _t.SuccessCallback,
+ 2: _t.ErrorCallback,
+
+ _optional: {
+ 1: true,
+ 2: true
+ }
+};
+
+_i.NFCTag.transceive = {
+ 0: [_t.byte],
+ 1: _t.ByteArraySuccessCallback,
+ 2: _t.ErrorCallback,
+
+ _optional: {
+ 2: true
+ }
+};
+
+// NFCPeer
+_i.NFCPeer.setReceiveNDEFListener = {
+ 0: _t.NDEFMessageReadCallback
+};
+
+_i.NFCPeer.unsetReceiveNDEFListener = null;
+
+_i.NFCPeer.sendNDEF = {
+ 0: _t.NDEFMessage,
+ 1: _t.SuccessCallback,
+ 2: _t.ErrorCallback,
+
+ _optional: {
+ 1: true,
+ 2: true
+ }
+};
+
+// NDEFMessage
+_i.NDEFMessage.toByte = null;
+
+/*
+ * Notification
+ */
+
+// NotificationManager
+_i.NotificationManager.post = {
+ 0: _t.Notification
+};
+
+_i.NotificationManager.update = {
+ 0: _t.Notification
+};
+
+_i.NotificationManager.remove = {
+ 0: _t.NotificationId
+};
+
+_i.NotificationManager.get = {
+ 0: _t.NotificationId
+};
+
+_i.NotificationManager.removeAll = null;
+_i.NotificationManager.getAll = null;
+
+/*
+ * Package
+ */
+
+// PackageManager
+_i.PackageManager.install = {
+ 0: _t.DOMString,
+ 1: _t.PackageProgressCallback,
+ 2: _t.ErrorCallback,
+
+ _optional: {
+ 2: true
+ }
+};
+
+_i.PackageManager.uninstall = {
+ 0: _t.PackageId,
+ 1: _t.PackageProgressCallback,
+ 2: _t.ErrorCallback,
+
+ _optional: {
+ 2: true
+ }
+};
+
+_i.PackageManager.getPackagesInfo = {
+ 0: _t.PackageInformationArraySuccessCallback,
+ 1: _t.ErrorCallback,
+
+ _optional: {
+ 1: true
+ }
+};
+
+_i.PackageManager.getPackageInfo = {
+ 0: _t.PackageId,
+
+ _optional: {
+ 0: true
+ }
+};
+
+_i.PackageManager.setPackageInfoEventListener = {
+ 0: _t.PackageInfomationEventCallback
+};
+
+_i.PackageManager.unsetPackageInfoEventListener = null;
+
+/*
+ * Push
+ */
+
+// PushManager
+_i.PushManager.registerService = {
+ 0: _t.ApplicationControl,
+ 1: _t.PushRegisterSuccessCallback,
+ 2: _t.ErrorCallback,
+
+ _optional: {
+ 2: true
+ }
+};
+
+_i.PushManager.unregisterService = {
+ 0: _t.SuccessCallback,
+ 1: _t.ErrorCallback,
+
+ _optional: {
+ 0: true,
+ 1: true
+ }
+};
+
+_i.PushManager.connectService = {
+ 0: _t.PushNotificationCallback
+};
+
+_i.PushManager.disconnectService = null;
+_i.PushManager.getRegistrationId = null;
+
+// Exports
+_t.constructor = _c;
+_t.interface = _i;
module.exports = _t;
var event = require('ripple/event'),
utils = require('ripple/utils'),
db = require('ripple/db'),
+ dbinit = require('ripple/platform/tizen/2.0/dbinit'),
DB_APPLICATION_KEY = "tizen1-db-application",
_data = {
- appList : {},
+ appList: {},
installedAppList: {}
},
_appInstalledTemplate,
- _apps = {
- "http://tizen.org/viewer": {
- id: "http://tizen.org/viewer",
- name: "Tizen viewer",
- iconPath: "001.png",
- version: "1.9",
- show: true,
- categories: ["media"],
- size: 5120,
- packageId: "TEST_APP_ID",
- sharedURI: "/usr/local/share/viewer",
- operation: "http://tizen.org/appcontrol/operation/view",
- appControl: {
- uri: "http://tizen.org/appcontrol/uri/view",
- mime: "image/*",
- category: "media",
- data: ""
- },
- type: "AUTHOR_ROOT",
- value: []
- },
- "http://tizen.org/player": {
- id: "http://tizen.org/player",
- name: "Tizen player",
- iconPath: "002.png",
- version: "2.0",
- show: true,
- categories: ["media"],
- size: 2048,
- packageId: "TEST_APP_ID",
- sharedURI: "/usr/local/share/player",
- operation: "http://tizen.org/appcontrol/operation/play",
- appControl: {
- uri: "http://tizen.org/appcontrol/uri/play",
- mime: "video/*",
- category: "media",
- data: ""
- },
- type: "AUTHOR_SIGNER",
- value: []
- },
- "http://tizen.org/dummy": {
- id: "http://tizen.org/dummy",
- name: "Tizen dummy",
- iconPath: "dummy.png",
- version: "1.7",
- show: true,
- categories: ["media"],
- size: 3094,
- packageId: "EXAMPLE_ID",
- sharedURI: "/usr/local/share/dummy",
- operation: "http://tizen.org/appcontrol/operation/dummy",
- appControl: {
- uri: "http://tizen.org/appcontrol/uri/dummy",
- mime: "video/*",
- category: "media",
- data: ""
- },
- type: "AUTHOR_SIGNER",
- value: []
- },
- "http://tizen.org/dialer": {
- id: "http://tizen.org/dialer",
- name: "Tizen dialer",
- iconPath: "002.png",
- version: "2.1",
- show: true,
- categories: ["dialer"],
- size: 2048,
- packageId: "SAMPLE_ID",
- sharedURI: "/usr/local/share/dialer",
- operation: "http://tizen.org/appcontrol/operation/call",
- appControl: {
- uri: "http://tizen.org/appcontrol/uri/call",
- mime: "application/xml",
- category: "dialer",
- data: ""
- },
- type: "AUTHOR_ROOT",
- value: []
- },
- "http://tizen.org/sender": {
- id: "http://tizen.org/sender",
- name: "Tizen sender",
- iconPath: "005.png",
- version: "2.2",
- show: true,
- categories: ["message"],
- size: 2048,
- packageId: "SAMPLE_ID",
- sharedURI: "/usr/local/share/sender",
- operation: "http://tizen.org/appcontrol/operation/send_text",
- appControl: {
- uri: "http://tizen.org/appcontrol/uri/send_text",
- mime: "text/plain",
- category: "message",
- data: ""
- },
- type: "AUTHOR_ROOT",
- value: []
- },
- "api1pack00.WebAPITizenPackageTests": {
- id: "api1pack00.WebAPITizenPackageTests",
- name: "Tizen test app",
- iconPath: "001.png",
- version: "2.2",
- show: true,
- categories: ["message"],
- size: 2048,
- packageId: "api1pack00",
- sharedURI: "/usr/local/share/apiuri",
- operation: "http://tizen.org/appcontrol/operation/test",
- appControl: {
- uri: "http://tizen.org/appcontrol/uri/test",
- mime: "text/plain",
- category: "message",
- data: ""
- },
- type: "AUTHOR_ROOT",
- value: []
- },
- "testpack00.autoWebapiTizenPackageTestApplication": {
- id: "testpack00.autoWebapiTizenPackageTestApplication",
- name: "Tizen test app 2",
- iconPath: "002.png",
- version: "3.0",
- show: true,
- categories: ["message"],
- size: 2048,
- packageId: "testpack00",
- sharedURI: "/usr/local/share/apiuri2",
- operation: "http://tizen.org/appcontrol/operation/test2",
- appControl: {
- uri: "http://tizen.org/appcontrol/uri/test2",
- mime: "text/plain",
- category: "message",
- data: ""
- },
- type: "AUTHOR_ROOT",
- value: []
- }
- },
- _installedAppList = {
- "http://tizen.org/dialer": {
- id: "http://tizen.org/dialer",
- name: "Tizen dialer",
- iconPath: "002.png",
- version: "2.1",
- show: true,
- categories: ["dialer"],
- installDate: new Date(),
- size: 2048,
- packageId: "SAMPLE_ID",
- sharedURI: "/usr/local/share/dialer",
- operation: "http://tizen.org/appcontrol/operation/call",
- appControl: {
- uri: "http://tizen.org/appcontrol/uri/call",
- mime: "application/xml",
- category: "dialer",
- data: ""
- },
- type: "AUTHOR_ROOT",
- value: []
- },
- "http://tizen.org/sender": {
- id: "http://tizen.org/sender",
- name: "Tizen sender",
- iconPath: "005.png",
- version: "2.2",
- show: true,
- categories: ["message"],
- installDate: new Date(),
- size: 2048,
- packageId: "SAMPLE_ID",
- sharedURI: "/usr/local/share/sender",
- operation: "http://tizen.org/appcontrol/operation/send_text",
- appControl: {
- uri: "http://tizen.org/appcontrol/uri/send_text",
- mime: "text/plain",
- category: "message",
- data: ""
- },
- type: "AUTHOR_ROOT",
- value: []
- },
- "api1pack00.WebAPITizenPackageTests": {
- id: "api1pack00.WebAPITizenPackageTests",
- name: "Tizen test app",
- iconPath: "001.png",
- version: "2.2",
- show: true,
- categories: ["message"],
- installDate: new Date(),
- size: 2048,
- packageId: "api1pack00",
- sharedURI: "/usr/local/share/apiuri",
- operation: "http://tizen.org/appcontrol/operation/test",
- appControl: {
- uri: "http://tizen.org/appcontrol/uri/test",
- mime: "text/plain",
- category: "message",
- data: ""
- },
- type: "AUTHOR_ROOT",
- value: []
- },
- "testpack00.autoWebapiTizenPackageTestApplication": {
- id: "testpack00.autoWebapiTizenPackageTestApplication",
- name: "Tizen test app 2",
- iconPath: "002.png",
- version: "3.0",
- show: true,
- categories: ["message"],
- installDate: new Date(),
- size: 2048,
- packageId: "testpack00",
- sharedURI: "/usr/local/share/apiuri2",
- operation: "http://tizen.org/appcontrol/operation/test2",
- appControl: {
- uri: "http://tizen.org/appcontrol/uri/test2",
- mime: "text/plain",
- category: "message",
- data: ""
- },
- type: "AUTHOR_ROOT",
- value: []
- }
- };
+ _apps,
+ _installedAppList;
function _get() {
_data = db.retrieveObject(DB_APPLICATION_KEY);
if (_data === undefined) {
_data = {
- appList : _apps,
+ appList: _apps,
installedAppList: _installedAppList
};
- _save();
}
}
});
jQuery("#application-installed-box").accordion("destroy");
jQuery("#application-installed-box").html(html).accordion({
- active : false,
- collapsible : true,
- autoHeight : false
+ active: false,
+ collapsible: true,
+ autoHeight: false
});
}
installDate: new Date(),
size: item.size,
packageId: item.packageId,
+ sharedURI: item.sharedURI,
operation: item.operation,
appControl: {
uri: item.appControl.uri,
_loadInstalledAppList();
}
+event.on("install-current-app", function (item) {
+ _data.installedAppList[item.id] = {
+ id: item.id,
+ name: item.name,
+ iconPath: item.iconPath,
+ version: item.version,
+ show: item.show,
+ categories: item.categories,
+ installDate: item.installDate,
+ size: item.size,
+ packageId: item.packageId,
+ sharedURI: item.sharedURI,
+ operation: item.operation,
+ appControl: {
+ uri: item.appControl.uri,
+ mime: item.appControl.mime,
+ category: item.appControl.category,
+ data: item.appControl.data
+ },
+ type: item.type,
+ value: item.value
+ };
+ _loadInstalledAppList();
+});
+
event.on("appServiceReplied", function () {
_displayInfo("The application has been launched successfully");
});
module.exports = {
initialize: function () {
+ _apps = dbinit.Application.apps;
+ _installedAppList = dbinit.Application.installedAppList;
_appInstalledTemplate = jQuery("#application-installed-template").html();
_get();
+ _save();
_loadInstalledAppList();
}
};
jQuery("#service-transfer-textarea-" + addr).val("");
jQuery("#service-receive-textarea-" + addr).html("");
});
+
+ //Default "Tizen Phone" is nearby
+ _btSimulatedDevs["22:33:44:12:34:56"] = btdevices["22:33:44:12:34:56"];
+ db.saveObject("bt-simulated-devices", _btSimulatedDevs);
+ _btRender();
}
};
var db = require('ripple/db'),
utils = require('ripple/utils'),
event = require('ripple/event'),
+ dbinit = require('ripple/platform/tizen/2.0/dbinit'),
PackageInformation = require('ripple/platform/tizen/2.0/PackageInformation'),
DB_PACKAGE_KEY = "tizen-db-package",
_data = {
packageList: {},
installedList: {}
},
- _packages = {
- "/opt/usr/media/test.wgt": {id: "TEST_APP_ID", name: "Test Package", iconPath: "test.png", version: "2.1",
- totalSize: 9216, dataSize: 124, author: "Tizen.org", description: "This is testing package",
- appIds: ["http://tizen.org/viewer", "http://tizen.org/player"]},
- "/opt/usr/media/example.wgt": {id: "EXAMPLE_ID", name: "Example Package", iconPath: "example.png", version: "2.3",
- totalSize: 10240, dataSize: 384, author: "Tizen.org", description: "This is example package",
- appIds: ["http://tizen.org/dummy"]},
- "/opt/usr/media/sample.wgt": {id: "SAMPLE_ID", name: "Sample Package", iconPath: "sample.png", version: "1.9",
- totalSize: 8264, dataSize: 50, author: "Tizen.org", description: "This is sample package",
- appIds: ["http://tizen.org/dialer", "http://tizen.org/sender"]},
- "/opt/usr/media/api1pack00.wgt": {
- id: "api1pack00", name: "tct-package-tizen-tests",
- iconPath: "tizen.png", version: "1.9",
- totalSize: 8264, dataSize: 50, author: "TizenDev",
- description: "This is a description which is used in tests.",
- appIds: ["api1pack00.WebAPITizenPackageTests"]},
- "/opt/usr/media/testpack00.wgt": {
- id: "testpack00", name: "autoWebapiTizenPackageTestApplication",
- iconPath: "tizen.png", version: "5.5.5",
- totalSize: 8264, dataSize: 50, author: "TizenDev",
- description: "This is a description which is used in tests.",
- appIds: ["testpack00.autoWebapiTizenPackageTestApplication"]}
- },
- _installedList = {
- "SAMPLE_ID": { id: "SAMPLE_ID", name: "Sample Package", iconPath: "sample.png", version: "1.9",
- totalSize: 8264, dataSize: 50, lastModified: new Date(), author: "Tizen.org", description: "This is sample package",
- appIds: ["http://tizen.org/dialer", "http://tizen.org/sender"]
- },
- "api1pack00": {id: "api1pack00", name: "tct-package-tizen-tests",
- iconPath: "tizen.png", version: "1.9",
- totalSize: 8264, dataSize: 50, lastModified: new Date(),
- author: "TizenDev",
- description: "This is a description which is used in tests.",
- appIds: ["api1pack00.WebAPITizenPackageTests"]
- },
- "testpack00": {id: "testpack00", name: "autoWebapiTizenPackageTestApplication",
- iconPath: "tizen.png", version: "5.5.5",
- totalSize: 8264, dataSize: 50, lastModified: new Date(),
- author: "TizenDev",
- description: "This is a description which is used in tests.",
- appIds: ["testpack00.autoWebapiTizenPackageTestApplication"]
- }
-
- },
+ _currentPackageId = null,
+ _packages,
+ _installedList,
_packageListTemplate,
_packageInstalledTemplate;
packageList: _packages,
installedList: _installedList
};
- _save();
}
utils.forEach(_data.installedList, function (item) {
item.lastModified = new Date(item.lastModified);
});
-
}
function _save() {
});
$("#package-installed-box").accordion("destroy");
$("#package-installed-box").html(html).accordion({
- active : false,
- collapsible : true,
- autoHeight : false
+ active: false,
+ collapsible: true,
+ autoHeight: false
});
$("." + "package-remove-btn").bind("click", function () {
var id = this.id;
+ if (id === _currentPackageId) {
+ $("#msg-" + id).html("Can't Uninstall:<br> Package including running app");
+ setTimeout(function () {
+ $("#msg-" + id).text("");
+ }, 5000);
+ return;
+ }
utils.forEach(_data.packageList, function (item) {
if (item.id === id) {
event.trigger("remove-apps", [item.appIds]);
display: true
},
initialize: function () {
+ _packages = dbinit.Package.packages;
+ _installedList = dbinit.Package.installedList;
_packageListTemplate = jQuery("#package-list-template").html();
_packageInstalledTemplate = jQuery("#package-installed-template").html();
_get();
+ _save();
loadPackageList();
loadInstalledList();
jQuery("#package-list-select").bind("focus change", function () {
loadPackageList();
loadInstalledList();
});
+ event.on("install-current-package", function (item) {
+ _data.installedList[item.id] = new PackageInformation(
+ item.id, item.name, item.iconPath, item.version,
+ item.totalSize, item.dataSize, item.lastModified,
+ item.author, item.description, item.appIds);
+ _currentPackageId = item.id;
+ loadInstalledList();
+ });
}
};
cosX = Math.cos(gamma * (Math.PI / 180));
sinX = Math.sin(gamma * (Math.PI / 180));
- cosY = Math.cos(beta * (Math.PI / 180));
+ cosY = Number(Math.cos(beta * (Math.PI / 180)).toFixed(6));
sinY = Math.sin(beta * (Math.PI / 180));
x = 9.81 * cosY * sinX;
y = -9.81 * sinY;
var version = db.retrieve(constants.RELEASE_VERSION);
// version: 20121115 is the first release version
- if (version === null || version === undefined || Number(version) < 20130417) {
+ if (version === null || version === undefined || Number(version) < 20130722) {
db.remove(constants.COMMON.APPLICATION_STATE + "tizen");
db.remove(constants.COMMON.APPLICATION_STATE + "cordova");
db.remove("tizen1-db-application");
db.remove("tizen-db-package");
- version = 20130417;
+ version = 20130722;
db.save(constants.RELEASE_VERSION, version);
}
}