int err = email_get_attachment_data(attachment->getId(), &attachment_data_holder.data);
if (EMAIL_ERROR_NONE != err ||
NULL == attachment_data_holder.data) {
- LoggerE("Couldn't get attachment data for attachmentId:%d", attachment->getId());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't get attachment.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Couldn't get attachment.",
+ ("Couldn't get attachment data for attachmentId:%d", attachment->getId()));
}
LoggerD("attachment name : %s", attachment_data_holder->attachment_name);
LoadAttachmentProxyPtr* load_attachment_proxy) {
load_attachment_proxy->reset(new LoadAttachmentProxy(path, iface));
if ((*load_attachment_proxy)->isNotProxyGot()) {
- LoggerE("Could not get load attachment proxy");
load_attachment_proxy->reset();
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not get load attachment proxy");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Could not get load attachment proxy");
} else {
return PlatformResult(ErrorCode::NO_ERROR);
}
LoggerD("Found callback for pair mailId:%d nth:%d", mail_id, nth);
PlatformResult ret = PlatformResult(ErrorCode::NO_ERROR);
- if(NOTI_DOWNLOAD_ATTACH_FINISH == status) {
+ if (NOTI_DOWNLOAD_ATTACH_FINISH == status) {
LoggerD("Message attachment downloaded!");
std::shared_ptr<MessageAttachment> att = callback->getMessageAttachment();
callback->SetSuccess(picojson::value(args));
callback->Post();
}
- } else if(NOTI_DOWNLOAD_ATTACH_FAIL) {
- LoggerD("Load message attachment failed!");
- ret = PlatformResult(ErrorCode::UNKNOWN_ERR, "Load message attachment failed!");
+ } else if (NOTI_DOWNLOAD_ATTACH_FAIL == status) {
+ ret = LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Load message attachment failed!");
}
if (ret.IsError()) {
LoggerE("Exception in signal callback");
LoadBodyProxyPtr* load_body_proxy) {
load_body_proxy->reset(new LoadBodyProxy(path, iface));
if ((*load_body_proxy)->isNotProxyGot()) {
- LoggerE("Could not get load body proxy");
load_body_proxy->reset();
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not get load body proxy");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Could not get load body proxy");
} else {
return PlatformResult(ErrorCode::NO_ERROR);
}
callback->Post();
}
} else if(NOTI_DOWNLOAD_BODY_FAIL == status) {
- LoggerD("Load message body failed!");
- ret = PlatformResult(ErrorCode::UNKNOWN_ERR, "Load message body failed!");
+ ret = LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Load message body failed!");
}
if (ret.IsError()) {
PlatformResult MessageProxy::create(MessageProxyPtr* message_proxy) {
message_proxy->reset(new MessageProxy());
if ((*message_proxy)->isNotProxyGot()) {
- LoggerE("Could not get proxy");
message_proxy->reset();
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not get proxy");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Could not get proxy");
} else {
return PlatformResult(ErrorCode::NO_ERROR);
}
//getting thread_id from message
email_mail_data_t *mail_data = NULL;
- if(EMAIL_ERROR_NONE != email_get_mail_data(mail_id, &mail_data)) {
+ int ntv_ret = email_get_mail_data(mail_id, &mail_data);
+ if(EMAIL_ERROR_NONE != ntv_ret) {
if (mail_data) email_free_mail_data(&mail_data, 1);
- LoggerE("Failed to get mail data during setting conversation id in MessageProxy.");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Failed to get mail data during setting"
- " conversation id in MessageProxy.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR,
+ "Failed to get mail data during setting"
+ " conversation id in MessageProxy.",
+ ("email_get_mail_data error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
thread_id = mail_data->thread_id;
email_mail_data_t* mail_data = EmailManager::getInstance().loadMessage(mail_id);
if (mail_data == NULL) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to load email");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to load email");
}
std::shared_ptr<Message> msg;
PlatformResult ret = Message::convertPlatformEmailToObject(*mail_data, &msg);
false));
} else {
email_mailbox_t* mail_box = NULL;
- if (EMAIL_ERROR_NONE != email_get_mailbox_by_mailbox_id(mailbox_id, &mail_box)) {
- LoggerE("Mailbox not retrieved");
+ int ntv_ret = email_get_mailbox_by_mailbox_id(mailbox_id, &mail_box);
+ if (EMAIL_ERROR_NONE != ntv_ret) {
delete eventFolder;
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to load mailbox");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to load mailbox",
+ ("email_get_mailbox_by_mailbox_id error: %d (%s)",
+ ntv_ret, get_error_message(ntv_ret)));
}
folder.reset(new MessageFolder(*mail_box));
if (EMAIL_ERROR_NONE != email_free_mailbox(&mail_box, 1)) {
PlatformResult SendProxy::create(SendProxyPtr* send_proxy) {
send_proxy->reset(new SendProxy());
if ((*send_proxy)->isNotProxyGot()) {
- LoggerE("Could not get send proxy");
send_proxy->reset();
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not get send proxy");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Could not get send proxy");
} else {
return PlatformResult(ErrorCode::NO_ERROR);
}
SyncProxyPtr* sync_proxy) {
sync_proxy->reset(new SyncProxy(path, iface));
if ((*sync_proxy)->isNotProxyGot()) {
- LoggerE("Could not get sync proxy");
sync_proxy->reset();
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not get sync proxy");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Could not get sync proxy");
} else {
return PlatformResult(ErrorCode::NO_ERROR);
}
break;
case NOTI_DOWNLOAD_FAIL:
- LoggerD("Sync failed!");
- callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Sync failed!"));
+ callback->SetError(LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Sync failed!"));
callback->Post();
break;
// map with specified opId (for example stopSync() has
// removed it), but sync() was already started - only
// warning here:
- LoggerW("Could not find callback with op_handle: %d", op_handle);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not find callback");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Could not find callback",
+ ("Could not find callback with op_handle: %d", op_handle));
}
} //namespace DBus
if (!instance.m_is_initialized) {
instance.getUniqueOpId();
- const int non_err = EMAIL_ERROR_NONE;
-
- if(non_err != email_service_begin()){
- LoggerE("Email service failed to begin");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Email service failed to begin");
+
+ int ntv_ret = email_service_begin();
+ if(ntv_ret != EMAIL_ERROR_NONE){
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Email service failed to begin",
+ ("email_service_begin error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
- if(non_err != email_open_db()){
- LoggerE("Email DB failed to open");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Email DB failed to open");
+ ntv_ret = email_open_db();
+ if(ntv_ret != EMAIL_ERROR_NONE){
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Email DB failed to open",
+ ("email_open_db error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
int slot_size = -1;
CHECK_ERROR(ret, "create sync proxy failed");
if (!instance.m_proxy_sync) {
LoggerE("Sync proxy is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Sync proxy is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Sync proxy is null");
}
instance.m_proxy_sync->signalSubscribe();
&instance.m_proxy_load_body);
CHECK_ERROR(ret, "create load body proxy failed");
if (!instance.m_proxy_load_body) {
- LoggerE("Load body proxy is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Load body proxy is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Load body proxy is null");
}
instance.m_proxy_load_body->signalSubscribe();
ret = DBus::MessageProxy::create(&instance.m_proxy_messageStorage);
CHECK_ERROR(ret, "create message proxy failed");
if (!instance.m_proxy_messageStorage) {
- LoggerE("Message proxy is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Message proxy is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Message proxy is null");
}
instance.m_proxy_messageStorage->signalSubscribe();
ret = DBus::SendProxy::create(&instance.m_proxy_send);
CHECK_ERROR(ret, "create send proxy failed");
if (!instance.m_proxy_send) {
- LoggerE("Send proxy is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Send proxy is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Send proxy is null");
}
instance.m_proxy_send->signalSubscribe();
email_account_t* account = NULL;
err = email_get_account(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account);
if(EMAIL_ERROR_NONE != err) {
- LoggerE("email_get_account failed. [%d]\n",err);
- err = email_free_mail_data(&mail_data,1);
- if(EMAIL_ERROR_NONE != err) {
- LoggerE("Failed to free mail data memory");
+ int ntv_ret = email_free_mail_data(&mail_data,1);
+ if(EMAIL_ERROR_NONE != ntv_ret) {
+ LoggerE("Failed to free mail data memory %d (%s)", ntv_ret, get_error_message(ntv_ret));
}
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot retrieve email account information");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot retrieve email account information",
+ ("email_get_account error: %d (%s)", err, get_error_message(err)));
}
LoggerE("FROM %s", account->user_email_address);
std::stringstream ss;
err = email_get_mailbox_by_mailbox_type(account_id, mailbox_type,
&mailbox_data);
if(EMAIL_ERROR_NONE != err) {
- LoggerD("email_get_mailbox_by_mailbox_type failed. [%d]\n",err);
- err = email_free_mail_data(&mail_data,1);
- if(EMAIL_ERROR_NONE != err) {
- LoggerE("Failed to free mail data memory");
+ int ntv_ret = email_free_mail_data(&mail_data,1);
+ if(EMAIL_ERROR_NONE != ntv_ret) {
+ LoggerE("Failed to free mail data memory: %d (%s)", ntv_ret, get_error_message(ntv_ret));
}
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot retrieve draft mailbox");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot retrieve draft mailbox",
+ ("email_get_mailbox_by_mailbox_type error: %d (%s)", err, get_error_message(err)));
}
else {
LoggerD("email_get_mailbox_by_mailbox_type success.\n");
//adding email without attachments
err = email_add_mail(mail_data, NULL, 0, NULL, 0);
if(EMAIL_ERROR_NONE != err) {
- LoggerD("email_add_mail failed. [%d]\n",err);
- err = email_free_mail_data(&mail_data,1);
- if(EMAIL_ERROR_NONE != err) {
- LoggerE("Failed to free mail data memory");
+ int ntv_ret = email_free_mail_data(&mail_data,1);
+ if(EMAIL_ERROR_NONE != ntv_ret) {
+ LoggerE("Failed to free mail data memory: %d (%s)", ntv_ret, get_error_message(ntv_ret));
}
- err = email_free_mailbox(&mailbox_data, 1);
- if (EMAIL_ERROR_NONE != err) {
- LoggerE("Failed to destroy mailbox");
+ ntv_ret = email_free_mailbox(&mailbox_data, 1);
+ if (EMAIL_ERROR_NONE != ntv_ret) {
+ LoggerE("Failed to destroy mailbox: %d (%s)", ntv_ret, get_error_message(ntv_ret));
}
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't add message to draft mailbox");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Couldn't add message to draft mailbox",
+ ("email_add_mail error: %d (%s)", err, get_error_message(err)));
}
else {
LoggerD("email_add_mail success.\n");
err = email_get_mail_data(message->getId(), &mail_data_final);
if(EMAIL_ERROR_NONE != err) {
- LoggerE("Failed to retrieve added mail data");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't retrieve added mail data");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Couldn't retrieve added mail data",
+ ("email_get_mail_data error: %d (%s)", err, get_error_message(err)));
}
ret = message->updateEmailMessage(*mail_data_final);
if (ret.IsError()) return ret;
err = email_free_mail_data(&mail_data_final,1);
if(EMAIL_ERROR_NONE != err) {
- LoggerE("Failed to free mail data final memory");
+ LoggerE("Failed to free mail data final memory: %d (%s)", err, get_error_message(err));
}
err = email_free_mail_data(&mail_data,1);
if(EMAIL_ERROR_NONE != err) {
- LoggerE("Failed to free mail data memory");
+ LoggerE("Failed to free mail data memory: %d (%s)", err, get_error_message(err));
}
err = email_free_mailbox(&mailbox_data, 1);
if (EMAIL_ERROR_NONE != err) {
- LoggerE("Failed to destroy mailbox");
+ LoggerE("Failed to destroy mailbox: %d (%s)", err, get_error_message(err));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
std::shared_ptr<Message> message = callback->getMessage();
PlatformResult ret = addDraftMessagePlatform(callback->getAccountId(), message);
if (ret.IsError()) {
- LoggerE("%d (%s)", ret.error_code(), ret.message().c_str());
callback->SetError(ret);
}
}
LoggerD("Entered");
if (!callback) {
- LoggerE("Callback is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
}
int err = EMAIL_ERROR_NONE;
if (platform_result) {
err = email_get_mail_data(message->getId(),&mail_data);
if (EMAIL_ERROR_NONE != err) {
- LoggerE("email_get_mail_data failed. [%d]\n", err);
- platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get platform email structure");
+ platform_result = LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to get platform email structure",
+ ("email_get_mail_data %d (%s)", err, get_error_message(err)));
} else {
LoggerD("email_get_mail_data success.\n");
err = email_send_mail(mail_data->mail_id, &req_id);
if (EMAIL_ERROR_NONE != err) {
- LoggerE("Failed to send message %d", err);
- platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to send message");
+ platform_result = LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to send message",
+ ("email_send_mail error: %d (%s)", err, get_error_message(err)));
} else {
LoggerD("req_id: %d", req_id);
callback->getMessage()->setMessageStatus(MessageStatus::STATUS_SENDING);
}
} else {
LoggerE("Message is null");
- platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Message is null");
+ platform_result = LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Message is null");
}
if (!platform_result) {
case EMAIL_ERROR_INVALID_STREAM:
case EMAIL_ERROR_NO_RESPONSE:
{
- LoggerE("Network error %d", error_code);
- callback->SetError(PlatformResult(ErrorCode::NETWORK_ERR, "Failed to send message"));
+ callback->SetError(LogAndCreateResult(
+ ErrorCode::NETWORK_ERR, "Failed to send message",
+ ("Network error: %d (%s)", error_code, get_error_message(error_code))));
break;
}
default:
- LoggerE("Unknown error %d", error_code);
- callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to send message"));
+ callback->SetError(LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to send message",
+ ("Unknown error: %d (%s)", error_code, get_error_message(error_code))));
break;
}
} else if (NOTI_SEND_FINISH == status) {
email_mail_data_t* mail_data = NULL;
int err = email_get_mail_data(msg_id, &mail_data);
if (EMAIL_ERROR_NONE != err) {
- LoggerE("email_get_mail_data failed. [%d]", err);
+ LoggerE("email_get_mail_data failed. [%d] (%s)", err, get_error_message(err));
} else {
LoggerD("email_get_mail_data success.");
}
int op_handle = -1;
int err = email_download_body(mailId, 0, &op_handle);
if(EMAIL_ERROR_NONE != err){
- LoggerE("Email download body failed, %d", err);
+ LoggerE("Email download body failed, %d (%s)", err, get_error_message(err));
m_proxy_load_body->removeCallback(callback);
return;
}
LoggerD("Entered");
if (!callback) {
- LoggerE("Callback is null");
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Callback is null");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Callback is null");
}
if (!callback->getMessageAttachment()) {
- LoggerE("Callback's message attachment is null");
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Callback's message attachment is null");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Callback's message attachment is null");
}
std::shared_ptr<MessageAttachment> msgAttachment = callback->getMessageAttachment();
};
if (!mail_data) {
- LoggerE("Couldn't get email_mail_data_t for messageId: %d", msgAttachment->getMessageId());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't load message.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Couldn't load message.",
+ ("Couldn't get email_mail_data_t for messageId: %d", msgAttachment->getMessageId()));
}
AttachmentPtrVector attachments;
}
if (attachmentIndex < 0) {
- LoggerE("Attachment with id: %d not found", msgAttachment->getId());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't find attachment.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Couldn't find attachment.",
+ ("Attachment with id: %d not found", msgAttachment->getId()));
}
LoggerD("Attachment with id: [%d] is located at index: [%d]",
int err = email_download_attachment(msgAttachment->getMessageId(), nth, &op_handle);
if (EMAIL_ERROR_NONE != err) {
- LoggerE("Download email attachment failed with error: %d", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to load attachment.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to load attachment.",
+ ("Download email attachment failed with error: %d (%s)", err, get_error_message(err)));
} else {
LoggerD("email_download_attachment returned handle: [%d]", op_handle);
callback->setOperationHandle(op_handle);
err = email_set_mail_slot_size(0, 0, slot_size);
if (EMAIL_ERROR_NONE != err) {
- LoggerE("Email set slot size failed, %d", err);
+ LoggerE("Email set slot size failed, %d (%s)", err, get_error_message(err));
m_proxy_sync->removeCallback(op_id);
return;
}
err = email_sync_header(account_id, 0, &op_handle);
if (EMAIL_ERROR_NONE != err) {
- LoggerE("Email sync header failed, %d", err);
+ LoggerE("Email sync header failed, %d (%s)", err, get_error_message(err));
m_proxy_sync->removeCallback(op_id);
} else {
callback->setOperationHandle(op_handle);
int err = email_get_mailbox_by_mailbox_id(folder_id, &mailbox);
if (EMAIL_ERROR_NONE != err || NULL == mailbox) {
- LoggerE("Couldn't get mailbox, error code: %d", err);
+ LoggerE("Couldn't get mailbox, error code: %d (%s)", err, get_error_message(err));
m_proxy_sync->removeCallback(op_id);
return;
}
err = email_set_mail_slot_size(0, 0, slot_size);
if (EMAIL_ERROR_NONE != err) {
- LoggerE("Email set slot size failed, %d", err);
+ LoggerE("Email set slot size failed, %d (%s)", err, get_error_message(err));
} else {
int op_handle = -1;
const int account_id = callback->getAccountId();
err = email_sync_header(account_id, mailbox->mailbox_id, &op_handle);
if (EMAIL_ERROR_NONE != err) {
- LoggerE("Email sync header failed, %d", err);
+ LoggerE("Email sync header failed, %d (%s)", err, get_error_message(err));
m_proxy_sync->removeCallback(op_id);
} else {
callback->setOperationHandle(op_handle);
if (NULL != mailbox) {
err = email_free_mailbox(&mailbox, 1);
if (EMAIL_ERROR_NONE != err) {
- LoggerE("Failed to email_free_mailbox - err:%d ", err);
+ LoggerE("Failed to email_free_mailbox - err: %d (%s)", err, get_error_message(err));
}
mailbox = NULL;
}
EMAIL_CANCELED_BY_USER);
if (EMAIL_ERROR_NONE != err) {
- LoggerE("Email cancel job failed, %d", err);
+ LoggerE("Email cancel job failed, %d (%s)", err, get_error_message(err));
}
- callback->SetError(PlatformResult(ErrorCode::ABORT_ERR, "Sync aborted by user"));
+ callback->SetError(LogAndCreateResult(ErrorCode::ABORT_ERR, "Sync aborted by user"));
callback->Post();
m_proxy_sync->removeCallback(op_id);
}
MessagesCallbackUserData* callback = it->callback;
if (NOTI_MAIL_DELETE_FAIL == status) {
- LoggerD("Failed to remove mail");
- callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Messages remove failed"));
+ callback->SetError(LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Messages remove failed"));
}
//if one of mails failed, call error callback
//if all mails are deleted, call success.
MessageType type = callback->getMessageServiceType();
for(auto it = messages.begin() ; it != messages.end(); ++it) {
if((*it)->getType() != type) {
- LoggerE("Invalid message type");
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting email");
+ return LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting email",
+ ("Invalid message type %d", (*it)->getType()));
}
}
for (auto it = messages.begin() ; it != messages.end(); ++it) {
error = email_get_mail_data((*it)->getId(), &mail);
if (EMAIL_ERROR_NONE != error) {
- LoggerE("Couldn't retrieve mail data");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while deleting mail");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while deleting mail",
+ ("Couldn't retrieve mail data: %d (%s)", error, get_error_message(error)));
}
//This task (_EMAIL_API_DELETE_MAIL) is for async
error = email_delete_mail(mail->mailbox_id, &mail->mail_id, 1, 0);
if (EMAIL_ERROR_NONE != error) {
email_free_mail_data(&mail, 1);
- LoggerE("Error while deleting mail");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while deleting mail");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while deleting mail",
+ ("email_delete_mail error: %d (%s)", error, get_error_message(error)));
}
email_free_mail_data(&mail, 1);
}
MessageType type = callback->getMessageServiceType();
for (auto it = messages.begin() ; it != messages.end(); ++it) {
if ((*it)->getType() != type) {
- LoggerE("Invalid message type");
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Error while updating message");
+ return LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Error while updating message",
+ ("Invalid message type: %d", (*it)->getType()));
}
}
for (auto it = messages.begin() ; it != messages.end(); ++it) {
LoggerD("mail deleted = [%d]\n", mail->mail_id);
error = email_delete_mail(mail->mailbox_id,&mail->mail_id,1,1);
if (EMAIL_ERROR_NONE != error) {
- LoggerE("Error while deleting old mail on update: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error while deleting old mail on update");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while deleting old mail on update",
+ ("email_delete_mail error: %d (%s)", error, get_error_message(error)));
}
} else {
LoggerD("There are no attachments, updating only email data.");
error = email_update_mail(mail, NULL, 0, NULL, 0);
if (EMAIL_ERROR_NONE != error) {
- LoggerE("Error while updating mail");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while updating mail");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while updating mail",
+ ("email_update_mail error: %d (%s)", error, get_error_message(error)));
}
}
}
tizen::AbstractFilterPtr filter = callback->getFilter();
if (!filter) {
- LoggerE("Filter not provided");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Filter not provided");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Filter not provided");
}
for(FilterIterator it(filter); false == it.isEnd(); it++) {
if (FIS_COMPOSITE_START == it.getState()) {
CompositeFilterPtr cf = castToCompositeFilter((*it));
if(cf && INTERSECTION != cf->getType()) {
- LoggerE("[ERROR] >>> invalid Filter type: %d", cf->getType());
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Invalid Filter Type");
+ return LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Invalid Filter Type",
+ ("Invalid Filter type: %d", cf->getType()));
}
}
else if (FIS_ATTRIBUTE_FILTER == it.getState()) {
if (FIND_FOLDERS_ATTRIBUTE_ACCOUNTID_NAME == attr_name) {
account_id = static_cast<int>(attrf->getMatchValue()->toLong());
} else {
- LoggerE("The attribute name: %s is invalid", attr_name.c_str());
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR,
- "The attribute name is invalid");
+ return LogAndCreateResult(
+ ErrorCode::INVALID_VALUES_ERR, "The attribute name is invalid",
+ ("The attribute name: %s is invalid", attr_name.c_str()));
}
}
}
&mailboxes,
&mailboxes_count);
if (EMAIL_ERROR_NONE != ret || !mailboxes) {
- LoggerE("Cannot get folders: %d", ret);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Platform error, cannot get folders");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Platform error, cannot get folders",
+ ("email_get_mailbox_list error: %d (%s)", ret, get_error_message(ret)));
}
if (mailboxes_count <= 0) {
int thread_id = 0;
for(auto it = conversations.begin() ; it != conversations.end(); ++it) {
if ((*it)->getType() != type) {
- LoggerE("Invalid message type");
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR,
- "Error while deleting email conversation");
+ return LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting email conversation",
+ ("Invalid message type %d", (*it)->getType()));
}
}
thread_id = (*it)->getConversationId();
error = email_delete_thread(thread_id, false);
if (EMAIL_ERROR_NONE != error) {
- LoggerE("Couldn't delete email conversation data");
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR,
- "Error while deleting email conversation");
+ return LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting email conversation",
+ ("Couldn't delete email conversation data %d (%s)", error, get_error_message(error)));
}
// for now, there is no way to recognize deleting email thread job is completed.
int ret = email_get_mail_data(id, &mail);
if (EMAIL_ERROR_NONE != ret ) {
- LoggerD("Failed to get data.");
+ LoggerD("Failed to get data %d (%s)", ret, get_error_message(ret));
return "";
}
ret = email_free_mail_data(&mail, 1);
if (EMAIL_ERROR_NONE != ret ) {
- LoggerD("Failed to free mail data.");
+ LoggerD("Failed to free mail data %d (%s)", ret, get_error_message(ret));
}
return MessagingUtil::messageStatusToString(status);
umask(old_mask);
if (NULL == file) {
- LoggerE("Failed to create file");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to create file");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to create file");
}
if (fprintf(file, "%s", data.c_str()) < 0) {
- LoggerE("Failed to write data into file");
fclose(file);
remove(tmp_name.c_str());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to write data into file");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to write data into file");
}
fflush(file);
fclose(file);
// Looking for the last occurrence of slash in source path
std::size_t slashPos;
if ((slashPos = attPath.find_last_of('/')) == std::string::npos) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR,
"Error while copying file to temp: the source path is invalid.");
}
LoggerD("attPath: %s, tmpPath: %s", attPath.c_str(), tmpPath.c_str());
if(EINA_TRUE != ecore_file_mkdir(dirPath.c_str())) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Unknown error while creating temp directory.");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Unknown error while creating temp directory.");
}
FILE *f1, *f2;
f1 = fopen(attPath.c_str(), "rb");
if (!f1) {
- LoggerE("Fail open attPath");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Fail open attPath");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail open attPath");
}
f2 = fopen(tmpPath.c_str(), "wb");
if (!f2) {
- LoggerE("Fail open tmpPath");
fclose (f1);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Fail open tmpPath");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail open tmpPath");
}
while ((num = fread(buf, 1, sizeof(buf), f1)) > 0) {
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. ";
- return PlatformResult(ErrorCode::UNKNOWN_ERR, error.c_str());
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Unknown error while copying file to temp.");
}
*result_path = dirPath;
{
LoggerD("Entered");
if(EINA_TRUE != ecore_file_recursive_rm(dirPath.c_str())) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Unknown error while deleting temp directory.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Unknown error while deleting temp directory.");
}
return PlatformResult(ErrorCode::NO_ERROR);
}
LoggerD("Entered");
email_mail_data_t* mail_data = nullptr;
if(EMAIL != message->getType()) {
- LoggerE("Invalid type");
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid type.");
+ return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, "Invalid type.");
}
if(message->is_id_set()) {
} else {
mail_data = (email_mail_data_t*)malloc(sizeof(email_mail_data_t));
if (!mail_data) {
- LoggerE("malloc failure");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to allocate memory.");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to allocate memory.");
}
memset(mail_data, 0x00, sizeof(email_mail_data_t));
}
mail_data->file_path_plain = strdup(body_file_path.c_str());
if(!mail_data->file_path_plain)
{
- LoggerE("Plain Body file is NULL.");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Plain Body file is NULL.");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Plain Body file is NULL.");
}
}
mail_data->file_path_html = strdup(html_file_path.c_str());
if(!mail_data->file_path_html)
{
- LoggerE("Html Body file is NULL.");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Html Body file is NULL.");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Html Body file is NULL.");
}
} else if(!body->getPlainBody().empty()) {
// check html data is exist if not exist copy plain body to html body
mail_data->file_path_html = strdup(html_file_path.c_str());
if(!mail_data->file_path_html)
{
- LoggerE("Plain Body file is NULL.");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Plain Body file is NULL.");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Plain Body file is NULL.");
}
}
}
int id = message->getId();
int err = email_add_attachment(id, tmp);
if(EMAIL_ERROR_NONE != err) {
- LoggerE("Error while adding attachment %d", err);
- err = email_free_attachment_data(&tmp, 1);
- if (EMAIL_ERROR_NONE != err) {
- LoggerW("Failed to free attachment data");
+ int ntv_ret = email_free_attachment_data(&tmp, 1);
+ if (EMAIL_ERROR_NONE != ntv_ret) {
+ LoggerW("Failed to free attachment data: %d (%s)", ntv_ret, get_error_message(ntv_ret));
}
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Unknown error while adding attachment");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Unknown error while adding attachment",
+ ("email_add_attachment error: %d (%s)", err, get_error_message(err)));
}
att->setId(tmp->attachment_id);
att->setMessageId(id);
err = email_free_attachment_data(&tmp, 1);
if (EMAIL_ERROR_NONE != err) {
- LoggerW("Failed to free attachment data");
+ LoggerW("Failed to free attachment data %d (%s)", err, get_error_message(err));
}
return removeDirFromTemp(dirPath);
if (EMAIL_ERROR_NONE != error) {
email_free_mail_data(&mail, 1);
email_free_attachment_data(&attachment_data_list,attachment_data_count);
- LoggerE("Error while adding attachments. Failed to get attachment list.");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error while adding attachments. Failed to get attachment list.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR,
+ "Error while adding attachments. Failed to get attachment list.",
+ ("Error %d while adding attachments. Failed to get attachment list. (%s)",
+ error, get_error_message(error)));
}
//save mail without attachments id
if (EMAIL_ERROR_NONE != error) {
email_free_mail_data(&mail, 1);
email_free_attachment_data(&attachment_data_list,attachment_data_count);
- LoggerE("Error while re-adding mail: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while re-adding mail");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while re-adding mail",
+ ("Error %d while re-adding mail (%s)", error, get_error_message(error)));
}
LoggerD("mail added - new id = [%d]\n", mail->mail_id);
error = email_delete_mail(mail->mailbox_id,&tmp_id,1,1);
if (EMAIL_ERROR_NONE != error) {
email_free_mail_data(&mail, 1);
- LoggerE("Error while deleting mail from server: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while deleting mail from server");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while deleting mail from server",
+ ("email_delete_mail error: %d (%s)", error, get_error_message(error)));
}
email_free_mail_data(&mail, 1);
return PlatformResult(ErrorCode::NO_ERROR);
address, strlen(address));
}
else {
- LoggerE("failed to add address[%d] %s", i, address);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to add address");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "failed to add address",
+ ("failed to add address[%d] %s", i, address));
}
}
return PlatformResult(ErrorCode::NO_ERROR);
address, strlen(address));
}
else {
- LoggerE("[%d] failed to add address: [%s], error: %d", i, address, error);
- return PlatformResult (ErrorCode::UNKNOWN_ERR, "failed to add address");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "failed to add address",
+ ("[%d] failed to add address: [%s], error: %d", i, address, error));
}
}
return PlatformResult(ErrorCode::NO_ERROR);
attach.at(i)->getMimeType().c_str());
}
} else {
- LoggerE("att[%d]: failed to add attachment");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to add attachment");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "failed to add attachment",
+ ("att[%d]: failed to add attachment"));
}
}
return PlatformResult(ErrorCode::NO_ERROR);
{
LoggerD("Entered");
+ int ntv_ret = 0;
+
if (message->getType() != SMS && message->getType() != MMS) {
- LoggerD("Invalid type");
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid type");
+ return LogAndCreateResult(
+ ErrorCode::INVALID_VALUES_ERR, "Invalid type",
+ ("Invalid type: %d", message->getType()));
}
msg_error_t err = MSG_SUCCESS;
std::unique_ptr<msg_struct_t, int (*)(msg_struct_t*)> send_opt_ptr(&send_opt, msg_release_struct);
err = msg_get_message(handle, id, msg, send_opt);
if (err != MSG_SUCCESS) {
- LoggerD("msg_get_message() Fail [%d]", err);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "msg_get_message() Fail");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "msg_get_message() Fail",
+ ("msg_get_message() Fail [%d] (%s)", err, get_error_message(err)));
}
LoggerD("Using existing msg for id: %d", id);
} else { // id is not set - the message does not exist in database
MessageType msgType = message->getType();
if (msgType == MessageType::SMS) {
// Set message type to SMS
- if (MSG_SUCCESS
- != msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS)) {
- LoggerE("Set SMS type error");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Set SMS type error");
+ ntv_ret = msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS);
+ if (MSG_SUCCESS != ntv_ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Set SMS type error",
+ ("msg_set_int_value error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
} else {
// Set message type to MMS
- if (MSG_SUCCESS
- != msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS)) {
- LoggerE("Set MMS type error");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Set MMS type error");
+ ntv_ret = msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS);
+ if (MSG_SUCCESS != ntv_ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Set MMS type error",
+ ("msg_set_int_value error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
}
}
// Reset SMS recipients
int error = msg_list_clear(msg, MSG_MESSAGE_ADDR_LIST_HND);
if( MSG_SUCCESS != error) {
- LoggerE("Failed to clear address list, error: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to clear address list");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to clear address list",
+ ("msg_list_clear error: %d (%s)", error, get_error_message(error)));
}
// Set SMS recipients
} else if (type == MSG_TYPE_MMS) {
// Set message type to MMS
- if (MSG_SUCCESS
- != msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS)) {
- LoggerE("Message(%p): Set MMS type error", message);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Set MMS type error");
+ ntv_ret = msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS);
+ if (MSG_SUCCESS != ntv_ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Set MMS type error",
+ ("Message(%p): Set MMS type error %d (%s)", message, ntv_ret, get_error_message(ntv_ret)));
}
// Create MMS data
msg_struct_t mms_data = msg_create_struct(MSG_STRUCT_MMS);
if (mms_data == NULL) {
- LoggerE("Message(%p): Set MMS data error", message);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Set MMS data error");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Set MMS data error",
+ ("Message(%p): Set MMS data error", message));
} else {
std::unique_ptr<msg_struct_t, int (*)(msg_struct_t*)> mms_data_ptr(&mms_data, msg_release_struct);
// Set MMS message subject
std::string subject = message->getSubject();
if (subject != "") {
- int r = msg_set_str_value(msg, MSG_MESSAGE_SUBJECT_STR,
- const_cast<char*>(subject.c_str()), subject.size());
- if (r != MSG_SUCCESS) {
- LoggerE("Message(%p): Set MMS subject error: %d", message, r);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Set MMS subject error");
+ ntv_ret = msg_set_str_value(msg, MSG_MESSAGE_SUBJECT_STR,
+ const_cast<char*>(subject.c_str()), subject.size());
+ if (ntv_ret != MSG_SUCCESS) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Set MMS subject error",
+ ("Message(%p): Set MMS subject error: %d (%s)", message, ntv_ret, get_error_message(ntv_ret)));
}
}
// Set MMS message text
const_cast<char*>(body_file_path.c_str()),
body_file_path.size());
if (error != MSG_SUCCESS) {
- LoggerE("Message(%p): Failed to set mms body filepath", message);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to set mms body filepath");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to set mms body filepath",
+ ("Message(%p): Failed to set mms body filepath %d (%s)",
+ message, error, get_error_message(error)));
}
msg_set_str_value(media, MSG_MMS_MEDIA_CONTENT_TYPE_STR,
const_cast<char*>("text/plain"), 10);
if (ret.IsError()) return ret;
}
// Set MMS body
- int r = msg_set_mms_struct(msg, mms_data);
- if (r != MSG_SUCCESS) {
- LoggerE("Message(%p): Set MMS body error: %d", message, r);
- return PlatformResult (ErrorCode::UNKNOWN_ERR, "Set MMS body error");
+ ntv_ret = msg_set_mms_struct(msg, mms_data);
+ if (ntv_ret != MSG_SUCCESS) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Set MMS body error",
+ ("Message(%p): Set MMS body error: %d (%s)",
+ message, ntv_ret, get_error_message(ntv_ret)));
}
}
if (ret.IsError()) return ret;
}
else {
- LoggerE("Message(%p): Invalid message type", message);
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid message type");
+ return LogAndCreateResult(
+ ErrorCode::INVALID_VALUES_ERR, "Invalid message type",
+ ("Message(%p): Invalid message type", message));
}
// set common attributes for SMS and MMS
// -1 means unknown - so do not set simindex in that case.
int sim_index = static_cast<int>(message->getSimIndex());
if (sim_index != -1) {
- int error =
- msg_set_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, sim_index+1);
- if ( MSG_SUCCESS != error) {
- LoggerE("Failed to set sim index, error: %d", error);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to set sim index");
+ int error = msg_set_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, sim_index+1);
+ if (MSG_SUCCESS != error) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to set sim index",
+ ("msg_set_int_value error: %d (%s)", error, get_error_message(error)));
}
}
LoggerD("Entered");
std::vector<std::string> address;
msg_list_handle_t addr_list = NULL;
- if (MSG_SUCCESS
- == msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND,
- (void **) &addr_list)) {
+ int ntv_ret = msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND, (void **) &addr_list);
+ if (MSG_SUCCESS == ntv_ret) {
int size = msg_list_length(addr_list);
for (int i = 0; i < size; i++) {
msg_struct_t addr_info = NULL;
address.push_back(std::string(infoStr));
}
} else {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "failed to add recipients",
+ ("msg_get_list_handle error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
LoggerE("failed to get recipients");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to add recipients");
}
*result_address = address;
return PlatformResult(ErrorCode::NO_ERROR);
LoggerD("Entered");
std::vector<std::string> address;
msg_list_handle_t addr_list = NULL;
- if (MSG_SUCCESS
- == msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND,
- (void **) &addr_list)) {
+ int ntv_ret = msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND, (void **) &addr_list);
+ if (MSG_SUCCESS == ntv_ret) {
int size = msg_list_length(addr_list);
for (int i = 0; i < size; i++) {
msg_struct_t addr_info = NULL;
}
}
} else {
- LoggerE("failed to get recipients");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to add recipients");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "failed to add recipients",
+ ("msg_get_list_handle error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
*result_address = address;
return PlatformResult(ErrorCode::NO_ERROR);
msg_struct_t mms_struct = msg_create_struct(MSG_STRUCT_MMS);
int error = msg_get_mms_struct(msg, mms_struct);
if (MSG_SUCCESS != error) {
- LoggerE("Cannot get mms struct, error:%d", error);
msg_release_struct(&mms_struct);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "cannot get mms struct");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "cannot get mms struct",
+ ("msg_get_mms_struct error: %d (%s)", error, get_error_message(error)));
}
bool body_has_been_set = false;
}
} else {
msg_release_struct(&mms_struct);
- LoggerE("failed to get attachment");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to get attachment");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "failed to get attachment",
+ ("msg_get_list_handle error: %d (%s)", error, get_error_message(error)));
}
msg_release_struct(&page);
}
} else {
msg_release_struct(&mms_struct);
- LoggerE("failed to get attachment");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to get attachment");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "failed to get attachment",
+ ("msg_get_list_handle error: %d (%s)", error, get_error_message(error)));
}
if(false == body_has_been_set) {
}
} else {
msg_release_struct(&mms_struct);
- LoggerE("failed to get attachment");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "failed to add attachment");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "failed to add attachment",
+ ("msg_get_list_handle error: %d (%s)", error, get_error_message(error)));
}
LoggerD("after MSG_MMS_ATTACH_LIST attachments count is:%d",
std::vector<std::string> recp_list;
PlatformResult ret = message->getSMSRecipientsFromStruct(msg, &recp_list);
if (ret.IsError()) {
- LoggerE("failed to get SMS recipients from struct");
+ LoggerE("failed to get SMS recipients from struct (%s)", ret.message().c_str());
return ret;
}
return ret;
}
} else {
- LoggerE("Invalid Message type: %d", infoInt);
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "Invalid Message type");
+ return LogAndCreateResult(
+ ErrorCode::INVALID_VALUES_ERR, "Invalid Message type",
+ ("Invalid Message type: %d", infoInt));
}
// get id
email_attachment_data_t* attachment = NULL;
int attachmentCount = 0;
- if (EMAIL_ERROR_NONE != email_get_attachment_data_list(mail.mail_id,
- &attachment, &attachmentCount)) {
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't get attachment.");
+ int ntv_ret = email_get_attachment_data_list(
+ mail.mail_id,
+ &attachment,
+ &attachmentCount);
+ if (EMAIL_ERROR_NONE != ntv_ret) {
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Couldn't get attachment.",
+ ("email_get_attachment_data_list error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
if ( attachment && attachmentCount > 0) {
for (int i = 0; i < attachmentCount; i++) {
PlatformResult Message::updateEmailMessage(email_mail_data_t& mail)
{
- LoggerW("This should be called on MessageEmail instance");
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR,
- "This should be called on MessageEmail instance");
+ return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR,
+ "This should be called on MessageEmail instance");
}
/**
PlatformResult ret = MessagingUtil::loadFileContentToString(mail.file_path_plain,
&result);
if (ret.IsError()) {
- LoggerE("Fail to open plain body.");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Fail to open plain body.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Fail to open plain body.",
+ ("%s", ret.message().c_str()));
}
setPlainBody(result);
}
PlatformResult ret = MessagingUtil::loadFileContentToString(mail.file_path_html,
&result);
if (ret.IsError()) {
- LoggerE("Fail to open html body.");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Fail to open html body.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Fail to open html body.",
+ ("%s", ret.message().c_str()));
}
setHtmlBody(result);
}
msg_error_t err = msg_get_thread(handle, conversation->m_conversation_id, msg_thread);
if (err != MSG_SUCCESS)
{
- LoggerE("Failed to retrieve thread.");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to retrieve thread.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to retrieve thread.",
+ ("msg_get_thread error: %d (%s)", err, get_error_message(err)));
}
msg_get_int_value(msg_thread, MSG_THREAD_MSG_TYPE_INT, &tempInt);
switch(tempInt)
// automatically release the memory
if (err != MSG_SUCCESS)
{
- LoggerE("Get conversation(msg) view list fail.");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Get conversation(msg) view list fail.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Get conversation(msg) view list fail.",
+ ("msg_get_conversation_view_list error: %d (%s)", err, get_error_message(err)));
}
lastMsgIndex = convViewList.nCount - 1;
msg_get_int_value(convViewList.msg_struct_info[lastMsgIndex], MSG_CONV_MSG_ID_INT, &tempInt);
conversation->m_last_message_id = tempInt;
- if (msg_get_message(handle, conversation->m_last_message_id, msgInfo,
- sendOpt) != MSG_SUCCESS)
+ err = msg_get_message(handle, conversation->m_last_message_id, msgInfo, sendOpt);
+ if (err != MSG_SUCCESS)
{
- LoggerE("Get message fail.");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "get message fail.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "get message fail.",
+ ("msg_get_message error: %d (%s)", err, get_error_message(err)));
}
msg_get_int_value(convViewList.msg_struct_info[lastMsgIndex], MSG_CONV_MSG_DIRECTION_INT, &tempInt);
email_mail_list_item_t *resultMail = NULL;
- if(email_get_thread_information_ex(threadId, &resultMail) != EMAIL_ERROR_NONE)
+ int ntv_ret = email_get_thread_information_ex(threadId, &resultMail);
+ if(ntv_ret != EMAIL_ERROR_NONE)
{
if (resultMail)
{
free(resultMail);
}
- LoggerE("Couldn't get conversation");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't get conversation.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Couldn't get conversation.",
+ ("email_get_thread_information_ex error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
} else {
if (!resultMail)
{
- LoggerE("Data is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Get email data fail.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Get email data fail.",
+ ("Data is null"));
}
email_mail_data_t* mailData = NULL;
- if (email_get_mail_data(resultMail->mail_id,
- &mailData) != EMAIL_ERROR_NONE)
+ ntv_ret = email_get_mail_data(resultMail->mail_id, &mailData);
+ if (ntv_ret != EMAIL_ERROR_NONE)
{
free(resultMail);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Get email data fail.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Get email data fail.",
+ ("email_get_mail_data error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
if (!mailData) {
free(resultMail);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Get email data fail.");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Get email data fail.");
}
int index = 0;
conversation->m_unread_messages = 0;
email_mail_list_item_t *mailList = NULL;
- if (email_get_mail_list(mailData->account_id, 0, threadId, 0,
- resultMail->thread_item_count, EMAIL_SORT_DATETIME_HIGH, &mailList,
- &count) != EMAIL_ERROR_NONE)
+ ntv_ret = email_get_mail_list(
+ mailData->account_id, 0, threadId, 0,
+ resultMail->thread_item_count, EMAIL_SORT_DATETIME_HIGH, &mailList,
+ &count);
+ if (ntv_ret != EMAIL_ERROR_NONE)
{
email_free_mail_data(&mailData , 1);
free(resultMail);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Get email data list fail.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Get email data list fail.",
+ ("email_get_mail_list error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
}
for (index = 0; index < count; index++)
sim_index--;
if (sim_index >= sim_count || sim_index < -1) {
- LoggerE("Sim index out of bound %d : %d", sim_index, sim_count);
- this->SetError(PlatformResult(ErrorCode::INVALID_VALUES_ERR, "The index of sim is out of bound"));
+ this->SetError(LogAndCreateResult(
+ ErrorCode::INVALID_VALUES_ERR, "The index of sim is out of bound",
+ ("Sim index out of bound %d : %d", sim_index, sim_count)));
return false;
}
common::PlatformResult MessageService::sendMessage(MessageRecipientsCallbackData *callback)
{
// this method should be overwritten be specific services
- LoggerE("Cannot send message");
delete callback;
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Unable to send message.");
+ return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "Unable to send message.");
}
PlatformResult MessageService::loadMessageBody(MessageBodyCallbackData* callback)
{
// this method should be overwritten by specific services
- LoggerE("Cannot load message body");
delete callback;
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot load message body");
+ return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot load message body");
}
PlatformResult MessageService::loadMessageAttachment(MessageAttachmentCallbackData* callback)
{
// this method should be overwritten by email service
// for MMS and SMS this function is not supported
- LoggerE("Cannot load message attachment");
delete callback;
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot load message attachment");
+ return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot load message attachment");
}
PlatformResult MessageService::sync(SyncCallbackData *callback, long* operation_id)
{
// this method should be overwritten by email service
// for MMS and SMS this function is not supported
- LoggerE("Cannot sync with external server");
delete callback;
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot sync with external server");
+ return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot sync with external server");
}
PlatformResult MessageService::syncFolder(SyncFolderCallbackData *callback, long* operation_id)
{
// this method should be overwritten by email service
// for MMS and SMS this function is not supported
- LoggerE("Cannot sync folder with external server");
delete callback;
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot sync folder with external server");
+ return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR,
+ "Cannot sync folder with external server");
}
PlatformResult MessageService::stopSync(long op_id)
{
// this method should be overwritten by email service
// for MMS and SMS this function is not supported
- LoggerE("Cannot stop sync with external server");
- return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, "Cannot stop sync with external server");
+ return LogAndCreateResult(ErrorCode::NOT_SUPPORTED_ERR,
+ "Cannot stop sync with external server");
}
} // messaging
LoggerD("Entered");
if (!callback) {
- LoggerE("Callback is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
}
callback->setAccountId(m_id);
guint id = g_idle_add(sendMessageTask, static_cast<void*>(callback));
if (!id) {
- LoggerE("g_idle_add fails");
delete callback;
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Could not add task",
+ ("g_idle_add fails"));
}
return PlatformResult(ErrorCode::NO_ERROR);
{
LoggerD("Entered");
if (!callback) {
- LoggerE("Callback is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
}
guint id = g_idle_add(loadMessageBodyTask, static_cast<void*>(callback));
if (!id) {
- LoggerE("g_idle_add failed");
delete callback;
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Could not add task",
+ ("g_idle_add failed"));
}
return PlatformResult(ErrorCode::NO_ERROR);
LoggerD("Entered");
guint id = g_idle_add(loadMessageAttachmentTask, static_cast<void*>(callback));
if (!id) {
- LoggerE("g_idle_add failed");
delete callback;
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Could not add task",
+ ("g_idle_add failed"));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
LoggerD("Entered");
if (!callback) {
- LoggerE("Callback is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
}
long op_id = EmailManager::getInstance().getUniqueOpId();
guint id = g_idle_add(syncTask, static_cast<void*>(callback));
if (!id) {
- LoggerE("g_idle_add failed");
delete callback;
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Could not add task",
+ ("g_idle_add failed"));
}
*operation_id = op_id;
registered_callbacks_.insert(op_id);
{
LoggerD("Entered");
if (!callback) {
- LoggerE("Callback is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
}
if (!callback->getMessageFolder()) {
- LoggerE("Message folder is null");
delete callback;
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Message folder is null");
+ return LogAndCreateResult(ErrorCode::TYPE_MISMATCH_ERR, "Message folder is null");
}
long op_id = EmailManager::getInstance().getUniqueOpId();
guint id = g_idle_add(syncFolderTask, callback);
if (!id) {
- LoggerE("g_idle_add fails");
delete callback;
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Could not add task",
+ ("g_idle_add fails"));
}
*operation_id = op_id;
registered_callbacks_.insert(op_id);
guint id = g_idle_add(stopSyncTask, static_cast<void*>(data));
if (!id) {
- LoggerE("g_idle_add failed");
delete data;
data = NULL;
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Could not add task",
+ ("g_idle_add failed"));
}
return PlatformResult(ErrorCode::NO_ERROR);
}
{
LoggerD("Entered");
if (!callback) {
- LoggerE("Callback is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
}
/*
}
if (sim_index >= sim_count) {
- LoggerE("Sim index out of count %d : %d", sim_index, sim_count);
delete callback;
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR, "The index of sim is out of bound");
+ return LogAndCreateResult(
+ ErrorCode::INVALID_VALUES_ERR, "The index of sim is out of bound",
+ ("Sim index out of count %d : %d", sim_index, sim_count));
}
callback->getMessage()->setSimIndex(sim_index);
}
if(!g_idle_add(sendMessageThread, static_cast<void*>(callback))) {
- LoggerE("g_idle_add fails");
delete callback;
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Could not add task",
+ ("g_idle_add fails"));
}
return PlatformResult(ErrorCode::NO_ERROR);
{
LoggerD("Entered");
if (!callback) {
- LoggerE("Callback is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
}
guint id = g_idle_add(loadMessageBodyTask, static_cast<void*>(callback));
if (!id) {
- LoggerE("g_idle_add fails");
delete callback;
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Could not add task");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Could not add task",
+ ("g_idle_add fails"));
}
return PlatformResult(ErrorCode::NO_ERROR);
std::ostringstream sqlQuery;
AttributeFilterPtr attr_filter = castToAttributeFilter(filter);
if(!attr_filter) {
- LoggerE("passed filter is not valid AttributeFilter!");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Wrong filter type - not attribute filter");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR,
+ "Wrong filter type - not attribute filter",
+ ("passed filter is not valid AttributeFilter!"));
}
const std::string attribute_name = attr_filter->getAttributeName();
if (it != attribute_map.end()) {
sqlQuery << "(" << attribute_map[attribute_name].sql_name << " ";
} else {
- LoggerE("The attribute: %s does not exist.", attribute_name.c_str());
- return PlatformResult(ErrorCode::INVALID_VALUES_ERR,
- "The attribute does not exist.");
+ return LogAndCreateResult(
+ ErrorCode::INVALID_VALUES_ERR, "The attribute does not exist.",
+ ("The attribute: %s does not exist.", attribute_name.c_str()));
}
AnyPtr match_value_any_ptr = attr_filter->getMatchValue();
} else if ("messaging.email" == match_value && MessageType::EMAIL == msgType) {
sqlQuery << "= " << attr_info.sql_name;
} else {
- LoggerE("attribute \"type\" matchValue:%s "
- "does not match messaging.sms/mms/email\n"
- "msgType:%d does not match SMS(%d), MMS(%d) nor EMAIL(%d)!",
- match_value.c_str(), msgType, MessageType::SMS, MessageType::MMS,
- MessageType::EMAIL);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "The value does not match service type.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "The value does not match service type.",
+ ("attribute \"type\" matchValue:%s "
+ "does not match messaging.sms/mms/email\n"
+ "msgType:%d does not match SMS(%d), MMS(%d) nor EMAIL(%d)!",
+ match_value.c_str(), msgType, MessageType::SMS, MessageType::MMS,
+ MessageType::EMAIL));
}
}
else if ("isRead" == attribute_name || "hasAttachment" == attribute_name) {
break;
}
default:
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "The match flag is incorrect.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "The match flag is incorrect.",
+ ("The match flag is incorrect: %d", match_flag));
}
if (MessageType::SMS == msgType || MessageType::MMS == msgType) {
AttributeRangeFilterPtr attr_range_filter = castToAttributeRangeFilter(filter);
if(!attr_range_filter) {
- LoggerE("passed filter is not valid AttributeRangeFilter!");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Wrong filter type - not attribute range filter");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Wrong filter type - not attribute range filter",
+ ("passed filter is not valid AttributeRangeFilter!"));
}
converter << attr_range_filter->getInitialValue()->toTimeT();
CompositeFilterPtr comp_filter = castToCompositeFilter(filter);
if(!comp_filter) {
- LoggerE("passed filter is not valid CompositeFilter!");
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Wrong filter type - not composite filter");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Wrong filter type - not composite filter",
+ ("passed filter is not valid CompositeFilter!"));
}
AbstractFilterPtrVector filters_arr = comp_filter->getFilters();
break;
}
default:
- LoggerE("Error while querying message - unsupported filter type: %d",
- filter_type);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error while querying message.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while querying message.",
+ ("Error while querying message - unsupported filter type: %d", filter_type));
}
if (i != (size - 1)) {
if (UNDEFINED != msg_type) {
sql_query << attribute_map["type"].sql_name << " = " << msg_type << " AND ";
} else {
- LoggerE("The service type is incorrect - msg_type is UNDEFINED");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "The service type is incorrect.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "The service type is incorrect.",
+ ("The service type is incorrect - %d", msg_type));
}
}
break;
}
default:
- LoggerE("The filter type is incorrect: %d", filter->getFilterType());
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "The filter type is incorrect.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "The filter type is incorrect.",
+ ("The filter type is incorrect: %d", filter->getFilterType()));
}
}
sql_query << "ORDER BY "
<< attribute_map[sort_mode->getAttributeName()].sql_name << " ";
} else {
- LoggerE("The attribute does not exist.");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "The attribute does not exist.");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "The attribute does not exist.");
}
if (ASC == sort_mode->getOrder()) {
// Getting results from database
msg_error_t err = getTable(sqlQuery.str(), &results, &resultsCount);
if (MSG_SUCCESS != err) {
- LoggerE("Getting results from database failed [%d]", err);
freeTable(&results);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error while getting data from database.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while getting data from database.",
+ ("getTable error: %d (%s)", err, get_error_message(err)));
}
for (int i = 0; i < resultsCount; ++i) {
if (EMAIL_ERROR_MAIL_NOT_FOUND == err) {
resultsCount = 0;
} else {
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error while getting data from database.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while getting data from database.",
+ ("email_query_mails error: %d (%s)", err, get_error_message(err)));
}
}
// Getting results from database
msg_error_t err = getTable(sqlQuery.str(), &results, &resultsCount);
if (MSG_SUCCESS != err) {
- LoggerE("Getting results from database failed [%d]", err);
freeTable(&results);
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error while getting data from database.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while getting data from database.",
+ ("getTable error: %d (%s)", err, get_error_message(err)));
}
for (int i = 0; i < resultsCount; ++i) {
if (EMAIL_ERROR_MAIL_NOT_FOUND == err) {
resultsCount = 0;
} else {
- return PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error while getting data from database.");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while getting data from database.",
+ ("email_query_mails error: %d (%s)", err, get_error_message(err)));
}
}
}
#define POST_AND_RETURN(ret, json, obj, action) \
- LoggerE("Error occured: (%s)", ret.message().c_str()); \
picojson::object args; \
- ReportError(ret, &args); \
+ LogAndReportError(ret, &args); \
obj[JSON_DATA] = picojson::value(args); \
obj[JSON_ACTION] = picojson::value(action); \
queue_.addAndResolve( \
try {
id = std::stoi(v_id.get<std::string>());
} catch(...) {
- LoggerE("Problem with MessageService");
- ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out);
+ LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out,
+ ("Problem with MessageService"));
return;
}
long limit = 0;
if (result) {
ReportSuccess(picojson::value(static_cast<double>(op_id)), out);
} else {
- ReportError(result, &out);
+ LogAndReportError(result, &out);
}
}
try {
id = std::stoi(v_id.get<std::string>());
} catch(...) {
- LoggerE("Problem with MessageService");
- ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out);
+ LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out,
+ ("Problem with MessageService"));
return;
}
if (result) {
ReportSuccess(picojson::value(static_cast<double>(op_id)), out);
} else {
- ReportError(result, &out);
+ LogAndReportError(result, &out);
}
}
try {
id = std::stoi(v_id.get<std::string>());
} catch(...) {
- LoggerD("Problem with MessageService");
- ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out);
+ LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out,
+ ("Problem with MessageService"));
return;
}
if (result) {
ReportSuccess(out);
} else {
- ReportError(result, &out);
+ LogAndReportError(result, &out);
}
} else {
- LoggerE("Unknown error");
- ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out);
+ LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR), &out,
+ ("Unknown error"));
}
}
MessageService* service = MessageServiceShortMsg::GetSmsMessageService();
if (!service) {
- LoggerE("MessageService for SMS creation failed");
- platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "MessageService for SMS creation failed");
+ platform_result = LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "MessageService for SMS creation failed");
} else {
*(user_data->sms_service) = std::make_pair(service->getMsgServiceId(), service);
MessageService* service = MessageServiceShortMsg::GetMmsMessageService();
if (!service) {
- LoggerE("MessageService for MMS creation failed");
- platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "MessageService for SMS creation failed");
+ platform_result = LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "MessageService for SMS creation failed");
} else {
*(user_data->mms_service) = std::make_pair(service->getMsgServiceId(), service);
email_account_t* email_accounts = nullptr;
int count = 0;
- if (email_get_account_list(&email_accounts, &count) != EMAIL_ERROR_NONE) {
- LoggerE("Method failed: email_get_account_list()");
- platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Error during getting account list");
+ int ntv_ret = email_get_account_list(&email_accounts, &count);
+ if (ntv_ret != EMAIL_ERROR_NONE) {
+ platform_result = LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error during getting account list",
+ ("email_get_account_list error: %d (%s)", ntv_ret, get_error_message(ntv_ret)));
} else {
std::vector<MessageService*> msgServices;
delete service;
});
msgServices.clear();
- LoggerE("MessageService for email creation failed");
- platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "MessageService for email creation failed");
+ platform_result = LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "MessageService for email creation failed");
} else {
msgServices.push_back(service);
}
}
break;
default:
- platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Service type is undefined");
+ platform_result = LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Service type is undefined");
}
} else {
- LoggerE("Unsupported service type");
- platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Unsupported service type");
+ platform_result = LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Unsupported service type");
}
if (!platform_result) {
const auto it = stringToTypeMap.find(str);
if (it == stringToTypeMap.end()) {
- LoggerE("Not supported type: %s", str.c_str());
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Not supported type: " + str);
+ return LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Not supported type: " + str,
+ ("Not supported type: %s", str.c_str()));
} else {
*out = it->second;
return PlatformResult(ErrorCode::NO_ERROR);
const auto it = typeToStringMap.find(type);
if (it == typeToStringMap.end()) {
- LoggerE("Invalid MessageType: %d", type);
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Invalid MessageType");
+ return LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Invalid MessageType",
+ ("Invalid MessageType: %d", type));
} else {
*out = it->second;
return PlatformResult(ErrorCode::NO_ERROR);
} else {
std::stringstream ss_error_msg;
ss_error_msg << "Failed to open file: " << file_path;
- return PlatformResult(ErrorCode::IO_ERR, ss_error_msg.str().c_str());
+ return LogAndCreateResult(ErrorCode::IO_ERR, ss_error_msg.str().c_str());
}
return PlatformResult(ErrorCode::NO_ERROR);
}
int mail_id = std::atoi(mid.c_str());
email_mail_data_t* mail = NULL;
if (EMAIL_ERROR_NONE != email_get_mail_data(mail_id, &mail)) {
- LoggerE("Fatal error: message not found: %d!", mail_id);
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR,
- "Failed to find specified email.");
+ return LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Failed to find specified email.",
+ ("Fatal error: message not found: %d!", mail_id));
} else {
platform_result = Message::convertPlatformEmailToObject(*mail, &message);
email_free_mail_data(&mail,1);
if (!v.is<std::string>()) {
const std::string message = "Passed array holds incorrect values "
+ v.serialize() + " is not a correct string value";
- LoggerE("Error: %s", message.c_str());
- conv_res = PlatformResult(ErrorCode::INVALID_VALUES_ERR, message);
+ conv_res = LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR, message);
}
if (conv_res.IsError()) {
return;
return jsonFilterToCompositeFilter(filter, result);
}
- LoggerE("Unsupported filter type: %s", type.c_str());
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Unsupported filter type");
+ return LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Unsupported filter type",
+ ("Unsupported filter type: %s", type.c_str()));
}
PlatformResult MessagingUtil::jsonFilterToAttributeFilter(const picojson::object& filter,
filterMatch = FilterMatchFlag::EXISTS;
}
else {
- LoggerE("Filter name is not recognized: %s", matchFlagStr.c_str());
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Filter name is not recognized");
+ return LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Filter name is not recognized",
+ ("Filter name is not recognized: %s", matchFlagStr.c_str()));
}
auto attributePtr = new AttributeFilter(name);
filterType = CompositeFilterType::INTERSECTION;
}
else {
- LoggerE("Composite filter type is not recognized: %s", type.c_str());
- return PlatformResult(ErrorCode::TYPE_MISMATCH_ERR,
- "Composite filter type is not recognized");
+ return LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Composite filter type is not recognized",
+ ("Composite filter type is not recognized: %s", type.c_str()));
}
auto compositeFilter = new CompositeFilter(filterType);
}
if (NULL == platform_msg) {
- LoggerE("Failed to prepare platform message");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot prepare platform message");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Cannot prepare platform message");
}
msg_struct_t send_opt = msg_create_struct(MSG_STRUCT_SENDOPT);
msg_set_bool_value(send_opt, MSG_SEND_OPT_SETTING_BOOL, false);
const int msg_id = msg_add_message(m_msg_handle, platform_msg, send_opt);
if (msg_id < MSG_SUCCESS) {
- LoggerE("Message(%p): Failed to add draft, error: %d", message.get(), msg_id);
msg_release_struct(&send_opt);
msg_release_struct(&platform_msg);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot add message to draft");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot add message to draft",
+ ("Message(%p): Failed to add draft, error: %d", message.get(), msg_id));
}
LoggerD("Message(%p): New message ID: %d", message.get(), msg_id);
msg_get_int_value(msg_conv, MSG_CONV_MSG_THREAD_ID_INT, &conversationId);
message->setConversationId(conversationId);
} else {
- LoggerE("Message(%p): Failed to get conv", message.get());
+ LoggerE("Message(%p): Failed to get conv: %d (%s)", message.get(), err, get_error_message(err));
}
Message* msgInfo = nullptr;
ret = Message::convertPlatformShortMessageToObject(
msg_conv = msg_create_struct(MSG_STRUCT_CONV_INFO);
ret = msg_get_message(m_msg_handle, msg_id, platform_msg, send_opt);
if (MSG_SUCCESS != ret) {
- LoggerE("Failed to get platform message structure: %d", ret);
- platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get platform Message structure");
+ platform_result = LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get platform Message structure",
+ ("msg_get_message error: %d (%s)", ret, get_error_message(ret)));
} else {
// Send message
message->setMessageStatus(MessageStatus::STATUS_SENDING);
int req_id = -1;
ret = msg_get_int_value(req, MSG_REQUEST_REQUESTID_INT, &req_id);
if (MSG_SUCCESS != ret) {
- LoggerE("Failed to get send request ID: %d", ret);
- platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get send request ID");
+ platform_result = LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to get send request ID",
+ ("msg_get_int_value error: %d (%s)", ret, get_error_message(ret)));
} else {
if (MessageType::MMS == message->getType()) {
LoggerD("Send MMS message");
ret = msg_sms_send_message(m_msg_handle, req);
}
else {
- LoggerE("Invalid message type: %d", message->getType());
- platform_result = PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Invalid message type");
+ platform_result = LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Invalid message type",
+ ("Invalid message type: %d", message->getType()));
}
if (platform_result) {
if (ret != MSG_SUCCESS) {
- LoggerE("Failed to send message: %d", ret);
- platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to send message");
+ platform_result = LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to send message",
+ ("Failed to send message: %d (%s)", ret, get_error_message(ret)));
} else {
ret = msg_get_int_value(req, MSG_REQUEST_REQUESTID_INT, &req_id);
if (ret != MSG_SUCCESS) {
- LoggerE("Failed to get message request ID: %d", ret);
- platform_result = PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get send request");
+ platform_result = LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Failed to get send request",
+ ("Failed to get message request ID: %d (%s)", ret, get_error_message(ret)));
}
if (platform_result.IsSuccess()) {
LoggerD("req_id: %d", req_id);
LoggerD("Entered");
if (!callback){
- LoggerE("Callback is null");
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
+ return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Callback is null");
}
PlatformResult platform_result(ErrorCode::NO_ERROR);
if (MSG_NETWORK_SEND_FAIL == status
|| MSG_NETWORK_SEND_TIMEOUT == status) {
- LoggerE("req_id:%d : Failed sending Message(%p) with msg_id:%d msg status is: %s",
- reqId,
- callback->getMessage().get(),
- callback->getMessage()->getId(),
- (MSG_NETWORK_SEND_FAIL == status ? "FAIL" : "TIMEOUT"));
+ callback->SetError(LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Send message failed",
+ ("req_id:%d : Failed sending Message(%p) with msg_id:%d msg status is: %s",
+ reqId,
+ callback->getMessage().get(),
+ callback->getMessage()->getId(),
+ (MSG_NETWORK_SEND_FAIL == status ? "FAIL" : "TIMEOUT"))));
- callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Send message failed"));
}
if (!g_idle_add(sendMessageCompleteCB, static_cast<void*>(callback))) {
MessageType type = callback->getMessageServiceType();
for(auto it = messages.begin() ; it != messages.end(); ++it) {
if((*it)->getType() != type) {
- LoggerE("Invalid message type: %d", (*it)->getType());
- callback->SetError(PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting message"));
+ callback->SetError(LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting message",
+ ("Invalid message type: %d", (*it)->getType())));
break;
}
}
int error = msg_delete_message(m_msg_handle, id);
if (MSG_SUCCESS != error) {
- LoggerE("Error while deleting message");
- callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while deleting message"));
+ callback->SetError(LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while deleting message",
+ ("msg_delete_message error: %d (%s)", error, get_error_message(error))));
break;
}
}
MessageType type = callback->getMessageServiceType();
for (auto it = messages.begin() ; it != messages.end(); ++it) {
if ((*it)->getType() != type) {
- LoggerE("Invalid message type");
- callback->SetError(PlatformResult(ErrorCode::TYPE_MISMATCH_ERR, "Error while updating message"));
+ callback->SetError(LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Error while updating message",
+ ("Invalid message type %d", (*it)->getType())));
break;
}
}
break;
}
if (NULL == platform_msg) {
- LoggerE("Failed to prepare platform message");
- callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot prepare platform message"));
+ callback->SetError(LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Cannot prepare platform message"));
break;
}
msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
msg_release_struct(&platform_msg);
msg_release_struct(&sendOpt);
if (error != MSG_SUCCESS) {
- LoggerE("Failed to update message %d", (*it)->getId());
- callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while updating message"));
+ callback->SetError(LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while updating message",
+ ("Failed to update message %d", (*it)->getId())));
break;
}
}
int error = msg_get_message(m_msg_handle, msg_id, msg, sendOpt);
if (MSG_SUCCESS != error) {
- LoggerE("Couldn't retrieve message from service, msgId: %d, error:%d", msg_id, error);
msg_release_struct(&sendOpt);
msg_release_struct(&msg);
- return PlatformResult(ErrorCode::UNKNOWN_ERR, "Couldn't retrieve message from service");
+ return LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Couldn't retrieve message from service",
+ ("Couldn't retrieve message from service, msgId: %d, error:%d", msg_id, error));
}
msg_release_struct(&sendOpt);
*out_msg = msg;
err = msg_get_message(m_msg_handle, messagesIds.at(i), msg, send_opt);
if (MSG_SUCCESS != err) {
- LoggerE("Failed to get platform message structure: %d", err);
- callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get platform Message structure"));
+ callback->SetError(LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get platform Message structure",
+ ("Failed to get platform message structure: %d (%s)", err, get_error_message(err))));
break;
}
LoggerW("Ignore messages with not supported/unrecognized type");
continue;
}
- LoggerE("Cannot get platform Message structure");
- callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Cannot get platform Message structure"));
+ callback->SetError(LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Cannot get platform Message structure"));
break;
}
if (!callback->IsError()) {
error = msg_open_msg_handle(&handle);
if (MSG_SUCCESS != error) {
- LoggerE("Open message handle error: %d", error);
- callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Error while creatng message handle"));
+ callback->SetError(LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while creatng message handle",
+ ("Open message handle error: %d (%s)", error, get_error_message(error))));
}
if (!callback->IsError()) {
for(auto it = conversations.begin() ; it != conversations.end(); ++it) {
if((*it)->getType() != type) {
- LoggerE("Invalid message type");
- callback->SetError(PlatformResult(ErrorCode::TYPE_MISMATCH_ERR,
- "Error while deleting message conversation"));
+ callback->SetError(LogAndCreateResult(
+ ErrorCode::TYPE_MISMATCH_ERR, "Error while deleting message conversation",
+ ("Invalid message type %d", (*it)->getType())));
break;
}
}
msg_id_conv_id_map = &m_mms_removed_msg_id_conv_id_map;
conv_id_object_map = &m_mms_removed_conv_id_object_map;
} else {
- LoggerE("Invalid message type:%d for ShortMsgManager!", type);
- callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Invalid message type for ShortMsgManager!"));
+ callback->SetError(LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Invalid message type for ShortMsgManager!",
+ ("Invalid message type:%d for ShortMsgManager!", type)));
}
}
error = msg_delete_thread_message_list(handle, (msg_thread_id_t) conv_id,
FALSE);
if (MSG_SUCCESS != error) {
- LoggerE("Error while deleting message conversation");
- callback->SetError(PlatformResult(ErrorCode::UNKNOWN_ERR,
- "Error while deleting message conversation"));
+ callback->SetError(LogAndCreateResult(
+ ErrorCode::UNKNOWN_ERR, "Error while deleting message conversation",
+ ("msg_delete_thread_message_list error: %d (%s)",
+ error, get_error_message(error))));
break;
}
}