group {
name: "smil_attachment_item_layout";
parts {
- part {
- name: "pad_left";
- type: SPACER;
- scale: 1;
- description {
- state: "default" 0.0;
- fixed: 1 0;
- min: 7 0;
- max: 7 0;
- align: 0 0.5;
- rel1.relative: 0 0;
- rel2.relative: 0 1;
- }
- description {
- state: "landscape" 0.0;
- inherit: "default" 0.0;
- min: 170 0;
- max: 170 0;
- }
- }
+ PADDING_LEFT("pad.left", 32);
+ PADDING_RIGHT("pad.right", 32);
+ PADDING_TOP("pad.top", 15);
+ PADDING_BOTTOM("pad.bottom", 15);
part {
name: "swallow.content";
type: SWALLOW;
scale: 1;
- mouse_events: 1;
- repeat_events: 1;
- description {
- state: "default" 0.0;
- min: 1 0;
- align: 0 0.5;
- rel1.relative: 1.0 0.0;
- rel2.relative: 0.0 0.0;
- rel1.to: "pad_left";
- rel2.to: "pad_right";
- }
- }
- part {
- name: "pad_right";
- type: SPACER;
- scale: 1;
- description {
- state: "default" 0.0;
- fixed: 1 0;
- min: 7 0;
- max: 7 0;
- align: 1 0.5;
- rel1.relative: 1 0;
- rel2.relative: 1 1;
- }
- description {
- state: "landscape" 0.0;
- inherit: "default" 0.0;
- min: 170 0;
- max: 170 0;
- }
- }
- }
- programs {
- program {
- name: "show_landscape";
- signal: "show,landscape";
- source: "*";
- action: STATE_SET "landscape" 0.0;
- target: "pad_right";
- target: "pad_left";
- }
- program {
- name: "show_portrait";
- signal: "show,portrait";
- source: "*";
- action: STATE_SET "default" 0.0;
- target: "pad_right";
- target: "pad_left";
- }
- }
- }
- group {
- name: "smil_attachment_item";
- parts {
- part {
- name: "bg";
- type: RECT;
- scale: 1;
- description {
- state: "default" 0.0;
- min: 0 100;
- max: -1 100;
- color_class: "WO21L1";
- }
- description {
- state: "pressed" 0.0;
- inherit: "default" 0.0;
- color_class: "B0211P";
- }
- }
-
- PART_PADDING_LEFT("pad.left", 16, "bg");
- PART_PADDING_RIGHT("pad.right", 16, "bg");
-
- part {
- name: "item.thumbnail.rect";
- type: RECT;
- scale: 1;
- mouse_events: 0;
description {
state: "default" 0.0;
visible: 1;
- fixed: 1 1;
- min: 74 74;
- max: 74 74;
- rel1 { relative: 1.0 0.0; to_x: "pad.left"; to_y: "bg"; }
- rel2 { relative: 1.0 1.0; to_x: "pad.left"; to_y: "bg"; }
- align: 0.0 0.5;
- color: 0 0 0 0;
- }
- }
-
- PART_PADDING_TOP("thumbnail.icon.line.top", 1, "item.thumbnail.rect")
- PART_PADDING_LEFT("thumbnail.icon.line.left", 1, "item.thumbnail.rect")
- PART_PADDING_RIGHT("thumbnail.icon.line.right", 1, "item.thumbnail.rect")
- PART_PADDING_BOTTOM("thumbnail.icon.line.bottom", 1, "item.thumbnail.rect")
-
- PART_SWALLOW("item.thumbnail.icon", "item.thumbnail.rect")
- PART_H_PIXEL_RECT("pad.thumbnail.icon.right", 10, 0.0, 1.0, "item.thumbnail.icon")
-
- part {
- name: "item.filename.rect";
- type: RECT;
- mouse_events: 0;
- scale: 1;
- description {
- state: "default" 0.0;
- align: 0.0 0.5;
- rel1 { relative: 1.0 0.0; to_x: "pad.thumbnail.icon.right"; to_y: "bg"; }
- rel2 { relative: 0.0 1.0; to_x: "pad.filename.right"; to_y: "bg"; }
- color: 0 0 0 0;
- }
- }
- PART_TEXT("item.filename.text", "item.filename.rect", 0.0, 0.5)
- PART_H_PIXEL_RECT("pad.filename.right", 10, 1.0, 0.0, "item.filesize.rect")
-
- part {
- name: "item.filesize.rect";
- type: RECT;
- mouse_events: 0;
- scale: 1;
- description {
- state: "default" 0.0;
- min: 80 0;
- align: 1.0 0.5;
- rel1 { relative: 0.0 0.0; to_x: "pad.right"; to_y: "pad.right"; }
- rel2 { relative: 0.0 1.0; to_x: "pad.right"; to_y: "pad.right"; }
- color: 0 0 0 0;
+ fixed: 0 0;
+ align: 0 0;
+ rel1 {to_x: "pad.left"; to_y: "pad.top"; relative: 1.0 1.0;}
+ rel2 {to_x: "pad.right"; to_y: "pad.bottom"; relative: 0.0 0.0;}
}
}
- PART_TEXT("item.filesize.text", "item.filesize.rect", 1.0, 0.5)
-
- PART_RECT("over", 0.0, 0.0, "bg", "bg", 0.0, 1.0, "item.filesize.rect", "item.filesize.rect")
- PART_EVENT_RECT("over_event", "over")
-
- PART_TOP_LINE("line.top", "bg")
- PART_BOTTOM_LINE("line.bottom", "bg")
- PART_LEFT_LINE("line.left", "bg")
- PART_RIGHT_LINE("line.right", "bg")
- }
-
- programs {
- program {
- name: "mouse_clicked";
- signal: "mouse,clicked,1";
- source: "over_event";
- action: SIGNAL_EMIT "clicked" "";
- }
- program {
- name: "item.pressed";
- signal: "pressed";
- source: "over_event";
- action: STATE_SET "pressed" 0.0;
- target: "bg";
- target: "item.filename.text";
- target: "item.filesize.text";
- }
- program {
- name: "item.unpressed";
- signal: "unpressed";
- source: "over_event";
- action: STATE_SET "default" 0.0;
- target: "bg";
- target: "item.filename.text";
- target: "item.filesize.text";
- }
- program {
- name: "item_press";
- signal: "play,press,sound";
- source: "*";
- action: RUN_PLUGIN "touch_sound";
- }
}
}
}
#define FileViewer_h_
#include "AppControlUtils.h"
-#include "WorkingDir.h"
namespace Msg
{
class FileViewer
{
public:
- FileViewer(WorkingDirRef workingDir);
+ FileViewer();
+ ~FileViewer();
static bool launch(const std::string &file);
bool launchWithCopy(const std::string &file);
FileViewer(const FileViewer&) = delete;
FileViewer& operator=(const FileViewer&) = delete;
+ std::string addFile(const std::string &path);
+
private:
- WorkingDirRef m_WorkingDir;
std::string m_FilePath;
};
}
#include "FileViewer.h"
#include "Logger.h"
#include "FileUtils.h"
+#include "PathUtils.h"
#include <app_control.h>
using namespace Msg;
-FileViewer::FileViewer(WorkingDirRef workingDir)
- : m_WorkingDir(workingDir)
+FileViewer::FileViewer()
{
}
+FileViewer::~FileViewer()
+{
+ if(!m_FilePath.empty())
+ FileUtils::remove(m_FilePath);
+}
+
bool FileViewer::launch(const std::string &file)
{
bool res = false;
return res;
}
+std::string FileViewer::addFile(const std::string &path)
+{
+ std::string newPath;
+
+ if(FileUtils::isExists(path))
+ {
+ std::string dataPath = PathUtils::getDataPath("");
+
+ if(path.find(dataPath) != std::string::npos)
+ {
+ newPath = path;
+ MSG_LOG("File is already exists: ", newPath);
+ }
+ else
+ {
+ newPath = FileUtils::genUniqueFilePath(dataPath, path);
+ if(!FileUtils::copy(path, newPath))
+ newPath.clear();
+ }
+ }
+
+ return newPath;
+}
+
bool FileViewer::launchWithCopy(const std::string &file)
{
bool res = false;
- if(m_WorkingDir)
- {
// Remove previous file (correct only for APP_CONTROL_LAUNCH_MODE_GROUP)
- if(!m_FilePath.empty())
- m_WorkingDir->removeFile(m_FilePath);
+ if(!m_FilePath.empty())
+ FileUtils::remove(m_FilePath);
- m_FilePath = m_WorkingDir->addFile(file);
- if(!m_FilePath.empty())
- res = launch(m_FilePath);
- }
+ m_FilePath = addFile(file);
+ if(!m_FilePath.empty())
+ res = launch(m_FilePath);
return res;
}
#include "PopupManager.h"
#include "MsgMedia.h"
#include "FileUtils.h"
-#include <media_content.h>
-#include <media_content_type.h>
#include <notification_status.h>
using namespace Msg;
void SaveAttachmentsPopup::onSaveButtonClicked(Popup &popup, int buttonId)
{
MSG_LOG("");
- bool result = false;
- if(media_content_connect() != 0)
- {
- popup.destroy();
- showSavingFailedPopup();
- return;
- }
- result = saveCheckedItems();
+ bool result = saveCheckedItems();
popup.destroy();
if(result)
notification_status_message_post(msg("IDS_MSGF_POP_SAVED_IN_MY_FILES").cStr());
else
showSavingFailedPopup();
-
- media_content_disconnect();
}
bool SaveAttachmentsPopup::isSaveButtonNeedToBeEnable()
bool SaveAttachmentsPopup::saveCheckedItems()
{
- bool success = true;
std::string filePathDst;
std::string dowloadPath = PathUtils::getDownloadPath();
auto items = getListView().getItems<PopupAttachmentListItem>();
+ std::list<std::string> files;
+
for(auto *item : items)
{
if(item->isCheckable() && item->getCheckedState())
- {
- filePathDst = FileUtils::genUniqueFilePath(dowloadPath, item->getFilePath());
- bool copySucceed = FileUtils::copy(item->getFilePath(), filePathDst);
- success &= copySucceed && (media_content_scan_file(filePathDst.c_str()) == MEDIA_CONTENT_ERROR_NONE);
- }
+ files.push_back(item->getFilePath());
}
- return success;
+ return FileUtils::saveFilesToStorage(files);
}
void SaveAttachmentsPopup::showSavingFailedPopup()
#ifdef TIZEN_PRIVATE_API
int res = msg_open_msg_handle(&m_MsgHandle);
- MSG_LOG_ERROR("handle open error = ", res);
+ MSG_LOG("handle open error = ", res);
m_Storage.reset(new MsgStoragePrivate(m_MsgHandle));
m_Transport.reset(new MsgTransportPrivate(m_MsgHandle));
#define __MSG_FILE_UTIL_H__
#include <string>
+#include <list>
namespace Msg
{
* the given file extension is not associated with specific file formats
*/
static std::string getMimeType(const std::string &filePath);
+
+ /**
+ * @brief Save files to default storage directory
+ * @param[in] file list of file path
+ * @return Returns true if all ok, false otherwise
+ */
+ static bool saveFilesToStorage(const std::list<std::string> &files);
+
+ /**
+ * @brief Save file to default storage directory
+ * @param[in] file path
+ * @return Returns true if all ok, false otherwise
+ */
+ static bool saveFileToStorage(const std::string &file);
};
}
*/
#include "FileUtils.h"
+#include "PathUtils.h"
#include <unistd.h>
#include <sys/stat.h>
#include <ctype.h>
#include <fstream>
#include <mime_type.h>
+#include <media_content.h>
using namespace Msg;
return res;
}
+#include "Logger.h"
bool FileUtils::copy(const std::string &src, const std::string &dst)
{
FILE *f1 = nullptr;
const size_t bufSize = 4 * 1024;
char buf[bufSize];
- char realPath1[PATH_MAX];
- char realPath2[PATH_MAX];
size_t num = 0;
bool ret = true;
- if(!realpath(src.c_str(), realPath1))
- return false;
-
- if(realpath(dst.c_str(), realPath2) && !strcmp(realPath1, realPath2))
- return false;
-
f1 = fopen(src.c_str(), "rb");
if(!f1)
return false;
}
return res;
}
+
+static bool saveFileToStoragePrivate(const std::string &file)
+{
+ bool res = false;
+
+ std::string dowloadPath = PathUtils::getDownloadPath();
+ std::string filePathDst = FileUtils::genUniqueFilePath(dowloadPath, file);
+
+ if(FileUtils::copy(file, filePathDst))
+ res = media_content_scan_file(filePathDst.c_str()) == MEDIA_CONTENT_ERROR_NONE;
+
+ return res;
+}
+
+bool FileUtils::saveFilesToStorage(const std::list<std::string> &files)
+{
+ bool res = true;
+ if(media_content_connect() != 0)
+ return false;
+
+ for(const std::string &file : files)
+ {
+ res &= saveFileToStoragePrivate(file);
+ }
+ media_content_disconnect();
+ return res;
+}
+
+bool FileUtils::saveFileToStorage(const std::string &file)
+{
+ if(media_content_connect() != 0)
+ return false;
+
+ bool res = saveFileToStoragePrivate(file);
+
+ media_content_disconnect();
+ return res;
+}
+
+
MSG_LOG("Media type: ", mediaType.mime);
Page *page = nullptr;
- if(mediaType.type != MsgMedia::UnknownType &&
- mediaType.type != MsgMedia::TextType)
+ if(mediaType.type != MsgMedia::UnknownType && mediaType.type != MsgMedia::TextType)
{
page = static_cast<Page*>(getPageForMedia(msgMediaTypeToPageItemType(mediaType.type)));
if(!page)
#include "Message.h"
#include "ContextPopup.h"
#include "App.h"
-#include <string>
#include "MessageDetailContent.h"
#include "FileViewer.h"
#include "MsgUtils.h"
+#include "WorkingDir.h"
namespace Msg
{
, m_pListner(nullptr)
, m_App(app)
, m_WorkingDir(workingDir)
- , m_FileViewer(workingDir)
+ , m_FileViewer()
, m_RecipThumbId(m_App.getThumbnailMaker().getThumbId(ThumbnailMaker::SingleThumb))
, m_SearchWord()
{
WorkingDir::WorkingDir()
{
+ MSG_LOG("");
createWorkingDir();
}
WorkingDir::~WorkingDir()
{
+ MSG_LOG("");
removeWorkingDir();
}
{
MSG_LOG("File added: ", newPath);
}
+ else
+ {
+ MSG_LOG_ERROR("Can't copy to working dir: ", path);
+ newPath.clear();
+ }
}
}
#include "SmilPageLayout.h"
#include "MsgPage.h"
#include "MsgAttachment.h"
+#include "SmilAttachmentItemView.h"
+#include "FileViewer.h"
#include <list>
class SmilPage
: public SmilPageLayout
+ , private ISmilSaveAllItemViewListener
+ , private ISmilAttachmentItemViewListener
{
public:
SmilPage(Evas_Object *parent, const MsgPage &page);
void buildText(const MsgMedia& media);
void buildAudio(const MsgMedia& media);
void buildVideo(const MsgMedia& media);
+ void buildSaveAllItem(int attachmentCount);
void buildAttachmentInfo(int attachmentCount);
void buildAttachment(const MsgAttachment& attachment);
+ // ISmilAttachmentItemViewListener:
+ virtual void onItemClicked(SmilAttachmentItemView &item);
+ virtual void onSaveButtonClicked(SmilAttachmentItemView &item);
+
+ // ISmilSaveAllItemViewListener:
+ virtual void onItemClicked(SmilSaveAllItemView &item);
+
private:
int m_Duration;
std::string m_MediaPath;
bool m_HasAudio;
SmilImageItemView *m_pImageItem;
std::list<std::string> m_Attachments;
+ FileViewer m_FileViewer;
};
}
#include "SmilTextItemView.h"
#include "SmilAudioItemView.h"
#include "SmilVideoItemView.h"
-#include "SmilAttachmentItemView.h"
#include "Logger.h"
#include "FileUtils.h"
#include "MediaPlayer.h"
#include "MediaUtils.h"
+#include <notification.h>
using namespace Msg;
const int defaultPageDuration = 5; // sec;
-std::string makeKbStr(long long bytes);
SmilPage::SmilPage(Evas_Object *parent, const MsgPage &page)
: SmilPageLayout(parent)
return;
buildAttachmentInfo(list.getLength());
+ buildSaveAllItem(list.getLength());
for(int i = 0; i < list.getLength(); ++i)
{
buildAttachment(list[i]);
appendItem(*item);
}
+void SmilPage::buildSaveAllItem(int attachmentCount)
+{
+ SmilSaveAllItemView *item = new SmilSaveAllItemView(getBox(), attachmentCount);
+ item->setListener(this);
+ appendItem(*item);
+}
+
void SmilPage::buildAttachmentInfo(int attachmentCount)
{
SmilAttachmentInfoItemView *item = new SmilAttachmentInfoItemView(getBox(), attachmentCount > 1);
void SmilPage::buildAttachment(const MsgAttachment& attachment)
{
SmilAttachmentItemView *item = new SmilAttachmentItemView(getBox());
+ item->setListener(this);
item->setFilePath(attachment.getFilePath());
item->setFileName(attachment.getFileName());
- item->setFileSize(makeKbStr(attachment.getFileSize()));
item->show();
appendItem(*item);
}
+
+void SmilPage::onItemClicked(SmilAttachmentItemView &item)
+{
+ MSG_LOG("");
+ m_FileViewer.launchWithCopy(item.getFilePath());
+}
+
+void SmilPage::onSaveButtonClicked(SmilAttachmentItemView &item)
+{
+ MSG_LOG("");
+ if(FileUtils::saveFileToStorage(item.getFilePath()))
+ notification_status_message_post(msg("IDS_MSGF_POP_SAVED_IN_MY_FILES").cStr());
+ // TODO: else
+}
+
+void SmilPage::onItemClicked(SmilSaveAllItemView &item)
+{
+ MSG_LOG("");
+ if(!m_Attachments.empty() && FileUtils::saveFilesToStorage(m_Attachments))
+ notification_status_message_post(msg("IDS_MSGF_POP_SAVED_IN_MY_FILES").cStr());
+ // TODO: else
+
+}
namespace Msg
{
class ISmilAttachmentItemViewListener;
+ class ISmilSaveAllItemViewListener;
+ // SmilAttachmentItemView:
class SmilAttachmentItemView
: public View
{
public:
- SmilAttachmentItemView(Evas_Object *parent, const std::string &thumbFilePath = "");
+ SmilAttachmentItemView(Evas_Object *parent);
virtual ~SmilAttachmentItemView();
void setListener(ISmilAttachmentItemViewListener *l);
void setFileName(const std::string &name);
- void setFileSize(const std::string &size);
void setFilePath(const std::string &filePath);
const std::string &getFilePath() const; // Return reference to file path
private:
- void onClickedCb(Evas_Object *obj, const char *emission, const char *source);
- Evas_Object *createItem(Evas_Object *parent, const std::string &thumbFilePath);
- Evas_Object *createIcon(Evas_Object *parent, const std::string &thumbFilePath);
-
- private:
- Evas_Object *m_pItem;
ISmilAttachmentItemViewListener *m_pListener;
std::string m_FilePath;
+ Evas_Object *m_pFileButton;
+ Evas_Object *m_pSaveButton;
};
+ // SmilAttachmentInfoItemView :
class SmilAttachmentInfoItemView
: public View
{
virtual ~SmilAttachmentInfoItemView();
};
+ // SmilSaveAllItemView :
+ class SmilSaveAllItemView
+ : public View
+ {
+ public:
+ SmilSaveAllItemView(Evas_Object *parent, int count);
+ virtual ~SmilSaveAllItemView();
+
+ void setListener(ISmilSaveAllItemViewListener *l);
+
+ private:
+ void onLanguageChanged(Evas_Object *obj, void *eventInfo);
+ void updateTitle();
+
+ private:
+ Evas_Object *m_pButton;
+ ISmilSaveAllItemViewListener *m_pListener;
+ const int m_Count;
+ };
+
class ISmilAttachmentItemViewListener
{
public:
virtual ~ISmilAttachmentItemViewListener() {}
virtual void onItemClicked(SmilAttachmentItemView &item) {};
+ virtual void onSaveButtonClicked(SmilAttachmentItemView &item) {};
+ };
+
+ class ISmilSaveAllItemViewListener
+ {
+ public:
+ virtual ~ISmilSaveAllItemViewListener() {}
+ virtual void onItemClicked(SmilSaveAllItemView &item) {};
};
}
#include "SmilAttachmentItemView.h"
#include "Resource.h"
+#include "FileUtils.h"
+#include "LangUtils.h"
+#include "Logger.h"
using namespace Msg;
namespace
{
- const char *attachmentGroup = "smil_attachment_item";
- const char * attachmentLayoutGroup = "smil_attachment_item_layout";
- const char *iconPart = "item.thumbnail.icon";
- const char *fileNamePart = "item.filename.text";
- const char *fileSizePart = "item.filesize.text";
- const char *attachmentLayoutContentPart = "swallow.content";
+ const float fileButtonWeight = 2.0 / 3.0;
+ const float saveButtonWeight = 1.0 / 3.0;
+ const char *layoutGroupName = "smil_attachment_item_layout";
+ const char *layoutSwallowContent = "swallow.content";
+ #define paddingBetweenButton ELM_SCALE_SIZE(16)
}
-SmilAttachmentItemView::SmilAttachmentItemView(Evas_Object *parent, const std::string &thumbFilePath)
- : m_pItem(nullptr)
- , m_pListener(nullptr)
+SmilAttachmentItemView::SmilAttachmentItemView(Evas_Object *parent)
+ : m_pListener(nullptr)
+ , m_pFileButton(nullptr)
+ , m_pSaveButton(nullptr)
{
- setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, attachmentLayoutGroup));
- setContent(createItem(getEo(), thumbFilePath), attachmentLayoutContentPart);
+ setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, layoutGroupName));
+
+ // Box:
+ Evas_Object *box = elm_box_add(getEo());
+ elm_box_horizontal_set(box, true);
+ elm_box_homogeneous_set(box, false);
+ elm_box_padding_set(box, paddingBetweenButton, 0);
+ evas_object_show(box);
+
+ setContent(box, layoutSwallowContent);
+
+ // File button:
+ m_pFileButton = elm_button_add(box);
+ evas_object_size_hint_weight_set(m_pFileButton, fileButtonWeight, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(m_pFileButton, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_smart_callback_add
+ (
+ m_pFileButton,
+ "clicked",
+ [] (void *data, Evas_Object *obj, void *event_info)
+ {
+ auto *self = (SmilAttachmentItemView*)data;
+ if(self->m_pListener)
+ self->m_pListener->onItemClicked(*self);
+ },
+ this
+ );
+ evas_object_show(m_pFileButton);
+
+ // Save button:
+ m_pSaveButton = elm_button_add(box);
+ evas_object_size_hint_weight_set(m_pSaveButton, saveButtonWeight, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(m_pSaveButton, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ setText(m_pSaveButton, msgt("IDS_MSG_BUTTON_SAVE_ABB2"));
+ evas_object_smart_callback_add
+ (
+ m_pSaveButton,
+ "clicked",
+ [] (void *data, Evas_Object *obj, void *event_info)
+ {
+ auto *self = (SmilAttachmentItemView*)data;
+ if(self->m_pListener)
+ self->m_pListener->onSaveButtonClicked(*self);
+ },
+ this
+ );
+ evas_object_show(m_pSaveButton);
+
+ elm_box_pack_end(box, m_pFileButton);
+ elm_box_pack_end(box, m_pSaveButton);
}
SmilAttachmentItemView::~SmilAttachmentItemView()
m_pListener = l;
}
-void SmilAttachmentItemView::setFileName(const std::string &name)
+const std::string &SmilAttachmentItemView::getFilePath() const
{
- elm_object_part_text_set(m_pItem, fileNamePart, name.c_str());
+ return m_FilePath;
}
-void SmilAttachmentItemView::setFileSize(const std::string &size)
+void SmilAttachmentItemView::setFileName(const std::string &name)
{
- elm_object_part_text_set(m_pItem, fileSizePart, size.c_str());
+ elm_object_text_set(m_pFileButton, name.c_str());
}
void SmilAttachmentItemView::setFilePath(const std::string &filePath)
m_FilePath = filePath;
}
-const std::string &SmilAttachmentItemView::getFilePath() const
+// SmilAttachmentInfoItemView:
+SmilAttachmentInfoItemView::SmilAttachmentInfoItemView(Evas_Object *parent, bool manyAttachments)
{
- return m_FilePath;
-}
+ setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, layoutGroupName));
-Evas_Object *SmilAttachmentItemView::createItem(Evas_Object *parent, const std::string &thumbFilePath)
-{
- m_pItem = addLayout(parent, SMIL_ITEM_EDJ_PATH, attachmentGroup);
- elm_object_signal_callback_add(m_pItem, "clicked", "*", EDJE_SIGNAL_CALLBACK(SmilAttachmentItemView, onClickedCb), this);
+ Evas_Object *entry = elm_entry_add(getEo());
+ elm_entry_editable_set(entry, false);
+ evas_object_show(entry);
- Evas_Object *icon = createIcon(m_pItem, thumbFilePath);
- elm_object_part_content_set(m_pItem, iconPart, icon);
+ setContent(entry, layoutSwallowContent);
- evas_object_show(m_pItem);
- return m_pItem;
+ if(manyAttachments)
+ setText(entry, msgt("IDS_MSGF_POP_HELP_PAGE_MESSAGE"));
+ else
+ setText(entry, msgt("IDS_MSGF_POP_HELP_PAGE_MESSAGE_FOR_ONE_FILE"));
}
-Evas_Object *SmilAttachmentItemView::createIcon(Evas_Object *parent, const std::string &thumbFilePath)
+SmilAttachmentInfoItemView::~SmilAttachmentInfoItemView()
{
- Evas_Object *thumbnail = elm_icon_add(parent);
- if(thumbFilePath.empty())
- {
- std::string imageEdjePath = PathUtils::getResourcePath(IMAGES_EDJ_PATH);
- elm_image_file_set(thumbnail, imageEdjePath.c_str(), ATTACH_IMG);
- }
- else
- {
- // TODO: impl. if needed
- }
- evas_object_size_hint_aspect_set(thumbnail, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
- evas_object_color_set(thumbnail, ICON_COLOR);
- evas_object_show(thumbnail);
- return thumbnail;
}
-void SmilAttachmentItemView::onClickedCb(Evas_Object *obj, const char *emission, const char *source)
+// SmilSaveAllItemView:
+SmilSaveAllItemView::SmilSaveAllItemView(Evas_Object *parent, int count)
+ : m_pButton(nullptr)
+ , m_pListener(nullptr)
+ , m_Count(count)
{
- if(m_pListener)
- m_pListener->onItemClicked(*this);
+ setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, layoutGroupName));
+ m_pButton = elm_button_add(getEo());
+ updateTitle();
+ evas_object_smart_callback_add(m_pButton, "language,changed", SMART_CALLBACK(SmilSaveAllItemView, onLanguageChanged), this);
+ evas_object_smart_callback_add
+ (
+ m_pButton,
+ "clicked",
+ [] (void *data, Evas_Object *obj, void *event_info)
+ {
+ auto *self = (SmilSaveAllItemView*)data;
+ if(self->m_pListener)
+ self->m_pListener->onItemClicked(*self);
+ },
+ this
+ );
+ evas_object_show(m_pButton);
+ setContent(m_pButton, layoutSwallowContent);
}
-// SmilAttachmentInfoItemView:
+SmilSaveAllItemView::~SmilSaveAllItemView()
+{
-SmilAttachmentInfoItemView::SmilAttachmentInfoItemView(Evas_Object *parent, bool manyAttachments)
+}
+
+void SmilSaveAllItemView::setListener(ISmilSaveAllItemViewListener *l)
{
- setEo(elm_entry_add(parent));
- elm_entry_editable_set(getEo(), false);
+ m_pListener = l;
+}
- if(manyAttachments)
- setText(msgt("IDS_MSGF_POP_HELP_PAGE_MESSAGE"));
- else
- setText(msgt("IDS_MSGF_POP_HELP_PAGE_MESSAGE_FOR_ONE_FILE"));
+void SmilSaveAllItemView::updateTitle()
+{
+ std::string title = msg("IDS_MSGF_BUTTON_SAVE_ALL_ATTACHMENTS_ABB");
+ title += " (" + std::to_string(m_Count) + ")";
+ elm_object_text_set(m_pButton, title.c_str());
}
-SmilAttachmentInfoItemView::~SmilAttachmentInfoItemView()
+void SmilSaveAllItemView::onLanguageChanged(Evas_Object *obj, void *eventInfo)
{
+ MSG_LOG("");
+ updateTitle();
}