From: Michal Michalski Date: Thu, 7 Nov 2019 14:48:03 +0000 (+0100) Subject: [messaging] Remove unused class MessageInit. X-Git-Tag: submit/tizen/20191122.072959~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F21%2F217221%2F2;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [messaging] Remove unused class MessageInit. [Verification] tct-messaging-*-tizen-tests on tm1 Signed-off-by: Michal Michalski Change-Id: Iba06a2a88b2d5ddec8a4b1f15ffa78e584dcf638 --- diff --git a/src/messaging/messaging_api.js b/src/messaging/messaging_api.js index e8c66ed1..65c0005b 100755 --- a/src/messaging/messaging_api.js +++ b/src/messaging/messaging_api.js @@ -92,21 +92,23 @@ function updateInternal_(internal, data) { } } -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) { + 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, @@ -116,26 +118,28 @@ function Message(type, data) { 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 = { @@ -381,27 +385,6 @@ function Message(type, data) { }); } -function MessageInit(data) { - if (!(this instanceof MessageInit)) { - return new MessageInit(data); - } - if (data === null || typeof data !== 'object') { - data = {}; - } - propertyFactory_(this, 'subject', data.subject || '', Property.ENUMERABLE | Property.WRITEABLE); - propertyFactory_(this, 'to', data.to || [], Property.ENUMERABLE | Property.WRITEABLE); - propertyFactory_(this, 'cc', data.cc || [], Property.ENUMERABLE | Property.WRITEABLE); - propertyFactory_(this, 'bcc', data.bcc || [], Property.ENUMERABLE | Property.WRITEABLE); - propertyFactory_(this, 'plainBody', data.plainBody || '', Property.ENUMERABLE | Property.WRITEABLE); - propertyFactory_(this, 'htmlBody', data.htmlBody || '', Property.ENUMERABLE | Property.WRITEABLE); - propertyFactory_( - this, - 'isHighPriority', - data.isHighPriority || false, - Property.ENUMERABLE | Property.WRITEABLE - ); -} - function MessageInit_(data) { if (!(this instanceof MessageInit_)) { return new MessageInit_(data); @@ -588,7 +571,7 @@ function Messaging() {} Messaging.prototype.getMessageServices = function() { 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 } ]);