[Messaging] Fixing the problem with the prefix file:// in attachments
authorAndrzej Popowski <a.popowski@samsung.com>
Tue, 27 Jan 2015 08:39:59 +0000 (09:39 +0100)
committerJerzy Pabich <j.pabich@samsung.com>
Wed, 28 Jan 2015 08:05:01 +0000 (17:05 +0900)
Change-Id: I3520a686c3db93b43af3b554474f80dce3313668
Signed-off-by: Andrzej Popowski <a.popowski@samsung.com>
src/messaging/message_attachment.cc
src/messaging/messaging_api.js

index d529af09cc53b96d7644a504091ff8433e9bd0cd..d5e261a75be7037185ca363cd12f38a219e6a63f 100755 (executable)
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include <ctype.h>
 #include "message_attachment.h"
 
 #include "common/logger.h"
@@ -124,7 +125,16 @@ std::string MessageAttachment::getShortFileName() const
 
 void MessageAttachment::setFilePath(const std::string &value)
 {
-    m_filePath = value;
+    std::string tmp = value;
+    // change to lower case
+    for (int i = 0; i < tmp.length() && i < 4; i++) {
+        tmp[i] = tolower(tmp[i]);
+    }
+    if (tmp.find("file://") != std::string::npos) {
+        m_filePath = value.substr(7);
+    } else {
+        m_filePath = value;
+    }
     m_isFilePathSet = true;
 }
 
index 8243ea9b2d8f822e707a355e9eff5415a54d1b1e..d4bfbfca86d73679046c38b9a0b3b2d4b63b22f7 100644 (file)
@@ -6,6 +6,7 @@
 
 var validator_ = xwalk.utils.validator;
 var types_ = validator_.Types;
+var T_ = xwalk.utils.type;
 var bridge = xwalk.utils.NativeBridge(extension, true);
 
 function throwException_(err) {
@@ -453,7 +454,8 @@ function Message(type, data) {
                     if (value.length < _internal.length) {
                         _internal.splice(value.length, _internal.length - value.length);
                     }
-                } else {
+                    _internal.attachments = value;
+                } else if (T_.isArray(value)) {
                     for (var k = 0; k < value.length; ++k) {
                         if (!(value[k] instanceof tizen.MessageAttachment)) {
                             return;
@@ -920,10 +922,6 @@ MessageService.prototype.stopSync = function () {
         {name: 'opId', type: types_.LONG}
     ]);
 
-    if(arguments.opId === undefined){
-        throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
-    }
-
     var self = this;
     bridge.sync({
         cmd: 'MessageService_stopSync',