[Messaging] Fixes for emails part 2
authorRobert Karolak <r.karolak@samsung.com>
Tue, 20 Jan 2015 14:59:38 +0000 (15:59 +0100)
committerJerzy Pabich <j.pabich@samsung.com>
Thu, 22 Jan 2015 12:30:47 +0000 (21:30 +0900)
[Verification] More test passes

Change-Id: Ie00dedeb7b71c6ad85d04fc2dc8526708aa4ac0e
Signed-off-by: Robert Karolak <r.karolak@samsung.com>
src/messaging/message.cc
src/messaging/messaging_api.js

index a69f04d..f237a85 100644 (file)
@@ -375,8 +375,33 @@ std::string copyFileToTemp(const std::string& sourcePath)
         throw common::UnknownException("Unknown error while creating temp directory.");
     }
 
-    if(EINA_TRUE != ecore_file_cp(attPath.c_str(), tmpPath.c_str())) {
-        throw common::UnknownException("Unknown error while copying file to temp.");
+    FILE *f1, *f2;
+    size_t num;
+    int ret = 1;
+
+    f1 = fopen(attPath.c_str(), "rb");
+    if (!f1) {
+        LoggerE("Fail open attPath");
+        return 0;
+    }
+    f2 = fopen(tmpPath.c_str(), "wb");
+    if (!f2) {
+        LoggerE("Fail open tmpPath");
+        fclose (f1);
+        return 0;
+    }
+
+    while ((num = fread(buf, 1, sizeof(buf), f1)) > 0) {
+        if (fwrite(buf, 1, num, f2) != num)
+            ret = 0;
+    }
+
+    fclose (f1);
+    fclose (f2);
+
+    if(EINA_TRUE != ret /*ecore_file_cp(attPath.c_str(), tmpPath.c_str())*/) {
+        std::string error = "Unknown error while copying file to temp. ";
+        throw common::UnknownException(error.c_str());
     }
 
     return dirPath;
index 07a0686..716ec57 100644 (file)
@@ -34,7 +34,7 @@ CommonFS.toRealPath = function (aPath) {
         _uriPrefix = 'file://',
         i;
     if (aPath.indexOf(_uriPrefix) === 0) {
-        _fileRealPath = aPath; /*.substr(_uriPrefix.length);*/
+        _fileRealPath = aPath.substr(_uriPrefix.length);
     } else if (aPath[0] != '/') {
         //virtual path$
         var _pathTokens = aPath.split('/');
@@ -137,7 +137,7 @@ var MessageServiceTag = ['messaging.sms', 'messaging.mms', 'messaging.email'];
 
 function Message(type, data) {
     if (!(this instanceof Message)) {
-        return new Message(type, data);
+        throw new TypeError("Constructor called like a function");
     }
     if (MessageServiceTag.indexOf(type) === -1) {
         throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
@@ -860,6 +860,10 @@ 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',