class AppControlCompose;
typedef std::shared_ptr<AppControlCompose> AppControlComposeRef;
+ struct VcfInfo
+ {
+ std::list<int> contactsIdList;
+ bool isMyProfile;
+ };
+
class AppControlCompose
: public AppControlCommand
{
*/
const FileList &getFileList() const;
+ /**
+ * Gets vcf info from APP_CONTROL_DATA_ID
+ */
+ const VcfInfo &getVcfInfo() const;
+
private:
bool parseUriCompose(app_control_h handle);
bool parseUriShare(app_control_h handle);
FileList m_FileList;
std::string m_MessageText;
std::string m_Subject;
+ VcfInfo m_VcfInfo;
};
}
namespace
{
+ const std::string mimeContact = "application/vnd.tizen.contact";
+ const std::string myProfileDataType = "my_profile";
+
typedef std::unordered_map<std::string, AppControlCompose::OpComposeType> OperationMap;
const OperationMap operationMap =
void AppControlCompose::createShareOp(app_control_h handle)
{
parseUriShare(handle);
+
+ if(mimeContact == AppControlUtils::getMimeType(handle))
+ {
+ std::string idStr = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_ID);
+ if(!idStr.empty())
+ {
+ std::string dataType = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TYPE);
+ m_VcfInfo.isMyProfile = (dataType == myProfileDataType);
+ m_VcfInfo.contactsIdList.push_back(atoi(idStr.c_str()));
+ }
+ }
+
if (m_FileList.empty())
{
m_FileList.push_back(AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_PATH));
}
void AppControlCompose::createMultiShareOp(app_control_h handle)
{
+ if(mimeContact == AppControlUtils::getMimeType(handle))
+ {
+ std::list<std::string> contactsList;
+ AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_ID, contactsList);
+ for(auto it : contactsList)
+ m_VcfInfo.contactsIdList.push_back(atoi(it.c_str()));
+ }
+
AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH, m_FileList);
parseUriShare(handle);
}
{
return m_isMms;
}
+
const std::string &AppControlCompose::getMessageText() const
{
return m_MessageText;
return m_FileList;
}
+const VcfInfo &AppControlCompose::getVcfInfo() const
+{
+ return m_VcfInfo;
+}
+
bool AppControlCompose::parseUriCompose(app_control_h handle)
{
TRACE;
*/
#include "ContactManager.h"
-#include "FileUtils.h"
#include <sstream>
#include "Logger.h"
#include <contacts_vcard.h>
using namespace Msg;
+namespace
+{
+ const int avgLengthOfContent = 2048;
+}
+
std::string ContactManager::makeVcard(const int personId, bool myProfile)
{
contacts_record_h record = nullptr;
return std::string();
}
vcardContent = createContactContent(record, myProfile);
- MSG_LOG("vcardContent = ", vcardContent);
+
if(record)
contacts_record_destroy(record, true);
std::string ContactManager::makeVcard(const std::list<int> &idList)
{
- std::ostringstream vcardContent;
-
+ std::string vcardContent;
+ vcardContent.reserve(idList.size() * avgLengthOfContent);
for(auto it : idList)
- {
- if(!vcardContent.str().empty())
- vcardContent << "/n";
+ vcardContent += createContentForContactList(it);
- vcardContent << createContentForContactList(it);
- }
- MSG_LOG("vcardContent = ", vcardContent.str());
- return vcardContent.str();
+ return vcardContent;
}
std::string ContactManager::createContactContent(contacts_record_h record, bool myProfile)
void onTooLargePopupDel(Evas_Object *obj, void *eventInfo);
+ std::string createVcfFile(const AppControlComposeRef &cmd);
+
// BodyView:
virtual void onContentChanged();
virtual void onItemDelete(PageViewItem &item);
namespace
{
+ const std::string contactFileName = "Contact.vcf";
+ const std::string contactsFileName = "Contacts.vcf";
+
inline TextPageViewItem *getTextItem(const PageView &page)
{
return page ? static_cast<TextPageViewItem*>(page.getItem(PageViewItem::TextType)) : nullptr;
if(textItem)
textItem->setText(cmd->getMessageText());
+ std::list<std::string> path = cmd->getFileList();
+ if(!cmd->getVcfInfo().contactsIdList.empty())
+ path.push_back(createVcfFile(cmd));
+
//TODO: implement fill of subject.
- addMedia(cmd->getFileList());
+ addMedia(path);
}
void Body::addAttachment(const std::string &filePath, const std::string &fileName)
m_TooLargePopupShow = false;
}
+std::string Body::createVcfFile(const AppControlComposeRef &cmd)
+{
+ auto &idList = cmd->getVcfInfo().contactsIdList;
+ std::string content;
+ std::string path;
+
+ if(cmd->getComposeType() == AppControlCompose::OpShare)
+ {
+ content = m_App.getContactManager().makeVcard(*idList.begin(), cmd->getVcfInfo().isMyProfile);
+ path = contactFileName;
+ }
+ else if(cmd->getComposeType() == AppControlCompose::OpMultiShare)
+ {
+ content = m_App.getContactManager().makeVcard(idList);
+ path = contactsFileName;
+ }
+
+ path = content.empty() ? std::string() : m_WorkingDir.addTextFile(content, path);
+
+ return path;
+}
+
void Body::onContentChanged()
{
if(!m_pOnChangedIdler)
std::string genUniqueFilePath(const std::string &fileName) const;
std::string addFile(const std::string &path);
- std::string addTextFile(const std::string &text);
+ std::string addTextFile(const std::string &text, const std::string &fileName = "");
void removeFile(const std::string &path);
void clear();
if(FileUtils::isExists(path))
{
- newPath = genUniqueFilePath(path);
- if(FileUtils::copy(path, newPath))
+ if(path.find(m_Path) != std::string::npos)
{
- MSG_LOG("File added: ", newPath);
+ newPath = path;
+ MSG_LOG("File is already exists: ", newPath);
+ }
+ else
+ {
+ newPath = genUniqueFilePath(path);
+ if(FileUtils::copy(path, newPath))
+ {
+ MSG_LOG("File added: ", newPath);
+ }
}
}
return newPath;
}
-std::string WorkingDir::addTextFile(const std::string &text)
+std::string WorkingDir::addTextFile(const std::string &text, const std::string &fileName)
{
- std::string path = genUniqueFilePath(textFileName);
+ 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())
{