#define msgt(strId) TText(strId, MSG_DOMAIN)
#define msg(strId) DText(strId, MSG_DOMAIN)
- #define msgArgs(strId, args) DText(0, strId, MSG_DOMAIN, args)
+ #define msgArgs(strId, ...) DText(0, strId, MSG_DOMAIN, __VA_ARGS__)
#define sys(strId) DText(strId, SYS_DOMAIN)
#define syst(strId) TText(strId, SYS_DOMAIN)
- #define sysArgs(strId, args) DText(0, strId, SYS_DOMAIN, args)
+ #define sysArgs(strId, ...) DText(0, strId, SYS_DOMAIN, __VA_ARGS__)
}
#endif /* LangUtils_h_ */
bool isMms();
const MsgTextMetric &getTextMetric();
long long getMsgSize();
+ int getAttachmentsCountTotal() const;
void read(Message &msg);
void write(const Message &msg);
void execCmd(const AppControlComposeRef &cmd);
private:
Page &createPage();
void showTooLargePopup();
+ void showTooMuchAttachedPopup(int willBeAttached);
+ void showTooMuchAttachedPopup();
void read(MessageSMS &msg);
void read(MessageMms &msg);
void readAttachments(MessageMms &msg);
void addAttachment( const std::string &filePath, const std::string &fileName = "");
void onTooLargePopupDel(Evas_Object *obj, void *eventInfo);
+ void onTooMuchAttachedPopupDel(Evas_Object *obj, void *eventInfo);
std::string createVcfFile(const AppControlComposeRef &cmd);
WorkingDirRef m_WorkingDir;
Ecore_Idler *m_pOnChangedIdler;
bool m_TooLargePopupShow;
+ bool m_TooMuchAttachedPopupShow;
};
class IBodyListener
, m_WorkingDir(workingDir)
, m_pOnChangedIdler(nullptr)
, m_TooLargePopupShow(false)
+ , m_TooMuchAttachedPopupShow(false)
{
}
bool Body::addMedia(const std::list<std::string> &fileList)
{
bool res = true;
+
+ int numAttached = getAttachmentsCountTotal();
+ int numToAttach = fileList.size();
+ int numAttachMax = m_App.getMsgEngine().getSettings().getAttachmentsMaxCount();
+
+ if((numAttached + numToAttach) > numAttachMax)
+ {
+ numToAttach = numAttachMax - numAttached;
+ if (numToAttach > 0)
+ showTooMuchAttachedPopup(numToAttach);
+ }
+
+ int i = 0;
for(auto &file : fileList)
+ {
+ if (i > numToAttach)
+ break;
res &= addMedia(file);
+ ++i;
+ }
return res;
}
{
MSG_LOG("Try add resource:", filePath);
+ int numAttached = getAttachmentsCountTotal();
+ int numAttachMax = m_App.getMsgEngine().getSettings().getAttachmentsMaxCount();
+
+ if(numAttached >= numAttachMax)
+ {
+ showTooMuchAttachedPopup();
+ return false;
+ }
+
if(!FileUtils::isExists(filePath) || FileUtils::isDir(filePath))
{
MSG_LOG_ERROR("File not exists: ", filePath);
return size;
}
+int Body::getAttachmentsCountTotal() const
+{
+ int count = getAttachments().size();
+
+ auto pages = getPages();
+ for(PageView *pageView : pages)
+ count += static_cast<Page*>(pageView)->getAttachmentsCount();
+
+ return count;
+}
+
void Body::read(Message &msg)
{
MSG_LOG("");
}
}
+void Body::showTooMuchAttachedPopup(int willBeAttached)
+{
+ if(!m_TooMuchAttachedPopupShow)
+ {
+ Popup &popup = m_App.getPopupManager().getPopup();
+ popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Body, onTooMuchAttachedPopupDel), this);
+ popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId);
+ int maxCount = m_App.getMsgEngine().getSettings().getAttachmentsMaxCount();
+ std::string content(msgArgs("IDS_MSGF_BODY_MAXIMUM_NUMBER_OF_ATTACHMENTS_HP1SS_EXCEEDED_ONLY_FIRST_P2SS_WILL_BE_ADDED", std::to_string(maxCount).c_str(), std::to_string(willBeAttached).c_str()));
+ popup.setContent(content);
+ popup.setAutoDismissBlockClickedFlag(true);
+ popup.show();
+ m_TooMuchAttachedPopupShow = true;
+ }
+}
+
+void Body::showTooMuchAttachedPopup()
+{
+ if(!m_TooMuchAttachedPopupShow)
+ {
+ Popup &popup = m_App.getPopupManager().getPopup();
+ popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Body, onTooMuchAttachedPopupDel), this);
+ popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId);
+ int maxCount = m_App.getMsgEngine().getSettings().getAttachmentsMaxCount();
+ std::string content(msgArgs("IDS_MSGF_POP_MAXIMUM_NUMBER_OF_ATTACHMENTS_HPS_EXCEEDED", std::to_string(maxCount).c_str()));
+ popup.setContent(content);
+ popup.setAutoDismissBlockClickedFlag(true);
+ popup.show();
+ m_TooMuchAttachedPopupShow = true;
+ }
+}
+
void Body::onRemoveMediaItemPressed(PopupListItem &item)
{
MSG_LOG("");
m_TooLargePopupShow = false;
}
+void Body::onTooMuchAttachedPopupDel(Evas_Object *obj, void *eventInfo)
+{
+ MSG_LOG("");
+ m_TooMuchAttachedPopupShow = false;
+}
+
std::string Body::createVcfFile(const AppControlComposeRef &cmd)
{
auto &idList = cmd->getVcfInfo().contactsIdList;