BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(xrandr)
+BuildRequires: pkgconfig(ecore)
BuildRequires: python
BuildRequires: pkgconfig(capi-system-info)
BuildRequires: pkgconfig(capi-system-runtime-info)
message->setId(mail_data->mail_id);
message->setMessageStatus(MessageStatus::STATUS_DRAFT);
-// TODO Adding attachments
-// if (message->getHasAttachment()){
-// Message::addEmailAttachments(message);
-// }
+ if (message->getHasAttachment()){
+ Message::addEmailAttachments(message);
+ }
err = email_get_mail_data(message->getId(), &mail_data_final);
if(EMAIL_ERROR_NONE != err) {
#include "message.h"
-//#include "Ecore_File.h"
#include <time.h>
#include <sys/stat.h>
#include <sstream>
#include "common/logger.h"
#include "common/platform_exception.h"
+#include "Ecore_File.h"
#include "message_email.h"
#include "messaging_util.h"
umask(mask);
dirPath = "/tmp/" + std::string(buf);
-// FIXME filesystem is unavalaible
-// if ( sourcePath[0] != '/' ) {
-// attPath = Filesystem::External::fromVirtualPath(sourcePath);
-// } else { // Assuming that the path is a real path
-// attPath = sourcePath;
-// }
-//
-// // Looking for the last occurrence of slash in source path
-// std::size_t slashPos;
-// if ((slashPos = attPath.find_last_of('/')) == std::string::npos) {
-// throw common::UnknownException(
-// "Error while copying file to temp: the source path is invalid.");
-// }
-//
-// fileName = attPath.substr(slashPos + 1);
-// tmpPath = dirPath + "/" + fileName;
-//
-// LoggerD("attPath: %s, tmpPath: %s", attPath.c_str(), tmpPath.c_str());
-// if(EINA_TRUE != ecore_file_mkdir(dirPath.c_str())) {
-// 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.");
-// }
+ if ( sourcePath[0] != '/' ) {
+// FIXME When filesystem will be available
+// attPath = sourcePath; change to attPath = Filesystem::External::fromVirtualPath(sourcePath);
+ attPath = sourcePath;
+ } else { // Assuming that the path is a real path
+ attPath = sourcePath;
+ }
+
+ // Looking for the last occurrence of slash in source path
+ std::size_t slashPos;
+ if ((slashPos = attPath.find_last_of('/')) == std::string::npos) {
+ throw common::UnknownException(
+ "Error while copying file to temp: the source path is invalid.");
+ }
+
+ fileName = attPath.substr(slashPos + 1);
+ tmpPath = dirPath + "/" + fileName;
+
+ LoggerD("attPath: %s, tmpPath: %s", attPath.c_str(), tmpPath.c_str());
+ if(EINA_TRUE != ecore_file_mkdir(dirPath.c_str())) {
+ 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.");
+ }
return dirPath;
}
void removeDirFromTemp(const std::string& dirPath)
{
-// FIXME Eina_File is unavalaible
-// if(EINA_TRUE != ecore_file_rmdir(dirPath.c_str())) {
-// throw common::UnknownException("Unknown error while deleting temp directory.");
-// }
+ if(EINA_TRUE != ecore_file_rmdir(dirPath.c_str())) {
+ throw common::UnknownException("Unknown error while deleting temp directory.");
+ }
}
email_mail_data_t* Message::convertPlatformEmail(std::shared_ptr<Message> message)
if (type == MSG_TYPE_SMS) {
// Set SMS message body text
-// std::shared_ptr<MessageBody> body;
-// body = message->getBody();
-// if (!body->getPlainBody().empty()) {
-// msg_set_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, const_cast<char*>
-// (body->getPlainBody().c_str()), body->getPlainBody().size());
-// }
+ std::shared_ptr<MessageBody> body;
+ body = message->getBody();
+ if (!body->getPlainBody().empty()) {
+ msg_set_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, const_cast<char*>
+ (body->getPlainBody().c_str()), body->getPlainBody().size());
+ }
// Reset SMS recipients
int error = msg_list_clear(msg, MSG_MESSAGE_ADDR_LIST_HND);
throw common::UnknownException("failed to add attachment");
}
-// LoggerD("after MSG_MMS_ATTACH_LIST attachments count is:%d",
-// message->m_attachments.size());
+ LoggerD("after MSG_MMS_ATTACH_LIST attachments count is:%d",
+ message->m_attachments.size());
msg_release_struct(&mms_struct);
}
setSubject(mail.subject);
}
-// TODO fix when MesageBody will be available
-// getBody()->updateBody(mail);
+ getBody()->updateBody(mail);
if (mail.mail_id != mail.thread_id) {
setInResponseTo(mail.thread_id);
setMessageStatus(MessageStatus::STATUS_UNDEFINED);
break;
}
-// TODO fix when Attachment will be available
-// AttachmentPtrVector att = convertEmailToMessageAttachment(mail);
-//
-// setMessageAttachments(att);
+
+ AttachmentPtrVector att = convertEmailToMessageAttachment(mail);
+
+ setMessageAttachments(att);
}
} // messaging
'dbus-1',
'dbus-glib-1',
'capi-system-info',
+ 'ecore',
'tapi',
'vconf'
],
E: 1 << 1, // ENUMERABLE
C: 1 << 2 // CONFIGURABLE
}
+//TODO remove CommonFS when C++ filesystem will be available
+function CommonFS(){};
+CommonFS.cacheVirtualToReal = {
+ 'downloads' : { path: '/opt/usr/media/Downloads'},
+ 'documents' : { path: '/opt/usr/media/Documents'},
+ 'music' : { path: '/opt/usr/media/Sounds'},
+ 'images' : { path: '/opt/usr/media/Images'},
+ 'videos' : { path: '/opt/usr/media/Videos'},
+ 'ringtones' : { path: '/opt/usr/share/settings/Ringtones'}
+};
+
+CommonFS.toRealPath = function (aPath) {
+ var _fileRealPath = '',
+ _uriPrefix = 'file://',
+ i;
+ if (aPath.indexOf(_uriPrefix) === 0) {
+ _fileRealPath = aPath.substr(_uriPrefix.length);
+ } else if (aPath[0] != '/') {
+ //virtual path$
+ var _pathTokens = aPath.split('/');
+ if (this.cacheVirtualToReal[_pathTokens[0]] && (
+ this.cacheVirtualToReal[_pathTokens[0]].state === undefined ||
+ this.cacheVirtualToReal[_pathTokens[0]].state === 'MOUNTED')) {
+ _fileRealPath = this.cacheVirtualToReal[_pathTokens[0]].path;
+ for (i = 1; i < _pathTokens.length; ++i) {
+ _fileRealPath += '/' + _pathTokens[i];
+ }
+ } else {
+ _fileRealPath = aPath;
+ }
+ } else {
+ _fileRealPath = aPath;
+ }
+ console.log("REAL PATH:"+_fileRealPath);
+ return _fileRealPath;
+};
/**
* Example usage:
function MessageAttachment(filePath, mimeType) {
console.dir(this);
+
+ //TODO remove CommonFS.toRealPath function when C++ filesystem will be available
+ filePath = CommonFS.toRealPath(filePath);
if (!this.id) {
propertyFactory_(this, 'id', null, Property.E);
}
htmlBody: "simle html body",
isHightPriority: false
}
-
- var msg = new tizen.Message("messaging.email", initDictionary);
+ msg = new tizen.Message("messaging.email", initDictionary);
+ msg.attachments = [new tizen.MessageAttachment("images/myimage.png", "image/png")];
services[0].messageStorage.addDraftMessage(msg, function(){
console.log("Add draft success");
}, function(){
const char* MESSAGE_BODY_ATTRIBUTE_PLAIN_BODY = "plainBody";
const char* MESSAGE_BODY_ATTRIBUTE_HTML_BODY = "htmlBody";
+const char* MESSAGE_ATTRIBUTE_MESSAGE_ATTACHMENTS = "attachments";
+const char* MESSAGE_ATTACHMENT_ATTRIBUTE_ID = "id";
+const char* MESSAGE_ATTACHMENT_ATTRIBUTE_MESSAGE_ID = "messageId";
+const char* MESSAGE_ATTACHMENT_ATTRIBUTE_MIME_TYPE = "mimeType";
+const char* MESSAGE_ATTACHMENT_ATTRIBUTE_FILE_PATH = "filePath";
+
namespace {
const std::string TYPE_SMS = "messaging.sms";
const std::string TYPE_MMS = "messaging.mms";
message->setBody(body);
- // TODO MessageAttachments
+ AttachmentPtrVector attachments;
+ auto ma = data.at(MESSAGE_ATTRIBUTE_MESSAGE_ATTACHMENTS).get<std::vector<picojson::value>>();
+
+ auto arrayVectorAttachmentConverter = [&attachments] (picojson::value& v)->void
+ {
+ std::shared_ptr<MessageAttachment> attachment =
+ std::shared_ptr<MessageAttachment>(new MessageAttachment());
+
+ auto obj = v.get<picojson::object>();
+ int messageAttachmentId = std::atoi(MessagingUtil::getValueFromJSONObject<std::string>(obj,
+ MESSAGE_ATTACHMENT_ATTRIBUTE_ID).c_str());
+ attachment->setId(messageAttachmentId);
+
+ int messageId = std::atoi(MessagingUtil::getValueFromJSONObject<std::string>(obj,
+ MESSAGE_ATTACHMENT_ATTRIBUTE_MESSAGE_ID).c_str());
+ attachment->setMessageId(messageId);
+
+ std::string mimeType = MessagingUtil::getValueFromJSONObject<std::string>(obj,
+ MESSAGE_ATTACHMENT_ATTRIBUTE_MIME_TYPE);
+ attachment->setMimeType(mimeType);
+
+ std::string filePath = MessagingUtil::getValueFromJSONObject<std::string>(obj,
+ MESSAGE_ATTACHMENT_ATTRIBUTE_FILE_PATH);
+ attachment->setFilePath(filePath);
+
+ attachments.push_back(attachment);
+ };
+
+ for_each(ma.begin(), ma.end(), arrayVectorAttachmentConverter);
+ message->setMessageAttachments(attachments);
return message;
extern const char* MESSAGE_BODY_ATTRIBUTE_PLAIN_BODY;
extern const char* MESSAGE_BODY_ATTRIBUTE_HTML_BODY;
+extern const char* MESSAGE_ATTRIBUTE_MESSAGE_ATTACHMENT;
+extern const char* MESSAGE_ATTACHMENT_ATTRIBUTE_ID;
+extern const char* MESSAGE_ATTACHMENT_ATTRIBUTE_MESSAGE_ID;
+extern const char* MESSAGE_ATTACHMENT_ATTRIBUTE_MIME_TYPE;
+extern const char* MESSAGE_ATTACHMENT_ATTRIBUTE_FILE_PATH;
+
+
enum MessageType {
UNDEFINED = 0,
SMS,