var native = new xwalk.utils.NativeManager(extension);
var privUtils_ = xwalk.utils;
-function throwException_(err) {
- throw new WebAPIException(err.code, err.name, err.message);
-}
-
var Property = {
- W: 1 << 0, // WRITABLE
- E: 1 << 1, // ENUMERABLE
- C: 1 << 2 // CONFIGURABLE
+ WRITEABLE: 1 << 0,
+ ENUMERABLE: 1 << 1,
+ CONFIGURABLE: 1 << 2
};
function addTypeToFilter_(data) {
return filter;
}
-/**
- * Example usage:
- * function Messaging () {
- * propertyFactory_(this, 'ids', [2,3,4], Property.W | Property.E | Property.C);
- * propertyFactory_(this, 'name', 'Name', Property.E);
- * propertyFactory_(this, 'age', 25, Property.W);
- * propertyFactory_(this, 'something', 1);
- * propertyFactory_(this, 'getSomething', Property.E, {get: function(){return 100;}});
- * }
- * Will produce:
- * var m = new Messaging();
- * {
- * id: [2,3,4],
- * name: 'Name',
- * age: 25
- * }
- *
- * m.name = 'A brand new name';
- * privUtils_.log(m.name); // Name
- */
function propertyFactory_(that, name, value, flags, options) {
flags = flags || 0;
if (options === null || typeof options !== 'object') {
if (!options.get && !options.set) {
options.value = value;
}
- if ((flags & Property.W) != 0) {
+ if ((flags & Property.WRITEABLE) != 0) {
options.writable = true;
}
- if ((flags & Property.E) != 0) {
+ if ((flags & Property.ENUMERABLE) != 0) {
options.enumerable = true;
}
- if ((flags & Property.C) != 0) {
+ if ((flags & Property.CONFIGURABLE) != 0) {
options.configurable = true;
}
Object.defineProperty(that, name, options);
}
}
-/**
- * Specifies the Messaging service tags.
- */
-var MessageServiceTag = ['messaging.sms', 'messaging.mms', 'messaging.email'];
+var MessageServiceTag = {
+ SMS: 'messaging.sms',
+ MMS: 'messaging.mms',
+ EMAIL: 'messaging.email'
+};
function Message(type, data) {
- if (!(this instanceof Message)) {
- throw new TypeError('Constructor called like a function');
- }
- if (MessageServiceTag.indexOf(type) === -1) {
+ privUtils_.deprecationWarn(
+ 'Message() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
+ validator_.isConstructorCall(this, Message);
+
+ if (Object.values(MessageServiceTag).indexOf(type) == -1) {
throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
+
if (!data || typeof data !== 'object') {
- // 'data' is optional
data = {};
}
- // set initial data from internal MessageInit_ object or to default values
var internal = data instanceof MessageInit_,
id = internal ? data.id : null,
conversationId = internal ? data.conversationId : null,
hasAttachment = internal ? data.hasAttachment : false,
isRead = internal ? data.isRead : false,
inResponseTo = internal ? data.inResponseTo : null;
- // create MessageBody object
+
var body = new MessageBody({
messageId: id,
plainBody: data.plainBody,
htmlBody: data.htmlBody
});
- // check 'to', 'cc' and 'bcc' fields
+
var to = data.to;
if (!(to instanceof Array)) {
to = [];
}
+
var cc = data.cc;
if (!(cc instanceof Array)) {
cc = [];
}
+
var bcc = data.bcc;
if (!(bcc instanceof Array)) {
bcc = [];
}
- // 'attachments' private variable, getter and setter
+
var attachments = (internal ? data.attachments : []) || [];
var _internal = {
inResponseTo: inResponseTo || null,
attachments: attachments
};
- // id
+
Object.defineProperty(this, 'id', {
get: function() {
return _internal.id;
enumerable: true
});
- //conversationId
Object.defineProperty(this, 'conversationId', {
get: function() {
return _internal.conversationId;
enumerable: true
});
- // folderId
Object.defineProperty(this, 'folderId', {
get: function() {
return _internal.folderId;
enumerable: true
});
- // type
Object.defineProperty(this, 'type', {
get: function() {
return _internal.type;
enumerable: true
});
- // timestamp
Object.defineProperty(this, 'timestamp', {
get: function() {
return _internal.timestamp
enumerable: true
});
- // from
Object.defineProperty(this, 'from', {
get: function() {
return _internal.from;
enumerable: true
});
- // to
Object.defineProperty(this, 'to', {
get: function() {
return _internal.to;
enumerable: true
});
- // cc
Object.defineProperty(this, 'cc', {
get: function() {
return _internal.cc;
enumerable: true
});
- // bcc
Object.defineProperty(this, 'bcc', {
get: function() {
return _internal.bcc;
enumerable: true
});
- // body
Object.defineProperty(this, 'body', {
get: function() {
return _internal.body;
enumerable: true
});
- // isRead
Object.defineProperty(this, 'isRead', {
get: function() {
return _internal.isRead;
enumerable: true
});
- // hasAttachment
Object.defineProperty(this, 'hasAttachment', {
get: function() {
return _internal.attachments.length > 0;
enumerable: true
});
- // isHighPriority
Object.defineProperty(this, 'isHighPriority', {
get: function() {
return _internal.isHighPriority;
enumerable: true
});
- // subject
Object.defineProperty(this, 'subject', {
get: function() {
return _internal.subject;
enumerable: true
});
- // inResponseTo
Object.defineProperty(this, 'inResponseTo', {
get: function() {
return _internal.inResponseTo;
enumerable: true
});
- // messageStatus
Object.defineProperty(this, 'messageStatus', {
get: function() {
if (_internal.id) {
enumerable: true
});
- // attachments
Object.defineProperty(this, 'attachments', {
get: function() {
return _internal.attachments;
});
}
-function MessageInit(data) {
- if (!(this instanceof MessageInit)) {
- return new MessageInit(data);
- }
- if (data === null || typeof data !== 'object') {
- data = {};
- }
- propertyFactory_(this, 'subject', data.subject || '', Property.E | Property.W);
- propertyFactory_(this, 'to', data.to || [], Property.E | Property.W);
- propertyFactory_(this, 'cc', data.cc || [], Property.E | Property.W);
- propertyFactory_(this, 'bcc', data.bcc || [], Property.E | Property.W);
- propertyFactory_(this, 'plainBody', data.plainBody || '', Property.E | Property.W);
- propertyFactory_(this, 'htmlBody', data.htmlBody || '', Property.E | Property.W);
- propertyFactory_(
- this,
- 'isHighPriority',
- data.isHighPriority || false,
- Property.E | Property.W
- );
-}
-
function MessageInit_(data) {
if (!(this instanceof MessageInit_)) {
return new MessageInit_(data);
inlineAttachments: data.inlineAttachments || []
};
- // messageId
Object.defineProperty(this, 'messageId', {
get: function() {
return _internal.messageId;
enumerable: true
});
- // loaded
Object.defineProperty(this, 'loaded', {
get: function() {
return _internal.loaded;
enumerable: true
});
- // plainBody
Object.defineProperty(this, 'plainBody', {
get: function() {
return _internal.plainBody;
enumerable: true
});
- // htmlBody
Object.defineProperty(this, 'htmlBody', {
get: function() {
return _internal.htmlBody;
enumerable: true
});
- // inlineAttachments
Object.defineProperty(this, 'inlineAttachments', {
get: function() {
return _internal.inlineAttachments;
var messageAttachmentsLoaded = {};
function MessageAttachment(first, second) {
+ privUtils_.deprecationWarn(
+ 'MessageAttachment() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
validator_.isConstructorCall(this, MessageAttachment);
if (!this instanceof MessageAttachment) {
return new MessageAttachment(data);
filePath: internalConstructor ? first.filePath : first
};
- // messageId
Object.defineProperty(this, 'messageId', {
get: function() {
return _internal.messageId;
},
enumerable: true
});
- // id
+
Object.defineProperty(this, 'id', {
get: function() {
return _internal.id;
},
enumerable: true
});
- // mimeType
+
Object.defineProperty(this, 'mimeType', {
get: function() {
return _internal.mimeType;
},
enumerable: true
});
- // filePath
+
Object.defineProperty(this, 'filePath', {
get: function() {
if (_internal.id && !messageAttachmentsLoaded[_internal.id]) {
function Messaging() {}
-/**
- * Gets the messaging service of a given type for a given account.
- * @param {!MessageServiceTag} messageServiceType Type of the services to be retrieved.
- * @param {!MessageServiceArraySuccessCallback} successCallback Callback function that
- * is called when the services are successfully retrieved.
- * @param {ErrorCallback} errorCallback Callback function that is called when
- * an error occurs.
- */
Messaging.prototype.getMessageServices = function() {
+ privUtils_.deprecationWarn(
+ 'getMessageServices() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
- { name: 'messageServiceType', type: types_.ENUM, values: MessageServiceTag },
+ {
+ name: 'messageServiceType',
+ type: types_.ENUM,
+ values: Object.values(MessageServiceTag)
+ },
{ name: 'successCallback', type: types_.FUNCTION },
{ name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true }
]);
function MessageStorage() {}
function MessageService(data) {
- propertyFactory_(this, 'id', data.id, Property.E);
- propertyFactory_(this, 'type', data.type, Property.E);
- propertyFactory_(this, 'name', data.name, Property.E);
- propertyFactory_(this, 'messageStorage', new MessageStorage(this), Property.E);
+ propertyFactory_(this, 'id', data.id, Property.ENUMERABLE);
+ propertyFactory_(this, 'type', data.type, Property.ENUMERABLE);
+ propertyFactory_(this, 'name', data.name, Property.ENUMERABLE);
+ propertyFactory_(
+ this,
+ 'messageStorage',
+ new MessageStorage(this),
+ Property.ENUMERABLE
+ );
}
MessageService.prototype.sendMessage = function() {
+ privUtils_.deprecationWarn(
+ 'sendMessage() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{ name: 'message', type: types_.PLATFORM_OBJECT, values: tizen.Message },
{
};
MessageService.prototype.loadMessageBody = function() {
+ privUtils_.deprecationWarn(
+ 'loadMessageBody() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{ name: 'message', type: types_.PLATFORM_OBJECT, values: tizen.Message },
{ name: 'successCallback', type: types_.FUNCTION },
}
};
MessageService.prototype.loadMessageAttachment = function() {
+ privUtils_.deprecationWarn(
+ 'loadMessageAttachment() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{ name: 'attachment', type: types_.PLATFORM_OBJECT, values: MessageAttachment },
{ name: 'successCallback', type: types_.FUNCTION },
};
MessageService.prototype.sync = function() {
+ privUtils_.deprecationWarn(
+ 'sync() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{
name: 'successCallback',
};
MessageService.prototype.syncFolder = function() {
+ privUtils_.deprecationWarn(
+ 'syncFolder() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{ name: 'folder', type: types_.PLATFORM_OBJECT, values: MessageFolder },
{
};
MessageService.prototype.stopSync = function() {
+ privUtils_.deprecationWarn(
+ 'stopSync() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [{ name: 'opId', type: types_.LONG }]);
var self = this;
}
MessageStorage.prototype.addDraftMessage = function() {
+ privUtils_.deprecationWarn(
+ 'addDraftMessage() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{ name: 'message', type: types_.PLATFORM_OBJECT, values: tizen.Message },
{
};
MessageStorage.prototype.findMessages = function() {
+ privUtils_.deprecationWarn(
+ 'findMessages() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{
name: 'filter',
};
MessageStorage.prototype.removeMessages = function() {
+ privUtils_.deprecationWarn(
+ 'removeMessages() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{ name: 'messages', type: types_.ARRAY, values: Message },
{
};
MessageStorage.prototype.updateMessages = function() {
+ privUtils_.deprecationWarn(
+ 'updateMessages() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{ name: 'messages', type: types_.ARRAY, values: Message },
{
};
MessageStorage.prototype.findConversations = function() {
+ privUtils_.deprecationWarn(
+ 'findConversations() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{
name: 'filter',
};
MessageStorage.prototype.removeConversations = function() {
+ privUtils_.deprecationWarn(
+ 'removeConversations() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{ name: 'conversations', type: types_.ARRAY },
{
};
MessageStorage.prototype.findFolders = function() {
+ privUtils_.deprecationWarn(
+ 'findFolders() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{
name: 'filter',
);
MessageStorage.prototype.addMessagesChangeListener = function() {
+ privUtils_.deprecationWarn(
+ 'addMessagesChangeListener() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{
name: 'messagesChangeCallback',
};
MessageStorage.prototype.addConversationsChangeListener = function() {
+ privUtils_.deprecationWarn(
+ 'addConversationsChangeListener() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{
name: 'conversationsChangeCallback',
};
MessageStorage.prototype.addFoldersChangeListener = function() {
+ privUtils_.deprecationWarn(
+ 'addFoldersChangeListener() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{
name: 'foldersChangeCallback',
};
MessageStorage.prototype.removeChangeListener = function() {
+ privUtils_.deprecationWarn(
+ 'removeChangeListener() is deprecated and will be ' +
+ 'removed from next release without any alternatives. ',
+ '8.0'
+ );
var args = validator_.validateArgs(arguments, [
{ name: 'watchId', type: types_.LONG }
]);
};
function MessageConversation(data) {
- propertyFactory_(this, 'id', data.id || null, Property.E);
- propertyFactory_(this, 'type', data.type || '', Property.E);
+ propertyFactory_(this, 'id', data.id || null, Property.ENUMERABLE);
+ propertyFactory_(this, 'type', data.type || '', Property.ENUMERABLE);
propertyFactory_(
this,
'timestamp',
data.timestamp ? new Date(data.timestamp * 1000) : null,
- Property.E
+ Property.ENUMERABLE
+ );
+ propertyFactory_(this, 'messageCount', data.messageCount || 0, Property.ENUMERABLE);
+ propertyFactory_(
+ this,
+ 'unreadMessages',
+ data.unreadMessages || 0,
+ Property.ENUMERABLE
+ );
+ propertyFactory_(this, 'preview', data.preview || '', Property.ENUMERABLE);
+ propertyFactory_(this, 'subject', data.subject || '', Property.ENUMERABLE);
+ propertyFactory_(this, 'isRead', data.isRead || false, Property.ENUMERABLE);
+ propertyFactory_(this, 'from', data.from || null, Property.ENUMERABLE);
+ propertyFactory_(this, 'to', data.to || [], Property.ENUMERABLE);
+ propertyFactory_(this, 'cc', data.cc || [], Property.ENUMERABLE);
+ propertyFactory_(this, 'bcc', data.bcc || [], Property.ENUMERABLE);
+ propertyFactory_(
+ this,
+ 'lastMessageId',
+ data.lastMessageId || null,
+ Property.ENUMERABLE
);
- propertyFactory_(this, 'messageCount', data.messageCount || 0, Property.E);
- propertyFactory_(this, 'unreadMessages', data.unreadMessages || 0, Property.E);
- propertyFactory_(this, 'preview', data.preview || '', Property.E);
- propertyFactory_(this, 'subject', data.subject || '', Property.E);
- propertyFactory_(this, 'isRead', data.isRead || false, Property.E);
- propertyFactory_(this, 'from', data.from || null, Property.E);
- propertyFactory_(this, 'to', data.to || [], Property.E);
- propertyFactory_(this, 'cc', data.cc || [], Property.E);
- propertyFactory_(this, 'bcc', data.bcc || [], Property.E);
- propertyFactory_(this, 'lastMessageId', data.lastMessageId || null, Property.E);
}
function MessageFolder(data) {