[messaging] Remove unused class MessageInit. 21/217221/2
authorMichal Michalski <m.michalski2@partner.samsung.com>
Thu, 7 Nov 2019 14:48:03 +0000 (15:48 +0100)
committerMichal Michalski <m.michalski2@partner.samsung.com>
Fri, 8 Nov 2019 10:00:43 +0000 (11:00 +0100)
[Verification] tct-messaging-*-tizen-tests on tm1

Signed-off-by: Michal Michalski <m.michalski2@partner.samsung.com>
Change-Id: Iba06a2a88b2d5ddec8a4b1f15ffa78e584dcf638

src/messaging/messaging_api.js

index e8c66ed..65c0005 100755 (executable)
@@ -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 }
     ]);