*/
class MsgStorage
{
+ public:
+ /**
+ * @brief Possible results message storage could cause to.
+ */
+ enum StorageResult
+ {
+ StorageSuccess = 0, /**< Storage successful.*/
+ StorageFail = -1, /**< Storage failure.*/
+ StorageSimFull = -2, /**< SIM storage is full.*/
+ };
+
public:
MsgStorage();
virtual ~MsgStorage();
* @brief Commits edited message into message-storage in two optional way:
* -# save existing message
* -# create a copy of source message
- * @param[out] msg message to be saved.
+ * @param[in] msg message to be saved.
* @param[in] a updateExisting flag that defines a saving strategy. If true the existing message is saved, otherwise a new message-copy is created.
+ * @param[out] result of storage operation.
* @return id of saved message.
*/
- virtual MsgId saveMessage(Message &msg, bool updateExisting) = 0;
+ virtual MsgId saveMessage(Message &msg, bool updateExisting, StorageResult *result = nullptr) = 0;
/**
* @brief Deletes single message with specified id.
#include "Logger.h"
#include "MsgUtilsPrivate.h"
#include "MsgReportPrivate.h"
+#include "MsgEngine.h"
#include <msg_storage.h>
#include <algorithm>
return msgRef;
}
-MsgId MsgStoragePrivate::saveMessage(Message &msg, bool updateExisting)
+MsgId MsgStoragePrivate::saveMessage(Message &msg, bool updateExisting, StorageResult *result)
{
+ if(result)
+ *result = StorageFail;
+
MsgId newMsgId;
MessagePrivate &msgPriv = dynamic_cast<MessagePrivate&>(msg);
msgPriv.commit();
if(msgPriv.getId().isValid() && updateExisting)
{
- if(msg_update_message(m_ServiceHandle, msgPriv, sendOpt) == 0)
- {
+ int err = msg_update_message(m_ServiceHandle, msgPriv, sendOpt);
+ if(result)
+ *result = MsgUtilsPrivate::nativeToStorageResult(err);
+ if(err == MSG_SUCCESS)
newMsgId = msg.getId();
- }
}
else
{
- int tmpMsgId = msg_add_message(m_ServiceHandle, msgPriv, sendOpt);
- if(tmpMsgId > 0)
+ newMsgId = msg_add_message(m_ServiceHandle, msgPriv, sendOpt);
+ if(newMsgId > 0)
{
- newMsgId = tmpMsgId;
- msg_move_msg_to_storage(m_ServiceHandle, newMsgId, msg.getMessageStorageType());
+ int err = msg_move_msg_to_storage(m_ServiceHandle, newMsgId, msg.getMessageStorageType());
+ if(result)
+ *result = MsgUtilsPrivate::nativeToStorageResult(err);
+ if(err != MSG_SUCCESS)
+ {
+ MSG_LOG_WARN("Can't move msg to storage, error = ", MsgEngine::whatError(err));
+ deleteMessage(newMsgId);
+ newMsgId.reset();
+ }
}
}
msg_release_struct(&sendOpt);
-
return newMsgId;
}
/**
*@brief Return id of new message or of updated message
- *@param[out] msg - message that we need to save
+ *@param[in] msg - message that we need to save
*@param[in] updateExisting - true if we need to update our message id DB,
* false if we need to save message with new id
+ *@param[out] result of storage operation.
*@return MessageId
*/
- virtual MsgId saveMessage(Message &msg, bool updateExisting);
+ virtual MsgId saveMessage(Message &msg, bool updateExisting, StorageResult *result);
virtual bool deleteMessage(MsgId id);
virtual bool deleteMessages(const MsgIdList &idList);
virtual MessageListRef searchMessage(const std::string &word);
}
return MSG_RINGTONE_TYPE_DEFAULT;
}
+
+MsgStorage::StorageResult MsgUtilsPrivate::nativeToStorageResult(int resultCode)
+{
+ MsgStorage::StorageResult res = MsgStorage::StorageFail;
+ switch(resultCode)
+ {
+ case MSG_SUCCESS:
+ res = MsgStorage::StorageSuccess;
+ break;
+ case MSG_ERR_SIM_STORAGE_FULL:
+ res = MsgStorage::StorageSimFull;
+ break;
+ }
+ return res;
+}
#include "MsgUtils.h"
#include "MsgSettings.h"
#include "MsgTransport.h"
+#include "MsgStorage.h"
#include <msg_storage.h>
#include <msg_types.h>
static MsgTransport::SendResult nativeToSendResult(int sendRes);
static MsgSettings::RingtoneType nativeToRingtoneType(int type);
static int ringtoneTypeToNative(MsgSettings::RingtoneType type);
+ static MsgStorage::StorageResult nativeToStorageResult(int resultCode);
static std::string getStr(msg_struct_t msgStruct, int field, int maxStrLen);
static int setStr(msg_struct_t msgStruct, int field, const std::string &text);
void updateDownloadButton();
BubbleDownloadButtonEntity *findDownloadButton() const;
void shareContent();
+ void copyMsgToSimCard();
// Create Popup when message is clicked
void showMainListPopup();
}
}
+void ConvListItem::copyMsgToSimCard()
+{
+ MsgStorage::StorageResult result = MsgStorage::StorageFail;
+ MessageRef msg = m_App.getMsgEngine().getStorage().getMessage(m_MsgId);
+ if(msg)
+ {
+ msg->setMessageStorageType(Message::MS_Sim);
+ m_App.getMsgEngine().getStorage().saveMessage(*msg, false, &result);
+
+ if(result == MsgStorage::StorageSimFull)
+ notification_status_message_post(msg("IDS_MSGF_BODY_SIM_MEMORY_FULL_DELETE_SOME_ITEMS").cStr());
+ }
+ if(result == MsgStorage::StorageSuccess)
+ notification_status_message_post(msg("IDS_MSGC_POP_COPIED_TO_SIM_CARD").cStr());
+}
+
Evas_Object *ConvListItem::getBubbleContent()
{
auto *bubble = new BubbleItemContainer(*getOwner());
{
MSG_LOG("");
item.getParent().destroy();
- MessageRef msg = m_App.getMsgEngine().getStorage().getMessage(m_MsgId);
- if(msg)
- {
- msg->setMessageStorageType(Message::MS_Sim);
- m_App.getMsgEngine().getStorage().saveMessage(*msg, false);
- }
-
- notification_status_message_post(msg("IDS_MSGC_POP_COPIED_TO_SIM_CARD").cStr());
+ copyMsgToSimCard();
}
void ConvListItem::onViewDetailsItemPressed(PopupListItem &item)
// IListViewListener:
virtual void onListItemChecked(ListItem &listItem);
- void checkHandler(SelectAllListItem &item);
// IHwButtonListener:
virtual void onHwMoreButtonClicked();
void MsgOnSimCard::onListItemChecked(ListItem &listItem)
{
- if(SelectAllListItem *it = dynamic_cast<SelectAllListItem*>(&listItem))
+ if(dynamic_cast<SelectAllListItem*>(&listItem))
{
- checkHandler(*it);
- }
- else
- {
- MSG_LOG_ERROR("dynamic_cast was FAILED!");
+ bool checked = listItem.getCheckedState();
+ m_pList->checkAllItems(checked);
}
int check = 0;
setTitleTranslatable();
}
-void MsgOnSimCard::checkHandler(SelectAllListItem &item)
-{
- bool checked = item.getCheckedState();
- m_pList->checkAllItems(checked);
- getNaviBar().disabledButton(NaviOkButtonId, !checked);
-}
-
void MsgOnSimCard::onHwMoreButtonClicked()
{
showCopyDeletePopup();