{
MSG_LOG("ComposeType: ", m_ComposeType);
- if(handle)
+ if (handle)
{
- switch(m_ComposeType)
+ switch (m_ComposeType)
{
case OpCompose:
createComposeOp(handle);
{
parseUriShare(handle);
- if(mimeContact == AppControlUtils::getMimeType(handle))
+ if (mimeContact == AppControlUtils::getMimeType(handle))
{
std::string idStr = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_ID);
- if(!idStr.empty())
+ if (!idStr.empty())
{
std::string dataType = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TYPE);
m_VcfInfo.isMyProfile = (dataType == myProfileDataType);
}
}
- if(m_FileList.empty())
+ if (m_FileList.empty())
{
std::string path = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_PATH);
- if(!path.empty())
+ if (!path.empty())
m_FileList.push_back(std::move(path));
}
}
void AppControlCompose::createMultiShareOp(app_control_h handle)
{
- if(mimeContact == AppControlUtils::getMimeType(handle))
+ if (mimeContact == AppControlUtils::getMimeType(handle))
{
std::list<std::string> contactsList;
AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_ID, contactsList);
- for(auto it : contactsList)
+ for (auto it : contactsList)
m_VcfInfo.contactsIdList.push_back(atoi(it.c_str()));
}
if (cur == "sms" || cur == "mmsto" || cur == "file")
{
m_isMms = (cur == "mmsto" || cur == "file");
- if(cur == "file" && m_FileList.empty())
+ if (cur == "file" && m_FileList.empty())
{
std::string prefix("file://");
m_FileList.push_back(uriToParse.erase(0, prefix.length()));
}
res = true;
- }
- else
- {
+ } else {
auto it = std::find(m_FileList.begin(), m_FileList.end(), uriToParse);
- if(it == m_FileList.end())
+ if (it == m_FileList.end())
m_FileList.push_back(uriToParse); // no prefix, uri is a path to file itself
}
}
AppControlDefault::~AppControlDefault()
{
-
}
MsgId AppControlDefault::getMessageId() const
{
char *key = nullptr;
app_control_get_extra_data(handle, keyType, &key);
- if(!key)
+ if (!key)
{
m_DefaultType = MainType;
return;
std::string type = key;
free(key);
- if(type == valueNewMsg)
+ if (type == valueNewMsg)
viewMessage(handle);
- else if(type == valueSendFailed)
+ else if (type == valueSendFailed)
m_DefaultType = SendFailedType;
else
MSG_LOG("Unknown type!");
char *msgIdStr = nullptr;
app_control_get_extra_data(handle, keyMsgId, &msgIdStr);
- if(!msgIdStr)
+ if (!msgIdStr)
return;
m_MsgId = atoi(msgIdStr);
{
char *keyVal = nullptr;
app_control_get_extra_data(handle, notificationPanel, &keyVal);
- if(keyVal)
+ if (keyVal)
{
free(keyVal);
return true;
}
- else
- return false;
+
+ return false;
}
void AppControlDefault::viewMessage(app_control_h handle)
{
makeReplyText(handle);
- if(isNotificationPanel(handle))
+ if (isNotificationPanel(handle))
m_DefaultType = NotificationType;
else
m_DefaultType = m_ReplyText.empty() ? ViewType : ReplyType;
app_control_get_operation(handle, &opStr);
- if(!opStr)
+ if (!opStr)
{
MSG_LOG_WARN("app_control operation is null");
return cmd;
AppControlCommand::OperationType opType = getOperation(opStr);
- switch(opType)
+ switch (opType)
{
case AppControlCommand::OpDefault:
cmd = std::make_shared<AppControlDefault>(opStr, handle);
{
std::string res;
char *val = nullptr;
- if(APP_CONTROL_ERROR_NONE == app_control_get_extra_data(handle, key.c_str(), &val))
+ if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data(handle, key.c_str(), &val))
{
- if(val)
+ if (val)
{
res = val;
free(val);
{
int arrayLength = 0;
char **pArrayVal = nullptr;
- if(APP_CONTROL_ERROR_NONE == app_control_get_extra_data_array(handle, key.c_str(), &pArrayVal, &arrayLength))
+ if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data_array(handle, key.c_str(), &pArrayVal, &arrayLength))
{
- for(int i = 0; i < arrayLength; ++i)
+ for (int i = 0; i < arrayLength; ++i)
{
outArray.push_back(pArrayVal[i]);
free(pArrayVal[i]);
{
char *val = nullptr;
int parsed = 0;
- if(APP_CONTROL_ERROR_NONE == app_control_get_extra_data(handle, key.c_str(), &val) && val)
+ if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data(handle, key.c_str(), &val) && val)
{
parsed = atoi(val);
free(val);
{
int arrayLength = 0;
char **pArrayVal = nullptr;
- if(APP_CONTROL_ERROR_NONE == app_control_get_extra_data_array(handle, key.c_str(), &pArrayVal, &arrayLength)
+ if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data_array(handle, key.c_str(), &pArrayVal, &arrayLength)
&& pArrayVal)
{
std::string::size_type sz;
- for(int i = 0; i < arrayLength; ++i)
+ for (int i = 0; i < arrayLength; ++i)
{
- if(pArrayVal[i])
+ if (pArrayVal[i])
{
std::string s(pArrayVal[i] ? pArrayVal[i] : "");
free(pArrayVal[i]);
int parsed = std::stoi(s, &sz);
- if(sz == s.length())
+ if (sz == s.length())
{
outArray.push_back(parsed);
}
char *mime = nullptr;
std::string result;
app_control_get_mime(handle, &mime);
- if(mime)
+ if (mime)
{
result = mime;
free(mime);
bool ContactEditor::launch(const std::string &address, Operation operation)
{
bool res = false;
- if(!address.empty())
+ if (!address.empty())
{
const char *op = nullptr;
- if(operation == EditOp)
+ if (operation == EditOp)
op = APP_CONTROL_OPERATION_EDIT;
- else if(operation == CreateOp)
+ else if (operation == CreateOp)
op = APP_CONTROL_OPERATION_ADD;
- if(op)
+ if (op)
{
- if(MsgUtils::isValidNumber(address))
+ if (MsgUtils::isValidNumber(address))
res = launch(address, op, APP_CONTROL_DATA_PHONE);
- else if(MsgUtils::isValidEmail(address))
+ else if (MsgUtils::isValidEmail(address))
res = launch(address, op, APP_CONTROL_DATA_EMAIL);
}
}
{
bool res = false;
terminate();
- if(APP_CONTROL_ERROR_NONE == app_control_create(&m_Handle))
+ if (APP_CONTROL_ERROR_NONE == app_control_create(&m_Handle))
{
app_control_set_operation(m_Handle, operation);
app_control_set_mime(m_Handle, mimeContact);
int ret = app_control_send_launch_request(m_Handle, APP_CONTROL_RES_CALLBACK(ContactEditor, onResultCb), this);
MSG_LOG("Result code: ", ret);
res = ret == APP_CONTROL_ERROR_NONE;
- if(!res)
+ if (!res)
terminate();
}
void ContactEditor::terminate()
{
- if(m_Handle)
+ if (m_Handle)
{
app_control_send_terminate_request(m_Handle);
app_control_destroy(m_Handle);
void ContactEditor::onResultCb(app_control_h request, app_control_h reply, app_control_result_e result)
{
- if(m_Handle)
+ if (m_Handle)
{
- if(result == APP_CONTROL_RESULT_SUCCEEDED && m_pListener)
+ if (result == APP_CONTROL_RESULT_SUCCEEDED && m_pListener)
{
char *op = nullptr;
app_control_get_operation(m_Handle, &op);
- if(op)
+ if (op)
{
terminate();
- if(strcmp(op, APP_CONTROL_OPERATION_EDIT) == 0)
+ if (strcmp(op, APP_CONTROL_OPERATION_EDIT) == 0)
m_pListener->onContactChanged(*this);
- else if(strcmp(op, APP_CONTROL_OPERATION_ADD) == 0)
+ else if (strcmp(op, APP_CONTROL_OPERATION_ADD) == 0)
m_pListener->onContactCreated(*this);
free(op);
}
ContactViewer::ContactViewer()
: m_Handle()
{
-
}
ContactViewer::~ContactViewer()
void ContactViewer::reset()
{
- if(m_Handle)
+ if (m_Handle)
{
app_control_send_terminate_request(m_Handle);
app_control_destroy(m_Handle);
bool res = false;
reset();
- if(APP_CONTROL_ERROR_NONE == app_control_create(&m_Handle))
+ if (APP_CONTROL_ERROR_NONE == app_control_create(&m_Handle))
{
app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_VIEW);
app_control_set_mime(m_Handle, mimeContact);
const char *ContactViewer::toStr(ContactAddress::OwnerType type)
{
- switch(type)
+ switch (type)
{
case ContactAddress::PersonType:
return personContactTypeStr;
FileViewer::~FileViewer()
{
- if(!m_FilePath.empty())
+ if (!m_FilePath.empty())
FileUtils::remove(m_FilePath);
}
MSG_LOG("File path: ", file);
MSG_LOG("MIME type: ", mime);
- if(mime.empty() || file.empty())
+ if (mime.empty() || file.empty())
return false;
- if(APP_CONTROL_ERROR_NONE == app_control_create(&svc_handle))
+ if (APP_CONTROL_ERROR_NONE == app_control_create(&svc_handle))
{
app_control_set_operation(svc_handle, APP_CONTROL_OPERATION_VIEW);
app_control_set_mime(svc_handle, mime.c_str());
{
bool res = false;
// Remove previous file (correct only for APP_CONTROL_LAUNCH_MODE_GROUP)
- if(!m_FilePath.empty())
+ if (!m_FilePath.empty())
FileUtils::remove(m_FilePath);
m_FilePath = FileUtils::addFileToDataDir(file);
- if(!m_FilePath.empty())
+ if (!m_FilePath.empty())
res = launch(m_FilePath);
return res;
Share::Share()
{
-
}
Share::~Share()
void Share::removeFiles()
{
- for(auto &&file : m_FileList)
+ for (auto &&file : m_FileList)
{
FileUtils::remove(file);
}
void Share::addFiles(const std::list<std::string> &files)
{
removeFiles();
- for(auto &&file : files)
+ for (auto &&file : files)
{
m_FileList.push_back(FileUtils::addFileToDataDir(file));
}
bool Share::launch(const std::list<std::string> &files)
{
- if(files.empty())
+ if (files.empty())
return false;
bool res = false;
app_control_h svc_handle = nullptr;
- if(APP_CONTROL_ERROR_NONE == app_control_create(&svc_handle))
+ if (APP_CONTROL_ERROR_NONE == app_control_create(&svc_handle))
{
addFiles(files);
app_control_set_operation(svc_handle, APP_CONTROL_OPERATION_MULTI_SHARE);
app_control_set_launch_mode(svc_handle, APP_CONTROL_LAUNCH_MODE_GROUP);
std::vector<const char*> nativePaths;
- for(const std::string &file : m_FileList)
+ for (const std::string &file : m_FileList)
{
- if(!file.empty())
+ if (!file.empty())
nativePaths.push_back(file.c_str());
}
bool Share::launch(const std::string &text)
{
- if(text.empty())
+ if (text.empty())
return false;
bool res = false;
app_control_h svc_handle = nullptr;
- if(APP_CONTROL_ERROR_NONE == app_control_create(&svc_handle))
+ if (APP_CONTROL_ERROR_NONE == app_control_create(&svc_handle))
{
app_control_set_operation(svc_handle, APP_CONTROL_OPERATION_SHARE_TEXT);
app_control_add_extra_data(svc_handle, APP_CONTROL_DATA_TEXT, text.c_str());
bool res = false;
app_control_h svcHandle = nullptr;
- if(APP_CONTROL_ERROR_NONE == app_control_create(&svcHandle))
+ if (APP_CONTROL_ERROR_NONE == app_control_create(&svcHandle))
{
app_control_set_operation(svcHandle, APP_CONTROL_OPERATION_CALL);
std::string phoneNumber = tel + number;
{
std::string res;
int count = getChildCount(_contacts_contact.number);
- if(count > 0)
+ if (count > 0)
res = getStr(getChildP(_contacts_contact.number, 0), _contacts_number.number);
return res;
}
{
std::string res;
int count = getChildCount(_contacts_contact.email);
- if(count > 0)
+ if (count > 0)
res = getStr(getChildP(_contacts_contact.number, 0), _contacts_email.email);
return res;
}
inline std::string Contact::getAddress() const
{
std::string address = getPhoneNumber();
- if(address.empty())
+ if (address.empty())
address = getEmail();
return address;
}
~ContactList()
{
- if(m_List)
+ if (m_List)
contacts_list_destroy(m_List, true);
}
MSG_LOG("");
m_AddressMap.reserve(mapReservSize);
int error = contacts_connect();
- if(error != 0)
+ if (error != 0)
{
MSG_LOG_ERROR(whatError(error));
}
{
MSG_LOG("");
int error = contacts_db_remove_changed_cb(_contacts_contact._uri, contactChangedCb, this);
- if(error != 0)
+ if (error != 0)
MSG_LOG_ERROR(whatError(error));
error = contacts_disconnect();
- if(error != 0)
+ if (error != 0)
MSG_LOG_ERROR(whatError(error));
}
std::string ContactManager::whatError(int error)
{
- switch(error)
+ switch (error)
{
case CONTACTS_ERROR_NONE:
return "CONTACTS_ERROR_NONE";
ContactMyProfileNumberRef ContactManager::getContactMyProfileNumber(const std::string &number)
{
auto myProfile = getOwnerProfile();
- if(!myProfile)
+ if (!myProfile)
return nullptr;
contacts_record_h rec = myProfile->getRecord();
contacts_record_get_child_record_count(rec, _contacts_my_profile.number, &count);
std::string normalizedNumber = PhoneNumberUtils::getInst().getNormalizedNumber(number);
- for(int i =0; i < count; ++i)
+ for (int i =0; i < count; ++i)
{
contacts_record_h child = nullptr;
contacts_record_get_child_record_at_p(rec, _contacts_my_profile.number, i, &child);
- if(child)
+ if (child)
{
char *num = nullptr;
contacts_record_get_str_p(child, _contacts_number.number, &num);
- if(num)
+ if (num)
{
std::string curNum = PhoneNumberUtils::getInst().getNormalizedNumber(num);
- if(normalizedNumber == curNum)
+ if (normalizedNumber == curNum)
{
contacts_record_h clonedRec = nullptr;
contacts_record_clone(child, &clonedRec);
- if(clonedRec)
+ if (clonedRec)
return std::make_shared<ContactMyProfileNumber>(true, *myProfile, clonedRec);
}
}
ContactMyProfileEmailRef ContactManager::getContactMyProfileEmail(const std::string &email)
{
auto myProfile = getOwnerProfile();
- if(!myProfile)
+ if (!myProfile)
return nullptr;
contacts_record_h rec = myProfile->getRecord();
int count = 0;
contacts_record_get_child_record_count(rec, _contacts_my_profile.email, &count);
- for(int i =0; i < count; ++i)
+ for (int i =0; i < count; ++i)
{
contacts_record_h child = nullptr;
contacts_record_get_child_record_at_p(rec, _contacts_my_profile.email, i, &child);
- if(child)
+ if (child)
{
char *curEmail = nullptr;
contacts_record_get_str_p(child, _contacts_email.email, &curEmail);
- if(curEmail)
+ if (curEmail)
{
- if(strcasecmp(email.c_str(), curEmail) == 0)
+ if (strcasecmp(email.c_str(), curEmail) == 0)
{
contacts_record_h clonedRec = nullptr;
contacts_record_clone(child, &clonedRec);
- if(clonedRec)
+ if (clonedRec)
return std::make_shared<ContactMyProfileEmail>(true, *myProfile, clonedRec);
}
}
ContactMyProfileRef ContactManager::getOwnerProfile()
{
- if(!m_OwnerProfile)
+ if (!m_OwnerProfile)
{
contacts_list_h list = nullptr;
contacts_record_h myProfile = nullptr;
contacts_db_get_all_records(_contacts_my_profile._uri, 0, 1, &list);
- if(list)
+ if (list)
{
contacts_list_get_current_record_p(list, &myProfile);
contacts_list_destroy(list, false);
}
- if(myProfile)
+ if (myProfile)
m_OwnerProfile.reset(new ContactMyProfile(true, myProfile));
}
return m_OwnerProfile;
{
ContactManager *self = static_cast<ContactManager *>(user_data);
self->invalidateCache();
- for(auto listener : self->m_Listeners)
+ for (auto listener : self->m_Listeners)
{
listener->onContactChanged();
}
{
ContactManager *self = static_cast<ContactManager *>(user_data);
self->invalidateCache();
- for(auto listener : self->m_Listeners)
+ for (auto listener : self->m_Listeners)
{
listener->onContactChanged();
}
void ContactManager::addListener(IContactManagerListener &listener)
{
auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &listener);
- if(found == m_Listeners.end())
+ if (found == m_Listeners.end())
{
m_Listeners.push_back(&listener);
}
void ContactManager::removeListener(IContactManagerListener &listener)
{
auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &listener);
- if(found != m_Listeners.end())
+ if (found != m_Listeners.end())
{
m_Listeners.erase(found);
}
};
int ctRrr = contacts_query_set_projection(query, numberProjection, sizeof(numberProjection) / sizeof(unsigned int));
- if(ctRrr == CONTACTS_ERROR_NONE)
+ if (ctRrr == CONTACTS_ERROR_NONE)
ctRrr = contacts_db_get_records_with_query(query, 0, 0, &list);
contacts_filter_destroy(filter);
contacts_query_destroy(query);
- while(ctRrr == CONTACTS_ERROR_NONE)
+ while (ctRrr == CONTACTS_ERROR_NONE)
{
int contactId = 0;
contacts_list_get_current_record_p(list, &crValue);
- if(crValue)
+ if (crValue)
{
contacts_record_get_int(crValue, _contacts_person_number.person_id, &contactId);
- if(contactId > 0)
+ if (contactId > 0)
cResValue = crValue;
else
contacts_record_destroy(crValue, true);
};
int ctRrr = contacts_query_set_projection(query, numberProjection, sizeof(numberProjection) / sizeof(unsigned int));
- if(ctRrr == CONTACTS_ERROR_NONE)
+ if (ctRrr == CONTACTS_ERROR_NONE)
ctRrr = contacts_db_get_records_with_query(query, 0, 0, &list);
contacts_filter_destroy(filter);
contacts_query_destroy(query);
- while(ctRrr == CONTACTS_ERROR_NONE)
+ while (ctRrr == CONTACTS_ERROR_NONE)
{
int contactId = 0;
contacts_list_get_current_record_p(list, &crValue);
- if(crValue)
+ if (crValue)
{
contacts_record_get_int(crValue, _contacts_person_email.person_id, &contactId);
- if(contactId > 0)
+ if (contactId > 0)
cResValue = crValue;
else
contacts_record_destroy(crValue, true);
ContactAddressRef ContactManager::getAddress(const std::string &address)
{
auto it = m_AddressMap.find(address);
- if(m_AddressMap.end() == it)
+ if (m_AddressMap.end() == it)
{
bool isNumber = MsgUtils::isValidNumber(address);
// ContactPerson:
ContactAddressRef contactAddress;
- if(isNumber)
+ if (isNumber)
contactAddress = getContactPersonNumber(address);
else
contactAddress = getContactPersonEmail(address);
// MyProfile:
- #if(0)
- if(!contactAddress)
+ #if (0)
+ if (!contactAddress)
{
- if(isNumber)
+ if (isNumber)
contactAddress = getContactMyProfileNumber(address);
else
contactAddress = getContactMyProfileEmail(address);
ContactRecord::~ContactRecord()
{
- if(m_Record && m_Release)
+ if (m_Record && m_Release)
{
contacts_record_destroy(m_Record, true);
m_Record = nullptr;
contacts_record_h record = nullptr;
std::string vcardContent;
- if(contacts_db_get_record((myProfile ? _contacts_my_profile._uri : _contacts_person._uri), personId, &record) != CONTACTS_ERROR_NONE)
+ if (contacts_db_get_record((myProfile ? _contacts_my_profile._uri : _contacts_person._uri), personId, &record) != CONTACTS_ERROR_NONE)
{
MSG_LOG_ERROR("contacts_db_get_record() failed");
record = nullptr;
}
vcardContent = createContactContent(record, myProfile);
- if(record)
+ if (record)
contacts_record_destroy(record, true);
return vcardContent;
{
std::string vcardContent;
vcardContent.reserve(idList.size() * avgLengthOfContent);
- for(auto it : idList)
+ for (auto it : idList)
vcardContent += createContentForContactList(it);
return vcardContent;
myProfile ? contacts_vcard_make_from_my_profile(record, &vcardBuff) : contacts_vcard_make_from_person(record, &vcardBuff);
- if(!vcardBuff)
+ if (!vcardBuff)
{
MSG_LOG_ERROR("vcardBuff is NULL");
return std::string();
std::string ContactManager::createContentForContactList(int personId)
{
contacts_record_h record = nullptr;
- if(contacts_db_get_record(_contacts_person._uri, personId, &record) != CONTACTS_ERROR_NONE)
+ if (contacts_db_get_record(_contacts_person._uri, personId, &record) != CONTACTS_ERROR_NONE)
{
MSG_LOG_ERROR("contacts_db_get_record() failed!");
record = nullptr;
{
std::list<ContactRef> res;
- if(filePath.empty())
+ if (filePath.empty())
return res;
int parseRes = contacts_vcard_parse_to_contact_foreach
list->emplace_back(recRef);
return true;
},
- &res
- );
+ &res);
MSG_LOG("Parse result: ", parseRes);
return res;
, m_IsPause(true)
{
int serviceResult = m_Engine.openService();
- if(serviceResult != MESSAGES_ERROR_NONE)
+ if (serviceResult != MESSAGES_ERROR_NONE)
{
MSG_ENGINE_WHAT_ERROR(serviceResult);
MSG_LOG_ERROR("Service handle open error = ", serviceResult);
ContactManager &App::getContactManager()
{
- if(!m_pContactManager)
+ if (!m_pContactManager)
m_pContactManager = new ContactManager;
return *m_pContactManager;
}
PopupManager &App::getPopupManager()
{
- if(!m_pPopupManager)
+ if (!m_pPopupManager)
m_pPopupManager = new PopupManager(getWindow());
return *m_pPopupManager;
}
ThumbnailMaker &App::getThumbnailMaker()
{
- if(!m_pThumbnailMaker)
+ if (!m_pThumbnailMaker)
m_pThumbnailMaker = new ThumbnailMaker(*this);
return *m_pThumbnailMaker;
}
SystemSettingsManager &App::getSysSettingsManager()
{
- if(!m_pSysSettingsManager)
+ if (!m_pSysSettingsManager)
m_pSysSettingsManager = new SystemSettingsManager;
return *m_pSysSettingsManager;
}
void App::addListener(IAppListener &l)
{
auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &l);
- if(found == m_Listeners.end())
+ if (found == m_Listeners.end())
m_Listeners.push_back(&l);
}
void App::removeListener(IAppListener &l)
{
auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &l);
- if(found != m_Listeners.end())
+ if (found != m_Listeners.end())
m_Listeners.erase(found);
}
void App::pause()
{
- if(!m_IsPause)
+ if (!m_IsPause)
{
m_IsPause = true;
- for(IAppListener *l : m_Listeners)
+ for (IAppListener *l : m_Listeners)
l->onAppPause();
updateActiveNotifPolicy();
getPopupManager().onPause();
void App::resume()
{
- if(m_IsPause)
+ if (m_IsPause)
{
m_IsPause = false;
updateActiveNotifPolicy();
- for(IAppListener *l : m_Listeners)
+ for (IAppListener *l : m_Listeners)
l->onAppResume();
}
}
void BaseController::onPause()
{
-
}
void BaseController::onResume()
{
-
}
MsgEngine &BaseController::getMsgEngine()
void FrameController::setNaviBarTitle(const MsgAddressList &addressList)
{
std::string title;
- if(!addressList.isEmpty())
+ if (!addressList.isEmpty())
{
std::string firstAddress = addressList[0].getAddress();
ContactAddressRef contactPersonAddress = getApp().getContactManager().getContactAddress(firstAddress);
- if(contactPersonAddress)
+ if (contactPersonAddress)
title = contactPersonAddress->getDispName();
- if(title.empty())
+ if (title.empty())
title = firstAddress;
int hidenAddresses = addressList.getLength() - 1;
- if(hidenAddresses > 0)
+ if (hidenAddresses > 0)
{
title += " + " + std::to_string(hidenAddresses);
getNaviBar().showButton(NaviExpandButtonId, true);
void FrameController::pause()
{
- if(!m_IsPause)
+ if (!m_IsPause)
{
m_IsPause = true;
onPause();
void FrameController::resume()
{
- if(m_IsPause && !getApp().isPause())
+ if (m_IsPause && !getApp().isPause())
{
m_IsPause = false;
onResume();
{
std::string dispName;
ContactAddressRef contactAddress = m_App.getContactManager().getContactAddress(address);
- if(contactAddress)
+ if (contactAddress)
dispName = contactAddress->getDispName();
- if(dispName.empty())
+ if (dispName.empty())
dispName = address;
return dispName;
}
void MbeRecipients::updateItemsDispName()
{
auto items = getItems();
- for(MbeRecipientItem *item: items)
+ for (MbeRecipientItem *item: items)
{
item->setDispName(getDispName(item->getAddress()));
}
{
clear();
int addrListLen = addressList.getLength();
- for(int i = 0; i < addrListLen; i++)
+ for (int i = 0; i < addrListLen; i++)
{
const MsgAddress &addr = addressList.at(i);
appendItem(addr.getAddress(), addr.getAddressType());
void MbeRecipients::update(ThreadId threadId)
{
clear();
- if(threadId.isValid())
+ if (threadId.isValid())
{
MsgAddressListRef addrList = m_App.getMsgEngine().getStorage().getAddressList(threadId);
- if(addrList)
+ if (addrList)
update(*addrList);
}
}
MbeRecipients::AppendItemStatus MbeRecipients::appendItem(const std::string &address, const std::string &dispName, MsgAddress::AddressType addressType)
{
- if(getItemsCount() >= m_App.getMsgEngine().getSettings().getMaxRecipientCount())
+ if (getItemsCount() >= m_App.getMsgEngine().getSettings().getMaxRecipientCount())
return TooManyRecipStatus;
AppendItemStatus result = SuccessStatus;
- if(!isRecipientExists(address))
+ if (!isRecipientExists(address))
{
- if(addressType == MsgAddress::UnknownAddressType)
+ if (addressType == MsgAddress::UnknownAddressType)
addressType = MsgUtils::getAddressType(address);
- if(addressType == MsgAddress::Phone || addressType == MsgAddress::Email)
+ if (addressType == MsgAddress::Phone || addressType == MsgAddress::Email)
{
result = SuccessStatus;
MbeRecipientItem *item = new MbeRecipientItem(address, dispName, addressType);
MbeRecipientsView::appendItem(*item);
- }
- else
- {
+ } else {
result = InvalidRecipStatus;
MSG_LOG("invalid recipient: ", address);
}
- }
- else
- {
+ } else {
result = DuplicatedStatus;
}
return result;
bool MbeRecipients::isRecipientExists(const std::string& address) const
{
auto recipientList = getItems();
- for(auto pViewItem : recipientList)
+ for (auto pViewItem : recipientList)
{
MbeRecipientItem *pItem = dynamic_cast<MbeRecipientItem*>(pViewItem);
- if(pItem && pItem->getAddress() == address)
+ if (pItem && pItem->getAddress() == address)
return true;
}
void NaviFrameController::pop(FrameController &frame)
{
- if(isLastFrame())
+ if (isLastFrame())
getApp().exit();
else
{
{
MSG_LOG("Execute app. control command: ", cmd.getOperationMsg());
std::string errorMsg;
- if(!getMsgEngine().isReady(errorMsg))
+ if (!getMsgEngine().isReady(errorMsg))
{
notification_status_message_post(errorMsg.c_str());
return false;
void NaviFrameController::execCmd(const AppControlDefaultRef &cmd)
{
- if(prepare(*cmd))
+ if (prepare(*cmd))
{
AppControlDefault::DefaultType type = cmd->getDefaultType();
MsgThread *thread = getTopFrame<MsgThread>(); // Check if thread is open
- if(!thread)
+ if (!thread)
insertToBottom(*new MsgThread(*this)); // Push thread list to the bottom
Conversation *conv = getTopFrame<Conversation>(); // Check if conversation is open
MessageRef msg = getMsgEngine().getStorage().getMessage(cmd->getMessageId()); //To avoid opening conversation if MsgId is invalid
- if(type != AppControlDefault::MainType && msg != nullptr)
+ if (type != AppControlDefault::MainType && msg != nullptr)
{
- if(conv)
+ if (conv)
{
promote(*conv);
conv->execCmd(cmd);
- }
- else if(!conv)
- {
- if(type == AppControlDefault::ViewType || type == AppControlDefault::ReplyType || isUnreadNotificationSingle(type))
+ } else if (!conv) {
+ if (type == AppControlDefault::ViewType || type == AppControlDefault::ReplyType || isUnreadNotificationSingle(type))
{
Conversation *conversation = new Conversation(*this);
push(*conversation);
void NaviFrameController::execCmd(const AppControlComposeRef &cmd)
{
- if(prepare(*cmd))
+ if (prepare(*cmd))
{
Conversation *conv = getTopFrame<Conversation>();
- if(conv)
+ if (conv)
{
promote(*conv);
- }
- else
- {
+ } else {
conv = new Conversation(*this);
push(*conv);
}
T *NaviFrameController::getTopFrame() const
{
auto items = getItems();
- for(auto item = items.rbegin(); item != items.rend(); ++item)
+ for (auto item = items.rbegin(); item != items.rend(); ++item)
{
T *frame = dynamic_cast<T*>(*item);
- if(frame)
+ if (frame)
return frame;
}
return nullptr;
void NaviFrameController::onHwBackButtonClicked()
{
auto *top = getTopFrame();
- if(top)
+ if (top)
pop(*top);
}
void NaviFrameController::onAppPause()
{
auto *top = getTopFrame();
- if(top)
+ if (top)
top->pause();
}
void NaviFrameController::onAppResume()
{
auto *top = getTopFrame();
- if(top)
+ if (top)
top->resume();
}
m_pList->show();
fillList();
- if(m_pList->getItemsCount() > 1)
+ if (m_pList->getItemsCount() > 1)
showSelectAllItem();
m_pList->checkAllItems(false);
{
MessageMmsRef mms = std::dynamic_pointer_cast<MessageMms>(getMsgEngine().getStorage().getMessage(m_Id));
const MsgPageList &pageList = mms->getPageList();
- for(int i = 0; i < pageList.getLength(); ++i)
+ for (int i = 0; i < pageList.getLength(); ++i)
{
const MsgMediaList &mediaList = pageList.at(i).getMediaList();
- for(int j = 0; j < mediaList.getLength(); ++j)
+ for (int j = 0; j < mediaList.getLength(); ++j)
{
MsgMedia::Type type = mediaList.at(j).getType();
- if(type != MsgMedia::TextType && type != MsgMedia::UnknownType)
+ if (type != MsgMedia::TextType && type != MsgMedia::UnknownType)
{
appendItem(mediaList.at(j).getFileName(), mediaList.at(j).getFilePath(), nullptr, this);
}
}
const MsgAttachmentList &attachmentList = mms->getAttachmentList();
- for(int i = 0; i < attachmentList.getLength(); ++i)
+ for (int i = 0; i < attachmentList.getLength(); ++i)
{
appendItem(attachmentList.at(i).getFileName(), attachmentList.at(i).getFilePath(), nullptr, this);
}
void SaveAttachments::updateSelectItemsTitle()
{
int checked = getAttachmentsCheckedCount();
- if(checked > 0)
+ if (checked > 0)
getNaviBar().setTitle(msgArgs("IDS_MSG_HEADER_PD_SELECTED_ABB3", checked));
else
getNaviBar().setTitle(msgt("IDS_MSG_HEADER_SELECT_ITEMS_ABB3"));
{
auto items = m_pList->getItems<SaveAttachmentsListItem>();
int count = 0;
- for(SaveAttachmentsListItem *item : items)
+ for (SaveAttachmentsListItem *item : items)
{
- if(item->isCheckable() && item->getCheckedState())
+ if (item->isCheckable() && item->getCheckedState())
++count;
}
return count;
void SaveAttachments::showSelectAllItem()
{
SelectAllListItem *item = dynamic_cast<SelectAllListItem*>(m_pList->getFirstItem());
- if(!item)
+ if (!item)
{
item = new SelectAllListItem;
m_pList->prependItem(*item);
void SaveAttachments::onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId)
{
- switch(buttonId)
+ switch (buttonId)
{
case NaviCancelButtonId:
onHwBackButtonClicked();
bool result = saveCheckedItems();
- if(result)
+ if (result)
notification_status_message_post(msg("IDS_MSG_TPOP_ATTACHMENTS_SAVED_IN_MY_FILES_DOWNLOADS").cStr());
else
showSavingFailedPopup();
void SaveAttachments::onListItemChecked(ListItem &listItem)
{
MSG_LOG("");
- if(SelectAllListItem *it = dynamic_cast<SelectAllListItem*>(&listItem))
+ if (SelectAllListItem *it = dynamic_cast<SelectAllListItem*>(&listItem))
checkSelectAllItem(*it);
else
checkItem(listItem);
void SaveAttachments::updateSelectAllItem()
{
- if(m_pList->getItems().size() > 1)
+ if (m_pList->getItems().size() > 1)
{
bool allChecked = areAllItemsChecked();
SelectAllListItem *selectAllItem = dynamic_cast<SelectAllListItem*>(m_pList->getFirstItem());
- if(selectAllItem)
+ if (selectAllItem)
selectAllItem->setCheckedState(allChecked, true);
}
}
ListItemCollection items = m_pList->getItems();
auto item = items.empty() ? items.begin() : ++items.begin();
- for(; item != items.end(); ++item)
+ for (; item != items.end(); ++item)
{
- if((*item)->isCheckable() && !(*item)->getCheckedState())
+ if ((*item)->isCheckable() && !(*item)->getCheckedState())
return false;
}
return true;
bool SaveAttachments::shouldEnableSaveBtn() const
{
ListItemCollection items = m_pList->getItems();
- for(auto *item : items)
+ for (auto *item : items)
{
- if(item->isCheckable() && item->getCheckedState())
+ if (item->isCheckable() && item->getCheckedState())
return true;
}
return false;
auto items = m_pList->getItems<SaveAttachmentsListItem>();
std::list<std::string> files;
- for(auto *item : items)
+ for (auto *item : items)
{
- if(item->isCheckable() && item->getCheckedState())
+ if (item->isCheckable() && item->getCheckedState())
files.push_back(item->getFilePath());
}
std::string SaveAttachmentsListItem::getText(ListItem &item, const char *part)
{
- if(!strcmp(part, namePart))
+ if (!strcmp(part, namePart))
return m_FileName;
return "";
ViewItemController::ViewItemController(BaseController *parent)
: BaseController(parent)
{
-
}
ViewItemController::~ViewItemController()
{
-
}
class MsgAttachment;
typedef std::shared_ptr<MsgAttachment> MsgAttachmentRef;
typedef MsgList<MsgAttachment> MsgAttachmentList;
- typedef std::shared_ptr<MsgList<MsgAttachment>>MsgAttachmentListRef;
+ typedef std::shared_ptr<MsgList<MsgAttachment>> MsgAttachmentListRef;
class MsgAttachment
{
virtual std::string getFileName() const = 0;
virtual int getFileSize() const = 0;
virtual std::string getMime() const = 0;
-
virtual void setFilePath(const std::string &path) = 0;
};
}
#else
messages_service_h m_MsgHandle;
#endif
-
};
}
Message::~Message()
{
-
}
MessageMms::~MessageMms()
{
-
}
MessageSMS::MessageSMS()
{
-
}
MessageSMS::~MessageSMS()
{
-
}
MsgConversationItem::~MsgConversationItem()
{
-
}
int MsgEngine::openService()
{
TRACE;
- if(m_MsgHandle)
+ if (m_MsgHandle)
{
MSG_LOG_ERROR("Handle already has been opened");
}
result = messages_open_service(&m_MsgHandle);
- /* if(result == MESSAGES_ERROR_NONE)
+ /* if (result == MESSAGES_ERROR_NONE)
{
m_Storage.reset(new MsgStorage(m_ServiceHandle));
}*/
int MsgEngine::closeService()
{
int result = 0;
- if(m_MsgHandle)
+ if (m_MsgHandle)
{
#ifdef TIZEN_PRIVATE_API
result = msg_close_msg_handle(&m_MsgHandle);
bool MsgEngine::isReady(std::string &errorMsg) const
{
#ifdef TIZEN_PRIVATE_API
- if(!m_MsgHandle)
+ if (!m_MsgHandle)
{
errorMsg = handleIsNullStr;
return false;
MsgSettings &MsgEngine::getSettings()
{
- if(!m_Settings.get())
+ if (!m_Settings.get())
m_Settings.reset(new MsgSettingsPrivate(m_MsgHandle));
return *m_Settings;
}
std::string MsgEngine::whatError(int error)
{
#ifdef TIZEN_PRIVATE_API
- switch(error)
+ switch (error)
{
case MSG_SUCCESS:
return "MSG_SUCCESS";
}
#else
- switch(error)
+ switch (error)
{
case MESSAGES_ERROR_NONE:
return "MESSAGES_ERROR_NONE";
int bytesInChar = 1;
textMetric.reset();
- if(!text.empty())
+ if (!text.empty())
{
- if(msg_util_calculate_text_length(text.c_str(), MSG_ENCODE_AUTO, &textLen, &segmentLen, &encode) != 0)
+ if (msg_util_calculate_text_length(text.c_str(), MSG_ENCODE_AUTO, &textLen, &segmentLen, &encode) != 0)
{
MSG_LOG_ERROR("msg_util_calculate_text_length returns error");
}
textMetric.bytes = textLen;
- switch(encode)
+ switch (encode)
{
case MSG_ENCODE_UCS2:
bytesInChar = 2;
segmentLen /= bytesInChar;
}
- if(segmentLen == 0)
+ if (segmentLen == 0)
segmentLen = encode == MSG_ENCODE_UCS2 ? maxUnicodeLen : maxGsm7Len;
- if(textLen == 0)
+ if (textLen == 0)
textLen = text.length() / bytesInChar;
textMetric.segmentsCount = (textLen / (segmentLen + 1)) + 1;
- if(textLen > 0)
+ if (textLen > 0)
textMetric.charsLeft = segmentLen - (textLen % (segmentLen + 1));
else
textMetric.charsLeft = maxGsm7Len;
MsgSettings::MsgSettings()
{
-
}
MsgSettings::~MsgSettings()
{
-
}
int MsgSettings::getMessageTextMaxChar() const
void MsgSettings::addListener(IMsgSettingsListener &listener)
{
auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener);
- if(itr == m_Listeners.end())
+ if (itr == m_Listeners.end())
{
m_Listeners.push_back(&listener);
}
void MsgSettings::removeListener(IMsgSettingsListener &listener)
{
auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener);
- if(itr != m_Listeners.end())
+ if (itr != m_Listeners.end())
{
m_Listeners.erase(itr);
}
void MsgStorage::addListener(IMsgStorageListener &listener)
{
auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener);
- if(itr == m_Listeners.end())
+ if (itr == m_Listeners.end())
{
m_Listeners.push_back(&listener);
}
void MsgStorage::removeListener(IMsgStorageListener &listener)
{
auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener);
- if(itr != m_Listeners.end())
+ if (itr != m_Listeners.end())
{
m_Listeners.erase(itr);
}
bool MsgStorage::hasEmail(ThreadId id)
{
- if(!id.isValid())
+ if (!id.isValid())
return false;
const MsgAddressListRef addressList = getAddressList(id);
- if(addressList)
+ if (addressList)
{
- for(int i = 0; i < addressList->getLength(); ++i)
+ for (int i = 0; i < addressList->getLength(); ++i)
{
const MsgAddress &msgAddr = addressList->at(i);
- if(msgAddr.getAddressType() == MsgAddress::Email)
+ if (msgAddr.getAddressType() == MsgAddress::Email)
return true;
- else if(MsgUtils::isValidEmail(msgAddr.getAddress()))
+ else if (MsgUtils::isValidEmail(msgAddr.getAddress()))
return true;
}
}
MsgThreadItem::~MsgThreadItem()
{
-
}
MsgTransport::MsgTransport()
{
-
}
MsgTransport::~MsgTransport()
{
-
}
MsgTransport::SendResult MsgTransport::sendMessage(MessageRef &msg, ThreadId *threadId)
std::string token;
MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType;
- while(begin != end)
+ while (begin != end)
{
- if(begin != std::string::npos)
+ if (begin != std::string::npos)
{
token = inputText.substr(begin, end != std::string::npos ? end-begin : std::string::npos);
begin = inputText.find_first_not_of(delimiters, end);
result.invalidResult.append(token);
addressType = getAddressType(result.invalidResult);
- if(addressType != MsgAddress::UnknownAddressType)
+ if (addressType != MsgAddress::UnknownAddressType)
{
result.validResults.push_back(std::make_pair(result.invalidResult, addressType));
result.invalidResult.clear();
- }
- else if(end != std::string::npos)
- {
+ } else if (end != std::string::npos) {
result.invalidResult.append(inputText.substr(end, begin != std::string::npos ? begin-end : std::string::npos));
}
end = inputText.find_first_of(delimiters, begin);
bool MsgUtils::isValidNumber(const std::string &address)
{
- if(address.empty())
+ if (address.empty())
return false;
std::regex numTemplate(numberRegex);
- return std::regex_match(address,numTemplate);
+ return std::regex_match(address, numTemplate);
}
bool MsgUtils::isValidEmail(const std::string &address)
{
- if(address.empty() || address.length() > emailAddrLenMax)
+ if (address.empty() || address.length() > emailAddrLenMax)
return false;
std::regex emailTemplate(emailRegex);
- return std::regex_match(address,emailTemplate);
+ return std::regex_match(address, emailTemplate);
}
bool MsgUtils::isValidAddress(const std::string &address)
MsgAddress::AddressType MsgUtils::getAddressType(const std::string &address)
{
- if(isValidNumber(address))
+ if (isValidNumber(address))
{
return MsgAddress::Phone;
}
- if(isValidEmail(address))
+ if (isValidEmail(address))
{
return MsgAddress::Email;
}
std::string MsgUtils::makeNormalizedNumber(const std::string &number)
{
std::string normalizedNumber;
- for(auto symbol : number)
+ for (auto symbol : number)
{
- if(isdigit(symbol) || symbol == '*' || symbol == '#' || symbol == '+')
+ if (isdigit(symbol) || symbol == '*' || symbol == '#' || symbol == '+')
{
normalizedNumber += symbol;
}
std::string MsgUtils::makeCleanedNumber(const std::string &number)
{
std::string cleanedNumber;
- for(auto symbol : number)
+ for (auto symbol : number)
{
- if(isdigit(symbol))
+ if (isdigit(symbol))
cleanedNumber += symbol;
}
return cleanedNumber;
bool MsgUtils::isMms(Message::Type type)
{
- switch(type)
+ switch (type)
{
case Message::MT_MMS:
case Message::MT_MMS_Noti:
{
const long long kb = 1024; // Bytes in kb
long long sizeKb = 0;
- if(bytes <= kb)
+ if (bytes <= kb)
{
sizeKb = 1;
- }
- else
- {
+ } else {
sizeKb = bytes / kb;
long long sizeB = bytes % kb;
- if(sizeB >= (kb / 2))
+ if (sizeB >= (kb / 2))
++sizeKb;
}
- return std::to_string(sizeKb) + " " + (std::string)msg("IDS_MSGF_BODY_MSGSIZE_KB");
+ return std::to_string(sizeKb) + " " + (std::string)msg("IDS_MSGF_BODY_MSGSIZE_KB");
}
, m_Page(false)
, m_Attachment(false)
{
- if(!m_MmsStruct)
+ if (!m_MmsStruct)
{
m_MmsStruct = msg_create_struct(MSG_STRUCT_MMS);
- if(msgStruct)
+ if (msgStruct)
{
msg_get_mms_struct(m_MsgStruct, m_MmsStruct);
}
MessageMmsPrivate::~MessageMmsPrivate()
{
- if(m_MmsStruct)
+ if (m_MmsStruct)
{
msg_release_struct(&m_MmsStruct);
}
std::string result;
int size = pageList.getLength();
- for(int i = 0; i < size; ++i)
+ for (int i = 0; i < size; ++i)
{
const MsgMediaList &mediaList = pageList.at(i).getMediaList();
int sizeList = mediaList.getLength();
- for(int j = 0; j < sizeList; ++j)
+ for (int j = 0; j < sizeList; ++j)
{
- if(mediaList[j].getType() == MsgMedia::TextType)
+ if (mediaList[j].getType() == MsgMedia::TextType)
{
std::string str = FileUtils::readTextFile(mediaList[j].getFilePath());
- if(!str.empty())
+ if (!str.empty())
{
- if(i > 0 && !result.empty())
+ if (i > 0 && !result.empty())
result.append("\n");
result += std::move(str);
int result = 0;
int size = pageList.getLength();
- for(int i = 0; i < size; ++i)
+ for (int i = 0; i < size; ++i)
{
const MsgMediaList &mediaList = pageList.at(i).getMediaList();
int sizeList = mediaList.getLength();
- for(int j = 0; j < sizeList; ++j)
+ for (int j = 0; j < sizeList; ++j)
{
- if(mediaList[j].getType() != MsgMedia::TextType && mediaList[j].getType() != MsgMedia::UnknownType)
+ if (mediaList[j].getType() != MsgMedia::TextType && mediaList[j].getType() != MsgMedia::UnknownType)
++result;
}
}
{
int msgSize = 0;
int res = msg_get_int_value(m_MmsStruct, MSG_MMS_HEADER_SIZE_INT, &msgSize); // Size in bytes
- if(res != MSG_SUCCESS || msgSize <= 0)
+ if (res != MSG_SUCCESS || msgSize <= 0)
msgSize = MessagePrivate::getSize();
return msgSize;
}
void MessagePrivate::addAddresses(const MsgAddressList &list)
{
int len = list.getLength();
- for(int i = 0; i < len; ++i)
+ for (int i = 0; i < len; ++i)
{
MsgAddressPrivate &newAddr = MessagePrivate::addAddress();
newAddr.setFields(list[i]);
std::string MessagePrivate::getText() const
{
- if(isMms())
+ if (isMms())
return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_MMS_TEXT_STR, MAX_MSG_TEXT_LEN);
else
return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_SMS_DATA_STR, MAX_MSG_DATA_LEN);
void MessagePrivate::setMessageStorageType(Message::MessageStorageType msgStorage)
{
- switch(msgStorage)
+ switch (msgStorage)
{
case Message::MS_Phone:
msg_set_int_value(m_MsgStruct, MSG_MESSAGE_STORAGE_ID_INT, MSG_STORAGE_PHONE);
void MessagePrivate::commit()
{
-
}
bool MessagePrivate::isMms() const
: MessagePrivate(release, msgStruct)
, MessageSMS()
{
-
}
MessageSMSPrivate::~MessageSMSPrivate()
: MsgStructPrivate(release, msgStruct)
, MsgAddress()
{
-
}
MsgAddressPrivate::~MsgAddressPrivate()
{
-
}
std::string MsgAddressPrivate::getAddress() const
MsgAttachmentPrivate::~MsgAttachmentPrivate()
{
-
}
std::string MsgAttachmentPrivate::getFilePath() const
int size = 0;
msg_get_int_value(m_MsgStruct, MSG_MMS_ATTACH_FILESIZE_INT, &size);
- if(size == 0)
+ if (size == 0)
{
MSG_LOG_WARN("File ", getFilePath(), " size = 0, trying to get real file size");
size = (int)FileUtils::getFileSize(getFilePath());
MsgComposerPrivate::MsgComposerPrivate()
{
-
}
MsgComposerPrivate::~MsgComposerPrivate()
{
-
}
MessageSMSRef MsgComposerPrivate::createSms()
{
MessageSMSRef smsRef;
msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
- if(msgInfo)
+ if (msgInfo)
{
msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS);
{
MessageMmsRef mmsRef;
msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
- if(msgInfo)
+ if (msgInfo)
{
msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS);
msg_struct_t mmsStruct = msg_create_struct(MSG_STRUCT_MMS);
: MsgStructPrivate(release, msgStruct)
, MsgConvMedia()
{
-
}
MsgConvMediaPrivate::~MsgConvMediaPrivate()
{
-
}
std::string MsgConvMediaPrivate::getMime() const
virtual std::string getThumbPath() const;
virtual std::string getContentId() const;
virtual std::string getContentLocation() const;
-
};
typedef class MsgListHandlePrivate<MsgConvMediaPrivate, MsgConvMedia> MsgConvMediaListHandlePrivate;
: MsgStructPrivate(release, msgStruct)
, m_MultipartList(false)
{
-
}
MsgConversationItemPrivate::~MsgConversationItemPrivate()
{
-
}
MsgId MsgConversationItemPrivate::getMsgId() const
virtual ~MsgListHandlePrivate()
{
- if(m_Release && m_List)
+ if (m_Release && m_List)
{
msg_list_free(m_List);
}
MsgMediaPrivate::~MsgMediaPrivate()
{
-
}
MsgMediaPrivate::Type MsgMediaPrivate::getType() const
{
msg_set_int_value(m_MsgStruct, MSG_MMS_MEDIA_TYPE_INT, MsgUtilsPrivate::smilTypeToNative(type));
- switch(type)
+ switch (type)
{
case ImageType:
case VideoType:
, m_MediaList(false)
, m_Media(false)
{
-
}
MsgPagePrivate::~MsgPagePrivate()
: MsgStructPrivate(release, msgStruct)
, MsgReport()
{
-
}
MsgReportPrivate::~MsgReportPrivate()
{
-
}
std::string MsgReportPrivate::getAddress() const
virtual ReadStatus getReadStatus() const;
virtual Type getType() const;
virtual time_t getTime() const;
-
};
typedef class MsgListHandlePrivate<MsgReportPrivate, MsgReport> MsgReportListHandlePrivate;
void MsgSettingsPrivate::finit()
{
- if(m_pActiveNotifJob)
+ if (m_pActiveNotifJob)
{
ecore_job_del(m_pActiveNotifJob);
- m_pActiveNotifJob= nullptr;
+ m_pActiveNotifJob = nullptr;
vconf_set_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, m_ActiveNotifValue);
MSG_LOG("ActiveNotifValue = ", m_ActiveNotifValue);
}
{
int res = 0;
msg_struct_t setting = msg_create_struct(MSG_STRUCT_SETTING_MSGSIZE_OPT);
- if(msg_get_msgsize_opt(m_ServiceHandle, setting) == 0)
+ if (msg_get_msgsize_opt(m_ServiceHandle, setting) == 0)
msg_get_int_value(setting, MSG_MESSAGE_SIZE_INT, &res);
msg_release_struct(&setting);
// Standard MMS has size 307200 bytes
const int kb = 1024;
- if(res > 0)
+ if (res > 0)
{
res *= kb;
res -= 5 * kb; // header size
- }
- else
- {
+ } else {
res = MAX_MSG_DATA_LEN * kb;
}
{
msg_set_int_value(m_GeneralOpt, MSG_GENERAL_RINGTONE_TYPE_INT, MsgUtilsPrivate::ringtoneTypeToNative(type));
msg_set_general_opt(m_ServiceHandle, m_GeneralOpt);
- for(auto listener: m_Listeners)
+ for (auto listener: m_Listeners)
{
listener->onRingtoneChanged(*this);
}
{
MsgUtilsPrivate::setStr(m_GeneralOpt, MSG_GENERAL_RINGTONE_PATH_STR, soundPath);
msg_set_general_opt(m_ServiceHandle, m_GeneralOpt);
- for(auto listener: m_Listeners)
+ for (auto listener: m_Listeners)
{
listener->onRingtoneChanged(*this);
}
void MsgSettingsPrivate::setMmsAutoRetr(bool value)
{
- int retrType= value ? MSG_HOME_AUTO_DOWNLOAD : MSG_HOME_MANUAL;
+ int retrType = value ? MSG_HOME_AUTO_DOWNLOAD : MSG_HOME_MANUAL;
msg_set_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_HOME_RETRIEVE_TYPE_INT, retrType);
msg_set_mms_recv_opt(m_ServiceHandle, m_MmsRecvOpt);
}
void MsgSettingsPrivate::addJobSetActiveNotifPolicy(int value)
{
m_ActiveNotifValue = value;
- if(!m_pActiveNotifJob)
+ if (!m_pActiveNotifJob)
{
m_pActiveNotifJob = ecore_job_add
(
vconf_set_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, self->m_ActiveNotifValue);
MSG_LOG("ActiveNotifValue = ", self->m_ActiveNotifValue);
},
- this
- );
+ this);
}
}
template <typename T>
void MsgStoragePrivate::notifyListeners(const T& delta, ListenerMethod<T> method)
{
- for(auto listener: m_Listeners)
+ for (auto listener: m_Listeners)
{
(listener->*method)(delta);
}
int count = pMsgIdList->nCount;
msgIdList.reserve(count);
- for(int i = 0; i < count; ++i)
+ for (int i = 0; i < count; ++i)
{
msgIdList.push_back(pMsgIdList->msgIdList[i]);
}
- switch(storageChangeType)
+ switch (storageChangeType)
{
case MSG_STORAGE_CHANGE_UPDATE:
self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageUpdate);
MsgStoragePrivate *self = static_cast<MsgStoragePrivate *>(user_param);
ThreadId tId = static_cast<ThreadId>(threadId);
- switch(storageChangeType)
+ switch (storageChangeType)
{
case MSG_STORAGE_CHANGE_UPDATE:
self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadUpdate);
int error = msg_get_thread_view_list(m_ServiceHandle, sortRule, &msgList);
msg_release_struct(&sortRule);
- if(error == 0)
+ if (error == 0)
{
res.reset(new MsgThreadStructListPrivate(true, msgList));
}
msg_set_int_value(listCond, MSG_LIST_CONDITION_SIM_INDEX_INT, 1);
msg_set_int_value(listCond, MSG_LIST_CONDITION_STORAGE_ID_INT, MSG_STORAGE_SIM);
- if(msg_get_message_list2(m_ServiceHandle, listCond, &msgList) == 0)
+ if (msg_get_message_list2(m_ServiceHandle, listCond, &msgList) == 0)
{
res.reset(new SmsStructListPrivate(true, msgList));
}
{
msg_thread_id_t id = ThreadId::invalidId;
- if(const MsgAddressListHandlePrivate *privateList = dynamic_cast<const MsgAddressListHandlePrivate*>(&addressList))
+ if (const MsgAddressListHandlePrivate *privateList = dynamic_cast<const MsgAddressListHandlePrivate*>(&addressList))
{
msg_list_handle_t handleList = *privateList;
msg_get_thread_id_by_address2(m_ServiceHandle, handleList, &id);
- }
- else if(const MsgAddressStructListPrivate *privateList = dynamic_cast<const MsgAddressStructListPrivate*>(&addressList))
- {
+ } else if (const MsgAddressStructListPrivate *privateList = dynamic_cast<const MsgAddressStructListPrivate*>(&addressList)) {
msg_struct_list_s msgStructList = *privateList;
msg_get_thread_id_by_address(m_ServiceHandle, &msgStructList, &id);
- }
- else
- {
+ } else {
assert(false);
}
msg_thread_id_t tid = ThreadId::invalidId;
msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
- if(msgInfo)
+ if (msgInfo)
{
- for(auto &addr : addressList)
+ for (auto &addr : addressList)
{
MsgAddress::AddressType type = MsgUtils::getAddressType(addr);
msg_struct_t tmpAddr = nullptr;
msg_list_handle_t addrList = nullptr;
msg_get_list_handle(msgInfo, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addrList);
- if(addrList)
+ if (addrList)
msg_get_thread_id_by_address2(m_ServiceHandle, addrList, &tid);
msg_release_struct(&msgInfo);
msg_struct_list_s searchList = {};
msg_error_t error = msg_search_message_for_thread_view(m_ServiceHandle, word.c_str(), &searchList);
- if(error != 0)
+ if (error != 0)
{
MSG_LOG_ERROR("msg_search_message_for_thread_view error ", error);
}
- if(error == 0)
+ if (error == 0)
res.reset(new MsgThreadStructListPrivate(true, searchList));
return res;
msg_get_thread_view_list(m_ServiceHandle, sortRule, &peerList);
msg_release_struct(&sortRule);
- for(int i = 0; i < peerList.nCount; i++)
+ for (int i = 0; i < peerList.nCount; i++)
{
int unreadCnt = 0;
msg_get_int_value(peerList.msg_struct_info[i], MSG_THREAD_UNREAD_COUNT_INT, &unreadCnt);
- if(unreadCnt > 0)
+ if (unreadCnt > 0)
unreadThreadCount++;
}
{
MsgThreadItemRef res;
msg_struct_t thread = msg_create_struct(MSG_STRUCT_THREAD_INFO);
- if(msg_get_thread(m_ServiceHandle, id, thread) == 0)
+ if (msg_get_thread(m_ServiceHandle, id, thread) == 0)
{
res.reset(new MsgThreadItemPrivate(true, thread));
}
msg_struct_list_s convList = {};
int error = msg_get_conversation_view_list(m_ServiceHandle, id, &convList);
- if(error == 0)
+ if (error == 0)
{
res.reset(new MsgConversationStructListPrivate(true, convList));
}
{
MsgConversationItemRef res;
msg_struct_t convItem = msg_create_struct(MSG_STRUCT_CONV_INFO);
- if(msg_get_conversation(m_ServiceHandle, id, convItem) == 0)
+ if (msg_get_conversation(m_ServiceHandle, id, convItem) == 0)
{
res.reset(new MsgConversationItemPrivate(true, convItem));
- }
- else
- {
+ } else {
msg_release_struct(&convItem);
}
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, id, msg, sendOpt) == 0)
+ if (msg_get_message(m_ServiceHandle, id, msg, sendOpt) == 0)
{
int nativeType = MSG_TYPE_INVALID;
msg_get_int_value(msg, MSG_MESSAGE_TYPE_INT, &nativeType);
msgRef = std::make_shared<MessageMmsPrivate>(true, msg);
else
msgRef = std::make_shared<MessageSMSPrivate>(true, msg);
- }
- else
- {
+ } else {
msg_release_struct(&msg);
}
msg_release_struct(&sendOpt);
MsgId MsgStoragePrivate::saveMessage(Message &msg, bool updateExisting, StorageResult *result)
{
- if(result)
+ if (result)
*result = StorageFail;
MsgId newMsgId;
msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false);
msgPriv.commit();
- if(msgPriv.getId().isValid() && updateExisting)
+ if (msgPriv.getId().isValid() && updateExisting)
{
int err = msg_update_message(m_ServiceHandle, msgPriv, sendOpt);
- if(result)
+ if (result)
*result = MsgUtilsPrivate::nativeToStorageResult(err);
- if(err == MSG_SUCCESS)
+ if (err == MSG_SUCCESS)
newMsgId = msg.getId();
- }
- else
- {
+ } else {
newMsgId = msg_add_message(m_ServiceHandle, msgPriv, sendOpt);
- if(newMsgId > 0)
+ if (newMsgId > 0)
{
int err = msg_move_msg_to_storage(m_ServiceHandle, newMsgId, msg.getMessageStorageType());
- if(result)
+ if (result)
*result = MsgUtilsPrivate::nativeToStorageResult(err);
- if(err != MSG_SUCCESS)
+ if (err != MSG_SUCCESS)
{
MSG_LOG_WARN("Can't move msg to storage, error = ", MsgEngine::whatError(err));
deleteMessage(newMsgId);
msg_id_list_s internalIdList;
internalIdList.nCount = idList.size();
- if(internalIdList.nCount <= 0)
+ if (internalIdList.nCount <= 0)
return false;
msg_message_id_t ids[internalIdList.nCount];
msg_error_t error = msg_get_message_list2(m_ServiceHandle, listCond, &searchList);
msg_release_struct(&listCond);
- if(error == 0)
+ if (error == 0)
res.reset(new MessageStructListPrivate(true, searchList));
return res;
msg_get_message(m_ServiceHandle, msgId, msgInfo, sendOpt);
msg_get_struct_handle(sendOpt, MSG_SEND_OPT_MMS_OPT_HND, &mmsSendOpt);
- if(mmsSendOpt)
+ if (mmsSendOpt)
msg_get_bool_value(mmsSendOpt, MSG_MMS_SENDOPTION_READ_REQUEST_BOOL, &readFlag);
msg_release_struct(&msgInfo);
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, id, msg, sendOpt) == 0)
+ if (msg_get_message(m_ServiceHandle, id, msg, sendOpt) == 0)
msg_get_int_value(msg, MSG_MESSAGE_THREAD_ID_INT, &threadId);
msg_release_struct(&msg);
virtual ~MsgStructListPrivate()
{
- if(m_Release && m_List.nCount)
+ if (m_Release && m_List.nCount)
{
msg_release_list_struct(&m_List);
}
inline MsgStructPrivate::~MsgStructPrivate()
{
- if(m_Release && m_MsgStruct)
+ if (m_Release && m_MsgStruct)
{
msg_release_struct(&m_MsgStruct);
}
: MsgStructPrivate(release, msgStruct)
, MsgThreadItem()
{
-
}
MsgThreadItemPrivate::~MsgThreadItemPrivate()
{
-
}
ThreadId MsgThreadItemPrivate::getId() const
: MsgTransport()
, m_ServiceHandle(serviceHandle)
{
-
}
MsgTransportPrivate::~MsgTransportPrivate()
{
-
}
MsgTransport::SendResult MsgTransportPrivate::sendMessage(Message &msg, ThreadId *threadId)
msg_set_struct_handle(req, MSG_REQUEST_MESSAGE_HND, privMsg);
- if(privMsg.isMms())
+ if (privMsg.isMms())
{
MSG_LOG("Sending MMS");
err = msg_mms_send_message(m_ServiceHandle, req);
- }
- else
- {
+ } else {
MSG_LOG("Sending SMS");
err = msg_sms_send_message(m_ServiceHandle, req);
}
- if(threadId)
+ if (threadId)
msg_get_thread_id_by_address2(m_ServiceHandle, privMsg.getAddressList(), (msg_thread_id_t*)threadId);
msg_release_struct(&req);
- MsgTransport::SendResult sendRes= MsgUtilsPrivate::nativeToSendResult(err);
+ MsgTransport::SendResult sendRes = MsgUtilsPrivate::nativeToSendResult(err);
MSG_LOG("Send result: ", sendRes);
return sendRes;
}
msg_release_struct(&sendOpt);
msg_release_struct(&req);
- MsgTransport::SendResult sendRes= MsgUtilsPrivate::nativeToSendResult(err);
+ MsgTransport::SendResult sendRes = MsgUtilsPrivate::nativeToSendResult(err);
MSG_LOG("Send result: ", sendRes);
return sendRes;
}
MsgTransport::SendResult MsgTransportPrivate::sendReadReport(MsgId msgId, MsgReport::ReadStatus status)
{
msg_error_t err = msg_mms_send_read_report(m_ServiceHandle, msgId, MsgUtilsPrivate::reportReadReportStatusToNative(status));
- MsgTransport::SendResult sendRes= MsgUtilsPrivate::nativeToSendResult(err);
+ MsgTransport::SendResult sendRes = MsgUtilsPrivate::nativeToSendResult(err);
MSG_LOG("Send result: ", sendRes);
return sendRes;
}
int MsgUtilsPrivate::directionToNative(Message::Direction direction)
{
- switch(direction)
+ switch (direction)
{
case Message::MD_Sent:
return MSG_DIRECTION_TYPE_MO;
Message::Direction MsgUtilsPrivate::nativeToDirection(int direction)
{
- switch(direction)
+ switch (direction)
{
case MSG_DIRECTION_TYPE_MO:
return Message::MD_Sent;
Message::MessageStorageType MsgUtilsPrivate::nativeToMessageStorage(int id)
{
- switch(id)
+ switch (id)
{
case MSG_STORAGE_PHONE:
return Message::MS_Phone;
int MsgUtilsPrivate::addressTypeToNative(MsgAddress::AddressType type)
{
- switch(type)
+ switch (type)
{
case MsgAddress::Phone:
return MSG_ADDRESS_TYPE_PLMN;
MsgAddress::AddressType MsgUtilsPrivate::nativeToAddressType(int type)
{
- switch(type)
+ switch (type)
{
case MSG_ADDRESS_TYPE_PLMN:
return MsgAddress::Phone;
MsgReport::DeliveryStatus MsgUtilsPrivate::nativeToReportDeliveryStatus(int status)
{
- switch(status)
+ switch (status)
{
case MSG_DELIVERY_REPORT_SUCCESS:
return MsgReport::StatusSuccess;
MsgReport::ReadStatus MsgUtilsPrivate::nativeToReportReadStatus(int status)
{
- switch(status)
+ switch (status)
{
case MSG_READ_REPORT_IS_READ:
return MsgReport::ReadStatusIsRead;
int MsgUtilsPrivate::reportReadReportStatusToNative(MsgReport::ReadStatus status)
{
- switch(status)
+ switch (status)
{
case MsgReport::ReadStatusIsRead:
return MSG_READ_REPORT_IS_READ;
MsgReport::Type MsgUtilsPrivate::nativeToReportType(int type)
{
- switch(type)
+ switch (type)
{
case MSG_REPORT_TYPE_READ:
return MsgReport::TypeRead;
int MsgUtilsPrivate::recipientTypeToNative(MsgAddress::RecipientType type)
{
- switch(type)
+ switch (type)
{
case MsgAddress::To:
return MSG_RECIPIENTS_TYPE_TO;
MsgAddress::RecipientType MsgUtilsPrivate::nativeToRecipientType(int type)
{
- switch(type)
+ switch (type)
{
case MSG_RECIPIENTS_TYPE_TO:
return MsgAddress::To;
Message::Type MsgUtilsPrivate::nativeToMessageType(int type)
{
- switch(type)
+ switch (type)
{
case MSG_TYPE_SMS:
case MSG_TYPE_SMS_CB:
MsgMedia::Type MsgUtilsPrivate::nativeToSmilType(int type)
{
- switch(type)
+ switch (type)
{
case MMS_SMIL_MEDIA_IMG:
return MsgMedia::ImageType;
int MsgUtilsPrivate::smilTypeToNative(MsgMedia::Type type)
{
- switch(type)
+ switch (type)
{
case MsgMedia::ImageType:
return MMS_SMIL_MEDIA_IMG;
{
std::string res;
char buf[maxStrLen + 1];
- if(msg_get_str_value(msgStruct, field, buf, maxStrLen) == 0)
+ if (msg_get_str_value(msgStruct, field, buf, maxStrLen) == 0)
{
res.assign(buf);
}
Message::NetworkStatus MsgUtilsPrivate::nativeToNetworkStatus(int status)
{
- switch(status)
+ switch (status)
{
case MSG_NETWORK_NOT_SEND:
return Message::NS_Not_Send;
int MsgUtilsPrivate::activeNotifPolicyToNative(MsgSettings::ActiveNotifPolicy policy)
{
- switch(policy)
+ switch (policy)
{
case MsgSettings::AppBackgroundPolicy:
return -1;
MsgTransport::SendResult MsgUtilsPrivate::nativeToSendResult(int sendRes)
{
- switch(sendRes)
+ switch (sendRes)
{
case MSG_SUCCESS:
return MsgTransport::SendSuccess;
MsgSettings::RingtoneType MsgUtilsPrivate::nativeToRingtoneType(int type)
{
- switch(type)
+ switch (type)
{
case MSG_RINGTONE_TYPE_SILENT:
return MsgSettings::SilentRingtone;
int MsgUtilsPrivate::ringtoneTypeToNative(MsgSettings::RingtoneType type)
{
- switch(type)
+ switch (type)
{
case MsgSettings::SilentRingtone:
return MSG_RINGTONE_TYPE_SILENT;
MsgStorage::StorageResult MsgUtilsPrivate::nativeToStorageResult(int resultCode)
{
MsgStorage::StorageResult res = MsgStorage::StorageFail;
- switch(resultCode)
+ switch (resultCode)
{
case MSG_SUCCESS:
res = MsgStorage::StorageSuccess;
SystemSettingsManager::~SystemSettingsManager()
{
- if(m_TelHandleList.handle != nullptr)
+ if (m_TelHandleList.handle != nullptr)
telephony_deinit(&m_TelHandleList);
deinitDpmHandle();
void SystemSettingsManager::prepareTel()
{
- if(m_TelHandleList.handle != nullptr)
+ if (m_TelHandleList.handle != nullptr)
return;
int err = telephony_init(&m_TelHandleList);
MSG_LOG("telephony_init = ", err);
void SystemSettingsManager::addListener(ISystemSettingsManager &l)
{
auto it = std::find(m_Listeners.begin(), m_Listeners.end(), &l);
- if(it == m_Listeners.end())
+ if (it == m_Listeners.end())
m_Listeners.push_back(&l);
}
void SystemSettingsManager::removeListener(ISystemSettingsManager&l)
{
auto it = std::find(m_Listeners.begin(), m_Listeners.end(), &l);
- if(it != m_Listeners.end())
+ if (it != m_Listeners.end())
m_Listeners.erase(it);
}
bool res = false;
const_cast<SystemSettingsManager*>(this)->prepareTel();
- if(m_TelHandleList.count > 0)
+ if (m_TelHandleList.count > 0)
{
telephony_h handle = m_TelHandleList.handle[0];
telephony_sim_state_e simState = TELEPHONY_SIM_STATE_UNAVAILABLE;
bool res = false;
const_cast<SystemSettingsManager*>(this)->prepareTel();
- if(m_TelHandleList.count > 0)
+ if (m_TelHandleList.count > 0)
{
telephony_h telHandle = m_TelHandleList.handle[0];
telephony_network_service_state_e servState;
- if(telephony_network_get_service_state(telHandle, &servState) == TELEPHONY_ERROR_NONE)
+ if (telephony_network_get_service_state(telHandle, &servState) == TELEPHONY_ERROR_NONE)
{
res = (servState == TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE);
MSG_LOG("servState = ", servState);
void SystemSettingsManager::onTimeFormatChanged()
{
- for(ISystemSettingsManager *it : m_Listeners)
+ for (ISystemSettingsManager *it : m_Listeners)
{
it->onTimeFormatChanged();
}
void SystemSettingsManager::onLanguageChanged()
{
- for(ISystemSettingsManager *it : m_Listeners)
+ for (ISystemSettingsManager *it : m_Listeners)
{
it->onLanguageChanged();
}
: m_pMsg(m_Buf)
{
va_list args;
- va_start (args, domainName);
+ va_start(args, domainName);
vsnprintf(m_Buf, maxBufSize, dgettext(domainName, stringId), args);
- va_end (args);
+ va_end(args);
}
const char *get() const
loggerImpl(LogPriority::WARN, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__);
#define MSG_ASSERT(expr, ...)\
- if(!(expr)) { MSG_LOG_ERROR(__VA_ARGS__); } \
+ if (!(expr)) { MSG_LOG_ERROR(__VA_ARGS__); } \
assert(expr)
#endif /* LOGGER_H_ */
{
std::ostringstream messageStr;
std::initializer_list<bool> { (messageStr << msg, true)... };
- dlog_print( static_cast<log_priority>(prior)
+ dlog_print(static_cast<log_priority>(prior)
, tag, "%s: %s(%d) -> %s", file, function, line
, messageStr.str().c_str());
}
~PhoneNumberUtils();
PhoneNumberUtils& operator=(PhoneNumberUtils&) = delete;
PhoneNumberUtils(PhoneNumberUtils&) = delete;
-
};
}
long long size = 0;
struct stat st = {};
- if(stat(file.c_str(), &st) == 0)
+ if (stat(file.c_str(), &st) == 0)
{
size = st.st_size;
}
bool ret = true;
f1 = fopen(src.c_str(), "rb");
- if(!f1)
+ if (!f1)
return false;
f2 = fopen(dst.c_str(), "wb");
- if(!f2)
+ if (!f2)
{
fclose(f1);
return false;
}
- while((num = fread(buf, 1, sizeof(buf), f1)) > 0)
+ while ((num = fread(buf, 1, sizeof(buf), f1)) > 0)
{
- if(fwrite(buf, 1, num, f2) != num)
+ if (fwrite(buf, 1, num, f2) != num)
{
ret = false;
}
std::string FileUtils::addFileToDataDir(const std::string &path)
{
std::string newPath;
- if(isExists(path))
+ if (isExists(path))
{
std::string dataPath = PathUtils::getDataPath("");
- if(path.find(dataPath) != std::string::npos)
+ if (path.find(dataPath) != std::string::npos)
{
newPath = path;
MSG_LOG("File is already exists: ", newPath);
- }
- else
- {
+ } else {
newPath = FileUtils::genUniqueFilePath(dataPath, path);
- if(!copy(path, newPath))
+ if (!copy(path, newPath))
newPath.clear();
}
}
{
auto pos = path.find_last_of('/');
- if(pos != std::string::npos)
+ if (pos != std::string::npos)
basePath = path.substr(0, pos + 1);
std::string name;
name = path.substr(pos + 1);
pos = name.find_last_of('.');
- if(pos != std::string::npos)
+ if (pos != std::string::npos)
{
extension = name.substr(pos + 1);
- if(pos != 0)
+ if (pos != 0)
fileName = name.substr(0, pos);
- }
- else
- {
+ } else {
fileName = name;
}
}
struct dirent *dirData = nullptr;
DIR *dp = opendir(path.c_str());
- if(dp)
+ if (dp)
{
- while(true)
+ while (true)
{
dirData = nullptr;
readdir_r(dp, &ep, &dirData);
- if(dirData == nullptr)
+ if (dirData == nullptr)
break;
- if(strcmp(dirData->d_name, ".") != 0 && strcmp(dirData->d_name, "..") != 0)
+ if (strcmp(dirData->d_name, ".") != 0 && strcmp(dirData->d_name, "..") != 0)
{
std::string child = path + "/" + dirData->d_name;
res &= remove(child, true);
}
closedir(dp);
- if(removeCurrentDir)
+ if (removeCurrentDir)
{
res &= rmdir(path.c_str()) == 0;
}
- }
- else
- {
+ } else {
res &= unlink(path.c_str()) == 0;
}
bool FileUtils::writeTextFile(const std::string &path, const std::string &text)
{
std::ofstream file(path, std::ofstream::trunc | std::ofstream::binary | std::ofstream::out);
- if(file.is_open())
+ if (file.is_open())
file << text;
return file.is_open() && file.good();
}
do
{
res = storagePath;
- if(res.back() != '/')
+ if (res.back() != '/')
res += '/';
res += name;
- if(i > 0)
+ if (i > 0)
res += "-" + std::to_string(i);
- if(!ext.empty())
+ if (!ext.empty())
res += '.' + ext;
++i;
- } while(isExists(res));
+ } while (isExists(res));
return res;
}
std::string name;
std::string ext;
splitPath(filePath, base, name, ext);
- if(!ext.empty())
+ if (!ext.empty())
{
char *mime = nullptr;
mime_type_get_mime_type(ext.c_str(), &mime);
- if(mime)
+ if (mime)
{
res = mime;
std::transform(res.begin(), res.end(), res.begin(), ::tolower);
std::string dowloadPath = PathUtils::getDownloadPath();
std::string filePathDst = FileUtils::genUniqueFilePath(dowloadPath, file);
- if(FileUtils::copy(file, filePathDst))
+ if (FileUtils::copy(file, filePathDst))
res = media_content_scan_file(filePathDst.c_str()) == MEDIA_CONTENT_ERROR_NONE;
return res;
bool FileUtils::saveFilesToStorage(const std::list<std::string> &files)
{
bool res = true;
- if(media_content_connect() != 0)
+ if (media_content_connect() != 0)
return false;
- for(const std::string &file : files)
+ for (const std::string &file : files)
{
res &= saveFileToStoragePrivate(file);
}
bool FileUtils::saveFileToStorage(const std::string &file)
{
- if(media_content_connect() != 0)
+ if (media_content_connect() != 0)
return false;
bool res = saveFileToStoragePrivate(file);
void IHwButtonListener::setHwButtonListener(Evas_Object * obj, IHwButtonListener *listener)
{
- if(listener)
+ if (listener)
{
setHwButtonListener(obj, nullptr);
eext_object_event_callback_add(obj, EEXT_CALLBACK_MORE, more_event_cb, listener);
eext_object_event_callback_add(obj, EEXT_CALLBACK_BACK, back_event_cb, listener);
- }
- else
- {
+ } else {
eext_object_event_callback_del(obj, EEXT_CALLBACK_MORE, more_event_cb);
eext_object_event_callback_del(obj, EEXT_CALLBACK_BACK, back_event_cb);
}
, m_File(file)
, m_Function(function)
{
- dlog_print( defaultPriority
+ dlog_print(defaultPriority
, m_Tag.c_str()
, enterFraseFormat.c_str()
, m_File.c_str()
LoggerImpl::~LoggerImpl()
{
- dlog_print( defaultPriority
+ dlog_print(defaultPriority
, m_Tag.c_str()
, leaveFraseFormat.c_str()
, m_File.c_str()
MetadataExtractor(const std::string &path)
: m_Metadata()
{
- if(FileUtils::isExists(path))
+ if (FileUtils::isExists(path))
{
metadata_extractor_create(&m_Metadata);
- if(metadata_extractor_set_path(m_Metadata, path.c_str()) != 0)
+ if (metadata_extractor_set_path(m_Metadata, path.c_str()) != 0)
{
metadata_extractor_destroy(m_Metadata);
m_Metadata = nullptr;
~MetadataExtractor()
{
- if(m_Metadata)
+ if (m_Metadata)
metadata_extractor_destroy(m_Metadata);
}
std::string res;
char *cStr = nullptr;
metadata_extractor_get_metadata(m_Metadata, attr, &cStr);
- if(cStr)
+ if (cStr)
{
res = cStr;
free(cStr);
std::string fileName = FileUtils::getFileName(path);
MetadataExtractor extractor(path);
- if(!extractor.isValid())
+ if (!extractor.isValid())
return fileName;
std::string title = extractor.getStr(METADATA_TITLE);
{
MetadataExtractor extractor(uri);
int duration = 0;
- if(extractor.isValid())
+ if (extractor.isValid())
{
duration = extractor.getInt(METADATA_DURATION);
MSG_LOG("Duration msec: ", duration);
MSG_LOG("File: ", uri);
MSG_LOG("Duration sec: ", sec);
- if(sec < 0)
+ if (sec < 0)
return 0;
return sec;
bool MediaUtils::getVideoFrame(const std::string &videoFilePath, const std::string &imageFilePath)
{
MetadataExtractor extractor(videoFilePath);
- if(!extractor.isValid())
+ if (!extractor.isValid())
return false;
int videoW = extractor.getInt(METADATA_VIDEO_WIDTH);
MSG_LOG("File: ", videoFilePath);
MSG_LOG("Frame: width = ", videoW, " height = ", videoH, " size = ", thumbSize);
- if(thumbnail)
+ if (thumbnail)
{
const int quality = 90; // JPEG image quality(1 ~ 100)
image_util_encode_h encode_h = {};
bool isOk = false;
isOk = image_util_encode_create(IMAGE_UTIL_JPEG, &encode_h) == IMAGE_UTIL_ERROR_NONE;
- if(!isOk)
+ if (!isOk)
{
free(thumbnail);
return false;
isOk &= image_util_encode_set_quality(encode_h, quality) == IMAGE_UTIL_ERROR_NONE;
isOk &= image_util_encode_set_input_buffer(encode_h, (unsigned char *)thumbnail) == IMAGE_UTIL_ERROR_NONE;
isOk &= image_util_encode_set_output_path(encode_h, imageFilePath.c_str()) == IMAGE_UTIL_ERROR_NONE;
- if(!isOk)
+ if (!isOk)
{
image_util_encode_destroy(encode_h);
free(thumbnail);
bool MediaUtils::getFrameSize(const std::string &videoFilePath, int &width, int &height)
{
MetadataExtractor extractor(videoFilePath);
- if(!extractor.isValid())
+ if (!extractor.isValid())
return false;
width = extractor.getInt(METADATA_VIDEO_WIDTH);
height = extractor.getInt(METADATA_VIDEO_HEIGHT);
int orient = extractor.getInt(METADATA_ROTATE);
- if(orient == 90 || orient == 270)
+ if (orient == 90 || orient == 270)
std::swap(width, height);
MSG_LOG("File: ", videoFilePath);
std::ofstream outputFile;
exifData = exif_data_new_from_file(imagePath.c_str());
- if(exifData)
+ if (exifData)
{
exif_data_save_data(exifData, &exifBuff, &exifBuffLen);
}
res = image_util_decode_create(&decode_h);
- if(res != IMAGE_UTIL_ERROR_NONE)
+ if (res != IMAGE_UTIL_ERROR_NONE)
{
return FileUtils::getFileSize(imagePath);
}
res = image_util_decode_set_input_path(decode_h, imagePath.c_str());
- if(res != IMAGE_UTIL_ERROR_NONE)
+ if (res != IMAGE_UTIL_ERROR_NONE)
{
image_util_decode_destroy(decode_h);
return FileUtils::getFileSize(imagePath);
}
res = image_util_decode_set_output_buffer(decode_h, &buffer);
- if(res != IMAGE_UTIL_ERROR_NONE)
+ if (res != IMAGE_UTIL_ERROR_NONE)
{
image_util_decode_destroy(decode_h);
return FileUtils::getFileSize(imagePath);
res = image_util_decode_run(decode_h, &width, &height, nullptr);
image_util_decode_destroy(decode_h);
- if(res != IMAGE_UTIL_ERROR_NONE)
+ if (res != IMAGE_UTIL_ERROR_NONE)
{
return FileUtils::getFileSize(imagePath);
}
res = image_util_encode_create(IMAGE_UTIL_JPEG, &encode_h);
- if(res != IMAGE_UTIL_ERROR_NONE)
+ if (res != IMAGE_UTIL_ERROR_NONE)
{
return FileUtils::getFileSize(imagePath);
}
res = image_util_encode_set_resolution(encode_h, width, height);
- if(res != IMAGE_UTIL_ERROR_NONE)
+ if (res != IMAGE_UTIL_ERROR_NONE)
{
image_util_encode_destroy(encode_h);
return FileUtils::getFileSize(imagePath);
}
res = image_util_encode_set_quality(encode_h, QUALITY);
- if(res != IMAGE_UTIL_ERROR_NONE)
+ if (res != IMAGE_UTIL_ERROR_NONE)
{
image_util_encode_destroy(encode_h);
return FileUtils::getFileSize(imagePath);
}
res = image_util_encode_set_input_buffer(encode_h, buffer);
- if(res != IMAGE_UTIL_ERROR_NONE)
+ if (res != IMAGE_UTIL_ERROR_NONE)
{
image_util_encode_destroy(encode_h);
return FileUtils::getFileSize(imagePath);
}
res = image_util_encode_set_output_buffer(encode_h, &jpegBuff);
- if(res != IMAGE_UTIL_ERROR_NONE)
+ if (res != IMAGE_UTIL_ERROR_NONE)
{
image_util_encode_destroy(encode_h);
return FileUtils::getFileSize(imagePath);
}
res = image_util_encode_run(encode_h, &jpegBuffLen);
image_util_encode_destroy(encode_h);
- if(res != IMAGE_UTIL_ERROR_NONE)
+ if (res != IMAGE_UTIL_ERROR_NONE)
{
free(buffer);
free(jpegBuff);
}
outputFile.open(imagePath.c_str());
- if(!outputFile.is_open())
+ if (!outputFile.is_open())
{
MSG_LOG_ERROR("Can't open file for write");
free(buffer);
free(jpegBuff);
return FileUtils::getFileSize(imagePath);
}
- if(exifData)
+ if (exifData)
{
// Write EXIF header
outputFile.write((char *)EXIF_HEADER, EXIF_HEADER_LEN);
outputFile.write((char *)jpegBuff + JPEG_HEADER_OFFSET, jpegBuffLen - JPEG_HEADER_OFFSET);
free(exifBuff);
exif_data_unref(exifData);
- }
- else
- {
+ } else {
// Write JPEG image data
outputFile.write((char *)jpegBuff, jpegBuffLen);
}
{
std::string res;
static std::string basePath;
- if(basePath.empty())
+ if (basePath.empty())
{
char *path = app_get_resource_path();
- if(path)
+ if (path)
{
basePath = path;
free(path);
{
std::string res;
static std::string basePath;
- if(basePath.empty())
+ if (basePath.empty())
{
char *path = app_get_data_path();
- if(path)
+ if (path)
{
basePath = path;
free(path);
{
std::string res;
char* resPath = app_get_resource_path();
- if(resPath)
+ if (resPath)
{
res = resPath;
free(resPath);
std::string PathUtils::getLocalePath()
{
std::string resPath(getResourcePath());
- if(!resPath.empty())
+ if (!resPath.empty())
{
resPath.append("locale");
}
static bool storageCb(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData)
{
- if(type == STORAGE_TYPE_INTERNAL)
+ if (type == STORAGE_TYPE_INTERNAL)
{
int *internalStorage = (int *)userData;
*internalStorage = storageId;
{
static std::string downloadPath;
- if(!downloadPath.empty())
+ if (!downloadPath.empty())
return downloadPath;
char *dirPath = nullptr;
int storageId = -1;
int error = storage_foreach_device_supported(storageCb, &storageId);
- if(error == STORAGE_ERROR_NONE)
+ if (error == STORAGE_ERROR_NONE)
storage_get_directory(storageId, STORAGE_DIRECTORY_DOWNLOADS, &dirPath);
- if(dirPath)
+ if (dirPath)
{
downloadPath = dirPath;
free(dirPath);
std::string res;
char *normalizedNum = nullptr;
phone_number_get_normalized_number(number.c_str(), &normalizedNum);
- if(normalizedNum)
+ if (normalizedNum)
{
res = normalizedNum;
free(normalizedNum);
{
const char *alignAsString(TextAlign align)
{
- switch(align)
+ switch (align)
{
case TextAlign::Center:
return "center";
, m_Align(align)
, m_Size(size)
{
-
}
TextStyle::~TextStyle()
std::string TextDecorator::highlightKeyword(std::string str, const std::string &searchWord, bool *foundRes)
{
- if(foundRes)
+ if (foundRes)
*foundRes = false;
- if(str.empty() || searchWord.empty())
+ if (str.empty() || searchWord.empty())
return std::move(str);
char *found = strcasestr((char*)str.c_str(), (char*)searchWord.c_str());
- if(!found)
+ if (!found)
return str;
- if(foundRes)
+ if (foundRes)
*foundRes = true;
std::string res;
m_ContactsMap.reserve(defaultCache);
m_OriginsMap.reserve(defaultCache);
- for(int i = 0; i <= maxStaticThumbId; i++)
+ for (int i = 0; i <= maxStaticThumbId; i++)
{
getThumbId((DefaultThumbs)i);
}
ThumbId ThumbnailMaker::getThumbIdFromFile(const std::string &path)
{
- if(path.empty())
+ if (path.empty())
{
return getThumbId(SingleThumb);
- }
- else
- {
+ } else {
auto it = m_ContactsMap.find(path);
- if(it != m_ContactsMap.end())
+ if (it != m_ContactsMap.end())
return it->second;
Evas_Object *origin = makeOriginThumb(m_App.getWindow(), path);
ThumbId ThumbnailMaker::getThumbId(DefaultThumbs thumb)
{
auto it = m_ContactsMap.find(defaultThumbsToStr(thumb));
- if(it != m_ContactsMap.end())
+ if (it != m_ContactsMap.end())
{
return it->second;
- }
- else
- {
+ } else {
Evas_Object *origin = nullptr;
- if(thumb != OwnerThumb)
+ if (thumb != OwnerThumb)
{
origin = makeDefaultOriginThumb(m_App.getWindow(), defaultThumbsToPath(thumb));
- }
- else
- {
+ } else {
ContactMyProfileRef ownerProfile = m_App.getContactManager().getOwnerProfile();
origin = ownerProfile ? makeOriginThumb(m_App.getWindow(), ownerProfile->getThumbnailPath()) :
makeDefaultOriginThumb(m_App.getWindow(), defaultThumbsToPath(SingleThumb));
Evas_Object *ThumbnailMaker::getThumb(Evas_Object *parent, ThumbId id, int thumbSize)
{
auto it = m_OriginsMap.find(id);
- if(it == m_OriginsMap.end())
+ if (it == m_OriginsMap.end())
{
MSG_LOG_ERROR("Invalid thumbnail id");
return nullptr;
// m_OriginsMap:
auto originsIt = m_OriginsMap.begin();
- for(; originsIt != m_OriginsMap.end();)
+ for (; originsIt != m_OriginsMap.end();)
{
- if(originsIt->first > maxStaticThumbId)
+ if (originsIt->first > maxStaticThumbId)
{
MSG_LOG(originsIt->first);
evas_object_del(originsIt->second);
originsIt = m_OriginsMap.erase(originsIt);
- }
- else
+ } else {
++originsIt;
+ }
}
// m_ContactsMap:
auto contactsIt = m_ContactsMap.begin();
- for(; contactsIt != m_ContactsMap.end();)
+ for (; contactsIt != m_ContactsMap.end();)
{
- if(contactsIt->second > maxStaticThumbId)
+ if (contactsIt->second > maxStaticThumbId)
contactsIt = m_ContactsMap.erase(contactsIt);
else
++contactsIt;
bool isToday = (curDay - msgDay == 0);
- if(isToday)
+ if (isToday)
{
const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? time24H : time12H;
return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime);
- }
- else
- {
+ } else {
bool notThisYear = (msgTimeTm.tm_year - curTimeTm.tm_year != 0);
const std::string &date = notThisYear ? dateListYear : dateListDefault;
return getFormattedDate(locale, getDateBestPattern(locale, date), msgTime);
int TimeUtils::getTimeFormat()
{
bool timeFormat = false;
- if(system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &timeFormat) < 0)
+ if (system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &timeFormat) < 0)
return TimeFormatUnknown;
return timeFormat ? TimeFormat24H : TimeFormat12H;
}
char *str = nullptr;
system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &str);
- if(str)
+ if (str)
{
i18n_ulocale_set_default(str);
res = str;
size_t i = res.find(".");
- if(i != std::string::npos)
+ if (i != std::string::npos)
res = res.substr(i);
free(str);
- }
- else
- {
+ } else {
res.clear();
}
return res;
if (len != -1)
{
buf[len] = '\0';
- }
- else
- {
+ } else {
MSG_LOG_ERROR("Getting default timezone failed, use system settings value");
std::string res;
char *time_zone = nullptr;
system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, &time_zone);
- if(time_zone)
+ if (time_zone)
{
res = time_zone;
free(time_zone);
MSG_LOG_ERROR("default timezone set error");
/* convert time_t to UDate, if it is */
- if(time)
+ if (time)
date = (i18n_udate)time * 1000;
else
i18n_ucalendar_get_now(&date);
dateFormat = getDateFormat(locale, uBestPattern, &status);
- if(status == I18N_ERROR_NONE)
+ if (status == I18N_ERROR_NONE)
{
/* get formatted string */
i18n_udate_format_date(dateFormat, date, formatted, formattedCapacity, nullptr, &formattedLength);
{
char *summary = nullptr;
calendar_record_get_str_p(record, _calendar_event.summary, &summary);
- if(summary)
+ if (summary)
m_Summary = summary;
calendar_time_s start = {};
- if(calendar_record_get_caltime(record, _calendar_event.start_time, &start) == 0)
+ if (calendar_record_get_caltime(record, _calendar_event.start_time, &start) == 0)
{
- if(start.type == CALENDAR_TIME_UTIME) // Unix time
+ if (start.type == CALENDAR_TIME_UTIME) // Unix time
{
m_StartDate = TimeUtils::makeCalEventString(start.time.utime);
- }
- else // Local time
- {
+ } else { // Local time
m_StartDate = TimeUtils::makeCalEventString
(
start.time.date.year,
start.time.date.mday,
start.time.date.hour,
start.time.date.minute,
- nullptr
- );
+ nullptr);
}
}
}
std::list<CalendarEvent> VCalendarParser::parse(const std::string &filePath)
{
- if(filePath.empty())
+ if (filePath.empty())
return {};
std::list<CalendarEvent> list;
calendar_list_get_count(records, &count);
calendar_list_first(records);
- for(int i = 0; i < count; ++i)
+ for (int i = 0; i < count; ++i)
{
calendar_record_h record = nullptr;
calendar_list_get_current_record_p(records, &record);
- if(record)
+ if (record)
{
char *viewUri = nullptr;
calendar_record_get_uri_p(record, &viewUri);
- if(viewUri && !strcmp(viewUri, _calendar_event._uri))
+ if (viewUri && !strcmp(viewUri, _calendar_event._uri))
list.emplace_back(record);
}
}
- if(records)
+ if (records)
calendar_list_destroy(records, true);
return list;
std::vector<T*> list;
list.reserve(elm_genlist_items_count(getEo()));
Elm_Object_Item *elmItem = elm_genlist_first_item_get(getEo());
- while(elmItem)
+ while (elmItem)
{
void *data = elm_object_item_data_get(elmItem);
- if(data)
+ if (data)
{
T *listItem = dynamic_cast<T*>(static_cast<ListItem*>(data));
- if(listItem)
+ if (listItem)
list.push_back(listItem);
}
elmItem = elm_genlist_item_next_get(elmItem);
{
next = getNextItem(*next);
res = dynamic_cast<T*>(next);
- } while(next && !res);
+ } while (next && !res);
return res;
}
{
prev = getPrevItem(*prev);
res = dynamic_cast<T*>(prev);
- } while(prev && !res);
+ } while (prev && !res);
return res;
}
inline void MbeRecipientItem::setDispName(const std::string &dispName)
{
m_DispName = dispName;
- if(getElmObjItem())
+ if (getElmObjItem())
setText(dispName);
}
}
};
public:
PopupList(Evas_Object *parent, PopupListType type = ListPopup);
- PopupList(PopupManager &parent, PopupListType type= ListPopup);
+ PopupList(PopupManager &parent, PopupListType type = ListPopup);
virtual ~PopupList();
/**
* @param[in] new popup owner
* @return popup created.
*/
- Popup &getPopup(void *newOwner = nullptr );
+ Popup &getPopup(void *newOwner = nullptr);
/**
* @brief Creates specific popup.
, m_pUserCb(userCb)
, m_pUserData(userData)
{
-
}
ContextPopupItem::~ContextPopupItem()
ContextPopupItem *newItem = new ContextPopupItem(*this, id, cb, userData);
Elm_Object_Item *elmItem = elm_ctxpopup_item_append(getEo(), text.c_str(), icon, on_item_pressed_cb, newItem);
- if(elmItem)
+ if (elmItem)
{
newItem->setElmObjItem(elmItem);
- }
- else
- {
+ } else {
delete newItem;
newItem = nullptr;
}
void ContextPopup::on_item_pressed_cb(void *data, Evas_Object *obj, void *event_info)
{
ContextPopupItem *item = static_cast<ContextPopupItem*>(data);
- if(item && item->m_pUserCb)
+ if (item && item->m_pUserCb)
item->m_pUserCb(*item, item->m_pUserData);
}
DefaultLayout::~DefaultLayout()
{
-
}
void DefaultLayout::setContent(Evas_Object *obj)
void DefaultLayout::showFloatingButton(bool show)
{
- if(show)
+ if (show)
{
View::setContent(m_pFloatingBtn, floatingPart, true);
evas_object_show(m_pFloatingBtn);
- }
- else
- {
+ } else {
View::unsetContent(floatingPart);
evas_object_hide(m_pFloatingBtn);
}
ListItemStyle::~ListItemStyle()
{
unregisterCallback();
- if(m_pGenlistItemClass)
+ if (m_pGenlistItemClass)
elm_genlist_item_class_free(m_pGenlistItemClass);
}
void ListItemStyle::setStyle(const char * itemStyle, const char * decorateItemStyle, const char * decorateAllItemStyle)
{
- if(!m_pGenlistItemClass)
+ if (!m_pGenlistItemClass)
return;
m_pGenlistItemClass->decorate_all_item_style = decorateAllItemStyle;
void ListItemStyle::registerCallback()
{
- if(!m_pGenlistItemClass)
+ if (!m_pGenlistItemClass)
return;
m_pGenlistItemClass->func.text_get = &ListItem::elm_gen_item_text_get_cb;
void ListItemStyle::unregisterCallback()
{
- if(!m_pGenlistItemClass)
+ if (!m_pGenlistItemClass)
return;
m_pGenlistItemClass->func.text_get = nullptr;
ListItem::ListItem(Elm_Genlist_Item_Type type)
: ListItem(ListItemStyleRef(), type)
{
-
}
ListItem::~ListItem()
{
ListItem *self = static_cast<ListItem*>(data);
- if(self)
+ if (self)
{
std::string text = self->getText(*self, part);
return text.empty() ? nullptr : strdup(text.c_str());
{
ListItem *self = static_cast<ListItem*>(data);
- if(!self)
+ if (!self)
return nullptr;
- if(self->getOwner()->getCheckMode())
+ if (self->getOwner()->getCheckMode())
{
const char *checkPart = self->getCheckPart(*self);
- if(checkPart && strcmp(checkPart, part) == 0)
+ if (checkPart && strcmp(checkPart, part) == 0)
{
return self->addCheck();
}
void ListItem::update()
{
- if(m_ItemStyle->m_pGenlistItemClass != elm_genlist_item_item_class_get(getElmObjItem()))
+ if (m_ItemStyle->m_pGenlistItemClass != elm_genlist_item_item_class_get(getElmObjItem()))
elm_genlist_item_item_class_update(getElmObjItem(), m_ItemStyle->m_pGenlistItemClass);
elm_genlist_item_update(getElmObjItem());
}
{
ListItem *self = static_cast<ListItem*>(data);
- if(self)
+ if (self)
self->onDelete(*self);
}
int res = 0;
ListItem *item1 = (ListItem*)elm_object_item_data_get((Elm_Object_Item*)data1);
ListItem *item2 = (ListItem*)elm_object_item_data_get((Elm_Object_Item*)data2);
- if(item1->m_pOwner->m_CmpFunc)
+ if (item1->m_pOwner->m_CmpFunc)
res = item1->m_pOwner->m_CmpFunc(*item1, *item2);
return res;
},
on_item_selected_cb,
- this
- );
+ this);
listItem.setElmObjItem(elmItem);
return elmItem != nullptr;
{
ListItemCollection list;
Elm_Object_Item *elmItem = elm_genlist_first_item_get(getEo());
- while(elmItem)
+ while (elmItem)
{
void *data = elm_object_item_data_get(elmItem);
MSG_ASSERT(data, "Genlist item data is NULL");
- if(data)
+ if (data)
{
ListItem *listItem = static_cast<ListItem *>(data);
list.push_back(listItem);
{
ListItemCollection collection;
Eina_List *list = elm_genlist_realized_items_get(getEo());
- if(list)
+ if (list)
{
void *obj = nullptr;
Eina_List *l = nullptr;
ListItem *item = ListItem::staticCast<ListItem*>(event_info);
MSG_ASSERT(item, "Item is null");
- if(item)
+ if (item)
{
ListView *owner = item->getOwner();
MSG_ASSERT(owner, "ListItem::owner is null");
- if(owner && owner->m_pListener)
+ if (owner && owner->m_pListener)
(owner->m_pListener->*method)(*item);
}
}
void ListView::checkAllItems(bool check, bool updateFullItem)
{
- for(ListItem *item: getItems())
+ for (ListItem *item: getItems())
{
item->setCheckedState(check, false);
}
if (updateFullItem)
updateRealizedItems();
else
- for(ListItem *item: getRealizedItems())
+ for (ListItem *item: getRealizedItems())
{
item->updateFields(item->getCheckPart(*item), ELM_GENLIST_ITEM_FIELD_ALL);
}
ListItem *item = ListItem::staticCast<ListItem*>(event_info);
item->setSelected(false);
- if(item->getOwner()->getCheckMode() && item->isCheckable())
+ if (item->getOwner()->getCheckMode() && item->isCheckable())
{
item->changeCheckedState(true);
notifyListener(data, obj, event_info, &IListViewListener::onListItemChecked);
- }
- else
- {
+ } else {
notifyListener(data, obj, event_info, &IListViewListener::onListItemSelected);
}
}
{
ListItem *item = ListItem::staticCast<ListItem*>(event_info);
item->setSelected(false);
- if(!item->getOwner()->getCheckMode())
+ if (!item->getOwner()->getCheckMode())
notifyListener(data, obj, event_info, &IListViewListener::onListItemLongPressed);
}
MbeRecipientsView::~MbeRecipientsView()
{
- if(m_pChangedJob)
+ if (m_pChangedJob)
{
ecore_job_del(m_pChangedJob);
m_pChangedJob = nullptr;
{
unsigned int res = 0;
const Eina_List* items = elm_multibuttonentry_items_get(getEo());
- if(items)
+ if (items)
res = eina_list_count(items);
return res;
}
std::vector<MbeRecipientItem*> res;
Elm_Object_Item *elmItem = elm_multibuttonentry_first_item_get(getEo());
- while(elmItem)
+ while (elmItem)
{
MbeRecipientItem *item = static_cast<MbeRecipientItem*>(elm_object_item_data_get(elmItem));
res.push_back(item);
void MbeRecipientsView::onMbeChanged(Evas_Object *obj, void *eventInfo)
{
- if(!m_pChangedJob)
+ if (!m_pChangedJob)
m_pChangedJob = ecore_job_add
(
[](void *data)
{
MbeRecipientsView *self = static_cast<MbeRecipientsView*>(data);
self->m_pChangedJob = nullptr;
- if(self->m_pListener)
+ if (self->m_pListener)
self->m_pListener->onMbeChanged();
},
- this
- );
+ this);
}
{
setContent(*m_pNaviBar, naviTitlePart);
evas_object_show(*m_pNaviBar);
- }
- else
- {
+ } else {
evas_object_hide(elm_object_item_part_content_unset(getElmObjItem(), naviTitlePart));
}
}
void NaviFrameItem::NaviBar::getButton(NaviButtonId id)
{
- if(!m_ButtonList[id].button)
+ if (!m_ButtonList[id].button)
{
Evas_Object *btn = elm_button_add(getEo());
m_ButtonList[id].button = btn;
void NaviFrameItem::NaviBar::showButton(NaviButtonId id, bool value)
{
- if(value)
+ if (value)
{
getButton(id);
- if(getContent(m_ButtonList[id].part) != m_ButtonList[id].button)
+ if (getContent(m_ButtonList[id].part) != m_ButtonList[id].button)
setContent(m_ButtonList[id].button, m_ButtonList[id].part);
setButtonColor(id, m_CurrentColor);
evas_object_show(m_ButtonList[id].button);
- }
- else
- {
- if(getContent(m_ButtonList[id].part) == m_ButtonList[id].button)
+ } else {
+ if (getContent(m_ButtonList[id].part) == m_ButtonList[id].button)
{
evas_object_del(m_ButtonList[id].button);
m_ButtonList[id].button = nullptr;
}
}
- switch(id)
+ switch (id)
{
case NaviCancelButtonId:
showCancelButtonPart(value);
{
elm_object_disabled_set(m_ButtonList[id].button, value);
- if(m_CurrentColor == NaviBlueColorId)
+ if (m_CurrentColor == NaviBlueColorId)
return;
TextStyle style;
void NaviFrameItem::NaviBar::showCancelButtonPart(bool value)
{
- if(value)
+ if (value)
{
emitSignal("cancel,show,btn", "*");
- }
- else if(getContent(cancelButtonPart) == nullptr)
- {
+ } else if (getContent(cancelButtonPart) == nullptr) {
emitSignal("left,clear", "*");
}
}
void NaviFrameItem::NaviBar::showOkButtonPart(bool value)
{
- if(value)
+ if (value)
emitSignal("done,show,btn", "*");
- else if(getContent(okButtonPart) == nullptr)
+ else if (getContent(okButtonPart) == nullptr)
emitSignal("right,clear", "*");
}
void NaviFrameItem::NaviBar::showPrevButtonPart(bool value)
{
- if(value)
+ if (value)
emitSignal("back,show,btn", "*");
- else if(getContent(prevButtonPart) == nullptr)
+ else if (getContent(prevButtonPart) == nullptr)
emitSignal("left,clear", "*");
- if(getContent(downButtonPart) == nullptr)
+ if (getContent(downButtonPart) == nullptr)
emitSignal("empty,right,show", "*");
}
void NaviFrameItem::NaviBar::showDownButtonPart(bool value)
{
- if(value)
+ if (value)
emitSignal("down,show,btn", "*");
- else if(getContent(downButtonPart) == nullptr)
+ else if (getContent(downButtonPart) == nullptr)
emitSignal("right,clear", "*");
}
void NaviFrameItem::NaviBar::setColor(NaviColorId id)
{
- switch(id)
+ switch (id)
{
case NaviBlueColorId:
emitSignal("title,color,blue", "*");
// Note that, button's color is opposite to title's color
TextStyle style;
- switch(m_CurrentColor)
+ switch (m_CurrentColor)
{
case NaviBlueColorId:
style.setColor(textColorWhiteTitleButtons);
// Note that, button's color is opposite to title's color
if (id == NaviPrevButtonId || id == NaviExpandButtonId)
{
- switch(titleColor)
+ switch (titleColor)
{
case NaviBlueColorId:
emitSignal(m_ButtonList[id].button, "button,color,white", "*");
default:
break;
}
- }
- else
- {
+ } else {
TextStyle style;
- switch(titleColor)
+ switch (titleColor)
{
case NaviBlueColorId:
style.setColor(textColorWhiteTitleButtons);
NaviFrameView::~NaviFrameView()
{
-
}
void NaviFrameView::create(Evas_Object *parent)
void NaviFrameView::pause()
{
NaviFrameItem *top = getTopFrame();
- if(top)
+ if (top)
onPause(*top);
}
void NaviFrameView::resume()
{
NaviFrameItem *top = getTopFrame();
- if(top)
+ if (top)
onResume(*top);
}
int NaviFrameView::getItemsCount() const
{
int res = 0;
- Eina_List *list= elm_naviframe_items_get(getEo());
- if(list)
+ Eina_List *list = elm_naviframe_items_get(getEo());
+ if (list)
{
res = eina_list_count(list);
eina_list_free(list);
NaviFrameItemList NaviFrameView::getItems() const
{
NaviFrameItemList result;
- Eina_List *list= elm_naviframe_items_get(getEo());
+ Eina_List *list = elm_naviframe_items_get(getEo());
- if(list)
+ if (list)
{
Eina_List *l = nullptr;
void *obj = nullptr;
void NaviFrameView::pop()
{
auto *topFrame = getTopFrame();
- if(topFrame)
+ if (topFrame)
pop(*topFrame);
}
{
// Workaround solution to avoid rejected JIRA issue: http://suprem.sec.samsung.net/jira/browse/TSAM-6776
item.m_IsPopping = true;
- if(getTransitionStatus())
+ if (getTransitionStatus())
{
m_ItemsToDelete.push_back(&item);
- }
- else
- {
- if(getTopFrame() == &item)
+ } else {
+ if (getTopFrame() == &item)
{
m_TransitionStatus = getItemsCount() > 1;
pause();
elm_naviframe_item_pop(getEo());
resume();
- }
- else
- {
+ } else {
pause();
item.destroy();
resume();
Elm_Object_Item *before = elm_naviframe_bottom_item_get(getEo());
Elm_Object_Item *insert = nullptr;
- if(before)
+ if (before)
{
insert = elm_naviframe_item_insert_before(getEo(), before, nullptr, nullptr, nullptr, nullptr, naviTitleStyleEmpty);
item.setElmObjItem(insert);
- }
- else
- {
+ } else {
m_TransitionStatus = !isEmpty();
pause();
insert = elm_naviframe_item_push(getEo(), nullptr, nullptr, nullptr, nullptr, naviTitleStyleEmpty);
void NaviFrameView::promote(NaviFrameItem &item)
{
bool isTop = &item == getTopFrame();
- if(!isTop)
+ if (!isTop)
{
m_TransitionStatus = true;
pause();
auto *transFinishedItem = ViewItem::staticCast<NaviFrameItem*>(eventInfo);
- for(NaviFrameItem *item: m_ItemsToDelete)
+ for (NaviFrameItem *item: m_ItemsToDelete)
{
- if(item == transFinishedItem)
+ if (item == transFinishedItem)
transFinishedItem = nullptr;
item->destroy();
}
m_ItemsToDelete.clear();
- if(transFinishedItem)
+ if (transFinishedItem)
transFinishedItem->onTransitionFinished(*transFinishedItem);
}
NoContentLayout::~NoContentLayout()
{
-
}
void NoContentLayout::setText(const TText &text)
Popup::~Popup()
{
MSG_LOG("Destructor");
- if(m_pShowIdler)
+ if (m_pShowIdler)
{
ecore_idler_del(m_pShowIdler);
m_pShowIdler = nullptr;
void Popup::destroy()
{
- if(m_pManager)
+ if (m_pManager)
m_pManager->reset();
else
View::destroy();
elm_object_style_set(btn, buttonStyle);
View::setContent(btn, ss.str().c_str());
- if(elm_object_part_content_get(getEo(), ss.str().c_str()))
+ if (elm_object_part_content_get(getEo(), ss.str().c_str()))
{
++m_CurrentButtonIndex;
evas_object_show(btn);
evas_object_data_set(btn, buttonCbDataKey, userData);
evas_object_smart_callback_add(btn, "clicked", on_button_clicked, this);
setText(btn, text);
- }
- else
- {
+ } else {
MSG_LOG_ERROR("Can't set content to part: ", ss.str());
evas_object_del(btn);
btn = nullptr;
void Popup::show(bool deferred)
{
- if(!deferred)
+ if (!deferred)
{
View::show();
- }
- else
- {
- if(!m_pShowIdler)
+ } else {
+ if (!m_pShowIdler)
{
m_pShowIdler = ecore_idler_add
(
self->View::show();
return false; // Delete idler
},
- this
- );
+ this);
}
}
}
void Popup::on_button_clicked(void *data, Evas_Object *obj, void *event_info)
{
PopupButtonCb cb = (PopupButtonCb)evas_object_data_get(obj, buttonCbKey);
- if(cb)
+ if (cb)
{
void *userData = evas_object_data_get(obj, buttonCbDataKey);
auto *popup = static_cast<Popup*>(data);
void Popup::on_popup_block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
auto *popup = static_cast<Popup*>(data);
- if(popup->m_OutsideTapDismiss)
+ if (popup->m_OutsideTapDismiss)
popup->destroy();
}
std::string PopupTextListItem::getText(ListItem &item, const char *part)
{
- if(strcmp(part, "elm.text") == 0)
+ if (strcmp(part, "elm.text") == 0)
return m_Text;
return std::string();
}
std::string PopupCheckListItem::getText(ListItem &item, const char *part)
{
- if(strcmp(part, "elm.text") == 0)
+ if (strcmp(part, "elm.text") == 0)
return m_Text;
return std::string();
}
void PopupManager::reset(void *popupOwner)
{
- if(!popupOwner || (popupOwner == m_pPopupOwner))
+ if (!popupOwner || (popupOwner == m_pPopupOwner))
{
- if(m_pPopup)
+ if (m_pPopup)
{
m_pPopup->View::destroy();
m_pPopup = nullptr;
void PopupManager::reset(Popup &popup, void *newOwner)
{
m_pPopupOwner = newOwner;
- if(&popup != m_pPopup)
+ if (&popup != m_pPopup)
{
reset();
eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, SMART_CALLBACK(PopupManager, onHwBackButtonPopupClicked), this);
std::string SelectAllListItem::getText(ListItem &item, const char *part)
{
- if(strcmp(part, textPart) == 0)
+ if (strcmp(part, textPart) == 0)
{
return msg("IDS_MSG_MBODY_SELECT_ALL");
}
void View::setEventCb(Evas_Callback_Type type)
{
Evas_Object_Event_Cb cb = getCb(type);
- if(cb)
+ if (cb)
{
evas_object_event_callback_add(m_pEo, type, cb, this);
- }
- else
- {
+ } else {
MSG_LOG_ERROR("Not implemented");
assert(false);
}
void View::setEo(Evas_Object *eo)
{
- if(m_pEo)
+ if (m_pEo)
{
MSG_LOG_ERROR("m_pEo not null");
assert(false);
}
m_pEo = eo;
- if(eo)
+ if (eo)
{
setData(this);
setEventCb(EVAS_CALLBACK_FREE);
void View::unsetEventCb(Evas_Callback_Type type)
{
Evas_Object_Event_Cb cb = getCb(type);
- if(cb)
+ if (cb)
{
evas_object_event_callback_del(m_pEo, type, cb);
- }
- else
- {
+ } else {
MSG_LOG_ERROR("Not implemented");
assert(false);
}
void View::on_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
View *view = static_cast<View*>(data);
- if(view)
+ if (view)
view->onViewDestroyed();
}
void View::on_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
View *view = static_cast<View*>(data);
- if(view)
+ if (view)
view->onBeforeDelete(*view);
}
void View::emitSignal(Evas_Object *obj, const char *emission, const char *source, bool async)
{
elm_object_signal_emit(obj, emission, source);
- if(!async)
+ if (!async)
processSignal(obj);
}
std::string Msg::markupToUtf8(const char *str)
{
- if(!str)
+ if (!str)
return std::string();
std::string res;
char *markup = elm_entry_markup_to_utf8(str);
- if(markup)
+ if (markup)
{
res = markup;
free(markup);
std::string Msg::utf8ToMarkup(const char *str)
{
- if(!str)
+ if (!str)
return std::string();
std::string res;
char *markup = elm_entry_utf8_to_markup(str);
- if(markup)
+ if (markup)
{
res = markup;
free(markup);