MessageRef MsgStoragePrivate::getMessage(MsgId id)
{
MessageRef msgRef;
- msg_struct_t msg = nullptr;
-
+ msg_struct_t msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
- if(msg_get_message(m_ServiceHandle, (msg_message_id_t)id, msg, sendOpt) == 0)
+
+ if(msg_get_message(m_ServiceHandle, id, msg, sendOpt) == 0)
{
int msgType = MSG_TYPE_INVALID;
msg_get_int_value(msg, MSG_MESSAGE_TYPE_INT, &msgType);
MSG_ASSERT(false, "Unsupported message type");
}
}
+ else
+ {
+ msg_release_struct(&msg);
+ }
msg_release_struct(&sendOpt);
return msgRef;
}
res += firstPart;
res += "<match>";
- res += searchWord;
+ res += std::string(found, searchWord.length());
res += "</match>";
res += lastPart;
void setContent(Evas_Object *obj);
void setBg(Evas_Object *obj);
void setFloatingButton(Evas_Object *obj);
+ void showFloatingButton(bool show);
+ private:
+ Evas_Object *m_pFloatingBtn;
};
}
void setSelected(bool selected);
bool getSelected() const;
void setExpanded(bool expand);
- virtual void update();
+ void update();
void updateFields(const char *parts, Elm_Genlist_Item_Field_Type type);;
ListView *getOwner() const;
Elm_Genlist_Item_Type getType() const;
inline void setSizeHintMin(Evas_Coord w, Evas_Coord h);
inline void setSizeHintMax(Evas_Coord w, Evas_Coord h);
Evas_Object *setContent(Evas_Object *content, const char *part = nullptr, bool saveOldContent = false);
+ inline Evas_Object *unsetContent(const char *part = nullptr);
inline Evas_Object* getContent(const char *part = nullptr) const;
inline void setFocusAllow(bool enable);
inline bool getFocusAllow() const;
{
evas_object_event_callback_add(m_pEo, type, func, data);
}
+
+ inline Evas_Object *View::unsetContent(const char *part)
+ {
+ return elm_object_part_content_unset(m_pEo, part);
+ }
}
#endif /* View_h_ */
using namespace Msg;
+namespace
+{
+ const char *floatingPart = "elm.swallow.floatingbutton";
+}
+
DefaultLayout::DefaultLayout(Evas_Object *parent)
+ : m_pFloatingBtn(nullptr)
{
setEo(elm_layout_add(parent));
elm_layout_theme_set(getEo(), "layout", "application", "default");
void DefaultLayout::setFloatingButton(Evas_Object *obj)
{
- elm_object_part_content_set(getEo(), "elm.swallow.floatingbutton", obj);
+ m_pFloatingBtn = obj;
+ elm_object_part_content_set(getEo(), floatingPart, obj);
+}
+
+void DefaultLayout::showFloatingButton(bool show)
+{
+ if(show)
+ {
+ View::setContent(m_pFloatingBtn, floatingPart, true);
+ evas_object_show(m_pFloatingBtn);
+ }
+ else
+ {
+ View::unsetContent(floatingPart);
+ evas_object_hide(m_pFloatingBtn);
+ }
}
namespace Msg
{
+ class ConvListItem;
+
class ConvList
: public ConvListLayout
, private IMsgStorageListener
*/
void setThreadId(ThreadId id);
+ /**
+ * @brief Navigate to mesage
+ * @param[in] msgId message id to navigate
+ */
+ void navigateTo(MsgId msgId);
+
private:
void create(Evas_Object *parent);
Evas_Object *createSelectAll(Evas_Object *parent);
void fill();
void selectListItems(bool state);
bool isAllListItemSelected() const;
+ ConvListItem *getItem(MsgId msgId) const;
// IListViewListener:
virtual void onListItemSelected(ListItem &listItem, void *funcData);
ConvListItem(MsgConversationItem &item);
virtual ~ConvListItem();
+ MsgId getMsgId() const;
+
protected:
virtual Evas_Object *getBubble();
virtual std::string getText();
fill();
}
+void ConvList::navigateTo(MsgId msgId)
+{
+ ConvListItem *item = getItem(msgId);
+ if(item)
+ m_pList->showItem(*item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
+}
+
+ConvListItem *ConvList::getItem(MsgId msgId) const
+{
+ auto items = m_pList->getItems<ConvListItem>();
+ for(ConvListItem *item : items)
+ {
+ if(item->getMsgId() == msgId)
+ return item;
+ }
+ return nullptr;
+}
+
bool ConvList::isAllListItemSelected() const
{
// Simple but not fast impl:
//TODO: convert time_t to string
return "10:23 PM";
}
+
+MsgId ConvListItem::getMsgId() const
+{
+ return m_MsgId;
+}
Conversation(NaviFrameController &parent, ThreadId threadId);
virtual ~Conversation();
+ void navigateTo(MsgId msgId);
+
private:
enum Mode
{
setHwButtonListener(*m_pLayout, this);
}
+void Conversation::navigateTo(MsgId msgId)
+{
+ m_pConvList->navigateTo(msgId);
+}
+
void Conversation::setMode(Mode mode)
{
if(m_Mode == mode)
class RecipientsPanel
: public RecipientsPanelView,
- public IContactPickerListener
+ private IContactPickerListener
{
public:
RecipientsPanel(Evas_Object *parent, App &app);
--- /dev/null
+/*
+ * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 BaseThreadListItem_h_
+#define BaseThreadListItem_h_
+
+#include "ThreadListViewItem.h"
+#include "ThumbnailMaker.h"
+#include "MsgThreadItem.h"
+#include "MsgAddress.h"
+#include "App.h"
+
+#include <time.h>
+
+namespace Msg
+{
+ class BaseThreadListItem
+ : public ThreadListViewItem
+ {
+ public:
+ BaseThreadListItem(App &app);
+ virtual ~BaseThreadListItem();
+
+ protected:
+ void updateThumbnail(const MsgAddress &addr);
+ void updateThumbnail(const MsgAddressList &addressList);
+ void updateThumbnail(const MsgThreadItem &threadItem);
+ void updateTime(time_t time);
+
+ // ThreadListViewItem:
+ virtual std::string getName();
+ virtual std::string getMessage();
+ virtual std::string getTime();
+ virtual Evas_Object *getThumbnail();
+
+ App &m_App;
+ ThumbnailMaker::Type m_ThumbType;
+ std::string m_ThumbPath;
+ std::string m_Name;
+ std::string m_Message;
+ std::string m_Time;
+ };
+}
+
+#endif // BaseThreadListItem_h_
--- /dev/null
+/*
+ * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 MsgSearchListItem_h_
+#define MsgSearchListItem_h_
+
+#include "BaseThreadListItem.h"
+#include "Message.h"
+
+namespace Msg
+{
+ class MsgSearchListItem
+ : public BaseThreadListItem
+ {
+ public:
+ MsgSearchListItem(App &app, const Message &msg, const std::string &searchWord);
+ virtual ~MsgSearchListItem();
+
+ MsgId getMsgId() const;
+
+ private:
+ void update(const Message &msg, const std::string &searchWord);
+ void updateThumbnail(const Message &msg);
+
+
+ private:
+ MsgId m_MsgId;
+ };
+}
+
+#endif // MsgSearchListItem_h_
// ThreadSearchList:
virtual void onSearchListChanged();
+ virtual void onSearchListItemSelected(ThreadId id);
+ virtual void onSearchListItemSelected(MsgId id);
private:
enum Mode
// MsgThread:
void composeNewMessage();
void navigateToSettings();
- void navigateToConversation(ThreadId threadId);
+ void navigateToConversation(ThreadId threadId, MsgId msgId = MsgId());
void showMainCtxPopup();
void setMode(Mode mode);
void setDeleteMode(bool value);
#ifndef ThreadListItem_h_
#define ThreadListItem_h_
-#include "ThreadListViewItem.h"
-#include "ViewItemController.h"
+#include "BaseThreadListItem.h"
#include "MsgThreadItem.h"
#include "ThumbnailMaker.h"
#include "ContactPersonNumber.h"
namespace Msg
{
class ThreadListItem
- : public ThreadListViewItem
+ : public BaseThreadListItem
{
public:
ThreadListItem(const MsgThreadItem &threadItem, App &app);
ThreadId getThreadId() const;
void updateModel(const MsgThreadItem &threadItem);
- void updateThumbnail(const MsgThreadItem &threadItem);
private:
// ThreadListViewItem:
- virtual std::string getName();
- virtual std::string getMessage();
- virtual std::string getTime();
virtual std::string getStatus();
- virtual Evas_Object *getThumbnail();
virtual Evas_Object *getIcon();
Evas_Object *makeUnreadBadge(int unreadCount);
private:
ThreadId m_ThreadId;
- App &m_App;
- ThumbnailMaker::Type m_ThumbType;
- std::string m_ThumbPath;
- std::string m_Name;
- std::string m_Message;
- std::string m_Time;
std::string m_Status;
};
}
#include "ListView.h"
#include "App.h"
+#include "MsgTypes.h"
#include <Ecore.h>
class ThreadSearchList
: public ListView
+ , private IListViewListener
{
public:
ThreadSearchList(Evas_Object *parent, App &app);
void setListener(IThreadSearchListListener *l);
void requestSearch(const std::string &searchWord);
void cancelSearch();
+ const std::string &getSearchWord() const;
private:
+ // IListViewListener:
+ virtual void onListItemSelected(ListItem &listItem, void *funcData);
+
void search();
private:
public:
virtual ~IThreadSearchListListener() {}
virtual void onSearchListChanged() {};
+ virtual void onSearchListItemSelected(ThreadId id) {};
+ virtual void onSearchListItemSelected(MsgId id) {};
};
}
#ifndef ThreadSearchListItem_h_
#define ThreadSearchListItem_h_
-#include "ThreadListViewItem.h"
-#include "ThumbnailMaker.h"
-#include "App.h"
-#include "Message.h"
+#include "BaseThreadListItem.h"
+#include "MsgThreadItem.h"
#include "MsgTypes.h"
namespace Msg
{
class ThreadSearchListItem
- : public ThreadListViewItem
+ : public BaseThreadListItem
{
public:
- ThreadSearchListItem(const Message &msg, App &app, const std::string &searchWord);
+ ThreadSearchListItem(App &app, const MsgThreadItem &item, const std::string &searchWord);
virtual ~ThreadSearchListItem();
- MsgId getMsgId() const;
+ ThreadId getThreadId() const;
private:
- void updateModel(const Message &msg, const std::string &searchWord);
- void updateThumbnail(const Message &msg);
-
- // ThreadListViewItem:
- virtual std::string getName();
- virtual std::string getMessage();
- virtual std::string getTime();
- virtual Evas_Object *getThumbnail();
-
- Evas_Object *makeUnreadBadge(int unreadCount);
+ void update(const MsgThreadItem &item, const std::string &searchWord);
private:
- MsgId m_MsgId;
- App &m_App;
- ThumbnailMaker::Type m_ThumbType;
- std::string m_ThumbPath;
- std::string m_Name;
- std::string m_Message;
- std::string m_Time;
+ ThreadId m_ThreadId;
};
}
--- /dev/null
+/*
+ * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "BaseThreadListItem.h"
+#include "ContactManager.h"
+#include "Resource.h"
+#include "ListView.h"
+
+using namespace Msg;
+
+BaseThreadListItem::BaseThreadListItem(App &app)
+ : m_App(app)
+ , m_ThumbType(ThumbnailMaker::UserType)
+{
+
+}
+
+BaseThreadListItem::~BaseThreadListItem()
+{
+
+}
+
+void BaseThreadListItem::updateThumbnail(const MsgThreadItem &threadItem)
+{
+ const MsgAddressListRef addressList = m_App.getMsgEngine().getStorage().getAddressList(threadItem.getId());
+ if(addressList)
+ updateThumbnail(*addressList);
+}
+
+void BaseThreadListItem::updateThumbnail(const MsgAddressList &addressList)
+{
+ int countContact = addressList.getLength();
+ m_ThumbType = ThumbnailMaker::MsgType;
+ if(countContact > 1)
+ {
+ m_ThumbPath = PathUtils::getResourcePath(THUMB_GROUP_IMG_PATH);
+ }
+ else if(countContact == 1)
+ {
+ const MsgAddress &addr = addressList[0];
+ updateThumbnail(addr);
+ }
+}
+
+void BaseThreadListItem::updateThumbnail(const MsgAddress &addr)
+{
+ ContactPersonNumber contactNumber = m_App.getContactManager().getContactPersonNumber(addr.getAddress());
+ const char *thumbPath = contactNumber.isValid() ? contactNumber.getThumbnailPath() : nullptr;
+ if(thumbPath)
+ {
+ m_ThumbPath.assign(thumbPath);
+ m_ThumbType = ThumbnailMaker::UserType;
+ }
+ else
+ {
+ m_ThumbPath = PathUtils::getResourcePath(THUMB_CONTACT_IMG_PATH);
+ }
+ contactNumber.release();
+}
+
+void BaseThreadListItem::updateTime(time_t time)
+{
+ m_Time = std::string("7:40"); // TODO: remove hardcode
+}
+
+std::string BaseThreadListItem::getName()
+{
+ return m_Name;
+}
+
+std::string BaseThreadListItem::getMessage()
+{
+ return m_Message;
+}
+
+std::string BaseThreadListItem::getTime()
+{
+ return m_Time;
+}
+
+Evas_Object *BaseThreadListItem::getThumbnail()
+{
+ return ThumbnailMaker::make(*getOwner(), m_ThumbType, m_ThumbPath);
+}
--- /dev/null
+/*
+ * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "MsgSearchListItem.h"
+#include "MsgEngine.h"
+#include "TextDecorator.h"
+
+using namespace Msg;
+
+MsgSearchListItem::MsgSearchListItem(App &app, const Message &msg, const std::string &searchWord)
+ : BaseThreadListItem(app)
+ , m_MsgId(msg.getId())
+{
+ setState(NormalState, false);
+ update(msg, searchWord);
+}
+
+MsgSearchListItem::~MsgSearchListItem()
+{
+}
+
+MsgId MsgSearchListItem::getMsgId() const
+{
+ return m_MsgId;
+}
+
+void MsgSearchListItem::updateThumbnail(const Message &msg)
+{
+ const MsgAddressList &addressList = msg.getAddressList();
+ BaseThreadListItem::updateThumbnail(addressList);
+}
+
+void MsgSearchListItem::update(const Message &msg, const std::string &searchWord)
+{
+ m_MsgId = msg.getId();
+ m_Message = TextDecorator::highlightKeyword(msg.getText(), searchWord);
+
+ const MsgAddressList &addressList = msg.getAddressList();
+ int addrCount = addressList.getLength();
+ if(addrCount > 0)
+ {
+ m_Name = addressList.at(0).getAddress();
+ if(addrCount > 1)
+ m_Name += " + " + std::to_string(addrCount - 1);
+ }
+
+ updateThumbnail(msg);
+}
getParent().push(*frame);
}
-void MsgThread::navigateToConversation(ThreadId threadId)
+void MsgThread::navigateToConversation(ThreadId threadId, MsgId msgId)
{
Conversation *frame = new Conversation(getParent(), threadId);
getParent().push(*frame);
+ if(msgId.isValid())
+ frame->navigateTo(msgId);
}
void MsgThread::setMode(Mode mode)
void MsgThread::update()
{
- if(m_Mode == SearchMode)
+ bool searchEnabled = m_Mode == SearchMode;
+
+ m_pLayout->showFloatingButton(!searchEnabled);
+ if(searchEnabled)
{
bool showSearch = !m_pSearchList->isEmpty();
- bool showThread = !showSearch && !m_pThreadList->isEmpty();
- bool showNoContent = !showThread;
+ bool showThread = !showSearch && !m_pThreadList->isEmpty() && m_pSearchList->getSearchWord().empty();
+ bool showNoContent = !showThread && !showSearch;
m_pLayout->showSearchList(showSearch);
m_pLayout->showThreadList(showThread);
m_pLayout->showNoContent(showNoContent);
+
}
else
{
update();
}
+void MsgThread::onSearchListItemSelected(ThreadId id)
+{
+ MSG_LOG("");
+ navigateToConversation(id);
+}
+
+void MsgThread::onSearchListItemSelected(MsgId id)
+{
+ MSG_LOG("");
+ MessageRef msg = getMsgEngine().getStorage().getMessage(id);
+ if(msg)
+ navigateToConversation(msg->getThreadId(), id);
+}
+
void MsgThread::onFloatingButtonPressed()
{
MSG_LOG("");
using namespace Msg;
ThreadListItem::ThreadListItem(const MsgThreadItem &threadItem, App &app)
- : ThreadListViewItem()
+ : BaseThreadListItem(app)
, m_ThreadId()
- , m_App(app)
- , m_ThumbType(ThumbnailMaker::MsgType)
{
updateModel(threadItem);
}
return m_ThreadId;
}
-std::string ThreadListItem::getName()
-{
- return m_Name;
-}
-
-std::string ThreadListItem::getMessage()
-{
- return m_Message;
-}
-
-Evas_Object *ThreadListItem::getThumbnail()
-{
- return ThumbnailMaker::make(*getOwner(), m_ThumbType, m_ThumbPath);
-}
-
-void ThreadListItem::updateThumbnail(const MsgThreadItem &threadItem)
-{
- const MsgAddressListRef addressList = m_App.getMsgEngine().getStorage().getAddressList(threadItem.getId());
-
- if(addressList)
- {
- int countContact = addressList->getLength();
- m_ThumbType = ThumbnailMaker::MsgType;
- if(countContact > 1)
- {
- m_ThumbPath = PathUtils::getResourcePath(THUMB_GROUP_IMG_PATH);
- }
- else if(countContact == 1)
- {
- const MsgAddress &addr = addressList->at(0);
- ContactPersonNumber contactNumber = m_App.getContactManager().getContactPersonNumber(addr.getAddress());
- const char *thumbPath = contactNumber.isValid() ? contactNumber.getThumbnailPath() : nullptr;
- if(thumbPath)
- {
- m_ThumbPath.assign(thumbPath);
- m_ThumbType = ThumbnailMaker::UserType;
- }
- else
- {
- m_ThumbPath = PathUtils::getResourcePath(THUMB_CONTACT_IMG_PATH);
- }
- contactNumber.release();
- }
- }
-}
-
-std::string ThreadListItem::getTime()
-{
- //m_MsgThreadItem.getTime();
- return std::string("7:40"); // TODO: remove hardcode
-}
-
std::string ThreadListItem::getStatus()
{
return m_Status;
*/
#include "ThreadSearchList.h"
+#include "MsgSearchListItem.h"
#include "ThreadSearchListItem.h"
-#include "MessageSMS.h"
#include "MsgEngine.h"
+#include "Logger.h"
using namespace Msg;
{
setMultiSelection(false);
setMode(ELM_LIST_COMPRESS);
+ ListView::setListener(this);
}
ThreadSearchList::~ThreadSearchList()
}
}
+const std::string &ThreadSearchList::getSearchWord() const
+{
+ return m_SearchWord;
+}
+
void ThreadSearchList::search()
{
+ MSG_LOG("Search word: ", m_SearchWord);
ListView::clear();
- // TODO: pull from model:
- // TODO: only for demo will be removed
- MessageSMSRef sms = m_App.getMsgEngine().getComposer().createSms();
- sms->setText("Hello world!!!");
- auto &addr = sms->addAddress();
- addr.setAddress("5555512335555");
- ThreadSearchListItem *item = new ThreadSearchListItem(*sms, m_App, m_SearchWord);
- ListView::appendItem(*item);
+ if(!m_SearchWord.empty())
+ {
+ MsgStorage &msgSotrage = m_App.getMsgEngine().getStorage();
+
+ // Thread:
+ MsgThreadListRef threadList = msgSotrage.searchThread(m_SearchWord);
+ if(threadList)
+ {
+ int length = threadList->getLength();
+ for(int i = 0; i < length; ++i)
+ {
+ const MsgThreadItem &threadItem = threadList->at(i);
+ ListView::appendItem(*new ThreadSearchListItem(m_App, threadItem, m_SearchWord));
+ }
+ }
+
+ // Message:
+ MessageListRef msgList = msgSotrage.searchMessage(m_SearchWord);
+ if(msgList)
+ {
+ int length = msgList->getLength();
+ for(int i = 0; i < length; ++i)
+ {
+ const Message &msg = msgList->at(i);
+ ListView::appendItem(*new MsgSearchListItem(m_App, msg, m_SearchWord));
+ }
+ }
+ }
if(m_pListener)
m_pListener->onSearchListChanged();
}
+void ThreadSearchList::onListItemSelected(ListItem &listItem, void *funcData)
+{
+ if(m_pListener)
+ {
+ if(auto it = dynamic_cast<MsgSearchListItem*>(&listItem))
+ m_pListener->onSearchListItemSelected(it->getMsgId());
+ else if(auto it = dynamic_cast<ThreadSearchListItem*>(&listItem))
+ m_pListener->onSearchListItemSelected(it->getThreadId());
+ }
+}
*/
#include "ThreadSearchListItem.h"
-#include "ListView.h"
-#include "Logger.h"
-#include "PathUtils.h"
-#include "MsgEngine.h"
-#include "LangUtils.h"
-#include "ContactManager.h"
#include "TextDecorator.h"
using namespace Msg;
-ThreadSearchListItem::ThreadSearchListItem(const Message &msg, App &app, const std::string &searchWord)
- : m_MsgId(msg.getId())
- , m_App(app)
- , m_ThumbType(ThumbnailMaker::MsgType)
+ThreadSearchListItem::ThreadSearchListItem(App &app, const MsgThreadItem &item, const std::string &searchWord)
+ : BaseThreadListItem(app)
{
- setState(NormalState, false);
- updateModel(msg, searchWord);
+ update(item, searchWord);
}
ThreadSearchListItem::~ThreadSearchListItem()
{
-}
-
-MsgId ThreadSearchListItem::getMsgId() const
-{
- return m_MsgId;
-}
-std::string ThreadSearchListItem::getName()
-{
- return m_Name;
}
-std::string ThreadSearchListItem::getMessage()
+ThreadId ThreadSearchListItem::getThreadId() const
{
- return m_Message;
+ return m_ThreadId;
}
-Evas_Object *ThreadSearchListItem::getThumbnail()
+void ThreadSearchListItem::update(const MsgThreadItem &item, const std::string &searchWord)
{
- return ThumbnailMaker::make(*getOwner(), m_ThumbType, m_ThumbPath);
+ m_ThreadId = item.getId();
+ m_Name = TextDecorator::highlightKeyword(item.getName(), searchWord);
+ m_Message = item.getLastMessage();
+ updateThumbnail(item);
}
-
-void ThreadSearchListItem::updateThumbnail(const Message &msg)
-{
- const MsgAddressList &addressList = msg.getAddressList();
- int countContact = addressList.getLength();
- m_ThumbType = ThumbnailMaker::MsgType;
-
- if(countContact > 1)
- {
- m_ThumbPath = PathUtils::getResourcePath(THUMB_GROUP_IMG_PATH);
- }
- else if(countContact == 1)
- {
- const MsgAddress &addr = addressList.at(0);
- ContactPersonNumber contactNumber = m_App.getContactManager().getContactPersonNumber(addr.getAddress());
- const char *thumbPath = contactNumber.isValid() ? contactNumber.getThumbnailPath() : nullptr;
- if(thumbPath)
- {
- m_ThumbPath.assign(thumbPath);
- m_ThumbType = ThumbnailMaker::UserType;
- }
- else
- {
- m_ThumbPath = PathUtils::getResourcePath(THUMB_CONTACT_IMG_PATH);
- }
- contactNumber.release();
- }
-}
-
-std::string ThreadSearchListItem::getTime()
-{
- //m_MsgThreadItem.getTime();
- return std::string("7:40"); // TODO: remove hardcode
-}
-
-Evas_Object *ThreadSearchListItem::makeUnreadBadge(int unreadCount)
-{
- Evas_Object *label = makeUnreadIcon(*getOwner() ,std::to_string(unreadCount));
- return label;
-}
-
-void ThreadSearchListItem::updateModel(const Message &msg, const std::string &searchWord)
-{
- m_MsgId = msg.getId();
- m_Message = TextDecorator::highlightKeyword(msg.getText(), searchWord);
-
- const MsgAddressList &addressList = msg.getAddressList();
- int addrCount = addressList.getLength();
- if(addrCount > 0)
- {
- m_Name = TextDecorator::highlightKeyword(addressList.at(0).getAddress(), searchWord);
- if(addrCount > 1)
- m_Name += " + " + std::to_string(addrCount - 1);
- }
-
- updateThumbnail(msg);
-}
-