From 4a783e5677800e48ff93e20896b08f090048d64f Mon Sep 17 00:00:00 2001 From: Robert Karolak Date: Tue, 20 Jan 2015 15:59:38 +0100 Subject: [PATCH] [Messaging] Fixes for emails part 2 [Verification] More test passes Change-Id: Ie00dedeb7b71c6ad85d04fc2dc8526708aa4ac0e Signed-off-by: Robert Karolak --- src/messaging/message.cc | 29 +++++++++++++++++++++++++++-- src/messaging/messaging_api.js | 8 ++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/messaging/message.cc b/src/messaging/message.cc index a69f04d..f237a85 100644 --- a/src/messaging/message.cc +++ b/src/messaging/message.cc @@ -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; diff --git a/src/messaging/messaging_api.js b/src/messaging/messaging_api.js index 07a0686..716ec57 100644 --- a/src/messaging/messaging_api.js +++ b/src/messaging/messaging_api.js @@ -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', -- 2.7.4