TizenRefApp-6898 Integrate new Compose Attachments to conversation-list part I 98/84098/1
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Tue, 16 Aug 2016 15:00:25 +0000 (18:00 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Tue, 16 Aug 2016 15:00:25 +0000 (18:00 +0300)
Change-Id: Ifef94c3a85721893b4260dcc8be895445b58603f
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
30 files changed:
src/Common/View/inc/ListView.h
src/Common/View/src/ListView.cpp
src/Conversation/Body/Controller/inc/Body.h
src/Conversation/Body/Controller/src/Body.cpp
src/Conversation/ConvList/Controller/inc/BubbleAudioEntity.h
src/Conversation/ConvList/Controller/inc/BubbleCalEventEntity.h
src/Conversation/ConvList/Controller/inc/BubbleContactEntity.h
src/Conversation/ConvList/Controller/inc/BubbleEntity.h
src/Conversation/ConvList/Controller/inc/BubbleEntityFactory.h [new file with mode: 0644]
src/Conversation/ConvList/Controller/inc/BubbleImageEntity.h
src/Conversation/ConvList/Controller/inc/BubbleUnknownFileEntity.h
src/Conversation/ConvList/Controller/inc/BubbleVideoEntity.h
src/Conversation/ConvList/Controller/inc/ComposeListItem.h [new file with mode: 0644]
src/Conversation/ConvList/Controller/inc/ConvList.h
src/Conversation/ConvList/Controller/inc/ConvListItem.h
src/Conversation/ConvList/Controller/src/BubbleAudioEntity.cpp
src/Conversation/ConvList/Controller/src/BubbleCalEventEntity.cpp
src/Conversation/ConvList/Controller/src/BubbleContactEntity.cpp
src/Conversation/ConvList/Controller/src/BubbleEntityFactory.cpp [new file with mode: 0644]
src/Conversation/ConvList/Controller/src/BubbleUnknownFileEntity.cpp
src/Conversation/ConvList/Controller/src/BubbleVideoEntity.cpp
src/Conversation/ConvList/Controller/src/ComposeListItem.cpp [new file with mode: 0644]
src/Conversation/ConvList/Controller/src/ConvList.cpp
src/Conversation/ConvList/Controller/src/ConvListItem.cpp
src/Conversation/ConvList/View/inc/BubbleViewItem.h
src/Conversation/ConvList/View/inc/ComposeListViewItem.h [new file with mode: 0644]
src/Conversation/ConvList/View/src/BubbleViewItem.cpp
src/Conversation/ConvList/View/src/ComposeListViewItem.cpp [new file with mode: 0644]
src/Conversation/Main/Controller/inc/Conversation.h
src/Conversation/Main/Controller/src/Conversation.cpp

index 351d16c..c607ed4 100644 (file)
@@ -60,6 +60,15 @@ namespace Msg
             bool appendItem(ListItem &listItem, ListItem *parent = nullptr);
 
             /**
+             * @brief Inserts an item before another in a genlist widget
+             * @param[in] listItem an item to be appended.
+             * @param[in] before the item before which to place this new one
+             * @param[in] parent a parent item.
+             * @return true in case of success, false otherwise.
+             */
+            bool insertBeforeItem(ListItem &listItem, ListItem &before, ListItem *parent = nullptr);
+
+            /**
              * @brief Prepends specified list-view item into list-view.
              * @param[in] listItem an item to be prepended.
              * @param[in] parent a parent item.
index 2583af8..06ef51c 100644 (file)
@@ -70,6 +70,17 @@ bool ListView::appendItem(ListItem &listItem, ListItem *parent)
     return elmItem != nullptr;
 }
 
+bool ListView::insertBeforeItem(ListItem &listItem, ListItem &before, ListItem *parent)
+{
+    Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr;
+
+    listItem.m_pOwner = this;
+    Elm_Object_Item *elmItem = elm_genlist_item_insert_before(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass,
+                                                       &listItem, parentItem, before, listItem.getType(), on_item_selected_cb, this);
+    listItem.setElmObjItem(elmItem);
+    return elmItem != nullptr;
+}
+
 bool ListView::prependItem(ListItem &listItem, ListItem *parent)
 {
     Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr;
index 2211236..8cd299b 100644 (file)
@@ -36,6 +36,7 @@ namespace Msg
     class App;
     class PopupListItem;
     class PopupList;
+    class ConvList;
 
     // TODO: move page(controller) methods to Page class
 
@@ -44,7 +45,7 @@ namespace Msg
         , private IAttachmentHandlerListener
     {
         public:
-            Body(App &app, WorkingDirRef workingDir);
+            Body(App &app, WorkingDirRef workingDir, ConvList &convList);
             virtual ~Body();
 
             void create(Evas_Object *parent);
@@ -122,6 +123,7 @@ namespace Msg
             AttachmentHandler m_AttachmentHandler;
             std::queue<std::string> m_SelectedFiles;
             bool m_AutoFocusForAttachments;
+            ConvList &m_ConvList;
     };
 
     class IBodyListener
index df9c7a1..81be929 100644 (file)
@@ -28,6 +28,8 @@
 #include "MediaUtils.h"
 #include "PopupList.h"
 #include "PopupBodyAttachmentListItem.h"
+#include "ComposeListItem.h"
+#include "ConvList.h"
 
 #include <assert.h>
 #include <string.h>
@@ -63,7 +65,7 @@ namespace
     }
 }
 
-Body::Body(App &app, WorkingDirRef workingDir)
+Body::Body(App &app, WorkingDirRef workingDir, ConvList &convList)
     : BodyView()
     , m_pListener(nullptr)
     , m_App(app)
@@ -75,6 +77,7 @@ Body::Body(App &app, WorkingDirRef workingDir)
     , m_MmsRecipFlag(false)
     , m_AttachmentHandler(workingDir)
     , m_AutoFocusForAttachments(true)
+    , m_ConvList(convList)
 {
     m_AttachmentHandler.setListener(this);
 }
@@ -310,8 +313,6 @@ void Body::execCmd(const AppControlComposeRef &cmd)
     if(!cmd->getVcfInfo().contactsIdList.empty())
         path.push_back(createVcfFile(cmd));
 
-    //TODO: implement fill of subject.
-
     addMedia(path);
 }
 
@@ -323,6 +324,7 @@ void Body::addAttachment(const std::string &filePath, const std::string &fileNam
         long long fileSize = FileUtils::getFileSize(newFilePath);
         std::string newFileName = fileName.empty() ? FileUtils::getFileName(filePath) : fileName;
         BodyView::addAttachment(newFilePath, fileSize, newFileName);
+        m_ConvList.getComposeItem()->addAttachment(newFilePath);
     }
 }
 
@@ -562,6 +564,8 @@ void Body::onFileReady(const std::string &filePath)
     MediaTypeData mediaType = getMsgMediaTypeByFileExt(filePath);
     MSG_LOG("Media type: ", mediaType.mime);
 
+    m_ConvList.getComposeItem()->addAttachment(filePath);
+
     Page *page = nullptr;
     if(mediaType.type != MsgMedia::UnknownType && mediaType.type != MsgMedia::TextType)
     {
index 722749f..86c8af7 100644 (file)
@@ -27,7 +27,7 @@ namespace Msg
         : public BubbleBgEntity
     {
         public:
-            BubbleAudioEntity(const MsgConvMedia &media, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+            BubbleAudioEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction);
             virtual ~BubbleAudioEntity();
 
             virtual BubbleAudioViewItem *createView(Evas_Object *parent);
index e375c73..7984fc8 100644 (file)
@@ -27,7 +27,7 @@ namespace Msg
         : public BubbleBgEntity
     {
         public:
-            BubbleCalEventEntity(const MsgConvMedia &convMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+            BubbleCalEventEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction);
             virtual ~BubbleCalEventEntity();
 
             virtual BubbleCalEventViewItem *createView(Evas_Object *parent);
index b96ab96..8bdd00a 100644 (file)
@@ -29,7 +29,7 @@ namespace Msg
         : public BubbleBgEntity
     {
         public:
-            BubbleContactEntity(App &app, const MsgConvMedia &media, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+            BubbleContactEntity(App &app, const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction);
             virtual ~BubbleContactEntity();
 
             virtual BubbleContactViewItem *createView(Evas_Object *parent);
index 7c7edf2..b8dbd59 100644 (file)
@@ -52,8 +52,6 @@ namespace Msg
             virtual std::string getFilePath() const = 0;
             virtual BubbleViewItem *createView(Evas_Object *parent) = 0;
 
-            static std::string getFileName(const MsgConvMedia &media);
-
         private:
             Type m_Type;
             Message::Direction m_Direction;
@@ -79,13 +77,6 @@ namespace Msg
         return m_Direction;
     }
 
-    inline std::string BubbleEntity::getFileName(const MsgConvMedia &media)
-    {
-        std::string res = media.getName();
-        if(res.empty())
-            res = FileUtils::getFileName(media.getPath());
-        return res;
-    }
 }
 
 #endif /* BubbleEntity_h_ */
diff --git a/src/Conversation/ConvList/Controller/inc/BubbleEntityFactory.h b/src/Conversation/ConvList/Controller/inc/BubbleEntityFactory.h
new file mode 100644 (file)
index 0000000..9a3bd55
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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 BubbleEntityFactory_h_
+#define BubbleEntityFactory_h_
+
+#include "App.h"
+#include "WorkingDir.h"
+#include "MsgConvMedia.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(App &app, WorkingDirRef workingDir);
+            ~BubbleEntityFactory();
+
+            BubbleEntity *createEntity(const std::string &filePath, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+            BubbleEntity *createEntity(const MsgConvMedia &msgMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+            BubbleTextEntity *createTextEntity(const std::string &text, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+            BubbleDownloadButtonEntity *createDownloadButtonEntity(Message::Direction direction);
+
+        private:
+            BubbleEntity *createEntity(const std::string &filePath, const std::string &fileName, std::string mime, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+
+            BubbleEntityFactory(BubbleEntityFactory&) = delete;
+            BubbleEntityFactory& operator=(const BubbleEntityFactory&) = delete;
+
+        private:
+            App &m_App;
+            WorkingDirRef m_WorkingDir;
+    };
+}
+
+#endif /* BubbleEntityFactory_h_ */
index f3782ff..417b0e1 100644 (file)
@@ -27,7 +27,7 @@ namespace Msg
         : public BubbleEntity
     {
         public:
-            BubbleImageEntity(const MsgConvMedia &media, Message::Direction direction);
+            BubbleImageEntity(const std::string &filePath, Message::Direction direction);
             virtual ~BubbleImageEntity();
 
             virtual BubbleImageViewItem *createView(Evas_Object *parent);
@@ -37,9 +37,10 @@ namespace Msg
             const std::string m_ImgPath;
     };
 
-    inline BubbleImageEntity::BubbleImageEntity(const MsgConvMedia &media, Message::Direction direction)
+
+    inline BubbleImageEntity::BubbleImageEntity(const std::string &filePath, Message::Direction direction)
         : BubbleEntity(ImageItem, direction)
-        , m_ImgPath(media.getPath())
+        , m_ImgPath(filePath)
     {
     }
 
index 29d55d0..36812df 100644 (file)
@@ -27,7 +27,7 @@ namespace Msg
         : public BubbleBgEntity
     {
         public:
-            BubbleUnknownFileEntity(const MsgConvMedia &convMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+            BubbleUnknownFileEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction);
             virtual ~BubbleUnknownFileEntity();
 
             virtual BubbleUnknownFileViewItem *createView(Evas_Object *parent);
index 29d90e0..5c20765 100644 (file)
@@ -28,7 +28,7 @@ namespace Msg
         : public BubbleEntity
     {
         public:
-            BubbleVideoEntity(WorkingDir &workingDir, const MsgConvMedia &media, Message::Direction direction);
+            BubbleVideoEntity(WorkingDirRef workingDir, const std::string &filePath, Message::Direction direction);
             virtual ~BubbleVideoEntity();
 
             virtual BubbleVideoViewItem *createView(Evas_Object *parent);
@@ -37,6 +37,7 @@ namespace Msg
         private:
             std::string m_VideoPath;
             std::string m_ImgPath;
+            WorkingDirRef m_WorkingDir;
     };
 }
 
diff --git a/src/Conversation/ConvList/Controller/inc/ComposeListItem.h b/src/Conversation/ConvList/Controller/inc/ComposeListItem.h
new file mode 100644 (file)
index 0000000..f7d9c78
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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 ComposeListItem_H_
+#define ComposeListItem_H_
+
+#include "ComposeListViewItem.h"
+#include "BubbleEntity.h"
+#include "BubbleEntityFactory.h"
+
+#include <list>
+
+namespace Msg
+{
+    class IComposeListItemListener;
+
+    class ComposeListItem
+        : public ComposeListViewItem
+        , private IBubbleViewItemListener
+    {
+        public:
+            ComposeListItem(BubbleEntityFactory &entityFactory);
+            virtual ~ComposeListItem();
+
+            void addAttachment(const std::string &filePath);
+            void setListener(IComposeListItemListener *l);
+
+        protected:
+            virtual Evas_Object *getBubbleContent();
+            virtual std::string getTime();
+            virtual std::string getMsgType();
+
+        private:
+            // IBubbleViewItemListener:
+            virtual void onAction(BubbleViewItem &item);
+            virtual void onDelClicked(BubbleViewItem &item);
+
+        private:
+            IComposeListItemListener *m_pListener;
+            std::list<BubbleEntity*> m_BubbleEntityList;
+            BubbleEntityFactory &m_BubbleEntityFactory;
+    };
+
+    class IComposeListItemListener
+    {
+        public:
+            virtual ~IComposeListItemListener() {}
+            virtual void onAttachmentDeleted(const std::string &filePath) {};
+    };
+}
+
+#endif /* ComposeListItem_H_ */
index 4a5d28e..947739b 100644 (file)
@@ -26,6 +26,7 @@
 #include "ConvListItem.h"
 #include "ContactManager.h"
 #include "FileViewer.h"
+#include "ComposeListItem.h"
 
 #include <unordered_map>
 #include <unordered_set>
@@ -119,6 +120,12 @@ namespace Msg
              */
             int getMessageCheckedCount() const;
 
+            /**
+             * @brief Get compose item
+             * @return compose item
+             */
+            ComposeListItem *getComposeItem();
+
         private:
             typedef std::unordered_map<MsgId::Type, ConvListItem*> ConvListItemMap;
             typedef std::unordered_set<std::string> DateLineItemSet;
@@ -176,10 +183,11 @@ namespace Msg
             DateLineItemSet m_DateLineItemSet;
             IConvListListener *m_pListener;
             App &m_App;
-            WorkingDirRef m_WorkingDir;
             FileViewer m_FileViewer;
             ThumbId m_RecipThumbId;
             std::string m_SearchWord;
+            BubbleEntityFactory m_BubbleEntityFactory;
+            ComposeListItem *m_pComposeItem;
     };
 
     class IConvListListener
index 895cca7..52671bf 100644 (file)
@@ -31,6 +31,7 @@
 #include "BubbleViewItem.h"
 #include "BubbleEntity.h"
 #include "BubbleBgViewItem.h"
+#include "BubbleEntityFactory.h"
 
 namespace Msg
 {
@@ -46,14 +47,14 @@ namespace Msg
              * @brief Creates item for Conversation list
              * @param[in] item MsgConversationItem model
              * @param[in] app Main application
-             * @param[in] workingDir Smart ptr to current working dir.
+             * @param[in] bubbleEntityFactory Bubble entity factory.
              * @param[in] searchWord string for search in bubble
              * @param[in] thumbId Reference to id of user thumbnail
              */
             ConvListItem(const MsgConversationItem &item,
                          App &app,
                          FileViewer &fileViewer,
-                         WorkingDirRef workingDir,
+                         BubbleEntityFactory &bubbleEntityFactory,
                          const std::string &searchWord,
                          const ThumbId &thumbId = invalidThumbId);
 
@@ -132,6 +133,7 @@ namespace Msg
             std::string m_TimeStr;
             std::list<BubbleEntity*> m_BubbleEntityList;
             const ThumbId &m_ThumbId;
+            BubbleEntityFactory &m_BubbleEntityFactory;
     };
 
     class IConvListItemListener
index 86c6408..7520b38 100644 (file)
@@ -18,6 +18,7 @@
 #include "BubbleAudioEntity.h"
 #include "MediaUtils.h"
 #include "Resource.h"
+#include "MediaUtils.h"
 
 #include <sstream>
 #include <iomanip>
@@ -35,11 +36,11 @@ std::string makeDurationStr(const std::string &filePath)
     return ss.str();
 }
 
-BubbleAudioEntity::BubbleAudioEntity(const MsgConvMedia &media, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+BubbleAudioEntity::BubbleAudioEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction)
     : BubbleBgEntity(AudioItem, bgType, direction)
-    , m_FilePath(media.getPath())
-    , m_FileName(getFileName(media))
-    , m_Duration(makeDurationStr(media.getPath()))
+    , m_FilePath(filePath)
+    , m_FileName(fileName)
+    , m_Duration(makeDurationStr(filePath))
 {
 }
 
index 358625a..1671b0f 100644 (file)
 
 using namespace Msg;
 
-
-BubbleCalEventEntity::BubbleCalEventEntity(const MsgConvMedia &convMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+BubbleCalEventEntity::BubbleCalEventEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction)
     : BubbleBgEntity(CalendarEventItem, bgType, direction)
-    , m_FilePath(convMedia.getPath())
+    , m_FilePath(filePath)
 {
-    auto list = VCalendarParser::getInst().parse(convMedia.getPath());
+    auto list = VCalendarParser::getInst().parse(filePath);
     if(list.size() == 1)
     {
         const CalendarEvent &event = list.front();
@@ -35,7 +34,7 @@ BubbleCalEventEntity::BubbleCalEventEntity(const MsgConvMedia &convMedia, Bubble
     }
     else
     {
-        m_Name = getFileName(convMedia);
+        m_Name = fileName;
     }
 }
 
index e33dcc1..427a1c6 100644 (file)
 
 using namespace Msg;
 
-BubbleContactEntity::BubbleContactEntity(App &app, const MsgConvMedia &media, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+BubbleContactEntity::BubbleContactEntity(App &app, const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction)
     : BubbleBgEntity(ContactItem, bgType, direction)
     , m_ThumbMaker(app.getThumbnailMaker())
-    , m_FilePath(media.getPath())
+    , m_FilePath(filePath)
 {
     auto list = app.getContactManager().parseVcard(m_FilePath);
     if(!list.empty())
@@ -43,7 +43,7 @@ BubbleContactEntity::BubbleContactEntity(App &app, const MsgConvMedia &media, Bu
         }
     }
     if(!m_Contact)
-        m_Name = getFileName(media);
+        m_Name = fileName;
 }
 
 BubbleContactEntity::~BubbleContactEntity()
diff --git a/src/Conversation/ConvList/Controller/src/BubbleEntityFactory.cpp b/src/Conversation/ConvList/Controller/src/BubbleEntityFactory.cpp
new file mode 100644 (file)
index 0000000..7aacd9f
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * 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 "BubbleEntityFactory.h"
+#include "FileUtils.h"
+#include "MediaType.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(App &app, WorkingDirRef workingDir)
+    : m_App(app)
+    , m_WorkingDir(workingDir)
+{
+
+}
+
+BubbleEntityFactory::~BubbleEntityFactory()
+{
+}
+
+BubbleEntity *BubbleEntityFactory::createEntity(const MsgConvMedia &msgMedia, BubbleBgViewItem::BgType bgType, 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, bgType, direction);
+}
+
+BubbleEntity *BubbleEntityFactory::createEntity(const std::string &filePath, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+{
+    return createEntity(filePath, FileUtils::getFileName(filePath), FileUtils::getMimeType(filePath), bgType, direction);
+}
+
+BubbleTextEntity *BubbleEntityFactory::createTextEntity(const std::string &text, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+{
+    return new BubbleTextEntity(bgType, direction, text);
+}
+
+BubbleDownloadButtonEntity *BubbleEntityFactory::createDownloadButtonEntity(Message::Direction direction)
+{
+    return new BubbleDownloadButtonEntity(direction);
+}
+
+BubbleEntity *BubbleEntityFactory::createEntity(const std::string &filePath, const std::string &fileName, std::string mime, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+{
+    std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower);
+    MsgMedia::Type msgMediaType = getMsgMediaTypeByMime(mime);
+
+    switch(msgMediaType)
+    {
+        case MsgMedia::ImageType:
+            // TODO: msg service corrupts thumbnail's metadata, so it lost rotation. Use getPath instead getThumbPath until fix
+            return new BubbleImageEntity(filePath, direction);
+        case MsgMedia::AudioType:
+            return new BubbleAudioEntity(filePath, fileName, bgType, direction);
+        case MsgMedia::VideoType:
+            return new BubbleVideoEntity(m_WorkingDir, filePath, direction);
+        default:
+          if(mime == "text/x-vcalendar" || mime == "text/calendar")
+              return new BubbleCalEventEntity(filePath, fileName, bgType, direction);
+          else if(mime == "text/x-vcard" || mime == "text/vcard")
+              return new BubbleContactEntity(m_App, filePath, fileName , bgType, direction);
+          else if(mime != "application/smil")
+              return new BubbleUnknownFileEntity(filePath, fileName, bgType, direction);
+    }
+
+    return nullptr;
+}
+
index c837709..f322a73 100644 (file)
 
 using namespace Msg;
 
-BubbleUnknownFileEntity::BubbleUnknownFileEntity(const MsgConvMedia &convMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+BubbleUnknownFileEntity::BubbleUnknownFileEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction)
     : BubbleBgEntity(UnknownFileItem, bgType, direction)
-    , m_FilePath(convMedia.getPath())
-    , m_FileName(getFileName(convMedia))
+    , m_FilePath(filePath)
+    , m_FileName(fileName)
 {
+
 }
 
 BubbleUnknownFileEntity::~BubbleUnknownFileEntity()
index 99181cf..36e583f 100644 (file)
 
 #include "BubbleVideoEntity.h"
 #include "MediaUtils.h"
+#include "FileUtils.h"
 
 using namespace Msg;
 
-BubbleVideoEntity::BubbleVideoEntity(WorkingDir &workingDir, const MsgConvMedia &media, Message::Direction direction)
+
+BubbleVideoEntity::BubbleVideoEntity(WorkingDirRef workingDir, const std::string &filePath, Message::Direction direction)
     : BubbleEntity(VideoItem, direction)
-    , m_VideoPath(media.getPath())
+    , m_VideoPath(filePath)
+    , m_WorkingDir(workingDir)
 {
     static const std::string thumbFileName = "thumbnail.jpeg";
-    m_ImgPath =  workingDir.genUniqueFilePath(thumbFileName);
+    m_ImgPath =  m_WorkingDir->genUniqueFilePath(thumbFileName);
     if(!m_ImgPath.empty())
         MediaUtils::getVideoFrame(m_VideoPath, m_ImgPath);
 }
 
 BubbleVideoEntity::~BubbleVideoEntity()
 {
+    m_WorkingDir->removeFile(m_ImgPath);
 }
 
 BubbleVideoViewItem *BubbleVideoEntity::createView(Evas_Object *parent)
diff --git a/src/Conversation/ConvList/Controller/src/ComposeListItem.cpp b/src/Conversation/ConvList/Controller/src/ComposeListItem.cpp
new file mode 100644 (file)
index 0000000..a3e3fbb
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * 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 "ComposeListItem.h"
+#include "LangUtils.h"
+#include "TimeUtils.h"
+#include "BubbleItemContainer.h"
+#include "ListView.h"
+
+// Bubble items:
+#include "BubbleImageEntity.h"
+#include "BubbleVideoEntity.h"
+#include "BubbleAudioEntity.h"
+#include "BubbleUnknownFileEntity.h"
+#include "BubbleCalEventEntity.h"
+#include "BubbleContactEntity.h"
+
+using namespace Msg;
+
+ComposeListItem::ComposeListItem(BubbleEntityFactory &entityFactory)
+    : m_pListener(nullptr)
+    , m_BubbleEntityFactory(entityFactory)
+{
+
+}
+
+ComposeListItem::~ComposeListItem()
+{
+
+}
+
+void ComposeListItem::addAttachment(const std::string &filePath)
+{
+    if(!filePath.empty())
+    {
+        auto *entity = m_BubbleEntityFactory.createEntity(filePath, BubbleBgViewItem::SentStyle, Message::MD_Sent);
+        if(entity)
+        {
+            m_BubbleEntityList.push_back(entity);
+            update();
+            getOwner()->showItem(*this, ELM_GENLIST_ITEM_SCROLLTO_BOTTOM);
+        }
+    }
+}
+
+void ComposeListItem::setListener(IComposeListItemListener *l)
+{
+
+}
+
+Evas_Object *ComposeListItem::getBubbleContent()
+{
+    auto *bubble = new BubbleItemContainer(*getOwner());
+    for(BubbleEntity *entity : m_BubbleEntityList)
+    {
+        BubbleViewItem *item = entity->createView(*bubble);
+        if(item)
+        {
+            item->showDelButton(true);
+            bubble->append(*item, entity->getDirection());
+            item->setListener(this);
+        }
+    }
+    bubble->go();
+    bubble->show();
+    return *bubble;
+}
+
+std::string ComposeListItem::getTime()
+{
+    return TimeUtils::makeBubbleTimeString(time(nullptr));
+}
+
+std::string ComposeListItem::getMsgType()
+{
+    return msg("IDS_MSGF_BODY_MMS");
+}
+
+void ComposeListItem::onAction(BubbleViewItem &item)
+{
+
+}
+
+void ComposeListItem::onDelClicked(BubbleViewItem &item)
+{
+
+}
index d383528..841bc4e 100644 (file)
@@ -39,10 +39,11 @@ ConvList::ConvList(Evas_Object *parent, App &app, WorkingDirRef workingDir)
     , m_DateLineItemSet()
     , m_pListener(nullptr)
     , m_App(app)
-    , m_WorkingDir(workingDir)
     , m_FileViewer()
     , m_RecipThumbId(m_App.getThumbnailMaker().getThumbId(ThumbnailMaker::SingleThumb))
     , m_SearchWord()
+    , m_BubbleEntityFactory(app, workingDir)
+    , m_pComposeItem(nullptr)
 {
     create(parent);
 }
@@ -184,9 +185,9 @@ ConvListItem *ConvList::getItem(MsgId msgId) const
 void ConvList::appendItem(const MsgConversationItem &item)
 {
     if(item.getDirection() == Message::MD_Received)
-        appendItem(new ConvListItem(item, m_App, m_FileViewer, m_WorkingDir, m_SearchWord, m_RecipThumbId));
+        appendItem(new ConvListItem(item, m_App, m_FileViewer, m_BubbleEntityFactory, m_SearchWord, m_RecipThumbId));
     else
-        appendItem(new ConvListItem(item, m_App, m_FileViewer, m_WorkingDir, m_SearchWord));
+        appendItem(new ConvListItem(item, m_App, m_FileViewer, m_BubbleEntityFactory, m_SearchWord));
 }
 
 void ConvList::appendItem(ConvListItem *item)
@@ -194,7 +195,10 @@ void ConvList::appendItem(ConvListItem *item)
     dateLineAddIfNec(item);
     m_ConvListItemMap[item->getMsgId()] = item;
     item->setListener(this);
-    m_pList->appendItem(*item);
+    if(m_pComposeItem)
+        m_pList->insertBeforeItem(*item, *m_pComposeItem);
+    else
+        m_pList->appendItem(*item);
 }
 
 void ConvList::deleteItem(ConvListItem *item)
@@ -228,6 +232,8 @@ void ConvList::demoteItem(ConvListItem *item)
     dateLineDelIfNec(item);
     dateLineAddIfNec(item);
     m_pList->demoteItem(*item);
+    if(m_pComposeItem)
+        m_pList->demoteItem(*m_pComposeItem);
 }
 
 void ConvList::dateLineDelIfNec(ConvListItem *item)
@@ -255,13 +261,21 @@ void ConvList::dateLineAddIfNec(ConvListItem *item)
     {
         DateLineItem *dateLine = new DateLineItem(item->getRawTime(), dateStr);
         m_DateLineItemSet.insert(dateStr);
-        m_pList->appendItem(*dateLine);
+        if(m_pComposeItem)
+            m_pList->insertBeforeItem(*dateLine, *m_pComposeItem);
+        else
+            m_pList->appendItem(*dateLine);
     }
 }
 
 void ConvList::clear()
 {
-    m_pList->clear();
+    auto items = m_pList->getItems();
+    for(ListItem *item : items)
+    {
+        if(item != m_pComposeItem)
+            item->destroy();
+    }
     m_ConvListItemMap.clear();
     m_DateLineItemSet.clear();
 }
@@ -320,6 +334,16 @@ void ConvList::selectListItems(bool state)
         m_pListener->onConvListItemChecked();
 }
 
+ComposeListItem *ConvList::getComposeItem()
+{
+    if(!m_pComposeItem)
+    {
+        m_pComposeItem = new ComposeListItem(m_BubbleEntityFactory);
+        m_pList->appendItem(*m_pComposeItem);
+    }
+    return m_pComposeItem;
+}
+
 void ConvList::onListItemLongPressed(ListItem &listItem)
 {
     ConvListItem &item = static_cast<ConvListItem&>(listItem);
index 2cb0f6c..5e0d248 100644 (file)
@@ -62,13 +62,12 @@ namespace
 ConvListItem::ConvListItem(const MsgConversationItem &item,
                            App &app,
                            FileViewer &fileViewer,
-                           WorkingDirRef workingDir,
+                           BubbleEntityFactory &bubbleEntityFactory,
                            const std::string &searchWord,
                            const ThumbId &thumbId)
     : ConvListViewItem(getConvItemType(item))
     , m_pListener(nullptr)
     , m_App(app)
-    , m_WorkingDir(workingDir)
     , m_FileViewer(fileViewer)
     , m_MsgId(item.getMsgId())
     , m_IsDraft(item.isDraft())
@@ -76,6 +75,7 @@ ConvListItem::ConvListItem(const MsgConversationItem &item,
     , m_Type(item.getType())
     , m_Time(item.getTime())
     , m_ThumbId(thumbId)
+    , m_BubbleEntityFactory(bubbleEntityFactory)
 {
     prepareBubble(item, searchWord);
 }
@@ -168,18 +168,15 @@ BubbleEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType, Me
 
     if(findText(text, searchWord))
         showSearch();
-
-    return new BubbleTextEntity(bgType, direction, utf8ToMarkup(text));
+    return m_BubbleEntityFactory.createTextEntity(utf8ToMarkup(text), bgType, direction);
 }
 
 BubbleEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, std::string text, bool markup, const std::string &searchWord)
 {
     if(findText(text, searchWord))
         showSearch();
-
     std::string resText = markup ? utf8ToMarkup(text) : std::move(text);
-
-    return new BubbleTextEntity(bgType, direction, resText);
+    return m_BubbleEntityFactory.createTextEntity(resText, bgType, direction);
 }
 
 void ConvListItem::addEntity(BubbleEntity *entity)
@@ -210,44 +207,20 @@ void ConvListItem::prepareBubble(const MsgConversationItem &item, const std::str
     {
         std::string text = MessageDetailContent::getMmsNotiConvListItemContent(m_App, m_MsgId);
         addEntity(createTextEntity(bgType, direction, text, false, searchWord));
-        addEntity(new BubbleDownloadButtonEntity(direction));
+        addEntity(m_BubbleEntityFactory.createDownloadButtonEntity(direction));
     }
     else
     {
         const MsgConvMediaList &list = item.getMediaList();
-        for(int i = 0; i < list.getLength(); i++)
+        for(int i = 0; i < list.getLength(); ++i)
         {
             const MsgConvMedia &media = list.at(i);
             std::string mime = media.getMime();
-            MsgMedia::Type msgMediaType = getMsgMediaTypeByMime(mime);
             std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower);
-            BubbleEntity *entity = nullptr;
-
-            switch(msgMediaType)
-            {
-                case MsgMedia::TextType:
-                    entity = createTextEntity(bgType, direction, media, searchWord);
-                    break;
-                case MsgMedia::ImageType:
-                    // TODO: msg service corrupts thumbnail's metadata, so it lost rotation. Use getPath instead getThumbPath until fix
-                    entity = new BubbleImageEntity(media, direction);
-                    break;
-                case MsgMedia::AudioType:
-                    entity = new BubbleAudioEntity(media, bgType, direction);
-                    break;
-                case MsgMedia::VideoType:
-                    entity = new BubbleVideoEntity(*m_WorkingDir, media, direction);
-                    break;
-                default:
-                    if(mime == "text/x-vcalendar" || mime == "text/calendar")
-                        entity =  new BubbleCalEventEntity(media, bgType, direction);
-                    else if(mime == "text/x-vcard" || mime == "text/vcard")
-                        entity = new BubbleContactEntity(m_App, media, bgType, direction);
-                    else if(mime != "application/smil")
-                        entity = new BubbleUnknownFileEntity(media, bgType, direction);
-                    break;
-            }
-            addEntity(entity);
+            if(mime == "text/plain")
+                addEntity(createTextEntity(bgType, direction, media, searchWord));
+            else if(mime != "application/smil")
+                addEntity(m_BubbleEntityFactory.createEntity(media, bgType, direction));
         }
     }
 }
index f8df410..7fae586 100644 (file)
@@ -58,7 +58,7 @@ namespace Msg
         public:
             virtual ~IBubbleViewItemListener() {};
             virtual void onAction(BubbleViewItem &item) {}; // Tap or Click
-            virtual void onDelClecked(BubbleViewItem &item) {}; // Delete button clicked
+            virtual void onDelClicked(BubbleViewItem &item) {}; // Delete button clicked
     };
 }
 
diff --git a/src/Conversation/ConvList/View/inc/ComposeListViewItem.h b/src/Conversation/ConvList/View/inc/ComposeListViewItem.h
new file mode 100644 (file)
index 0000000..4f3fe44
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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 ComposeListViewItem_H_
+#define ComposeListViewItem_H_
+
+#include "ListItem.h"
+
+namespace Msg
+{
+    class ComposeListViewItem
+        : public ListItem
+    {
+        public:
+            ComposeListViewItem();
+            virtual ~ComposeListViewItem();
+
+        protected:
+            virtual Evas_Object *getBubbleContent() = 0;
+            virtual std::string getTime() = 0;
+            virtual std::string getMsgType() = 0;
+
+        private:
+            virtual std::string getText(ListItem &item, const char *part);
+            virtual Evas_Object *getContent(ListItem &item, const char *part);
+
+        private:
+    };
+}
+
+#endif /* ComposeListViewItem_H_ */
index 06a7b32..eb44b1a 100644 (file)
@@ -130,5 +130,5 @@ void BubbleViewItem::emitActionEvent()
 void BubbleViewItem::onDelButtonClicked(Evas_Object *obj, void *eventInfo)
 {
     if(m_pListener)
-        m_pListener->onDelClecked(*this);
+        m_pListener->onDelClicked(*this);
 }
diff --git a/src/Conversation/ConvList/View/src/ComposeListViewItem.cpp b/src/Conversation/ConvList/View/src/ComposeListViewItem.cpp
new file mode 100644 (file)
index 0000000..99d589d
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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 "ComposeListViewItem.h"
+#include "CallbackAssist.h"
+#include "ListView.h"
+#include "Resource.h"
+
+using namespace Msg;
+
+namespace
+{
+    ListItemStyleRef sentStyle = ListItemStyle::create("sentbubble");
+
+    const char *bubbleContentPart = "bubble.content";
+    const char *timeTextPart = "info.time";
+    const char *msgType = "msg.type";
+}
+
+ComposeListViewItem::ComposeListViewItem()
+    : ListItem(sentStyle)
+{
+}
+
+ComposeListViewItem::~ComposeListViewItem()
+{
+
+}
+
+std::string ComposeListViewItem::getText(ListItem &item, const char *part)
+{
+    if(!strcmp(part, timeTextPart))
+        return getTime();
+    else if(!strcmp(part, msgType))
+        return getMsgType();
+
+    return "";
+}
+
+Evas_Object *ComposeListViewItem::getContent(ListItem &item, const char *part)
+{
+    if(!strcmp(part, bubbleContentPart))
+        return getBubbleContent();
+
+    return nullptr;
+}
+
index e8683b7..594a433 100644 (file)
@@ -146,7 +146,7 @@ namespace Msg
             void setMode(Mode mode);
             void setNewMessageMode();
             void setConversationMode();
-            void createBody(Evas_Object *parent);
+            void createBody(Evas_Object *parent, ConvList &convList);
             void createRecipPanel(Evas_Object *parent);
             void destroyRecipPanel();
             void createContactList(Evas_Object *parent);
index 178e0a6..4b522b6 100644 (file)
@@ -146,8 +146,8 @@ void Conversation::create()
     m_WorkingDir = std::make_shared<WorkingDir>();
     createMainLayout(getParent());
     createMsgInputPanel(*m_pLayout);
-    createBody(*m_pMsgInputPanel);
     createConvList(*m_pLayout);
+    createBody(*m_pMsgInputPanel, *m_pConvList);
     updateMsgInputPanel();
 
     getApp().getContactManager().addListener(*this);
@@ -420,12 +420,12 @@ void Conversation::createMsgInputPanel(Evas_Object *parent)
     }
 }
 
-void Conversation::createBody(Evas_Object *parent)
+void Conversation::createBody(Evas_Object *parent, ConvList &convList)
 {
     assert(m_pMsgInputPanel);
     if(!m_pBody && m_pMsgInputPanel)
     {
-        m_pBody = new Body(getApp(), m_WorkingDir);
+        m_pBody = new Body(getApp(), m_WorkingDir, convList);
         m_pBody->create(*m_pMsgInputPanel);
         m_pBody->setListener(this);
         m_pBody->show();