<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Common/Controller/inc}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Common/AppControl/inc}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Common/ContactManager/inc}""/>
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Conversation/ConvList/View/inc}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Common/MsgEngine/inc}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Common/SystemSettingsManager/inc}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Common/Utils/inc}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Common/Controller/inc}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Common/AppControl/inc}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Common/ContactManager/inc}""/>
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Conversation/ConvList/View/inc}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Common/MsgEngine/inc}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Common/SystemSettingsManager/inc}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src/Common/Utils/inc}""/>
#include "MsgConversationItemDummy.h"
#include "Logger.h"
#include "MsgUtilsDummy.h"
+#include "fakeNames.h"
#include <assert.h>
MsgId MsgConversationItemDummy::getMsgId() const
{
- int id = rand()%100;
+ int id = rand() % 100;
return id;
}
ThreadId MsgConversationItemDummy::getThreadId() const
{
- int id = rand()%50;
+ int id = rand() % 50;
return id;
}
std::string MsgConversationItemDummy::getText() const
{
- return MsgUtilsDummy::getStr();
+ return fakeMessages[rand() % fakeMessages.size()];
}
std::string MsgConversationItemDummy::getSubject() const
{
- return MsgUtilsDummy::getStr();
+ return "Subject";
}
time_t MsgConversationItemDummy::getTime() const
{
- int time = 0;
- return time;
+ return rand();
}
Message::Direction MsgConversationItemDummy::getDirection() const
Message::Type MsgConversationItemDummy::getType() const
{
- int type = 0;
- return MsgUtilsDummy::nativeToMessageType(type);
+ Message::Type type = (Message::Type )(rand() % Message::MT_MMS + 1);
+ return type;
}
Message::NetworkStatus MsgConversationItemDummy::getNetworkStatus() const
{
- return MsgUtilsDummy::nativeToNetworkStatus(0);
+ Message::NetworkStatus m[] = {Message::NS_Sending,
+ Message::NS_Send_Success,
+ Message::NS_Received,
+ Message::NS_Retrieving,
+ Message::NS_Retrieve_Success,
+ Message::NS_Retrieve_Fail,
+ Message::NS_Send_Fail};
+
+ size_t count = sizeof(m) / sizeof(Message::NetworkStatus);
+ size_t index = rand() % count;
+ return m[index];
}
bool MsgConversationItemDummy::isDraft() const
bool MsgConversationItemDummy::isRestrictedByDpm() const
{
- return true;
+ return false;
}
Message::Direction MsgUtilsDummy::nativeToDirection(int direction)
{
- return Message::MD_Sent;
+ return (Message::Direction)(rand() % 2);
}
Message::MessageStorageType MsgUtilsDummy::nativeToMessageStorage(int id)
int MsgUtilsDummy::addressTypeToNative(MsgAddress::AddressType type)
{
- return 0;
+ return 0;
}
MsgAddress::AddressType MsgUtilsDummy::nativeToAddressType(int type)
{
return MsgAddress::Phone;
-
}
-
MsgReport::DeliveryStatus MsgUtilsDummy::nativeToReportDeliveryStatus(int status)
{
return MsgReport::StatusNone;
--- /dev/null
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WorkingDir_h_
+#define WorkingDir_h_
+
+#include <string>
+#include <memory>
+#include <mutex>
+
+namespace Msg {
+ class WorkingDir {
+ public:
+ WorkingDir();
+ ~WorkingDir();
+
+ WorkingDir(WorkingDir&) = delete;
+ void operator=(WorkingDir&) = delete;
+
+ bool isValid() const;
+ const std::string &getPath() const;
+
+ std::string genUniqueFilePath(const std::string &fileName) const;
+ std::string addFile(const std::string &path);
+ std::string addTextFile(const std::string &text, const std::string &fileName = "");
+ void removeFile(const std::string &path);
+ void clear();
+
+ private:
+ void createWorkingDir();
+ void removeWorkingDir();
+ std::string getUniqueDirName(const std::string &path);
+
+ private:
+ std::string m_Path;
+ mutable std::recursive_mutex m_Mutex;
+ };
+
+ typedef std::shared_ptr<WorkingDir> WorkingDirRef;
+}
+
+#endif /* WorkingDir_h_ */
--- /dev/null
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "WorkingDir.h"
+#include "PathUtils.h"
+#include "FileUtils.h"
+#include "Logger.h"
+
+#include <string>
+#include <fstream>
+
+using namespace Msg;
+
+const std::string commonWorkingDirName = "Temp";
+const std::string currentWorkingDirPrefix = "Temp";
+const std::string textFileName = "mms.txt";
+
+
+WorkingDir::WorkingDir()
+{
+ MSG_LOG("");
+ createWorkingDir();
+}
+
+WorkingDir::~WorkingDir()
+{
+ MSG_LOG("");
+ removeWorkingDir();
+}
+
+void WorkingDir::createWorkingDir()
+{
+ // Create common dir. if not exists:
+ std::string commonDir = PathUtils::getDataPath(commonWorkingDirName);
+ bool isCommonExists = FileUtils::isExists(commonDir);
+ if (!isCommonExists) {
+ isCommonExists = FileUtils::makeDir(commonDir);
+ MSG_ASSERT(isCommonExists, "Can't create common working dir: ", commonDir);
+ }
+
+ // Create current dir:
+ if (isCommonExists) {
+ std::string uniqueDir = getUniqueDirName(commonDir + "/" + currentWorkingDirPrefix);
+ FileUtils::makeDir(uniqueDir);
+ bool isExists = FileUtils::isExists(uniqueDir);
+ MSG_ASSERT(isExists, "Can't create current working dir: ", uniqueDir);
+ if (isExists)
+ m_Path = uniqueDir;
+ }
+}
+
+void WorkingDir::removeWorkingDir()
+{
+ if (!m_Path.empty()) {
+ bool res = FileUtils::remove(m_Path, true);
+ MSG_LOG("Working dir remove with result = ", res);
+ }
+}
+
+bool WorkingDir::isValid() const
+{
+ return !m_Path.empty() && FileUtils::isExists(m_Path);
+}
+
+const std::string &WorkingDir::getPath() const
+{
+ return m_Path;
+}
+
+std::string WorkingDir::genUniqueFilePath(const std::string &path) const
+{
+ std::lock_guard<std::recursive_mutex> _lock(m_Mutex);
+ return FileUtils::genUniqueFilePath(m_Path, path);
+}
+
+std::string WorkingDir::addFile(const std::string &path)
+{
+ std::lock_guard<std::recursive_mutex> _lock(m_Mutex);
+ std::string newPath;
+
+ if (FileUtils::isExists(path)) {
+ if (path.find(m_Path) != std::string::npos) {
+ newPath = path;
+ MSG_LOG("File is already exists: ", newPath);
+ } else {
+ newPath = genUniqueFilePath(path);
+ if (FileUtils::copy(path, newPath)) {
+ MSG_LOG("File added: ", newPath);
+ } else {
+ MSG_LOG_ERROR("Can't copy to working dir: ", path);
+ newPath.clear();
+ }
+ }
+ }
+
+ return newPath;
+}
+
+std::string WorkingDir::addTextFile(const std::string &text, const std::string &fileName)
+{
+ std::lock_guard<std::recursive_mutex> _lock(m_Mutex);
+ std::string result;
+ result = fileName.empty() ? textFileName : fileName;
+
+ std::string path = genUniqueFilePath(result);
+ std::ofstream file(path, std::ofstream::trunc | std::ofstream::binary | std::ofstream::out);
+ if (file.is_open()) {
+ file << text;
+ MSG_LOG("Text file added: ", path);
+ } else {
+ path.clear();
+ }
+
+ return path;
+}
+
+void WorkingDir::removeFile(const std::string &path)
+{
+ std::lock_guard<std::recursive_mutex> _lock(m_Mutex);
+ if (!path.empty())
+ FileUtils::remove(path);
+}
+
+void WorkingDir::clear()
+{
+ std::lock_guard<std::recursive_mutex> _lock(m_Mutex);
+ FileUtils::remove(m_Path, false);
+}
+
+std::string WorkingDir::getUniqueDirName(const std::string &path)
+{
+ std::string res;
+ unsigned i = 0;
+ do {
+ res = path + "-" + std::to_string(i);
+ ++i;
+ } while (FileUtils::isExists(res));
+ return res;
+}
--- /dev/null
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BubbleEntityFactory_h_
+#define BubbleEntityFactory_h_
+
+#include "MsgConvMedia.h"
+#include "WorkingDir.h"
+
+// Bubble items:
+#include "BubbleTextEntity.h"
+/*
+#include "BubbleImageEntity.h"
+#include "BubbleVideoEntity.h"
+#include "BubbleAudioEntity.h"
+#include "BubbleDownloadButtonEntity.h"
+#include "BubbleUnknownFileEntity.h"
+#include "BubbleCalEventEntity.h"
+#include "BubbleContactEntity.h"
+*/
+
+#include <string>
+
+namespace Msg {
+ class BubbleEntityFactory {
+ public:
+ BubbleEntityFactory(WorkingDirRef &workingDir);
+ ~BubbleEntityFactory();
+
+ BubbleEntity *createEntity(std::string filePath, Message::Direction direction);
+ BubbleEntity *createEntity(const MsgConvMedia &msgMedia, Message::Direction direction);
+ BubbleTextEntity *createTextEntity(std::string text, Message::Direction direction);
+
+ private:
+ BubbleEntity *createTextEntityFromFile(std::string filePath, Message::Direction direction);
+ BubbleEntity *createEntity(std::string filePath, std::string fileName, std::string mime, Message::Direction direction);
+ BubbleEntity *createVideoEntity(std::string filePath, std::string fileName, Message::Direction direction);
+ BubbleEntity *createAudioEntity(std::string filePath, std::string fileName, Message::Direction direction);
+ BubbleEntityFactory(BubbleEntityFactory&) = delete;
+ BubbleEntityFactory& operator=(const BubbleEntityFactory&) = delete;
+
+ private:
+ WorkingDirRef m_WorkingDir;
+ };
+}
+
+#endif /* BubbleEntityFactory_h_ */
#include "AppControlCompose.h"
#include "AppControlDefault.h"
#include "ConvList.h"
+#include "WorkingDir.h"
namespace Msg
{
private:
+ void prepareWorkingDir();
void prepareLayout();
void prepareMoreOption();
void prepareDeleteViews();
MoreOption *m_pMoreOption;
BottomButton *m_pDeleteButton;
SelectButton *m_pSelectButton;
+ WorkingDirRef m_WorkingDir;
};
}
#include "ListView.h"
#include "MsgEngine.h"
+#include "WorkingDir.h"
+#include "BubbleEntityFactory.h"
+#include "ConvListItem.h"
+
+#include <unordered_map>
+#include <unordered_set>
namespace Msg {
: public ListView
, private IListViewListener {
public:
- ConvList(Evas_Object *parent);
+ ConvList(Evas_Object *parent, WorkingDirRef &workingDir);
virtual ~ConvList();
void setThreadId(ThreadId id);
bool getDeleteMode() const;
private:
+ typedef std::unordered_map<MsgId::Type, ConvListItem*> ConvListItemMap;
+ typedef std::unordered_set<std::string> DateLineItemSet;
+
void onListItemSelected(ListItem &listItem) override;
void onListItemLongPressed(ListItem &listItem) override;
void onListItemChecked(ListItem &listItem) override;
- private:
void fillList();
MsgStorage &getMsgStorage();
void insertItem(const MsgConversationItem &item);
IConvListListener *m_pListener;
PaddingListViewItem *m_pBottomPadItem;
ConvReplyListItem *m_pReplyItem;
+ WorkingDirRef m_WorkingDir;
+ BubbleEntityFactory m_BubbleEntityFactory;
+ ConvListItemMap m_ConvListItemMap;
+ DateLineItemSet m_DateLineItemSet;
};
class IConvListListener {
--- /dev/null
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ConvListItem_h_
+#define ConvListItem_h_
+
+#include "ConvListViewItem.h"
+#include "BubbleViewItem.h"
+#include "MsgTypes.h"
+#include "Message.h"
+#include "WorkingDir.h"
+
+#include <list>
+
+namespace Msg {
+
+ class MsgConversationItem;
+ class BubbleEntityFactory;
+ class BubbleEntity;
+
+ class ConvListItem
+ : public ConvListViewItem
+ , private IBubbleViewItemListener {
+
+ public:
+ ConvListItem(const MsgConversationItem &item,
+ WorkingDirRef &workingDir,
+ BubbleEntityFactory &bubbleEntityFactory);
+ virtual ~ConvListItem();
+
+ MsgId getMsgId() const;
+ time_t getRawTime() const;
+ void updateStatus();
+ void updateTime();
+
+ protected:
+ Evas_Object *getBubbleContent() override;
+ std::string getTime() override;
+ std::string getMsgType() override;
+
+ private:
+ // IBubbleViewItemListener
+ void onAction(BubbleViewItem &item) override;
+
+ void updateViewStatus();
+ void prepareContent(const MsgConversationItem &item);
+ void addEntity(BubbleEntity *entity);
+
+ private:
+ MsgId m_MsgId;
+ time_t m_Time;
+ Message::Direction m_Direction;
+ Message::NetworkStatus m_NetworkStatus;
+ Message::Type m_Type;
+ std::string m_TimeStr;
+ std::list<BubbleEntity*> m_BubbleEntityList;
+ WorkingDirRef m_WorkingDir;
+ BubbleEntityFactory &m_BubbleEntityFactory;
+ };
+}
+
+#endif /* ConvListItem_h_ */
--- /dev/null
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "BubbleEntityFactory.h"
+#include "FileUtils.h"
+#include "MediaType.h"
+#include "MediaUtils.h"
+
+// Bubble items:
+#include "BubbleTextEntity.h"
+/*
+#include "BubbleImageEntity.h"
+#include "BubbleVideoEntity.h"
+#include "BubbleAudioEntity.h"
+#include "BubbleDownloadButtonEntity.h"
+#include "BubbleUnknownFileEntity.h"
+#include "BubbleCalEventEntity.h"
+#include "BubbleContactEntity.h"
+*/
+
+#include <algorithm>
+
+using namespace Msg;
+
+BubbleEntityFactory::BubbleEntityFactory(WorkingDirRef &workingDir)
+ : m_WorkingDir(workingDir)
+{
+}
+
+BubbleEntityFactory::~BubbleEntityFactory()
+{
+}
+
+BubbleEntity *BubbleEntityFactory::createEntity(const MsgConvMedia &msgMedia, Message::Direction direction)
+{
+ std::string mime = msgMedia.getMime();
+ std::string fileName = msgMedia.getName();
+ std::string filePath = msgMedia.getPath();
+
+ if (mime.empty())
+ mime = FileUtils::getMimeType(filePath);
+
+ if (fileName.empty())
+ fileName = FileUtils::getFileName(filePath);
+
+ return createEntity(filePath, fileName, mime, direction);
+}
+
+BubbleEntity *BubbleEntityFactory::createEntity(std::string filePath, Message::Direction direction)
+{
+ return createEntity(std::move(filePath), FileUtils::getFileName(filePath), FileUtils::getMimeType(filePath), direction);
+}
+
+BubbleTextEntity *BubbleEntityFactory::createTextEntity(std::string text, Message::Direction direction)
+{
+ return text.empty() ? nullptr : new BubbleTextEntity(direction, std::move(text));
+}
+
+BubbleEntity *BubbleEntityFactory::createAudioEntity(std::string filePath, std::string fileName, Message::Direction direction)
+{
+ // TDOO: impl.
+ return nullptr;
+
+/* if (MediaUtils::hasAudio(filePath))
+ return new BubbleAudioEntity(filePath, fileName, direction);
+
+ // File does not contain audio or broken:
+ return new BubbleUnknownFileEntity(filePath, fileName, bgType, direction);*/
+}
+
+BubbleEntity *BubbleEntityFactory::createVideoEntity(std::string filePath, std::string fileName, Message::Direction direction)
+{
+ // TDOO: impl.
+ return nullptr;
+
+/* if (MediaUtils::hasVideo(filePath))
+ return new BubbleVideoEntity(m_WorkingDir, filePath, direction);
+
+ // Try to create Audio entity.
+ return createAudioEntity(filePath, fileName, bgType, direction);*/
+}
+
+BubbleEntity *BubbleEntityFactory::createTextEntityFromFile(std::string filePath, Message::Direction direction)
+{
+ std::string text = FileUtils::readTextFile(filePath);
+ BubbleTextEntity *entity = createTextEntity(std::move(text), direction);
+ if (entity)
+ entity->setFilePath(std::move(filePath));
+ return entity;
+}
+
+BubbleEntity *BubbleEntityFactory::createEntity(std::string filePath, std::string fileName, std::string mime, Message::Direction direction)
+{
+ if (FileUtils::isExists(filePath)) {
+ std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower);
+ MsgMedia::Type msgMediaType = getMsgMediaTypeByMime(mime);
+
+ switch (msgMediaType) {
+ case MsgMedia::TextType:
+ return createTextEntityFromFile(std::move(filePath), direction);
+
+ // TDOO: impl.
+
+ /* case MsgMedia::ImageType:
+ return new BubbleImageEntity(filePath, direction);
+ case MsgMedia::AudioType:
+ return createAudioEntity(filePath, fileName, direction);
+ case MsgMedia::VideoType:
+ return createVideoEntity(filePath, fileName, direction);
+ default:
+ if (mime == "text/x-vcalendar" || mime == "text/calendar")
+ return new BubbleCalEventEntity(filePath, fileName, direction);
+ else if (mime == "text/x-vcard" ||
+ mime == "text/vcard" ||
+ mime == "text/x-vcalendar")
+ return new BubbleContactEntity(m_App, filePath, fileName, direction);
+ else if (mime != "application/smil")
+ return new BubbleUnknownFileEntity(filePath, fileName, direction);
+ */
+ }
+ }
+
+ return nullptr;
+}
+
, m_pDeleteButton(nullptr)
, m_pSelectButton(nullptr)
{
+ prepareWorkingDir();
prepareLayout();
prepareList();
prepareMoreOption();
// TODO: impl.
}
+void ConvFrame::prepareWorkingDir()
+{
+ if (!m_WorkingDir)
+ m_WorkingDir = std::make_shared<WorkingDir>();
+}
+
void ConvFrame::prepareLayout()
{
if (!m_pLayout) {
void ConvFrame::prepareList()
{
if (!m_pList) {
- m_pList = new ConvList(*m_pLayout);
+ m_pList = new ConvList(*m_pLayout, m_WorkingDir);
m_pList->setListener(this);
m_pLayout->setContent(*m_pList);
}
using namespace Msg;
-ConvList::ConvList(Evas_Object *parent)
+ConvList::ConvList(Evas_Object *parent, WorkingDirRef &workingDir)
: ListView(parent, App::getInst().getWindow().getCircleSurface())
, m_DeleteMode(false)
, m_pListener(nullptr)
, m_pBottomPadItem(nullptr)
, m_pReplyItem(nullptr)
+ , m_WorkingDir(workingDir)
+ , m_BubbleEntityFactory(m_WorkingDir)
{
ListView::setListener(this);
ListView::setHomogeneous(false);
ListView::setMultiSelection(false);
ListView::enabledAlign(false);
-
- fillList();
}
ConvList::~ConvList()
void ConvList::insertItem(const MsgConversationItem &item)
{
+ ListView::appendItem(*new ConvListItem(item, m_WorkingDir, m_BubbleEntityFactory));
}
void ConvList::setThreadId(ThreadId id)
--- /dev/null
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ConvListItem.h"
+#include "MsgEngine.h"
+#include "TimeUtils.h"
+#include "MsgUtils.h"
+#include "MediaUtils.h"
+#include "FileUtils.h"
+#include "FileViewer.h"
+#include "Logger.h"
+#include "ListView.h"
+#include "App.h"
+
+#include <algorithm>
+
+// Bubble items:
+#include "BubbleItemContainer.h"
+#include "BubbleEntityFactory.h"
+#include "BubbleTextEntity.h"
+// #include "BubbleImageEntity.h"
+// #include "BubbleVideoEntity.h"
+// #include "BubbleAudioEntity.h"
+// #include "BubbleDownloadButtonEntity.h"
+// #include "BubbleUnknownFileEntity.h"
+// #include "BubbleCalEventEntity.h"
+// #include "BubbleContactEntity.h"
+
+using namespace Msg;
+
+ConvListItem::ConvListItem(const MsgConversationItem &item,
+ WorkingDirRef &workingDir,
+ BubbleEntityFactory &bubbleEntityFactory)
+ : ConvListViewItem(item.getDirection() == Message::MD_Sent ? Sent : Received)
+ , m_MsgId(item.getMsgId())
+ , m_Time(item.getTime())
+ , m_Direction(item.getDirection())
+ , m_NetworkStatus(item.getNetworkStatus())
+ , m_Type(item.getType())
+ , m_WorkingDir(workingDir)
+ , m_BubbleEntityFactory(bubbleEntityFactory)
+{
+ prepareContent(item);
+ updateViewStatus();
+}
+
+ConvListItem::~ConvListItem()
+{
+ for (auto *entity : m_BubbleEntityList)
+ delete entity;
+
+ m_BubbleEntityList.clear();
+}
+
+MsgId ConvListItem::getMsgId() const
+{
+ return m_MsgId;
+}
+
+time_t ConvListItem::getRawTime() const
+{
+ return m_Time;
+}
+
+void ConvListItem::updateViewStatus()
+{
+ switch (m_NetworkStatus) {
+ case Message::NS_Send_Fail:
+ setInfoStatus(ConvListViewItem::FailedStatus);
+ break;
+
+ case Message::NS_Sending:
+ setInfoStatus(ConvListViewItem::ProgressStatus);
+ break;
+
+ case Message::NS_Retrieving:
+ case Message::NS_Retrieve_Success:
+ case Message::NS_Retrieve_Fail:
+ setInfoStatus(m_NetworkStatus == Message::NS_Retrieving ? ProgressStatus : NoneStatus);
+ break;
+
+ default:
+ setInfoStatus(NoneStatus);
+ break;
+ }
+}
+
+void ConvListItem::updateStatus()
+{
+ MessageRef msg = App::getInst().getMsgEngine().getStorage().getMessage(m_MsgId);
+ if (msg) {
+ m_Time = msg->getTime();
+ m_NetworkStatus = msg->getNetworkStatus();
+ updateTime();
+ updateViewStatus();
+ }
+}
+
+void ConvListItem::updateTime()
+{
+ m_TimeStr.clear();
+}
+
+void ConvListItem::prepareContent(const MsgConversationItem &item)
+{
+ if (MsgUtils::isSms(m_Type)) {
+ addEntity(m_BubbleEntityFactory.createTextEntity(item.getText(), m_Direction));
+ } else if (m_Type == Message::MT_MMS_Noti) {
+ // TODO: impl.
+ } else {
+ const MsgConvMediaList &list = item.getMediaList();
+ for (int i = 0; i < list.getLength(); ++i) {
+ const MsgConvMedia &media = list.at(i);
+ addEntity(m_BubbleEntityFactory.createEntity(media, m_Direction));
+ }
+ }
+}
+
+void ConvListItem::addEntity(BubbleEntity *entity)
+{
+ if (entity)
+ m_BubbleEntityList.push_back(entity);
+}
+
+Evas_Object *ConvListItem::getBubbleContent()
+{
+ if (m_BubbleEntityList.empty())
+ return nullptr;
+
+ auto *bubble = new BubbleItemContainer(*getOwner());
+ for (BubbleEntity *entity : m_BubbleEntityList) {
+ BubbleViewItem *item = entity->createView(*bubble);
+ if (item) {
+ bubble->append(*item, entity->getDirection());
+ item->setListener(this);
+ }
+ }
+ bubble->go();
+ bubble->show();
+ return *bubble;
+}
+
+std::string ConvListItem::getTime()
+{
+ if (m_TimeStr.empty())
+ m_TimeStr = TimeUtils::makeBubbleTimeString(m_Time);
+ return m_TimeStr;
+}
+
+std::string ConvListItem::getMsgType()
+{
+ return MsgUtils::isMms(m_Type) ? (std::string)msg("WDS_MSG_SBODY_MMS_ABB") : "";
+}
+
+void ConvListItem::onAction(BubbleViewItem &item)
+{
+ MSG_LOG("");
+ // TODO: iml.
+}
+
+
enum InfoStatusType {
NoneStatus,
- SendingStatus,
+ ProgressStatus,
FailedStatus
};
virtual ~ConvListViewItem();
void setCheckedState(bool state);
- void setInfoStatusType(InfoStatusType statusType, bool updateUi);
+ void setInfoStatus(InfoStatusType statusType);
protected:
virtual Evas_Object *getBubbleContent() = 0;
protected:
void updateContent();
- void updateItemType(ConvItemType type);
private:
- virtual std::string getText(ListItem &item, const char *part);
- virtual Evas_Object *getContent(ListItem &item, const char *part);
+ std::string getText(ListItem &item, const char *part) override;
+ Evas_Object *getContent(ListItem &item, const char *part) override;
Evas_Object *createProgress();
Evas_Object *createFailedButton();
+ void updateItemType(ConvItemType type);
private:
ConvItemType m_Type;
emitSignal(sig, "");
}
-void ConvListViewItem::setInfoStatusType(InfoStatusType statusType, bool updateUi)
+void ConvListViewItem::setInfoStatus(InfoStatusType statusType)
{
if (statusType == m_Status)
return;
m_Status = statusType;
- if (updateUi) {
+ if (getElmObjItem()) {
updateFields(infoStatus, ELM_GENLIST_ITEM_FIELD_CONTENT);
updateFields(timeTextPart, ELM_GENLIST_ITEM_FIELD_TEXT);
updateFields(msgType, ELM_GENLIST_ITEM_FIELD_TEXT);
return getBubbleContent();
} else if (!strcmp(part, infoStatus)) {
if (m_Type == Sent) {
- if (m_Status == SendingStatus)
+ if (m_Status == ProgressStatus)
return createProgress();
if (m_Status == FailedStatus)
return createFailedButton();