std::string getPhoneNumber() const;
std::string getEmail() const;
std::string getThumb() const;
+ std::string getAddress() const;
};
inline Contact::Contact(bool release, contacts_record_h record)
inline std::string Contact::getPhoneNumber() const
{
- return getStr(_contacts_contact.number);
+ std::string res;
+ int count = getChildCount(_contacts_contact.number);
+ if(count > 0)
+ res = getStr(getChildP(_contacts_contact.number, 0), _contacts_number.number);
+ return res;
}
inline std::string Contact::getEmail() const
{
- return getStr(_contacts_contact.email);
+ std::string res;
+ int count = getChildCount(_contacts_contact.email);
+ if(count > 0)
+ res = getStr(getChildP(_contacts_contact.number, 0), _contacts_email.email);
+ return res;
}
inline std::string Contact::getThumb() const
{
return getStr(_contacts_contact.image_thumbnail_path);
}
+
+ inline std::string Contact::getAddress() const
+ {
+ std::string address = getPhoneNumber();
+ if(address.empty())
+ address = getEmail();
+ return address;
+ }
}
#endif /* __Contact_h__ */
return count;
}
+ bool isEmpty() const
+ {
+ return getCount() <= 0;
+ }
+
private:
contacts_list_h m_List;
T m_Record;
protected:
std::string getStr(unsigned propertyId) const;
int getInt(unsigned propertyId) const;
+ int getChildCount(unsigned propertyId) const;
+ contacts_record_h getChildP(unsigned propertyId, int index) const;
+
+ static std::string getStr(contacts_record_h rec, unsigned propertyId);
+ static int getInt(contacts_record_h rec, unsigned propertyId);
+ static int getChildCount(contacts_record_h rec, unsigned propertyId);
+ static contacts_record_h getChildP(contacts_record_h rec, unsigned propertyId, int index);
private:
contacts_record_h m_Record;
m_Record = record;
}
- inline std::string ContactRecord::getStr(unsigned propertyId) const
+ inline contacts_record_h ContactRecord::getRecord() const
+ {
+ return m_Record;
+ }
+
+ inline std::string ContactRecord::getStr(contacts_record_h rec, unsigned propertyId)
{
char *str = nullptr;
- contacts_record_get_str_p(m_Record, propertyId, &str);
+ contacts_record_get_str_p(rec, propertyId, &str);
return str ? str : std::string();
}
- inline int ContactRecord::getInt(unsigned propertyId) const
+ inline int ContactRecord::getChildCount(contacts_record_h rec, unsigned propertyId)
+ {
+ int count = 0;
+ contacts_record_get_child_record_count(rec, propertyId, &count);
+ return count;
+ }
+
+ inline contacts_record_h ContactRecord::getChildP(contacts_record_h rec, unsigned propertyId, int index)
+ {
+ contacts_record_h res = {};
+ contacts_record_get_child_record_at_p(rec, propertyId, index, &res);
+ return res;
+ }
+
+ inline int ContactRecord::getInt(contacts_record_h rec, unsigned propertyId)
{
int val = 0;
- contacts_record_get_int(m_Record, propertyId, &val);
+ contacts_record_get_int(rec, propertyId, &val);
return val;
}
- inline contacts_record_h ContactRecord::getRecord() const
+ inline std::string ContactRecord::getStr(unsigned propertyId) const
{
- return m_Record;
+ return getStr(m_Record, propertyId);
+ }
+
+ inline int ContactRecord::getChildCount(unsigned propertyId) const
+ {
+ return getChildCount(m_Record, propertyId);
}
+ inline contacts_record_h ContactRecord::getChildP(unsigned propertyId, int index) const
+ {
+ return getChildP(m_Record, propertyId, index);
+ }
+
+ inline int ContactRecord::getInt(unsigned propertyId) const
+ {
+ return getInt(m_Record, propertyId);
+ }
}
#endif /* __ContactRecord_h__ */
namespace Msg
{
class App;
+ typedef long ThumbId;
class ThumbnailMaker
: public IContactManagerListener
{
public:
- typedef long ThumbId;
enum DefaultThumbs
{
SingleThumb = 0, // Static thumb
m_App.getContactManager().removeListener(*this);
}
-ThumbnailMaker::ThumbId ThumbnailMaker::getThumbId(const MsgAddress &address)
+ThumbId ThumbnailMaker::getThumbId(const MsgAddress &address)
{
return getThumbId(address.getAddress());
}
-ThumbnailMaker::ThumbId ThumbnailMaker::getThumbId(const std::string &address)
+ThumbId ThumbnailMaker::getThumbId(const std::string &address)
{
ContactAddressRef contact = m_App.getContactManager().getContactAddress(address);
return contact ? getThumbIdFromFile(contact->getThumbnailPath()) : getThumbId(SingleThumb);
}
-ThumbnailMaker::ThumbId ThumbnailMaker::getThumbIdFromFile(const std::string &path)
+ThumbId ThumbnailMaker::getThumbIdFromFile(const std::string &path)
{
if(path.empty())
{
}
}
-ThumbnailMaker::ThumbId ThumbnailMaker::getThumbId(DefaultThumbs thumb)
+ThumbId ThumbnailMaker::getThumbId(DefaultThumbs thumb)
{
auto it = m_ContactsMap.find(defaultThumbsToStr(thumb));
if(it != m_ContactsMap.end())
private:
App &m_App;
std::string m_Recipient;
- ThumbnailMaker::ThumbId m_ThumbId;
+ ThumbId m_ThumbId;
std::string m_MainText;
std::string m_SubText;
};
App &m_App;
WorkingDirRef m_WorkingDir;
FileViewer m_FileViewer;
- ThumbnailMaker::ThumbId m_RecipThumbId;
+ ThumbId m_RecipThumbId;
std::string m_SearchWord;
};
FileViewer &fileViewer,
WorkingDirRef workingDir,
const std::string &searchWord,
- const ThumbnailMaker::ThumbId &thumbId = -1);
+ const ThumbId &thumbId = -1);
virtual ~ConvListItem();
void addTextItem(const MsgConvMedia &media, const std::string &searchWord);
void addTextItem(std::string text, bool markup, const std::string &searchWord);
void addImageItem(const MsgConvMedia &media);
- void addAttachedFileItem(const MsgConvMedia &media);
+ void addUnknownFileItem(const MsgConvMedia &media);
void addCalendarItem(const MsgConvMedia &media);
+ void addContactItem(const MsgConvMedia &media);
// Create Popup when message is clicked
void showMainListPopup();
time_t m_Time;
std::string m_TimeStr;
std::list<BubbleEntity*> m_BubbleEntityList;
- const ThumbnailMaker::ThumbId &m_ThumbId;
+ const ThumbId &m_ThumbId;
};
class IConvListItemListener
void ConvList::appendItem(const MsgConversationItem &item)
{
- static const ThumbnailMaker::ThumbId invalidId = -1;
- const ThumbnailMaker::ThumbId &thumbId = item.getDirection() == Message::MD_Received ? m_RecipThumbId : invalidId;
+ static const ThumbId invalidId = -1;
+ const ThumbId &thumbId = item.getDirection() == Message::MD_Received ? m_RecipThumbId : invalidId;
appendItem(new ConvListItem(item, m_App, m_FileViewer, m_WorkingDir, m_SearchWord, thumbId));
}
#include "TimeUtils.h"
#include "FileViewer.h"
#include "BubbleItemContainer.h"
+#include "ContactManager.h"
// Bubble items:
#include "BubbleTextViewItem.h"
#include "BubbleDownloadButtonViewItem.h"
#include "BubbleUnknownFileViewItem.h"
#include "BubbleCalEventViewItem.h"
+#include "BubbleContactViewItem.h"
#include <notification_status.h>
#include <sstream>
<< std::setfill('0') << std::setw(2) << m;
return ss.str();
}
+
+ std::string getFileName(const MsgConvMedia &media)
+ {
+ std::string res = media.getName();
+ if(res.empty())
+ res = FileUtils::getFileName(media.getPath());
+ return res;
+ }
}
ConvListItem::ConvListItem(const MsgConversationItem &item,
FileViewer &fileViewer,
WorkingDirRef workingDir,
const std::string &searchWord,
- const ThumbnailMaker::ThumbId &thumbId)
+ const ThumbId &thumbId)
: ConvListViewItem(getConvItemType(item))
, m_pListener(nullptr)
, m_App(app)
m_BubbleEntityList.push_back(entity);
}
-void ConvListItem::addAttachedFileItem(const MsgConvMedia &media)
+void ConvListItem::addUnknownFileItem(const MsgConvMedia &media)
{
- std::string dsipName = media.getName();
- std::string path = media.getPath();
- if(dsipName.empty())
- dsipName = FileUtils::getFileName(path);
-
- auto *entity = new BubbleUnknownFileEntity(path, dsipName);
+ std::string dsipName = getFileName(media);
+ auto *entity = new BubbleUnknownFileEntity(media.getPath(), dsipName);
m_BubbleEntityList.push_back(entity);
}
}
}
+void ConvListItem::addContactItem(const MsgConvMedia &media)
+{
+ auto list = m_App.getContactManager().parseVcard(media.getPath());
+ if(list && !list->isEmpty())
+ {
+ BubbleContactEntity *entity = nullptr;
+
+ if(list->getCount() > 1)
+ {
+ std::string fileName = getFileName(media);
+ entity = new BubbleContactEntity(m_App.getThumbnailMaker(), media.getPath(), fileName);
+ }
+ else
+ {
+ const Contact &rec = list->get();
+ entity = new BubbleContactEntity(m_App.getThumbnailMaker(), media.getPath(), rec.getDispName(), rec.getAddress());
+ }
+ if(entity)
+ m_BubbleEntityList.push_back(entity);
+ }
+}
+
void ConvListItem::addDownloadButtonItem()
{
auto *entity = new BubbleDownloadButtonEntity;
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);
+
switch(msgMediaType)
{
case MsgMedia::TextType:
default:
if(mime == "text/x-vcalendar" || mime == "text/calendar")
addCalendarItem(media);
+ if(mime == "text/x-vcard" || mime == "text/vcard")
+ addContactItem(media);
else if(mime != "application/smil")
- addAttachedFileItem(media);
+ addUnknownFileItem(media);
break;
}
}
--- /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 BubbleContactViewItem_h_
+#define BubbleContactViewItem_h_
+
+#include "BubbleIconTextLayoutItem.h"
+#include "ThumbnailMaker.h"
+
+namespace Msg
+{
+ class BubbleContactViewItem
+ : public BubbleIconTextLayoutItem
+ {
+ public:
+ BubbleContactViewItem(BubbleEntity &entity, Evas_Object *parent, LayoutType type);
+ virtual ~BubbleContactViewItem();
+ };
+
+ class BubbleContactEntity
+ : public BubbleEntity
+ {
+ public:
+ BubbleContactEntity(ThumbnailMaker &thumbMaker, const std::string &filePath, const std::string &fileName);
+ BubbleContactEntity(ThumbnailMaker &thumbMaker, const std::string &filePath, const std::string &dispName, const std::string &address);
+ virtual ~BubbleContactEntity();
+
+ void setThumbId(ThumbId id);
+ virtual BubbleContactViewItem *createView(Evas_Object *parent);
+ virtual const std::string &getFilePath() const;
+
+ private:
+ ThumbnailMaker &m_ThumbMaker;
+ const std::string m_FilePath;
+ const std::string m_Name;
+ const std::string m_Address;
+ ThumbId m_ThumbId;
+ };
+}
+
+#endif /* BubbleContactViewItem_h_ */
Layout1Icon1Text,
Layout1Icon2Text
};
+ static const int iconSize = 50;
public:
BubbleIconTextLayoutItem(BubbleEntity &entity, Evas_Object *parent, LayoutType layoutType);
virtual ~BubbleIconTextLayoutItem();
+ LayoutType getLayoutType() const;
void setIcon(Evas_Object *icon);
void setMainText(const std::string &text);
void setSubText(const std::string &text);
static Evas_Object *createIcon(Evas_Object *parent, const std::string &edjFileName);
+
+ private:
+ LayoutType m_LayoutType;
};
}
--- /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 "BubbleContactViewItem.h"
+#include "Resource.h"
+
+using namespace Msg;
+
+BubbleContactViewItem::BubbleContactViewItem(BubbleEntity &entity, Evas_Object *parent, LayoutType type)
+ : BubbleIconTextLayoutItem(entity, parent, type)
+{
+ attachGestureTapLayer(getEo(), getEo());
+}
+
+BubbleContactViewItem::~BubbleContactViewItem()
+{
+}
+
+BubbleContactEntity::BubbleContactEntity(ThumbnailMaker &thumbMaker, const std::string &filePath, const std::string &fileName)
+ : BubbleContactEntity(thumbMaker, filePath, fileName, {})
+{
+
+}
+
+BubbleContactEntity::BubbleContactEntity(ThumbnailMaker &thumbMaker, const std::string &filePath, const std::string &dispName, const std::string &address)
+ : BubbleEntity(ContactItem)
+ , m_FilePath(filePath)
+ , m_Name(dispName)
+ , m_Address(address)
+ , m_ThumbId(ThumbnailMaker::SingleThumb)
+ , m_ThumbMaker(thumbMaker)
+{
+}
+
+BubbleContactEntity::~BubbleContactEntity()
+{
+}
+
+BubbleContactViewItem *BubbleContactEntity::createView(Evas_Object *parent)
+{
+ BubbleContactViewItem::LayoutType type = m_Address.empty() ? BubbleContactViewItem::Layout1Icon1Text : BubbleContactViewItem::Layout1Icon2Text;
+ auto *item = new BubbleContactViewItem(*this, parent, type);
+ item->setIcon(m_ThumbMaker.getThumbById(*item, m_ThumbId, BubbleContactViewItem::iconSize));
+ item->setMainText(m_Name);
+ if(!m_Address.empty())
+ item->setSubText(m_Address);
+ return item;
+}
+
+const std::string &BubbleContactEntity::getFilePath() const
+{
+ return m_FilePath;
+}
+
+void BubbleContactEntity::setThumbId(ThumbId id)
+{
+ m_ThumbId = id;
+}
BubbleIconTextLayoutItem::BubbleIconTextLayoutItem(BubbleEntity &entity, Evas_Object *parent, LayoutType layoutType)
: BubbleViewItem(entity)
+ , m_LayoutType(layoutType)
{
const char *group = nullptr;
switch(layoutType)
evas_object_show(icon);
return icon;
}
+
+BubbleIconTextLayoutItem::LayoutType BubbleIconTextLayoutItem::getLayoutType() const
+{
+ return m_LayoutType;
+}
virtual Evas_Object *getThumbnail();
App &m_App;
- ThumbnailMaker::ThumbId m_ThumbId;
+ ThumbId m_ThumbId;
std::string m_Name;
std::string m_Message;
std::string m_Time;